@switchbot/homebridge-switchbot 4.3.1-beta.1 → 4.3.1-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,97 @@
1
+ #!/bin/env node
2
+
3
+ /**
4
+ * This scripts queries the npm registry to pull out the latest version for a given tag.
5
+ */
6
+
7
+ import assert from 'node:assert'
8
+ import child_process from 'node:child_process'
9
+ import fs from 'node:fs'
10
+ import process from 'node:process'
11
+
12
+ const BRANCH_VERSION_PATTERN = /^([A-Z]+)-(\d+\.\d+\.\d+)$/i
13
+
14
+ // Load the contents of the package.json file
15
+ const packageJSON = JSON.parse(fs.readFileSync('package.json', 'utf8'))
16
+
17
+ const refArgument = process.argv[2]
18
+ const tagArgument = process.argv[3] || 'latest'
19
+
20
+ if (!refArgument) {
21
+ console.error('ref argument is missing')
22
+ console.error('Usage: npm-version-script-esm.js <ref> [tag]')
23
+ process.exit(1)
24
+ }
25
+
26
+ /**
27
+ * Queries the NPM registry for the latest version for the provided base version and tag.
28
+ * If the tag is latest, then the base version is returned if it exists. For other tags, the latest
29
+ * version found for that base version and tag is returned.
30
+ * @param baseVersion The base version to query for, e.g. 2.0.0
31
+ * @param tag The tag to query for, e.g. beta or latest
32
+ * @returns {string} Returns the version, or '' if not found
33
+ */
34
+ function getTagVersionFromNpm(baseVersion, tag) {
35
+ try {
36
+ return JSON.parse(child_process.execSync(`npm info ${packageJSON.name} versions --json`).toString('utf8').trim())
37
+ .filter(v => tag === 'latest' ? v === baseVersion : v.startsWith(`${baseVersion}-${tag}.`)) // find all published versions for this base version and tag
38
+ .reduce((_, current) => current, '') // choose the last as they're sorted in ascending order, or '' if there are none
39
+ } catch (e) {
40
+ console.error(`Failed to query the npm registry for the latest version for tag: ${tag}`, e)
41
+ // throw e;
42
+ return ''
43
+ }
44
+ }
45
+
46
+ function desiredTargetVersion(ref) {
47
+ // ref is a GitHub action ref string
48
+ if (ref.startsWith('refs/pull/')) {
49
+ throw new Error('The version script was executed inside a PR!')
50
+ }
51
+
52
+ assert(ref.startsWith('refs/heads/'))
53
+ const branchName = ref.slice('refs/heads/'.length)
54
+
55
+ const results = branchName.match(BRANCH_VERSION_PATTERN)
56
+ if (results !== null) {
57
+ if (results[1] !== tagArgument) {
58
+ console.warn(`The base branch name (${results[1]}) differs from the tag name ${tagArgument}`)
59
+ }
60
+
61
+ return results[2]
62
+ }
63
+
64
+ throw new Error(`Malformed branch name for ref: ${ref}. Can't derive the base version. Use a branch name like: beta-x.x.x or alpha-x.x.x`)
65
+ }
66
+
67
+ // derive the base version from the branch ref
68
+ const baseVersion = desiredTargetVersion(refArgument)
69
+
70
+ // query the npm registry for the latest version of the provided tag name
71
+ const latestReleasedVersion = getTagVersionFromNpm(baseVersion, tagArgument) // e.g. 0.7.0-beta.12
72
+
73
+ let publishTag
74
+
75
+ if (latestReleasedVersion) {
76
+ console.warn(`Latest published version for ${baseVersion} with tag ${tagArgument} is ${latestReleasedVersion}`)
77
+ publishTag = latestReleasedVersion // set this released beta or alpha to be incremented
78
+ } else {
79
+ console.warn(`No published versions for ${baseVersion} with tag ${tagArgument}`)
80
+ publishTag = baseVersion // start off with a new beta or alpha version
81
+ }
82
+
83
+ if (packageJSON.version !== publishTag) {
84
+ // report the change for CI
85
+ console.warn(`Changing version in package.json from ${packageJSON.version} to ${publishTag}`)
86
+
87
+ // save the package.json
88
+ packageJSON.version = publishTag
89
+ fs.writeFileSync('package.json', JSON.stringify(packageJSON, null, 2))
90
+
91
+ // perform the same change to the package-lock.json
92
+ const packageLockJSON = JSON.parse(fs.readFileSync('package-lock.json', 'utf8'))
93
+ packageLockJSON.version = publishTag
94
+ fs.writeFileSync('package-lock.json', JSON.stringify(packageLockJSON, null, 2))
95
+ } else {
96
+ console.warn(`Leaving version in package.json at ${packageJSON.version}`)
97
+ }
@@ -22,7 +22,7 @@ jobs:
22
22
  if: ${{ github.repository == 'OpenWonderLabs/homebridge-switchbot' }}
