@sanity/cli 6.1.8 → 6.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +301 -294
- package/dist/actions/debug/gatherDebugInfo.js +130 -81
- package/dist/actions/debug/gatherDebugInfo.js.map +1 -1
- package/dist/actions/debug/output.js +25 -0
- package/dist/actions/debug/output.js.map +1 -0
- package/dist/actions/debug/types.js.map +1 -1
- package/dist/actions/manifest/__tests__/testHelpers.js +21 -0
- package/dist/actions/manifest/__tests__/testHelpers.js.map +1 -0
- package/dist/actions/manifest/schemaTypeTransformer.js +2 -1
- package/dist/actions/manifest/schemaTypeTransformer.js.map +1 -1
- package/dist/actions/mcp/setupMCP.js +5 -5
- package/dist/actions/mcp/setupMCP.js.map +1 -1
- package/dist/actions/schema/getExtractOptions.js.map +1 -1
- package/dist/commands/{backup → backups}/disable.js +3 -0
- package/dist/commands/backups/disable.js.map +1 -0
- package/dist/commands/{backup → backups}/download.js +3 -0
- package/dist/commands/backups/download.js.map +1 -0
- package/dist/commands/{backup → backups}/enable.js +3 -0
- package/dist/commands/backups/enable.js.map +1 -0
- package/dist/commands/{backup → backups}/list.js +3 -0
- package/dist/commands/backups/list.js.map +1 -0
- package/dist/commands/{dataset → datasets}/alias/create.js +3 -0
- package/dist/commands/datasets/alias/create.js.map +1 -0
- package/dist/commands/{dataset → datasets}/alias/delete.js +3 -0
- package/dist/commands/datasets/alias/delete.js.map +1 -0
- package/dist/commands/{dataset → datasets}/alias/link.js +3 -0
- package/dist/commands/datasets/alias/link.js.map +1 -0
- package/dist/commands/{dataset → datasets}/alias/unlink.js +3 -0
- package/dist/commands/datasets/alias/unlink.js.map +1 -0
- package/dist/commands/{dataset → datasets}/copy.js +3 -0
- package/dist/commands/datasets/copy.js.map +1 -0
- package/dist/commands/{dataset → datasets}/create.js +3 -0
- package/dist/commands/datasets/create.js.map +1 -0
- package/dist/commands/{dataset → datasets}/delete.js +3 -0
- package/dist/commands/datasets/delete.js.map +1 -0
- package/dist/commands/{dataset → datasets}/embeddings/disable.js +3 -0
- package/dist/commands/datasets/embeddings/disable.js.map +1 -0
- package/dist/commands/{dataset → datasets}/embeddings/enable.js +3 -0
- package/dist/commands/datasets/embeddings/enable.js.map +1 -0
- package/dist/commands/{dataset → datasets}/embeddings/status.js +3 -0
- package/dist/commands/datasets/embeddings/status.js.map +1 -0
- package/dist/commands/{dataset → datasets}/export.js +3 -0
- package/dist/commands/datasets/export.js.map +1 -0
- package/dist/commands/{dataset → datasets}/import.js +14 -10
- package/dist/commands/datasets/import.js.map +1 -0
- package/dist/commands/{dataset → datasets}/list.js +3 -0
- package/dist/commands/datasets/list.js.map +1 -0
- package/dist/commands/{dataset → datasets}/visibility/get.js +3 -0
- package/dist/commands/datasets/visibility/get.js.map +1 -0
- package/dist/commands/{dataset → datasets}/visibility/set.js +3 -0
- package/dist/commands/datasets/visibility/set.js.map +1 -0
- package/dist/commands/debug.js +189 -74
- package/dist/commands/debug.js.map +1 -1
- package/dist/commands/documents/create.js +3 -0
- package/dist/commands/documents/create.js.map +1 -1
- package/dist/commands/documents/delete.js +3 -0
- package/dist/commands/documents/delete.js.map +1 -1
- package/dist/commands/documents/get.js +3 -0
- package/dist/commands/documents/get.js.map +1 -1
- package/dist/commands/documents/query.js +3 -0
- package/dist/commands/documents/query.js.map +1 -1
- package/dist/commands/documents/validate.js +3 -0
- package/dist/commands/documents/validate.js.map +1 -1
- package/dist/commands/{hook → hooks}/attempt.js +3 -0
- package/dist/commands/hooks/attempt.js.map +1 -0
- package/dist/commands/{hook → hooks}/create.js +3 -0
- package/dist/commands/hooks/create.js.map +1 -0
- package/dist/commands/{hook → hooks}/delete.js +3 -0
- package/dist/commands/hooks/delete.js.map +1 -0
- package/dist/commands/{hook → hooks}/list.js +3 -0
- package/dist/commands/hooks/list.js.map +1 -0
- package/dist/commands/{hook → hooks}/logs.js +3 -0
- package/dist/commands/hooks/logs.js.map +1 -0
- package/dist/commands/init.js +65 -13
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/mcp/configure.js +3 -2
- package/dist/commands/mcp/configure.js.map +1 -1
- package/dist/commands/preview.js +1 -0
- package/dist/commands/preview.js.map +1 -1
- package/dist/commands/projects/create.js +3 -0
- package/dist/commands/projects/create.js.map +1 -1
- package/dist/commands/projects/list.js +3 -0
- package/dist/commands/projects/list.js.map +1 -1
- package/dist/commands/{schema → schemas}/delete.js +3 -0
- package/dist/commands/schemas/delete.js.map +1 -0
- package/dist/commands/{schema → schemas}/deploy.js +3 -0
- package/dist/commands/schemas/deploy.js.map +1 -0
- package/dist/commands/{schema → schemas}/extract.js +3 -0
- package/dist/commands/schemas/extract.js.map +1 -0
- package/dist/commands/{schema → schemas}/list.js +3 -0
- package/dist/commands/schemas/list.js.map +1 -0
- package/dist/commands/{schema → schemas}/validate.js +3 -0
- package/dist/commands/schemas/validate.js.map +1 -0
- package/dist/commands/tokens/add.js +3 -0
- package/dist/commands/tokens/add.js.map +1 -1
- package/dist/commands/tokens/delete.js +3 -0
- package/dist/commands/tokens/delete.js.map +1 -1
- package/dist/commands/tokens/list.js +3 -0
- package/dist/commands/tokens/list.js.map +1 -1
- package/dist/commands/users/invite.js +3 -0
- package/dist/commands/users/invite.js.map +1 -1
- package/dist/commands/users/list.js +3 -0
- package/dist/commands/users/list.js.map +1 -1
- package/dist/hooks/commandNotFound/topicAliases.js +71 -0
- package/dist/hooks/commandNotFound/topicAliases.js.map +1 -0
- package/dist/services/telemetry.js +23 -2
- package/dist/services/telemetry.js.map +1 -1
- package/dist/topicAliases.js +51 -0
- package/dist/topicAliases.js.map +1 -0
- package/dist/util/packageManager/packageManagerChoice.js +1 -2
- package/dist/util/packageManager/packageManagerChoice.js.map +1 -1
- package/oclif.config.js +20 -7
- package/oclif.manifest.json +478 -362
- package/package.json +17 -16
- package/dist/actions/debug/formatters.js +0 -22
- package/dist/actions/debug/formatters.js.map +0 -1
- package/dist/actions/debug/getGlobalConfigLocation.js +0 -7
- package/dist/actions/debug/getGlobalConfigLocation.js.map +0 -1
- package/dist/commands/backup/disable.js.map +0 -1
- package/dist/commands/backup/download.js.map +0 -1
- package/dist/commands/backup/enable.js.map +0 -1
- package/dist/commands/backup/list.js.map +0 -1
- package/dist/commands/dataset/alias/create.js.map +0 -1
- package/dist/commands/dataset/alias/delete.js.map +0 -1
- package/dist/commands/dataset/alias/link.js.map +0 -1
- package/dist/commands/dataset/alias/unlink.js.map +0 -1
- package/dist/commands/dataset/copy.js.map +0 -1
- package/dist/commands/dataset/create.js.map +0 -1
- package/dist/commands/dataset/delete.js.map +0 -1
- package/dist/commands/dataset/embeddings/disable.js.map +0 -1
- package/dist/commands/dataset/embeddings/enable.js.map +0 -1
- package/dist/commands/dataset/embeddings/status.js.map +0 -1
- package/dist/commands/dataset/export.js.map +0 -1
- package/dist/commands/dataset/import.js.map +0 -1
- package/dist/commands/dataset/list.js.map +0 -1
- package/dist/commands/dataset/visibility/get.js.map +0 -1
- package/dist/commands/dataset/visibility/set.js.map +0 -1
- package/dist/commands/hook/attempt.js.map +0 -1
- package/dist/commands/hook/create.js.map +0 -1
- package/dist/commands/hook/delete.js.map +0 -1
- package/dist/commands/hook/list.js.map +0 -1
- package/dist/commands/hook/logs.js.map +0 -1
- package/dist/commands/schema/delete.js.map +0 -1
- package/dist/commands/schema/deploy.js.map +0 -1
- package/dist/commands/schema/extract.js.map +0 -1
- package/dist/commands/schema/list.js.map +0 -1
- package/dist/commands/schema/validate.js.map +0 -1
package/dist/commands/init.js
CHANGED
|
@@ -50,7 +50,7 @@ import { getSanityEnv } from '../util/getSanityEnv.js';
|
|
|
50
50
|
import { getPeerDependencies } from '../util/packageManager/getPeerDependencies.js';
|
|
51
51
|
import { installDeclaredPackages, installNewPackages } from '../util/packageManager/installPackages.js';
|
|
52
52
|
import { getPartialEnvWithNpmPath } from '../util/packageManager/packageManagerChoice.js';
|
|
53
|
-
import { ImportDatasetCommand } from './
|
|
53
|
+
import { ImportDatasetCommand } from './datasets/import.js';
|
|
54
54
|
const debug = subdebug('init');
|
|
55
55
|
export class InitCommand extends SanityCommand {
|
|
56
56
|
static args = {
|
|
@@ -75,7 +75,7 @@ export class InitCommand extends SanityCommand {
|
|
|
75
75
|
description: 'Initialize a project with the given project ID and dataset using the moviedb template to the given path'
|
|
76
76
|
},
|
|
77
77
|
{
|
|
78
|
-
command: '<%= config.bin %> <%= command.id %> -y --
|
|
78
|
+
command: '<%= config.bin %> <%= command.id %> -y --project-name "Movies Unlimited" --dataset moviedb --visibility private --template moviedb --output-path /Users/espenh/movies-unlimited',
|
|
79
79
|
description: 'Create a brand new project with name "Movies Unlimited"'
|
|
80
80
|
}
|
|
81
81
|
];
|
|
@@ -99,8 +99,12 @@ export class InitCommand extends SanityCommand {
|
|
|
99
99
|
helpValue: '<code>'
|
|
100
100
|
}),
|
|
101
101
|
'create-project': Flags.string({
|
|
102
|
+
deprecated: {
|
|
103
|
+
message: 'Use --project-name instead'
|
|
104
|
+
},
|
|
102
105
|
description: 'Create a new project with the given name',
|
|
103
|
-
helpValue: '<name>'
|
|
106
|
+
helpValue: '<name>',
|
|
107
|
+
hidden: true
|
|
104
108
|
}),
|
|
105
109
|
dataset: Flags.string({
|
|
106
110
|
description: 'Dataset name for the studio',
|
|
@@ -139,6 +143,11 @@ export class InitCommand extends SanityCommand {
|
|
|
139
143
|
helpLabel: ' --[no-]git',
|
|
140
144
|
helpValue: '<message>'
|
|
141
145
|
}),
|
|
146
|
+
'import-dataset': Flags.boolean({
|
|
147
|
+
allowNo: true,
|
|
148
|
+
default: undefined,
|
|
149
|
+
description: 'Import template sample dataset'
|
|
150
|
+
}),
|
|
142
151
|
mcp: Flags.boolean({
|
|
143
152
|
allowNo: true,
|
|
144
153
|
default: true,
|
|
@@ -206,10 +215,19 @@ export class InitCommand extends SanityCommand {
|
|
|
206
215
|
],
|
|
207
216
|
description: 'Project ID to use for the studio',
|
|
208
217
|
exclusive: [
|
|
209
|
-
'create-project'
|
|
218
|
+
'create-project',
|
|
219
|
+
'project-name'
|
|
210
220
|
],
|
|
211
221
|
helpValue: '<id>'
|
|
212
222
|
}),
|
|
223
|
+
'project-name': Flags.string({
|
|
224
|
+
description: 'Create a new project with the given name',
|
|
225
|
+
exclusive: [
|
|
226
|
+
'project',
|
|
227
|
+
'create-project'
|
|
228
|
+
],
|
|
229
|
+
helpValue: '<name>'
|
|
230
|
+
}),
|
|
213
231
|
'project-plan': Flags.string({
|
|
214
232
|
description: 'Optionally select a plan for a new project',
|
|
215
233
|
helpValue: '<name>'
|
|
@@ -269,7 +287,7 @@ export class InitCommand extends SanityCommand {
|
|
|
269
287
|
_trace;
|
|
270
288
|
async run() {
|
|
271
289
|
const workDir = process.cwd();
|
|
272
|
-
const createProjectName = this.flags['create-project'];
|
|
290
|
+
const createProjectName = this.flags['project-name'] ?? this.flags['create-project'];
|
|
273
291
|
// For backwards "compatibility" - we used to allow `sanity init plugin`,
|
|
274
292
|
// and no longer do - but instead of printing an error about an unknown
|
|
275
293
|
// _command_, we want to acknowledge that the user is trying to do something
|
|
@@ -312,10 +330,13 @@ export class InitCommand extends SanityCommand {
|
|
|
312
330
|
exit: 1
|
|
313
331
|
});
|
|
314
332
|
}
|
|
333
|
+
const isAppTemplate = this.flags.template ? determineAppTemplate(this.flags.template) : false // Default to false
|
|
334
|
+
;
|
|
315
335
|
// Checks flags are present when in unattended mode
|
|
316
336
|
if (this.isUnattended()) {
|
|
317
337
|
this.checkFlagsInUnattendedMode({
|
|
318
338
|
createProjectName,
|
|
339
|
+
isAppTemplate,
|
|
319
340
|
isNextJs
|
|
320
341
|
});
|
|
321
342
|
}
|
|
@@ -346,8 +367,6 @@ export class InitCommand extends SanityCommand {
|
|
|
346
367
|
const envFilename = typeof this.flags.env === 'string' ? this.flags.env : envFilenameDefault;
|
|
347
368
|
// If the user isn't already autenticated, make it so
|
|
348
369
|
const { user } = await this.ensureAuthenticated();
|
|
349
|
-
const isAppTemplate = this.flags.template ? determineAppTemplate(this.flags.template) : false // Default to false
|
|
350
|
-
;
|
|
351
370
|
if (!isAppTemplate) {
|
|
352
371
|
this.log(`${logSymbols.success} Fetching existing projects`);
|
|
353
372
|
this.log('');
|
|
@@ -401,8 +420,14 @@ export class InitCommand extends SanityCommand {
|
|
|
401
420
|
workDir
|
|
402
421
|
});
|
|
403
422
|
// Set up MCP integration
|
|
423
|
+
let mcpMode = 'prompt';
|
|
424
|
+
if (!this.flags.mcp || !this.resolveIsInteractive()) {
|
|
425
|
+
mcpMode = 'skip';
|
|
426
|
+
} else if (this.flags.yes) {
|
|
427
|
+
mcpMode = 'auto';
|
|
428
|
+
}
|
|
404
429
|
const mcpResult = await setupMCP({
|
|
405
|
-
|
|
430
|
+
mode: mcpMode
|
|
406
431
|
});
|
|
407
432
|
this._trace.log({
|
|
408
433
|
configuredEditors: mcpResult.configuredEditors,
|
|
@@ -476,7 +501,8 @@ export class InitCommand extends SanityCommand {
|
|
|
476
501
|
});
|
|
477
502
|
}
|
|
478
503
|
// If the template has a sample dataset, prompt the user whether or not we should import it
|
|
479
|
-
const
|
|
504
|
+
const importDatasetFlag = this.flags['import-dataset'];
|
|
505
|
+
const shouldImport = template?.datasetUrl && (importDatasetFlag ?? (!this.isUnattended() && await this.promptForDatasetImport(template.importPrompt)));
|
|
480
506
|
this._trace.log({
|
|
481
507
|
selectedOption: shouldImport ? 'yes' : 'no',
|
|
482
508
|
step: 'importTemplateDataset'
|
|
@@ -621,8 +647,22 @@ export class InitCommand extends SanityCommand {
|
|
|
621
647
|
}
|
|
622
648
|
this._trace.complete();
|
|
623
649
|
}
|
|
624
|
-
checkFlagsInUnattendedMode({ createProjectName, isNextJs }) {
|
|
650
|
+
checkFlagsInUnattendedMode({ createProjectName, isAppTemplate, isNextJs }) {
|
|
625
651
|
debug('Unattended mode, validating required options');
|
|
652
|
+
// App templates only require --organization and --output-path
|
|
653
|
+
if (isAppTemplate) {
|
|
654
|
+
if (!this.flags['output-path']) {
|
|
655
|
+
this.error('`--output-path` must be specified in unattended mode', {
|
|
656
|
+
exit: 1
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
if (!this.flags.organization) {
|
|
660
|
+
this.error('The --organization flag is required for app templates in unattended mode. ' + 'Use --organization <id> to specify which organization to use.', {
|
|
661
|
+
exit: 1
|
|
662
|
+
});
|
|
663
|
+
}
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
626
666
|
if (!this.flags['dataset']) {
|
|
627
667
|
this.error(`\`--dataset\` must be specified in unattended mode`, {
|
|
628
668
|
exit: 1
|
|
@@ -635,18 +675,18 @@ export class InitCommand extends SanityCommand {
|
|
|
635
675
|
});
|
|
636
676
|
}
|
|
637
677
|
if (!this.flags.project && !createProjectName) {
|
|
638
|
-
this.error('`--project <id>` or `--
|
|
678
|
+
this.error('`--project <id>` or `--project-name <name>` must be specified in unattended mode', {
|
|
639
679
|
exit: 1
|
|
640
680
|
});
|
|
641
681
|
}
|
|
642
682
|
if (createProjectName && !this.flags.organization) {
|
|
643
|
-
this.error('
|
|
683
|
+
this.error('`--project-name` requires `--organization <id>` in unattended mode', {
|
|
644
684
|
exit: 1
|
|
645
685
|
});
|
|
646
686
|
}
|
|
647
687
|
}
|
|
648
688
|
async createProjectFromName({ createProjectName, planId, user }) {
|
|
649
|
-
debug('--
|
|
689
|
+
debug('--project-name specified, creating a new project');
|
|
650
690
|
let orgForCreateProjectFlag = this.flags.organization;
|
|
651
691
|
if (!orgForCreateProjectFlag) {
|
|
652
692
|
debug('no organization specified, selecting one');
|
|
@@ -948,6 +988,18 @@ export class InitCommand extends SanityCommand {
|
|
|
948
988
|
}
|
|
949
989
|
async getProjectDetails({ isAppTemplate, newProject, planId, showDefaultConfigPrompt, user }) {
|
|
950
990
|
if (isAppTemplate) {
|
|
991
|
+
// If organization flag is provided, use it directly (skip prompt and API call)
|
|
992
|
+
if (this.flags.organization) {
|
|
993
|
+
return {
|
|
994
|
+
datasetName: '',
|
|
995
|
+
displayName: '',
|
|
996
|
+
isFirstProject: false,
|
|
997
|
+
organizationId: this.flags.organization,
|
|
998
|
+
projectId: ''
|
|
999
|
+
};
|
|
1000
|
+
}
|
|
1001
|
+
// Interactive mode: fetch orgs and prompt
|
|
1002
|
+
// Note: unattended mode without --organization is rejected by checkFlagsInUnattendedMode
|
|
951
1003
|
const organizations = await listOrganizations({
|
|
952
1004
|
includeImplicitMemberships: 'true',
|
|
953
1005
|
includeMembers: 'true'
|