@glasshome/widget-cli 0.4.11 → 0.4.12
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 +9 -4
- package/package.json +1 -1
- package/src/commands/connect.ts +8 -8
package/bin/cli.ts
CHANGED
|
@@ -66,7 +66,12 @@ const { values: flags, positionals } = parseArgs({
|
|
|
66
66
|
strict: false,
|
|
67
67
|
});
|
|
68
68
|
|
|
69
|
-
|
|
69
|
+
// strict:false widens every flag to string | boolean | undefined; a bare
|
|
70
|
+
// `--flag` with no value parses as `true`, which no string option accepts.
|
|
71
|
+
const str = (v: string | boolean | undefined): string | undefined =>
|
|
72
|
+
typeof v === "string" ? v : undefined;
|
|
73
|
+
|
|
74
|
+
const explicitDir = str(flags.dir);
|
|
70
75
|
const [command, ...args] = positionals;
|
|
71
76
|
|
|
72
77
|
if (command === "help" || flags.help) {
|
|
@@ -144,9 +149,9 @@ switch (effectiveCommand) {
|
|
|
144
149
|
const hubUrlArg = args[0];
|
|
145
150
|
const { runPublish } = await import("../src/commands/publish");
|
|
146
151
|
await runPublish(resolveWidgetDir(), hubUrlArg, {
|
|
147
|
-
name: flags.name,
|
|
148
|
-
bump: flags.bump as "keep" | "patch" | "minor" | "major" | undefined,
|
|
149
|
-
scope: flags.scope,
|
|
152
|
+
name: str(flags.name),
|
|
153
|
+
bump: str(flags.bump) as "keep" | "patch" | "minor" | "major" | undefined,
|
|
154
|
+
scope: str(flags.scope),
|
|
150
155
|
});
|
|
151
156
|
outro("Done");
|
|
152
157
|
break;
|
package/package.json
CHANGED
package/src/commands/connect.ts
CHANGED
|
@@ -216,19 +216,19 @@ export async function runConnect(apiUrl: string, cwd: string): Promise<void> {
|
|
|
216
216
|
});
|
|
217
217
|
|
|
218
218
|
if (res.ok) {
|
|
219
|
-
// better-auth's device-authorization plugin returns
|
|
220
|
-
//
|
|
221
|
-
//
|
|
219
|
+
// better-auth's device-authorization plugin returns an OAuth-style
|
|
220
|
+
// bundle: { access_token, token_type, expires_in, scope }. The
|
|
221
|
+
// access_token IS the first-party session token.
|
|
222
222
|
const data = (await res.json()) as {
|
|
223
|
-
|
|
224
|
-
|
|
223
|
+
access_token?: string;
|
|
224
|
+
expires_in?: number;
|
|
225
225
|
};
|
|
226
|
-
if (!data.
|
|
226
|
+
if (!data.access_token) {
|
|
227
227
|
s.stop("Auth response missing session token");
|
|
228
228
|
break;
|
|
229
229
|
}
|
|
230
|
-
token = data.
|
|
231
|
-
const tokenExpiresAt =
|
|
230
|
+
token = data.access_token;
|
|
231
|
+
const tokenExpiresAt = Date.now() + (data.expires_in ?? 0) * 1000;
|
|
232
232
|
storeHostToken(host, token, tokenExpiresAt);
|
|
233
233
|
break;
|
|
234
234
|
}
|