@detergent-software/atk 9.4.0-dev.1 → 9.4.0-dev.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/build/command-manifest.json +1 -1
  3. package/build/commands/info.js +1 -0
  4. package/build/commands/info.js.map +1 -1
  5. package/build/commands/install.d.ts.map +1 -1
  6. package/build/commands/install.js +277 -80
  7. package/build/commands/install.js.map +1 -1
  8. package/build/commands/update.d.ts.map +1 -1
  9. package/build/commands/update.js +14 -7
  10. package/build/commands/update.js.map +1 -1
  11. package/build/components/AssetDetail.d.ts.map +1 -1
  12. package/build/components/AssetDetail.js +1 -1
  13. package/build/components/AssetDetail.js.map +1 -1
  14. package/build/components/PreferredScopeQuestion.d.ts +16 -0
  15. package/build/components/PreferredScopeQuestion.d.ts.map +1 -0
  16. package/build/components/PreferredScopeQuestion.js +20 -0
  17. package/build/components/PreferredScopeQuestion.js.map +1 -0
  18. package/build/components/PreferredScopeWarning.d.ts +17 -0
  19. package/build/components/PreferredScopeWarning.d.ts.map +1 -0
  20. package/build/components/PreferredScopeWarning.js +13 -0
  21. package/build/components/PreferredScopeWarning.js.map +1 -0
  22. package/build/components/index.d.ts +2 -0
  23. package/build/components/index.d.ts.map +1 -1
  24. package/build/components/index.js +2 -0
  25. package/build/components/index.js.map +1 -1
  26. package/build/hooks/useListActions.d.ts.map +1 -1
  27. package/build/hooks/useListActions.js +5 -1
  28. package/build/hooks/useListActions.js.map +1 -1
  29. package/build/lib/asset-tools.d.ts +2 -0
  30. package/build/lib/asset-tools.d.ts.map +1 -1
  31. package/build/lib/asset-tools.js +4 -0
  32. package/build/lib/asset-tools.js.map +1 -1
  33. package/build/lib/atk-schemas/index.d.ts +1 -1
  34. package/build/lib/atk-schemas/index.d.ts.map +1 -1
  35. package/build/lib/atk-schemas/index.js +1 -1
  36. package/build/lib/atk-schemas/index.js.map +1 -1
  37. package/build/lib/atk-schemas/manifest.d.ts +14 -0
  38. package/build/lib/atk-schemas/manifest.d.ts.map +1 -1
  39. package/build/lib/atk-schemas/manifest.js +3 -0
  40. package/build/lib/atk-schemas/manifest.js.map +1 -1
  41. package/build/lib/atk-schemas/registry.d.ts +16 -0
  42. package/build/lib/atk-schemas/registry.d.ts.map +1 -1
  43. package/build/lib/atk-schemas/registry.js +2 -1
  44. package/build/lib/atk-schemas/registry.js.map +1 -1
  45. package/build/lib/diff-command.d.ts +6 -1
  46. package/build/lib/diff-command.d.ts.map +1 -1
  47. package/build/lib/diff-command.js +25 -28
  48. package/build/lib/diff-command.js.map +1 -1
  49. package/build/lib/install-targets.d.ts +35 -8
  50. package/build/lib/install-targets.d.ts.map +1 -1
  51. package/build/lib/install-targets.js +79 -12
  52. package/build/lib/install-targets.js.map +1 -1
  53. package/build/lib/installer.d.ts +9 -3
  54. package/build/lib/installer.d.ts.map +1 -1
  55. package/build/lib/installer.js +28 -10
  56. package/build/lib/installer.js.map +1 -1
  57. package/build/lib/multi-tool-install.d.ts +35 -6
  58. package/build/lib/multi-tool-install.d.ts.map +1 -1
  59. package/build/lib/multi-tool-install.js +123 -28
  60. package/build/lib/multi-tool-install.js.map +1 -1
  61. package/build/lib/preferred-scope.d.ts +38 -0
  62. package/build/lib/preferred-scope.d.ts.map +1 -0
  63. package/build/lib/preferred-scope.js +53 -0
  64. package/build/lib/preferred-scope.js.map +1 -0
  65. package/build/lib/updater.d.ts +30 -5
  66. package/build/lib/updater.d.ts.map +1 -1
  67. package/build/lib/updater.js +94 -12
  68. package/build/lib/updater.js.map +1 -1
  69. 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
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: 'Alias for --all: install every asset from an org scope without prompting',
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(InstallAsset, { adopt: adopt, dryRun: dryRun, force: force, json: json, org: org, pin: pin, projectRoot: projectRoot, rawName: rawName, tool: tool, user: user }));
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,95 @@ 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
+ 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 };
301
395
  // 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.
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.
303
398
  if (dryRun) {
304
399
  const asInstalled = (resolved) => withoutKeptDependencies(resolved, currentLockfile, tools, {
400
+ named: { force },
305
401
  onProgress: progress,
402
+ pin,
306
403
  projectDir,
307
404
  scope: installScope,
308
405
  });
309
406
  if (bundle) {
310
- progress('Resolving bundle assets...');
311
- const resolved = resolveBundleInstallPlan(registry, bundle);
312
407
  // Nothing is written, so the members an install would adopt are the ones with no origin now.
313
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);
314
424
  return {
315
425
  bundleName: bundle.name,
316
426
  outcome: 'dry-run-bundle',
317
427
  plan: asInstalled(resolved),
318
428
  tools: toolNames,
319
429
  version: bundle.version,
320
- ...bundleReport(adopt ? outside.filter((m) => m.bundle) : outside, adopt ? outside.filter((m) => !m.bundle) : [], { adoptCommand, bundle }),
430
+ ...report,
321
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,
322
442
  };
323
443
  }
