@sanity/runtime-cli 17.9.0-blueprinit.g14aaebd → 17.10.0-next.g5e0bba6

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 (73) hide show
  1. package/README.md +19 -19
  2. package/dist/actions/blueprints/blueprint.js +1 -1
  3. package/dist/actions/blueprints/pre-deploy.js +7 -6
  4. package/dist/actions/blueprints/wait-for-operation.js +2 -1
  5. package/dist/cores/blueprints/config.js +18 -8
  6. package/dist/cores/blueprints/deploy.js +9 -8
  7. package/dist/cores/blueprints/destroy.js +7 -6
  8. package/dist/cores/blueprints/doctor.js +15 -2
  9. package/dist/cores/blueprints/init.d.ts +2 -0
  10. package/dist/cores/blueprints/init.js +56 -20
  11. package/dist/cores/blueprints/plan.js +11 -6
  12. package/dist/cores/blueprints/promote.js +3 -2
  13. package/dist/cores/functions/add.js +11 -7
  14. package/dist/cores/functions/logs.js +50 -6
  15. package/dist/cores/index.d.ts +5 -0
  16. package/dist/utils/blueprints/hints.js +8 -3
  17. package/dist/utils/display/prompt.d.ts +15 -2
  18. package/dist/utils/display/prompt.js +70 -8
  19. package/dist/utils/functions/child-runtime/durable.js +19 -2
  20. package/dist/utils/package-manager.d.ts +20 -0
  21. package/dist/utils/package-manager.js +63 -0
  22. package/dist/utils/types.d.ts +10 -1
  23. package/oclif.manifest.json +1 -152
  24. package/package.json +2 -2
  25. package/dist/actions/blueprinit/manifest.d.ts +0 -46
  26. package/dist/actions/blueprinit/manifest.js +0 -121
  27. package/dist/actions/blueprinit/quote.d.ts +0 -6
  28. package/dist/actions/blueprinit/quote.js +0 -8
  29. package/dist/actions/blueprinit/studio.d.ts +0 -6
  30. package/dist/actions/blueprinit/studio.js +0 -43
  31. package/dist/actions/blueprinit/templates.d.ts +0 -73
  32. package/dist/actions/blueprinit/templates.js +0 -138
  33. package/dist/actions/blueprinit/versions.d.ts +0 -8
  34. package/dist/actions/blueprinit/versions.js +0 -11
  35. package/dist/actions/blueprinit/workspace.d.ts +0 -27
  36. package/dist/actions/blueprinit/workspace.js +0 -145
  37. package/dist/actions/sanity/create-project.d.ts +0 -19
  38. package/dist/actions/sanity/create-project.js +0 -32
  39. package/dist/actions/sanity/datasets.d.ts +0 -15
  40. package/dist/actions/sanity/datasets.js +0 -26
  41. package/dist/commands/init.d.ts +0 -21
  42. package/dist/commands/init.js +0 -82
  43. package/dist/cores/blueprinit/adopt.d.ts +0 -6
  44. package/dist/cores/blueprinit/adopt.js +0 -137
  45. package/dist/cores/blueprinit/columns.d.ts +0 -26
  46. package/dist/cores/blueprinit/columns.js +0 -27
  47. package/dist/cores/blueprinit/finish.d.ts +0 -15
  48. package/dist/cores/blueprinit/finish.js +0 -72
  49. package/dist/cores/blueprinit/fresh.d.ts +0 -3
  50. package/dist/cores/blueprinit/fresh.js +0 -219
  51. package/dist/cores/blueprinit/naming.d.ts +0 -27
  52. package/dist/cores/blueprinit/naming.js +0 -43
  53. package/dist/cores/blueprinit/preview.d.ts +0 -34
  54. package/dist/cores/blueprinit/preview.js +0 -110
  55. package/dist/cores/blueprinit/project-choice.d.ts +0 -28
  56. package/dist/cores/blueprinit/project-choice.js +0 -82
  57. package/dist/cores/blueprinit/prompts.d.ts +0 -13
  58. package/dist/cores/blueprinit/prompts.js +0 -42
  59. package/dist/cores/blueprinit/results.d.ts +0 -8
  60. package/dist/cores/blueprinit/results.js +0 -4
  61. package/dist/cores/blueprinit/selection.d.ts +0 -15
  62. package/dist/cores/blueprinit/selection.js +0 -90
  63. package/dist/cores/blueprinit/stack-name.d.ts +0 -39
  64. package/dist/cores/blueprinit/stack-name.js +0 -56
  65. package/dist/cores/blueprinit/target.d.ts +0 -33
  66. package/dist/cores/blueprinit/target.js +0 -80
  67. package/dist/cores/blueprinit/types.d.ts +0 -20
  68. package/dist/cores/blueprinit/types.js +0 -1
  69. package/dist/cores/blueprinit.d.ts +0 -7
  70. package/dist/cores/blueprinit.js +0 -64
  71. package/dist/utils/display/intro.d.ts +0 -6
  72. package/dist/utils/display/intro.js +0 -63
  73. package/skills/init.md +0 -199
