-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15 from BottlecapDave/develop
New release
- Loading branch information
Showing
24 changed files
with
771 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
const bodySuffix = "---\nEnjoying the integration? Why not make a one time or monthly [GitHub sponsorship](https://github.com/sponsors/bottlecapdave)?" | ||
|
||
async function createGithubRelease(githubToken: string, githubOwnerRepo: string, tag: string, notes: string) { | ||
if (!githubToken) { | ||
throw new Error('Github token not specified'); | ||
} | ||
|
||
if (!githubOwnerRepo) { | ||
throw new Error('Github owner/repo not specified'); | ||
} | ||
|
||
if (!tag) { | ||
throw new Error('Tag not specified'); | ||
} | ||
|
||
if (!notes) { | ||
throw new Error('Notes not specified'); | ||
} | ||
|
||
console.log(`Publishing ${tag} release to ${githubOwnerRepo}`); | ||
|
||
const body = JSON.stringify({ | ||
tag_name: tag, | ||
name: tag, | ||
body: notes, | ||
draft: false, | ||
prerelease:false | ||
}); | ||
|
||
const response = await fetch( | ||
`https://api.github.com/repos/${githubOwnerRepo}/releases`, | ||
{ | ||
method: 'POST', | ||
headers: { | ||
"Accept": "application/vnd.github+json", | ||
"Authorization": `Bearer ${githubToken}`, | ||
"X-GitHub-Api-Version": "2022-11-28" | ||
}, | ||
body | ||
} | ||
); | ||
|
||
if (response.status >= 300) { | ||
throw new Error(response.statusText); | ||
} | ||
} | ||
|
||
createGithubRelease( | ||
process.env.GITHUB_TOKEN, | ||
process.env.GITHUB_REPOSITORY, | ||
process.argv[2], | ||
`${process.argv[3]}\n${bodySuffix}` | ||
).then(() => console.log('Success')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"compilerOptions": { | ||
"alwaysStrict": true, | ||
"module": "commonjs", | ||
"noImplicitAny": true, | ||
"removeComments": true, | ||
"preserveConstEnums": true, | ||
"sourceMap": true, | ||
|
||
}, | ||
"include": ["**/*"] | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { readFileSync, writeFileSync } from 'fs'; | ||
import { join } from 'path'; | ||
|
||
const filePath = join(__dirname, '../custom_components/first_bus/manifest.json'); | ||
|
||
function updateManifest(version: string) { | ||
|
||
const buffer = readFileSync(filePath); | ||
const content = JSON.parse(buffer.toString()); | ||
content.version = version; | ||
|
||
writeFileSync(filePath, JSON.stringify(content, null, 2)); | ||
console.log(`Updated version to '${version}'`); | ||
} | ||
|
||
updateManifest(process.argv[2]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import logging | ||
import re | ||
from ..const import CONFIG_BUSES, REGEX_BUSES | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
def merge_config(data: dict, options: dict, updated_config: dict = None): | ||
config = dict(data) | ||
if options is not None: | ||
config.update(options) | ||
|
||
if updated_config is not None: | ||
config.update(updated_config) | ||
|
||
if CONFIG_BUSES not in updated_config: | ||
del config[CONFIG_BUSES] | ||
|
||
_LOGGER.debug(f'data: {data}; options: {options}; updated_config: {updated_config};') | ||
|
||
return config | ||
|
||
def validate_config(config: dict): | ||
new_config = dict(config) | ||
errors = {} | ||
if CONFIG_BUSES in new_config and new_config[CONFIG_BUSES] is not None and len(new_config[CONFIG_BUSES]) > 0: | ||
matches = re.search(REGEX_BUSES, new_config[CONFIG_BUSES]) | ||
if (matches is None): | ||
errors[CONFIG_BUSES] = "invalid_buses" | ||
else: | ||
new_config[CONFIG_BUSES] = new_config[CONFIG_BUSES].split(",") | ||
else: | ||
new_config[CONFIG_BUSES] = [] | ||
|
||
return (errors, new_config) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.