@sequenceholdings/studio-cli 0.9.16 → 0.9.18-next.0
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/README.md +10 -0
- package/dist/atlas-client.js +3 -3
- package/dist/auth.js +38 -4
- package/dist/command-contract.d.ts +6 -0
- package/dist/command-contract.js +1 -0
- package/dist/host-token.d.ts +21 -2
- package/dist/host-token.js +36 -2
- package/dist/main.js +5 -1
- package/dist/pnpm-auto-update.d.ts +7 -0
- package/dist/pnpm-auto-update.js +133 -0
- package/dist/update-check.d.ts +3 -7
- package/dist/update-check.js +73 -34
- package/package.json +6 -5
- package/release-summary.json +4 -0
package/README.md
CHANGED
|
@@ -70,6 +70,16 @@ pnpm add -D @sequenceholdings/studio-cli @sequenceholdings/lattice
|
|
|
70
70
|
pnpm add -g @sequenceholdings/studio-cli
|
|
71
71
|
```
|
|
72
72
|
|
|
73
|
+
Global installations made with pnpm 10.28.2 through 10.x automatically follow the
|
|
74
|
+
`latest` npm tag on user machines. The CLI checks in the background at most
|
|
75
|
+
daily and upgrades only when the running package matches that pnpm global
|
|
76
|
+
installation. The command that triggered the check finishes before the upgrade;
|
|
77
|
+
the next eligible command reports a successful update on stderr. Run
|
|
78
|
+
`seq-studio updater track next` for previews, `seq-studio updater track latest`
|
|
79
|
+
to return, or `seq-studio updater status` to inspect the selected track.
|
|
80
|
+
Set `SEQ_STUDIO_NO_AUTO_UPDATE=1` to keep update notices without installing
|
|
81
|
+
updates. Project dependencies, CI, and pinned devboxes keep their own versions.
|
|
82
|
+
|
|
73
83
|
### Why pnpm and not npm
|
|
74
84
|
|
|
75
85
|
Sequence uses pnpm's `minimumReleaseAge` setting (in `pnpm-workspace.yaml`)
|
package/dist/atlas-client.js
CHANGED
|
@@ -9,7 +9,7 @@ import { createPlatformTransport, createOperatorPlatformClient, } from "@sequenc
|
|
|
9
9
|
import { validationDetail } from "./validation-detail.js";
|
|
10
10
|
import { edgeAuthHeaders } from "./edge-auth-headers.js";
|
|
11
11
|
import { sandboxBearerFor } from "./sandbox-auth.js";
|
|
12
|
-
import {
|
|
12
|
+
import { devboxAwareBearer } from "./host-token.js";
|
|
13
13
|
import { errorCode, isTransient503 } from "./transient-503.js";
|
|
14
14
|
import { fetchWithCliAttribution } from "./cli-attribution.js";
|
|
15
15
|
const MAX_503_RETRIES = 5;
|
|
@@ -58,7 +58,7 @@ async function authenticatedFetch({ baseUrl, init = {}, path, token, retry503 =
|
|
|
58
58
|
timeoutMs,
|
|
59
59
|
auth: {
|
|
60
60
|
kind: "operator",
|
|
61
|
-
bearer: async () => (await sandboxBearerFor(baseUrl)) ?? (await
|
|
61
|
+
bearer: async () => (await sandboxBearerFor(baseUrl)) ?? (await devboxAwareBearer(baseUrl, token)),
|
|
62
62
|
},
|
|
63
63
|
edgeHeaders: () => edgeAuthHeaders(baseUrl),
|
|
64
64
|
});
|
|
@@ -343,7 +343,7 @@ export function operatorPlatformClient({ baseUrl, token, }) {
|
|
|
343
343
|
return createOperatorPlatformClient({
|
|
344
344
|
fetchImpl: fetchWithCliAttribution,
|
|
345
345
|
baseUrl,
|
|
346
|
-
bearer: async () => (await sandboxBearerFor(baseUrl)) ?? (await
|
|
346
|
+
bearer: async () => (await sandboxBearerFor(baseUrl)) ?? (await devboxAwareBearer(baseUrl, token)),
|
|
347
347
|
edgeHeaders: () => edgeAuthHeaders(baseUrl),
|
|
348
348
|
});
|
|
349
349
|
}
|
package/dist/auth.js
CHANGED
|
@@ -495,14 +495,48 @@ async function devboxAccessToken(targetUrl) {
|
|
|
495
495
|
const token = targetUrl ? await devboxHostToken(targetUrl) : null;
|
|
496
496
|
return token ? { authMode: 'user', token } : null;
|
|
497
497
|
}
|
|
498
|
-
/**
|
|
499
|
-
|
|
500
|
-
|
|
498
|
+
/**
|
|
499
|
+
* The user's own unexpired cached login for this environment, or null. Never
|
|
500
|
+
* refreshes, logs in, or throws: it only decides whether a login the user
|
|
501
|
+
* chose to make should win over the devbox owner token.
|
|
502
|
+
*/
|
|
503
|
+
async function liveCachedUserLogin(options) {
|
|
504
|
+
if (authModePrefersM2m())
|
|
505
|
+
return null;
|
|
506
|
+
try {
|
|
507
|
+
const realm = await realmForEnv(options.env, { targetUrl: options.targetUrl });
|
|
508
|
+
if (options.targetUrl)
|
|
509
|
+
validateRealmTarget({ realm, targetUrl: options.targetUrl });
|
|
510
|
+
const tokens = await loadCachedUserTokens(realm.name);
|
|
511
|
+
if (!tokens?.access_token || (tokens.expires_at ?? 0) <= Date.now() / 1000 + 60)
|
|
512
|
+
return null;
|
|
513
|
+
verifyTokenMatchesRealm({ accessToken: tokens.access_token, realm });
|
|
514
|
+
return { authMode: 'user', token: tokens.access_token };
|
|
515
|
+
}
|
|
516
|
+
catch {
|
|
517
|
+
return null;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* A token the environment supplies rather than a login: the sandbox bearer,
|
|
522
|
+
* else a devbox owner token. A live login of the user's own for the same
|
|
523
|
+
* deployment beats the devbox token: the user made it deliberately (the
|
|
524
|
+
* box's sign-in page), and it keeps working on a deployment that does not
|
|
525
|
+
* accept the box's token yet. Without one, the devbox token is used as before.
|
|
526
|
+
*/
|
|
527
|
+
async function ambientAccessToken(options) {
|
|
528
|
+
const sandbox = await sandboxAccessToken(options.targetUrl);
|
|
529
|
+
if (sandbox)
|
|
530
|
+
return sandbox;
|
|
531
|
+
const devbox = await devboxAccessToken(options.targetUrl);
|
|
532
|
+
if (!devbox)
|
|
533
|
+
return null;
|
|
534
|
+
return (await liveCachedUserLogin(options)) ?? devbox;
|
|
501
535
|
}
|
|
502
536
|
async function resolveAccessTokenWithMode(options) {
|
|
503
537
|
// Sandbox token mode replaces every other source, before any realm lookup;
|
|
504
538
|
// then a devbox owner's login for the target host.
|
|
505
|
-
const ambient = await ambientAccessToken(options?.targetUrl);
|
|
539
|
+
const ambient = await ambientAccessToken({ env: options?.env, targetUrl: options?.targetUrl });
|
|
506
540
|
if (ambient)
|
|
507
541
|
return ambient;
|
|
508
542
|
const realm = await realmForEnv(options?.env, { targetUrl: options?.targetUrl });
|
|
@@ -119,6 +119,12 @@ export declare const COMMAND_CONTRACT: readonly [{
|
|
|
119
119
|
readonly lifecycle: "preview";
|
|
120
120
|
readonly access: "offline";
|
|
121
121
|
readonly subcommands: readonly ["enable", "disable", "status"];
|
|
122
|
+
}, {
|
|
123
|
+
readonly name: "updater";
|
|
124
|
+
readonly description: "Control global pnpm CLI updates";
|
|
125
|
+
readonly lifecycle: "preview";
|
|
126
|
+
readonly access: "offline";
|
|
127
|
+
readonly subcommands: readonly ["status", "track"];
|
|
122
128
|
}, {
|
|
123
129
|
readonly name: "version";
|
|
124
130
|
readonly description: "Print the installed CLI version";
|
package/dist/command-contract.js
CHANGED
|
@@ -20,6 +20,7 @@ export const COMMAND_CONTRACT = [
|
|
|
20
20
|
{ name: 'logout', description: 'Remove cached user tokens', lifecycle: 'stable', access: 'public', subcommands: [] },
|
|
21
21
|
{ name: 'doctor', description: 'Diagnose CLI configuration and access', lifecycle: 'stable', access: 'mixed', subcommands: [] },
|
|
22
22
|
{ name: 'telemetry', description: 'Control authenticated command telemetry', lifecycle: 'preview', access: 'offline', subcommands: ['enable', 'disable', 'status'] },
|
|
23
|
+
{ name: 'updater', description: 'Control global pnpm CLI updates', lifecycle: 'preview', access: 'offline', subcommands: ['status', 'track'] },
|
|
23
24
|
{ name: 'version', description: 'Print the installed CLI version', lifecycle: 'stable', access: 'offline', subcommands: [] },
|
|
24
25
|
{ name: 'help', description: 'Show command help', lifecycle: 'stable', access: 'offline', subcommands: [] },
|
|
25
26
|
{ name: 'storage', description: 'Manage Workspaces V2 file storage', lifecycle: 'preview', access: 'authenticated', subcommands: ['init', 'validate', 'apply', 'list', 'show', 'mkdir', 'upload', 'import', 'uploads', 'reconcile', 'download', 'access', 'trash', 'restore', 'purge', 'operations', 'abort', 'delete'] },
|
package/dist/host-token.d.ts
CHANGED
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
*
|
|
9
9
|
* SEQ_DEVBOX_TOKEN_DIR/<host> e.g. staging.example.seqholdings.com
|
|
10
10
|
*
|
|
11
|
-
* A request to an origin whose host has a live file uses it
|
|
12
|
-
*
|
|
11
|
+
* A request to an origin whose host has a live file uses it, unless the user
|
|
12
|
+
* has a live login of their own for that deployment, which wins (auth.ts);
|
|
13
|
+
* every other origin resolves exactly as before. Unlike sandbox token
|
|
13
14
|
* mode this pins nothing: `-e` still picks the deployment, and a deployment
|
|
14
15
|
* with no file (or `-e local`) falls through to the usual login.
|
|
15
16
|
*
|
|
@@ -34,3 +35,21 @@ export declare function devboxHostToken(url: string, { env, now }?: {
|
|
|
34
35
|
env?: NodeJS.ProcessEnv;
|
|
35
36
|
now?: number;
|
|
36
37
|
}): Promise<string | null>;
|
|
38
|
+
/**
|
|
39
|
+
* Whether `token` is one the control plane writes into the devbox token
|
|
40
|
+
* directory (a devbox owner token, or the control plane's own agent sandbox
|
|
41
|
+
* token) rather than a person's login. Read without verifying, only to decide
|
|
42
|
+
* whether re-reading the file mid-command may replace it.
|
|
43
|
+
*/
|
|
44
|
+
export declare function isDevboxFileToken(token: string): boolean;
|
|
45
|
+
/**
|
|
46
|
+
* The bearer for one request on a command whose token was resolved up front.
|
|
47
|
+
* A command that started on the devbox file re-reads it, so a rotation
|
|
48
|
+
* mid-command is picked up. One that resolved to the user's own login keeps
|
|
49
|
+
* it while it has more than a minute left, then moves to the box's live
|
|
50
|
+
* token, so a long command does not die when that login expires.
|
|
51
|
+
*/
|
|
52
|
+
export declare function devboxAwareBearer(url: string, token: string, { env, now }?: {
|
|
53
|
+
env?: NodeJS.ProcessEnv;
|
|
54
|
+
now?: number;
|
|
55
|
+
}): Promise<string>;
|
package/dist/host-token.js
CHANGED
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
*
|
|
9
9
|
* SEQ_DEVBOX_TOKEN_DIR/<host> e.g. staging.example.seqholdings.com
|
|
10
10
|
*
|
|
11
|
-
* A request to an origin whose host has a live file uses it
|
|
12
|
-
*
|
|
11
|
+
* A request to an origin whose host has a live file uses it, unless the user
|
|
12
|
+
* has a live login of their own for that deployment, which wins (auth.ts);
|
|
13
|
+
* every other origin resolves exactly as before. Unlike sandbox token
|
|
13
14
|
* mode this pins nothing: `-e` still picks the deployment, and a deployment
|
|
14
15
|
* with no file (or `-e local`) falls through to the usual login.
|
|
15
16
|
*
|
|
@@ -81,3 +82,36 @@ export async function devboxHostToken(url, { env = process.env, now = Date.now()
|
|
|
81
82
|
return null;
|
|
82
83
|
return token;
|
|
83
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Whether `token` is one the control plane writes into the devbox token
|
|
87
|
+
* directory (a devbox owner token, or the control plane's own agent sandbox
|
|
88
|
+
* token) rather than a person's login. Read without verifying, only to decide
|
|
89
|
+
* whether re-reading the file mid-command may replace it.
|
|
90
|
+
*/
|
|
91
|
+
export function isDevboxFileToken(token) {
|
|
92
|
+
const payload = token.split('.')[1];
|
|
93
|
+
if (!payload)
|
|
94
|
+
return false;
|
|
95
|
+
try {
|
|
96
|
+
const source = JSON.parse(Buffer.from(payload, 'base64url').toString('utf8')).source;
|
|
97
|
+
return source === 'devbox-owner' || source === 'agent-sandbox';
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The bearer for one request on a command whose token was resolved up front.
|
|
105
|
+
* A command that started on the devbox file re-reads it, so a rotation
|
|
106
|
+
* mid-command is picked up. One that resolved to the user's own login keeps
|
|
107
|
+
* it while it has more than a minute left, then moves to the box's live
|
|
108
|
+
* token, so a long command does not die when that login expires.
|
|
109
|
+
*/
|
|
110
|
+
export async function devboxAwareBearer(url, token, { env = process.env, now = Date.now() } = {}) {
|
|
111
|
+
if (token && !isDevboxFileToken(token)) {
|
|
112
|
+
const exp = jwtExpiry(token);
|
|
113
|
+
if (exp === null || exp * 1000 > now + EXPIRY_MARGIN_SECONDS * 1000)
|
|
114
|
+
return token;
|
|
115
|
+
}
|
|
116
|
+
return (await devboxHostToken(url, { env, now })) ?? token;
|
|
117
|
+
}
|
package/dist/main.js
CHANGED
|
@@ -57,6 +57,7 @@ const TOP_LEVEL_USAGE = `usage:
|
|
|
57
57
|
seq-studio logout [--env <name>] remove one realm's cached user tokens
|
|
58
58
|
seq-studio doctor [-e <env>] [--json] [--offline] diagnose config, auth, toolchain, and writer gate
|
|
59
59
|
seq-studio telemetry enable|disable|status control authenticated command metrics
|
|
60
|
+
seq-studio updater status | track latest|next control global pnpm auto-updates
|
|
60
61
|
seq-studio version print the installed version
|
|
61
62
|
seq-studio capabilities [--json] describe command availability and access
|
|
62
63
|
seq-studio help show this message
|
|
@@ -112,8 +113,9 @@ const SUBCOMMANDS = {
|
|
|
112
113
|
orm: new Set(['init', 'generate', 'validate', 'plan', 'apply', 'history', 'deployment-policy', 'execute', 'namespaces', 'describe', 'read', 'sql', 'diff', 'migrate-from-yaml', 'import']),
|
|
113
114
|
pipeline: new Set(['list', 'assets', 'search', 'describe', 'schema', 'sample', 'query', 'init', 'validate', 'repin-orm', 'codegen', 'adopt', 'unbind', 'retire', 'plan', 'deploy', 'status', 'migrate', 'promote', 'rollback', 'run-now']),
|
|
114
115
|
envs: new Set(['add', 'list']),
|
|
116
|
+
updater: new Set(['status', 'track']),
|
|
115
117
|
};
|
|
116
|
-
const TELEMETRY_EXCLUDED = new Set(['validate', 'telemetry', 'version', 'capabilities', 'help', 'login', 'logout', 'envs']);
|
|
118
|
+
const TELEMETRY_EXCLUDED = new Set(['validate', 'telemetry', 'updater', 'version', 'capabilities', 'help', 'login', 'logout', 'envs']);
|
|
117
119
|
const TELEMETRY_TOP_LEVEL = new Set(['init', 'add', 'deploy', 'doctor']);
|
|
118
120
|
const TELEMETRY_NESTED = {
|
|
119
121
|
'repos pulls': new Set(['list', 'show', 'create', 'diff', 'merge', 'edit', 'close', 'comment', 'comments', 'resolve', 'unresolve', 'review', 'reviews', 'checks']),
|
|
@@ -279,6 +281,8 @@ async function dispatch(argv) {
|
|
|
279
281
|
console.log(currentVersion());
|
|
280
282
|
return 0;
|
|
281
283
|
}
|
|
284
|
+
case 'updater':
|
|
285
|
+
return (await import('./pnpm-auto-update.js')).updaterCommand([sub, ...rest].filter((arg) => Boolean(arg)));
|
|
282
286
|
case 'capabilities':
|
|
283
287
|
return runCapabilities([sub, ...rest].filter((value) => Boolean(value)));
|
|
284
288
|
case 'doctor':
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export type UpdateTrack = 'latest' | 'next';
|
|
2
|
+
export declare function isGlobalPnpmInstallation(): boolean;
|
|
3
|
+
export declare function globalUpdateTrack(): Promise<UpdateTrack>;
|
|
4
|
+
export declare function setGlobalUpdateTrack(track: UpdateTrack): Promise<boolean>;
|
|
5
|
+
export declare function updaterCommand(args: string[]): Promise<number>;
|
|
6
|
+
/** Runs only in the detached registry-refresh worker, never in a CLI command. */
|
|
7
|
+
export declare function maybeUpgradeGlobalPnpm(available: string, expectedTrack?: UpdateTrack): Promise<boolean>;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { realpathSync, readFileSync } from 'node:fs';
|
|
3
|
+
import { mkdir, readFile, rename, writeFile } from 'node:fs/promises';
|
|
4
|
+
import { homedir } from 'node:os';
|
|
5
|
+
import { dirname, join } from 'node:path';
|
|
6
|
+
import { fileURLToPath } from 'node:url';
|
|
7
|
+
import { gt, lt, prerelease, valid } from 'semver';
|
|
8
|
+
const PACKAGE = '@sequenceholdings/studio-cli';
|
|
9
|
+
const PACKAGE_PATH = join('@sequenceholdings', 'studio-cli');
|
|
10
|
+
function trackPath() { return join(homedir(), '.config', 'lattice', 'update-track.json'); }
|
|
11
|
+
function installedPackageRoot() {
|
|
12
|
+
return dirname(dirname(fileURLToPath(import.meta.url)));
|
|
13
|
+
}
|
|
14
|
+
function globalPackageRoot() {
|
|
15
|
+
const result = spawnSync('pnpm', ['root', '-g'], { encoding: 'utf8', timeout: 5000 });
|
|
16
|
+
if (result.status !== 0)
|
|
17
|
+
return null;
|
|
18
|
+
const root = result.stdout.trim();
|
|
19
|
+
if (!root)
|
|
20
|
+
return null;
|
|
21
|
+
try {
|
|
22
|
+
const global = realpathSync(join(root, PACKAGE_PATH));
|
|
23
|
+
return global === realpathSync(installedPackageRoot()) ? root : null;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export function isGlobalPnpmInstallation() { return globalPackageRoot() !== null; }
|
|
30
|
+
export async function globalUpdateTrack() {
|
|
31
|
+
try {
|
|
32
|
+
const parsed = JSON.parse(await readFile(trackPath(), 'utf8'));
|
|
33
|
+
const track = typeof parsed === 'object' && parsed !== null ? Reflect.get(parsed, 'track') : null;
|
|
34
|
+
return track === 'next' ? 'next' : 'latest';
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return 'latest';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export async function setGlobalUpdateTrack(track) {
|
|
41
|
+
if (!isGlobalPnpmInstallation())
|
|
42
|
+
return false;
|
|
43
|
+
const path = trackPath();
|
|
44
|
+
await mkdir(dirname(path), { recursive: true });
|
|
45
|
+
const temporary = `${path}.${process.pid}.tmp`;
|
|
46
|
+
await writeFile(temporary, JSON.stringify({ track }) + '\n', { mode: 0o600 });
|
|
47
|
+
await rename(temporary, path);
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
export async function updaterCommand(args) {
|
|
51
|
+
const [action, track] = args;
|
|
52
|
+
if (!action || action === '--help' || action === '-h' || action === 'help') {
|
|
53
|
+
console.log('usage: seq-studio updater status | track latest|next');
|
|
54
|
+
return 0;
|
|
55
|
+
}
|
|
56
|
+
const root = globalPackageRoot();
|
|
57
|
+
if (!root) {
|
|
58
|
+
console.error('Automatic updates require a global pnpm installation of seq-studio; project dependencies remain pinned.');
|
|
59
|
+
return 1;
|
|
60
|
+
}
|
|
61
|
+
if (action === 'status') {
|
|
62
|
+
console.log(`Global pnpm seq-studio ${packageVersion(root) ?? 'unknown'} (${await globalUpdateTrack()})`);
|
|
63
|
+
return 0;
|
|
64
|
+
}
|
|
65
|
+
if (action === 'track' && (track === 'latest' || track === 'next')) {
|
|
66
|
+
await setGlobalUpdateTrack(track);
|
|
67
|
+
console.log(`seq-studio now follows npm ${track}`);
|
|
68
|
+
return 0;
|
|
69
|
+
}
|
|
70
|
+
console.error('usage: seq-studio updater status | track latest|next');
|
|
71
|
+
return 1;
|
|
72
|
+
}
|
|
73
|
+
function packageVersion(root) {
|
|
74
|
+
try {
|
|
75
|
+
const parsed = JSON.parse(readFileSync(join(root, PACKAGE_PATH, 'package.json'), 'utf8'));
|
|
76
|
+
const version = typeof parsed === 'object' && parsed !== null ? Reflect.get(parsed, 'version') : null;
|
|
77
|
+
return typeof version === 'string' ? version : null;
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/** Runs only in the detached registry-refresh worker, never in a CLI command. */
|
|
84
|
+
export async function maybeUpgradeGlobalPnpm(available, expectedTrack) {
|
|
85
|
+
const ci = process.env['CI']?.trim().toLowerCase();
|
|
86
|
+
if (process.env['SEQ_STUDIO_NO_AUTO_UPDATE'] === '1' || process.env['SEQ_STUDIO_TOKEN_FILE'] || (ci && ci !== 'false' && ci !== '0'))
|
|
87
|
+
return false;
|
|
88
|
+
if (!valid(available))
|
|
89
|
+
return false;
|
|
90
|
+
const root = globalPackageRoot();
|
|
91
|
+
if (!root)
|
|
92
|
+
return false;
|
|
93
|
+
if (expectedTrack && await globalUpdateTrack() !== expectedTrack)
|
|
94
|
+
return false;
|
|
95
|
+
const previous = packageVersion(root);
|
|
96
|
+
if (!previous || !valid(previous) || available === previous)
|
|
97
|
+
return false;
|
|
98
|
+
// Leaving next can select an older stable release. Honor that explicit track
|
|
99
|
+
// change, but never downgrade one stable release to another on a stale tag.
|
|
100
|
+
const returnsToStable = prerelease(previous) !== null && prerelease(available) === null;
|
|
101
|
+
if (!gt(available, previous) && !returnsToStable)
|
|
102
|
+
return false;
|
|
103
|
+
const pnpm = spawnSync('pnpm', ['--version'], { encoding: 'utf8', timeout: 5000 });
|
|
104
|
+
const pnpmVersion = pnpm.stdout.trim();
|
|
105
|
+
if (pnpm.status !== 0 || !valid(pnpmVersion) || lt(pnpmVersion, '10.28.2') || !lt(pnpmVersion, '11.0.0'))
|
|
106
|
+
return false;
|
|
107
|
+
if (expectedTrack && await globalUpdateTrack() !== expectedTrack)
|
|
108
|
+
return false;
|
|
109
|
+
const result = spawnSync('pnpm', ['add', '-g', '--ignore-scripts', '--registry', 'https://registry.npmjs.org/', `${PACKAGE}@${available}`], {
|
|
110
|
+
encoding: 'utf8', timeout: 300000,
|
|
111
|
+
env: {
|
|
112
|
+
...process.env,
|
|
113
|
+
npm_config_minimum_release_age: '10080',
|
|
114
|
+
npm_config_minimum_release_age_exclude: '["@sequenceholdings/*"]',
|
|
115
|
+
},
|
|
116
|
+
});
|
|
117
|
+
if (result.status !== 0 || packageVersion(root) !== available)
|
|
118
|
+
return false;
|
|
119
|
+
let summary;
|
|
120
|
+
try {
|
|
121
|
+
const parsed = JSON.parse(await readFile(join(root, PACKAGE_PATH, 'release-summary.json'), 'utf8'));
|
|
122
|
+
const value = typeof parsed === 'object' && parsed !== null ? Reflect.get(parsed, available) : null;
|
|
123
|
+
if (typeof value === 'string' && value.length <= 300)
|
|
124
|
+
summary = value;
|
|
125
|
+
}
|
|
126
|
+
catch { /* An update notice can omit the summary. */ }
|
|
127
|
+
const notices = join(homedir(), '.config', 'lattice');
|
|
128
|
+
await mkdir(notices, { recursive: true });
|
|
129
|
+
const temporary = join(notices, `update-installed.${process.pid}.tmp`);
|
|
130
|
+
await writeFile(temporary, JSON.stringify({ from: previous, to: available, summary }) + '\n', { mode: 0o600 });
|
|
131
|
+
await rename(temporary, join(notices, 'update-installed.json'));
|
|
132
|
+
return true;
|
|
133
|
+
}
|
package/dist/update-check.d.ts
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
1
|
/** The version of this installed package (dist/../package.json). */
|
|
2
2
|
export declare function currentVersion(): string;
|
|
3
|
-
export declare function updateCheckCachePath(): string;
|
|
3
|
+
export declare function updateCheckCachePath(installationFile?: string): string;
|
|
4
4
|
/** Exclusive-create marker that makes "who spawns the refresh?" atomic. */
|
|
5
5
|
export declare function updateCheckClaimPath(): string;
|
|
6
6
|
/** Receipt is scoped to the local user cache and installed/available pair. */
|
|
7
7
|
export declare function updateNoticeReceiptPath(installed: string, available: string): string;
|
|
8
|
-
/**
|
|
9
|
-
* True when `candidate` is a strictly newer semver than `current`.
|
|
10
|
-
* Prerelease suffixes are ignored — the published channel is plain
|
|
11
|
-
* major.minor.patch and this only drives a notice, not resolution.
|
|
12
|
-
*/
|
|
8
|
+
/** True when `candidate` is a strictly newer semver than `current`. */
|
|
13
9
|
export declare function isNewerVersion(candidate: string, current: string): boolean;
|
|
14
10
|
/**
|
|
15
|
-
* Poll the registry and persist the result. Runs in the detached background
|
|
11
|
+
* Poll the registry, upgrade an eligible global pnpm install, and persist the result. Runs in the detached background
|
|
16
12
|
* process (see update-check-refresh.ts) — never on a command's exit path.
|
|
17
13
|
* Failed fetches still record `lastCheckedAt` (keeping any previously known
|
|
18
14
|
* version) so attempts are throttled to once per interval either way. The
|
package/dist/update-check.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
import { createHash } from 'node:crypto';
|
|
3
|
-
import { mkdir, readFile, rm, stat, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { mkdir, readFile, rename, rm, stat, writeFile } from 'node:fs/promises';
|
|
4
4
|
import { readFileSync } from 'node:fs';
|
|
5
5
|
import { homedir } from 'node:os';
|
|
6
6
|
import { dirname, join } from 'node:path';
|
|
7
7
|
import { fileURLToPath } from 'node:url';
|
|
8
|
+
import { gt, valid } from 'semver';
|
|
8
9
|
/**
|
|
9
|
-
* Update
|
|
10
|
+
* Update discovery: tell CLI users and agents when a newer version is on npm.
|
|
10
11
|
*
|
|
11
|
-
* Zero foreground latency is the design constraint. The command path
|
|
12
|
-
*
|
|
13
|
-
*
|
|
12
|
+
* Zero foreground network latency is the design constraint. The command path
|
|
13
|
+
* reads the on-disk cache (~/.config/lattice/update-check.json) and prints;
|
|
14
|
+
* the registry poll and eligible global pnpm upgrade run in a detached process spawned
|
|
14
15
|
* at most once per CHECK_INTERVAL_MS — including after failures, which
|
|
15
16
|
* record their attempt time so a downed registry doesn't retry on every
|
|
16
17
|
* command. An exclusive claim file elects a single refresher even across
|
|
@@ -19,7 +20,7 @@ import { fileURLToPath } from 'node:url';
|
|
|
19
20
|
* installed/available version pair for this local user. Its write is the
|
|
20
21
|
* notification claim, so concurrent invocations cannot print duplicates.
|
|
21
22
|
*
|
|
22
|
-
*
|
|
23
|
+
* Notices go to stderr, leaving JSON stdout intact. CI and
|
|
23
24
|
* explicitly offline commands skip discovery. Opt out entirely with
|
|
24
25
|
* SEQ_STUDIO_NO_UPDATE_CHECK=1. Everything is best-effort: failures are
|
|
25
26
|
* silent and never affect the command's exit code.
|
|
@@ -36,8 +37,11 @@ export function currentVersion() {
|
|
|
36
37
|
const version = typeof parsed === 'object' && parsed !== null ? Reflect.get(parsed, 'version') : null;
|
|
37
38
|
return typeof version === 'string' ? version : '0.0.0';
|
|
38
39
|
}
|
|
39
|
-
export function updateCheckCachePath() {
|
|
40
|
-
|
|
40
|
+
export function updateCheckCachePath(installationFile = fileURLToPath(import.meta.url)) {
|
|
41
|
+
// A project-pinned CLI must not consume the global installation's daily
|
|
42
|
+
// check. pnpm versions live at distinct real paths, so hash the package path.
|
|
43
|
+
const installation = createHash('sha256').update(dirname(installationFile)).digest('hex').slice(0, 16);
|
|
44
|
+
return join(homedir(), '.config', 'lattice', `update-check-${installation}.json`);
|
|
41
45
|
}
|
|
42
46
|
/** Exclusive-create marker that makes "who spawns the refresh?" atomic. */
|
|
43
47
|
export function updateCheckClaimPath() {
|
|
@@ -48,24 +52,9 @@ export function updateNoticeReceiptPath(installed, available) {
|
|
|
48
52
|
const installation = createHash('sha256').update(dirname(fileURLToPath(import.meta.url))).digest('hex').slice(0, 16);
|
|
49
53
|
return join(dirname(updateCheckCachePath()), 'update-notices', installation, `${encodeURIComponent(installed)}--${encodeURIComponent(available)}.receipt`);
|
|
50
54
|
}
|
|
51
|
-
/**
|
|
52
|
-
* True when `candidate` is a strictly newer semver than `current`.
|
|
53
|
-
* Prerelease suffixes are ignored — the published channel is plain
|
|
54
|
-
* major.minor.patch and this only drives a notice, not resolution.
|
|
55
|
-
*/
|
|
55
|
+
/** True when `candidate` is a strictly newer semver than `current`. */
|
|
56
56
|
export function isNewerVersion(candidate, current) {
|
|
57
|
-
|
|
58
|
-
.replace(/^v/, '')
|
|
59
|
-
.split('-')[0]
|
|
60
|
-
.split('.')
|
|
61
|
-
.map((part) => Number.parseInt(part, 10) || 0);
|
|
62
|
-
const [a, b] = [parse(candidate), parse(current)];
|
|
63
|
-
for (let i = 0; i < 3; i++) {
|
|
64
|
-
const diff = (a[i] ?? 0) - (b[i] ?? 0);
|
|
65
|
-
if (diff !== 0)
|
|
66
|
-
return diff > 0;
|
|
67
|
-
}
|
|
68
|
-
return false;
|
|
57
|
+
return valid(candidate) !== null && valid(current) !== null && gt(candidate, current);
|
|
69
58
|
}
|
|
70
59
|
async function readCache() {
|
|
71
60
|
try {
|
|
@@ -78,7 +67,8 @@ async function readCache() {
|
|
|
78
67
|
if (typeof candidate.latestVersion !== 'string' && candidate.latestVersion !== null) {
|
|
79
68
|
return null;
|
|
80
69
|
}
|
|
81
|
-
return { lastCheckedAt: candidate.lastCheckedAt, latestVersion: candidate.latestVersion
|
|
70
|
+
return { lastCheckedAt: candidate.lastCheckedAt, latestVersion: candidate.latestVersion,
|
|
71
|
+
track: candidate.track === 'next' ? 'next' : 'latest' };
|
|
82
72
|
}
|
|
83
73
|
catch {
|
|
84
74
|
return null;
|
|
@@ -89,15 +79,28 @@ async function writeCache(cache) {
|
|
|
89
79
|
await mkdir(dirname(path), { recursive: true });
|
|
90
80
|
await writeFile(path, JSON.stringify(cache, null, 2) + '\n', 'utf8');
|
|
91
81
|
}
|
|
92
|
-
async function fetchLatestVersion() {
|
|
82
|
+
async function fetchLatestVersion(track) {
|
|
93
83
|
const controller = new AbortController();
|
|
94
84
|
const timer = setTimeout(() => controller.abort(), FETCH_TIMEOUT_MS);
|
|
95
85
|
try {
|
|
96
|
-
const response = await fetch(`https://registry.npmjs.org/${PACKAGE_NAME}/latest`, { signal: controller.signal });
|
|
86
|
+
const response = await fetch(track === 'next' ? `https://registry.npmjs.org/${PACKAGE_NAME.replace('/', '%2f')}` : `https://registry.npmjs.org/${PACKAGE_NAME}/latest`, { signal: controller.signal });
|
|
97
87
|
if (!response.ok)
|
|
98
88
|
return null;
|
|
99
|
-
const body =
|
|
100
|
-
|
|
89
|
+
const body = await response.json();
|
|
90
|
+
if (typeof body !== 'object' || body === null)
|
|
91
|
+
return null;
|
|
92
|
+
if (track === 'latest') {
|
|
93
|
+
const version = Reflect.get(body, 'version');
|
|
94
|
+
return typeof version === 'string' ? version : null;
|
|
95
|
+
}
|
|
96
|
+
const tags = Reflect.get(body, 'dist-tags');
|
|
97
|
+
if (typeof tags !== 'object' || tags === null)
|
|
98
|
+
return null;
|
|
99
|
+
const latest = Reflect.get(tags, 'latest');
|
|
100
|
+
const next = Reflect.get(tags, 'next');
|
|
101
|
+
if (typeof latest !== 'string' || valid(latest) === null)
|
|
102
|
+
return null;
|
|
103
|
+
return typeof next === 'string' && isNewerVersion(next, latest) ? next : latest;
|
|
101
104
|
}
|
|
102
105
|
catch {
|
|
103
106
|
return null;
|
|
@@ -107,7 +110,7 @@ async function fetchLatestVersion() {
|
|
|
107
110
|
}
|
|
108
111
|
}
|
|
109
112
|
/**
|
|
110
|
-
* Poll the registry and persist the result. Runs in the detached background
|
|
113
|
+
* Poll the registry, upgrade an eligible global pnpm install, and persist the result. Runs in the detached background
|
|
111
114
|
* process (see update-check-refresh.ts) — never on a command's exit path.
|
|
112
115
|
* Failed fetches still record `lastCheckedAt` (keeping any previously known
|
|
113
116
|
* version) so attempts are throttled to once per interval either way. The
|
|
@@ -116,17 +119,49 @@ async function fetchLatestVersion() {
|
|
|
116
119
|
*/
|
|
117
120
|
export async function refreshUpdateCache() {
|
|
118
121
|
try {
|
|
122
|
+
const { globalUpdateTrack, maybeUpgradeGlobalPnpm } = await import('./pnpm-auto-update.js');
|
|
123
|
+
const track = await globalUpdateTrack();
|
|
119
124
|
const previous = await readCache();
|
|
120
|
-
const fetched = await fetchLatestVersion();
|
|
125
|
+
const fetched = await fetchLatestVersion(track);
|
|
126
|
+
// Track selection can change while the network request is in flight.
|
|
127
|
+
if (await globalUpdateTrack() !== track)
|
|
128
|
+
return;
|
|
129
|
+
if (fetched && fetched !== currentVersion()) {
|
|
130
|
+
await maybeUpgradeGlobalPnpm(fetched, track).catch(() => false);
|
|
131
|
+
}
|
|
121
132
|
await writeCache({
|
|
122
133
|
lastCheckedAt: Date.now(),
|
|
123
|
-
latestVersion: fetched ?? previous?.latestVersion
|
|
134
|
+
latestVersion: fetched ?? (previous?.track === track ? previous.latestVersion : null),
|
|
135
|
+
track,
|
|
124
136
|
});
|
|
125
137
|
}
|
|
126
138
|
finally {
|
|
127
139
|
await rm(updateCheckClaimPath(), { force: true }).catch(() => { });
|
|
128
140
|
}
|
|
129
141
|
}
|
|
142
|
+
async function printInstalledNotice() {
|
|
143
|
+
const path = join(dirname(updateCheckCachePath()), 'update-installed.json');
|
|
144
|
+
const claimed = `${path}.${process.pid}.claimed`;
|
|
145
|
+
try {
|
|
146
|
+
await rename(path, claimed);
|
|
147
|
+
const parsed = JSON.parse(await readFile(claimed, 'utf8'));
|
|
148
|
+
if (typeof parsed !== 'object' || parsed === null)
|
|
149
|
+
return;
|
|
150
|
+
const from = Reflect.get(parsed, 'from');
|
|
151
|
+
const to = Reflect.get(parsed, 'to');
|
|
152
|
+
const summary = Reflect.get(parsed, 'summary');
|
|
153
|
+
if (typeof from === 'string' && typeof to === 'string' && to === currentVersion()) {
|
|
154
|
+
process.stderr.write(`seq-studio updated ${from} → ${to}.${typeof summary === 'string' ? ` ${summary}` : ''} Future commands use ${to}.\n`);
|
|
155
|
+
}
|
|
156
|
+
else if (typeof from === 'string' && typeof to === 'string') {
|
|
157
|
+
await writeFile(path, JSON.stringify(parsed) + '\n', { flag: 'wx', mode: 0o600 }).catch(() => { });
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
catch { /* A notice must never affect a command. */ }
|
|
161
|
+
finally {
|
|
162
|
+
await rm(claimed, { force: true }).catch(() => { });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
130
165
|
/**
|
|
131
166
|
* Atomically claim the right to spawn a refresh. The `wx` flag makes the
|
|
132
167
|
* create exclusive at the filesystem level, so concurrent CLI processes
|
|
@@ -198,7 +233,11 @@ export async function maybeNotifyUpdate() {
|
|
|
198
233
|
return;
|
|
199
234
|
if (isCiEnvironment())
|
|
200
235
|
return;
|
|
201
|
-
|
|
236
|
+
await printInstalledNotice();
|
|
237
|
+
const { globalUpdateTrack } = await import('./pnpm-auto-update.js');
|
|
238
|
+
const selectedTrack = await globalUpdateTrack();
|
|
239
|
+
const storedCache = await readCache();
|
|
240
|
+
const cache = storedCache?.track === selectedTrack ? storedCache : null;
|
|
202
241
|
if (!cache || Date.now() - cache.lastCheckedAt > CHECK_INTERVAL_MS) {
|
|
203
242
|
// Exactly one process refreshes: the exclusive claim file elects a
|
|
204
243
|
// single refresher even across concurrent CLI invocations, and the
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sequenceholdings/studio-cli",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.18-next.0",
|
|
4
4
|
"description": "Unified Sequence Studio CLI — `seq-studio init` / `add` / `deploy` (app monorepos), `seq-studio agents`, `seq-studio process` (Lattice), `seq-studio artifact`, `seq-studio functions` / `secrets`, `seq-studio repos`, and `seq-studio auth whoami`. Includes Auth0 browser login shared with seqapi.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -33,6 +33,7 @@
|
|
|
33
33
|
"files": [
|
|
34
34
|
"dist",
|
|
35
35
|
"templates",
|
|
36
|
+
"release-summary.json",
|
|
36
37
|
"README.md"
|
|
37
38
|
],
|
|
38
39
|
"dependencies": {
|
|
@@ -52,8 +53,8 @@
|
|
|
52
53
|
"@sequenceholdings/platform": "0.1.4"
|
|
53
54
|
},
|
|
54
55
|
"peerDependencies": {
|
|
55
|
-
"@sequenceholdings/
|
|
56
|
-
"@sequenceholdings/
|
|
56
|
+
"@sequenceholdings/pipeline-spec": "0.3.10",
|
|
57
|
+
"@sequenceholdings/orm": "2.10.0"
|
|
57
58
|
},
|
|
58
59
|
"peerDependenciesMeta": {
|
|
59
60
|
"@sequenceholdings/orm": {
|
|
@@ -69,8 +70,8 @@
|
|
|
69
70
|
"@types/semver": "^7.8.0",
|
|
70
71
|
"typescript": "^5.6.0",
|
|
71
72
|
"vitest": "^4.1.12",
|
|
72
|
-
"@sequenceholdings/
|
|
73
|
-
"@sequenceholdings/
|
|
73
|
+
"@sequenceholdings/pipeline-spec": "0.3.10",
|
|
74
|
+
"@sequenceholdings/orm": "2.10.0"
|
|
74
75
|
},
|
|
75
76
|
"engines": {
|
|
76
77
|
"node": ">=20"
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
{
|
|
2
|
+
"0.9.17": "Global pnpm 10 installs now update automatically to latest after a background check. If a command fails to start during an update, retry it. Use seq-studio updater track next for previews.",
|
|
3
|
+
"0.9.18-next.0": "Preview build for testing automatic CLI updates on the next track. No command behavior changes."
|
|
4
|
+
}
|