package/README.md CHANGED
@@ -90,7 +90,7 @@ EXAMPLES
90
90
  $ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
91
91
  ```
92
92
 
93
- _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.9.0-blueprinit.g14aaebd/src/commands/blueprints/add.ts)_
93
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.10.0-next.g5e0bba6/src/commands/blueprints/add.ts)_
94
94
 
95
95
  ## `sanity-run blueprints config`
96
96
 
@@ -127,7 +127,7 @@ EXAMPLES
127
127
  $ sanity-run blueprints config --edit --project-id <projectId> --stack <name-or-id>
128
128
  ```
129
129
 
130
- _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.9.0-blueprinit.g14aaebd/src/commands/blueprints/config.ts)_
130
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.10.0-next.g5e0bba6/src/commands/blueprints/config.ts)_
131
131
 
132
132
  ## `sanity-run blueprints deploy`
133
133
 
@@ -183,7 +183,7 @@ EXAMPLES
183
183
  $ sanity-run blueprints deploy --new-stack-name <new-name>
184
184
  ```
185
185
 
186
- _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.9.0-blueprinit.g14aaebd/src/commands/blueprints/deploy.ts)_
186
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.10.0-next.g5e0bba6/src/commands/blueprints/deploy.ts)_
187
187
 
188
188
  ## `sanity-run blueprints destroy`
189
189
 
@@ -221,7 +221,7 @@ EXAMPLES
221
221
  $ sanity-run blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-wait
222
222
  ```
223
223
 
224
- _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.9.0-blueprinit.g14aaebd/src/commands/blueprints/destroy.ts)_
224
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.10.0-next.g5e0bba6/src/commands/blueprints/destroy.ts)_
225
225
 
226
226
  ## `sanity-run blueprints doctor`
227
227
 
@@ -253,7 +253,7 @@ EXAMPLES
253
253
  $ sanity-run blueprints doctor --fix
254
254
  ```
255
255
 
256
- _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.9.0-blueprinit.g14aaebd/src/commands/blueprints/doctor.ts)_
256
+ _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.10.0-next.g5e0bba6/src/commands/blueprints/doctor.ts)_
257
257
 
258
258
  ## `sanity-run blueprints info`
259
259
 
@@ -291,7 +291,7 @@ EXAMPLES
291
291
  $ sanity-run blueprints info --organization-id <orgId> --stack <name-or-id>
292
292
  ```
293
293
 
294
- _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.9.0-blueprinit.g14aaebd/src/commands/blueprints/info.ts)_
294
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.10.0-next.g5e0bba6/src/commands/blueprints/info.ts)_
295
295
 
296
296
  ## `sanity-run blueprints init [DIR]`
297
297
 
@@ -355,7 +355,7 @@ EXAMPLES
355
355
  $ sanity-run blueprints init old-stack --type <json|js|ts> --project-id <projectId> --stack-id <existingStackId>
356
356
  ```
357
357
 
358
- _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.9.0-blueprinit.g14aaebd/src/commands/blueprints/init.ts)_
358
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.10.0-next.g5e0bba6/src/commands/blueprints/init.ts)_
359
359
 
360
360
  ## `sanity-run blueprints logs`
361
361
 
@@ -401,7 +401,7 @@ EXAMPLES
401
401
  $ sanity-run blueprints logs --before 2026-05-01T00:00:00Z
402
402
  ```
403
403
 
404
- _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.9.0-blueprinit.g14aaebd/src/commands/blueprints/logs.ts)_
404
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.10.0-next.g5e0bba6/src/commands/blueprints/logs.ts)_
405
405
 
406
406
  ## `sanity-run blueprints mint-deploy-token`
407
407
 
@@ -446,7 +446,7 @@ EXAMPLES
446
446
  $ sanity-run blueprints mint-deploy-token --organization-id <orgId>
447
447
  ```
448
448
 
449
- _See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v17.9.0-blueprinit.g14aaebd/src/commands/blueprints/mint-deploy-token.ts)_
449
+ _See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v17.10.0-next.g5e0bba6/src/commands/blueprints/mint-deploy-token.ts)_
450
450
 
451
451
  ## `sanity-run blueprints plan`
452
452
 
@@ -479,7 +479,7 @@ EXAMPLES
479
479
  $ sanity-run blueprints plan --organization-id <orgId> --stack <name-or-id>
480
480
  ```
481
481
 
482
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.9.0-blueprinit.g14aaebd/src/commands/blueprints/plan.ts)_
482
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.10.0-next.g5e0bba6/src/commands/blueprints/plan.ts)_
483
483
 
484
484
  ## `sanity-run blueprints promote`
485
485
 
@@ -515,7 +515,7 @@ EXAMPLES
515
515
  $ sanity-run blueprints promote --new-stack-name <new-name>
