@detergent-software/atk 9.4.0-dev.2 → 9.4.0-dev.21
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 +165 -0
- package/README.md +2 -2
- package/build/command-manifest.json +5 -5
- package/build/commands/audit.d.ts.map +1 -1
- package/build/commands/audit.js +7 -4
- package/build/commands/audit.js.map +1 -1
- package/build/commands/diff.d.ts.map +1 -1
- package/build/commands/diff.js +10 -10
- package/build/commands/diff.js.map +1 -1
- package/build/commands/info.d.ts.map +1 -1
- package/build/commands/info.js +17 -14
- package/build/commands/info.js.map +1 -1
- package/build/commands/install.d.ts.map +1 -1
- package/build/commands/install.js +279 -81
- package/build/commands/install.js.map +1 -1
- package/build/commands/move.d.ts.map +1 -1
- package/build/commands/move.js +5 -4
- package/build/commands/move.js.map +1 -1
- package/build/commands/outdated.js +1 -1
- package/build/commands/outdated.js.map +1 -1
- package/build/commands/update.d.ts.map +1 -1
- package/build/commands/update.js +14 -7
- package/build/commands/update.js.map +1 -1
- package/build/commands/why.d.ts.map +1 -1
- package/build/commands/why.js +28 -7
- package/build/commands/why.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/DiffView.d.ts +3 -1
- package/build/components/DiffView.d.ts.map +1 -1
- package/build/components/DiffView.js +2 -2
- package/build/components/DiffView.js.map +1 -1
- package/build/components/InitSuccess.d.ts.map +1 -1
- package/build/components/InitSuccess.js +4 -1
- package/build/components/InitSuccess.js.map +1 -1
- package/build/components/InstallSummary.d.ts +7 -2
- package/build/components/InstallSummary.d.ts.map +1 -1
- package/build/components/InstallSummary.js +3 -1
- package/build/components/InstallSummary.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/useInitState.d.ts +9 -1
- package/build/hooks/useInitState.d.ts.map +1 -1
- package/build/hooks/useInitState.js +43 -6
- package/build/hooks/useInitState.js.map +1 -1
- package/build/hooks/useListActions.d.ts.map +1 -1
- package/build/hooks/useListActions.js +9 -2
- package/build/hooks/useListActions.js.map +1 -1
- package/build/lib/adapter.d.ts +14 -9
- package/build/lib/adapter.d.ts.map +1 -1
- package/build/lib/adapter.js +46 -8
- package/build/lib/adapter.js.map +1 -1
- package/build/lib/asset-tools.d.ts +10 -0
- package/build/lib/asset-tools.d.ts.map +1 -1
- package/build/lib/asset-tools.js +18 -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/completion/candidates.d.ts.map +1 -1
- package/build/lib/completion/candidates.js +21 -8
- package/build/lib/completion/candidates.js.map +1 -1
- package/build/lib/config-entries.d.ts +3 -3
- package/build/lib/config-entries.d.ts.map +1 -1
- package/build/lib/config-entries.js +16 -6
- package/build/lib/config-entries.js.map +1 -1
- package/build/lib/config-lock.d.ts +2 -1
- package/build/lib/config-lock.d.ts.map +1 -1
- package/build/lib/config-lock.js +10 -2
- package/build/lib/config-lock.js.map +1 -1
- package/build/lib/cross-scope.d.ts +6 -2
- package/build/lib/cross-scope.d.ts.map +1 -1
- package/build/lib/cross-scope.js +20 -13
- package/build/lib/cross-scope.js.map +1 -1
- package/build/lib/diagnostics.d.ts +3 -2
- package/build/lib/diagnostics.d.ts.map +1 -1
- package/build/lib/diagnostics.js +6 -4
- package/build/lib/diagnostics.js.map +1 -1
- package/build/lib/diff-command.d.ts +7 -2
- package/build/lib/diff-command.d.ts.map +1 -1
- package/build/lib/diff-command.js +14 -10
- package/build/lib/diff-command.js.map +1 -1
- package/build/lib/gitignore.d.ts +8 -0
- package/build/lib/gitignore.d.ts.map +1 -1
- package/build/lib/gitignore.js +51 -6
- package/build/lib/gitignore.js.map +1 -1
- package/build/lib/hook-config.d.ts +60 -5
- package/build/lib/hook-config.d.ts.map +1 -1
- package/build/lib/hook-config.js +97 -5
- package/build/lib/hook-config.js.map +1 -1
- package/build/lib/hook-script.d.ts +10 -0
- package/build/lib/hook-script.d.ts.map +1 -1
- package/build/lib/hook-script.js +31 -1
- package/build/lib/hook-script.js.map +1 -1
- package/build/lib/init.d.ts +12 -4
- package/build/lib/init.d.ts.map +1 -1
- package/build/lib/init.js +78 -16
- package/build/lib/init.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 +87 -14
- package/build/lib/install-targets.js.map +1 -1
- package/build/lib/installer.d.ts +19 -3
- package/build/lib/installer.d.ts.map +1 -1
- package/build/lib/installer.js +112 -32
- package/build/lib/installer.js.map +1 -1
- package/build/lib/mover.d.ts +5 -4
- package/build/lib/mover.d.ts.map +1 -1
- package/build/lib/mover.js +23 -27
- package/build/lib/mover.js.map +1 -1
- package/build/lib/multi-tool-install.d.ts +48 -11
- package/build/lib/multi-tool-install.d.ts.map +1 -1
- package/build/lib/multi-tool-install.js +167 -38
- package/build/lib/multi-tool-install.js.map +1 -1
- package/build/lib/named-entry.d.ts +12 -0
- package/build/lib/named-entry.d.ts.map +1 -1
- package/build/lib/named-entry.js +16 -8
- package/build/lib/named-entry.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/schemas/adapter.d.ts +24 -0
- package/build/lib/schemas/adapter.d.ts.map +1 -1
- package/build/lib/schemas/adapter.js +18 -4
- package/build/lib/schemas/adapter.js.map +1 -1
- package/build/lib/sync.d.ts +7 -0
- package/build/lib/sync.d.ts.map +1 -1
- package/build/lib/sync.js +41 -3
- package/build/lib/sync.js.map +1 -1
- package/build/lib/touched-paths.d.ts.map +1 -1
- package/build/lib/touched-paths.js +2 -1
- package/build/lib/touched-paths.js.map +1 -1
- package/build/lib/uninstaller.d.ts.map +1 -1
- package/build/lib/uninstaller.js +11 -3
- package/build/lib/uninstaller.js.map +1 -1
- package/build/lib/updater.d.ts +32 -5
- package/build/lib/updater.d.ts.map +1 -1
- package/build/lib/updater.js +129 -14
- package/build/lib/updater.js.map +1 -1
- package/package.json +1 -1
- package/tool-adapters/codex-cli.json +5 -1
- package/tool-adapters/copilot-cli.json +55 -9
|
@@ -2,23 +2,24 @@ 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
|
-
import { placesAsset } from '../lib/asset-tools.js';
|
|
8
|
+
import { placesAsset, takesEntrypoint } from '../lib/asset-tools.js';
|
|
9
9
|
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
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
|
|
@@ -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,7 +225,7 @@ 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
|
|
@@ -239,6 +249,48 @@ function InstallAsset({ adopt, dryRun, force, json, org: cliOrg, pin, projectRoo
|
|
|
239
249
|
const org = resolveSpecOrg(nameScope, cliOrg, currentLockfile.org, config.org);
|
|
240
250
|
const effectiveVersion = requestedVersion;
|
|
241
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
|
+
};
|
|
242
294
|
// Check if the name matches a bundle. Bundle identity is (name, org) with
|
|
243
295
|
// exact matching — an @org/name spec never falls back to a global bundle
|
|
244
296
|
// and a bare name never resolves to an org-scoped one.
|
|
@@ -298,27 +350,96 @@ function InstallAsset({ adopt, dryRun, force, json, org: cliOrg, pin, projectRoo
|
|
|
298
350
|
user,
|
|
299
351
|
})
|
|
300
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
|
+
takesEntrypoint(t.adapter, existing.type, existing.entrypoint));
|
|
380
|
+
const inPlace = supportingTools.length > 0 &&
|
|
381
|
+
supportingTools.every((t) => isInstalledForTool(existing, t.adapter, projectDir)) &&
|
|
382
|
+
(!effectiveVersion || registryMatch.version === existing.version);
|
|
383
|
+
return inPlace ? existing : undefined;
|
|
384
|
+
};
|
|
385
|
+
// What the install does with an asset in place: makes a dependency direct and, with --pin, pins
|
|
386
|
+
// it at its version, as `atk pin` would.
|
|
387
|
+
const inPlaceReport = (existing) => ({
|
|
388
|
+
name: existing.name,
|
|
389
|
+
...(existing.org ? { org: existing.org } : {}),
|
|
390
|
+
outcome: (existing.installReason ?? 'direct') === 'dependency' ? 'upgraded-to-direct' : 'already-installed',
|
|
391
|
+
...(pin ? { pin: inPlacePin(existing) } : {}),
|
|
392
|
+
type: existing.type,
|
|
393
|
+
version: existing.version,
|
|
394
|
+
});
|
|
395
|
+
const nothingToInstall = { entries: [], totalCount: 0 };
|
|
301
396
|
// Dry-run: resolve plan without acquiring lockfile lock or executing. The install leaves
|
|
302
|
-
// dependencies already in place alone and refuses to move a pinned one, and so does the plan
|
|
397
|
+
// dependencies already in place alone and refuses to move a pinned one, and so does the plan,
|
|
398
|
+
// and it says what it would do with a target in place, as the install would.
|
|
303
399
|
if (dryRun) {
|
|
304
400
|
const asInstalled = (resolved) => withoutKeptDependencies(resolved, currentLockfile, tools, {
|
|
401
|
+
named: { force },
|
|
305
402
|
onProgress: progress,
|
|
403
|
+
pin,
|
|
306
404
|
projectDir,
|
|
307
405
|
scope: installScope,
|
|
308
406
|
});
|
|
309
407
|
if (bundle) {
|
|
310
|
-
progress('Resolving bundle assets...');
|
|
311
|
-
const resolved = resolveBundleInstallPlan(registry, bundle);
|
|
312
408
|
// Nothing is written, so the members an install would adopt are the ones with no origin now.
|
|
313
409
|
const outside = membersOutsideBundle(currentLockfile, members, bundle);
|
|
410
|
+
const report = bundleReport(adopt ? outside.filter((m) => m.bundle) : outside, adopt ? outside.filter((m) => !m.bundle) : [], { adoptCommand, bundle });
|
|
411
|
+
if (isBundleHere(currentLockfile)) {
|
|
412
|
+
return {
|
|
413
|
+
bundleName: bundle.name,
|
|
414
|
+
inPlace: true,
|
|
415
|
+
outcome: 'dry-run-bundle',
|
|
416
|
+
...bundlePinField(membersInPlace(currentLockfile, members)),
|
|
417
|
+
plan: nothingToInstall,
|
|
418
|
+
tools: toolNames,
|
|
419
|
+
version: bundle.version,
|
|
420
|
+
...report,
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
progress('Resolving bundle assets...');
|
|
424
|
+
const resolved = resolveBundleInstallPlan(registry, bundle);
|
|
314
425
|
return {
|
|
315
426
|
bundleName: bundle.name,
|
|
316
427
|
outcome: 'dry-run-bundle',
|
|
317
428
|
plan: asInstalled(resolved),
|
|
318
429
|
tools: toolNames,
|
|
319
430
|
version: bundle.version,
|
|
320
|
-
...
|
|
431
|
+
...report,
|
|
321
432
|
...(await crossScope(resolved)),
|
|
433
|
+
...preferredScope(resolved),
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
const existing = assetInPlace(currentLockfile);
|
|
437
|
+
if (existing) {
|
|
438
|
+
return {
|
|
439
|
+
assets: [inPlaceReport(existing)],
|
|
440
|
+
outcome: 'dry-run-install',
|
|
441
|
+
plan: nothingToInstall,
|
|
442
|
+
tools: toolNames,
|
|
322
443
|
};
|
|
323
444
|
}
|
|
324
445
|
const versionLabel = effectiveVersion ? `@${effectiveVersion}` : '';
|
|
@@ -329,6 +450,7 @@ function InstallAsset({ adopt, dryRun, force, json, org: cliOrg, pin, projectRoo
|
|
|
329
450
|
plan: asInstalled(resolved),
|
|
330
451
|
tools: toolNames,
|
|
331
452
|
...(await crossScope(resolved)),
|
|
453
|
+
...preferredScope(resolved),
|
|
332
454
|
};
|
|
333
455
|
}
|
|
334
456
|
return await withLockfileErrorHandling(projectDir, async () => {
|
|
@@ -340,34 +462,42 @@ function InstallAsset({ adopt, dryRun, force, json, org: cliOrg, pin, projectRoo
|
|
|
340
462
|
version: bundle.version,
|
|
341
463
|
};
|
|
342
464
|
// Bundle installation flow — check if already installed for ALL tools
|
|
343
|
-
if (
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
465
|
+
if (isBundleHere(before)) {
|
|
466
|
+
// Adopting a bundle that is in place only records its origin on the members with none:
|
|
467
|
+
// their files, versions and pins stay as they are. Another bundle's member stays its.
|
|
468
|
+
// --pin pins every member at its version, as a fresh install with --pin would.
|
|
469
|
+
const outside = membersOutsideBundle(before, members, bundle);
|
|
470
|
+
const adopted = adopt ? outside.filter((member) => !member.bundle) : [];
|
|
471
|
+
const installedMembers = membersInPlace(before, members);
|
|
472
|
+
const pinField = bundlePinField(installedMembers);
|
|
473
|
+
if (adopted.length > 0 || pinField.pin === 'pinned') {
|
|
474
|
+
let lockfile = before;
|
|
475
|
+
for (const { name: memberName, org: memberOrg, type } of adopted) {
|
|
476
|
+
const installed = findInstalledAsset(lockfile, memberName, type, memberOrg);
|
|
477
|
+
lockfile = addAssetToLockfile(lockfile, { ...installed, bundleOrigin });
|
|
356
478
|
}
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
version: bundle.version,
|
|
361
|
-
...bundleReport(outside.filter((member) => !adopted.includes(member)), adopted, { adoptCommand, bundle }),
|
|
362
|
-
};
|
|
479
|
+
if (pinField.pin === 'pinned')
|
|
480
|
+
lockfile = pinMembersInPlace(lockfile, installedMembers);
|
|
481
|
+
await writeLockfile(projectDir, lockfile);
|
|
363
482
|
}
|
|
483
|
+
return {
|
|
484
|
+
bundleName: bundle.name,
|
|
485
|
+
outcome: 'bundle-already-installed',
|
|
486
|
+
...pinField,
|
|
487
|
+
version: bundle.version,
|
|
488
|
+
...bundleReport(outside.filter((member) => !adopted.includes(member)), adopted, { adoptCommand, bundle }),
|
|
489
|
+
};
|
|
364
490
|
}
|
|
365
491
|
progress('Resolving bundle assets...');
|
|
366
492
|
const plan = resolveBundleInstallPlan(registry, bundle);
|
|
493
|
+
const question = await askScope(plan, bundle.name);
|
|
494
|
+
if (question)
|
|
495
|
+
return question;
|
|
367
496
|
const toolResults = await executeInstallPlanForTools(plan, tools, {
|
|
368
497
|
adopt,
|
|
369
498
|
bundleOrigin,
|
|
370
499
|
force,
|
|
500
|
+
named: { force },
|
|
371
501
|
onProgress: progress,
|
|
372
502
|
onTool: (toolName) => progress(`Installing bundle for ${toolName}...`),
|
|
373
503
|
pin,
|
|
@@ -385,56 +515,52 @@ function InstallAsset({ adopt, dryRun, force, json, org: cliOrg, pin, projectRoo
|
|
|
385
515
|
version: bundle.version,
|
|
386
516
|
...bundleReport(kept, adopted, { adoptCommand, bundle }),
|
|
387
517
|
...(await crossScope(plan, projectDir)),
|
|
518
|
+
...preferredScope(plan),
|
|
388
519
|
};
|
|
389
520
|
}
|
|
390
521
|
// Single asset installation flow
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
? findInstalledAsset(lockfile, name, registryMatch.asset.type, registryMatch.asset.org)
|
|
400
|
-
: undefined;
|
|
401
|
-
// Tools that cannot place this asset (its type, or a hook its manifest doesn't declare)
|
|
402
|
-
// have nothing to check. When none of the targeted tools can, fall through so the
|
|
403
|
-
// installer reports why instead of claiming the asset is already installed.
|
|
404
|
-
const supportingTools = existing && registryMatch
|
|
405
|
-
? tools.filter((t) => placesAsset(t.adapter, existing.type, registryMatch.versionData.tools))
|
|
406
|
-
: [];
|
|
407
|
-
if (existing &&
|
|
408
|
-
supportingTools.length > 0 &&
|
|
409
|
-
supportingTools.every((t) => isInstalledForTool(existing, t.adapter, projectDir))) {
|
|
410
|
-
// If it was auto-installed as a dependency, upgrade it to a direct install
|
|
411
|
-
if ((existing.installReason ?? 'direct') === 'dependency') {
|
|
412
|
-
const updated = upgradeToDirectInstall(lockfile, name, existing.type, existing.org);
|
|
413
|
-
await writeLockfile(projectDir, updated);
|
|
414
|
-
return { name, outcome: 'upgraded-to-direct', version: existing.version };
|
|
415
|
-
}
|
|
416
|
-
// If a specific version was requested and it differs from installed,
|
|
417
|
-
// fall through to resolver (which will error if version doesn't exist)
|
|
418
|
-
if (effectiveVersion && effectiveVersion !== existing.version) {
|
|
419
|
-
// Let it proceed to resolveInstallPlan below
|
|
522
|
+
const lockfile = force ? undefined : await readLockfile(projectDir);
|
|
523
|
+
const existing = lockfile && assetInPlace(lockfile);
|
|
524
|
+
if (lockfile && existing) {
|
|
525
|
+
const { outcome, pin: pinned } = inPlaceReport(existing);
|
|
526
|
+
if (outcome === 'upgraded-to-direct' || pinned === 'pinned') {
|
|
527
|
+
let updated = lockfile;
|
|
528
|
+
if (outcome === 'upgraded-to-direct') {
|
|
529
|
+
updated = upgradeToDirectInstall(updated, name, existing.type, existing.org);
|
|
420
530
|
}
|
|
421
|
-
|
|
422
|
-
|
|
531
|
+
if (pinned === 'pinned') {
|
|
532
|
+
updated = pinAssetVersion(updated, name, existing.version, existing.type, existing.org);
|
|
423
533
|
}
|
|
534
|
+
await writeLockfile(projectDir, updated);
|
|
424
535
|
}
|
|
536
|
+
return {
|
|
537
|
+
name,
|
|
538
|
+
outcome: outcome === 'upgraded-to-direct' ? 'upgraded-to-direct' : 'already-installed',
|
|
539
|
+
...(pinned ? { pin: pinned } : {}),
|
|
540
|
+
version: existing.version,
|
|
541
|
+
};
|
|
425
542
|
}
|
|
426
543
|
const versionLabel = effectiveVersion ? `@${effectiveVersion}` : '';
|
|
427
544
|
progress(`Resolving dependencies${versionLabel}...`);
|
|
428
545
|
const plan = resolveInstallPlan(registry, name, undefined, effectiveVersion, org);
|
|
546
|
+
const question = await askScope(plan);
|
|
547
|
+
if (question)
|
|
548
|
+
return question;
|
|
429
549
|
const toolResults = await executeInstallPlanForTools(plan, tools, {
|
|
430
550
|
force,
|
|
551
|
+
named: { force },
|
|
431
552
|
onProgress: progress,
|
|
432
553
|
onTool: (toolName) => progress(`Installing for ${toolName}...`),
|
|
433
554
|
pin,
|
|
434
555
|
projectDir: projectDir,
|
|
435
556
|
scope: installScope,
|
|
436
557
|
});
|
|
437
|
-
return {
|
|
558
|
+
return {
|
|
559
|
+
outcome: 'installed',
|
|
560
|
+
toolResults,
|
|
561
|
+
...(await crossScope(plan, projectDir)),
|
|
562
|
+
...preferredScope(plan),
|
|
563
|
+
};
|
|
438
564
|
});
|
|
439
565
|
}, [adopt, cliOrg, dryRun, force, inlineOrg, name, pin, requestedVersion, tool]);
|
|
440
566
|
if (state.status === 'loading') {
|
|
@@ -456,31 +582,59 @@ function InstallAsset({ adopt, dryRun, force, json, org: cliOrg, pin, projectRoo
|
|
|
456
582
|
const { data } = state;
|
|
457
583
|
const label = resolved && scopeLabel(resolved);
|
|
458
584
|
const where = label ? ` in ${label}` : '';
|
|
585
|
+
if (data.outcome === 'ask-scope') {
|
|
586
|
+
return (_jsx(PreferredScopeQuestion, { bundleName: data.bundleName, onAnswer: (move) => onScopeAnswer?.(move ? { scope: data.preferred.scope, spec: data.spec } : undefined), preferred: data.preferred }));
|
|
587
|
+
}
|
|
459
588
|
if (effectiveJson) {
|
|
460
589
|
return renderJson({ ...data, ...fields });
|
|
461
590
|
}
|
|
462
591
|
if (data.outcome === 'bundle-already-installed') {
|
|
463
|
-
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 })] }));
|
|
592
|
+
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 })] }));
|
|
464
593
|
}
|
|
465
594
|
if (data.outcome === 'bundle-installed') {
|
|
466
|
-
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 ?? [] })] }));
|
|
595
|
+
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 })] }));
|
|
467
596
|
}
|
|
468
597
|
if (data.outcome === 'already-installed') {
|
|
469
|
-
|
|
598
|
+
if (data.pin === 'pinned') {
|
|
599
|
+
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, "."] }));
|
|
600
|
+
}
|
|
601
|
+
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." })] }));
|
|
470
602
|
}
|
|
471
603
|
if (data.outcome === 'upgraded-to-direct') {
|
|
472
|
-
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,
|
|
604
|
+
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'
|
|
605
|
+
? `, and is now pinned at v${data.version}`
|
|
606
|
+
: data.pin === 'already-pinned'
|
|
607
|
+
? `, already pinned at v${data.version}`
|
|
608
|
+
: '', "."] }), _jsx(Text, { dimColor: true, children: "It will no longer be auto-removed when its parent is uninstalled." })] }));
|
|
473
609
|
}
|
|
474
610
|
if (data.outcome === 'dry-run-install') {
|
|
475
|
-
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 ?? [] })] }));
|
|
611
|
+
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 })] }));
|
|
476
612
|
}
|
|
477
613
|
if (data.outcome === 'dry-run-bundle') {
|
|
478
|
-
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 ?? [] })] }));
|
|
614
|
+
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 })] }));
|
|
479
615
|
}
|
|
480
616
|
if (data.outcome === 'deprecated') {
|
|
481
617
|
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." })] }));
|
|
482
618
|
}
|
|
483
|
-
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 ?? [] })] }));
|
|
619
|
+
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 })] }));
|
|
620
|
+
}
|
|
621
|
+
/**
|
|
622
|
+
* One asset or bundle, asking first when its authors prefer the other scope: the install runs again
|
|
623
|
+
* at the scope the answer picks, and doesn't ask twice.
|
|
624
|
+
*/
|
|
625
|
+
function InstallAssetAtAnsweredScope(props) {
|
|
626
|
+
const [answer, setAnswer] = useState();
|
|
627
|
+
if (!answer) {
|
|
628
|
+
// Only the first key answers: a second one, before the question goes, would change the scope under the install.
|
|
629
|
+
return _jsx(InstallAsset, { ...props, onScopeAnswer: (move) => setAnswer((first) => first ?? { move }) }, 'asking');
|
|
630
|
+
}
|
|
631
|
+
if (!answer.move) {
|
|
632
|
+
return _jsx(InstallAsset, { ...props, answered: true }, 'answered');
|
|
633
|
+
}
|
|
634
|
+
// The other scope's root: the user root, or the cwd's project, never the --project-root asked with; and
|
|
635
|
+
// the asset by the name the question resolved, which --org can't contradict.
|
|
636
|
+
const { scope, spec } = answer.move;
|
|
637
|
+
return (_jsx(InstallAsset, { ...props, answered: true, org: undefined, projectRoot: undefined, rawName: spec, user: scope === 'user' }, 'moved'));
|
|
484
638
|
}
|
|
485
639
|
/**
|
|
486
640
|
* `atk install a b@1.2.0 @org/c my-bundle @org --all`: the named assets, the bundles' members and
|
|
@@ -591,7 +745,7 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
|
|
|
591
745
|
user,
|
|
592
746
|
});
|
|
593
747
|
progress('Resolving dependencies...');
|
|
594
|
-
const targetsPlan = planTargetsInstall(registry, targets, currentLockfile, tools, { force, projectDir });
|
|
748
|
+
const targetsPlan = planTargetsInstall(registry, targets, currentLockfile, tools, { force, pin, projectDir });
|
|
595
749
|
const { assets: report, plan, toInstall } = targetsPlan;
|
|
596
750
|
const bundles = targetsPlan.bundlesInPlace.map((request) => {
|
|
597
751
|
const { bundle } = request;
|
|
@@ -599,6 +753,7 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
|
|
|
599
753
|
name: bundle.name,
|
|
600
754
|
...(bundle.org ? { org: bundle.org } : {}),
|
|
601
755
|
outcome: 'already-installed',
|
|
756
|
+
...(request.pin ? { pin: request.pin } : {}),
|
|
602
757
|
version: bundle.version,
|
|
603
758
|
...bundleReport(membersOutsideBundle(currentLockfile, bundleMembers(registry, bundle, tools), bundle), [], {
|
|
604
759
|
adoptCommand: adoptCommandFor(request),
|
|
@@ -607,6 +762,13 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
|
|
|
607
762
|
};
|
|
608
763
|
});
|
|
609
764
|
const crossScope = (resolvedPlan, installedAt) => crossScopeOf(resolvedPlan, { installedAt, json: effectiveJson, scope: installScope, tools: toolNames });
|
|
765
|
+
// Several names install together at one scope, so a preference for the other only gets a notice.
|
|
766
|
+
const preferredScope = (resolvedPlan) => preferredScopeField(preferredScopeOf(resolvedPlan, installScope), (preferred) => preferredScopeCommand(preferred, {
|
|
767
|
+
force,
|
|
768
|
+
orgActive: Boolean(cliOrg || currentLockfile.org || config.org),
|
|
769
|
+
pin,
|
|
770
|
+
tool,
|
|
771
|
+
}), effectiveJson);
|
|
610
772
|
// Each bundle in the plan, in the order named, then the ones left out; and the orgs.
|
|
611
773
|
const targetsField = (lockfile, planned) => {
|
|
612
774
|
const installedBundles = toInstall.flatMap((request) => {
|
|
@@ -639,17 +801,21 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
|
|
|
639
801
|
...targetsField(currentLockfile, true),
|
|
640
802
|
outcome: 'dry-run-install',
|
|
641
803
|
plan: withoutKeptDependencies(plan, currentLockfile, tools, {
|
|
804
|
+
named: { force },
|
|
642
805
|
onProgress: progress,
|
|
806
|
+
pin,
|
|
643
807
|
projectDir,
|
|
644
808
|
scope: installScope,
|
|
645
809
|
}),
|
|
646
810
|
tools: toolNames,
|
|
647
811
|
...(await crossScope(plan)),
|
|
812
|
+
...preferredScope(plan),
|
|
648
813
|
};
|
|
649
814
|
}
|
|
650
815
|
return await withLockfileErrorHandling(projectDir, async () => {
|
|
651
816
|
const toolResults = await installPlannedTargets(targetsPlan, tools, {
|
|
652
817
|
force,
|
|
818
|
+
named: { force },
|
|
653
819
|
onProgress: progress,
|
|
654
820
|
onTool: (toolName) => progress(`Installing for ${toolName}...`),
|
|
655
821
|
pin,
|
|
@@ -665,6 +831,7 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
|
|
|
665
831
|
outcome: 'installed',
|
|
666
832
|
toolResults,
|
|
667
833
|
...(await crossScope(plan, projectDir)),
|
|
834
|
+
...preferredScope(plan),
|
|
668
835
|
};
|
|
669
836
|
});
|
|
670
837
|
}, [adopt, all, cliOrg, dryRun, force, pin, specs.join(' '), tool]);
|
|
@@ -690,10 +857,10 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
|
|
|
690
857
|
return renderJson({ ...data, ...fields });
|
|
691
858
|
}
|
|
692
859
|
if (data.outcome === 'dry-run-install') {
|
|
693
|
-
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 ?? [] })] }));
|
|
860
|
+
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 })] }));
|
|
694
861
|
}
|
|
695
862
|
return (_jsxs(Box, { flexDirection: 'column', children: [data.outcome === 'installed' &&
|
|
696
|
-
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 ?? [] })] }));
|
|
863
|
+
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 })] }));
|
|
697
864
|
}
|
|
698
865
|
/** `atk install <spec>` with the run's own flags, for a command an error suggests. */
|
|
699
866
|
function installCommandFor(spec, { adopt, dryRun, force, pin, projectRoot, tool, user }) {
|
|
@@ -799,14 +966,21 @@ function InstallOrg({ cliOrg, dryRun, force, json, orgName, pin, projectRoot, sk
|
|
|
799
966
|
const refs = assetsToInstall.map((a) => ({ name: a.name, type: a.type }));
|
|
800
967
|
const plan = resolveMultipleInstallPlans(ctx.registry, refs, ctx.activeOrg);
|
|
801
968
|
const crossScope = (resolved, installedAt) => crossScopeOf(resolved, { installedAt, json: effectiveJson, scope: ctx.scope, tools: ctx.toolNames });
|
|
969
|
+
// The picker already chose what installs here, so a preference for the other scope only gets a
|
|
970
|
+
// notice, once the run has planned or installed (a failed install records none). An org's assets
|
|
971
|
+
// are all its own, so each is named `@org/name`.
|
|
972
|
+
const preferredScope = () => preferredScopeField(preferredScopeOf(plan, ctx.scope), (preferred) => preferredScopeCommand(preferred, { force, pin, tool }), effectiveJson);
|
|
802
973
|
if (dryRun) {
|
|
974
|
+
// An org's assets aren't named one by one, so --force doesn't move them past a pin or a dependent.
|
|
803
975
|
const kept = withoutKeptDependencies(plan, ctx.lockfile, ctx.tools, {
|
|
976
|
+
pin,
|
|
804
977
|
projectDir: ctx.projectDir,
|
|
805
978
|
scope: ctx.scope,
|
|
806
979
|
});
|
|
807
980
|
const field = await crossScope(plan);
|
|
808
|
-
if (!cancelled)
|
|
809
|
-
setState({ phase: 'dry-run', plan: kept, tools: ctx.toolNames, ...field });
|
|
981
|
+
if (!cancelled) {
|
|
982
|
+
setState({ phase: 'dry-run', plan: kept, tools: ctx.toolNames, ...field, ...preferredScope() });
|
|
983
|
+
}
|
|
810
984
|
return;
|
|
811
985
|
}
|
|
812
986
|
if (!cancelled)
|
|
@@ -827,7 +1001,7 @@ function InstallOrg({ cliOrg, dryRun, force, json, orgName, pin, projectRoot, sk
|
|
|
827
1001
|
}));
|
|
828
1002
|
const field = await crossScope(plan, ctx.projectDir);
|
|
829
1003
|
if (!cancelled)
|
|
830
|
-
setState({ phase: 'done', toolResults, ...field });
|
|
1004
|
+
setState({ phase: 'done', toolResults, ...field, ...preferredScope() });
|
|
831
1005
|
}
|
|
832
1006
|
catch (err) {
|
|
833
1007
|
showError(err);
|
|
@@ -937,11 +1111,12 @@ function InstallOrg({ cliOrg, dryRun, force, json, orgName, pin, projectRoot, sk
|
|
|
937
1111
|
org: orgName,
|
|
938
1112
|
outcome: 'dry-run-org',
|
|
939
1113
|
plan: state.plan,
|
|
1114
|
+
preferredScope: state.preferredScope,
|
|
940
1115
|
tools: state.tools,
|
|
941
1116
|
...fields,
|
|
942
1117
|
});
|
|
943
1118
|
}
|
|
944
|
-
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 ?? [] })] }));
|
|
1119
|
+
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 })] }));
|
|
945
1120
|
}
|
|
946
1121
|
if (state.phase === 'done') {
|
|
947
1122
|
if (effectiveJson) {
|
|
@@ -949,11 +1124,12 @@ function InstallOrg({ cliOrg, dryRun, force, json, orgName, pin, projectRoot, sk
|
|
|
949
1124
|
crossScope: state.crossScope,
|
|
950
1125
|
org: orgName,
|
|
951
1126
|
outcome: 'org-installed',
|
|
1127
|
+
preferredScope: state.preferredScope,
|
|
952
1128
|
toolResults: state.toolResults,
|
|
953
1129
|
...fields,
|
|
954
1130
|
});
|
|
955
1131
|
}
|
|
956
|
-
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 ?? [] })] }));
|
|
1132
|
+
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 })] }));
|
|
957
1133
|
}
|
|
958
1134
|
return null;
|
|
959
1135
|
}
|
|
@@ -981,9 +1157,13 @@ function NamedAssetLines({ assets, dryRun = false, where, }) {
|
|
|
981
1157
|
const inScope = where ? ` in ${where}` : '';
|
|
982
1158
|
return (_jsx(_Fragment, { children: assets
|
|
983
1159
|
.filter((a) => a.outcome !== 'installed')
|
|
984
|
-
.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'
|
|
985
|
-
? `${dryRun ? 'would become' : 'is now'} a direct install${inScope}
|
|
986
|
-
: `is already installed${inScope}
|
|
1160
|
+
.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'
|
|
1161
|
+
? `${dryRun ? 'would become' : 'is now'} a direct install${inScope}`
|
|
1162
|
+
: `is already installed${inScope}`, a.pin === 'pinned'
|
|
1163
|
+
? `, and ${dryRun ? 'would be' : 'is now'} pinned at v${a.version}.`
|
|
1164
|
+
: a.pin === 'already-pinned'
|
|
1165
|
+
? `${a.outcome === 'upgraded-to-direct' ? ', already' : ' and'} pinned at v${a.version}.`
|
|
1166
|
+
: '.'] }, identityKey(a)))) }));
|
|
987
1167
|
}
|
|
988
1168
|
/**
|
|
989
1169
|
* The error for a bundle name that only another scope has, when no asset can claim the name
|
|
@@ -1016,6 +1196,24 @@ function plannedOutsideBundle(plan, lockfile, members, bundle) {
|
|
|
1016
1196
|
return [{ ...(origin ? { bundle: origin } : {}), ...member }];
|
|
1017
1197
|
});
|
|
1018
1198
|
}
|
|
1199
|
+
/** The install of the targets that prefer the other scope, at that scope, with the run's own flags. */
|
|
1200
|
+
function preferredScopeCommand({ assets, scope }, { adopt, force, orgActive = false, pin, spec, tool, }) {
|
|
1201
|
+
const names = assets.map((asset) => asset.org ? formatOrgName(asset.org, asset.name) : orgActive ? `global:${asset.name}` : asset.name);
|
|
1202
|
+
return installCommandFor(spec ?? names.join(' '), { adopt, force, pin, tool, user: scope === 'user' });
|
|
1203
|
+
}
|
|
1204
|
+
/**
|
|
1205
|
+
* The plan's direct targets that prefer the other scope, as the outcome's `preferredScope`, with
|
|
1206
|
+
* `command`, which installs them there. In JSON mode it also records the `preferred-scope` notice; a
|
|
1207
|
+
* TTY run shows `PreferredScopeWarning` under its summary instead.
|
|
1208
|
+
*/
|
|
1209
|
+
function preferredScopeField(preferred, command, json) {
|
|
1210
|
+
if (!preferred)
|
|
1211
|
+
return {};
|
|
1212
|
+
const field = { ...preferred, command: command(preferred) };
|
|
1213
|
+
if (json)
|
|
1214
|
+
addNotice(preferredScopeNotice(preferred, field.command));
|
|
1215
|
+
return { preferredScope: field };
|
|
1216
|
+
}
|
|
1019
1217
|
/**
|
|
1020
1218
|
* The bundles and orgs a run of several names had among them: what it did with each bundle, the
|
|
1021
1219
|
* bundle's members outside it, and how many assets each org brought.
|
|
@@ -1024,7 +1222,7 @@ function TargetLines({ bundles = [], dryRun = false, orgs = [], where, }) {
|
|
|
1024
1222
|
const inScope = where ? ` in ${where}` : '';
|
|
1025
1223
|
return (_jsxs(_Fragment, { children: [bundles.map((bundle) => {
|
|
1026
1224
|
const spec = formatOrgName(bundle.org, bundle.name);
|
|
1027
|
-
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));
|
|
1225
|
+
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));
|
|
1028
1226
|
}), 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)))] }));
|
|
1029
1227
|
}
|
|
1030
1228
|
//# sourceMappingURL=install.js.map
|