324
444
  const versionLabel = effectiveVersion ? `@${effectiveVersion}` : '';
@@ -329,6 +449,7 @@ function InstallAsset({ adopt, dryRun, force, json, org: cliOrg, pin, projectRoo
329
449
  plan: asInstalled(resolved),
330
450
  tools: toolNames,
331
451
  ...(await crossScope(resolved)),
452
+ ...preferredScope(resolved),
332
453
  };
333
454
  }
334
455
  return await withLockfileErrorHandling(projectDir, async () => {
@@ -340,34 +461,42 @@ function InstallAsset({ adopt, dryRun, force, json, org: cliOrg, pin, projectRoo
340
461
  version: bundle.version,
341
462
  };
342
463
  // Bundle installation flow — check if already installed for ALL tools
343
- if (!force) {
344
- if (isBundleInPlace(registry, bundle, before, { members, projectDir, requiredBundleVersion, tools })) {
345
- // Adopting a bundle that is in place only records its origin on the members with none:
346
- // their files, versions and pins stay as they are. Another bundle's member stays its.
347
- const outside = membersOutsideBundle(before, members, bundle);
348
- const adopted = adopt ? outside.filter((member) => !member.bundle) : [];
349
- if (adopted.length > 0) {
350
- let lockfile = before;
351
- for (const { name: memberName, org: memberOrg, type } of adopted) {
352
- const installed = findInstalledAsset(lockfile, memberName, type, memberOrg);
353
- lockfile = addAssetToLockfile(lockfile, { ...installed, bundleOrigin });
354
- }
355
- await writeLockfile(projectDir, lockfile);
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 });
356
477
  }
357
- return {
358
- bundleName: bundle.name,
359
- outcome: 'bundle-already-installed',
360
- version: bundle.version,
361
- ...bundleReport(outside.filter((member) => !adopted.includes(member)), adopted, { adoptCommand, bundle }),
362
- };
478
+ if (pinField.pin === 'pinned')
479
+ lockfile = pinMembersInPlace(lockfile, installedMembers);
480
+ await writeLockfile(projectDir, lockfile);
363
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
+ };
364
489
  }
365
490
  progress('Resolving bundle assets...');
366
491
  const plan = resolveBundleInstallPlan(registry, bundle);
492
+ const question = await askScope(plan, bundle.name);
493
+ if (question)
494
+ return question;
367
495
  const toolResults = await executeInstallPlanForTools(plan, tools, {
368
496
  adopt,
369
497
  bundleOrigin,
370
498
  force,
499
+ named: { force },
371
500
  onProgress: progress,
372
501
  onTool: (toolName) => progress(`Installing bundle for ${toolName}...`),
373
502
  pin,
@@ -385,56 +514,52 @@ function InstallAsset({ adopt, dryRun, force, json, org: cliOrg, pin, projectRoo
385
514
  version: bundle.version,
386
515
  ...bundleReport(kept, adopted, { adoptCommand, bundle }),
387
516
  ...(await crossScope(plan, projectDir)),
517
+ ...preferredScope(plan),
388
518
  };
389
519
  }
390
520
  // Single asset installation flow
391
- if (!force) {
392
- const lockfile = await readLockfile(projectDir);
393
- // Resolve the registry identity first so the already-installed check matches on
394
- // (name, type, org), not name alone — a same-named asset of a different type or
395
- // org must not short-circuit this install. The lockfile is shared across tools, so
396
- // the asset only counts as installed when every targeted tool has it in place.
397
- const registryMatch = findAsset(registry, name, undefined, effectiveVersion, org);
398
- const existing = registryMatch
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
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);
420
529
  }
421
- else {
422
- return { name, outcome: 'already-installed', version: existing.version };
530
+ if (pinned === 'pinned') {
531
+ updated = pinAssetVersion(updated, name, existing.version, existing.type, existing.org);
423
532
  }
533
+ await writeLockfile(projectDir, updated);
424
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
+ };
425
541
  }
426
542
  const versionLabel = effectiveVersion ? `@${effectiveVersion}` : '';
427
543
  progress(`Resolving dependencies${versionLabel}...`);
428
544
  const plan = resolveInstallPlan(registry, name, undefined, effectiveVersion, org);
545
+ const question = await askScope(plan);
546
+ if (question)
547
+ return question;
429
548
  const toolResults = await executeInstallPlanForTools(plan, tools, {
430
549
  force,
550
+ named: { force },
431
551
  onProgress: progress,
432
552
  onTool: (toolName) => progress(`Installing for ${toolName}...`),
433
553
  pin,
434
554
  projectDir: projectDir,
435
555
  scope: installScope,
436
556
  });
437
- return { outcome: 'installed', toolResults, ...(await crossScope(plan, projectDir)) };
557
+ return {
558
+ outcome: 'installed',
559
+ toolResults,
560
+ ...(await crossScope(plan, projectDir)),
561
+ ...preferredScope(plan),
562
+ };
438
563
  });