516
516
  ```
517
517
 
518
- _See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.9.0-blueprinit.g14aaebd/src/commands/blueprints/promote.ts)_
518
+ _See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.10.0-next.g5e0bba6/src/commands/blueprints/promote.ts)_
519
519
 
520
520
  ## `sanity-run blueprints stacks`
521
521
 
@@ -556,7 +556,7 @@ EXAMPLES
556
556
  $ sanity-run blueprints stacks --organization-id <organizationId> --include-projects
557
557
  ```
558
558
 
559
- _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.9.0-blueprinit.g14aaebd/src/commands/blueprints/stacks.ts)_
559
+ _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.10.0-next.g5e0bba6/src/commands/blueprints/stacks.ts)_
560
560
 
561
561
  ## `sanity-run functions add`
562
562
 
@@ -608,7 +608,7 @@ EXAMPLES
608
608
  $ sanity-run functions add --name my-function --type document-create --type document-update --lang js
609
609
  ```
610
610
 
611
- _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.9.0-blueprinit.g14aaebd/src/commands/functions/add.ts)_
611
+ _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.10.0-next.g5e0bba6/src/commands/functions/add.ts)_
612
612
 
613
613
  ## `sanity-run functions dev`
614
614
 
@@ -643,7 +643,7 @@ EXAMPLES
643
643
  $ sanity-run functions dev --timeout 60
644
644
  ```
645
645
 
646
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.9.0-blueprinit.g14aaebd/src/commands/functions/dev.ts)_
646
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.10.0-next.g5e0bba6/src/commands/functions/dev.ts)_
647
647
 
648
648
  ## `sanity-run functions env add NAME KEY VALUE`
649
649
 
@@ -676,7 +676,7 @@ EXAMPLES
676
676
  $ sanity-run functions env add --stack <name-or-id> MyFunction API_URL https://api.example.com/
677
677
  ```
678
678
 
679
- _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.9.0-blueprinit.g14aaebd/src/commands/functions/env/add.ts)_
679
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.10.0-next.g5e0bba6/src/commands/functions/env/add.ts)_
680
680
 
681
681
  ## `sanity-run functions env list NAME`
682
682
 
@@ -706,7 +706,7 @@ EXAMPLES
706
706
  $ sanity-run functions env list --stack <name-or-id> MyFunction
707
707
  ```
708
708
 
709
- _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.9.0-blueprinit.g14aaebd/src/commands/functions/env/list.ts)_
709
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.10.0-next.g5e0bba6/src/commands/functions/env/list.ts)_
710
710
 
711
711
  ## `sanity-run functions env remove NAME KEY`
712
712
 
@@ -738,7 +738,7 @@ EXAMPLES
738
738
  $ sanity-run functions env remove --stack <name-or-id> MyFunction API_URL
739
739
  ```
740
740
 
741
- _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.9.0-blueprinit.g14aaebd/src/commands/functions/env/remove.ts)_
741
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.10.0-next.g5e0bba6/src/commands/functions/env/remove.ts)_
742
742
 
743
743
  ## `sanity-run functions logs [NAME]`
744
744
 
@@ -778,7 +778,7 @@ EXAMPLES
778
778
  $ sanity-run functions logs <name> --delete
779
779
  ```
780
780
 
781
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.9.0-blueprinit.g14aaebd/src/commands/functions/logs.ts)_
781
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.10.0-next.g5e0bba6/src/commands/functions/logs.ts)_
782
782
 
783
783
  ## `sanity-run functions test [NAME]`
784
784
 
@@ -836,7 +836,7 @@ EXAMPLES
836
836
  $ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
837
837
  ```
838
838
 
839
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.9.0-blueprinit.g14aaebd/src/commands/functions/test.ts)_
839
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.10.0-next.g5e0bba6/src/commands/functions/test.ts)_
840
840
 
841
841
  ## `sanity-run help [COMMAND]`
842
842
 
@@ -24,7 +24,7 @@ import {defineBlueprint, defineDocumentFunction} from '@sanity/blueprints'
24
24
 
25
25
  export default defineBlueprint({
26
26
  resources: [
27
- // defineDocumentFunction({name: 'my-function'}),
27
+ // defineDocumentFunction({name: 'my-function', event: {on: ['create', 'update']}}),
28
28
  ],
29
29
  })
30
30
  `.trim();
@@ -1,5 +1,6 @@
1
1
  import { resolveDeployedResources } from '../../utils/blueprints/resolve-deployed-resources.js';
2
2
  import { CODE_OPERATION_UNCONFIRMED, EXIT_OPERATION_UNCONFIRMED } from '../../utils/exit-codes.js';
3
+ import { runCommand } from '../../utils/package-manager.js';
3
4
  import { styleText } from '../../utils/style-text.js';
4
5
  import { isAssetResource, } from '../../utils/types.js';
5
6
  import { processAssets } from './process-assets.js';