23
23
  permissions:
24
24
  id-token: write
25
- uses: OpenWonderLabs/.github/.github/workflows/npm-publish.yml@latest
25
+ uses: OpenWonderLabs/.github/.github/workflows/npm-publish-esm.yml@latest
26
26
  with:
27
27
  tag: 'beta'
28
28
  dynamically_adjust_version: true
@@ -17,7 +17,7 @@ jobs:
17
17
  if: ${{ github.repository == 'OpenWonderLabs/homebridge-switchbot' }}
18
18
  permissions:
19
19
  id-token: write
20
- uses: OpenWonderLabs/.github/.github/workflows/npm-publish.yml@latest
20
+ uses: OpenWonderLabs/.github/.github/workflows/npm-publish-esm.yml@latest
21
21
  secrets:
22
22
  npm_auth_token: ${{ secrets.npm_token }}
23
23
 
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import { describe, expect, it, vi } from 'vitest';
2
+ import registerPlatform from './index.js';
3
+ import { SwitchBotPlatform } from './platform.js';
4
+ import { PLATFORM_NAME, PLUGIN_NAME } from './settings.js';
5
+ describe('index.ts', () => {
6
+ it('should register the platform with homebridge', () => {
7
+ const api = {
8
+ registerPlatform: vi.fn(),
9
+ };
10
+ registerPlatform(api);
11
+ expect(api.registerPlatform).toHaveBeenCalledWith(PLUGIN_NAME, PLATFORM_NAME, SwitchBotPlatform);
12
+ });
13
+ });
14
+ //# sourceMappingURL=index.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.test.js","sourceRoot":"","sources":["../src/index.test.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAEjD,OAAO,gBAAgB,MAAM,YAAY,CAAA;AACzC,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAA;AACjD,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE1D,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACxB,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACtD,MAAM,GAAG,GAAG;YACV,gBAAgB,EAAE,EAAE,CAAC,EAAE,EAAE;SACR,CAAA;QAEnB,gBAAgB,CAAC,GAAG,CAAC,CAAA;QAErB,MAAM,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC,oBAAoB,CAAC,WAAW,EAAE,aAAa,EAAE,iBAAiB,CAAC,CAAA;IAClG,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
@@ -1,2 +1,2 @@
1
1
  <!DOCTYPE html><html class="default" lang="en" data-base=".."><head><style>body { visibility: hidden; }</style><meta charset="utf-8"><meta http-equiv="x-ua-compatible" content="IE=edge"><title>default | @switchbot/homebridge-switchbot</title><meta name="description" content="Documentation for @switchbot/homebridge-switchbot"><meta name="viewport" content="width=device-width, initial-scale=1"><link rel="stylesheet" href="../assets/style.css"><link rel="stylesheet" href="../assets/highlight.css"><script defer="" src="../assets/main.js"></script><script async="" src="../assets/icons.js" id="tsd-icons-script"></script><link rel="stylesheet" href="../assets/dmt/dmt-components.css"><link rel="stylesheet" href="../assets/dmt/dmt-theme.css"><script src="../assets/dmt/dmt-components.js" type="module"></script><noscript><style>body { visibility: visible; }</style></noscript></head><body><script>document.documentElement.dataset.theme = localStorage.getItem("tsd-theme") || "os";</script><div class="overlay"></div>