439
564
  }, [adopt, cliOrg, dryRun, force, inlineOrg, name, pin, requestedVersion, tool]);
440
565
  if (state.status === 'loading') {
@@ -456,31 +581,59 @@ function InstallAsset({ adopt, dryRun, force, json, org: cliOrg, pin, projectRoo
456
581
  const { data } = state;
457
582
  const label = resolved && scopeLabel(resolved);
458
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
+ }
459
587
  if (effectiveJson) {
460
588
  return renderJson({ ...data, ...fields });
461
589
  }
462
590
  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 })] }));
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 })] }));
464
592
  }
465
593
  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 ?? [] })] }));
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 })] }));
467
595
  }
468
596
  if (data.outcome === 'already-installed') {
469
- 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, "."] }), _jsx(Text, { dimColor: true, children: "Use --force to reinstall." })] }));
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." })] }));
470
601
  }
471
602
  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, "."] }), _jsx(Text, { dimColor: true, children: "It will no longer be auto-removed when its parent is uninstalled." })] }));
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." })] }));
473
608
  }
474
609
  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 ?? [] })] }));
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 })] }));
476
611
  }
477
612
  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 ?? [] })] }));
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 })] }));
479
614
  }
480
615
  if (data.outcome === 'deprecated') {
481
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." })] }));
482
617
  }
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 ?? [] })] }));
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'));
484
637
  }
485
638
  /**
486
639
  * `atk install a b@1.2.0 @org/c my-bundle @org --all`: the named assets, the bundles' members and
@@ -591,7 +744,7 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
591
744
  user,
592
745
  });
593
746
  progress('Resolving dependencies...');
594
- const targetsPlan = planTargetsInstall(registry, targets, currentLockfile, tools, { force, projectDir });
747
+ const targetsPlan = planTargetsInstall(registry, targets, currentLockfile, tools, { force, pin, projectDir });
595
748
  const { assets: report, plan, toInstall } = targetsPlan;
596
749
  const bundles = targetsPlan.bundlesInPlace.map((request) => {
597
750
  const { bundle } = request;
@@ -599,6 +752,7 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
599
752
  name: bundle.name,
600
753
  ...(bundle.org ? { org: bundle.org } : {}),
601
754
  outcome: 'already-installed',
755
+ ...(request.pin ? { pin: request.pin } : {}),
602
756
  version: bundle.version,
603
757
  ...bundleReport(membersOutsideBundle(currentLockfile, bundleMembers(registry, bundle, tools), bundle), [], {
604
758
  adoptCommand: adoptCommandFor(request),
@@ -607,6 +761,13 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
607
761
  };
608
762
  });
609
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);
610
771
  // Each bundle in the plan, in the order named, then the ones left out; and the orgs.
611
772
  const targetsField = (lockfile, planned) => {
612
773
  const installedBundles = toInstall.flatMap((request) => {
@@ -639,17 +800,21 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
639
800
  ...targetsField(currentLockfile, true),
640
801
  outcome: 'dry-run-install',
641
802
  plan: withoutKeptDependencies(plan, currentLockfile, tools, {
803
+ named: { force },
642
804
  onProgress: progress,
805
+ pin,
643
806
  projectDir,
644
807
  scope: installScope,
645
808
  }),
646
809
  tools: toolNames,
647
810
  ...(await crossScope(plan)),
811
+ ...preferredScope(plan),
648
812
  };
649
813
  }
650
814
  return await withLockfileErrorHandling(projectDir, async () => {
651
815
  const toolResults = await installPlannedTargets(targetsPlan, tools, {
652
816
  force,
817
+ named: { force },
653
818
  onProgress: progress,
654
819
  onTool: (toolName) => progress(`Installing for ${toolName}...`),
655
820
  pin,
@@ -665,6 +830,7 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
665
830
  outcome: 'installed',
666
831
  toolResults,
667
832
  ...(await crossScope(plan, projectDir)),
833
+ ...preferredScope(plan),
668
834
  };
669
835
  });
670
836
  }, [adopt, all, cliOrg, dryRun, force, pin, specs.join(' '), tool]);
@@ -690,10 +856,10 @@ function InstallAssets({ adopt, all, dryRun, force, json, org: cliOrg, pin, proj
690
856
  return renderJson({ ...data, ...fields });
691
857
  }
692
858
  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 ?? [] })] }));
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 })] }));
694
860
  }
695
861
  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 ?? [] })] }));
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 })] }));
697
863
  }
698
864
  /** `atk install <spec>` with the run's own flags, for a command an error suggests. */