@@ -67,8 +68,8 @@ async function preDeployStack(options) {
67
68
  success: false,
68
69
  error: deployError || 'Failed to complete Stack pre-deployment',
69
70
  suggestions: [
70
- `Run \`npx ${bin} blueprints plan\` to preview changes before deploying.`,
71
- `Run \`npx ${bin} blueprints doctor\` to check your configuration.`,
71
+ `Run \`${runCommand(bin)} blueprints plan\` to preview changes before deploying.`,
72
+ `Run \`${runCommand(bin)} blueprints doctor\` to check your configuration.`,
72
73
  ],
73
74
  };
74
75
  }
@@ -97,8 +98,8 @@ async function preDeployStack(options) {
97
98
  exitCode: EXIT_OPERATION_UNCONFIRMED,
98
99
  suggestions: [
99
100
  'The pre-deployment may or may not have finished on Sanity servers.',
100
- `Run \`npx ${bin} blueprints info\` to check status.`,
101
- `Run \`npx ${bin} blueprints logs --watch\` to keep streaming logs.`,
101
+ `Run \`${runCommand(bin)} blueprints info\` to check status.`,
102
+ `Run \`${runCommand(bin)} blueprints logs --watch\` to keep streaming logs.`,
102
103
  ],
103
104
  };
104
105
  }
@@ -109,8 +110,8 @@ async function preDeployStack(options) {
109
110
  suggestions: [
110
111
  ...outcome.logHints,
111
112
  'Review the pre-deployment output above for error details.',
112
- `Run \`npx ${bin} blueprints logs --verbose\` for more context.`,
113
- `Run \`npx ${bin} blueprints plan\` to identify issues with your Blueprint.`,
113
+ `Run \`${runCommand(bin)} blueprints logs --verbose\` for more context.`,
114
+ `Run \`${runCommand(bin)} blueprints plan\` to identify issues with your Blueprint.`,
114
115
  ],
115
116
  };
116
117
  }
@@ -1,5 +1,6 @@
1
1
  import { setTimeout as sleep } from 'node:timers/promises';
2
2
  import { createHintCollector } from '../../utils/blueprints/hints.js';
3
+ import { runCommand } from '../../utils/package-manager.js';
3
4
  import { setupLogPolling } from './logs-polling.js';
4
5
  import { classifyOperationPoll, getOperation, OPERATION_POLL_INITIAL_DELAY_MS, OPERATION_POLL_INTERVAL_MS, OPERATION_POLL_MAX_CONSECUTIVE_ERRORS, } from './operations.js';
5
6
  const IDLE_SPINNER_DELAY_MS = 30_000;
