@sanity/cli 6.0.0-alpha.11 → 6.0.0-alpha.13
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 +100 -112
- package/dist/actions/build/buildApp.js +15 -6
- package/dist/actions/build/buildApp.js.map +1 -1
- package/dist/actions/build/buildStudio.js +9 -3
- package/dist/actions/build/buildStudio.js.map +1 -1
- package/dist/actions/build/checkRequiredDependencies.js +6 -3
- package/dist/actions/build/checkRequiredDependencies.js.map +1 -1
- package/dist/actions/build/checkStudioDependencyVersions.js +6 -4
- package/dist/actions/build/checkStudioDependencyVersions.js.map +1 -1
- package/dist/actions/build/types.js.map +1 -1
- package/dist/actions/deploy/deployApp.js +1 -2
- package/dist/actions/deploy/deployApp.js.map +1 -1
- package/dist/actions/deploy/deployStudio.js +1 -2
- package/dist/actions/deploy/deployStudio.js.map +1 -1
- package/dist/actions/deploy/types.js.map +1 -1
- package/dist/actions/init/checkNextJsReactCompatibility.js +1 -1
- package/dist/actions/init/checkNextJsReactCompatibility.js.map +1 -1
- package/dist/actions/init/createPackageManifest.js +13 -8
- package/dist/actions/init/createPackageManifest.js.map +1 -1
- package/dist/actions/init/remoteTemplate.js +1 -2
- package/dist/actions/init/remoteTemplate.js.map +1 -1
- package/dist/actions/manifest/SchemaIcon.js +6 -4
- package/dist/actions/manifest/SchemaIcon.js.map +1 -1
- package/dist/actions/manifest/blockTypeTransformer.js +67 -0
- package/dist/actions/manifest/blockTypeTransformer.js.map +1 -0
- package/dist/actions/manifest/debug.js +4 -0
- package/dist/actions/manifest/debug.js.map +1 -0
- package/dist/actions/manifest/extractManifest.js +26 -41
- package/dist/actions/manifest/extractManifest.js.map +1 -1
- package/dist/actions/manifest/extractManifest.worker.js +31 -0
- package/dist/actions/manifest/extractManifest.worker.js.map +1 -0
- package/dist/actions/manifest/extractWorkspaceManifest.js +31 -372
- package/dist/actions/manifest/extractWorkspaceManifest.js.map +1 -1
- package/dist/actions/manifest/iconResolver.js +30 -0
- package/dist/actions/manifest/iconResolver.js.map +1 -0
- package/dist/actions/manifest/referenceTransformer.js +51 -0
- package/dist/actions/manifest/referenceTransformer.js.map +1 -0
- package/dist/actions/manifest/schemaTypeHelpers.js +2 -2
- package/dist/actions/manifest/schemaTypeHelpers.js.map +1 -1
- package/dist/actions/manifest/schemaTypeTransformer.js +168 -0
- package/dist/actions/manifest/schemaTypeTransformer.js.map +1 -0
- package/dist/actions/manifest/transformerUtils.js +40 -0
- package/dist/actions/manifest/transformerUtils.js.map +1 -0
- package/dist/actions/manifest/types.js +5 -0
- package/dist/actions/manifest/types.js.map +1 -1
- package/dist/actions/manifest/validationTransformer.js +84 -0
- package/dist/actions/manifest/validationTransformer.js.map +1 -0
- package/dist/actions/manifest/writeWorkspaceFiles.js +30 -0
- package/dist/actions/manifest/writeWorkspaceFiles.js.map +1 -0
- package/dist/actions/schema/deleteSchemaAction.js +14 -30
- package/dist/actions/schema/deleteSchemaAction.js.map +1 -1
- package/dist/actions/schema/extractSchema.js +1 -8
- package/dist/actions/schema/extractSchema.js.map +1 -1
- package/dist/actions/schema/listSchemas.js +53 -56
- package/dist/actions/schema/listSchemas.js.map +1 -1
- package/dist/actions/schema/types.js +4 -0
- package/dist/actions/schema/types.js.map +1 -1
- package/dist/actions/schema/uniqueWorkspaces.worker.js +22 -0
- package/dist/actions/schema/uniqueWorkspaces.worker.js.map +1 -0
- package/dist/actions/schema/utils/SchemaExtractionError.js +10 -0
- package/dist/actions/schema/utils/SchemaExtractionError.js.map +1 -0
- package/dist/actions/schema/utils/manifestExtractor.js +3 -7
- package/dist/actions/schema/utils/manifestExtractor.js.map +1 -1
- package/dist/actions/schema/utils/schemaStoreValidation.js +1 -9
- package/dist/actions/schema/utils/schemaStoreValidation.js.map +1 -1
- package/dist/actions/schema/utils/uniqByProjectIdDataset.js +1 -1
- package/dist/actions/schema/utils/uniqByProjectIdDataset.js.map +1 -1
- package/dist/actions/versions/filterSanityModules.js.map +1 -1
- package/dist/actions/versions/findSanityModulesVersions.js +1 -1
- package/dist/actions/versions/findSanityModulesVersions.js.map +1 -1
- package/dist/commands/build.js +2 -5
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/deploy.js +1 -4
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/manifest/extract.js +13 -9
- package/dist/commands/manifest/extract.js.map +1 -1
- package/dist/commands/schema/delete.js +15 -25
- package/dist/commands/schema/delete.js.map +1 -1
- package/dist/commands/schema/list.js +10 -31
- package/dist/commands/schema/list.js.map +1 -1
- package/dist/config/createCliConfig.js +1 -2
- package/dist/config/createCliConfig.js.map +1 -1
- package/dist/exports/_internal.d.ts +132 -0
- package/dist/exports/_internal.js +4 -0
- package/dist/exports/_internal.js.map +1 -0
- package/dist/exports/index.d.ts +51 -0
- package/dist/exports/index.js +6 -0
- package/dist/exports/index.js.map +1 -0
- package/dist/hooks/init/checkForUpdates.js +14 -0
- package/dist/hooks/init/checkForUpdates.js.map +1 -0
- package/dist/hooks/prerun/setupTelemetry.js +7 -2
- package/dist/hooks/prerun/setupTelemetry.js.map +1 -1
- package/dist/services/schemas.js.map +1 -1
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -1
- package/dist/util/cliClient.js +5 -3
- package/dist/util/cliClient.js.map +1 -1
- package/dist/util/compareDependencyVersions.js +9 -5
- package/dist/util/compareDependencyVersions.js.map +1 -1
- package/dist/util/getCliVersion.js +1 -1
- package/dist/util/getCliVersion.js.map +1 -1
- package/dist/util/getLocalPackageVersion.js +1 -1
- package/dist/util/getLocalPackageVersion.js.map +1 -1
- package/dist/util/promiseRaceWithTimeout.js +28 -0
- package/dist/util/promiseRaceWithTimeout.js.map +1 -0
- package/dist/util/readModuleVersion.js +11 -5
- package/dist/util/readModuleVersion.js.map +1 -1
- package/dist/util/update/fetchLatestVersion.js +21 -0
- package/dist/util/update/fetchLatestVersion.js.map +1 -0
- package/dist/util/update/getUpdateCommand.js +15 -0
- package/dist/util/update/getUpdateCommand.js.map +1 -0
- package/dist/util/update/isInstalledUsingYarn.js +17 -0
- package/dist/util/update/isInstalledUsingYarn.js.map +1 -0
- package/dist/util/update/showNotificationUpdate.js +31 -0
- package/dist/util/update/showNotificationUpdate.js.map +1 -0
- package/dist/util/update/updateChecker.js +59 -0
- package/dist/util/update/updateChecker.js.map +1 -0
- package/dist/util/update/updateCheckerDebug.js +4 -0
- package/dist/util/update/updateCheckerDebug.js.map +1 -0
- package/oclif.config.js +1 -0
- package/oclif.manifest.json +299 -303
- package/package.json +26 -22
- package/dist/index.d.ts +0 -2326
- package/dist/index.js +0 -6
- package/dist/index.js.map +0 -1
- package/dist/typings/deepSortObject.d.js +0 -2
- package/dist/typings/deepSortObject.d.js.map +0 -1
- package/dist/util/importStudioConfig.js +0 -40
- package/dist/util/importStudioConfig.js.map +0 -1
- package/dist/util/readPackageJson.js +0 -44
- package/dist/util/readPackageJson.js.map +0 -1
- package/dist/util/readPackageManifest.js +0 -46
- package/dist/util/readPackageManifest.js.map +0 -1
- package/dist/util/uniqBy.js +0 -14
- package/dist/util/uniqBy.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/deploy.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {Args, Flags} from '@oclif/core'\nimport {SanityCommand} from '@sanity/cli-core'\nimport {confirm} from '@sanity/cli-core/ux'\n\nimport {deployApp} from '../actions/deploy/deployApp.js'\nimport {deployDebug} from '../actions/deploy/deployDebug.js'\nimport {deployStudio} from '../actions/deploy/deployStudio.js'\nimport {determineIsApp} from '../util/determineIsApp.js'\nimport {dirIsEmptyOrNonExistent} from '../util/dirIsEmptyOrNonExistent.js'\n\nexport class DeployCommand extends SanityCommand<typeof DeployCommand> {\n static override args = {\n sourceDir: Args.directory({\n description: 'Source directory',\n }),\n }\n\n static override description = 'Builds and deploys Sanity Studio or application to Sanity hosting'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n
|
|
1
|
+
{"version":3,"sources":["../../src/commands/deploy.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {Args, Flags} from '@oclif/core'\nimport {SanityCommand} from '@sanity/cli-core'\nimport {confirm} from '@sanity/cli-core/ux'\n\nimport {deployApp} from '../actions/deploy/deployApp.js'\nimport {deployDebug} from '../actions/deploy/deployDebug.js'\nimport {deployStudio} from '../actions/deploy/deployStudio.js'\nimport {determineIsApp} from '../util/determineIsApp.js'\nimport {dirIsEmptyOrNonExistent} from '../util/dirIsEmptyOrNonExistent.js'\n\nexport class DeployCommand extends SanityCommand<typeof DeployCommand> {\n static override args = {\n sourceDir: Args.directory({\n description: 'Source directory',\n }),\n }\n\n static override description = 'Builds and deploys Sanity Studio or application to Sanity hosting'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Build and deploy the studio to Sanity hosting',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --no-minify --source-maps',\n description: 'Deploys non-minified build with source maps',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --schema-required',\n description:\n 'Fail fast on schema store fails - for when other services rely on the stored schema',\n },\n ]\n\n static override flags = {\n 'auto-updates': Flags.boolean({\n allowNo: true,\n deprecated: true,\n description: 'Automatically update the studio to the latest version',\n }),\n build: Flags.boolean({\n allowNo: true,\n default: true,\n description:\n \"Don't build the studio prior to deploy, instead deploying the version currently in `dist/`\",\n }),\n minify: Flags.boolean({\n allowNo: true,\n default: true,\n description: 'Skip minifying built JavaScript (speeds up build, increases size of bundle)',\n }),\n 'schema-required': Flags.boolean({\n default: false,\n description: 'Fail-fast deployment if schema store fails',\n }),\n 'source-maps': Flags.boolean({\n default: false,\n description: 'Enable source maps for built bundles (increases size of bundle)',\n }),\n verbose: Flags.boolean({\n default: false,\n description: 'Enable verbose logging',\n }),\n yes: Flags.boolean({\n char: 'y',\n default: false,\n description:\n 'Unattended mode, answers \"yes\" to any \"yes/no\" prompt and otherwise uses defaults',\n }),\n }\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(DeployCommand)\n\n const cliConfig = await this.getCliConfig()\n const workDir = (await this.getProjectRoot()).directory\n\n const isApp = determineIsApp(cliConfig)\n\n const defaultOutputDir = path.resolve(path.join(workDir, 'dist'))\n const sourceDir = path.resolve(process.cwd(), this.args.sourceDir || defaultOutputDir)\n\n if (this.args.sourceDir && this.args.sourceDir !== 'dist') {\n let relativeOutput = path.relative(process.cwd(), sourceDir)\n if (relativeOutput[0] !== '.') {\n relativeOutput = `./${relativeOutput}`\n }\n\n const isEmpty = await dirIsEmptyOrNonExistent(sourceDir)\n // Prompt to delete the directory if it's not empty\n const shouldProceed =\n isEmpty ||\n (await confirm({\n default: false,\n message: `\"${relativeOutput}\" is not empty, do you want to proceed?`,\n }))\n\n if (!shouldProceed) {\n this.output.error('Cancelled.', {exit: 1})\n }\n\n this.output.log(`Building to ${relativeOutput}\\n`)\n }\n\n if (isApp) {\n deployDebug('Deploying app')\n await deployApp({\n cliConfig,\n flags,\n output: this.output,\n sourceDir,\n workDir,\n })\n } else {\n deployDebug('Deploying studio')\n await deployStudio({\n cliConfig,\n flags,\n output: this.output,\n sourceDir,\n workDir,\n })\n }\n }\n}\n"],"names":["path","Args","Flags","SanityCommand","confirm","deployApp","deployDebug","deployStudio","determineIsApp","dirIsEmptyOrNonExistent","DeployCommand","args","sourceDir","directory","description","examples","command","flags","boolean","allowNo","deprecated","build","default","minify","verbose","yes","char","run","parse","cliConfig","getCliConfig","workDir","getProjectRoot","isApp","defaultOutputDir","resolve","join","process","cwd","relativeOutput","relative","isEmpty","shouldProceed","message","output","error","exit","log"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B,SAAQC,IAAI,EAAEC,KAAK,QAAO,cAAa;AACvC,SAAQC,aAAa,QAAO,mBAAkB;AAC9C,SAAQC,OAAO,QAAO,sBAAqB;AAE3C,SAAQC,SAAS,QAAO,iCAAgC;AACxD,SAAQC,WAAW,QAAO,mCAAkC;AAC5D,SAAQC,YAAY,QAAO,oCAAmC;AAC9D,SAAQC,cAA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C,GAAG,IAAI,IAAI,CAAC3B,IAAI,CAACC,SAAS,IAAIsB;QAErE,IAAI,IAAI,CAACvB,IAAI,CAACC,SAAS,IAAI,IAAI,CAACD,IAAI,CAACC,SAAS,KAAK,QAAQ;YACzD,IAAI2B,iBAAiBvC,KAAKwC,QAAQ,CAACH,QAAQC,GAAG,IAAI1B;YAClD,IAAI2B,cAAc,CAAC,EAAE,KAAK,KAAK;gBAC7BA,iBAAiB,CAAC,EAAE,EAAEA,gBAAgB;YACxC;YAEA,MAAME,UAAU,MAAMhC,wBAAwBG;YAC9C,mDAAmD;YACnD,MAAM8B,gBACJD,WACC,MAAMrC,QAAQ;gBACbkB,SAAS;gBACTqB,SAAS,CAAC,CAAC,EAAEJ,eAAe,uCAAuC,CAAC;YACtE;YAEF,IAAI,CAACG,eAAe;gBAClB,IAAI,CAACE,MAAM,CAACC,KAAK,CAAC,cAAc;oBAACC,MAAM;gBAAC;YAC1C;YAEA,IAAI,CAACF,MAAM,CAACG,GAAG,CAAC,CAAC,YAAY,EAAER,eAAe,EAAE,CAAC;QACnD;QAEA,IAAIN,OAAO;YACT3B,YAAY;YACZ,MAAMD,UAAU;gBACdwB;gBACAZ;gBACA2B,QAAQ,IAAI,CAACA,MAAM;gBACnBhC;gBACAmB;YACF;QACF,OAAO;YACLzB,YAAY;YACZ,MAAMC,aAAa;gBACjBsB;gBACAZ;gBACA2B,QAAQ,IAAI,CAACA,MAAM;gBACnBhC;gBACAmB;YACF;QACF;IACF;AACF"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
2
|
import { SanityCommand } from '@sanity/cli-core';
|
|
3
|
-
import {
|
|
3
|
+
import { manifestDebug } from '../../actions/manifest/debug.js';
|
|
4
|
+
import { extractManifest } from '../../actions/manifest/extractManifest.js';
|
|
5
|
+
import { formatSchemaValidation } from '../../actions/schema/formatSchemaValidation.js';
|
|
6
|
+
import { SchemaExtractionError } from '../../actions/schema/utils/SchemaExtractionError.js';
|
|
4
7
|
const description = `
|
|
5
8
|
Extracts the studio configuration as one or more JSON manifest files.
|
|
6
9
|
|
|
@@ -26,14 +29,15 @@ export class ExtractManifestCommand extends SanityCommand {
|
|
|
26
29
|
};
|
|
27
30
|
async run() {
|
|
28
31
|
const { flags } = await this.parse(ExtractManifestCommand);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
try {
|
|
33
|
+
await extractManifest(flags.path);
|
|
34
|
+
} catch (error) {
|
|
35
|
+
manifestDebug('Error extracting manifest in command', error);
|
|
36
|
+
if (error instanceof SchemaExtractionError && error.validation && error.validation.length > 0) {
|
|
37
|
+
this.output.log(formatSchemaValidation(error.validation));
|
|
38
|
+
this.exit(1);
|
|
39
|
+
}
|
|
40
|
+
this.error(`Failed to extract manifest:\n${error instanceof Error ? error.message : String(error)}`, {
|
|
37
41
|
exit: 1
|
|
38
42
|
});
|
|
39
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/manifest/extract.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\nimport {SanityCommand} from '@sanity/cli-core'\n\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/manifest/extract.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\nimport {SanityCommand} from '@sanity/cli-core'\n\nimport {manifestDebug} from '../../actions/manifest/debug.js'\nimport {extractManifest} from '../../actions/manifest/extractManifest.js'\nimport {formatSchemaValidation} from '../../actions/schema/formatSchemaValidation.js'\nimport {SchemaExtractionError} from '../../actions/schema/utils/SchemaExtractionError.js'\n\nconst description = `\nExtracts the studio configuration as one or more JSON manifest files.\n\n**Note**: This command is experimental and subject to change. It is currently intended for use with Create only.\n`.trim()\n\nexport class ExtractManifestCommand extends SanityCommand<typeof ExtractManifestCommand> {\n static override description = description\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'Extracts manifests',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --path /public/static',\n description: 'Extracts manifests into /public/static',\n },\n ]\n\n static override flags = {\n path: Flags.string({\n default: '/dist/static',\n description: 'Optional path to specify destination directory of the manifest files',\n }),\n }\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(ExtractManifestCommand)\n\n try {\n await extractManifest(flags.path)\n } catch (error) {\n manifestDebug('Error extracting manifest in command', error)\n if (\n error instanceof SchemaExtractionError &&\n error.validation &&\n error.validation.length > 0\n ) {\n this.output.log(formatSchemaValidation(error.validation))\n this.exit(1)\n }\n\n this.error(\n `Failed to extract manifest:\\n${error instanceof Error ? error.message : String(error)}`,\n {exit: 1},\n )\n }\n }\n}\n"],"names":["Flags","SanityCommand","manifestDebug","extractManifest","formatSchemaValidation","SchemaExtractionError","description","trim","ExtractManifestCommand","examples","command","flags","path","string","default","run","parse","error","validation","length","output","log","exit","Error","message","String"],"mappings":"AAAA,SAAQA,KAAK,QAAO,cAAa;AACjC,SAAQC,aAAa,QAAO,mBAAkB;AAE9C,SAAQC,aAAa,QAAO,kCAAiC;AAC7D,SAAQC,eAAe,QAAO,4CAA2C;AACzE,SAAQC,sBAAsB,QAAO,iDAAgD;AACrF,SAAQC,qBAAqB,QAAO,sDAAqD;AAEzF,MAAMC,cAAc,CAAC;;;;AAIrB,CAAC,CAACC,IAAI;AAEN,OAAO,MAAMC,+BAA+BP;IAC1C,OAAgBK,cAAcA,YAAW;IAEzC,OAAgBG,WAAW;QACzB;YACEC,SAAS;YACTJ,aAAa;QACf;QACA;YACEI,SAAS;YACTJ,aAAa;QACf;KACD,CAAA;IAED,OAAgBK,QAAQ;QACtBC,MAAMZ,MAAMa,MAAM,CAAC;YACjBC,SAAS;YACTR,aAAa;QACf;IACF,EAAC;IAED,MAAaS,MAAqB;QAChC,MAAM,EAACJ,KAAK,EAAC,GAAG,MAAM,IAAI,CAACK,KAAK,CAACR;QAEjC,IAAI;YACF,MAAML,gBAAgBQ,MAAMC,IAAI;QAClC,EAAE,OAAOK,OAAO;YACdf,cAAc,wCAAwCe;YACtD,IACEA,iBAAiBZ,yBACjBY,MAAMC,UAAU,IAChBD,MAAMC,UAAU,CAACC,MAAM,GAAG,GAC1B;gBACA,IAAI,CAACC,MAAM,CAACC,GAAG,CAACjB,uBAAuBa,MAAMC,UAAU;gBACvD,IAAI,CAACI,IAAI,CAAC;YACZ;YAEA,IAAI,CAACL,KAAK,CACR,CAAC,6BAA6B,EAAEA,iBAAiBM,QAAQN,MAAMO,OAAO,GAAGC,OAAOR,QAAQ,EACxF;gBAACK,MAAM;YAAC;QAEZ;IACF;AACF"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
+
import { CLIError } from '@oclif/core/errors';
|
|
2
3
|
import { parseStringFlag, SanityCommand, subdebug } from '@sanity/cli-core';
|
|
3
4
|
import { deleteSchemaAction } from '../../actions/schema/deleteSchemaAction.js';
|
|
4
5
|
import { parseIds } from '../../actions/schema/utils/schemaStoreValidation.js';
|
|
5
|
-
import {
|
|
6
|
+
import { NO_PROJECT_ID } from '../../util/errorMessages.js';
|
|
6
7
|
const deleteSchemaDebug = subdebug('schema:delete');
|
|
7
8
|
export class DeleteSchemaCommand extends SanityCommand {
|
|
8
9
|
static description = 'Delete schema documents by id';
|
|
@@ -14,10 +15,6 @@ export class DeleteSchemaCommand extends SanityCommand {
|
|
|
14
15
|
{
|
|
15
16
|
command: '<%= config.bin %> <%= command.id %> --ids sanity.workspace.schema.workspaceName,prefix.sanity.workspace.schema.otherWorkspace',
|
|
16
17
|
description: 'Delete multiple schemas'
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
command: '<%= config.bin %> <%= command.id %> --no-extract-manifest --ids sanity.workspace.schema.workspaceName',
|
|
20
|
-
description: 'Delete using a pre-existing manifest file (config changes in sanity.config will not be picked up)'
|
|
21
18
|
}
|
|
22
19
|
];
|
|
23
20
|
static flags = {
|
|
@@ -28,7 +25,8 @@ export class DeleteSchemaCommand extends SanityCommand {
|
|
|
28
25
|
'extract-manifest': Flags.boolean({
|
|
29
26
|
allowNo: true,
|
|
30
27
|
default: true,
|
|
31
|
-
description: 'Generate manifest file (disable with --no-extract-manifest)'
|
|
28
|
+
description: 'Generate manifest file (disable with --no-extract-manifest)',
|
|
29
|
+
hidden: true
|
|
32
30
|
}),
|
|
33
31
|
ids: Flags.string({
|
|
34
32
|
description: 'Comma-separated list of schema ids to delete',
|
|
@@ -36,7 +34,8 @@ export class DeleteSchemaCommand extends SanityCommand {
|
|
|
36
34
|
}),
|
|
37
35
|
'manifest-dir': Flags.directory({
|
|
38
36
|
default: './dist/static',
|
|
39
|
-
description: 'Directory containing manifest file'
|
|
37
|
+
description: 'Directory containing manifest file',
|
|
38
|
+
hidden: true
|
|
40
39
|
}),
|
|
41
40
|
verbose: Flags.boolean({
|
|
42
41
|
default: false,
|
|
@@ -49,39 +48,30 @@ export class DeleteSchemaCommand extends SanityCommand {
|
|
|
49
48
|
deleteSchemaDebug('Running schema delete with flags: %O', flags);
|
|
50
49
|
const ids = parseIds(flags.ids);
|
|
51
50
|
try {
|
|
52
|
-
const workDir =
|
|
53
|
-
const cliConfig = await this.getCliConfig();
|
|
51
|
+
const workDir = await this.getProjectRoot();
|
|
54
52
|
const projectId = await this.getProjectId();
|
|
55
|
-
const cliDataset = cliConfig.api?.dataset;
|
|
56
53
|
if (!projectId) {
|
|
57
54
|
this.error(NO_PROJECT_ID, {
|
|
58
55
|
exit: 1
|
|
59
56
|
});
|
|
60
57
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
exit: 1
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
const result = await deleteSchemaAction({
|
|
58
|
+
await deleteSchemaAction({
|
|
59
|
+
configPath: workDir.path,
|
|
67
60
|
dataset,
|
|
68
|
-
extractManifest: flags['extract-manifest'],
|
|
69
61
|
ids,
|
|
70
|
-
manifestDir: flags['manifest-dir'],
|
|
71
62
|
output: this.output,
|
|
72
63
|
projectId,
|
|
73
64
|
verbose: flags['verbose'],
|
|
74
|
-
workDir
|
|
65
|
+
workDir: workDir.directory
|
|
75
66
|
});
|
|
76
|
-
|
|
77
|
-
|
|
67
|
+
} catch (error) {
|
|
68
|
+
if (error instanceof CLIError) {
|
|
69
|
+
this.error(error.message, {
|
|
78
70
|
exit: 1
|
|
79
71
|
});
|
|
80
72
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
deleteSchemaDebug('Error deleting schemas', err);
|
|
84
|
-
this.error(`Failed to delete schemas: ${err.message}`, {
|
|
73
|
+
deleteSchemaDebug('Error deleting schemas', error);
|
|
74
|
+
this.error(`Failed to delete schemas: ${error.message}`, {
|
|
85
75
|
exit: 1
|
|
86
76
|
});
|
|
87
77
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/schema/delete.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\nimport {parseStringFlag, SanityCommand, subdebug} from '@sanity/cli-core'\n\nimport {deleteSchemaAction} from '../../actions/schema/deleteSchemaAction.js'\nimport {parseIds} from '../../actions/schema/utils/schemaStoreValidation.js'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/schema/delete.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\nimport {CLIError} from '@oclif/core/errors'\nimport {parseStringFlag, SanityCommand, subdebug} from '@sanity/cli-core'\n\nimport {deleteSchemaAction} from '../../actions/schema/deleteSchemaAction.js'\nimport {parseIds} from '../../actions/schema/utils/schemaStoreValidation.js'\nimport {NO_PROJECT_ID} from '../../util/errorMessages.js'\n\nconst deleteSchemaDebug = subdebug('schema:delete')\n\nexport class DeleteSchemaCommand extends SanityCommand<typeof DeleteSchemaCommand> {\n static override description = 'Delete schema documents by id'\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %> --ids sanity.workspace.schema.workspaceName',\n description: 'Delete a single schema',\n },\n {\n command:\n '<%= config.bin %> <%= command.id %> --ids sanity.workspace.schema.workspaceName,prefix.sanity.workspace.schema.otherWorkspace',\n description: 'Delete multiple schemas',\n },\n ]\n\n static override flags = {\n dataset: Flags.string({\n description: 'Delete schemas from a specific dataset',\n parse: async (input) => parseStringFlag('dataset', input),\n }),\n 'extract-manifest': Flags.boolean({\n allowNo: true,\n default: true,\n description: 'Generate manifest file (disable with --no-extract-manifest)',\n hidden: true,\n }),\n ids: Flags.string({\n description: 'Comma-separated list of schema ids to delete',\n required: true,\n }),\n 'manifest-dir': Flags.directory({\n default: './dist/static',\n description: 'Directory containing manifest file',\n hidden: true,\n }),\n verbose: Flags.boolean({\n default: false,\n description: 'Enable verbose logging',\n }),\n }\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(DeleteSchemaCommand)\n const {dataset} = flags\n\n deleteSchemaDebug('Running schema delete with flags: %O', flags)\n\n const ids = parseIds(flags.ids)\n\n try {\n const workDir = await this.getProjectRoot()\n const projectId = await this.getProjectId()\n\n if (!projectId) {\n this.error(NO_PROJECT_ID, {exit: 1})\n }\n\n await deleteSchemaAction({\n configPath: workDir.path,\n dataset,\n ids,\n output: this.output,\n projectId,\n verbose: flags['verbose'],\n workDir: workDir.directory,\n })\n } catch (error) {\n if (error instanceof CLIError) {\n this.error(error.message, {exit: 1})\n }\n\n deleteSchemaDebug('Error deleting schemas', error)\n this.error(`Failed to delete schemas: ${error.message}`, {exit: 1})\n }\n }\n}\n"],"names":["Flags","CLIError","parseStringFlag","SanityCommand","subdebug","deleteSchemaAction","parseIds","NO_PROJECT_ID","deleteSchemaDebug","DeleteSchemaCommand","description","examples","command","flags","dataset","string","parse","input","boolean","allowNo","default","hidden","ids","required","directory","verbose","run","workDir","getProjectRoot","projectId","getProjectId","error","exit","configPath","path","output","message"],"mappings":"AAAA,SAAQA,KAAK,QAAO,cAAa;AACjC,SAAQC,QAAQ,QAAO,qBAAoB;AAC3C,SAAQC,eAAe,EAAEC,aAAa,EAAEC,QAAQ,QAAO,mBAAkB;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AAK,CAAC,UAAU;gBACzBc,SAASA,QAAQH,SAAS;YAC5B;QACF,EAAE,OAAOO,OAAO;YACd,IAAIA,iBAAiB9B,UAAU;gBAC7B,IAAI,CAAC8B,KAAK,CAACA,MAAMK,OAAO,EAAE;oBAACJ,MAAM;gBAAC;YACpC;YAEAxB,kBAAkB,0BAA0BuB;YAC5C,IAAI,CAACA,KAAK,CAAC,CAAC,0BAA0B,EAAEA,MAAMK,OAAO,EAAE,EAAE;gBAACJ,MAAM;YAAC;QACnE;IACF;AACF"}
|
|
@@ -3,7 +3,6 @@ import { SanityCommand } from '@sanity/cli-core';
|
|
|
3
3
|
import { listSchemas } from '../../actions/schema/listSchemas.js';
|
|
4
4
|
import { schemasListDebug } from '../../actions/schema/utils/debug.js';
|
|
5
5
|
import { parseWorkspaceSchemaId } from '../../actions/schema/utils/schemaStoreValidation.js';
|
|
6
|
-
import { NO_DATASET_ID, NO_PROJECT_ID } from '../../util/errorMessages.js';
|
|
7
6
|
const description = `
|
|
8
7
|
Lists all schemas in the current dataset.
|
|
9
8
|
|
|
@@ -30,17 +29,14 @@ export class ListSchemaCommand extends SanityCommand {
|
|
|
30
29
|
{
|
|
31
30
|
command: '<%= config.bin %> <%= command.id %> --json --id _.schemas.workspaceName',
|
|
32
31
|
description: 'Get singular stored schema as pretty-printed json-object'
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
command: '<%= config.bin %> <%= command.id %> --no-extract-manifest',
|
|
36
|
-
description: 'Runs using a pre-existing manifest file. Config changes in sanity.config will not be picked up in this case.'
|
|
37
32
|
}
|
|
38
33
|
];
|
|
39
34
|
static flags = {
|
|
40
35
|
'extract-manifest': Flags.boolean({
|
|
41
36
|
allowNo: true,
|
|
42
37
|
default: true,
|
|
43
|
-
description: 'Disables manifest generation - the command will fail if no manifest exists'
|
|
38
|
+
description: 'Disables manifest generation - the command will fail if no manifest exists',
|
|
39
|
+
hidden: true
|
|
44
40
|
}),
|
|
45
41
|
id: Flags.string({
|
|
46
42
|
description: 'Fetch a single schema by id',
|
|
@@ -52,26 +48,14 @@ export class ListSchemaCommand extends SanityCommand {
|
|
|
52
48
|
'manifest-dir': Flags.directory({
|
|
53
49
|
default: './dist/static',
|
|
54
50
|
description: 'Directory containing manifest file',
|
|
55
|
-
helpValue: '<directory>'
|
|
51
|
+
helpValue: '<directory>',
|
|
52
|
+
hidden: true
|
|
56
53
|
})
|
|
57
54
|
};
|
|
58
55
|
async run() {
|
|
59
56
|
const { flags } = await this.parse(ListSchemaCommand);
|
|
60
57
|
try {
|
|
61
|
-
const
|
|
62
|
-
const cliConfig = await this.getCliConfig();
|
|
63
|
-
const projectId = await this.getProjectId();
|
|
64
|
-
const dataset = cliConfig.api?.dataset;
|
|
65
|
-
if (!projectId) {
|
|
66
|
-
this.error(NO_PROJECT_ID, {
|
|
67
|
-
exit: 1
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
if (!dataset) {
|
|
71
|
-
this.error(NO_DATASET_ID, {
|
|
72
|
-
exit: 1
|
|
73
|
-
});
|
|
74
|
-
}
|
|
58
|
+
const projectRoot = await this.getProjectRoot();
|
|
75
59
|
const errors = [];
|
|
76
60
|
const id = parseWorkspaceSchemaId(errors, flags.id)?.schemaId;
|
|
77
61
|
if (errors.length > 0) {
|
|
@@ -79,22 +63,17 @@ export class ListSchemaCommand extends SanityCommand {
|
|
|
79
63
|
exit: 1
|
|
80
64
|
});
|
|
81
65
|
}
|
|
82
|
-
|
|
83
|
-
|
|
66
|
+
await listSchemas({
|
|
67
|
+
configPath: projectRoot.path,
|
|
84
68
|
id,
|
|
85
69
|
json: !!flags.json,
|
|
86
|
-
manifestDir: flags['manifest-dir'],
|
|
87
70
|
output: this.output,
|
|
88
|
-
workDir
|
|
71
|
+
workDir: projectRoot.directory
|
|
89
72
|
});
|
|
90
|
-
if (result === 'failure') {
|
|
91
|
-
this.error('Failed to list schemas', {
|
|
92
|
-
exit: 1
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
73
|
} catch (error) {
|
|
96
74
|
schemasListDebug('Failed to list schemas', error);
|
|
97
|
-
|
|
75
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
76
|
+
this.error(`Failed to list schemas:\n${errorMessage}`, {
|
|
98
77
|
exit: 1
|
|
99
78
|
});
|
|
100
79
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/commands/schema/list.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\nimport {SanityCommand} from '@sanity/cli-core'\n\nimport {listSchemas} from '../../actions/schema/listSchemas.js'\nimport {schemasListDebug} from '../../actions/schema/utils/debug.js'\nimport {parseWorkspaceSchemaId} from '../../actions/schema/utils/schemaStoreValidation.js'\
|
|
1
|
+
{"version":3,"sources":["../../../src/commands/schema/list.ts"],"sourcesContent":["import {Flags} from '@oclif/core'\nimport {SanityCommand} from '@sanity/cli-core'\n\nimport {listSchemas} from '../../actions/schema/listSchemas.js'\nimport {schemasListDebug} from '../../actions/schema/utils/debug.js'\nimport {parseWorkspaceSchemaId} from '../../actions/schema/utils/schemaStoreValidation.js'\n\nconst description = `\nLists all schemas in the current dataset.\n\n**Note**: This command is experimental and subject to change.\n\nThis operation (re-)generates a manifest file describing the sanity config workspace by default.\nTo re-use an existing manifest file, use --no-extract-manifest.\n`.trim()\n\nexport class ListSchemaCommand extends SanityCommand<typeof ListSchemaCommand> {\n static override description = description\n\n static override examples = [\n {\n command: '<%= config.bin %> <%= command.id %>',\n description: 'List all schemas found in any workspace dataset in a table',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --id _.schemas.workspaceName',\n description: 'Get a schema for a given id',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --json',\n description: 'Get stored schemas as pretty-printed json-array',\n },\n {\n command: '<%= config.bin %> <%= command.id %> --json --id _.schemas.workspaceName',\n description: 'Get singular stored schema as pretty-printed json-object',\n },\n ]\n\n static override flags = {\n 'extract-manifest': Flags.boolean({\n allowNo: true,\n default: true,\n description: 'Disables manifest generation - the command will fail if no manifest exists',\n hidden: true,\n }),\n id: Flags.string({\n description: 'Fetch a single schema by id',\n helpValue: '<schema_id>',\n }),\n json: Flags.boolean({\n description: 'Get schema as json',\n }),\n 'manifest-dir': Flags.directory({\n default: './dist/static',\n description: 'Directory containing manifest file',\n helpValue: '<directory>',\n hidden: true,\n }),\n }\n\n public async run(): Promise<void> {\n const {flags} = await this.parse(ListSchemaCommand)\n\n try {\n const projectRoot = await this.getProjectRoot()\n\n const errors: string[] = []\n const id = parseWorkspaceSchemaId(errors, flags.id)?.schemaId\n if (errors.length > 0) {\n this.error(`Invalid arguments:\\n${errors.map((error) => ` - ${error}`).join('\\n')}`, {\n exit: 1,\n })\n }\n\n await listSchemas({\n configPath: projectRoot.path,\n id,\n json: !!flags.json,\n output: this.output,\n workDir: projectRoot.directory,\n })\n } catch (error) {\n schemasListDebug('Failed to list schemas', error)\n\n const errorMessage = error instanceof Error ? error.message : String(error)\n this.error(`Failed to list schemas:\\n${errorMessage}`, {exit: 1})\n }\n }\n}\n"],"names":["Flags","SanityCommand","listSchemas","schemasListDebug","parseWorkspaceSchemaId","description","trim","ListSchemaCommand","examples","command","flags","boolean","allowNo","default","hidden","id","string","helpValue","json","directory","run","parse","projectRoot","getProjectRoot","errors","schemaId","length","error","map","join","exit","configPath","path","output","workDir","errorMessage","Error","message","String"],"mappings":"AAAA,SAAQA,KAAK,QAAO,cAAa;AACjC,SAAQC,aAAa,QAAO,mBAAkB;AAE9C,SAAQC,WAAW,QAAO,sCAAqC;AAC/D,SAAQC,gBAAgB,QAAO,sCAAqC;AACpE,SAAQC,sBAAsB,QAAO,sDAAqD;AAE1F,MAAMC,cAAc,CAAC;;;;;;;AAOrB,CAAC,CAACC,IAAI;AAEN,OAAO,MAAMC,0BAA0BN;IACrC,OAAgBI,cAAcA,YAAW;IAEzC,OAAgBG,WAAW;QACzB;YACEC,SAAS;YACTJ,aAAa;QACf;QACA;YACEI,SAAS;YACTJ,aAAa;QACf;QACA;YACE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1,9 +1,8 @@
|
|
|
1
|
-
import { cliConfigSchema } from '@sanity/cli-core';
|
|
2
1
|
/**
|
|
3
2
|
* @deprecated Use `defineCliConfig` instead
|
|
4
3
|
* @public
|
|
5
4
|
*/ export function createCliConfig(config) {
|
|
6
|
-
return
|
|
5
|
+
return config;
|
|
7
6
|
}
|
|
8
7
|
|
|
9
8
|
//# sourceMappingURL=createCliConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/config/createCliConfig.ts"],"sourcesContent":["import {type CliConfig
|
|
1
|
+
{"version":3,"sources":["../../src/config/createCliConfig.ts"],"sourcesContent":["import {type CliConfig} from '@sanity/cli-core'\n\n/**\n * @deprecated Use `defineCliConfig` instead\n * @public\n */\nexport function createCliConfig(config: CliConfig): CliConfig {\n return config\n}\n"],"names":["createCliConfig","config"],"mappings":"AAEA;;;CAGC,GACD,OAAO,SAASA,gBAAgBC,MAAiB;IAC/C,OAAOA;AACT"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import {Schema} from '@sanity/types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Extracts all serializable properties from userland schema types,
|
|
5
|
+
* so they best-effort can be used as definitions for Schema.compile.
|
|
6
|
+
*
|
|
7
|
+
* @internal
|
|
8
|
+
*/
|
|
9
|
+
export declare function extractManifestSchemaTypes(
|
|
10
|
+
schema: Schema,
|
|
11
|
+
workDir: string,
|
|
12
|
+
): Promise<ManifestSchemaType[]>
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Get environment variables prefixed with SANITY_STUDIO_, as an object.
|
|
16
|
+
*
|
|
17
|
+
* @param options - Options for the environment variable loading
|
|
18
|
+
* {@link StudioEnvVariablesOptions}
|
|
19
|
+
* @returns Object of studio environment variables
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```tsx
|
|
23
|
+
* getStudioEnvironmentVariables({prefix: 'process.env.', jsonEncode: true})
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @public
|
|
27
|
+
*/
|
|
28
|
+
export declare function getStudioEnvironmentVariables(
|
|
29
|
+
options?: StudioEnvVariablesOptions,
|
|
30
|
+
): Record<string, string>
|
|
31
|
+
|
|
32
|
+
declare type ManifestArrayMember = Omit<ManifestSchemaType, 'name'> & {
|
|
33
|
+
name?: string
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare type ManifestField = ManifestSchemaType & {
|
|
37
|
+
fieldset?: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare interface ManifestFieldset {
|
|
41
|
+
[index: string]: ManifestSerializable | undefined
|
|
42
|
+
name: string
|
|
43
|
+
title?: string
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
declare type ManifestReferenceMember = Omit<ManifestSchemaType, 'name'> & {
|
|
47
|
+
name?: string
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
declare interface ManifestSchemaType {
|
|
51
|
+
name: string
|
|
52
|
+
type: string
|
|
53
|
+
deprecated?: {
|
|
54
|
+
reason: string
|
|
55
|
+
}
|
|
56
|
+
fields?: ManifestField[]
|
|
57
|
+
fieldsets?: ManifestFieldset[]
|
|
58
|
+
hidden?: 'conditional' | boolean
|
|
59
|
+
lists?: ManifestTitledValue[]
|
|
60
|
+
marks?: {
|
|
61
|
+
annotations?: ManifestArrayMember[]
|
|
62
|
+
decorators?: ManifestTitledValue[]
|
|
63
|
+
}
|
|
64
|
+
of?: ManifestArrayMember[]
|
|
65
|
+
options?: Record<string, ManifestSerializable>
|
|
66
|
+
preview?: {
|
|
67
|
+
select: Record<string, string>
|
|
68
|
+
}
|
|
69
|
+
readOnly?: 'conditional' | boolean
|
|
70
|
+
styles?: ManifestTitledValue[]
|
|
71
|
+
title?: string
|
|
72
|
+
to?: ManifestReferenceMember[]
|
|
73
|
+
validation?: ManifestValidationGroup[]
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
declare type ManifestSerializable =
|
|
77
|
+
| boolean
|
|
78
|
+
| ManifestSerializable[]
|
|
79
|
+
| number
|
|
80
|
+
| string
|
|
81
|
+
| {
|
|
82
|
+
[k: string]: ManifestSerializable
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
declare interface ManifestTitledValue {
|
|
86
|
+
value: string
|
|
87
|
+
title?: string
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
declare interface ManifestValidationGroup {
|
|
91
|
+
rules: ManifestValidationRule[]
|
|
92
|
+
level?: 'error' | 'info' | 'warning'
|
|
93
|
+
message?: string
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
declare type ManifestValidationRule = {
|
|
97
|
+
[index: string]: ManifestSerializable | undefined
|
|
98
|
+
constraint?: ManifestSerializable
|
|
99
|
+
flag: string
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* The params for the `getStudioEnvironmentVariables` function that gets Studio focused environment variables.
|
|
104
|
+
*
|
|
105
|
+
* @public
|
|
106
|
+
*/
|
|
107
|
+
export declare interface StudioEnvVariablesOptions {
|
|
108
|
+
/**
|
|
109
|
+
* When specified includes environment variables from dotenv files (`.env`), in the same way the studio does.
|
|
110
|
+
* A `mode` must be specified, usually `development`
|
|
111
|
+
* or `production`, which will load the corresponding `.env.development` or `.env.production`.
|
|
112
|
+
* To specify where to look for the dotenv files, specify `options.envFile.envDir`.
|
|
113
|
+
*/
|
|
114
|
+
envFile?:
|
|
115
|
+
| false
|
|
116
|
+
| {
|
|
117
|
+
envDir?: string
|
|
118
|
+
mode: string
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* When specified, JSON-encodes the values, which is handy if you want to pass
|
|
122
|
+
* this to a bundlers hardcoded defines, such as Vite's `define` or Webpack's `DefinePlugin`.
|
|
123
|
+
*/
|
|
124
|
+
jsonEncode?: boolean
|
|
125
|
+
/**
|
|
126
|
+
* When specified adds a prefix to the environment variable keys,
|
|
127
|
+
* eg: `getStudioEnvironmentVariables({prefix: 'process.env.'})`
|
|
128
|
+
*/
|
|
129
|
+
prefix?: string
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export {}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/exports/_internal.ts"],"sourcesContent":["export {getStudioEnvironmentVariables} from '../actions/build/getStudioEnvironmentVariables.js'\nexport type {StudioEnvVariablesOptions} from '../actions/build/getStudioEnvironmentVariables.js'\nexport {extractManifestSchemaTypes} from '../actions/manifest/extractWorkspaceManifest.js'\n"],"names":["getStudioEnvironmentVariables","extractManifestSchemaTypes"],"mappings":"AAAA,SAAQA,6BAA6B,QAAO,oDAAmD;AAE/F,SAAQC,0BAA0B,QAAO,kDAAiD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import {CliConfig} from '@sanity/cli-core'
|
|
2
|
+
import {ClientConfig} from '@sanity/client'
|
|
3
|
+
import {loadEnv} from 'vite'
|
|
4
|
+
import {PackageJson} from '@sanity/cli-core'
|
|
5
|
+
import {SanityClient} from '@sanity/client'
|
|
6
|
+
|
|
7
|
+
declare type CliClientGetter = ((options?: CliClientOptions) => SanityClient) & {
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated This is only for INTERNAL use, and should not be relied upon outside of official Sanity modules
|
|
10
|
+
* @returns A token to use when constructing a client without a `token` explicitly defined, or undefined
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
13
|
+
__internal__getToken: () => string | undefined
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare interface CliClientOptions extends ClientConfig {
|
|
20
|
+
/**
|
|
21
|
+
* If no `projectId` or `dataset` is provided, `getCliClient` will try to
|
|
22
|
+
* resolve these from the `sanity.cli.ts` configuration file. Use this option
|
|
23
|
+
* to specify the directory to look for this file.
|
|
24
|
+
*/
|
|
25
|
+
cwd?: string
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export {CliConfig}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @deprecated Use `defineCliConfig` instead
|
|
32
|
+
* @public
|
|
33
|
+
*/
|
|
34
|
+
export declare function createCliConfig(config: CliConfig): CliConfig
|
|
35
|
+
|
|
36
|
+
/** @beta */
|
|
37
|
+
export declare function defineCliConfig(config: CliConfig): CliConfig
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @public
|
|
41
|
+
*
|
|
42
|
+
* @param options - The options to use for the client.
|
|
43
|
+
* @returns A configured Sanity API client.
|
|
44
|
+
*/
|
|
45
|
+
export declare const getCliClient: CliClientGetter
|
|
46
|
+
|
|
47
|
+
export {loadEnv}
|
|
48
|
+
|
|
49
|
+
export {PackageJson}
|
|
50
|
+
|
|
51
|
+
export {}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { createCliConfig } from '../config/createCliConfig.js';
|
|
2
|
+
export { defineCliConfig } from '../config/defineCliConfig.js';
|
|
3
|
+
export { getCliClient } from '../util/cliClient.js';
|
|
4
|
+
export { loadEnv } from '../util/loadEnv.js';
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/exports/index.ts"],"sourcesContent":["export {createCliConfig} from '../config/createCliConfig.js'\nexport {defineCliConfig} from '../config/defineCliConfig.js'\nexport type {PackageJson} from '../types.js'\nexport {type CliClientOptions, getCliClient} from '../util/cliClient.js'\nexport {loadEnv} from '../util/loadEnv.js'\nexport type {CliConfig} from '@sanity/cli-core'\n"],"names":["createCliConfig","defineCliConfig","getCliClient","loadEnv"],"mappings":"AAAA,SAAQA,eAAe,QAAO,+BAA8B;AAC5D,SAAQC,eAAe,QAAO,+BAA8B;AAE5D,SAA+BC,YAAY,QAAO,uBAAsB;AACxE,SAAQC,OAAO,QAAO,qBAAoB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { updateChecker } from '../../util/update/updateChecker.js';
|
|
2
|
+
import { updateCheckerDebug } from '../../util/update/updateCheckerDebug.js';
|
|
3
|
+
/**
|
|
4
|
+
* Init hook that checks for CLI updates and notifies the user if a new version is available.
|
|
5
|
+
* This is non-blocking and will silently fail if anything goes wrong.
|
|
6
|
+
*/ export const checkForUpdates = async function({ config }) {
|
|
7
|
+
try {
|
|
8
|
+
await updateChecker(config);
|
|
9
|
+
} catch (err) {
|
|
10
|
+
updateCheckerDebug(`Error checking for updates: ${err}`);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=checkForUpdates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/hooks/init/checkForUpdates.ts"],"sourcesContent":["import {type Hook} from '@oclif/core'\n\nimport {updateChecker} from '../../util/update/updateChecker.js'\nimport {updateCheckerDebug} from '../../util/update/updateCheckerDebug.js'\n\n/**\n * Init hook that checks for CLI updates and notifies the user if a new version is available.\n * This is non-blocking and will silently fail if anything goes wrong.\n */\nexport const checkForUpdates: Hook.Init = async function ({config}) {\n try {\n await updateChecker(config)\n } catch (err) {\n updateCheckerDebug(`Error checking for updates: ${err}`)\n }\n}\n"],"names":["updateChecker","updateCheckerDebug","checkForUpdates","config","err"],"mappings":"AAEA,SAAQA,aAAa,QAAO,qCAAoC;AAChE,SAAQC,kBAAkB,QAAO,0CAAyC;AAE1E;;;CAGC,GACD,OAAO,MAAMC,kBAA6B,eAAgB,EAACC,MAAM,EAAC;IAChE,IAAI;QACF,MAAMH,cAAcG;IACtB,EAAE,OAAOC,KAAK;QACZH,mBAAmB,CAAC,4BAA4B,EAAEG,KAAK;IACzD;AACF,EAAC"}
|
|
@@ -15,8 +15,13 @@ export const setupTelemetry = async function({ config }) {
|
|
|
15
15
|
const telemetry = createTelemetryStore(sessionId, {
|
|
16
16
|
resolveConsent
|
|
17
17
|
});
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
let cliConfig;
|
|
19
|
+
try {
|
|
20
|
+
const projectRoot = await findProjectRoot(process.cwd());
|
|
21
|
+
cliConfig = await getCliConfig(projectRoot.directory);
|
|
22
|
+
} catch {
|
|
23
|
+
// Accept not finding a project root and/or CLI config
|
|
24
|
+
}
|
|
20
25
|
telemetry.updateUserProperties({
|
|
21
26
|
cliVersion: config.version,
|
|
22
27
|
cpuArchitecture: process.arch,
|