icuewidget-cli 0.4.44

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.
package/LICENSE ADDED
@@ -0,0 +1,182 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship made available under
36
+ the License, as indicated by a copyright notice that is included in
37
+ or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link (or bind by name) to the interfaces of,
45
+ the Work and Derivative Works thereof.
46
+
47
+ "Contribution" shall mean, as submitted to the Licensor for inclusion
48
+ in the Work by the copyright owner or by an individual or Legal Entity
49
+ authorized to submit on behalf of the copyright owner. For the purposes
50
+ of this definition, "submitted" means any form of electronic, verbal,
51
+ or written communication sent to the Licensor or its representatives,
52
+ including but not limited to communication on electronic mailing lists,
53
+ source code control systems, and issue tracking systems that are managed
54
+ by, or on behalf of, the Licensor for the purpose of discussing and
55
+ improving the Work, but excluding communication that is conspicuously
56
+ marked or otherwise designated in writing by the copyright owner as
57
+ "Not a Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any Legal Entity on behalf of
60
+ whom a Contribution has been received by the Licensor and subsequently
61
+ incorporated within the Work.
62
+
63
+ 2. Grant of Copyright License. Subject to the terms and conditions of
64
+ this License, each Contributor hereby grants to You a perpetual,
65
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
66
+ copyright license to reproduce, prepare Derivative Works of,
67
+ publicly display, publicly perform, sublicense, and distribute the
68
+ Work and such Derivative Works in Source or Object form.
69
+
70
+ 3. Grant of Patent License. Subject to the terms and conditions of
71
+ this License, each Contributor hereby grants to You a perpetual,
72
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
73
+ (except as stated in this section) patent license to make, have made,
74
+ use, offer to sell, sell, import, and otherwise transfer the Work,
75
+ where such license applies only to those patent claims licensable
76
+ by such Contributor that are necessarily infringed by their
77
+ Contribution(s) alone or by combination of their Contribution(s)
78
+ with the Work to which such Contribution(s) was submitted. If You
79
+ institute patent litigation against any entity (including a cross-claim
80
+ or counterclaim in a lawsuit) alleging that the Work or any
81
+ Contribution embodied within the Work constitutes direct or contributory
82
+ patent infringement, then any patent licenses granted to You under
83
+ this License for that Work shall terminate as of the date such
84
+ litigation is filed.
85
+
86
+ 4. Redistribution. You may reproduce and distribute copies of the
87
+ Work or Derivative Works thereof in any medium, with or without
88
+ modifications, and in Source or Object form, provided that You
89
+ meet the following conditions:
90
+
91
+ (a) You must give any other recipients of the Work or
92
+ Derivative Works a copy of this License; and
93
+
94
+ (b) You must cause any modified files to carry prominent notices
95
+ stating that You changed the files; and
96
+
97
+ (c) You must retain, in the Source form of any Derivative Works
98
+ that You distribute, all copyright, patent, trademark, and
99
+ attribution notices from the Source form of the Work,
100
+ excluding those notices that do not pertain to any part of
101
+ the Derivative Works; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file as part of its
104
+ distribution, You must include a readable copy of the
105
+ attribution notices contained within such NOTICE file, in
106
+ at least one of the following places: within a NOTICE text
107
+ file distributed as part of the Derivative Works; within
108
+ the Source form or documentation, if provided along with the
109
+ Derivative Works; or, within a display generated by the
110
+ Derivative Works, if and wherever such third-party notices
111
+ normally appear. The contents of the NOTICE file are for
112
+ informational purposes only and do not modify the License.
113
+ You may add Your own attribution notices within Derivative
114
+ Works that You distribute, alongside or as an addendum to
115
+ the NOTICE text from the Work, provided that such additional
116
+ attribution notices cannot be construed as modifying the License.
117
+
118
+ You may add Your own license statement for Your modifications and
119
+ may provide additional grant of rights to use, reproduce, modify,
120
+ and distribute those modifications, as provided in the License.
121
+
122
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
123
+ any Contribution intentionally submitted for inclusion in the Work
124
+ by You to the Licensor shall be under the terms and conditions of
125
+ this License, without any additional terms or conditions.
126
+ Notwithstanding the above, nothing herein shall supersede or modify
127
+ the terms of any separate license agreement you may have executed
128
+ with Licensor regarding such Contributions.
129
+
130
+ 6. Trademarks. This License does not grant permission to use the trade
131
+ names, trademarks, service marks, or product names of the Licensor,
132
+ except as required for reasonable and customary use in describing the
133
+ origin of the Work and reproducing the content of the NOTICE file.
134
+
135
+ 7. Disclaimer of Warranty. Unless required by applicable law or
136
+ agreed to in writing, Licensor provides the Work (and each
137
+ Contributor provides its Contributions) on an "AS IS" BASIS,
138
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
139
+ implied, including, without limitation, any conditions of TITLE,
140
+ NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR
141
+ PURPOSE. You are solely responsible for determining the
142
+ appropriateness of using or reproducing the Work and assume any
143
+ risks associated with Your exercise of permissions under this License.
144
+
145
+ 8. Limitation of Liability. In no event and under no legal theory,
146
+ whether in tort (including negligence), contract, or otherwise,
147
+ unless required by applicable law (such as deliberate and grossly
148
+ negligent acts) or agreed to in writing, shall any Contributor be
149
+ liable to You for damages, including any direct, indirect, special,
150
+ incidental, or exemplary damages of any character arising as a
151
+ result of this License or out of the use or inability to use the
152
+ Work (including but not limited to damages for loss of goodwill,
153
+ work stoppage, computer failure or malfunction, or all other
154
+ commercial damages or losses), even if such Contributor has been
155
+ advised of the possibility of such damages.
156
+
157
+ 9. Accepting Warranty or Additional Liability. While redistributing
158
+ the Work or Derivative Works thereof, You may choose to offer,
159
+ and charge a fee for, acceptance of support, warranty, indemnity,
160
+ or other liability obligations and/or rights consistent with this
161
+ License. However, in accepting such obligations, You may act only
162
+ on Your own behalf and on Your sole responsibility, not on behalf
163
+ of any other Contributor, and only if You agree to indemnify,
164
+ defend, and hold each Contributor harmless for any liability
165
+ incurred by, or claims asserted against, such Contributor by reason
166
+ of your accepting any such warranty or additional liability.
167
+
168
+ END OF TERMS AND CONDITIONS
169
+
170
+ Copyright 2026 Corsair Memory, Inc.
171
+
172
+ Licensed under the Apache License, Version 2.0 (the "License");
173
+ you may not use this file except in compliance with the License.
174
+ You may obtain a copy of the License at
175
+
176
+ http://www.apache.org/licenses/LICENSE-2.0
177
+
178
+ Unless required by applicable law or agreed to in writing, software
179
+ distributed under the License is distributed on an "AS IS" BASIS,
180
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
181
+ See the License for the specific language governing permissions and
182
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,163 @@
1
+ # icuewidget CLI
2
+
3
+ This repository contains the `icuewidget` command-line tool for creating, validating, updating, and packaging iCUE widgets.
4
+
5
+ The CLI uses:
6
+
7
+ - Node.js so it can run through `npx` without a native installer
8
+ - built-in Node APIs for prompts, validation, and `.icuewidget` packaging
9
+ - optional native installer builders for Windows `.exe` and macOS `.pkg`
10
+
11
+ ## Commands
12
+
13
+ - `icuewidget init [path]` - Creates a new widget from the starter template.
14
+ - `icuewidget validate [path]` - Validates widget files and manifest requirements.
15
+ - `icuewidget update [path]` - Updates manifest requirements, bumps widget version, and regenerates the `.icuewidget` package.
16
+ - `icuewidget package [path]` - Validates widget and creates an `.icuewidget` package.
17
+ - `icuewidget --help`
18
+ - `icuewidget --version`
19
+
20
+ ## Contents
21
+
22
+ ```text
23
+ .github/workflows/
24
+ installer/
25
+ node-bin/
26
+ scripts/
27
+ src-node/
28
+ test-node/
29
+ package-lock.json
30
+ package.json
31
+ ```
32
+
33
+ ## Run with npx
34
+
35
+ After publishing to npm:
36
+
37
+ ```bash
38
+ npx @icue/icuewidget-cli --help
39
+ npx @icue/icuewidget-cli init ./MyWidget
40
+ npx @icue/icuewidget-cli validate ./MyWidget
41
+ npx @icue/icuewidget-cli update ./MyWidget --min-app-version 5.45
42
+ npx @icue/icuewidget-cli package ./MyWidget
43
+ ```
44
+
45
+ ## Run locally without publishing
46
+
47
+ ```bash
48
+ npm install
49
+ npm link
50
+ icuewidget --help
51
+ ```
52
+
53
+ Or run the local bin directly:
54
+
55
+ ```bash
56
+ node node-bin/icuewidget.js --help
57
+ node node-bin/icuewidget.js init ./MyWidget
58
+ node node-bin/icuewidget.js validate ./MyWidget
59
+ node node-bin/icuewidget.js package ./MyWidget
60
+ ```
61
+
62
+ ## Generated starter widget
63
+
64
+ `icuewidget init` always scaffolds a configurable hello-world widget for:
65
+
66
+ - `windows`
67
+ - `dashboard_lcd`
68
+
69
+ The generated widget includes example customizable properties such as:
70
+
71
+ - headline
72
+ - subtitle
73
+ - show/hide subtitle
74
+ - text color
75
+ - background color
76
+
77
+ The CLI always creates:
78
+
79
+ - `manifest.json`
80
+ - `index.html`
81
+ - `translation.json`
82
+ - `resources/icon.svg`
83
+ - `styles/main.css`
84
+ - `scripts/main.js`
85
+
86
+ Examples:
87
+
88
+ ```bash
89
+ icuewidget init ./HelloWidget
90
+ ```
91
+
92
+
93
+ ## Versioning
94
+
95
+ The source package uses the base version `0.4.0`. Release automation can set the
96
+ third digit at build time with one of these environment variables:
97
+
98
+ ```bash
99
+ CLI_BUILD_PATCH=123 npm run build
100
+ CLI_BUILD_VERSION=0.4.123 npm run build
101
+ ```
102
+
103
+ `CLI_BUILD_PATCH`, `BUILD_NUMBER`, or `GITHUB_RUN_NUMBER` produces
104
+ `0.4.<patch>` for installer filenames and the bundled CLI `--version` output.
105
+
106
+ For npm publishing, publish a full semantic version, for example:
107
+
108
+ ```bash
109
+ npm version 0.4.123
110
+ npm publish --access public
111
+ ```
112
+
113
+ ## npm publishing
114
+
115
+ Before publishing, verify the package contents and tests:
116
+
117
+ ```bash
118
+ npm test
119
+ npm pack --dry-run
120
+ ```
121
+
122
+ Then publish from this package directory:
123
+
124
+ ```bash
125
+ npm publish --access public
126
+ ```
127
+
128
+ Only the CLI runtime files listed in `package.json` are published to npm. The
129
+ installer assets and build scripts stay in the repository and are excluded from
130
+ the npm package.
131
+
132
+ ## Native installers
133
+
134
+ The repository can also build native installers for users who do not want to use
135
+ `npx` or `npm install -g`.
136
+
137
+ Build standalone binaries first, then the platform installer:
138
+
139
+ ```bash
140
+ npm run build
141
+ ```
142
+
143
+ Outputs are written to:
144
+
145
+ ```text
146
+ release/
147
+ ```
148
+
149
+ Platform requirements:
150
+
151
+ - Windows `.exe`: build on Windows with NSIS `makensis` on `PATH`
152
+ - macOS `.pkg`: build on macOS with `pkgbuild` and `productbuild`
153
+
154
+ By default, installer builds package the checked-out local CLI source. To build
155
+ from a published npm package or tarball, set `CLI_PACKAGE_SPEC`:
156
+
157
+ ```bash
158
+ CLI_PACKAGE_SPEC=@icue/icuewidget-cli@latest npm run build
159
+ CLI_PACKAGE_SPEC=./corsair-icuewidget-cli-1.0.0.tgz npm run build
160
+ ```
161
+
162
+ The installers include best-effort cleanup for older Python-distributed versions
163
+ of `icuewidget-cli` before installing the standalone Node CLI binary.
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { main } from "../src-node/cli.js";
4
+
5
+ main(process.argv).catch((error) => {
6
+ console.error(`Error: ${error.message}`);
7
+ process.exitCode = 1;
8
+ });
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "icuewidget-cli",
3
+ "version": "0.4.44",
4
+ "description": "Create, validate, update, and package CORSAIR iCUE widgets.",
5
+ "keywords": [
6
+ "corsair",
7
+ "icue",
8
+ "widget",
9
+ "cli"
10
+ ],
11
+ "homepage": "https://gitlab.com/corsair-gaming/various-projects/icuewidgets-cli#readme",
12
+ "bugs": {
13
+ "url": "https://gitlab.com/corsair-gaming/various-projects/icuewidgets-cli/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://gitlab.com/corsair-gaming/various-projects/icuewidgets-cli.git"
18
+ },
19
+ "license": "Apache-2.0",
20
+ "author": "CORSAIR",
21
+ "type": "module",
22
+ "main": "index.js",
23
+ "bin": {
24
+ "icuewidget": "node-bin/icuewidget.js"
25
+ },
26
+ "files": [
27
+ "node-bin/",
28
+ "src-node/",
29
+ "README.md"
30
+ ],
31
+ "scripts": {
32
+ "test": "node --test test-node/*.test.js",
33
+ "build:binaries": "node scripts/build-binaries.mjs",
34
+ "build:installers": "node scripts/build-installers.mjs",
35
+ "build": "npm run build:binaries && npm run build:installers",
36
+ "check": "node --check scripts/build-binaries.mjs && node --check scripts/build-installers.mjs"
37
+ },
38
+ "dependencies": {},
39
+ "devDependencies": {
40
+ "@yao-pkg/pkg": "^6.5.1"
41
+ },
42
+ "engines": {
43
+ "node": ">=18.0.0"
44
+ }
45
+ }
@@ -0,0 +1,243 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import {
5
+ APP_NAME,
6
+ APP_VERSION_RE,
7
+ CLI_VERSION,
8
+ DEFAULT_APP_VERSION,
9
+ IDENTIFIER_RE,
10
+ SEMVER_RE,
11
+ SLUG_RE,
12
+ } from "./constants.js";
13
+ import { pathExists } from "./fs-utils.js";
14
+ import { updateManifestToLatest } from "./manifest-update.js";
15
+ import { closePrompts, prompt, promptValidated } from "./prompts.js";
16
+ import { scaffoldWidget } from "./scaffold.js";
17
+ import { color, header, info, panel, success, table } from "./theme.js";
18
+ import { notifyAboutUpdate, runUpdateCheckWorker } from "./update-check.js";
19
+ import { ValidationError, validateWidget } from "./validation.js";
20
+ import { createPackage } from "./zip.js";
21
+
22
+ export async function main(argv = process.argv) {
23
+ try {
24
+ const args = argv.slice(2);
25
+ if (has(args, "--update-check-worker")) {
26
+ await runUpdateCheckWorker();
27
+ return;
28
+ }
29
+ if (args.length === 0 || has(args, "--help") || has(args, "-h")) {
30
+ printHelp();
31
+ return;
32
+ }
33
+ if (has(args, "--version") || has(args, "-v")) {
34
+ console.log(CLI_VERSION);
35
+ return;
36
+ }
37
+
38
+ const [command, ...rest] = args;
39
+ switch (command) {
40
+ case "init":
41
+ await initCommand(rest);
42
+ break;
43
+ case "validate":
44
+ await validateCommand(rest);
45
+ break;
46
+ case "update":
47
+ await updateCommand(rest);
48
+ break;
49
+ case "package":
50
+ await packageCommand(rest);
51
+ break;
52
+ default:
53
+ throw new Error(`Unknown command: ${command}`);
54
+ }
55
+ } finally {
56
+ closePrompts();
57
+ await notifyAboutUpdate({ argv });
58
+ }
59
+ }
60
+
61
+ async function initCommand(args) {
62
+ const { positionals } = parseArgs(args);
63
+ const requested = positionals[0] ?? ".";
64
+ const widgetNameDefault = requested === "." ? "HelloWidget" : path.basename(requested);
65
+ const widgetName = await promptValidated("Widget name", widgetNameDefault, (v) => v.trim().length > 0, "Widget name is required.");
66
+ const targetDir = path.resolve(requested === "." ? slugify(widgetName) : requested);
67
+ if (await pathExists(targetDir)) {
68
+ const entries = await fs.readdir(targetDir);
69
+ if (entries.length) throw new Error(`Target directory is not empty: ${targetDir}`);
70
+ }
71
+
72
+ const answers = {
73
+ widgetName,
74
+ author: await prompt("Author", "Corsair"),
75
+ widgetId: await promptValidated("Widget id", buildDefaultWidgetId(widgetName), validateIdentifier, "Use letters, numbers, dots, and hyphens only."),
76
+ description: await prompt("Description", `${widgetName} iCUE widget`),
77
+ version: await promptValidated("Version", "1.0.0", isSemver, "Use semantic version format like 1.0.0."),
78
+ minAppVersion: await promptValidated("Minimum iCUE version required", DEFAULT_APP_VERSION, isAppVersion, "Use iCUE version format like 5.45 or 5.45.104."),
79
+ previewIcon: await prompt("Preview icon path", "resources/icon.svg"),
80
+ };
81
+
82
+ await scaffoldWidget(targetDir, answers);
83
+ header(APP_NAME, CLI_VERSION);
84
+ success("Widget scaffold created");
85
+ table("Summary", [
86
+ ["Widget", answers.widgetName],
87
+ ["Widget id", answers.widgetId],
88
+ ["Minimum iCUE", answers.minAppVersion],
89
+ ["Path", targetDir],
90
+ ]);
91
+ panel("Next steps", [
92
+ `1. Edit ${path.join(targetDir, "index.html")}`,
93
+ `2. Customize ${path.join(targetDir, "resources", "icon.svg")}`,
94
+ `3. Run ${APP_NAME} validate ${path.basename(targetDir)}`,
95
+ `4. Run ${APP_NAME} package ${path.basename(targetDir)}`,
96
+ ], color.magenta);
97
+ }
98
+
99
+ async function validateCommand(args) {
100
+ const { positionals } = parseArgs(args);
101
+ const result = await runValidation(resolveWidgetDir(positionals[0] ?? "."));
102
+ header(APP_NAME, CLI_VERSION);
103
+ success("Widget is valid");
104
+ table("Summary", [["Widget", result.manifest.name], ["Version", result.manifest.version]]);
105
+ printWarnings(result.warnings);
106
+ }
107
+
108
+ async function packageCommand(args) {
109
+ const { positionals, options } = parseArgs(args, { output: ["--output", "-o"] });
110
+ const widgetDir = resolveWidgetDir(positionals[0] ?? ".");
111
+ const result = await runValidation(widgetDir);
112
+ let outputPath = options.output ? path.resolve(options.output) : defaultOutputPath(widgetDir, result.manifest);
113
+ if (path.extname(outputPath) !== ".icuewidget") outputPath = `${outputPath}.icuewidget`;
114
+ await createPackage(widgetDir, outputPath);
115
+ header(APP_NAME, CLI_VERSION);
116
+ success("Package created");
117
+ table("Summary", [["Widget", result.manifest.name], ["Output", outputPath]]);
118
+ printWarnings(result.warnings);
119
+ }
120
+
121
+ async function updateCommand(args) {
122
+ const { positionals, options } = parseArgs(args, {
123
+ minAppVersion: ["--min-app-version"],
124
+ version: ["--version"],
125
+ output: ["--output", "-o"],
126
+ });
127
+ const widgetDir = resolveWidgetDir(positionals[0] ?? ".");
128
+ const changes = await updateManifestToLatest(widgetDir, options);
129
+ const result = await runValidation(widgetDir);
130
+ if (!changes.length) {
131
+ header(APP_NAME, CLI_VERSION);
132
+ info("Widget is up to date.");
133
+ printWarnings(result.warnings);
134
+ return;
135
+ }
136
+ let outputPath = options.output ? path.resolve(options.output) : defaultOutputPath(widgetDir, result.manifest);
137
+ if (path.extname(outputPath) !== ".icuewidget") outputPath = `${outputPath}.icuewidget`;
138
+ await createPackage(widgetDir, outputPath);
139
+ header(APP_NAME, CLI_VERSION);
140
+ success("Widget updated and package regenerated");
141
+ table("Summary", [["Widget", result.manifest.name], ["Updated", changes.join(", ")], ["Output", outputPath]]);
142
+ printWarnings(result.warnings);
143
+ }
144
+
145
+ async function runValidation(widgetDir) {
146
+ try {
147
+ return await validateWidget(widgetDir);
148
+ } catch (error) {
149
+ if (error instanceof ValidationError) throw error;
150
+ throw error;
151
+ }
152
+ }
153
+
154
+ function printHelp() {
155
+ header(APP_NAME, CLI_VERSION);
156
+ console.log();
157
+ console.log("Create, validate, update, and package iCUE widgets.");
158
+ console.log();
159
+ console.log(`${color.yellow("Usage:")} ${color.bold(APP_NAME)} [-v | --version] [-h | --help] <command> [<args>]`);
160
+ console.log();
161
+ panel("Options", [
162
+ `${color.cyan("-v, --version")} Show the CLI version and exit.`,
163
+ `${color.cyan("-h, --help")} Show this message and exit.`,
164
+ ]);
165
+ panel("Commands", [
166
+ `${color.cyan("init")} Creates a new widget from the starter template.`,
167
+ `${color.cyan("validate")} Validates widget files and manifest requirements.`,
168
+ `${color.cyan("update")} Updates manifest requirements, bumps widget version, and regenerates package.`,
169
+ `${color.cyan("package")} Validates widget and creates an .icuewidget package.`,
170
+ ]);
171
+ panel("Examples", [
172
+ `${APP_NAME} init HelloWidget`,
173
+ `${APP_NAME} validate HelloWidget`,
174
+ `${APP_NAME} update HelloWidget --min-app-version 5.45`,
175
+ `${APP_NAME} update HelloWidget --version 1.0.1`,
176
+ `${APP_NAME} package HelloWidget`,
177
+ ], color.magenta);
178
+ }
179
+
180
+ function parseArgs(args, specs = {}) {
181
+ const options = {};
182
+ const positionals = [];
183
+ const aliases = new Map();
184
+ for (const [name, flags] of Object.entries(specs)) for (const flag of flags) aliases.set(flag, name);
185
+ for (let i = 0; i < args.length; i += 1) {
186
+ const arg = args[i];
187
+ if (aliases.has(arg)) {
188
+ const value = args[i + 1];
189
+ if (!value || value.startsWith("-")) throw new Error(`${arg} requires a value`);
190
+ options[aliases.get(arg)] = value;
191
+ i += 1;
192
+ } else if (arg.startsWith("-")) {
193
+ throw new Error(`Unknown option: ${arg}`);
194
+ } else {
195
+ positionals.push(arg);
196
+ }
197
+ }
198
+ return { options, positionals };
199
+ }
200
+
201
+ function has(args, flag) {
202
+ return args.includes(flag);
203
+ }
204
+
205
+ export function slugify(value) {
206
+ return value.toLowerCase().replace(SLUG_RE, "-").replace(/^-+|-+$/g, "") || "widget";
207
+ }
208
+
209
+ export function buildDefaultWidgetId(widgetName) {
210
+ return `com.corsair.${slugify(widgetName)}`;
211
+ }
212
+
213
+ export function defaultOutputPath(widgetDir, manifest) {
214
+ return path.join(path.dirname(path.resolve(widgetDir)), `${slugify(manifest.name || manifest.id || path.basename(widgetDir))}.icuewidget`);
215
+ }
216
+
217
+ export function resolveWidgetDir(value) {
218
+ return path.resolve(value);
219
+ }
220
+
221
+ export function isSemver(value) {
222
+ return SEMVER_RE.test(value);
223
+ }
224
+
225
+ export function isAppVersion(value) {
226
+ return APP_VERSION_RE.test(value);
227
+ }
228
+
229
+ export function validateIdentifier(value) {
230
+ return IDENTIFIER_RE.test(value);
231
+ }
232
+
233
+ function printWarnings(warnings) {
234
+ if (!warnings.length) return;
235
+ panel("Warnings", warnings.map((warning) => color.yellow(`! ${warning}`)), color.yellow);
236
+ }
237
+
238
+ if (process.argv[1] === fileURLToPath(import.meta.url)) {
239
+ main(process.argv).catch((error) => {
240
+ console.error(`Error: ${error.message}`);
241
+ process.exitCode = 1;
242
+ });
243
+ }
@@ -0,0 +1,19 @@
1
+ export const APP_NAME = "icuewidget";
2
+ export const NPM_PACKAGE_NAME = "icuewidget-cli";
3
+ export const CLI_VERSION = "0.4.44";
4
+ export const DEFAULT_APP_VERSION = "5.45";
5
+ export const DEFAULT_FRAMEWORK_VERSION = "1.0.0";
6
+ export const DEFAULT_PLATFORM = "windows";
7
+ export const DEFAULT_DEVICE_TYPE = "dashboard_lcd";
8
+
9
+ export const ALLOWED_PLATFORMS = new Set(["windows"]);
10
+ export const ALLOWED_DEVICE_TYPES = new Set([
11
+ "dashboard_lcd",
12
+ "pump_lcd",
13
+ "keyboard_lcd",
14
+ ]);
15
+
16
+ export const SEMVER_RE = /^\d+\.\d+\.\d+$/;
17
+ export const APP_VERSION_RE = /^\d+\.\d+(?:\.\d+)?$/;
18
+ export const IDENTIFIER_RE = /^[A-Za-z0-9.-]+$/;
19
+ export const SLUG_RE = /[^a-z0-9]+/g;