699
865
  function installCommandFor(spec, { adopt, dryRun, force, pin, projectRoot, tool, user }) {
@@ -799,14 +965,21 @@ function InstallOrg({ cliOrg, dryRun, force, json, orgName, pin, projectRoot, sk
799
965
  const refs = assetsToInstall.map((a) => ({ name: a.name, type: a.type }));
800
966
  const plan = resolveMultipleInstallPlans(ctx.registry, refs, ctx.activeOrg);
801
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);
802
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.
803
974
  const kept = withoutKeptDependencies(plan, ctx.lockfile, ctx.tools, {
975
+ pin,
804
976
  projectDir: ctx.projectDir,
805
977
  scope: ctx.scope,
806
978
  });
807
979
  const field = await crossScope(plan);
808
- if (!cancelled)
809
- 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
+ }
810
983
  return;
811
984
  }
812
985
  if (!cancelled)
@@ -827,7 +1000,7 @@ function InstallOrg({ cliOrg, dryRun, force, json, orgName, pin, projectRoot, sk
827
1000
  }));
828
1001
  const field = await crossScope(plan, ctx.projectDir);
829
1002
  if (!cancelled)
830
- setState({ phase: 'done', toolResults, ...field });
1003
+ setState({ phase: 'done', toolResults, ...field, ...preferredScope() });
831
1004
  }
832
1005
  catch (err) {
833
1006
  showError(err);
@@ -937,11 +1110,12 @@ function InstallOrg({ cliOrg, dryRun, force, json, orgName, pin, projectRoot, sk
937
1110
  org: orgName,
938
1111
  outcome: 'dry-run-org',
939
1112
  plan: state.plan,
1113
+ preferredScope: state.preferredScope,
940
1114
  tools: state.tools,
941
1115
  ...fields,
942
1116
  });
943
1117
  }
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 ?? [] })] }));
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 })] }));
945
1119
  }
946
1120
  if (state.phase === 'done') {
947
1121
  if (effectiveJson) {
@@ -949,11 +1123,12 @@ function InstallOrg({ cliOrg, dryRun, force, json, orgName, pin, projectRoot, sk
949
1123
  crossScope: state.crossScope,
950
1124
  org: orgName,
951
1125
  outcome: 'org-installed',
1126
+ preferredScope: state.preferredScope,
952
1127
  toolResults: state.toolResults,
953
1128
  ...fields,
954
1129
  });
955
1130
  }
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 ?? [] })] }));
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 })] }));
957
1132
  }
958
1133
  return null;
959
1134
  }
@@ -981,9 +1156,13 @@ function NamedAssetLines({ assets, dryRun = false, where, }) {
981
1156
  const inScope = where ? ` in ${where}` : '';
982
1157
  return (_jsx(_Fragment, { children: assets
983
1158
  .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}.`] }, identityKey(a)))) }));
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)))) }));
987
1166
  }
988
1167
  /**
989
1168
  * The error for a bundle name that only another scope has, when no asset can claim the name
@@ -1016,6 +1195,24 @@ function plannedOutsideBundle(plan, lockfile, members, bundle) {
1016
1195
  return [{ ...(origin ? { bundle: origin } : {}), ...member }];
1017
1196
  });
1018
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
+ }
1019
1216
  /**
1020
1217
  * The bundles and orgs a run of several names had among them: what it did with each bundle, the
1021
1218
  * bundle's members outside it, and how many assets each org brought.
@@ -1024,7 +1221,7 @@ function TargetLines({ bundles = [], dryRun = false, orgs = [], where, }) {
1024
1221
  const inScope = where ? ` in ${where}` : '';
1025
1222
  return (_jsxs(_Fragment, { children: [bundles.map((bundle) => {
1026
1223
  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));
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));
1028
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)))] }));
1029
1226
  }
1030
1227
  //# sourceMappingURL=install.js.map