2
- <main><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search"><div class="field" id="dmt-search-main"></div><div class="field" id="dmt-toolbar"><a href="../index.html" class="title">@switchbot/homebridge-switchbot</a></div></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main" tabindex="-1"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"></ul><div class="dmt-title-header-flex"><h1>Function default</h1></div></div><section class="tsd-panel"><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="default" class="tsd-anchor"></a><span class="tsd-kind-call-signature">default</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">api</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">API</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">void</span><a href="#default" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">api</span>: <span class="tsd-signature-type">API</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/OpenWonderLabs/homebridge-switchbot/blob/92317be236d295931222e0c4f0d5208738450461/src/index.ts#L11">index.ts:11</a></li></ul></aside></li></ul></section></div><div class="col-sidebar" tabindex="-1"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked=""><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu" tabindex="-1"><nav class="tsd-navigation"><a href="../modules.html">@switchbot/homebridge-switchbot</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"></ul></nav></div></div></div></main></body></html>
2
+ <main><header class="tsd-page-toolbar"><div class="tsd-toolbar-contents container"><div class="table-cell" id="tsd-search"><div class="field" id="dmt-search-main"></div><div class="field" id="dmt-toolbar"><a href="../index.html" class="title">@switchbot/homebridge-switchbot</a></div></div><div class="table-cell" id="tsd-widgets"><a href="#" class="tsd-widget tsd-toolbar-icon menu no-caption" data-toggle="menu" aria-label="Menu"><svg width="16" height="16" viewBox="0 0 16 16" fill="none"><use href="../assets/icons.svg#icon-menu"></use></svg></a></div></div></header><div class="container container-main" tabindex="-1"><div class="col-content"><div class="tsd-page-title"><ul class="tsd-breadcrumb"></ul><div class="dmt-title-header-flex"><h1>Function default</h1></div></div><section class="tsd-panel"><ul class="tsd-signatures"><li class="tsd-signature tsd-anchor-link"><a id="default" class="tsd-anchor"></a><span class="tsd-kind-call-signature">default</span><span class="tsd-signature-symbol">(</span><span class="tsd-kind-parameter">api</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">API</span><span class="tsd-signature-symbol">)</span><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">void</span><a href="#default" aria-label="Permalink" class="tsd-anchor-icon"><svg viewBox="0 0 24 24"><use href="../assets/icons.svg#icon-anchor"></use></svg></a></li><li class="tsd-description"><div class="tsd-parameters"><h4 class="tsd-parameters-title">Parameters</h4><ul class="tsd-parameter-list"><li><span><span class="tsd-kind-parameter">api</span>: <span class="tsd-signature-type">API</span></span></li></ul></div><h4 class="tsd-returns-title">Returns <span class="tsd-signature-type">void</span></h4><aside class="tsd-sources"><ul><li>Defined in <a href="https://github.com/OpenWonderLabs/homebridge-switchbot/blob/7f316898a707cbc28d21a4a6638678032b74c0a3/src/index.ts#L11">index.ts:11</a></li></ul></aside></li></ul></section></div><div class="col-sidebar" tabindex="-1"><div class="page-menu"><div class="tsd-navigation settings"><details class="tsd-accordion"><summary class="tsd-accordion-summary"><h3><svg width="20" height="20" viewBox="0 0 24 24" fill="none"><use href="../assets/icons.svg#icon-chevronDown"></use></svg>Settings</h3></summary><div class="tsd-accordion-details"><div class="tsd-filter-visibility"><span class="settings-label">Member Visibility</span><ul id="tsd-filter-options"><li class="tsd-filter-item"><label class="tsd-filter-input"><input type="checkbox" id="tsd-filter-inherited" name="inherited" checked=""><svg width="32" height="32" viewBox="0 0 32 32" aria-hidden="true"><rect class="tsd-checkbox-background" width="30" height="30" x="1" y="1" rx="6" fill="none"></rect><path class="tsd-checkbox-checkmark" d="M8.35422 16.8214L13.2143 21.75L24.6458 10.25" stroke="none" stroke-width="3.5" stroke-linejoin="round" fill="none"></path></svg><span>Inherited</span></label></li></ul></div><div class="tsd-theme-toggle"><label class="settings-label" for="tsd-theme">Theme</label><select id="tsd-theme"><option value="os">OS</option><option value="light">Light</option><option value="dark">Dark</option></select></div></div></details></div></div><div class="site-menu" tabindex="-1"><nav class="tsd-navigation"><a href="../modules.html">@switchbot/homebridge-switchbot</a><ul class="tsd-small-nested-navigation" id="tsd-nav-container"></ul></nav></div></div></div></main></body></html>
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@switchbot/homebridge-switchbot",
3
3
  "displayName": "SwitchBot",
4
4
  "type": "module",
5
- "version": "4.3.1-beta.1",
5
+ "version": "4.3.1-beta.3",
6
6
  "description": "The SwitchBot plugin allows you to access your SwitchBot device(s) from HomeKit.",
7
7
  "author": "SwitchBot <support@wondertechlabs.com> (https://github.com/SwitchBot)",
8
8
  "contributors": [
@@ -82,31 +82,31 @@
82
82
  "@homebridge/plugin-ui-utils": "^2.0.1",
83
83
  "async-mqtt": "^2.6.3",
84
84
  "fakegato-history": "^0.6.5",
85
- "homebridge-lib": "^7.1.2",
86
- "node-switchbot": "^3.4.9",
85
+ "homebridge-lib": "^7.1.3",
86
+ "node-switchbot": "^3.5.0-beta.4",
87
87
  "rxjs": "^7.8.1"
88
88
  },
89
89
  "devDependencies": {
90
- "@antfu/eslint-config": "^3.16.0",
90
+ "@antfu/eslint-config": "^4.1.1",
91
91
  "@types/aes-js": "^3.1.4",
92
92
  "@types/debug": "^4.1.12",
93
93
  "@types/fs-extra": "^11.0.4",
94
94
  "@types/mdast": "^4.0.4",
95
- "@types/node": "^22.10.7",
95
+ "@types/node": "^22.13.1",
96
96
  "@types/semver": "^7.5.8",
97
97
  "@types/source-map-support": "^0.5.10",
98
98
  "@typhonjs-typedoc/typedoc-theme-dmt": "^0.3.1",
99
- "@vitest/coverage-v8": "^3.0.0",
99
+ "@vitest/coverage-v8": "^3.0.5",
100
100
  "eslint": "^9.19.0",
101
101
  "eslint-plugin-format": "^1.0.1",
102
102
  "homebridge": "^1.8.5",
103
- "homebridge-config-ui-x": "4.68.0",
103
+ "homebridge-config-ui-x": "4.69.0",
104
104
  "nodemon": "^3.1.9",
105
105
  "shx": "^0.3.4",
106
106
  "ts-node": "^10.9.2",
107
107
  "typedoc": "^0.27.6",
108
108
  "typescript": "^5.7.3",
109
- "vitest": "^3.0.0"
109
+ "vitest": "^3.0.5"
110
110
  },
111
111
  "directories": {
112
112
  "doc": "docs"
@@ -0,0 +1,19 @@
1
+ import type { API } from 'homebridge'
2
+
3
+ import { describe, expect, it, vi } from 'vitest'
4
+
5
+ import registerPlatform from './index.js'
6
+ import { SwitchBotPlatform } from './platform.js'
7
+ import { PLATFORM_NAME, PLUGIN_NAME } from './settings.js'
8
+
9
+ describe('index.ts', () => {
10
+ it('should register the platform with homebridge', () => {
11
+ const api = {
12
+ registerPlatform: vi.fn(),
13
+ } as unknown as API
14
+
15
+ registerPlatform(api)
16
+
17
+ expect(api.registerPlatform).toHaveBeenCalledWith(PLUGIN_NAME, PLATFORM_NAME, SwitchBotPlatform)
18
+ })
19
+ })
package/tsconfig.json CHANGED
@@ -7,8 +7,7 @@
7
7
  ],
8
8
  "rootDir": "src",
9
9
  "module": "ES2022",
10
- "moduleResolution": "node",
11
- "types": ["node"],
10
+ "moduleResolution": "bundler",
12
11
  "strict": true,
13
12
  "noImplicitAny": false,
14
13
  "declaration": true,
package/.eslintrc DELETED
@@ -1,86 +0,0 @@
1
- {
2
- "parser": "@typescript-eslint/parser",
3
- "extends": [
4
- "eslint:recommended",
5
- "plugin:@typescript-eslint/eslint-recommended",
6
- "plugin:@typescript-eslint/recommended" // uses the recommended rules from the @typescript-eslint/eslint-plugin
7
- ],
8
- "parserOptions": {
9
- "ecmaVersion": 2021,
10
- "sourceType": "module"
11
- },
12
- "ignorePatterns": [
13
- "dist",
14
- "server"
15
- ],
16
- "rules": {
17
- "quotes": [
18
- "warn",
19
- "single"
20
- ],
21
- "indent": [
22
- "warn",
23
- 2,
24
- {
25
- "SwitchCase": 1
26
- }
27
- ],
28
- "linebreak-style": [
29
- "warn",
30
- "unix"
31
- ],
32
- "semi": [
33
- "warn",
34
- "always"
35
- ],
36
- "comma-dangle": [
37
- "warn",
38
- "always-multiline"
39
- ],
40
- "dot-notation": "off",
41
- "eqeqeq": "warn",
42
- "curly": [
43
- "warn",
44
- "all"
45
- ],
46
- "brace-style": [
47
- "warn"
48
- ],
49
- "prefer-arrow-callback": [
50
- "warn"
51
- ],
52
- "max-len": [
53
- "warn",
54
- 150
55
- ],
56
- "no-console": [
57
- "warn"
58
- ], // use the provided Homebridge log method instead
59
- "no-non-null-assertion": [
60
- "off"
61
- ],
62
- "comma-spacing": [
63
- "error"
64
- ],
65
- "no-multi-spaces": [
66
- "warn",
67
- {
68
- "ignoreEOLComments": true
69
- }
70
- ],
71
- "no-trailing-spaces": [
72
- "warn"
73
- ],
74
- "lines-between-class-members": [
75
- "warn",
76
- "always",
77
- {
78
- "exceptAfterSingleLine": true
79
- }
80
- ],
81
- "@typescript-eslint/explicit-function-return-type": "off",
82
- "@typescript-eslint/no-non-null-assertion": "off",
83
- "@typescript-eslint/explicit-module-boundary-types": "off",
84
- "@typescript-eslint/no-explicit-any": "off"
85
- }
86
- }
@@ -1,81 +0,0 @@
1
- #!/bin/env node
2
-
3
- /**
4
- * This scripts queries the npm registry to pull out the latest version for a given tag.
5
- */
6
-
7
- const fs = require("fs");
8
- const semver = require("semver");
9
- const child_process = require("child_process");
10
- const assert = require("assert");
11
-
12
- const BRANCH_VERSION_PATTERN = /^([A-Za-z]*)-(\d+.\d+.\d+)$/
13
-
14
- // Load the contents of the package.json file
15
- const packageJSON = JSON.parse(fs.readFileSync("package.json", "utf8"));
16
-
17
- let refArgument = process.argv[2];
18
- let tagArgument = process.argv[3] || "latest";
19
-
20
- if (refArgument == null) {
21
- console.error("ref argument is missing");
22
- console.error("Usage: npm-version-script.cjs <ref> [tag]");
23
- process.exit(1);
24
- }
25
-
26
- /**
27
- * Queries the NPM registry for the latest version for the provided tag.
28
- * @param tag The tag to query for.
29
- * @returns {string} Returns the version.
30
- */
31
- function getTagVersionFromNpm(tag) {
32
- try {
33
- return child_process.execSync(`npm info ${packageJSON.name} version --tag="${tag}"`).toString("utf8").trim();
34
- } catch (e) {
35
- throw e;
36
- }
37
- }
38
-
39
- function desiredTargetVersion(ref) {
40
- // ref is a GitHub action ref string
41
- if (ref.startsWith("refs/pull/")) {
42
- throw Error("The version script was executed inside a PR!");
43
- }
44
-
45
- assert(ref.startsWith("refs/heads/"))
46
- let branchName = ref.slice("refs/heads/".length);
47
-
48
- let results = branchName.match(BRANCH_VERSION_PATTERN);
49
- if (results != null) {
50
- if (results[1] !== tagArgument) {
51
- console.warn(`The base branch name (${results[1]}) differs from the tag name ${tagArgument}`);
52
- }
53
-
54
- return results[2];
55
- }
56
-
57
- // legacy mode were we use the `betaVersion` property in the package.json
58
- if (branchName === "beta" && packageJSON.betaVersion) {
59
- return packageJSON.betaVersion
60
- }
61
-
62
- throw new Error("Malformed branch name for ref: " + ref + ". Can't derive the base version. Use a branch name like: beta-x.x.x!");
63
- }
64
-
65
- // derive the base version from the branch ref
66
- const baseVersion = desiredTargetVersion(refArgument);
67
-
68
- // query the npm registry for the latest version of the provided tag name
69
- const latestReleasedVersion = getTagVersionFromNpm(tagArgument); // e.g. 0.7.0-beta.12
70
- const latestReleaseBase = semver.inc(latestReleasedVersion, "patch"); // will produce 0.7.0 (removing the preid, needed for the equality check below)
71
-
72
- let publishTag;
73
- if (semver.eq(baseVersion, latestReleaseBase)) { // check if we are releasing another version for the latest beta
74
- publishTag = latestReleasedVersion; // set the current latest beta to be incremented
75
- } else {
76
- publishTag = baseVersion; // start of with a new beta version
77
- }
78
-
79
- // save the package.json
80
- packageJSON.version = publishTag;
81
- fs.writeFileSync("package.json", JSON.stringify(packageJSON, null, 2));