@bitmagic/cli 0.1.53-dev.1 → 0.1.53-dev.11
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 +140 -36
- package/dist/assets/revoxelize.d.ts +61 -1
- package/dist/assets/revoxelize.js +157 -13
- package/dist/assets/revoxelize.js.map +1 -1
- package/dist/cli.d.ts +35 -1
- package/dist/cli.js +18 -1
- package/dist/cli.js.map +1 -1
- package/dist/commands/assets.js +3 -2
- package/dist/commands/assets.js.map +1 -1
- package/dist/commands/build.d.ts +4 -0
- package/dist/commands/build.js +7 -1
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/cover.d.ts +5 -0
- package/dist/commands/cover.js +3 -0
- package/dist/commands/cover.js.map +1 -1
- package/dist/commands/dev.js +1 -2
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/forge.d.ts +4 -0
- package/dist/commands/forge.js +9 -0
- package/dist/commands/forge.js.map +1 -1
- package/dist/commands/generate.d.ts +25 -0
- package/dist/commands/generate.js +80 -8
- package/dist/commands/generate.js.map +1 -1
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.js +12 -1
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/publish.d.ts +39 -5
- package/dist/commands/publish.js +102 -21
- package/dist/commands/publish.js.map +1 -1
- package/dist/commands/reload.js +1 -3
- package/dist/commands/reload.js.map +1 -1
- package/dist/commands/reset-account.js +25 -8
- package/dist/commands/reset-account.js.map +1 -1
- package/dist/commands/self-update.d.ts +67 -0
- package/dist/commands/self-update.js +196 -0
- package/dist/commands/self-update.js.map +1 -0
- package/dist/commands/upgrade.js +5 -2
- package/dist/commands/upgrade.js.map +1 -1
- package/dist/editor/asset-detail-panel.d.ts +2 -2
- package/dist/editor/asset-detail-panel.js +5 -2
- package/dist/editor/asset-detail-panel.js.map +1 -1
- package/dist/editor/cli-update.d.ts +32 -0
- package/dist/editor/cli-update.js +67 -0
- package/dist/editor/cli-update.js.map +1 -0
- package/dist/editor/publish-panel.d.ts +31 -0
- package/dist/editor/publish-panel.js +69 -0
- package/dist/editor/publish-panel.js.map +1 -0
- package/dist/editor/server.js +43 -1
- package/dist/editor/server.js.map +1 -1
- package/dist/editor/shell-page.js +249 -8
- package/dist/editor/shell-page.js.map +1 -1
- package/dist/forge/upload-proxy.d.ts +14 -0
- package/dist/forge/upload-proxy.js +28 -1
- package/dist/forge/upload-proxy.js.map +1 -1
- package/dist/generate/model.d.ts +7 -0
- package/dist/generate/model.js +13 -3
- package/dist/generate/model.js.map +1 -1
- package/dist/generate/prop.d.ts +20 -0
- package/dist/generate/prop.js +22 -2
- package/dist/generate/prop.js.map +1 -1
- package/dist/generate/vehicle.d.ts +2 -0
- package/dist/generate/vehicle.js +1 -0
- package/dist/generate/vehicle.js.map +1 -1
- package/dist/project/dev-handle.d.ts +28 -0
- package/dist/project/dev-handle.js +43 -0
- package/dist/project/dev-handle.js.map +1 -1
- package/dist/project/jobs.js +11 -9
- package/dist/project/jobs.js.map +1 -1
- package/dist/publish/bundle.d.ts +35 -8
- package/dist/publish/bundle.js +41 -13
- package/dist/publish/bundle.js.map +1 -1
- package/dist/publish/client.d.ts +13 -2
- package/dist/publish/client.js.map +1 -1
- package/dist/publish/record.d.ts +22 -0
- package/dist/publish/record.js +62 -0
- package/dist/publish/record.js.map +1 -0
- package/dist/render/qr-output.d.ts +44 -0
- package/dist/render/qr-output.js +71 -0
- package/dist/render/qr-output.js.map +1 -0
- package/dist/render/qr-png.d.ts +37 -0
- package/dist/render/qr-png.js +111 -0
- package/dist/render/qr-png.js.map +1 -0
- package/dist/render/qr-terminal.d.ts +63 -0
- package/dist/render/qr-terminal.js +142 -0
- package/dist/render/qr-terminal.js.map +1 -0
- package/dist/render/qr.d.ts +51 -0
- package/dist/render/qr.js +516 -0
- package/dist/render/qr.js.map +1 -0
- package/dist/scaffold/project-files.d.ts +42 -9
- package/dist/scaffold/project-files.js +242 -43
- package/dist/scaffold/project-files.js.map +1 -1
- package/dist/scaffold/project.js +2 -1
- package/dist/scaffold/project.js.map +1 -1
- package/dist/scaffold/suggest-template.d.ts +2 -0
- package/dist/scaffold/suggest-template.js +2 -1
- package/dist/scaffold/suggest-template.js.map +1 -1
- package/dist/telemetry/command-context.d.ts +12 -0
- package/dist/telemetry/command-context.js +7 -0
- package/dist/telemetry/command-context.js.map +1 -1
- package/dist/telemetry/creator-prompt.d.ts +35 -0
- package/dist/telemetry/creator-prompt.js +45 -0
- package/dist/telemetry/creator-prompt.js.map +1 -0
- package/dist/update/check.js +2 -1
- package/dist/update/check.js.map +1 -1
- package/dist/update/notice.d.ts +31 -1
- package/dist/update/notice.js +39 -5
- package/dist/update/notice.js.map +1 -1
- package/dist/update/self-install.d.ts +175 -0
- package/dist/update/self-install.js +335 -0
- package/dist/update/self-install.js.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where this CLI is installed, and how to reinstall it *there*.
|
|
3
|
+
*
|
|
4
|
+
* The problem this module exists for: until now every update path in the CLI was a printed
|
|
5
|
+
* string — `npm i -g @bitmagic/cli` — for a person or an agent to run in some other shell. That
|
|
6
|
+
* only works if the `npm` on that shell's PATH owns this install, and on a machine using nvm it
|
|
7
|
+
* routinely does not. A coding agent's non-interactive shell sources no profile, so nvm never
|
|
8
|
+
* loads, `npm` resolves to Homebrew's (or to nothing), and the install lands in a prefix whose
|
|
9
|
+
* `bin/` is not the one the creator's `bitmagic` comes from. npm reports success, the next
|
|
10
|
+
* `bitmagic` run is still the old build, and nothing anywhere says so.
|
|
11
|
+
*
|
|
12
|
+
* The fix is to stop asking the shell. `process.execPath` is the node binary running right now and
|
|
13
|
+
* `import.meta.url` is inside the installed package; between them the prefix, the package manager
|
|
14
|
+
* and the target directory are all derivable, and neither depends on the environment. This is how
|
|
15
|
+
* npm updates itself, and it is why every function here takes its inputs as arguments instead of
|
|
16
|
+
* reading them from a lookup that a stripped PATH can change the answer to.
|
|
17
|
+
*
|
|
18
|
+
* Everything that decides is a pure function over a path plus an `exists` probe, so the install
|
|
19
|
+
* shapes this has to survive — nvm, Homebrew, pnpm's two-root side-by-side recipe from the README,
|
|
20
|
+
* an npx cache, a repo checkout — are a test table rather than six machines.
|
|
21
|
+
*/
|
|
22
|
+
import { spawnSync } from 'child_process';
|
|
23
|
+
import * as fs from 'fs';
|
|
24
|
+
import * as path from 'path';
|
|
25
|
+
import { createRequire } from 'module';
|
|
26
|
+
/** The npm package this CLI is published as. */
|
|
27
|
+
export const PACKAGE_NAME = '@bitmagic/cli';
|
|
28
|
+
const realExists = (candidate) => fs.existsSync(candidate);
|
|
29
|
+
export function isUpdatable(location) {
|
|
30
|
+
return location.kind === 'npm-global' || location.kind === 'pnpm-global';
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* This package's own directory on disk.
|
|
34
|
+
*
|
|
35
|
+
* `../../package.json` resolves to this package's manifest from both `dist/update/` and
|
|
36
|
+
* `src/update/`, which is the same specifier — and the same reason — as
|
|
37
|
+
* `cli-version.ts`'s `currentCliVersion`. Node resolves symlinks here, so under pnpm this is the
|
|
38
|
+
* store directory rather than the linked one; `classifyInstall` is written for that.
|
|
39
|
+
*/
|
|
40
|
+
export function packageDirFrom(moduleUrl) {
|
|
41
|
+
return path.dirname(createRequire(moduleUrl).resolve('../../package.json'));
|
|
42
|
+
}
|
|
43
|
+
const DIGITS = /^\d+$/;
|
|
44
|
+
/**
|
|
45
|
+
* Read the install shape straight off the resolved package path.
|
|
46
|
+
*
|
|
47
|
+
* Order matters: an npx cache and a checkout both sit under directory names that would otherwise
|
|
48
|
+
* be read as an ordinary install, so they are excluded first. The remaining two are told apart by
|
|
49
|
+
* the store layout each package manager writes, not by asking which manager is on PATH — that
|
|
50
|
+
* question has the same wrong answer as the one this module exists to stop asking.
|
|
51
|
+
*/
|
|
52
|
+
export function classifyInstall(packageDir, exists = realExists) {
|
|
53
|
+
const segments = packageDir.split(path.sep);
|
|
54
|
+
// `npx @bitmagic/cli` unpacks into npm's `_npx` cache and throws it away. There is no install
|
|
55
|
+
// here for an update to move, and reinstalling into the cache would achieve nothing.
|
|
56
|
+
if (segments.includes('_npx'))
|
|
57
|
+
return { kind: 'npx', packageDir };
|
|
58
|
+
// The published package is `dist` + `LICENSE.md` + `README.md` + `package.json`; `src/` only
|
|
59
|
+
// exists in the repo. Catches both a checkout run directly and a `pnpm link -g` of one.
|
|
60
|
+
if (exists(path.join(packageDir, 'src')))
|
|
61
|
+
return { kind: 'linked-dev', packageDir };
|
|
62
|
+
const pnpm = classifyPnpm(segments);
|
|
63
|
+
if (pnpm !== null)
|
|
64
|
+
return { ...pnpm, packageDir, binDir: pnpmBinDir(pnpm.globalDir, exists) };
|
|
65
|
+
// A `.pnpm` store that `classifyPnpm` did not claim is a project's, not the machine's. It is
|
|
66
|
+
// shaped enough like an npm tree for the check below to read a "prefix" out of it — which would
|
|
67
|
+
// be a package directory inside the store, and installing there would corrupt one project's
|
|
68
|
+
// dependencies on behalf of a command the creator meant for their whole machine.
|
|
69
|
+
if (segments.includes('.pnpm'))
|
|
70
|
+
return { kind: 'unknown', packageDir };
|
|
71
|
+
const npm = classifyNpm(segments, exists);
|
|
72
|
+
if (npm !== null)
|
|
73
|
+
return { ...npm, packageDir };
|
|
74
|
+
return { kind: 'unknown', packageDir };
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* pnpm's global store: `<globalDir>/<n>/node_modules/.pnpm/@bitmagic+cli@<v>/node_modules/@bitmagic/cli`.
|
|
78
|
+
*
|
|
79
|
+
* The numbered directory is pnpm's store-layout version, and requiring it is what separates a
|
|
80
|
+
* GLOBAL pnpm install from a project-local one — a `.pnpm` directory inside a project's
|
|
81
|
+
* node_modules has no such parent, and reinstalling globally on its behalf would be wrong.
|
|
82
|
+
*/
|
|
83
|
+
function classifyPnpm(segments) {
|
|
84
|
+
const store = segments.indexOf('.pnpm');
|
|
85
|
+
if (store < 2)
|
|
86
|
+
return null;
|
|
87
|
+
if (segments[store - 1] !== 'node_modules')
|
|
88
|
+
return null;
|
|
89
|
+
if (!DIGITS.test(segments[store - 2] ?? ''))
|
|
90
|
+
return null;
|
|
91
|
+
const modulesRoot = segments.slice(0, store).join(path.sep);
|
|
92
|
+
return {
|
|
93
|
+
kind: 'pnpm-global',
|
|
94
|
+
verifyDir: path.join(modulesRoot, '@bitmagic', 'cli'),
|
|
95
|
+
modulesRoot,
|
|
96
|
+
globalDir: segments.slice(0, store - 2).join(path.sep),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* npm's global root: `<prefix>/lib/node_modules/@bitmagic/cli` on unix, and
|
|
101
|
+
* `<prefix>/node_modules/@bitmagic/cli` on Windows, where the prefix is the node installation
|
|
102
|
+
* itself rather than a `lib` inside it.
|
|
103
|
+
*
|
|
104
|
+
* That second shape is also what a project-local dependency looks like, and the two have to be
|
|
105
|
+
* told apart: a node prefix has no `package.json` beside its `node_modules`, and a project does.
|
|
106
|
+
* Without the distinction, a CLI listed as a project's devDependency would answer `self-update`
|
|
107
|
+
* by installing globally into the project directory. The unix shape needs no such check — nothing
|
|
108
|
+
* puts a project's manifest two levels above its own `lib/node_modules`.
|
|
109
|
+
*/
|
|
110
|
+
function classifyNpm(segments, exists) {
|
|
111
|
+
const end = segments.length;
|
|
112
|
+
if (segments[end - 1] !== 'cli' || segments[end - 2] !== '@bitmagic')
|
|
113
|
+
return null;
|
|
114
|
+
if (segments[end - 3] !== 'node_modules')
|
|
115
|
+
return null;
|
|
116
|
+
const modulesRoot = segments.slice(0, end - 2).join(path.sep);
|
|
117
|
+
const underLib = segments[end - 4] === 'lib';
|
|
118
|
+
const prefix = segments.slice(0, underLib ? end - 4 : end - 3).join(path.sep);
|
|
119
|
+
if (prefix === '')
|
|
120
|
+
return null;
|
|
121
|
+
if (!underLib && exists(path.join(prefix, 'package.json')))
|
|
122
|
+
return null;
|
|
123
|
+
return {
|
|
124
|
+
kind: 'npm-global',
|
|
125
|
+
verifyDir: path.join(modulesRoot, '@bitmagic', 'cli'),
|
|
126
|
+
modulesRoot,
|
|
127
|
+
prefix,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* pnpm refuses `add -g` without a global bin directory it can write, and there is no way to read
|
|
132
|
+
* back the one an install used — `PNPM_HOME` is a shell variable, and the whole point here is that
|
|
133
|
+
* the shell may tell us nothing. So it is recovered from the disk instead: the directory holding
|
|
134
|
+
* the `bitmagic` command that this install produced.
|
|
135
|
+
*
|
|
136
|
+
* `<globalDir>/bin` is the README's two-root recipe (`--global-dir ~/.bitmagic-cli/prod
|
|
137
|
+
* --global-bin-dir ~/.bitmagic-cli/prod/bin`); the parent of `globalDir` is pnpm's own default,
|
|
138
|
+
* where `~/Library/pnpm/global` pairs with `~/Library/pnpm`.
|
|
139
|
+
*
|
|
140
|
+
* Undefined when neither holds the command — the caller then refuses rather than installing into
|
|
141
|
+
* a guessed root, which is the failure mode this module exists to prevent.
|
|
142
|
+
*/
|
|
143
|
+
export function pnpmBinDir(globalDir, exists = realExists) {
|
|
144
|
+
const candidates = [path.join(globalDir, 'bin'), path.dirname(globalDir)];
|
|
145
|
+
return candidates.find((dir) => exists(path.join(dir, 'bitmagic')));
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* How far above the node binary to look for the npm that ships with it.
|
|
149
|
+
*
|
|
150
|
+
* One level covers nvm, fnm and a plain tarball install (`<prefix>/bin/node` beside
|
|
151
|
+
* `<prefix>/lib/node_modules/npm`). Homebrew needs four: `process.execPath` is the RESOLVED path,
|
|
152
|
+
* so a `/opt/homebrew/bin/node` symlink reports itself as
|
|
153
|
+
* `/opt/homebrew/Cellar/node/<version>/bin/node` — and the Cellar directory has no `lib/node_modules`
|
|
154
|
+
* at all, because Homebrew links npm into the prefix rather than keeping it with the keg. Six is
|
|
155
|
+
* that case with room to spare, and still far short of anywhere a stray npm could plausibly sit.
|
|
156
|
+
*/
|
|
157
|
+
const NODE_ROOT_SEARCH_DEPTH = 6;
|
|
158
|
+
/** `dir` and its ancestors, nearest first, stopping at the filesystem root. */
|
|
159
|
+
function selfAndAncestors(dir, depth) {
|
|
160
|
+
const roots = [];
|
|
161
|
+
let current = dir;
|
|
162
|
+
for (let i = 0; i <= depth; i += 1) {
|
|
163
|
+
roots.push(current);
|
|
164
|
+
const parent = path.dirname(current);
|
|
165
|
+
if (parent === current)
|
|
166
|
+
break;
|
|
167
|
+
current = parent;
|
|
168
|
+
}
|
|
169
|
+
return roots;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* npm, found without consulting PATH.
|
|
173
|
+
*
|
|
174
|
+
* npm ships inside the node installation, so the node binary executing this process names it —
|
|
175
|
+
* and running that script with `process.execPath` is the whole fix: it is by construction the same
|
|
176
|
+
* node, and therefore the same global prefix, this CLI was installed into, whatever nvm did or did
|
|
177
|
+
* not do to PATH.
|
|
178
|
+
*
|
|
179
|
+
* The install's own prefix is tried first, because that is where the package demonstrably lives;
|
|
180
|
+
* the node's own tree is the fallback for the ordinary case where a global prefix carries no npm
|
|
181
|
+
* of its own.
|
|
182
|
+
*/
|
|
183
|
+
export function npmCommand(execPath, installPrefix, exists = realExists) {
|
|
184
|
+
const roots = [
|
|
185
|
+
...(installPrefix === undefined ? [] : [installPrefix]),
|
|
186
|
+
...selfAndAncestors(path.dirname(execPath), NODE_ROOT_SEARCH_DEPTH),
|
|
187
|
+
];
|
|
188
|
+
for (const root of roots) {
|
|
189
|
+
// `lib/node_modules` on unix; `node_modules` directly under the prefix on Windows.
|
|
190
|
+
for (const middle of [['lib', 'node_modules'], ['node_modules']]) {
|
|
191
|
+
const script = path.join(root, ...middle, 'npm', 'bin', 'npm-cli.js');
|
|
192
|
+
if (exists(script))
|
|
193
|
+
return { command: execPath, leadingArgs: [script], fromPath: false };
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
return { command: 'npm', leadingArgs: [], fromPath: true };
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* pnpm, which — unlike npm — is not bundled with node and so cannot be located from `execPath`.
|
|
200
|
+
*
|
|
201
|
+
* The best that can be done is the directory pnpm itself installed the `bitmagic` command into,
|
|
202
|
+
* which for a default install is also where the `pnpm` command lives. Failing that the name is
|
|
203
|
+
* left to PATH; a pnpm user whose shell has no pnpm gets a clear refusal naming the resolved
|
|
204
|
+
* global dir, which is still strictly better than an install silently landing elsewhere.
|
|
205
|
+
*/
|
|
206
|
+
export function pnpmCommand(globalDir, binDir, exists = realExists) {
|
|
207
|
+
const candidates = [binDir, path.dirname(globalDir)].filter((dir) => dir !== undefined);
|
|
208
|
+
for (const dir of candidates) {
|
|
209
|
+
const binary = path.join(dir, 'pnpm');
|
|
210
|
+
if (exists(binary))
|
|
211
|
+
return { command: binary, leadingArgs: [], fromPath: false };
|
|
212
|
+
}
|
|
213
|
+
return { command: 'pnpm', leadingArgs: [], fromPath: true };
|
|
214
|
+
}
|
|
215
|
+
/** The manager that owns `location`, resolved without PATH wherever that is possible. */
|
|
216
|
+
export function managerFor(location, execPath, exists = realExists) {
|
|
217
|
+
return location.kind === 'npm-global'
|
|
218
|
+
? npmCommand(execPath, location.prefix, exists)
|
|
219
|
+
: pnpmCommand(location.globalDir, location.binDir, exists);
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Install `spec` into exactly this location.
|
|
223
|
+
*
|
|
224
|
+
* The target is named explicitly (`--prefix` / `--global-dir`) even though the executable resolved
|
|
225
|
+
* above already implies it, because the two say different things: the executable decides which
|
|
226
|
+
* npm runs, the flag decides where it writes. The README's side-by-side recipe puts two installs
|
|
227
|
+
* under one node, so only the flag can tell them apart.
|
|
228
|
+
*
|
|
229
|
+
* `--prefer-online` is not belt-and-braces. The CLI pins its three `@bitmagic/*` dependencies to
|
|
230
|
+
* exact versions and publishes last, so for a few minutes after a release an installer holding a
|
|
231
|
+
* stale packument resolves the new CLI and then fails ETARGET on a dependency that is already
|
|
232
|
+
* there — see docs/npm-publishing.md, "The first minutes after a release". Forcing the refetch is
|
|
233
|
+
* the documented fix.
|
|
234
|
+
*/
|
|
235
|
+
export function installArgs(location, spec) {
|
|
236
|
+
if (location.kind === 'pnpm-global') {
|
|
237
|
+
return [
|
|
238
|
+
'add',
|
|
239
|
+
'-g',
|
|
240
|
+
'--global-dir',
|
|
241
|
+
location.globalDir,
|
|
242
|
+
...(location.binDir === undefined ? [] : ['--global-bin-dir', location.binDir]),
|
|
243
|
+
spec,
|
|
244
|
+
];
|
|
245
|
+
}
|
|
246
|
+
return ['install', '-g', '--prefix', location.prefix, spec, '--prefer-online'];
|
|
247
|
+
}
|
|
248
|
+
/** The mirror of `installArgs`, for `bitmagic reset-account`'s "start over like a new creator". */
|
|
249
|
+
export function uninstallArgs(location) {
|
|
250
|
+
if (location.kind === 'pnpm-global') {
|
|
251
|
+
return [
|
|
252
|
+
'remove',
|
|
253
|
+
'-g',
|
|
254
|
+
'--global-dir',
|
|
255
|
+
location.globalDir,
|
|
256
|
+
...(location.binDir === undefined ? [] : ['--global-bin-dir', location.binDir]),
|
|
257
|
+
PACKAGE_NAME,
|
|
258
|
+
];
|
|
259
|
+
}
|
|
260
|
+
return ['uninstall', '-g', '--prefix', location.prefix, PACKAGE_NAME];
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* npm's own environment overrides are stripped before it runs.
|
|
264
|
+
*
|
|
265
|
+
* When the CLI is invoked from an npm script (an agent doing `npm run something` that shells out),
|
|
266
|
+
* npm exports its whole config as `npm_config_*`. `npm_config_prefix` in particular names the
|
|
267
|
+
* prefix of the OUTER npm, which is exactly the wrong answer here and exactly the confusion this
|
|
268
|
+
* module removes. Only the prefix keys are dropped: a corporate `npm_config_registry` is a
|
|
269
|
+
* legitimate setting that an update must keep honouring.
|
|
270
|
+
*/
|
|
271
|
+
function environmentWithoutNpmPrefix() {
|
|
272
|
+
const env = { ...process.env };
|
|
273
|
+
delete env.npm_config_prefix;
|
|
274
|
+
delete env.npm_config_global_prefix;
|
|
275
|
+
delete env.NPM_CONFIG_PREFIX;
|
|
276
|
+
return env;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Output is CAPTURED, not inherited — the same rule, for the same reason, as
|
|
280
|
+
* `reset-account`'s uninstall: under `--json` this CLI's stdout is contractually one document, and
|
|
281
|
+
* a subprocess writing its own progress there would corrupt it. Nothing is printed unless the
|
|
282
|
+
* install fails, and then it goes out through the `Output` seam like every other line.
|
|
283
|
+
*/
|
|
284
|
+
export const realSpawnManager = (command, args) => {
|
|
285
|
+
const result = spawnSync(command, args, { encoding: 'utf-8', env: environmentWithoutNpmPrefix() });
|
|
286
|
+
return {
|
|
287
|
+
status: result.status,
|
|
288
|
+
stdout: result.stdout ?? '',
|
|
289
|
+
stderr: result.stderr ?? '',
|
|
290
|
+
error: result.error,
|
|
291
|
+
};
|
|
292
|
+
};
|
|
293
|
+
/**
|
|
294
|
+
* The version sitting in `dir` right now, read off the disk.
|
|
295
|
+
*
|
|
296
|
+
* Deliberately not `currentCliVersion()`: that reports the manifest this process loaded at start,
|
|
297
|
+
* which after an update is the OLD one. Reading the file again is the only way to tell an install
|
|
298
|
+
* that moved from one that reported success and did nothing — the silent no-op that this whole
|
|
299
|
+
* module exists to make impossible.
|
|
300
|
+
*/
|
|
301
|
+
export function readInstalledVersion(dir, readFile = (p) => fs.readFileSync(p, 'utf-8')) {
|
|
302
|
+
try {
|
|
303
|
+
const parsed = JSON.parse(readFile(path.join(dir, 'package.json')));
|
|
304
|
+
if (typeof parsed !== 'object' || parsed === null)
|
|
305
|
+
return null;
|
|
306
|
+
const version = parsed.version;
|
|
307
|
+
return typeof version === 'string' ? version : null;
|
|
308
|
+
}
|
|
309
|
+
catch {
|
|
310
|
+
return null;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/** Whether `dir` can be written to, checked before spawning an install that would fail on it. */
|
|
314
|
+
export function isWritable(dir, access = (p) => fs.accessSync(p, fs.constants.W_OK)) {
|
|
315
|
+
try {
|
|
316
|
+
access(dir);
|
|
317
|
+
return true;
|
|
318
|
+
}
|
|
319
|
+
catch {
|
|
320
|
+
return false;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* npm's answer when a version it can see on the registry is not yet in its cached packument. The
|
|
325
|
+
* documented remedy is to retry, which is what the caller does — once, and only for this.
|
|
326
|
+
*/
|
|
327
|
+
export function isStalePackumentFailure(outcome) {
|
|
328
|
+
const text = `${outcome.stdout}\n${outcome.stderr}`;
|
|
329
|
+
return text.includes('ETARGET') || text.includes('No matching version found');
|
|
330
|
+
}
|
|
331
|
+
/** Where this build actually is. The one impure entry point; everything above it is a pure rule. */
|
|
332
|
+
export function resolveInstall(moduleUrl, exists = realExists) {
|
|
333
|
+
return classifyInstall(packageDirFrom(moduleUrl), exists);
|
|
334
|
+
}
|
|
335
|
+
//# sourceMappingURL=self-install.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self-install.js","sourceRoot":"","sources":["../../src/update/self-install.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAEvC,gDAAgD;AAChD,MAAM,CAAC,MAAM,YAAY,GAAG,eAAe,CAAC;AAK5C,MAAM,UAAU,GAAW,CAAC,SAAS,EAAE,EAAE,CAAC,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AAgDnE,MAAM,UAAU,WAAW,CAAC,QAAyB;IACnD,OAAO,QAAQ,CAAC,IAAI,KAAK,YAAY,IAAI,QAAQ,CAAC,IAAI,KAAK,aAAa,CAAC;AAC3E,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,cAAc,CAAC,SAAiB;IAC9C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AC,CAAC;AAChF,CAAC;AAED,oGAAoG;AACpG,MAAM,UAAU,cAAc,CAAC,SAAiB,EAAE,SAAiB,UAAU;IAC3E,OAAO,eAAe,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC,CAAC;AAC5D,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitmagic/cli",
|
|
3
|
-
"version": "0.1.53-dev.
|
|
3
|
+
"version": "0.1.53-dev.11",
|
|
4
4
|
"description": "Build Bitmagic games from your own agent tool",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
6
6
|
"author": "Bitmagic Oy",
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
"fflate": "^0.8.2",
|
|
24
24
|
"playwright-core": "^1.59.1",
|
|
25
25
|
"tar": "^7.4.3",
|
|
26
|
-
"@bitmagic/
|
|
27
|
-
"@bitmagic/
|
|
28
|
-
"@bitmagic/
|
|
26
|
+
"@bitmagic/animation-forger": "0.1.8-dev.11",
|
|
27
|
+
"@bitmagic/asset-core": "0.2.8-dev.11",
|
|
28
|
+
"@bitmagic/world-forger": "0.1.13-dev.11"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@eslint/js": "^9.38.0",
|