@detergent-software/atk 9.3.1-dev.1 → 9.4.0-dev.10
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/CHANGELOG.md +83 -0
- package/build/command-manifest.json +9 -9
- package/build/commands/freeze.d.ts.map +1 -1
- package/build/commands/freeze.js +3 -1
- package/build/commands/freeze.js.map +1 -1
- package/build/commands/info.js +1 -0
- package/build/commands/info.js.map +1 -1
- package/build/commands/install.d.ts.map +1 -1
- package/build/commands/install.js +289 -90
- package/build/commands/install.js.map +1 -1
- package/build/commands/outdated.d.ts.map +1 -1
- package/build/commands/outdated.js +2 -1
- package/build/commands/outdated.js.map +1 -1
- package/build/commands/pin.js +1 -1
- package/build/commands/pin.js.map +1 -1
- package/build/commands/sync.d.ts.map +1 -1
- package/build/commands/sync.js +26 -13
- package/build/commands/sync.js.map +1 -1
- package/build/commands/thaw.d.ts.map +1 -1
- package/build/commands/thaw.js +5 -1
- package/build/commands/thaw.js.map +1 -1
- package/build/commands/uninstall.d.ts.map +1 -1
- package/build/commands/uninstall.js +6 -1
- package/build/commands/uninstall.js.map +1 -1
- package/build/commands/unpin.d.ts.map +1 -1
- package/build/commands/unpin.js +5 -1
- package/build/commands/unpin.js.map +1 -1
- package/build/commands/update.d.ts.map +1 -1
- package/build/commands/update.js +18 -8
- package/build/commands/update.js.map +1 -1
- package/build/components/AssetDetail.d.ts.map +1 -1
- package/build/components/AssetDetail.js +1 -1
- package/build/components/AssetDetail.js.map +1 -1
- package/build/components/PreferredScopeQuestion.d.ts +16 -0
- package/build/components/PreferredScopeQuestion.d.ts.map +1 -0
- package/build/components/PreferredScopeQuestion.js +20 -0
- package/build/components/PreferredScopeQuestion.js.map +1 -0
- package/build/components/PreferredScopeWarning.d.ts +17 -0
- package/build/components/PreferredScopeWarning.d.ts.map +1 -0
- package/build/components/PreferredScopeWarning.js +13 -0
- package/build/components/PreferredScopeWarning.js.map +1 -0
- package/build/components/index.d.ts +2 -0
- package/build/components/index.d.ts.map +1 -1
- package/build/components/index.js +2 -0
- package/build/components/index.js.map +1 -1
- package/build/hooks/useListActions.d.ts.map +1 -1
- package/build/hooks/useListActions.js +5 -1
- package/build/hooks/useListActions.js.map +1 -1
- package/build/hooks/useUninstallState.d.ts.map +1 -1
- package/build/hooks/useUninstallState.js +16 -12
- package/build/hooks/useUninstallState.js.map +1 -1
- package/build/lib/asset-tools.d.ts +2 -0
- package/build/lib/asset-tools.d.ts.map +1 -1
- package/build/lib/asset-tools.js +4 -0
- package/build/lib/asset-tools.js.map +1 -1
- package/build/lib/atk-schemas/index.d.ts +1 -1
- package/build/lib/atk-schemas/index.d.ts.map +1 -1
- package/build/lib/atk-schemas/index.js +1 -1
- package/build/lib/atk-schemas/index.js.map +1 -1
- package/build/lib/atk-schemas/manifest.d.ts +14 -0
- package/build/lib/atk-schemas/manifest.d.ts.map +1 -1
- package/build/lib/atk-schemas/manifest.js +3 -0
- package/build/lib/atk-schemas/manifest.js.map +1 -1
- package/build/lib/atk-schemas/registry.d.ts +16 -0
- package/build/lib/atk-schemas/registry.d.ts.map +1 -1
- package/build/lib/atk-schemas/registry.js +2 -1
- package/build/lib/atk-schemas/registry.js.map +1 -1
- package/build/lib/diff-command.d.ts +6 -1
- package/build/lib/diff-command.d.ts.map +1 -1
- package/build/lib/diff-command.js +25 -28
- package/build/lib/diff-command.js.map +1 -1
- package/build/lib/install-targets.d.ts +35 -8
- package/build/lib/install-targets.d.ts.map +1 -1
- package/build/lib/install-targets.js +78 -11
- package/build/lib/install-targets.js.map +1 -1
- package/build/lib/installer.d.ts +9 -3
- package/build/lib/installer.d.ts.map +1 -1
- package/build/lib/installer.js +28 -10
- package/build/lib/installer.js.map +1 -1
- package/build/lib/multi-tool-install.d.ts +35 -6
- package/build/lib/multi-tool-install.d.ts.map +1 -1
- package/build/lib/multi-tool-install.js +128 -31
- package/build/lib/multi-tool-install.js.map +1 -1
- package/build/lib/named-entry.d.ts +10 -2
- package/build/lib/named-entry.d.ts.map +1 -1
- package/build/lib/named-entry.js +23 -9
- package/build/lib/named-entry.js.map +1 -1
- package/build/lib/org.d.ts +32 -13
- package/build/lib/org.d.ts.map +1 -1
- package/build/lib/org.js +36 -12
- package/build/lib/org.js.map +1 -1
- package/build/lib/preferred-scope.d.ts +38 -0
- package/build/lib/preferred-scope.d.ts.map +1 -0
- package/build/lib/preferred-scope.js +53 -0
- package/build/lib/preferred-scope.js.map +1 -0
- package/build/lib/updater.d.ts +30 -5
- package/build/lib/updater.d.ts.map +1 -1
- package/build/lib/updater.js +114 -27
- package/build/lib/updater.js.map +1 -1
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import { Box, Text, useApp } from 'ink';
|
|
3
3
|
import { Fragment, useCallback, useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { z } from 'zod';
|
|
5
|
-
import { CrossScopeWarning, DryRunBanner, ErrorView, InstallSummary, MultiSelectList, Spinner, } from '../components/index.js';
|
|
5
|
+
import { CrossScopeWarning, DryRunBanner, ErrorView, InstallSummary, MultiSelectList, PreferredScopeQuestion, PreferredScopeWarning, Spinner, } from '../components/index.js';
|
|
6
6
|
import { useCommand } from '../hooks/useCommand.js';
|
|
7
7
|
import { useResolvedScope } from '../hooks/useResolvedScope.js';
|
|
8
8
|
import { placesAsset } from '../lib/asset-tools.js';
|
|
@@ -10,15 +10,16 @@ import { resolveBundleVersion } from '../lib/bundle-version.js';
|
|
|
10
10
|
import { loadConfig } from '../lib/config.js';
|
|
11
11
|
import { crossScopeNotice, findCrossScopeInstalls } from '../lib/cross-scope.js';
|
|
12
12
|
import { errorGuidance, errorMessage } from '../lib/errors.js';
|
|
13
|
-
import { bundleMembers, installPlannedTargets, isBundleInPlace, planTargetsInstall } from '../lib/install-targets.js';
|
|
13
|
+
import { bundleInPlacePin, bundleMembers, inPlacePin, installPlannedTargets, isBundleInPlace, membersInPlace, pinMembersInPlace, planTargetsInstall, } from '../lib/install-targets.js';
|
|
14
14
|
import { isInstalledForTool } from '../lib/installed-for-tool.js';
|
|
15
15
|
import { InstallerError } from '../lib/installer.js';
|
|
16
|
-
import { addAssetToLockfile, findInstalledAsset, identityKey, readLockfile, upgradeToDirectInstall, withLockfileErrorHandling, writeLockfile, } from '../lib/lockfile.js';
|
|
16
|
+
import { addAssetToLockfile, findInstalledAsset, identityKey, pinAssetVersion, readLockfile, upgradeToDirectInstall, withLockfileErrorHandling, writeLockfile, } from '../lib/lockfile.js';
|
|
17
17
|
import { executeInstallPlanForTools, withoutKeptDependencies } from '../lib/multi-tool-install.js';
|
|
18
18
|
import { addNotice } from '../lib/notices.js';
|
|
19
|
-
import { formatOrgName, isBareOrgScope,
|
|
19
|
+
import { formatOrgName, inlineOrgOf, isBareOrgScope, parseNameScope, resolveActiveOrg, resolveSpecOrg, } from '../lib/org.js';
|
|
20
20
|
import { renderJson, useNonInteractive } from '../lib/output.js';
|
|
21
21
|
import { argument, option } from '../lib/pastel/index.js';
|
|
22
|
+
import { canInstallAt, preferredScopeNotice, preferredScopeOf } from '../lib/preferred-scope.js';
|
|
22
23
|
import { fetchRegistry, findAsset, findAssetsByName, findBundle, getAssetsByOrg, isDeprecated, isLatestAlias, } from '../lib/registry.js';
|
|
23
24
|
import { resolveBundleInstallPlan, resolveInstallPlan, resolveMultipleInstallPlans, ResolverError, } from '../lib/resolver.js';
|
|
24
25
|
import { scopeLabel } from '../lib/scope.js';
|
|
@@ -107,7 +108,7 @@ export const options = z.object({
|
|
|
107
108
|
.default(false)
|
|
108
109
|
.describe(option({
|
|
109
110
|
alias: 'y',
|
|
110
|
-
description:
|
|
111
|
+
description: "Alias for --all: install every asset from an org scope without prompting; also installs at the scope asked without asking about an asset's preferred scope",
|
|
111
112
|
})),
|
|
112
113
|
});
|
|
113
114
|
export const args = z
|
|
@@ -116,7 +117,7 @@ export const args = z
|
|
|
116
117
|
.string()
|
|
117
118
|
.optional()
|
|
118
119
|
.describe(argument({
|
|
119
|
-
description: 'Asset, bundle, or org scope to install (supports name@version and @org)',
|
|
120
|
+
description: 'Asset, bundle, or org scope to install (supports name@version, @org/name, global:name and @org)',
|
|
120
121
|
name: 'target',
|
|
121
122
|
})),
|
|
122
123
|
])
|
|
@@ -136,7 +137,7 @@ export default function Install({ args: [rawName, ...more], options: { adopt, al
|
|
|
136
137
|
const orgName = rawName.slice(1);
|
|
137
138
|
return (_jsx(InstallOrg, { cliOrg: org, dryRun: dryRun, force: force, json: json, orgName: orgName, pin: pin, projectRoot: projectRoot, skipPicker: all || yes, tool: tool, user: user }));
|
|
138
139
|
}
|
|
139
|
-
return (_jsx(
|
|
140
|
+
return (_jsx(InstallAssetAtAnsweredScope, { adopt: adopt, dryRun: dryRun, force: force, json: json, org: org, pin: pin, projectRoot: projectRoot, rawName: rawName, tool: tool, user: user, yes: yes }));
|
|
140
141
|
}
|
|
141
142
|
/** The picker lists one org's assets, so type and name identify each. */
|
|
142
143
|
function assetKey(asset) {
|
|
@@ -151,6 +152,15 @@ async function bundleAtRequestedVersion(entry, requested, progress) {
|
|
|
151
152
|
}
|
|
152
153
|
return resolution.bundle;
|
|
153
154
|
}
|
|
155
|
+
/** What `--pin` did, or would do, with the members of a bundle in place. */
|
|
156
|
+
function BundlePinLine({ dryRun = false, pin }) {
|
|
157
|
+
if (pin === 'pinned') {
|
|
158
|
+
return (_jsxs(Text, { children: [_jsx(Text, { color: 'green', children: "\u2713" }), " Its members ", dryRun ? 'would be' : 'are now', " pinned at their installed versions."] }));
|
|
159
|
+
}
|
|
160
|
+
if (pin === 'already-pinned')
|
|
161
|
+
return _jsx(Text, { children: "Its members are already pinned at their installed versions." });
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
154
164
|
/**
|
|
155
165
|
* What a bundle install says about its members outside the bundle (`kept`) and the members it
|
|
156
166
|
* `adopted`. A member with no origin can be adopted; another bundle's member stays with that bundle.
|
|
@@ -215,14 +225,15 @@ async function crossScopeOf(plan, { installedAt, json, scope, tools }) {
|
|
|
215
225
|
function installAllCommand({ orgName, ...flags }) {
|
|
216
226
|
return installCommandFor(`@${orgName} --all`, flags);
|
|
217
227
|
}
|
|
218
|
-
function InstallAsset({ adopt, dryRun, force, json, org: cliOrg, pin, projectRoot, rawName, tool, user, }) {
|
|
228
|
+
function InstallAsset({ adopt, answered = false, dryRun, force, json, onScopeAnswer, org: cliOrg, pin, projectRoot, rawName, tool, user, yes = false, }) {
|
|
219
229
|
const { json: effectiveJson } = useNonInteractive(json);
|
|
220
230
|
const { name: parsedName, version: requestedVersion } = parseNameVersion(rawName);
|
|
221
231
|
// Extract org from @org/name syntax if present (shared spec parser — the
|
|
222
232
|
// same canonical identity applies whether the name turns out to be an asset
|
|
223
|
-
// or a bundle)
|
|
224
|
-
const
|
|
225
|
-
const name =
|
|
233
|
+
// or a bundle); `global:name` names the global one.
|
|
234
|
+
const nameScope = parseNameScope(parsedName);
|
|
235
|
+
const { name } = nameScope;
|
|
236
|
+
const inlineOrg = inlineOrgOf(nameScope);
|
|
226
237
|
const { fields, resolve, resolved } = useResolvedScope({ projectRoot, user });
|
|
227
238
|
const state = useCommand(async (progress) => {
|
|
228
239
|
const { root: projectDir, scope: installScope } = await resolve();
|
|
@@ -234,10 +245,52 @@ function InstallAsset({ adopt, dryRun, force, json, org: cliOrg, pin, projectRoo
|
|
|
234
245
|
const registry = await fetchRegistry({ force: true });
|
|
235
246
|
// Read lockfile to get org for resolution
|
|
236
247
|
const currentLockfile = await readLockfile(projectDir);
|
|
237
|
-
// Resolve active org: inline @org/name takes priority over --org flag
|
|
238
|
-
const org =
|
|
248
|
+
// Resolve active org: inline @org/name takes priority over --org flag, and global:name has none
|
|
249
|
+
const org = resolveSpecOrg(nameScope, cliOrg, currentLockfile.org, config.org);
|
|
239
250
|
const effectiveVersion = requestedVersion;
|
|
240
251
|
const crossScope = (plan, installedAt) => crossScopeOf(plan, { installedAt, json: effectiveJson, scope: installScope, tools: toolNames });
|
|
252
|
+
// The asset this run resolved, named so the other scope's active org (its lockfile's) can't turn
|
|
253
|
+
// it into another one: `@org/name`, or `global:name` for a global asset when `always` or an org
|
|
254
|
+
// is active here. A bundle's name never falls back across orgs, so it stays as asked.
|
|
255
|
+
const otherScopeSpec = (plan, { always }) => {
|
|
256
|
+
const target = plan.entries.find((entry) => entry.reason === 'direct');
|
|
257
|
+
if (indexBundle || !target)
|
|
258
|
+
return rawName;
|
|
259
|
+
const targetOrg = target.asset.org ?? target.org;
|
|
260
|
+
const spec = targetOrg
|
|
261
|
+
? formatOrgName(targetOrg, target.asset.name)
|
|
262
|
+
: always || org || config.org
|
|
263
|
+
? `global:${target.asset.name}`
|
|
264
|
+
: target.asset.name;
|
|
265
|
+
return effectiveVersion ? `${spec}@${effectiveVersion}` : spec;
|
|
266
|
+
};
|
|
267
|
+
// Once answered, the install goes where the answer said, with nothing more to say about it. When
|
|
268
|
+
// a bundle's members disagree, the command installs only the members that prefer the other scope.
|
|
269
|
+
const preferredScope = (plan) => answered
|
|
270
|
+
? {}
|
|
271
|
+
: preferredScopeField(preferredScopeOf(plan, installScope), (preferred) => preferredScopeCommand(preferred, {
|
|
272
|
+
adopt,
|
|
273
|
+
force,
|
|
274
|
+
orgActive: Boolean(org || config.org),
|
|
275
|
+
pin,
|
|
276
|
+
spec: indexBundle && preferred.conflict ? undefined : otherScopeSpec(plan, { always: false }),
|
|
277
|
+
tool,
|
|
278
|
+
}), effectiveJson);
|
|
279
|
+
// A terminal run asks before it installs, unless --yes, or the targets' authors disagree on the
|
|
280
|
+
// scope, or there is no other scope to move to (a --user install outside any project).
|
|
281
|
+
const askScope = async (plan, bundleName) => {
|
|
282
|
+
if (answered || yes || effectiveJson)
|
|
283
|
+
return undefined;
|
|
284
|
+
const preferred = preferredScopeOf(plan, installScope);
|
|
285
|
+
if (!preferred || preferred.conflict || !(await canInstallAt(preferred.scope)))
|
|
286
|
+
return undefined;
|
|
287
|
+
return {
|
|
288
|
+
...(bundleName ? { bundleName } : {}),
|
|
289
|
+
outcome: 'ask-scope',
|
|
290
|
+
preferred,
|
|
291
|
+
spec: otherScopeSpec(plan, { always: true }),
|
|
292
|
+
};
|
|
293
|
+
};
|
|
241
294
|
// Check if the name matches a bundle. Bundle identity is (name, org) with
|
|
242
295
|
// exact matching — an @org/name spec never falls back to a global bundle
|
|
243
296
|
// and a bare name never resolves to an org-scoped one.
|
|
@@ -297,27 +350,95 @@ function InstallAsset({ adopt, dryRun, force, json, org: cliOrg, pin, projectRoo
|
|
|
297
350
|
user,
|
|
298
351
|
})
|
|
299
352
|
: '';
|
|
353
|
+
// Whether every targeted tool has the bundle whole, which the install leaves as it is.
|
|
354
|
+
const isBundleHere = (lockfile) => bundle !== undefined &&
|
|
355
|
+
!force &&
|
|
356
|
+
isBundleInPlace(registry, bundle, lockfile, { members, projectDir, requiredBundleVersion, tools });
|
|
357
|
+
// With --pin, what the install does with the pins of a bundle in place.
|
|
358
|
+
const bundlePinField = (installed) => {
|
|
359
|
+
const bundlePin = pin ? bundleInPlacePin(installed) : undefined;
|
|
360
|
+
return bundlePin ? { pin: bundlePin } : {};
|
|
361
|
+
};
|
|
362
|
+
// The asset installed already, when every targeted tool has it in place, which the install leaves
|
|
363
|
+
// where it is. The lockfile is shared across tools, so tools that can't place the asset (its type,
|
|
364
|
+
// or a hook its manifest doesn't declare) have nothing to check; when none of them can, the
|
|
365
|
+
// installer says why instead. The registry identity is resolved first so the check matches on
|
|
366
|
+
// (name, type, org), not name alone. A version asked for that resolves to another one (`latest`
|
|
367
|
+
// and ranges included) goes to the resolver: the install makes the asset direct and checks its
|
|
368
|
+
// pin and dependents.
|
|
369
|
+
const assetInPlace = (lockfile) => {
|
|
370
|
+
if (bundle || force)
|
|
371
|
+
return undefined;
|
|
372
|
+
const registryMatch = findAsset(registry, name, undefined, effectiveVersion, org);
|
|
373
|
+
const existing = registryMatch
|
|
374
|
+
? findInstalledAsset(lockfile, name, registryMatch.asset.type, registryMatch.asset.org)
|
|
375
|
+
: undefined;
|
|
376
|
+
if (!existing || !registryMatch)
|
|
377
|
+
return undefined;
|
|
378
|
+
const supportingTools = tools.filter((t) => placesAsset(t.adapter, existing.type, registryMatch.versionData.tools));
|
|
379
|
+
const inPlace = supportingTools.length > 0 &&
|
|
380
|
+
supportingTools.every((t) => isInstalledForTool(existing, t.adapter, projectDir)) &&
|
|
381
|
+
(!effectiveVersion || registryMatch.version === existing.version);
|
|
382
|
+
return inPlace ? existing : undefined;
|
|
383
|
+
};
|
|
384
|
+
// What the install does with an asset in place: makes a dependency direct and, with --pin, pins
|
|
385
|
+
// it at its version, as `atk pin` would.
|
|
386
|
+
const inPlaceReport = (existing) => ({
|
|
387
|
+
name: existing.name,
|
|
388
|
+
...(existing.org ? { org: existing.org } : {}),
|
|
389
|
+
outcome: (existing.installReason ?? 'direct') === 'dependency' ? 'upgraded-to-direct' : 'already-installed',
|
|
390
|
+
...(pin ? { pin: inPlacePin(existing) } : {}),
|
|
391
|
+
type: existing.type,
|
|
392
|
+
version: existing.version,
|
|
393
|
+
});
|
|
394
|
+
const nothingToInstall = { entries: [], totalCount: 0 };
|
|
300
395
|
// Dry-run: resolve plan without acquiring lockfile lock or executing. The install leaves
|
|
301
|
-
// dependencies already in place alone and refuses to move a pinned one, and so does the plan
|
|
396
|
+
// dependencies already in place alone and refuses to move a pinned one, and so does the plan,
|
|
397
|
+
// and it says what it would do with a target in place, as the install would.
|
|
302
398
|
if (dryRun) {
|
|
303
399
|
const asInstalled = (resolved) => withoutKeptDependencies(resolved, currentLockfile, tools, {
|
|
400
|
+
named: { force },
|
|
304
401
|
onProgress: progress,
|
|
402
|
+
pin,
|
|
305
403
|
projectDir,
|
|
306
404
|
scope: installScope,
|
|
307
405
|
});
|
|
308
406
|
if (bundle) {
|
|
309
|
-
progress('Resolving bundle assets...');
|
|
310
|
-
const resolved = resolveBundleInstallPlan(registry, bundle);
|
|
311
407
|
// Nothing is written, so the members an install would adopt are the ones with no origin now.
|
|
312
408
|
const outside = membersOutsideBundle(currentLockfile, members, bundle);
|
|
409
|
+
const report = bundleReport(adopt ? outside.filter((m) => m.bundle) : outside, adopt ? outside.filter((m) => !m.bundle) : [], { adoptCommand, bundle });
|
|
410
|
+
if (isBundleHere(currentLockfile)) {
|
|
411
|
+
return {
|
|
412
|
+
bundleName: bundle.name,
|
|
413
|
+
inPlace: true,
|
|
414
|
+
outcome: 'dry-run-bundle',
|
|
415
|
+
...bundlePinField(membersInPlace(currentLockfile, members)),
|
|
416
|
+
plan: nothingToInstall,
|
|
417
|
+
tools: toolNames,
|
|
418
|
+
version: bundle.version,
|
|
419
|
+
...report,
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
progress('Resolving bundle assets...');
|
|
423
|
+
const resolved = resolveBundleInstallPlan(registry, bundle);
|
|
313
424
|
return {
|
|
314
425
|
bundleName: bundle.name,
|
|
315
426
|
outcome: 'dry-run-bundle',
|
|
316
427
|
plan: asInstalled(resolved),
|
|
317
428
|
tools: toolNames,
|
|
318
429
|
version: bundle.version,
|
|
319
|
-
...
|
|
430
|
+
...report,
|
|
320
431
|
...(await crossScope(resolved)),
|
|
432
|
+
...preferredScope(resolved),
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
const existing = assetInPlace(currentLockfile);
|
|
436
|
+
if (existing) {
|
|
437
|
+
return {
|
|
438
|
+
assets: [inPlaceReport(existing)],
|
|
439
|
+
outcome: 'dry-run-install',
|
|
440
|
+
plan: nothingToInstall,
|
|
441
|
+
tools: toolNames,
|
|
321
442
|
};
|
|
322
443
|
}
|
|
323
444
|
const versionLabel = effectiveVersion ? `@${effectiveVersion}` : '';
|
|
@@ -328,6 +449,7 @@ function InstallAsset({ adopt, dryRun, force, json, org: cliOrg, pin, projectRoo
|
|
|
328
449
|
plan: asInstalled(resolved),
|
|
329
450
|
tools: toolNames,
|
|
330
451
|
...(await crossScope(resolved)),
|
|
452
|
+
...preferredScope(resolved),
|
|
331
453
|
};
|
|
332
454
|
}
|
|
333
455
|
return await withLockfileErrorHandling(projectDir, async () => {
|
|
@@ -339,34 +461,42 @@ function InstallAsset({ adopt, dryRun, force, json, org: cliOrg, pin, projectRoo
|
|
|
339
461
|
version: bundle.version,
|
|
340
462
|
};
|
|
341
463
|
// Bundle installation flow — check if already installed for ALL tools
|
|
342
|
-
if (
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
464
|
+
if (isBundleHere(before)) {
|
|
465
|
+
// Adopting a bundle that is in place only records its origin on the members with none:
|
|
466
|
+
// their files, versions and pins stay as they are. Another bundle's member stays its.
|
|
467
|
+
// --pin pins every member at its version, as a fresh install with --pin would.
|
|
468
|
+
const outside = membersOutsideBundle(before, members, bundle);
|
|
469
|
+
const adopted = adopt ? outside.filter((member) => !member.bundle) : [];
|
|
470
|
+
const installedMembers = membersInPlace(before, members);
|
|
471
|
+
const pinField = bundlePinField(installedMembers);
|
|
472
|
+
if (adopted.length > 0 || pinField.pin === 'pinned') {
|
|
473
|
+
let lockfile = before;
|
|
474
|
+
for (const { name: memberName, org: memberOrg, type } of adopted) {
|
|
475
|
+
const installed = findInstalledAsset(lockfile, memberName, type, memberOrg);
|
|
476
|
+
lockfile = addAssetToLockfile(lockfile, { ...installed, bundleOrigin });
|
|
355
477
|
}
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
version: bundle.version,
|
|
360
|
-
...bundleReport(outside.filter((member) => !adopted.includes(member)), adopted, { adoptCommand, bundle }),
|
|
361
|
-
};
|
|
478
|
+
if (pinField.pin === 'pinned')
|
|
479
|
+
lockfile = pinMembersInPlace(lockfile, installedMembers);
|
|
480
|
+
await writeLockfile(projectDir, lockfile);
|
|
362
481
|
}
|
|
482
|
+
return {
|
|
483
|
+
bundleName: bundle.name,
|
|
484
|
+
outcome: 'bundle-already-installed',
|
|
485
|
+
...pinField,
|
|
486
|
+
version: bundle.version,
|
|
487
|
+
...bundleReport(outside.filter((member) => !adopted.includes(member)), adopted, { adoptCommand, bundle }),
|
|
488
|
+
};
|
|
363
489
|
}
|
|
364
490
|
progress('Resolving bundle assets...');
|
|
365
491
|
const plan = resolveBundleInstallPlan(registry, bundle);
|
|
492
|
+
const question = await askScope(plan, bundle.name);
|
|
493
|
+
if (question)
|
|
494
|
+
return question;
|
|
366
495
|
const toolResults = await executeInstallPlanForTools(plan, tools, {
|
|
367
496
|
adopt,
|
|
368
497
|
bundleOrigin,
|
|
369
498
|
force,
|
|
499
|
+
named: { force },
|
|
370
500
|
onProgress: progress,
|
|
371
501
|
onTool: (toolName) => progress(`Installing bundle for ${toolName}...`),
|
|
372
502
|
pin,
|
|
@@ -384,56 +514,52 @@ function InstallAsset({ adopt, dryRun, force, json, org: cliOrg, pin, projectRoo
|
|
|
384
514
|
version: bundle.version,
|
|
385
515
|
...bundleReport(kept, adopted, { adoptCommand, bundle }),
|
|
386
516
|
...(await crossScope(plan, projectDir)),
|
|
517
|
+
...preferredScope(plan),
|
|
387
518
|
};
|
|
388
519
|
}
|
|
389
520
|
// Single asset installation flow
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
? findInstalledAsset(lockfile, name, registryMatch.asset.type, registryMatch.asset.org)
|
|
399
|
-
: undefined;
|
|
400
|
-
// Tools that cannot place this asset (its type, or a hook its manifest doesn't declare)
|
|
401
|
-
// have nothing to check. When none of the targeted tools can, fall through so the
|
|
402
|
-
// installer reports why instead of claiming the asset is already installed.
|
|
403
|
-
const supportingTools = existing && registryMatch
|
|
404
|
-
? tools.filter((t) => placesAsset(t.adapter, existing.type, registryMatch.versionData.tools))
|
|
405
|
-
: [];
|
|
406
|
-
if (existing &&
|
|
407
|
-
supportingTools.length > 0 &&
|
|
408
|
-
supportingTools.every((t) => isInstalledForTool(existing, t.adapter, projectDir))) {
|
|
409
|
-
// If it was auto-installed as a dependency, upgrade it to a direct install
|
|
410
|
-
if ((existing.installReason ?? 'direct') === 'dependency') {
|
|
411
|
-
const updated = upgradeToDirectInstall(lockfile, name, existing.type, existing.org);
|
|
412
|
-
await writeLockfile(projectDir, updated);
|
|
413
|
-
return { name, outcome: 'upgraded-to-direct', version: existing.version };
|
|
414
|
-
}
|
|
415
|
-
// If a specific version was requested and it differs from installed,
|
|
416
|
-
// fall through to resolver (which will error if version doesn't exist)
|
|
417
|
-
if (effectiveVersion && effectiveVersion !== existing.version) {
|
|
418
|
-
// Let it proceed to resolveInstallPlan below
|
|
521
|
+
const lockfile = force ? undefined : await readLockfile(projectDir);
|
|
522
|
+
const existing = lockfile && assetInPlace(lockfile);
|
|
523
|
+
if (lockfile && existing) {
|
|
524
|
+
const { outcome, pin: pinned } = inPlaceReport(existing);
|
|
525
|
+
if (outcome === 'upgraded-to-direct' || pinned === 'pinned') {
|
|
526
|
+
let updated = lockfile;
|
|
527
|
+
if (outcome === 'upgraded-to-direct') {
|
|
528
|
+
updated = upgradeToDirectInstall(updated, name, existing.type, existing.org);
|
|
419
529
|
}
|
|
420
|
-
|
|
421
|
-
|
|
530
|
+
if (pinned === 'pinned') {
|
|
531
|
+
updated = pinAssetVersion(updated, name, existing.version, existing.type, existing.org);
|
|
422
532
|
}
|
|
533
|
+
await writeLockfile(projectDir, updated);
|
|
423
534
|
}
|
|
535
|
+
return {
|
|
536
|
+
name,
|
|
537
|
+
outcome: outcome === 'upgraded-to-direct' ? 'upgraded-to-direct' : 'already-installed',
|
|
538
|
+
...(pinned ? { pin: pinned } : {}),
|
|
539
|
+
version: existing.version,
|
|
540
|
+
};
|
|
424
541
|
}
|
|
425
542
|
const versionLabel = effectiveVersion ? `@${effectiveVersion}` : '';
|
|
426
543
|
progress(`Resolving dependencies${versionLabel}...`);
|
|
427
544
|
const plan = resolveInstallPlan(registry, name, undefined, effectiveVersion, org);
|
|
545
|
+
const question = await askScope(plan);
|
|
546
|
+
if (question)
|
|
547
|
+
return question;
|
|
428
548
|
const toolResults = await executeInstallPlanForTools(plan, tools, {
|
|
429
549
|
force,
|
|
550
|
+
named: { force },
|
|
430
551
|
onProgress: progress,
|
|
431
552
|
onTool: (toolName) => progress(`Installing for ${toolName}...`),
|
|
432
553
|
pin,
|
|
433
554
|
projectDir: projectDir,
|
|
434
555
|
scope: installScope,
|
|
435
556
|
});
|
|
436
|
-
return {
|
|
557
|
+
return {
|
|
558
|
+
outcome: 'installed',
|
|
559
|
+
toolResults,
|
|
560
|
+
...(await crossScope(plan, projectDir)),
|
|
561
|
+
...preferredScope(plan),
|
|
562
|
+
};
|
|
437
563
|
});
|
|
438
564
|
}, [adopt, cliOrg, dryRun, force, inlineOrg, name, pin, requestedVersion, tool]);
|
|
439
565
|
if (state.status === 'loading') {
|
|
@@ -455,31 +581,59 @@ function InstallAsset({ adopt, dryRun, force, json, org: cliOrg, pin, projectRoo
|
|
|
455
581
|
const { data } = state;
|
|
456
582
|
const label = resolved && scopeLabel(resolved);
|
|
457
583
|
const where = label ? ` in ${label}` : '';
|
|
584
|
+
if (data.outcome === 'ask-scope') {
|
|
585
|
+
return (_jsx(PreferredScopeQuestion, { bundleName: data.bundleName, onAnswer: (move) => onScopeAnswer?.(move ? { scope: data.preferred.scope, spec: data.spec } : undefined), preferred: data.preferred }));
|
|
586
|
+
}
|
|
458
587
|
if (effectiveJson) {
|
|
459
588
|
return renderJson({ ...data, ...fields });
|
|
460
589
|
}
|
|
461
590
|
if (data.outcome === 'bundle-already-installed') {
|
|
462
|
-
return (_jsxs(Box, { flexDirection: 'column', children: [_jsxs(Text, { children: [_jsx(Text, { color: 'yellow', children: "!" }), " Bundle ", _jsx(Text, { bold: true, children: data.bundleName }), " is already fully installed (v", data.version, ")", where, "."] }), _jsx(Text, { dimColor: true, children: "Use --force to reinstall." }), _jsx(BundleReportLines, { bundleName: data.bundleName, report: data })] }));
|
|
591
|
+
return (_jsxs(Box, { flexDirection: 'column', children: [_jsxs(Text, { children: [_jsx(Text, { color: 'yellow', children: "!" }), " Bundle ", _jsx(Text, { bold: true, children: data.bundleName }), " is already fully installed (v", data.version, ")", where, "."] }), _jsx(BundlePinLine, { pin: data.pin }), _jsx(Text, { dimColor: true, children: "Use --force to reinstall." }), _jsx(BundleReportLines, { bundleName: data.bundleName, report: data })] }));
|
|
463
592
|
}
|
|
464
593
|
if (data.outcome === 'bundle-installed') {
|
|
465
|
-
return (_jsxs(Box, { flexDirection: 'column', children: [data.toolResults.map(({ results, skipped, tool: toolName, warnings }) => (_jsxs(Box, { flexDirection: 'column', children: [_jsxs(Text, { color: 'green', children: ["\u2713 Bundle ", _jsx(Text, { bold: true, children: data.bundleName }), " v", data.version, " \u2014 ", results.length, " asset", results.length !== 1 ? 's' : ''] }), _jsx(InstallSummary, { results: results, skipped: skipped, tools: [toolName], warnings: warnings, where: label })] }, toolName))), _jsx(BundleReportLines, { bundleName: data.bundleName, report: data }), _jsx(CrossScopeWarning, { installs: data.crossScope ?? [] })] }));
|
|
594
|
+
return (_jsxs(Box, { flexDirection: 'column', children: [data.toolResults.map(({ results, skipped, tool: toolName, warnings }) => (_jsxs(Box, { flexDirection: 'column', children: [_jsxs(Text, { color: 'green', children: ["\u2713 Bundle ", _jsx(Text, { bold: true, children: data.bundleName }), " v", data.version, " \u2014 ", results.length, " asset", results.length !== 1 ? 's' : ''] }), _jsx(InstallSummary, { results: results, skipped: skipped, tools: [toolName], warnings: warnings, where: label })] }, toolName))), _jsx(BundleReportLines, { bundleName: data.bundleName, report: data }), _jsx(CrossScopeWarning, { installs: data.crossScope ?? [] }), _jsx(PreferredScopeWarning, { preferred: data.preferredScope })] }));
|
|
466
595
|
}
|
|
467
596
|
if (data.outcome === 'already-installed') {
|
|
468
|
-
|
|
597
|
+
if (data.pin === 'pinned') {
|
|
598
|
+
return (_jsxs(Text, { color: 'green', children: ["\u2713 ", _jsx(Text, { bold: true, children: data.name }), " is already installed (v", data.version, ")", where, " and is now pinned at v", data.version, "."] }));
|
|
599
|
+
}
|
|
600
|
+
return (_jsxs(Box, { flexDirection: 'column', children: [_jsxs(Text, { children: [_jsx(Text, { color: 'yellow', children: "!" }), " ", _jsx(Text, { bold: true, children: data.name }), " is already installed (v", data.version, ")", where, data.pin === 'already-pinned' ? ` and pinned at v${data.version}` : '', "."] }), _jsx(Text, { dimColor: true, children: "Use --force to reinstall." })] }));
|
|
469
601
|
}
|
|
470
602
|
if (data.outcome === 'upgraded-to-direct') {
|
|
471
|
-
return (_jsxs(Box, { flexDirection: 'column', children: [_jsxs(Text, { color: 'green', children: ["\u2713 ", _jsx(Text, { bold: true, children: data.name }), " (v", data.version, ") is now a direct install", where,
|
|
603
|
+
return (_jsxs(Box, { flexDirection: 'column', children: [_jsxs(Text, { color: 'green', children: ["\u2713 ", _jsx(Text, { bold: true, children: data.name }), " (v", data.version, ") is now a direct install", where, data.pin === 'pinned'
|
|
604
|
+
? `, and is now pinned at v${data.version}`
|
|
605
|
+
: data.pin === 'already-pinned'
|
|
606
|
+
? `, already pinned at v${data.version}`
|
|
607
|
+
: '', "."] }), _jsx(Text, { dimColor: true, children: "It will no longer be auto-removed when its parent is uninstalled." })] }));
|
|
472
608
|
}
|
|
473
609
|
if (data.outcome === 'dry-run-install') {
|
|
474
|
-
return (_jsxs(Box, { flexDirection: 'column', children: [_jsx(DryRunBanner, { action: 'install', count: data.plan.totalCount, tools: data.tools, where: label }), _jsx(Text, { children: " " }), _jsx(PlanEntryLines, { plan: data.plan }), _jsx(CrossScopeWarning, { installs: data.crossScope ?? [] })] }));
|
|
610
|
+
return (_jsxs(Box, { flexDirection: 'column', children: [_jsx(DryRunBanner, { action: 'install', count: data.plan.totalCount, tools: data.tools, where: label }), _jsx(Text, { children: " " }), _jsx(PlanEntryLines, { plan: data.plan }), _jsx(NamedAssetLines, { assets: data.assets ?? [], dryRun: true, where: label }), _jsx(CrossScopeWarning, { installs: data.crossScope ?? [] }), _jsx(PreferredScopeWarning, { preferred: data.preferredScope })] }));
|
|
475
611
|
}
|
|
476
612
|
if (data.outcome === 'dry-run-bundle') {
|
|
477
|
-
return (_jsxs(Box, { flexDirection: 'column', children: [_jsx(DryRunBanner, { action: 'install', count: data.plan.totalCount, tools: data.tools, where: label }), _jsx(Text, { children: " " }), _jsxs(Text, { children: [_jsxs(Text, { bold: true, color: 'magenta', children: ["Bundle: ", data.bundleName] }), _jsxs(Text, { dimColor: true, children: [" v", data.version] })] }), _jsx(Text, { children: " " }), _jsx(PlanEntryLines, { plan: data.plan }), _jsx(BundleReportLines, { bundleName: data.bundleName, dryRun: true, report: data }), _jsx(CrossScopeWarning, { installs: data.crossScope ?? [] })] }));
|
|
613
|
+
return (_jsxs(Box, { flexDirection: 'column', children: [_jsx(DryRunBanner, { action: 'install', count: data.plan.totalCount, tools: data.tools, where: label }), _jsx(Text, { children: " " }), _jsxs(Text, { children: [_jsxs(Text, { bold: true, color: 'magenta', children: ["Bundle: ", data.bundleName] }), _jsxs(Text, { dimColor: true, children: [" v", data.version] })] }), _jsx(Text, { children: " " }), _jsx(PlanEntryLines, { plan: data.plan }), data.inPlace && (_jsxs(Text, { children: [_jsx(Text, { color: 'yellow', children: "!" }), " Bundle ", _jsx(Text, { bold: true, children: data.bundleName }), " is already fully installed (v", data.version, ")", where, "."] })), _jsx(BundlePinLine, { dryRun: true, pin: data.pin }), _jsx(BundleReportLines, { bundleName: data.bundleName, dryRun: true, report: data }), _jsx(CrossScopeWarning, { installs: data.crossScope ?? [] }), _jsx(PreferredScopeWarning, { preferred: data.preferredScope })] }));
|
|
478
614
|
}
|
|
479
615
|
if (data.outcome === 'deprecated') {
|
|
480
616
|
return (_jsxs(Box, { flexDirection: 'column', children: [_jsxs(Text, { color: 'yellow', children: ["Warning: \"", data.name, "\" is deprecated \u2014 ", data.reason] }), data.replacement && (_jsxs(Text, { children: ["Consider using", ' ', _jsx(Text, { bold: true, color: 'cyan', children: data.replacement }), ' ', "instead."] })), _jsx(Text, { dimColor: true, children: "Use --force to install anyway." })] }));
|
|
481
617
|
}
|
|
482
|
-
return (_jsxs(Box, { flexDirection: 'column', children: [data.toolResults.map(({ results, skipped, tool: toolName, warnings }) => (_jsx(InstallSummary, { results: results, skipped: skipped, tools: [toolName], warnings: warnings, where: label }, toolName))), _jsx(CrossScopeWarning, { installs: data.crossScope ?? [] })] }));
|
|
618
|
+
return (_jsxs(Box, { flexDirection: 'column', children: [data.toolResults.map(({ results, skipped, tool: toolName, warnings }) => (_jsx(InstallSummary, { results: results, skipped: skipped, tools: [toolName], warnings: warnings, where: label }, toolName))), _jsx(CrossScopeWarning, { installs: data.crossScope ?? [] }), _jsx(PreferredScopeWarning, { preferred: data.preferredScope })] }));
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* One asset or bundle, asking first when its authors prefer the other scope: the install runs again
|
|
622
|
+
* at the scope the answer picks, and doesn't ask twice.
|
|
623
|
+
*/
|
|
624
|
+
function InstallAssetAtAnsweredScope(props) {
|
|
625
|
+
const [answer, setAnswer] = useState();
|
|
626
|
+
if (!answer) {
|
|
627
|
+
// Only the first key answers: a second one, before the question goes, would change the scope under the install.
|
|
628
|
+
return _jsx(InstallAsset, { ...props, onScopeAnswer: (move) => setAnswer((first) => first ?? { move }) }, 'asking');
|
|
629
|
+
}
|
|
630
|
+
if (!answer.move) {
|
|
631
|
+
return _jsx(InstallAsset, { ...props, answered: true }, 'answered');
|
|
632
|
+
}
|
|
633
|
+
// The other scope's root: the user root, or the cwd's project, never the --project-root asked with; and
|
|
634
|
+
// the asset by the name the question resolved, which --org can't contradict.
|
|
635
|
+
const { scope, spec } = answer.move;
|
|
636
|
+
return (_jsx(InstallAsset, { ...props, answered: true, org: undefined, projectRoot: undefined, rawName: spec, user: scope === 'user' }, 'moved'));
|
|
483
637
|
}
|
|
484
638
|
/**
|
|
485
639
|
* `atk install a b@1.2.0 @org/c my-bundle @org --all`: the named assets, the bundles' members and
|
|
@@ -545,9 +699,10 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
|
|
|
545
699
|
continue;
|
|
546
700
|
}
|
|
547
701
|
const { name: parsedName, version } = parseNameVersion(spec);
|
|
548
|
-
const
|
|
549
|
-
const name =
|
|
550
|
-
const
|
|
702
|
+
const nameScope = parseNameScope(parsedName);
|
|
703
|
+
const { name } = nameScope;
|
|
704
|
+
const inlineOrg = inlineOrgOf(nameScope);
|
|
705
|
+
const org = resolveSpecOrg(nameScope, cliOrg, currentLockfile.org, config.org);
|
|
551
706
|
const indexBundle = findBundle(registry, name, inlineOrg);
|
|
552
707
|
if (indexBundle) {
|
|
553
708
|
const bundle = await bundleAtRequestedVersion(indexBundle, version, progress);
|
|
@@ -589,7 +744,7 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
|
|
|
589
744
|
user,
|
|
590
745
|
});
|
|
591
746
|
progress('Resolving dependencies...');
|
|
592
|
-
const targetsPlan = planTargetsInstall(registry, targets, currentLockfile, tools, { force, projectDir });
|
|
747
|
+
const targetsPlan = planTargetsInstall(registry, targets, currentLockfile, tools, { force, pin, projectDir });
|
|
593
748
|
const { assets: report, plan, toInstall } = targetsPlan;
|
|
594
749
|
const bundles = targetsPlan.bundlesInPlace.map((request) => {
|
|
595
750
|
const { bundle } = request;
|
|
@@ -597,6 +752,7 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
|
|
|
597
752
|
name: bundle.name,
|
|
598
753
|
...(bundle.org ? { org: bundle.org } : {}),
|
|
599
754
|
outcome: 'already-installed',
|
|
755
|
+
...(request.pin ? { pin: request.pin } : {}),
|
|
600
756
|
version: bundle.version,
|
|
601
757
|
...bundleReport(membersOutsideBundle(currentLockfile, bundleMembers(registry, bundle, tools), bundle), [], {
|
|
602
758
|
adoptCommand: adoptCommandFor(request),
|
|
@@ -605,6 +761,13 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
|
|
|
605
761
|
};
|
|
606
762
|
});
|
|
607
763
|
const crossScope = (resolvedPlan, installedAt) => crossScopeOf(resolvedPlan, { installedAt, json: effectiveJson, scope: installScope, tools: toolNames });
|
|
764
|
+
// Several names install together at one scope, so a preference for the other only gets a notice.
|
|
765
|
+
const preferredScope = (resolvedPlan) => preferredScopeField(preferredScopeOf(resolvedPlan, installScope), (preferred) => preferredScopeCommand(preferred, {
|
|
766
|
+
force,
|
|
767
|
+
orgActive: Boolean(cliOrg || currentLockfile.org || config.org),
|
|
768
|
+
pin,
|
|
769
|
+
tool,
|
|
770
|
+
}), effectiveJson);
|
|
608
771
|
// Each bundle in the plan, in the order named, then the ones left out; and the orgs.
|
|
609
772
|
const targetsField = (lockfile, planned) => {
|
|
610
773
|
const installedBundles = toInstall.flatMap((request) => {
|
|
@@ -637,17 +800,21 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
|
|
|
637
800
|
...targetsField(currentLockfile, true),
|
|
638
801
|
outcome: 'dry-run-install',
|
|
639
802
|
plan: withoutKeptDependencies(plan, currentLockfile, tools, {
|
|
803
|
+
named: { force },
|
|
640
804
|
onProgress: progress,
|
|
805
|
+
pin,
|
|
641
806
|
projectDir,
|
|
642
807
|
scope: installScope,
|
|
643
808
|
}),
|
|
644
809
|
tools: toolNames,
|
|
645
810
|
...(await crossScope(plan)),
|
|
811
|
+
...preferredScope(plan),
|
|
646
812
|
};
|
|
647
813
|
}
|
|
648
814
|
return await withLockfileErrorHandling(projectDir, async () => {
|
|
649
815
|
const toolResults = await installPlannedTargets(targetsPlan, tools, {
|
|
650
816
|
force,
|
|
817
|
+
named: { force },
|
|
651
818
|
onProgress: progress,
|
|
652
819
|
onTool: (toolName) => progress(`Installing for ${toolName}...`),
|
|
653
820
|
pin,
|
|
@@ -663,6 +830,7 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
|
|
|
663
830
|
outcome: 'installed',
|
|
664
831
|
toolResults,
|
|
665
832
|
...(await crossScope(plan, projectDir)),
|
|
833
|
+
...preferredScope(plan),
|
|
666
834
|
};
|
|
667
835
|
});
|
|
668
836
|
}, [adopt, all, cliOrg, dryRun, force, pin, specs.join(' '), tool]);
|
|
@@ -688,10 +856,10 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
|
|
|
688
856
|
return renderJson({ ...data, ...fields });
|
|
689
857
|
}
|
|
690
858
|
if (data.outcome === 'dry-run-install') {
|
|
691
|
-
return (_jsxs(Box, { flexDirection: 'column', children: [_jsx(DryRunBanner, { action: 'install', count: data.plan.totalCount, tools: data.tools, where: label }), _jsx(Text, { children: " " }), _jsx(PlanEntryLines, { plan: data.plan }), _jsx(NamedAssetLines, { assets: data.assets, dryRun: true, where: label }), _jsx(TargetLines, { bundles: data.bundles, dryRun: true, orgs: data.orgs, where: label }), _jsx(CrossScopeWarning, { installs: data.crossScope ?? [] })] }));
|
|
859
|
+
return (_jsxs(Box, { flexDirection: 'column', children: [_jsx(DryRunBanner, { action: 'install', count: data.plan.totalCount, tools: data.tools, where: label }), _jsx(Text, { children: " " }), _jsx(PlanEntryLines, { plan: data.plan }), _jsx(NamedAssetLines, { assets: data.assets, dryRun: true, where: label }), _jsx(TargetLines, { bundles: data.bundles, dryRun: true, orgs: data.orgs, where: label }), _jsx(CrossScopeWarning, { installs: data.crossScope ?? [] }), _jsx(PreferredScopeWarning, { preferred: data.preferredScope })] }));
|
|
692
860
|
}
|
|
693
861
|
return (_jsxs(Box, { flexDirection: 'column', children: [data.outcome === 'installed' &&
|
|
694
|
-
data.toolResults.map(({ results, skipped, tool: toolName, warnings }) => (_jsx(InstallSummary, { results: results, skipped: skipped, tools: [toolName], warnings: warnings, where: label }, toolName))), _jsx(NamedAssetLines, { assets: data.assets, where: label }), _jsx(TargetLines, { bundles: data.bundles, orgs: data.orgs, where: label }), data.outcome === 'installed' && _jsx(CrossScopeWarning, { installs: data.crossScope ?? [] })] }));
|
|
862
|
+
data.toolResults.map(({ results, skipped, tool: toolName, warnings }) => (_jsx(InstallSummary, { results: results, skipped: skipped, tools: [toolName], warnings: warnings, where: label }, toolName))), _jsx(NamedAssetLines, { assets: data.assets, where: label }), _jsx(TargetLines, { bundles: data.bundles, orgs: data.orgs, where: label }), data.outcome === 'installed' && _jsx(CrossScopeWarning, { installs: data.crossScope ?? [] }), data.outcome === 'installed' && _jsx(PreferredScopeWarning, { preferred: data.preferredScope })] }));
|
|
695
863
|
}
|
|
696
864
|
/** `atk install <spec>` with the run's own flags, for a command an error suggests. */
|
|
697
865
|
function installCommandFor(spec, { adopt, dryRun, force, pin, projectRoot, tool, user }) {
|
|
@@ -797,14 +965,21 @@ function InstallOrg({ cliOrg, dryRun, force, json, orgName, pin, projectRoot, sk
|
|
|
797
965
|
const refs = assetsToInstall.map((a) => ({ name: a.name, type: a.type }));
|
|
798
966
|
const plan = resolveMultipleInstallPlans(ctx.registry, refs, ctx.activeOrg);
|
|
799
967
|
const crossScope = (resolved, installedAt) => crossScopeOf(resolved, { installedAt, json: effectiveJson, scope: ctx.scope, tools: ctx.toolNames });
|
|
968
|
+
// The picker already chose what installs here, so a preference for the other scope only gets a
|
|
969
|
+
// notice, once the run has planned or installed (a failed install records none). An org's assets
|
|
970
|
+
// are all its own, so each is named `@org/name`.
|
|
971
|
+
const preferredScope = () => preferredScopeField(preferredScopeOf(plan, ctx.scope), (preferred) => preferredScopeCommand(preferred, { force, pin, tool }), effectiveJson);
|
|
800
972
|
if (dryRun) {
|
|
973
|
+
// An org's assets aren't named one by one, so --force doesn't move them past a pin or a dependent.
|
|
801
974
|
const kept = withoutKeptDependencies(plan, ctx.lockfile, ctx.tools, {
|
|
975
|
+
pin,
|
|
802
976
|
projectDir: ctx.projectDir,
|
|
803
977
|
scope: ctx.scope,
|
|
804
978
|
});
|
|
805
979
|
const field = await crossScope(plan);
|
|
806
|
-
if (!cancelled)
|
|
807
|
-
setState({ phase: 'dry-run', plan: kept, tools: ctx.toolNames, ...field });
|
|
980
|
+
if (!cancelled) {
|
|
981
|
+
setState({ phase: 'dry-run', plan: kept, tools: ctx.toolNames, ...field, ...preferredScope() });
|
|
982
|
+
}
|
|
808
983
|
return;
|
|
809
984
|
}
|
|
810
985
|
if (!cancelled)
|
|
@@ -825,7 +1000,7 @@ function InstallOrg({ cliOrg, dryRun, force, json, orgName, pin, projectRoot, sk
|
|
|
825
1000
|
}));
|
|
826
1001
|
const field = await crossScope(plan, ctx.projectDir);
|
|
827
1002
|
if (!cancelled)
|
|
828
|
-
setState({ phase: 'done', toolResults, ...field });
|
|
1003
|
+
setState({ phase: 'done', toolResults, ...field, ...preferredScope() });
|
|
829
1004
|
}
|
|
830
1005
|
catch (err) {
|
|
831
1006
|
showError(err);
|
|
@@ -935,11 +1110,12 @@ function InstallOrg({ cliOrg, dryRun, force, json, orgName, pin, projectRoot, sk
|
|
|
935
1110
|
org: orgName,
|
|
936
1111
|
outcome: 'dry-run-org',
|
|
937
1112
|
plan: state.plan,
|
|
1113
|
+
preferredScope: state.preferredScope,
|
|
938
1114
|
tools: state.tools,
|
|
939
1115
|
...fields,
|
|
940
1116
|
});
|
|
941
1117
|
}
|
|
942
|
-
return (_jsxs(Box, { flexDirection: 'column', children: [_jsx(DryRunBanner, { action: 'install', count: state.plan.totalCount, tools: state.tools, where: label }), _jsx(Text, { children: " " }), _jsx(Text, { children: _jsxs(Text, { bold: true, color: 'magenta', children: ["Org: @", orgName] }) }), _jsx(Text, { children: " " }), _jsx(PlanEntryLines, { plan: state.plan }), _jsx(CrossScopeWarning, { installs: state.crossScope ?? [] })] }));
|
|
1118
|
+
return (_jsxs(Box, { flexDirection: 'column', children: [_jsx(DryRunBanner, { action: 'install', count: state.plan.totalCount, tools: state.tools, where: label }), _jsx(Text, { children: " " }), _jsx(Text, { children: _jsxs(Text, { bold: true, color: 'magenta', children: ["Org: @", orgName] }) }), _jsx(Text, { children: " " }), _jsx(PlanEntryLines, { plan: state.plan }), _jsx(CrossScopeWarning, { installs: state.crossScope ?? [] }), _jsx(PreferredScopeWarning, { preferred: state.preferredScope })] }));
|
|
943
1119
|
}
|
|
944
1120
|
if (state.phase === 'done') {
|
|
945
1121
|
if (effectiveJson) {
|
|
@@ -947,11 +1123,12 @@ function InstallOrg({ cliOrg, dryRun, force, json, orgName, pin, projectRoot, sk
|
|
|
947
1123
|
crossScope: state.crossScope,
|
|
948
1124
|
org: orgName,
|
|
949
1125
|
outcome: 'org-installed',
|
|
1126
|
+
preferredScope: state.preferredScope,
|
|
950
1127
|
toolResults: state.toolResults,
|
|
951
1128
|
...fields,
|
|
952
1129
|
});
|
|
953
1130
|
}
|
|
954
|
-
return (_jsxs(Box, { flexDirection: 'column', children: [_jsxs(Text, { color: 'green', children: ["\u2713 Installed from ", _jsxs(Text, { bold: true, children: ["@", orgName] })] }), state.toolResults.map(({ results, skipped, tool: toolName, warnings }) => (_jsx(InstallSummary, { results: results, skipped: skipped, tools: [toolName], warnings: warnings, where: label }, toolName))), _jsx(CrossScopeWarning, { installs: state.crossScope ?? [] })] }));
|
|
1131
|
+
return (_jsxs(Box, { flexDirection: 'column', children: [_jsxs(Text, { color: 'green', children: ["\u2713 Installed from ", _jsxs(Text, { bold: true, children: ["@", orgName] })] }), state.toolResults.map(({ results, skipped, tool: toolName, warnings }) => (_jsx(InstallSummary, { results: results, skipped: skipped, tools: [toolName], warnings: warnings, where: label }, toolName))), _jsx(CrossScopeWarning, { installs: state.crossScope ?? [] }), _jsx(PreferredScopeWarning, { preferred: state.preferredScope })] }));
|
|
955
1132
|
}
|
|
956
1133
|
return null;
|
|
957
1134
|
}
|
|
@@ -979,9 +1156,13 @@ function NamedAssetLines({ assets, dryRun = false, where, }) {
|
|
|
979
1156
|
const inScope = where ? ` in ${where}` : '';
|
|
980
1157
|
return (_jsx(_Fragment, { children: assets
|
|
981
1158
|
.filter((a) => a.outcome !== 'installed')
|
|
982
|
-
.map((a) => (_jsxs(Text, { children: [a.outcome === 'upgraded-to-direct' ? _jsx(Text, { color: 'green', children: "\u2713" }) : _jsx(Text, { color: 'yellow', children: "!" }), ' ', _jsx(Text, { bold: true, children: formatOrgName(a.org, a.name) }), " (v", a.version, ")", ' ', a.outcome === 'upgraded-to-direct'
|
|
983
|
-
? `${dryRun ? 'would become' : 'is now'} a direct install${inScope}
|
|
984
|
-
: `is already installed${inScope}
|
|
1159
|
+
.map((a) => (_jsxs(Text, { children: [a.outcome === 'upgraded-to-direct' || a.pin === 'pinned' ? (_jsx(Text, { color: 'green', children: "\u2713" })) : (_jsx(Text, { color: 'yellow', children: "!" })), ' ', _jsx(Text, { bold: true, children: formatOrgName(a.org, a.name) }), " (v", a.version, ")", ' ', a.outcome === 'upgraded-to-direct'
|
|
1160
|
+
? `${dryRun ? 'would become' : 'is now'} a direct install${inScope}`
|
|
1161
|
+
: `is already installed${inScope}`, a.pin === 'pinned'
|
|
1162
|
+
? `, and ${dryRun ? 'would be' : 'is now'} pinned at v${a.version}.`
|
|
1163
|
+
: a.pin === 'already-pinned'
|
|
1164
|
+
? `${a.outcome === 'upgraded-to-direct' ? ', already' : ' and'} pinned at v${a.version}.`
|
|
1165
|
+
: '.'] }, identityKey(a)))) }));
|
|
985
1166
|
}
|
|
986
1167
|
/**
|
|
987
1168
|
* The error for a bundle name that only another scope has, when no asset can claim the name
|
|
@@ -1014,6 +1195,24 @@ function plannedOutsideBundle(plan, lockfile, members, bundle) {
|
|
|
1014
1195
|
return [{ ...(origin ? { bundle: origin } : {}), ...member }];
|
|
1015
1196
|
});
|
|
1016
1197
|
}
|
|
1198
|
+
/** The install of the targets that prefer the other scope, at that scope, with the run's own flags. */
|
|
1199
|
+
function preferredScopeCommand({ assets, scope }, { adopt, force, orgActive = false, pin, spec, tool, }) {
|
|
1200
|
+
const names = assets.map((asset) => asset.org ? formatOrgName(asset.org, asset.name) : orgActive ? `global:${asset.name}` : asset.name);
|
|
1201
|
+
return installCommandFor(spec ?? names.join(' '), { adopt, force, pin, tool, user: scope === 'user' });
|
|
1202
|
+
}
|
|
1203
|
+
/**
|
|
1204
|
+
* The plan's direct targets that prefer the other scope, as the outcome's `preferredScope`, with
|
|
1205
|
+
* `command`, which installs them there. In JSON mode it also records the `preferred-scope` notice; a
|
|
1206
|
+
* TTY run shows `PreferredScopeWarning` under its summary instead.
|
|
1207
|
+
*/
|
|
1208
|
+
function preferredScopeField(preferred, command, json) {
|
|
1209
|
+
if (!preferred)
|
|
1210
|
+
return {};
|
|
1211
|
+
const field = { ...preferred, command: command(preferred) };
|
|
1212
|
+
if (json)
|
|
1213
|
+
addNotice(preferredScopeNotice(preferred, field.command));
|
|
1214
|
+
return { preferredScope: field };
|
|
1215
|
+
}
|
|
1017
1216
|
/**
|
|
1018
1217
|
* The bundles and orgs a run of several names had among them: what it did with each bundle, the
|
|
1019
1218
|
* bundle's members outside it, and how many assets each org brought.
|
|
@@ -1022,7 +1221,7 @@ function TargetLines({ bundles = [], dryRun = false, orgs = [], where, }) {
|
|
|
1022
1221
|
const inScope = where ? ` in ${where}` : '';
|
|
1023
1222
|
return (_jsxs(_Fragment, { children: [bundles.map((bundle) => {
|
|
1024
1223
|
const spec = formatOrgName(bundle.org, bundle.name);
|
|
1025
|
-
return (_jsxs(Fragment, { children: [bundle.outcome === 'already-installed' ? (_jsxs(Text, { children: [_jsx(Text, { color: 'yellow', children: "!" }), " Bundle ", _jsx(Text, { bold: true, children: spec }), " is already fully installed (v", bundle.version, ")", inScope, "."] })) : (_jsxs(Text, { children: [_jsx(Text, { color: 'green', children: "\u2713" }), " Bundle ", _jsx(Text, { bold: true, children: spec }), " v", bundle.version, ' ', dryRun ? 'would be installed' : 'installed', inScope, "."] })), _jsx(BundleReportLines, { bundleName: spec, dryRun: dryRun, report: bundle })] }, spec));
|
|
1224
|
+
return (_jsxs(Fragment, { children: [bundle.outcome === 'already-installed' ? (_jsxs(Text, { children: [_jsx(Text, { color: 'yellow', children: "!" }), " Bundle ", _jsx(Text, { bold: true, children: spec }), " is already fully installed (v", bundle.version, ")", inScope, "."] })) : (_jsxs(Text, { children: [_jsx(Text, { color: 'green', children: "\u2713" }), " Bundle ", _jsx(Text, { bold: true, children: spec }), " v", bundle.version, ' ', dryRun ? 'would be installed' : 'installed', inScope, "."] })), _jsx(BundlePinLine, { dryRun: dryRun, pin: bundle.pin }), _jsx(BundleReportLines, { bundleName: spec, dryRun: dryRun, report: bundle })] }, spec));
|
|
1026
1225
|
}), orgs.map(({ count, org }) => (_jsxs(Text, { children: [_jsxs(Text, { bold: true, color: 'magenta', children: ["Org: @", org] }), _jsxs(Text, { dimColor: true, children: [' ', "\u2014 all ", count, " asset", count !== 1 ? 's' : ''] })] }, org)))] }));
|
|
1027
1226
|
}
|
|
1028
1227
|
//# sourceMappingURL=install.js.map
|