generated from homebridge/homebridge-plugin-template
-
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.
- Loading branch information
Showing
35 changed files
with
10,882 additions
and
1,950 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,3 @@ | ||
{ | ||
"path": "./node_modules/cz-conventional-changelog" | ||
} |
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
Binary file not shown.
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,38 @@ | ||
name: Release | ||
on: | ||
push: | ||
branches: | ||
- latest | ||
repository_dispatch: | ||
types: [semantic-release] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
issues: write | ||
pull-requests: write | ||
id-token: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: "lts/*" | ||
- name: Install dependencies | ||
run: npm clean-install | ||
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies | ||
run: npm audit signatures | ||
- name: Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: npx semantic-release |
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,14 @@ | ||
{ | ||
"branches": ["latest"], | ||
"plugins": [ | ||
"@semantic-release/commit-analyzer", | ||
"@semantic-release/release-notes-generator", | ||
"@semantic-release/npm", | ||
[ | ||
"@semantic-release/github", | ||
{ | ||
"assets": ["dist/**"] | ||
} | ||
] | ||
] | ||
} |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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,10 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -e | ||
|
||
CWD=$(dirname $(readlink -f "$0")) | ||
|
||
rm -f "$CWD"/*.js | ||
tsc -p "$CWD" | ||
chmod 744 "$CWD/schema2ts.js" | ||
node "$CWD/schema2ts.js" |
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,83 @@ | ||
import { join } from 'path'; | ||
import { exit, stdout } from 'process'; | ||
import { writeFile, readFile } from 'fs/promises'; | ||
import { compile, Options } from 'json-schema-to-typescript'; | ||
|
||
import { schema } from '../config.schema.json'; | ||
|
||
const configInterfaceName = 'ShortcutsButtonsUserConfig'; | ||
const moduleName = 'SchemaForm2Ts'; | ||
const outputRootPath = '/src/config.ts'; | ||
const outputRelativePath = join(__dirname, '../', outputRootPath); | ||
const prettierrcPath = join(__dirname, '../.prettierrc'); | ||
|
||
async function main(): Promise<void> { | ||
const config = await compile( | ||
schema as never, | ||
configInterfaceName, | ||
await getCompileOptions(), | ||
); | ||
|
||
await writeConfig(config); | ||
|
||
stdout.write( | ||
`🚀 ${moduleName}: Plugin configuration interface generated at ${outputRootPath}\n\n`, | ||
); | ||
|
||
exit(0); | ||
} | ||
|
||
async function getCompileOptions(): Promise<Partial<Options>> { | ||
let style: Options['style']; | ||
try { | ||
const prettierConfig = await readFile(prettierrcPath); | ||
style = await JSON.parse(prettierConfig.toString()); | ||
} catch (e) { | ||
throw new SchemaForm2TsError( | ||
`Unable to read Prettier configuration from ${prettierrcPath}`, | ||
e, | ||
); | ||
} | ||
|
||
return { | ||
additionalProperties: false, | ||
bannerComment: | ||
'/**\n* DO NOT EDIT MANUALLY.\n' + | ||
'* This file was automatically generated from `/config.schema.json`.\n' + | ||
'* Update the source schema file and run `schema2ts` to regenerate this file.\n*/', | ||
ignoreMinAndMaxItems: true, | ||
strictIndexSignatures: true, | ||
style, | ||
}; | ||
} | ||
|
||
async function writeConfig(config: string): Promise<void> { | ||
try { | ||
return await writeFile(outputRelativePath, config, { | ||
flag: 'w+', | ||
mode: 0o644, | ||
}); | ||
} catch (e) { | ||
throw new SchemaForm2TsError( | ||
`Unable to write output at ${outputRootPath}`, | ||
e, | ||
); | ||
} | ||
} | ||
|
||
@frozen | ||
class SchemaForm2TsError extends Error { | ||
constructor(message: string, exception: unknown) { | ||
require('source-map-support').install(); | ||
super(`${message}\n\n ${exception}\n`); | ||
Error.captureStackTrace(this, this.constructor); | ||
this.name = `💥 ${moduleName}`; | ||
} | ||
} | ||
|
||
function frozen(constructor: Function) { | ||
Object.freeze(constructor); | ||
Object.freeze(constructor.prototype); | ||
} | ||
|
||
(async (): Promise<void> => main()).call(null); |
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 @@ | ||
{ | ||
"compilerOptions": { | ||
"emitDecoratorMetadata": true, | ||
"experimentalDecorators": true, | ||
"inlineSourceMap": true, | ||
"noEmitOnError": true, | ||
"noImplicitAny": true, | ||
"noImplicitReturns": true, | ||
"noImplicitThis": true, | ||
"resolveJsonModule": true, | ||
"skipLibCheck": true, | ||
"strict": true | ||
}, | ||
"include": ["**/*.ts"], | ||
"exclude": ["**/*.spec.ts"] | ||
} |
Oops, something went wrong.