@@ -95,7 +96,7 @@ export async function waitForOperation(options) {
95
96
  Math.floor((idleFor - IDLE_SPINNER_DELAY_MS) / IDLE_SPINNER_UPDATE_INTERVAL_MS) *
96
97
  IDLE_SPINNER_UPDATE_INTERVAL_MS;
97
98
  const elapsedIdleSeconds = elapsedIdleMs / 1000;
98
- const text = `No new activity for ${elapsedIdleSeconds} seconds. The ${progressNoun} is still running on Sanity servers. You can safely exit and check status later with \`npx ${bin} blueprints info\`.`;
99
+ const text = `No new activity for ${elapsedIdleSeconds} seconds. The ${progressNoun} is still running on Sanity servers. You can safely exit and check status later with \`${runCommand(bin)} blueprints info\`.`;
99
100
  if (idleSpinner)
100
101
  idleSpinner.start(text);
101
102
  else
@@ -2,7 +2,8 @@ import { patchConfigFile, writeConfigFile, } from '../../actions/blueprints/conf
2
2
  import { resolveStackIdByNameOrId } from '../../actions/blueprints/stacks.js';
3
3
  import { formatDateTime } from '../../utils/display/dates.js';
4
4
  import { filePathRelativeToCwd, labeledId, warn } from '../../utils/display/presenters.js';
5
- import { runScopeAndStackWizard } from '../../utils/display/prompt.js';
5
+ import { CancelledError, runScopeAndStackWizard } from '../../utils/display/prompt.js';
6
+ import { runCommand } from '../../utils/package-manager.js';
6
7
  import { styleText } from '../../utils/style-text.js';
7
8
  export async function blueprintConfigCore(options) {
8
9
  const { bin = 'sanity', blueprint, log, token, flags } = options;
@@ -19,7 +20,7 @@ export async function blueprintConfigCore(options) {
19
20
  log('No Blueprint config found at .sanity/blueprint.config.json.');
20
21
  }
21
22
  if (!editConfig) {
22
- log(`Run \`npx ${bin} blueprints doctor\` for diagnostics.`);
23
+ log(`Run \`${runCommand(bin)} blueprints doctor\` for diagnostics.`);
23
24
  return { success: true }; // not necessarily fatal
24
25
  }
25
26
  }
@@ -82,12 +83,21 @@ export async function blueprintConfigCore(options) {
82
83
  log('');
83
84
  const knownOrganizationId = configScopeType === 'organization' ? configScopeId : undefined;
84
85
  const knownProjectId = configScopeType === 'project' ? configScopeId : undefined;
85
- const wizardResult = await runScopeAndStackWizard({
86
- token,
87
- knownOrganizationId,
88
- knownProjectId,
89
- logger: log,
90
- });
86
+ let wizardResult;
87
+ try {
88
+ wizardResult = await runScopeAndStackWizard({
89
+ token,
90
+ knownOrganizationId,
91
+ knownProjectId,
92
+ logger: log,
93
+ });
94
+ }
95
+ catch (error) {
96
+ if (error instanceof CancelledError) {
97
+ return { success: false, error: 'Configuration cancelled.', cancelled: true };
98
+ }
99
+ throw error;
100
+ }
91
101
  if (!wizardResult.scopeId)
92
102
  return { success: false, error: 'Scope selection is required.' };
93
103
  try {
@@ -7,6 +7,7 @@ import { extractDurableConfig } from '../../utils/blueprints/extract-durable-con
7
7
  import { createHintCollector } from '../../utils/blueprints/hints.js';
8
8
  import { check, niceId, severe } from '../../utils/display/presenters.js';
9
9
  import { CODE_OPERATION_UNCONFIRMED, EXIT_OPERATION_UNCONFIRMED } from '../../utils/exit-codes.js';
10
+ import { runCommand } from '../../utils/package-manager.js';
10
11
  import { styleText } from '../../utils/style-text.js';
11
12
  import { getWarnings } from '../../utils/warnings.js';
12
13
  export async function blueprintDeployCore(options) {
@@ -29,7 +30,7 @@ export async function blueprintDeployCore(options) {
29
30
  success: false,
30
31
  error: 'A Stack operation is already in progress.',
31
32
  suggestions: [
32
- `Run \`npx ${bin} blueprints info\` to check operation status.`,
33
+ `Run \`${runCommand(bin)} blueprints info\` to check operation status.`,
33
34
  'Wait for the current operation to complete, then try again.',
34
35
  ],
35
36
  };
@@ -76,8 +77,8 @@ export async function blueprintDeployCore(options) {
76
77
  error: deployError || 'Failed to update Stack deployment',
77
78
  suggestions: [
78
79
  ...hints.getSuggestions(),
79
- `Run \`npx ${bin} blueprints plan\` to preview changes before deploying.`,
80
- `Run \`npx ${bin} blueprints doctor\` to check your configuration.`,
80
+ `Run \`${runCommand(bin)} blueprints plan\` to preview changes before deploying.`,
81
+ `Run \`${runCommand(bin)} blueprints doctor\` to check your configuration.`,
81
82
  ],
82
83
  };
83
84
  }
@@ -92,7 +93,7 @@ export async function blueprintDeployCore(options) {
92
93
  : Promise.resolve(null);
93
94
  if (noWait) {
94
95
  logger(styleText(['bold', 'green'], 'Stack deployment started!'));
95
- logger(`Use \`npx ${bin} blueprints info\` to check status`);
96
+ logger(`Use \`${runCommand(bin)} blueprints info\` to check status`);
96
97
  const legacyWarning = await legacyPermissionsNoticePromise;
97
98
  const warnings = [...(legacyWarning ? [legacyWarning] : []), ...workspaceWarnings];
98
99
  return {
@@ -132,8 +133,8 @@ export async function blueprintDeployCore(options) {
132
133
  exitCode: EXIT_OPERATION_UNCONFIRMED,
133
134
  suggestions: [
134
135
  'The deployment may or may not have finished on Sanity servers.',
135
- `Run \`npx ${bin} blueprints info\` to check status.`,
136
- `Run \`npx ${bin} blueprints logs --watch\` to keep streaming logs.`,
136
+ `Run \`${runCommand(bin)} blueprints info\` to check status.`,
137
+ `Run \`${runCommand(bin)} blueprints logs --watch\` to keep streaming logs.`,
137
138
  ],
138
139
  };
139
140
  }
@@ -143,8 +144,8 @@ export async function blueprintDeployCore(options) {
143
144
  suggestions: [
144
145
  ...outcome.logHints,
145
146
  'Review the deployment output above for error details.',
146
- `Run \`npx ${bin} blueprints logs --verbose\` for more context.`,
147
- `Run \`npx ${bin} blueprints plan\` to identify issues with your Blueprint.`,
147
+ `Run \`${runCommand(bin)} blueprints logs --verbose\` for more context.`,
148
+ `Run \`${runCommand(bin)} blueprints plan\` to identify issues with your Blueprint.`,
148
149
  ],
149
150
  };
150
151
  }
@@ -5,6 +5,7 @@ import { destroyStack, getStack, resolveStackIdByNameOrId } from '../../actions/
5
5
  import { waitForOperation } from '../../actions/blueprints/wait-for-operation.js';
6
6
  import { niceId } from '../../utils/display/presenters.js';
7
7
  import { CODE_OPERATION_UNCONFIRMED, EXIT_OPERATION_UNCONFIRMED } from '../../utils/exit-codes.js';
8
+ import { runCommand } from '../../utils/package-manager.js';
8
9
  import { styleText } from '../../utils/style-text.js';
9
10
  export async function blueprintDestroyCore(options) {
10
11
  const { bin = 'sanity', log, token, scopeType, scopeId, localStackId, blueprintConfig, flags, } = options;
@@ -64,8 +65,8 @@ export async function blueprintDestroyCore(options) {
64
65
  success: false,
65
66
  error: 'Stack deployment not found',
66
67
  suggestions: [
67
- `Run \`npx ${bin} blueprints stacks\` to list available Stacks.`,
68
- `Run \`npx ${bin} blueprints doctor\` to check your configuration.`,
68
+ `Run \`${runCommand(bin)} blueprints stacks\` to list available Stacks.`,
69
+ `Run \`${runCommand(bin)} blueprints doctor\` to check your configuration.`,
69
70
  ],
70
71
  };
71
72
  }
@@ -164,8 +165,8 @@ async function waitForDestruction(options) {
164
165
  exitCode: EXIT_OPERATION_UNCONFIRMED,
165
166
  suggestions: [
166
167
  'The destruction may or may not have finished on Sanity servers.',
167
- `Run \`npx ${bin} blueprints info\` to view current Stack status.`,
168
- `Run \`npx ${bin} blueprints logs --watch\` to keep streaming logs.`,
168
+ `Run \`${runCommand(bin)} blueprints info\` to view current Stack status.`,
169
+ `Run \`${runCommand(bin)} blueprints logs --watch\` to keep streaming logs.`,
169
170
  ],
170
171
  };
171
172
  }
@@ -175,8 +176,8 @@ async function waitForDestruction(options) {
175
176
  suggestions: [
176
177
  ...outcome.logHints,
177
178
  'Review the destruction output above for error details.',
178
- `Run \`npx ${bin} blueprints logs --verbose\` for more context.`,
179
- `Run \`npx ${bin} blueprints info\` to view current Stack status.`,
179
+ `Run \`${runCommand(bin)} blueprints logs --verbose\` for more context.`,
180
+ `Run \`${runCommand(bin)} blueprints info\` to view current Stack status.`,
180
181
  ],
181
182
  };
182
183
  }
@@ -10,6 +10,7 @@ import config, { RUNTIME_CLI_VERSION } from '../../config.js';
10
10
  import { formatDateTime } from '../../utils/display/dates.js';
11
11
  import { presentBlueprintParserErrors } from '../../utils/display/errors.js';
12
12
  import { advise, check, filePathRelativeToCwd, niceId, renderSection, severe, unsure, } from '../../utils/display/presenters.js';
13
+ import { runCommand } from '../../utils/package-manager.js';
13
14
  import { styleText } from '../../utils/style-text.js';
14
15
  import { createTracedFetch } from '../../utils/traced-fetch.js';
15
16
  import { validTokenOrErrorMessage } from '../../utils/validated-token.js';
@@ -374,7 +375,9 @@ export async function blueprintDoctorCore(options) {
374
375
  return {
375
376
  success: false,
376
377
  error: `${errorMessage}. Unable to fix: Blueprint manifest is missing or invalid`,
377
- suggestions: [`Run \`npx ${bin} blueprints init\` to create a new Blueprint manifest.`],
378
+ suggestions: [
379
+ `Run \`${runCommand(bin)} blueprints init\` to create a new Blueprint manifest.`,
380
+ ],
378
381
  data: { diagnostics: flatDiagnostics },
379
382
  };
380
383
  }
@@ -389,12 +392,22 @@ export async function blueprintDoctorCore(options) {
389
392
  if (fixResult.success) {
390
393
  return { ...fixResult, warnings: hasWarnings ? warnings : undefined };
391
394
  }
395
+ if (fixResult.cancelled) {
396
+ return {
397
+ success: false,
398
+ error: `${errorMessage}. Unable to fix: ${fixResult.error}`,
399
+ cancelled: true,
400
+ data: { diagnostics: flatDiagnostics },
401
+ };
402
+ }
392
403
  return fixResult;
393
404
  }
394
405
  return {
395
406
  success: false,
396
407
  error: errorMessage,
397
- suggestions: [`Run \`npx ${bin} blueprints doctor --fix\` to fix configuration issues.`],
408
+ suggestions: [
409
+ `Run \`${runCommand(bin)} blueprints doctor --fix\` to fix configuration issues.`,
410
+ ],
398
411
  data: { diagnostics: flatDiagnostics },
399
412
  };
400
413
  }
@@ -36,6 +36,8 @@ export declare function resolveScopeAndStack(params: {
36
36
  stackId: string | undefined;
37
37
  stackName: string | undefined;
38
38
  knownProjectId?: string;
39
+ /** Where the Blueprint lands; its folder name seeds the new Stack name. */
40
+ blueprintDir?: string;
39
41
  log: Logger;
40
42
  token: string;
41
43
  }): Promise<ResolvedScope>;
@@ -1,5 +1,5 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
- import { join } from 'node:path';
2
+ import { basename, dirname, join, resolve } from 'node:path';
3
3
  import { cwd } from 'node:process';
4
4
  import { confirm } from '@inquirer/prompts';
5
5
  import { findBlueprintFile, readLocalBlueprint, writeBlueprintToDisk, } from '../../actions/blueprints/blueprint.js';
@@ -11,8 +11,9 @@ import { verifyExampleExists, writeExample } from '../../actions/sanity/examples
11
11
  import { getProject } from '../../actions/sanity/projects.js';
12
12
  import { BLUEPRINT_CONFIG_DIR, BLUEPRINT_CONFIG_FILE } from '../../config.js';
13
13
  import { check, filePathRelativeToCwd, labeledId, warn } from '../../utils/display/presenters.js';
14
- import { promptForBlueprintType, promptForOrganization, promptForProjectInOrg, promptForStack, runScopeAndStackWizard, } from '../../utils/display/prompt.js';
14
+ import { CancelledError, promptForBlueprintType, promptForInitLocation, promptForOrganization, promptForProjectInOrg, promptForStack, runScopeAndStackWizard, } from '../../utils/display/prompt.js';
15
15
  import { isInteractive } from '../../utils/interactive.js';
16
+ import { installCommand, runCommand } from '../../utils/package-manager.js';
16
17
  import { styleText } from '../../utils/style-text.js';
17
18
  import { blueprintConfigCore } from './config.js';
18
19
  /** Derive scope type and ID from mutually exclusive flag values. */
@@ -29,8 +30,8 @@ export async function blueprintInitCore(options) {
29
30
  const { dir: argDir } = args;
30
31
  const explicitDir = argDir || flagDir;
31
32
  const isHere = !explicitDir || explicitDir === '.' || explicitDir === './';
32
- const blueprintDir = isHere ? '.' : explicitDir;
33
- const userProvidedDirName = isHere ? undefined : explicitDir;
33
+ let blueprintDir = isHere ? '.' : explicitDir;
34
+ let userProvidedDirName = isHere ? undefined : explicitDir;
34
35
  const validationError = validateFlags({
35
36
  stackId: flagStackId,
36
37
  stackName: flagStackName,
@@ -43,7 +44,7 @@ export async function blueprintInitCore(options) {
43
44
  const existingBlueprintFile = findBlueprintFile(blueprintDir);
44
45
  // existing blueprint file on disk → configure it for deployment
45
46
  if (existingBlueprintFile) {
46
- return handleExistingBlueprint({
47
+ const result = await handleExistingBlueprint({
47
48
  existingBlueprintFile,
48
49
  bin,
49
50
  log,
@@ -56,6 +57,11 @@ export async function blueprintInitCore(options) {
56
57
  flagStackName,
57
58
  verbose,
58
59
  });
60
+ // the config core owns the wizard, but the user ran `init`
61
+ if (!result.success && result.cancelled) {
62
+ return { success: false, error: 'Initialization cancelled.', cancelled: true };
63
+ }
64
+ return result;
59
65
  }
60
66
  // --example flag → scaffold from an example template
61
67
  if (flagExample) {
@@ -70,13 +76,21 @@ export async function blueprintInitCore(options) {
70
76
  }
71
77
  // no blueprint on disk → create new blueprint files from scratch
72
78
  if (!explicitDir && isInteractive) {
73
- const proceed = await confirm({
74
- message: `Initialize a Blueprint here in ${cwd()}?`,
75
- default: true,
76
- });
77
- if (!proceed) {
78
- log(`Run \`${bin} blueprints init <directory>\` to initialize in a different location.`);
79
- return { success: false, error: 'Initialization cancelled.' };
79
+ const chosenDir = await promptForInitLocation(cwd());
80
+ if (chosenDir) {
81
+ blueprintDir = chosenDir;
82
+ userProvidedDirName = chosenDir;
83
+ // findBlueprintFile walks up, so only refuse on a manifest in the folder itself
84
+ const existing = findBlueprintFile(chosenDir);
85
+ if (existing && dirname(resolve(existing.blueprintFilePath)) === resolve(chosenDir)) {
86
+ return {
87
+ success: false,
88
+ error: `A Blueprint already exists in "${chosenDir}".`,
89
+ suggestions: [
90
+ `Run \`${runCommand(bin)} blueprints init ${chosenDir}\` to configure it for deployment.`,
91
+ ],
92
+ };
93
+ }
80
94
  }
81
95
  }
82
96
  return handleFreshInitialization({
@@ -94,6 +108,9 @@ export async function blueprintInitCore(options) {
94
108
  });
95
109
  }
96
110
  catch (error) {
111
+ if (error instanceof CancelledError) {
112
+ return { success: false, error: 'Initialization cancelled.', cancelled: true };
113
+ }
97
114
  const errorMessage = error instanceof Error ? error.message : String(error);
98
115
  return { success: false, error: errorMessage };
99
116
  }
@@ -156,6 +173,7 @@ async function handleFreshInitialization(options) {
156
173
  stackId: flagStackId,
157
174
  stackName: flagStackName,
158
175
  knownProjectId,
176
+ blueprintDir,
159
177
  log,
160
178
  token,
161
179
  });
@@ -241,7 +259,7 @@ async function handleExampleInitialization(options) {
241
259
  const { blueprintFilePath } = discoveredBlueprint;
242
260
  writeConfigFile(blueprintFilePath, { projectId: resolvedProjectId, stackId: stack.id });
243
261
  log(check(`${styleText('bold', 'Configured:')} ${exampleDir}/${BLUEPRINT_CONFIG_DIR}/${BLUEPRINT_CONFIG_FILE}`));
244
- log(`\n Run "${styleText(['bold', 'magenta'], `cd ${exampleDir} && npm i`)}" and check out the README`);
262
+ log(`\n Run "${styleText(['bold', 'magenta'], `cd ${exampleDir} && ${installCommand(exampleDir)}`)}" and check out the README`);
245
263
  if (instructions) {
246
264
  log('');
247
265
  log(instructions);
@@ -251,6 +269,7 @@ async function handleExampleInitialization(options) {
251
269
  export async function resolveScopeAndStack(params) {
252
270
  const { projectId, organizationId, stackId, stackName, knownProjectId, log, token } = params;
253
271
  const flagScope = resolveScopeFromFlags(projectId, organizationId);
272
+ const suggestedName = params.blueprintDir ? basename(resolve(params.blueprintDir)) : undefined;
254
273
  // --- Branch 1: Scope provided via flags ---
255
274
  if (flagScope) {
256
275
  const { scopeType, scopeId } = flagScope;
@@ -283,7 +302,13 @@ export async function resolveScopeAndStack(params) {
283
302
  // No stack flag: prompt for stack selection
284
303
  if (!resolvedStackId) {
285
304
  log('\nBlueprints are deployed to a "Stack".');
286
- const stackResult = await promptForStack({ scopeType, scopeId, token, logger: log });
305
+ const stackResult = await promptForStack({
306
+ scopeType,
307
+ scopeId,
308
+ token,
309
+ logger: log,
310
+ suggestedName,
311
+ });
287
312
  if (typeof stackResult === 'symbol')
288
313
  throw new Error('Unexpected back navigation');
289
314
  resolvedStackId = stackResult.stackId;
@@ -315,6 +340,7 @@ export async function resolveScopeAndStack(params) {
315
340
  scopeId: knownProjectId,
316
341
  token,
317
342
  logger: log,
343
+ suggestedName,
318
344
  });
319
345
  if (typeof stackResult === 'symbol')
320
346
  throw new Error('Unexpected back navigation');
@@ -323,7 +349,11 @@ export async function resolveScopeAndStack(params) {
323
349
  }
324
350
  }
325
351
  // Full wizard: org -> scope -> project (if needed) -> stack
326
- const wizard = await runScopeAndStackWizard({ token, logger: log });
352
+ const wizard = await runScopeAndStackWizard({
353
+ token,
354
+ logger: log,
355
+ suggestedStackName: suggestedName,
356
+ });
327
357
  return { scopeType: wizard.scopeType, scopeId: wizard.scopeId, stackId: wizard.stackId };
328
358
  }
329
359
  export async function determineBlueprintExtension(params) {
@@ -386,12 +416,18 @@ export async function createBlueprintFiles(params) {
386
416
  log.warn(warn(`Unable to add ${blueprintsPackage} to your project.`));
387
417
  }
388
418
  }
389
- const nextStepParts = [];
419
+ const runLine = (command, purpose) => ` Run "${styleText(['bold', 'magenta'], command)}" ${purpose}`;
420
+ // project setup, only when there is something to do
421
+ const setupParts = [];
390
422
  if (userProvidedDirName)
391
- nextStepParts.push(`cd ${userProvidedDirName}`);
423
+ setupParts.push(`cd ${userProvidedDirName}`);
392
424
  if (blueprintExtension !== 'json')
393
- nextStepParts.push('npm install');
394
- nextStepParts.push(`npx ${bin} blueprints --help`);
395
- log(`\n Run "${styleText(['bold', 'magenta'], nextStepParts.join(' && '))}" to get started`);
425
+ setupParts.push(installCommand(blueprintDir));
426
+ log('');
427
+ if (setupParts.length > 0)
428
+ log(runLine(setupParts.join(' && '), 'first'));
429
+ // the manifest starts empty, so name the command that fills it
430
+ log(runLine(`${runCommand(bin)} functions add`, 'to add a Function'));
431
+ log(runLine(`${runCommand(bin)} blueprints --help`, 'to see every command'));
396
432
  return { success: true };
397
433
  }