@glasshome/widget-cli 0.4.7 → 0.4.9

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/bin/cli.ts CHANGED
@@ -51,16 +51,25 @@ Examples:
51
51
  glasshome-widget publish --dir packages/widgets
52
52
  `.trim();
53
53
 
54
- const rawArgs = process.argv.slice(2);
55
- const dirFlagIdx = rawArgs.indexOf("--dir");
56
- let explicitDir: string | undefined;
57
- if (dirFlagIdx !== -1) {
58
- explicitDir = rawArgs[dirFlagIdx + 1];
59
- rawArgs.splice(dirFlagIdx, 2);
60
- }
61
- const [command, ...args] = rawArgs;
62
-
63
- if (command === "help" || command === "--help" || command === "-h") {
54
+ import { parseArgs } from "node:util";
55
+
56
+ const { values: flags, positionals } = parseArgs({
57
+ args: process.argv.slice(2),
58
+ options: {
59
+ dir: { type: "string" },
60
+ name: { type: "string" },
61
+ bump: { type: "string" },
62
+ scope: { type: "string" },
63
+ help: { type: "boolean", short: "h" },
64
+ },
65
+ allowPositionals: true,
66
+ strict: false,
67
+ });
68
+
69
+ const explicitDir = flags.dir;
70
+ const [command, ...args] = positionals;
71
+
72
+ if (command === "help" || flags.help) {
64
73
  console.log(HELP);
65
74
  process.exit(0);
66
75
  }
@@ -132,18 +141,12 @@ switch (effectiveCommand) {
132
141
  }
133
142
 
134
143
  case "publish": {
135
- const hubUrlArg = args.find((a) => !a.startsWith("--"));
136
- const nameIdx = rawArgs.indexOf("--name");
137
- const bumpIdx = rawArgs.indexOf("--bump");
138
- const scopeIdx = rawArgs.indexOf("--scope");
139
- const pubName = nameIdx !== -1 ? rawArgs[nameIdx + 1] : undefined;
140
- const pubBump = bumpIdx !== -1 ? rawArgs[bumpIdx + 1] : undefined;
141
- const pubScope = scopeIdx !== -1 ? rawArgs[scopeIdx + 1] : undefined;
144
+ const hubUrlArg = args[0];
142
145
  const { runPublish } = await import("../src/commands/publish");
143
146
  await runPublish(resolveWidgetDir(), hubUrlArg, {
144
- name: pubName,
145
- bump: pubBump as "keep" | "patch" | "minor" | "major" | undefined,
146
- scope: pubScope,
147
+ name: flags.name,
148
+ bump: flags.bump as "keep" | "patch" | "minor" | "major" | undefined,
149
+ scope: flags.scope,
147
150
  });
148
151
  outro("Done");
149
152
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glasshome/widget-cli",
3
- "version": "0.4.7",
3
+ "version": "0.4.9",
4
4
  "description": "CLI for creating and managing GlassHome widgets",
5
5
  "type": "module",
6
6
  "bin": {
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@clack/prompts": "^0.10.0",
24
- "@glasshome/widget-sdk": "0.2.5",
24
+ "@glasshome/widget-sdk": "^0.4.0",
25
25
  "open": "^11.0.0",
26
26
  "semver": "^7.6.0",
27
27
  "vite-plugin-solid": "^2.11.0"
@@ -3,7 +3,7 @@ import { resolve } from "node:path";
3
3
  import { log, spinner } from "@clack/prompts";
4
4
  import { buildWidgets } from "@glasshome/widget-sdk/vite";
5
5
  import { trpcMutate, trpcQuery } from "../utils/api";
6
- import { extractHost, getHostToken, storeHostToken } from "../utils/auth";
6
+ import { clearHostToken, extractHost, getHostToken, storeHostToken } from "../utils/auth";
7
7
 
8
8
  interface RegistryWidget {
9
9
  name: string;
@@ -127,9 +127,16 @@ export async function runConnect(apiUrl: string, cwd: string): Promise<void> {
127
127
  headers: { Authorization: `Bearer ${existingToken}` },
128
128
  });
129
129
  if (check.ok) {
130
- token = existingToken;
131
- log.info("Using stored credentials for dashboard.");
130
+ const body = (await check.json()) as { session?: unknown } | null;
131
+ if (body?.session) {
132
+ token = existingToken;
133
+ log.info("Using stored credentials for dashboard.");
134
+ } else {
135
+ clearHostToken(host);
136
+ log.warn("Stored credentials expired — re-authenticating.");
137
+ }
132
138
  } else {
139
+ clearHostToken(host);
133
140
  log.warn("Stored credentials expired — re-authenticating.");
134
141
  }
135
142
  } catch {
@@ -32,6 +32,16 @@ function validateManifest(manifest: WidgetManifest): ValidationResult {
32
32
  if (!manifest.name) errors.push("Missing required field: name");
33
33
  if (!manifest.sdkVersion) errors.push("Missing required field: sdkVersion");
34
34
 
35
+ // INS-05: "*" sdkVersion is rejected at publish time — authors must declare
36
+ // a real range (e.g. "^0.3.0"). Installed widgets that already ship "*" are
37
+ // still tolerated by the loader with a warn-and-mount, but new publishes
38
+ // are blocked here.
39
+ if (manifest.sdkVersion === "*") {
40
+ errors.push(
41
+ `sdkVersion "*" is not allowed — declare a semver range (e.g. "^0.3.0") to opt into host compatibility checks`,
42
+ );
43
+ }
44
+
35
45
  // Size validation
36
46
  if (!hasValidMinSize) {
37
47
  errors.push("minSize must be an object with numeric w and h properties");