diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..f06235c --- /dev/null +++ b/.eslintignore @@ -0,0 +1,2 @@ +node_modules +dist diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..8aaf920 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,15 @@ +{ + "root": true, + "parser": "@typescript-eslint/parser", + "plugins": ["@typescript-eslint", "prettier"], + "extends": [ + "eslint:recommended", + "plugin:@typescript-eslint/eslint-recommended", + "plugin:@typescript-eslint/recommended", + "prettier" + ], + "rules": { + "no-console": 1, // Means warning + "prettier/prettier": 2 // Means error + } +} diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..79daf50 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,42 @@ +--- +name: Bug report +about: Create a report to help with improvements +title: '' +labels: bug +assignees: '' + +--- + + + +**Describe the bug** + + +**To Reproduce** + + +**Expected behavior** + + +**Screenshots** + + +**ADC-SystemStates.json** + + +**Homebridge System (please complete the following information):** +* **Node.js Version**: +* **NPM Version**: +* **Homebridge Version**: +* **Operating System**: Raspbian / Ubuntu / Debian / Windows / macOS / Docker +* **Process Supervisor**: Docker / Systemd / init.d / pm2 / launchctl / hb-service / other / none + +**Additional context** + diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..11fc491 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: enhancement +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. diff --git a/.github/stale.yml b/.github/stale.yml new file mode 100644 index 0000000..752d28f --- /dev/null +++ b/.github/stale.yml @@ -0,0 +1,18 @@ +# Number of days of inactivity before an issue becomes stale +daysUntilStale: 30 +# Number of days of inactivity before a stale issue is closed +daysUntilClose: 7 +# Issues with these labels will never be considered stale +exemptLabels: + - pinned + - security + - enhancement +# Label to use when marking an issue as stale +staleLabel: stale +# Comment to post when marking an issue as stale. Set to `false` to disable +markComment: > + This issue has been automatically marked as stale because it has not had + recent activity. It will be closed if no further activity occurs. +# Comment to post when closing a stale issue. Set to `false` to disable +closeComment: > + This issue has been automatically closed. diff --git a/.github/workflows/nodejs-beta.yml b/.github/workflows/nodejs-beta.yml new file mode 100644 index 0000000..15e3567 --- /dev/null +++ b/.github/workflows/nodejs-beta.yml @@ -0,0 +1,44 @@ +name: Node-CI Beta + +on: + push: + branches: [beta] + +jobs: + build: + strategy: + matrix: + node-version: [18.x, 20.x] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + - name: npm install, build # and test + run: | + npm ci + npm run build + # We don't yet have any tests setup + # npm test + env: + CI: true + + publish-npm: + if: github.repository == 'node-alarm-dot-com/homebridge-node-alarm-dot-com' + needs: build # only run if build succeeds + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 16 # use the minimum required version + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: node .github/workflows/prerelease.js + - run: npm --no-git-tag-version version pre --preid=beta + - run: npm publish --tag=beta + env: + NODE_AUTH_TOKEN: ${{secrets.npm_token}} diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml new file mode 100644 index 0000000..aa52525 --- /dev/null +++ b/.github/workflows/nodejs.yml @@ -0,0 +1,46 @@ +name: Node-CI + +on: + push: + branches: [master] + pull_request: + release: + types: [released] + +jobs: + build: + strategy: + matrix: + node-version: [18.x, 20.x] + os: [ubuntu-latest] + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + - name: npm install, build # and test + run: | + npm ci + npm run build + # We don't have tests (yet?) + # npm test + env: + CI: true + + publish-npm: + # publish only if we are on our own repo + if: github.repository == 'node-alarm-dot-com/homebridge-node-alarm-dot-com' && github.event_name == 'release' + needs: build # only run if build succeeds + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: 16 # use the minimum required version + registry-url: https://registry.npmjs.org/ + - run: npm ci + - run: npm publish + env: + NODE_AUTH_TOKEN: ${{ secrets.npm_token }} diff --git a/.github/workflows/prerelease.js b/.github/workflows/prerelease.js new file mode 100644 index 0000000..3dee6e4 --- /dev/null +++ b/.github/workflows/prerelease.js @@ -0,0 +1,35 @@ +#!/bin/env node + +const fs = require("fs"); +const semver = require("semver"); +const child_process = require("child_process"); + +const packageJSON = JSON.parse(fs.readFileSync("package.json", "utf8")); + +function getTagVersionFromNpm(tag) { + try { + return child_process.execSync(`npm info ${packageJSON.name} version --tag="${tag}"`).toString("utf8").trim(); + } catch (e) { + throw e; + } +} + +// betaVersion is a custom property we put into the package.json to indicate which release we want to tag +const projectBetaVersion = packageJSON.betaVersion; +if (!projectBetaVersion) { + throw new Error("Unable to calculate the next prerelease version. 'betaVersion' was not set in the package.json") +} + +const latestReleaseBeta = getTagVersionFromNpm("beta"); // like 0.7.0-beta.12 +const betaAsRelease = semver.inc(latestReleaseBeta, "patch"); // will produce 0.7.0 (needed for the equality check below) + +let publishTag; +if (semver.eq(projectBetaVersion, betaAsRelease)) { // check if we are releasing another version for the latest beta + publishTag = latestReleaseBeta; // set the current latest beta to be incremented +} else { + publishTag = projectBetaVersion; // start of with a new beta version +} + +// save the package.json +packageJSON.version = publishTag; +fs.writeFileSync("package.json", JSON.stringify(packageJSON, null, 2)); diff --git a/.gitignore b/.gitignore index e775959..46298c4 100644 --- a/.gitignore +++ b/.gitignore @@ -58,4 +58,15 @@ typings/ .env # Visual Studio cache/options directory -.vs/ \ No newline at end of file +.vs/ + +# Jetbrains user settings +.idea/ + +# VSCode user settings +.code-workspace +*.code-workspace + +dist/ +P/ +.DS_Store diff --git a/.jshintrc b/.jshintrc new file mode 100644 index 0000000..69df6fb --- /dev/null +++ b/.jshintrc @@ -0,0 +1,5 @@ +{ + "esversion": 6, + "asi": true, + "-W014": true +} \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..788805e --- /dev/null +++ b/.npmignore @@ -0,0 +1,2 @@ +tsconfig.json +src/ diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..6961e6e --- /dev/null +++ b/.prettierrc @@ -0,0 +1,6 @@ +{ + "semi": true, + "trailingComma": "none", + "singleQuote": true, + "printWidth": 120 +} \ No newline at end of file diff --git a/.run/Debug.run.xml b/.run/Debug.run.xml new file mode 100644 index 0000000..99473c5 --- /dev/null +++ b/.run/Debug.run.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/.run/watch.run.xml b/.run/watch.run.xml new file mode 100644 index 0000000..21d8e22 --- /dev/null +++ b/.run/watch.run.xml @@ -0,0 +1,29 @@ + + + + + +