@sanity/cli 6.0.0-alpha.10 → 6.0.0-alpha.12
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 +29 -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.map +1 -1
- 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/index.d.ts +10 -2287
- 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 +45 -49
- package/package.json +18 -18
- 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/actions/schema/extractSchema.ts"],"sourcesContent":["import {mkdir, writeFile} from 'node:fs/promises'\nimport {join, resolve} from 'node:path'\n\nimport {exit} from '@oclif/core/errors'\nimport {\n getCliTelemetry,\n type Output,\n type ProjectRootResult,\n studioWorkerTask,\n} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {type extractSchema as extractSchemaInternal} from '@sanity/schema/_internal'\
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/schema/extractSchema.ts"],"sourcesContent":["import {mkdir, writeFile} from 'node:fs/promises'\nimport {join, resolve} from 'node:path'\n\nimport {exit} from '@oclif/core/errors'\nimport {\n getCliTelemetry,\n type Output,\n type ProjectRootResult,\n studioWorkerTask,\n} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport {type extractSchema as extractSchemaInternal} from '@sanity/schema/_internal'\n\nimport {type ExtractSchemaCommand} from '../../commands/schema/extract'\nimport {SchemaExtractedTrace} from '../../telemetry/extractSchema.telemetry.js'\nimport {formatSchemaValidation} from './formatSchemaValidation.js'\nimport {type ExtractSchemaWorkerData, type ExtractSchemaWorkerError} from './types.js'\nimport {schemasExtractDebug} from './utils/debug.js'\nimport {SchemaExtractionError} from './utils/SchemaExtractionError.js'\n\nconst FILENAME = 'schema.json'\n\ninterface ExtractSchemaOptions {\n flags: ExtractSchemaCommand['flags']\n output: Output\n projectRoot: ProjectRootResult\n}\n\ninterface ExtractSchemaWorkerResult {\n schema: ReturnType<typeof extractSchemaInternal>\n type: 'success'\n}\n\ntype ExtractSchemaWorkerMessage = ExtractSchemaWorkerError | ExtractSchemaWorkerResult\n\nexport async function extractSchema(options: ExtractSchemaOptions): Promise<void> {\n const {flags, output, projectRoot} = options\n const {\n 'enforce-required-fields': enforceRequiredFields,\n format,\n path,\n workspace: workspaceName,\n } = flags\n const spin = spinner(\n enforceRequiredFields ? 'Extracting schema with enforced required fields' : 'Extracting schema',\n ).start()\n\n const workDir = projectRoot.directory\n\n const trace = getCliTelemetry().trace(SchemaExtractedTrace)\n trace.start()\n\n try {\n if (format !== 'groq-type-nodes') {\n throw new Error(`Unsupported format: \"${format}\"`)\n }\n\n const result = await studioWorkerTask<ExtractSchemaWorkerMessage>(\n new URL('extractSanitySchema.worker.js', import.meta.url),\n {\n name: 'extractSanitySchema',\n studioRootPath: workDir,\n workerData: {\n configPath: projectRoot.path,\n enforceRequiredFields,\n workDir,\n workspaceName,\n } satisfies ExtractSchemaWorkerData,\n },\n )\n\n if (result.type === 'error') {\n throw new SchemaExtractionError(result.error, result.validation)\n }\n\n const schema = result.schema\n\n trace.log({\n enforceRequiredFields,\n schemaAllTypesCount: schema.length,\n schemaDocumentTypesCount: schema.filter((type) => type.type === 'document').length,\n schemaFormat: flags.format || 'groq-type-nodes',\n schemaTypesCount: schema.filter((type) => type.type === 'type').length,\n })\n\n const outputDir = path ? resolve(join(workDir, path)) : workDir\n const outputPath = join(outputDir, FILENAME)\n await mkdir(outputDir, {recursive: true})\n\n spin.text = `Writing schema to ${outputPath}`\n\n await writeFile(outputPath, `${JSON.stringify(schema, null, 2)}\\n`)\n\n spin.succeed(\n enforceRequiredFields\n ? `Extracted schema to ${outputPath} with enforced required fields`\n : `Extracted schema to ${outputPath}`,\n )\n\n trace.complete()\n } catch (err) {\n trace.error(err)\n schemasExtractDebug('Failed to extract schema', err)\n spin.fail(\n enforceRequiredFields\n ? 'Failed to extract schema with enforced required fields'\n : 'Failed to extract schema',\n )\n\n // Display validation errors if available\n if (err instanceof SchemaExtractionError && err.validation && err.validation.length > 0) {\n output.log('')\n output.log(formatSchemaValidation(err.validation))\n }\n\n if (err instanceof Error) {\n output.error(err.message, {exit: 1})\n }\n\n exit(1)\n }\n}\n"],"names":["mkdir","writeFile","join","resolve","exit","getCliTelemetry","studioWorkerTask","spinner","SchemaExtractedTrace","formatSchemaValidation","schemasExtractDebug","SchemaExtractionError","FILENAME","extractSchema","options","flags","output","projectRoot","enforceRequiredFields","format","path","workspace","workspaceName","spin","start","workDir","directory","trace","Error","result","URL","url","name","studioRootPath","workerData","configPath","type","error","validation","schema","log","schemaAllTypesCount","length","schemaDocumentTypesCount","filter","schemaFormat","schemaTypesCount","outputDir","outputPath","recursive","text","JSON","stringify","succeed","complete","err","fail","message"],"mappings":"AAAA,SAAQA,KAAK,EAAEC,SAAS,QAAO,mBAAkB;AACjD,SAAQC,IAAI,EAAEC,OAAO,QAAO,YAAW;AAEvC,SAAQC,IAAI,QAAO,qBAAoB;AACvC,SACEC,eAAe,EAGfC,gBAAgB,QACX,mBAAkB;AACzB,SAAQC,OAAO,QAAO,sBAAqB;AAI3C,SAAQC,oBAAoB,QAAO,6CAA4C;AAC/E,SAAQC,sBAAsB,QAAO,8BAA6B;AAElE,SAAQC,mBAAmB,QAAO,mBAAkB;AACpD,SAAQC,qBAAqB,QAAO,mCAAkC;AAEtE,MAAMC,WAAW;AAejB,OAAO,eAAeC,cAAcC,OAA6B;IAC/D,MAAM,EAACC,KAAK,EAAEC,MAAM,EAAEC,WAAW,EAAC,GAAGH;IACrC,MAAM,EACJ,2BAA2BI,qBAAqB,EAChDC,MAAM,EACNC,IAAI,EACJC,WAAWC,aAAa,EACzB,GAAG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CAAC,GACjE,CAAC,oBAAoB,EAAEA,YAAY;QAGzCrB,MAAM2B,QAAQ;IAChB,EAAE,OAAOC,KAAK;QACZ5B,MAAMU,KAAK,CAACkB;QACZ7C,oBAAoB,4BAA4B6C;QAChDhC,KAAKiC,IAAI,CACPtC,wBACI,2DACA;QAGN,yCAAyC;QACzC,IAAIqC,eAAe5C,yBAAyB4C,IAAIjB,UAAU,IAAIiB,IAAIjB,UAAU,CAACI,MAAM,GAAG,GAAG;YACvF1B,OAAOwB,GAAG,CAAC;YACXxB,OAAOwB,GAAG,CAAC/B,uBAAuB8C,IAAIjB,UAAU;QAClD;QAEA,IAAIiB,eAAe3B,OAAO;YACxBZ,OAAOqB,KAAK,CAACkB,IAAIE,OAAO,EAAE;gBAACrD,MAAM;YAAC;QACpC;QAEAA,KAAK;IACP;AACF"}
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { styleText } from 'node:util';
|
|
2
|
+
import { studioWorkerTask } from '@sanity/cli-core';
|
|
3
|
+
import { logSymbols } from '@sanity/cli-core/ux';
|
|
4
|
+
import { Table } from 'console-table-printer';
|
|
2
5
|
import { getSchemas } from '../../services/schemas.js';
|
|
3
6
|
import { isDefined } from '../manifest/schemaTypeHelpers.js';
|
|
4
|
-
import { schemasListDebug } from './utils/debug.js';
|
|
5
|
-
import { ensureManifestExtractSatisfied } from './utils/manifestExtractor.js';
|
|
6
|
-
import { createManifestReader } from './utils/manifestReader.js';
|
|
7
7
|
import { getDatasetsOutString } from './utils/schemaStoreOutStrings.js';
|
|
8
8
|
import { SCHEMA_PERMISSION_HELP_TEXT } from './utils/schemaStoreValidation.js';
|
|
9
|
-
import { uniqByProjectIdDataset } from './utils/uniqByProjectIdDataset.js';
|
|
10
9
|
class DatasetError extends Error {
|
|
11
10
|
dataset;
|
|
12
11
|
projectId;
|
|
@@ -18,43 +17,32 @@ class DatasetError extends Error {
|
|
|
18
17
|
}
|
|
19
18
|
}
|
|
20
19
|
export async function listSchemas(options) {
|
|
21
|
-
const {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
})
|
|
29
|
-
return 'failure';
|
|
30
|
-
}
|
|
31
|
-
const manifest = await createManifestReader({
|
|
32
|
-
manifestDir,
|
|
33
|
-
output,
|
|
34
|
-
workDir
|
|
35
|
-
}).getManifest();
|
|
36
|
-
const projectDatasets = uniqByProjectIdDataset(manifest.workspaces);
|
|
20
|
+
const { configPath, id, json, output, workDir } = options;
|
|
21
|
+
const projectDatasets = await studioWorkerTask(new URL('uniqueWorkspaces.worker.js', import.meta.url), {
|
|
22
|
+
name: 'uniqueWorkspaces',
|
|
23
|
+
studioRootPath: workDir,
|
|
24
|
+
workerData: {
|
|
25
|
+
configPath
|
|
26
|
+
}
|
|
27
|
+
});
|
|
37
28
|
const schemas = await getDatasetSchemas(projectDatasets, id);
|
|
38
29
|
const parsedSchemas = parseSchemas(schemas, output);
|
|
39
30
|
if (parsedSchemas.length === 0) {
|
|
40
31
|
const datasetString = getDatasetsOutString(projectDatasets.map((dataset)=>dataset.dataset));
|
|
41
|
-
|
|
42
|
-
schemasListDebug('Error finding schema');
|
|
43
|
-
return 'failure';
|
|
32
|
+
throw new Error(id ? `Schema for id "${id}" not found in ${datasetString}` : `No schemas found in ${datasetString}`);
|
|
44
33
|
}
|
|
45
34
|
if (json) {
|
|
46
|
-
output.log(
|
|
35
|
+
output.log(JSON.stringify(id ? parsedSchemas[0] : parsedSchemas, null, 2));
|
|
47
36
|
} else {
|
|
48
37
|
printSchemas({
|
|
49
|
-
manifest,
|
|
50
38
|
output,
|
|
51
|
-
schemas: parsedSchemas
|
|
39
|
+
schemas: parsedSchemas,
|
|
40
|
+
workspaces: projectDatasets
|
|
52
41
|
});
|
|
53
42
|
}
|
|
54
|
-
return 'success';
|
|
55
43
|
}
|
|
56
44
|
async function getDatasetSchemas(projectDatasets, id) {
|
|
57
|
-
return
|
|
45
|
+
return Promise.allSettled(projectDatasets.map(async ({ dataset, projectId })=>{
|
|
58
46
|
try {
|
|
59
47
|
return await getSchemas(dataset, projectId, id);
|
|
60
48
|
} catch (error) {
|
|
@@ -74,46 +62,55 @@ function parseSchemas(schemas, output) {
|
|
|
74
62
|
const error = schema.reason;
|
|
75
63
|
if (error instanceof DatasetError) {
|
|
76
64
|
if ('cause' in error && error.cause && typeof error.cause === 'object' && 'statusCode' in error.cause && error.cause.statusCode === 401) {
|
|
77
|
-
output.
|
|
65
|
+
output.log(styleText('yellow', `${logSymbols.warning} ↳ No permissions to read schema from "${error.dataset}". ${SCHEMA_PERMISSION_HELP_TEXT}:\n ${styleText('red', `${error.message}`)}`));
|
|
78
66
|
return [];
|
|
79
67
|
}
|
|
80
|
-
|
|
81
|
-
|
|
68
|
+
output.log(styleText('red', `↳ Failed to fetch schema from "${error.dataset}":\n ${error.message}`));
|
|
69
|
+
return [];
|
|
82
70
|
} else {
|
|
83
71
|
//hubris inc: given the try-catch wrapping all the full promise "this should never happen"
|
|
84
72
|
throw error;
|
|
85
73
|
}
|
|
86
74
|
}).filter((schema)=>isDefined(schema)).flat();
|
|
87
75
|
}
|
|
88
|
-
function printSchemas({
|
|
76
|
+
function printSchemas({ output, schemas, workspaces }) {
|
|
89
77
|
const rows = schemas.toSorted((a, b)=>-(a._createdAt || '').localeCompare(b._createdAt || '')).map(({ _createdAt: createdAt, _id: id, workspace })=>{
|
|
90
|
-
const workspaceData =
|
|
78
|
+
const workspaceData = workspaces.find((w)=>w.name === workspace.name);
|
|
91
79
|
if (!workspaceData) return;
|
|
92
|
-
return
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
workspaceData.projectId,
|
|
97
|
-
|
|
98
|
-
|
|
80
|
+
return {
|
|
81
|
+
CreatedAt: createdAt,
|
|
82
|
+
Dataset: workspaceData.dataset,
|
|
83
|
+
Id: id,
|
|
84
|
+
ProjectId: workspaceData.projectId,
|
|
85
|
+
Workspace: workspace.name
|
|
86
|
+
};
|
|
99
87
|
}).filter((schema)=>isDefined(schema));
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
88
|
+
const table = new Table({
|
|
89
|
+
columns: [
|
|
90
|
+
{
|
|
91
|
+
alignment: 'left',
|
|
92
|
+
name: 'Id'
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
alignment: 'left',
|
|
96
|
+
name: 'Workspace'
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
alignment: 'left',
|
|
100
|
+
name: 'Dataset'
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
alignment: 'left',
|
|
104
|
+
name: 'ProjectId'
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
alignment: 'left',
|
|
108
|
+
name: 'CreatedAt'
|
|
109
|
+
}
|
|
110
|
+
]
|
|
113
111
|
});
|
|
114
|
-
|
|
115
|
-
output.log(
|
|
116
|
-
for (const row of rows)output.log(rowToString(row));
|
|
112
|
+
table.addRows(rows);
|
|
113
|
+
output.log(table.render());
|
|
117
114
|
}
|
|
118
115
|
|
|
119
116
|
//# sourceMappingURL=listSchemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/schema/listSchemas.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {type Output} from '@sanity/cli-core'\
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/schema/listSchemas.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {type Output, studioWorkerTask} from '@sanity/cli-core'\nimport {logSymbols} from '@sanity/cli-core/ux'\nimport {Table} from 'console-table-printer'\nimport {type Workspace} from 'sanity'\n\nimport {getSchemas} from '../../services/schemas.js'\nimport {isDefined} from '../manifest/schemaTypeHelpers.js'\nimport {type StoredWorkspaceSchema} from '../manifest/types.js'\nimport {type UniqWorkspaceWorkerData} from './types.js'\nimport {getDatasetsOutString} from './utils/schemaStoreOutStrings.js'\nimport {SCHEMA_PERMISSION_HELP_TEXT} from './utils/schemaStoreValidation.js'\n\ninterface ListSchemasOptions {\n configPath: string\n json: boolean\n output: Output\n workDir: string\n\n id?: string\n}\n\nclass DatasetError extends Error {\n public dataset: string\n public projectId: string\n constructor(args: {dataset: string; options?: ErrorOptions; projectId: string}) {\n super((args.options?.cause as {message?: string})?.message, args.options)\n this.projectId = args.projectId\n this.dataset = args.dataset\n this.name = 'DatasetError'\n }\n}\n\nexport async function listSchemas(options: ListSchemasOptions): Promise<void> {\n const {configPath, id, json, output, workDir} = options\n\n const projectDatasets = await studioWorkerTask<(Workspace & {key: string})[]>(\n new URL('uniqueWorkspaces.worker.js', import.meta.url),\n {\n name: 'uniqueWorkspaces',\n studioRootPath: workDir,\n workerData: {configPath} satisfies UniqWorkspaceWorkerData,\n },\n )\n\n const schemas = await getDatasetSchemas(projectDatasets, id)\n const parsedSchemas = parseSchemas(schemas, output)\n\n if (parsedSchemas.length === 0) {\n const datasetString = getDatasetsOutString(projectDatasets.map((dataset) => dataset.dataset))\n\n throw new Error(\n id\n ? `Schema for id \"${id}\" not found in ${datasetString}`\n : `No schemas found in ${datasetString}`,\n )\n }\n\n if (json) {\n output.log(JSON.stringify(id ? parsedSchemas[0] : parsedSchemas, null, 2))\n } else {\n printSchemas({output, schemas: parsedSchemas, workspaces: projectDatasets})\n }\n}\n\nasync function getDatasetSchemas(projectDatasets: Workspace[], id?: string) {\n return Promise.allSettled(\n projectDatasets.map(async ({dataset, projectId}) => {\n try {\n return await getSchemas(dataset, projectId, id)\n } catch (error) {\n throw new DatasetError({dataset, options: {cause: error}, projectId})\n }\n }),\n )\n}\n\nfunction parseSchemas(schemas: PromiseSettledResult<StoredWorkspaceSchema[]>[], output: Output) {\n return schemas\n .map((schema) => {\n if (schema.status === 'fulfilled') return schema.value\n\n const error = schema.reason\n\n if (error instanceof DatasetError) {\n if (\n 'cause' in error &&\n error.cause &&\n typeof error.cause === 'object' &&\n 'statusCode' in error.cause &&\n error.cause.statusCode === 401\n ) {\n output.log(\n styleText(\n 'yellow',\n `${logSymbols.warning} ↳ No permissions to read schema from \"${error.dataset}\". ${\n SCHEMA_PERMISSION_HELP_TEXT\n }:\\n ${styleText('red', `${error.message}`)}`,\n ),\n )\n return []\n }\n\n output.log(\n styleText('red', `↳ Failed to fetch schema from \"${error.dataset}\":\\n ${error.message}`),\n )\n return []\n } else {\n //hubris inc: given the try-catch wrapping all the full promise \"this should never happen\"\n throw error\n }\n })\n .filter((schema) => isDefined(schema))\n .flat()\n}\n\nfunction printSchemas({\n output,\n schemas,\n workspaces,\n}: {\n output: Output\n schemas: StoredWorkspaceSchema[]\n workspaces: Workspace[]\n}) {\n const rows = schemas\n .toSorted((a, b) => -(a._createdAt || '').localeCompare(b._createdAt || ''))\n .map(({_createdAt: createdAt, _id: id, workspace}) => {\n const workspaceData = workspaces.find((w) => w.name === workspace.name)\n if (!workspaceData) return\n\n return {\n CreatedAt: createdAt,\n Dataset: workspaceData.dataset,\n Id: id,\n ProjectId: workspaceData.projectId,\n Workspace: workspace.name,\n }\n })\n .filter((schema) => isDefined(schema))\n\n const table = new Table({\n columns: [\n {alignment: 'left', name: 'Id'},\n {alignment: 'left', name: 'Workspace'},\n {alignment: 'left', name: 'Dataset'},\n {alignment: 'left', name: 'ProjectId'},\n {alignment: 'left', name: 'CreatedAt'},\n ],\n })\n\n table.addRows(rows)\n output.log(table.render())\n}\n"],"names":["styleText","studioWorkerTask","logSymbols","Table","getSchemas","isDefined","getDatasetsOutString","SCHEMA_PERMISSION_HELP_TEXT","DatasetError","Error","dataset","projectId","args","options","cause","message","name","listSchemas","configPath","id","json","output","workDir","projectDatasets","URL","url","studioRootPath","workerData","schemas","getDatasetSchemas","parsedSchemas","parseSchemas","length","datasetString","map","log","JSON","stringify","printSchemas","workspaces","Promise","allSettled","error","schema","status","value","reason","statusCode","warning","filter","flat","rows","toSorted","a","b","_createdAt","localeCompare","createdAt","_id","workspace","workspaceData","find","w","CreatedAt","Dataset","Id","ProjectId","Workspace","table","columns","alignment","addRows","render"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAEnC,SAAqBC,gBAAgB,QAAO,mBAAkB;AAC9D,SAAQC,UAAU,QAAO,sBAAqB;AAC9C,SAAQC,KAAK,QAAO,wBAAuB;AAG3C,SAAQC,UAAU,QAAO,4BAA2B;AACpD,SAAQC,SAAS,QAAO,mCAAkC;AAG1D,SAAQC,oBAAoB,QAAO,mCAAkC;AACrE,SAAQC,2BAA2B,QAAO,mCAAkC;AAW5E,MAAMC,qBAAqBC;IAClBC,QAAe;IACfC,UAAiB;IACxB,YAAYC,IAAkE,CAAE;QAC9E,KAAK,CAAEA,KAAKC,OAAO,EAAEC,OAA8BC,SAASH,KAAKC,OAAO;QACxE,IAAI,CAACF,SAAS,GAAGC,KAAKD,SAAS;QAC/B,IAAI,CAACD,OAAO,GAAGE,KAAKF,OAAO;QAC3B,IAAI,CAACM,IAAI,GAAG;IACd;AACF;AAEA,OAAO,eAAeC,YAAYJ,OAA2B;IAC3D,MAAM,EAACK,UAAU,EAAEC,EAAE,EAAEC,IAAI,EAAEC,MAAM,EAAEC,OAAO,EAAC,GAAGT;IAEhD,MAAMU,kBAAkB,MAAMtB,iBAC5B,IAAIuB,IAAI,8BAA8B,YAAYC,GAAG,GACrD;QACET,MAAM;QACNU,gBAAgBJ;QAChBK,YAAY;YAACT;QAAU;IACzB;IAGF,MAAMU,UAAU,MAAMC,kBAAkBN,iBAAiBJ;IACzD,MAAMW,gBAAgBC,aAAaH,SAASP;IAE5C,IAAIS,cAAcE,MAAM,KAAK,GAAG;QAC9B,MAAMC,gBAAgB3B,qBAAqBiB,gBAAgBW,GAAG,CAAC,CAACxB,UAAYA,QAAQA,OAAO;QAE3F,MAAM,IAAID,MACRU,KACI,CAAC,eAAe,EAAEA,GAAG,eAAe,EAAEc,eAAe,GACr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AAE;YAE1F,OAAO,EAAE;QACX,OAAO;YACL,0FAA0F;YAC1F,MAAM2B;QACR;IACF,GACCO,MAAM,CAAC,CAACN,SAAWtC,UAAUsC,SAC7BO,IAAI;AACT;AAEA,SAASZ,aAAa,EACpBjB,MAAM,EACNO,OAAO,EACPW,UAAU,EAKX;IACC,MAAMY,OAAOvB,QACVwB,QAAQ,CAAC,CAACC,GAAGC,IAAM,CAAC,AAACD,CAAAA,EAAEE,UAAU,IAAI,EAAC,EAAGC,aAAa,CAACF,EAAEC,UAAU,IAAI,KACvErB,GAAG,CAAC,CAAC,EAACqB,YAAYE,SAAS,EAAEC,KAAKvC,EAAE,EAAEwC,SAAS,EAAC;QAC/C,MAAMC,gBAAgBrB,WAAWsB,IAAI,CAAC,CAACC,IAAMA,EAAE9C,IAAI,KAAK2C,UAAU3C,IAAI;QACtE,IAAI,CAAC4C,eAAe;QAEpB,OAAO;YACLG,WAAWN;YACXO,SAASJ,cAAclD,OAAO;YAC9BuD,IAAI9C;YACJ+C,WAAWN,cAAcjD,SAAS;YAClCwD,WAAWR,UAAU3C,IAAI;QAC3B;IACF,GACCiC,MAAM,CAAC,CAACN,SAAWtC,UAAUsC;IAEhC,MAAMyB,QAAQ,IAAIjE,MAAM;QACtBkE,SAAS;YACP;gBAACC,WAAW;gBAAQtD,MAAM;YAAI;YAC9B;gBAACsD,WAAW;gBAAQtD,MAAM;YAAW;YACrC;gBAACsD,WAAW;gBAAQtD,MAAM;YAAS;YACnC;gBAACsD,WAAW;gBAAQtD,MAAM;YAAW;YACrC;gBAACsD,WAAW;gBAAQtD,MAAM;YAAW;SACtC;IACH;IAEAoD,MAAMG,OAAO,CAACpB;IACd9B,OAAOc,GAAG,CAACiC,MAAMI,MAAM;AACzB"}
|
|
@@ -5,5 +5,9 @@ export const extractSchemaWorkerData = z.object({
|
|
|
5
5
|
workDir: z.string(),
|
|
6
6
|
workspaceName: z.string().optional()
|
|
7
7
|
});
|
|
8
|
+
export const uniqWorkspaceWorkerDataSchema = z.object({
|
|
9
|
+
configPath: z.string(),
|
|
10
|
+
dataset: z.string().optional()
|
|
11
|
+
});
|
|
8
12
|
|
|
9
13
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/schema/types.ts"],"sourcesContent":["import {z} from 'zod'\n\nexport const extractSchemaWorkerData = z.object({\n configPath: z.string(),\n enforceRequiredFields: z.boolean(),\n workDir: z.string(),\n workspaceName: z.string().optional(),\n})\n\nexport type ExtractSchemaWorkerData = z.infer<typeof extractSchemaWorkerData>\n\n/**\n * Contains debug information about the serialized schema.\n *\n * @internal\n **/\nexport type SerializedSchemaDebug = {\n hoisted: Record<string, SerializedTypeDebug>\n parent?: SerializedSchemaDebug\n size: number\n types: Record<string, SerializedTypeDebug>\n}\n\n/**\n * Contains debug information about a serialized type.\n *\n * @internal\n **/\nexport type SerializedTypeDebug = {\n extends: string\n fields?: Record<string, SerializedTypeDebug>\n of?: Record<string, SerializedTypeDebug>\n size: number\n}\n"],"names":["z","extractSchemaWorkerData","object","configPath","string","enforceRequiredFields","boolean","workDir","workspaceName","optional"],"mappings":"
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/schema/types.ts"],"sourcesContent":["import {type SchemaValidationProblemGroup} from '@sanity/types'\nimport {z} from 'zod'\n\nexport const extractSchemaWorkerData = z.object({\n configPath: z.string(),\n enforceRequiredFields: z.boolean(),\n workDir: z.string(),\n workspaceName: z.string().optional(),\n})\n\nexport type ExtractSchemaWorkerData = z.infer<typeof extractSchemaWorkerData>\n\n/**\n * Contains debug information about the serialized schema.\n *\n * @internal\n **/\nexport type SerializedSchemaDebug = {\n hoisted: Record<string, SerializedTypeDebug>\n parent?: SerializedSchemaDebug\n size: number\n types: Record<string, SerializedTypeDebug>\n}\n\n/**\n * Contains debug information about a serialized type.\n *\n * @internal\n **/\nexport type SerializedTypeDebug = {\n extends: string\n fields?: Record<string, SerializedTypeDebug>\n of?: Record<string, SerializedTypeDebug>\n size: number\n}\n\n/** @internal */\nexport interface ExtractSchemaWorkerError {\n error: string\n type: 'error'\n\n validation?: SchemaValidationProblemGroup[]\n}\n\nexport const uniqWorkspaceWorkerDataSchema = z.object({\n configPath: z.string(),\n dataset: z.string().optional(),\n})\n\nexport type UniqWorkspaceWorkerData = z.infer<typeof uniqWorkspaceWorkerDataSchema>\n"],"names":["z","extractSchemaWorkerData","object","configPath","string","enforceRequiredFields","boolean","workDir","workspaceName","optional","uniqWorkspaceWorkerDataSchema","dataset"],"mappings":"AACA,SAAQA,CAAC,QAAO,MAAK;AAErB,OAAO,MAAMC,0BAA0BD,EAAEE,MAAM,CAAC;IAC9CC,YAAYH,EAAEI,MAAM;IACpBC,uBAAuBL,EAAEM,OAAO;IAChCC,SAASP,EAAEI,MAAM;IACjBI,eAAeR,EAAEI,MAAM,GAAGK,QAAQ;AACpC,GAAE;AAoCF,OAAO,MAAMC,gCAAgCV,EAAEE,MAAM,CAAC;IACpDC,YAAYH,EAAEI,MAAM;IACpBO,SAASX,EAAEI,MAAM,GAAGK,QAAQ;AAC9B,GAAE"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isMainThread, parentPort, workerData } from 'node:worker_threads';
|
|
2
|
+
import { getStudioWorkspaces, safeStructuredClone } from '@sanity/cli-core';
|
|
3
|
+
import { uniqWorkspaceWorkerDataSchema } from './types.js';
|
|
4
|
+
import { uniqByProjectIdDataset } from './utils/uniqByProjectIdDataset.js';
|
|
5
|
+
if (isMainThread || !parentPort) {
|
|
6
|
+
throw new Error('Should only be run in a worker!');
|
|
7
|
+
}
|
|
8
|
+
const { configPath, dataset } = uniqWorkspaceWorkerDataSchema.parse(workerData);
|
|
9
|
+
try {
|
|
10
|
+
const workspaces = await getStudioWorkspaces(configPath);
|
|
11
|
+
let filteredWorkspaces = workspaces;
|
|
12
|
+
// If a dataset is provided, filter the workspaces to only include those with the same dataset
|
|
13
|
+
if (dataset) {
|
|
14
|
+
filteredWorkspaces = workspaces.filter((workspace)=>workspace.dataset === dataset);
|
|
15
|
+
}
|
|
16
|
+
const uniqueWorkspaces = uniqByProjectIdDataset(filteredWorkspaces);
|
|
17
|
+
parentPort.postMessage(safeStructuredClone(uniqueWorkspaces));
|
|
18
|
+
} catch (error) {
|
|
19
|
+
throw new Error(error instanceof Error ? error.message : String(error));
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=uniqueWorkspaces.worker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/schema/uniqueWorkspaces.worker.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData} from 'node:worker_threads'\n\nimport {getStudioWorkspaces, safeStructuredClone} from '@sanity/cli-core'\n\nimport {uniqWorkspaceWorkerDataSchema} from './types.js'\nimport {uniqByProjectIdDataset} from './utils/uniqByProjectIdDataset.js'\n\nif (isMainThread || !parentPort) {\n throw new Error('Should only be run in a worker!')\n}\n\nconst {configPath, dataset} = uniqWorkspaceWorkerDataSchema.parse(workerData)\n\ntry {\n const workspaces = await getStudioWorkspaces(configPath)\n\n let filteredWorkspaces = workspaces\n // If a dataset is provided, filter the workspaces to only include those with the same dataset\n if (dataset) {\n filteredWorkspaces = workspaces.filter((workspace) => workspace.dataset === dataset)\n }\n\n const uniqueWorkspaces = uniqByProjectIdDataset(filteredWorkspaces)\n\n parentPort.postMessage(safeStructuredClone(uniqueWorkspaces))\n} catch (error) {\n throw new Error(error instanceof Error ? error.message : String(error))\n}\n"],"names":["isMainThread","parentPort","workerData","getStudioWorkspaces","safeStructuredClone","uniqWorkspaceWorkerDataSchema","uniqByProjectIdDataset","Error","configPath","dataset","parse","workspaces","filteredWorkspaces","filter","workspace","uniqueWorkspaces","postMessage","error","message","String"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,UAAU,EAAEC,UAAU,QAAO,sBAAqB;AAExE,SAAQC,mBAAmB,EAAEC,mBAAmB,QAAO,mBAAkB;AAEzE,SAAQC,6BAA6B,QAAO,aAAY;AACxD,SAAQC,sBAAsB,QAAO,oCAAmC;AAExE,IAAIN,gBAAgB,CAACC,YAAY;IAC/B,MAAM,IAAIM,MAAM;AAClB;AAEA,MAAM,EAACC,UAAU,EAAEC,OAAO,EAAC,GAAGJ,8BAA8BK,KAAK,CAACR;AAElE,IAAI;IACF,MAAMS,aAAa,MAAMR,oBAAoBK;IAE7C,IAAII,qBAAqBD;IACzB,8FAA8F;IAC9F,IAAIF,SAAS;QACXG,qBAAqBD,WAAWE,MAAM,CAAC,CAACC,YAAcA,UAAUL,OAAO,KAAKA;IAC9E;IAEA,MAAMM,mBAAmBT,uBAAuBM;IAEhDX,WAAWe,WAAW,CAACZ,oBAAoBW;AAC7C,EAAE,OAAOE,OAAO;IACd,MAAM,IAAIV,MAAMU,iBAAiBV,QAAQU,MAAMC,OAAO,GAAGC,OAAOF;AAClE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/schema/utils/SchemaExtractionError.ts"],"sourcesContent":["import {type SchemaValidationProblemGroup} from '@sanity/types'\n\nexport class SchemaExtractionError extends Error {\n validation?: SchemaValidationProblemGroup[]\n\n constructor(message: string, validation?: SchemaValidationProblemGroup[]) {\n super(message)\n this.name = 'SchemaExtractionError'\n this.validation = validation\n }\n}\n"],"names":["SchemaExtractionError","Error","validation","message","name"],"mappings":"AAEA,OAAO,MAAMA,8BAA8BC;IACzCC,WAA2C;IAE3C,YAAYC,OAAe,EAAED,UAA2C,CAAE;QACxE,KAAK,CAACC;QACN,IAAI,CAACC,IAAI,GAAG;QACZ,IAAI,CAACF,UAAU,GAAGA;IACpB;AACF"}
|
|
@@ -2,19 +2,15 @@ import { styleText } from 'node:util';
|
|
|
2
2
|
import { extractManifestSafe } from '../../manifest/extractManifest.js';
|
|
3
3
|
import { FlagValidationError } from './schemaStoreValidation.js';
|
|
4
4
|
export async function ensureManifestExtractSatisfied(args) {
|
|
5
|
-
const { extractManifest, manifestDir, manifestSafe, output, schemaRequired
|
|
5
|
+
const { extractManifest, manifestDir, manifestSafe, output, schemaRequired } = args;
|
|
6
6
|
if (!extractManifest) {
|
|
7
7
|
return true;
|
|
8
8
|
}
|
|
9
9
|
try {
|
|
10
10
|
// a successful manifest extract will write a new manifest file, which manifestReader will then read from disk
|
|
11
11
|
const error = await extractManifestSafe({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
path: manifestDir
|
|
15
|
-
},
|
|
16
|
-
output,
|
|
17
|
-
workDir
|
|
12
|
+
outPath: manifestDir,
|
|
13
|
+
output
|
|
18
14
|
});
|
|
19
15
|
if (!manifestSafe && error) {
|
|
20
16
|
throw error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/schema/utils/manifestExtractor.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {type Output} from '@sanity/cli-core'\n\nimport {extractManifestSafe} from '../../manifest/extractManifest.js'\nimport {FlagValidationError} from './schemaStoreValidation.js'\n\nexport async function ensureManifestExtractSatisfied(args: {\n extractManifest: boolean\n manifestDir: string\n manifestSafe?: boolean\n output: Output\n schemaRequired?: boolean\n workDir: string\n}) {\n const {extractManifest, manifestDir, manifestSafe, output, schemaRequired
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/schema/utils/manifestExtractor.ts"],"sourcesContent":["import {styleText} from 'node:util'\n\nimport {type Output} from '@sanity/cli-core'\n\nimport {extractManifestSafe} from '../../manifest/extractManifest.js'\nimport {FlagValidationError} from './schemaStoreValidation.js'\n\nexport async function ensureManifestExtractSatisfied(args: {\n extractManifest: boolean\n manifestDir: string\n manifestSafe?: boolean\n output: Output\n schemaRequired?: boolean\n workDir: string\n}) {\n const {extractManifest, manifestDir, manifestSafe, output, schemaRequired} = args\n if (!extractManifest) {\n return true\n }\n try {\n // a successful manifest extract will write a new manifest file, which manifestReader will then read from disk\n const error = await extractManifestSafe({\n outPath: manifestDir,\n output,\n })\n\n if (!manifestSafe && error) {\n throw error\n }\n\n return true\n } catch (err) {\n if (schemaRequired || err instanceof FlagValidationError) {\n throw err\n } else {\n output.log(styleText('gray', `↳ Failed to extract manifest:\\n ${err.message}`))\n return false\n }\n }\n}\n"],"names":["styleText","extractManifestSafe","FlagValidationError","ensureManifestExtractSatisfied","args","extractManifest","manifestDir","manifestSafe","output","schemaRequired","error","outPath","err","log","message"],"mappings":"AAAA,SAAQA,SAAS,QAAO,YAAW;AAInC,SAAQC,mBAAmB,QAAO,oCAAmC;AACrE,SAAQC,mBAAmB,QAAO,6BAA4B;AAE9D,OAAO,eAAeC,+BAA+BC,IAOpD;IACC,MAAM,EAACC,eAAe,EAAEC,WAAW,EAAEC,YAAY,EAAEC,MAAM,EAAEC,cAAc,EAAC,GAAGL;IAC7E,IAAI,CAACC,iBAAiB;QACpB,OAAO;IACT;IACA,IAAI;QACF,8GAA8G;QAC9G,MAAMK,QAAQ,MAAMT,oBAAoB;YACtCU,SAASL;YACTE;QACF;QAEA,IAAI,CAACD,gBAAgBG,OAAO;YAC1B,MAAMA;QACR;QAEA,OAAO;IACT,EAAE,OAAOE,KAAK;QACZ,IAAIH,kBAAkBG,eAAeV,qBAAqB;YACxD,MAAMU;QACR,OAAO;YACLJ,OAAOK,GAAG,CAACb,UAAU,QAAQ,CAAC,iCAAiC,EAAEY,IAAIE,OAAO,EAAE;YAC9E,OAAO;QACT;IACF;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CLIError } from '@oclif/core/errors';
|
|
2
|
-
import { uniqBy } from '
|
|
2
|
+
import { uniqBy } from 'lodash-es';
|
|
3
3
|
import { isDefined } from '../../manifest/schemaTypeHelpers.js';
|
|
4
4
|
import { SANITY_WORKSPACE_SCHEMA_ID_PREFIX } from '../../manifest/types.js';
|
|
5
5
|
const validForIdChars = 'a-zA-Z0-9._-';
|
|
@@ -95,14 +95,6 @@ export function parseWorkspaceSchemaId(errors, id) {
|
|
|
95
95
|
}
|
|
96
96
|
return tag;
|
|
97
97
|
}
|
|
98
|
-
function getProjectIdMismatchMessage(workspace, operation) {
|
|
99
|
-
return `No permissions to ${operation} schema for workspace "${workspace.name}" with projectId "${workspace.projectId}"`;
|
|
100
|
-
}
|
|
101
|
-
export function filterLogReadProjectIdMismatch(workspace, projectId, output) {
|
|
102
|
-
const canRead = workspace.projectId === projectId;
|
|
103
|
-
if (!canRead) output.warn(`${getProjectIdMismatchMessage(workspace, 'read')} – ignoring it.`);
|
|
104
|
-
return canRead;
|
|
105
|
-
}
|
|
106
98
|
export const SCHEMA_PERMISSION_HELP_TEXT = 'For multi-project workspaces, set SANITY_AUTH_TOKEN environment variable to a token with access to the workspace projects.';
|
|
107
99
|
|
|
108
100
|
//# sourceMappingURL=schemaStoreValidation.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/schema/utils/schemaStoreValidation.ts"],"sourcesContent":["import {CLIError} from '@oclif/core/errors'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/schema/utils/schemaStoreValidation.ts"],"sourcesContent":["import {CLIError} from '@oclif/core/errors'\nimport {uniqBy} from 'lodash-es'\n\nimport {isDefined} from '../../manifest/schemaTypeHelpers.js'\nimport {SANITY_WORKSPACE_SCHEMA_ID_PREFIX} from '../../manifest/types.js'\n\nconst validForIdChars = 'a-zA-Z0-9._-'\nconst validForIdPattern = new RegExp(`^[${validForIdChars}]+$`)\n\n//no periods allowed in workspaceName or tag in ids\nexport const validForNamesChars = 'a-zA-Z0-9_-'\nexport const validForNamesPattern = new RegExp(`^[${validForNamesChars}]+$`)\n\nconst requiredInId = SANITY_WORKSPACE_SCHEMA_ID_PREFIX.replaceAll(/[.]/g, String.raw`\\.`)\n\nconst idIdPatternString = String.raw`^${requiredInId}\\.([${validForNamesChars}]+)`\nconst baseIdPattern = new RegExp(`${idIdPatternString}$`)\nconst taggedIdIdPattern = new RegExp(\n String.raw`${idIdPatternString}\\.tag\\.([${validForNamesChars}]+)$`,\n)\n\nexport class FlagValidationError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'FlagValidationError'\n }\n}\n\nexport interface WorkspaceSchemaId {\n schemaId: string\n workspace: string\n}\n\nexport function parseIds(ids?: string): WorkspaceSchemaId[] {\n if (!ids) {\n throw new CLIError('ids argument is empty')\n }\n\n const errors: string[] = []\n\n const parsedIds = ids\n .split(',')\n .map((id) => id.trim())\n .filter((id) => !!id)\n .map((id) => parseWorkspaceSchemaId(errors, id))\n .filter((item) => isDefined(item))\n\n if (errors.length > 0) {\n throw new CLIError(`Invalid arguments:\\n${errors.map((error) => ` - ${error}`).join('\\n')}`)\n }\n\n if (parsedIds.length === 0) {\n throw new CLIError(`ids contains no valid id strings`)\n }\n\n const uniqueIds = uniqBy(parsedIds, 'schemaId' satisfies keyof (typeof parsedIds)[number])\n if (uniqueIds.length < parsedIds.length) {\n throw new CLIError(`ids contains duplicates`)\n }\n\n return uniqueIds\n}\n\nexport function parseWorkspaceSchemaId(errors: string[], id?: string) {\n if (id === undefined) {\n return\n }\n\n if (!id) {\n errors.push('id argument is empty')\n return\n }\n\n const trimmedId = id.trim()\n\n if (!validForIdPattern.test(trimmedId)) {\n errors.push(`id can only contain characters in [${validForIdChars}] but found: \"${trimmedId}\"`)\n return\n }\n\n if (trimmedId.startsWith('-')) {\n errors.push(`id cannot start with - (dash) but found: \"${trimmedId}\"`)\n return\n }\n\n if (/\\.\\./g.test(trimmedId)) {\n errors.push(`id cannot have consecutive . (period) characters, but found: \"${trimmedId}\"`)\n return\n }\n\n const [, workspace] = trimmedId.match(taggedIdIdPattern) ?? trimmedId.match(baseIdPattern) ?? []\n if (!workspace) {\n errors.push(\n [\n `id must either match ${SANITY_WORKSPACE_SCHEMA_ID_PREFIX}.<workspaceName> `,\n `or ${SANITY_WORKSPACE_SCHEMA_ID_PREFIX}.<workspaceName>.tag.<tag> but found: \"${trimmedId}\". `,\n `Note that workspace name characters not in [${validForNamesChars}] has to be replaced with _ for schema id.`,\n ].join(''),\n )\n return\n }\n return {\n schemaId: trimmedId,\n workspace,\n }\n}\n\n/**\n *\n * @param tag - The tag to parse\n * Throws an error if the tag is empty\n * Throws an error if the tag contains a period\n * Throws an error if the tag starts with a dash\n * Returns the parsed tag\n */\nexport async function parseTag(tag?: string) {\n if (tag === undefined) {\n return tag\n }\n\n if (!tag) {\n throw new CLIError('tag argument is empty')\n }\n\n if (tag.includes('.')) {\n throw new CLIError(`tag cannot contain . (period), but was: \"${tag}\"`)\n }\n\n if (!validForNamesPattern.test(tag)) {\n throw new CLIError(\n `tag can only contain characters in [${validForNamesChars}], but was: \"${tag}\"`,\n )\n }\n\n if (tag.startsWith('-')) {\n throw new CLIError(`tag cannot start with - (dash) but was: \"${tag}\"`)\n }\n\n return tag\n}\n\nexport const SCHEMA_PERMISSION_HELP_TEXT =\n 'For multi-project workspaces, set SANITY_AUTH_TOKEN environment variable to a token with access to the workspace projects.'\n"],"names":["CLIError","uniqBy","isDefined","SANITY_WORKSPACE_SCHEMA_ID_PREFIX","validForIdChars","validForIdPattern","RegExp","validForNamesChars","validForNamesPattern","requiredInId","replaceAll","String","raw","idIdPatternString","baseIdPattern","taggedIdIdPattern","FlagValidationError","Error","message","name","parseIds","ids","errors","parsedIds","split","map","id","trim","filter","parseWorkspaceSchemaId","item","length","error","join","uniqueIds","undefined","push","trimmedId","test","startsWith","workspace","match","schemaId","parseTag","tag","includes","SCHEMA_PERMISSION_HELP_TEXT"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,qBAAoB;AAC3C,SAAQC,MAAM,QAAO,YAAW;AAEhC,SAAQC,SAAS,QAAO,sCAAqC;AAC7D,SAAQC,iCAAiC,QAAO,0BAAyB;AAEzE,MAAMC,kBAAkB;AACxB,MAAMC,oBAAoB,IAAIC,OAAO,CAAC,EAAE,EAAEF,gBAAgB,GAAG,CAAC;AAE9D,mDAAmD;AACnD,OAAO,MAAMG,qBAAqB,cAAa;AAC/C,OAAO,MAAMC,uBAAuB,IAAIF,OAAO,CAAC,EAAE,EAAEC,mBA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CAAC,CAAC;IACvE;IAEA,IAAI,CAACpC,qBAAqB8B,IAAI,CAACM,MAAM;QACnC,MAAM,IAAI5C,SACR,CAAC,oCAAoC,EAAEO,mBAAmB,aAAa,EAAEqC,IAAI,CAAC,CAAC;IAEnF;IAEA,IAAIA,IAAIL,UAAU,CAAC,MAAM;QACvB,MAAM,IAAIvC,SAAS,CAAC,yCAAyC,EAAE4C,IAAI,CAAC,CAAC;IACvE;IAEA,OAAOA;AACT;AAEA,OAAO,MAAME,8BACX,6HAA4H"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/actions/schema/utils/uniqByProjectIdDataset.ts"],"sourcesContent":["import {uniqBy} from '
|
|
1
|
+
{"version":3,"sources":["../../../../src/actions/schema/utils/uniqByProjectIdDataset.ts"],"sourcesContent":["import {uniqBy} from 'lodash-es'\nimport {type Workspace} from 'sanity'\n\nexport function uniqByProjectIdDataset(workspaces: Workspace[]) {\n return uniqBy<Workspace & {key: string}>(\n workspaces.map((w) => ({\n ...w,\n key: `${w.projectId}-${w.dataset}`,\n })),\n 'key',\n )\n}\n"],"names":["uniqBy","uniqByProjectIdDataset","workspaces","map","w","key","projectId","dataset"],"mappings":"AAAA,SAAQA,MAAM,QAAO,YAAW;AAGhC,OAAO,SAASC,uBAAuBC,UAAuB;IAC5D,OAAOF,OACLE,WAAWC,GAAG,CAAC,CAACC,IAAO,CAAA;YACrB,GAAGA,CAAC;YACJC,KAAK,GAAGD,EAAEE,SAAS,CAAC,CAAC,EAAEF,EAAEG,OAAO,EAAE;QACpC,CAAA,IACA;AAEJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/versions/filterSanityModules.ts"],"sourcesContent":["import {type PackageJson} from '
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/versions/filterSanityModules.ts"],"sourcesContent":["import {type PackageJson} from '@sanity/cli-core'\n\n/**\n * Filter the sanity modules from the package.json.\n *\n * @param manifest - The package.json manifest.\n * @returns The filtered sanity modules.\n */\nexport function filterSanityModules(manifest: Partial<PackageJson>): Record<string, string> {\n const dependencies = {\n ...manifest.dependencies,\n ...manifest.devDependencies,\n }\n\n const filteredDependencies: Record<string, string> = {}\n\n for (const mod in dependencies) {\n if (mod.startsWith('@sanity/') || mod === 'sanity') {\n filteredDependencies[mod] = dependencies[mod]\n }\n }\n\n return filteredDependencies\n}\n"],"names":["filterSanityModules","manifest","dependencies","devDependencies","filteredDependencies","mod","startsWith"],"mappings":"AAEA;;;;;CAKC,GACD,OAAO,SAASA,oBAAoBC,QAA8B;IAChE,MAAMC,eAAe;QACnB,GAAGD,SAASC,YAAY;QACxB,GAAGD,SAASE,eAAe;IAC7B;IAEA,MAAMC,uBAA+C,CAAC;IAEtD,IAAK,MAAMC,OAAOH,aAAc;QAC9B,IAAIG,IAAIC,UAAU,CAAC,eAAeD,QAAQ,UAAU;YAClDD,oBAAoB,CAACC,IAAI,GAAGH,YAAY,CAACG,IAAI;QAC/C;IACF;IAEA,OAAOD;AACT"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
+
import { readPackageJson } from '@sanity/cli-core';
|
|
2
3
|
import { spinner } from '@sanity/cli-core/ux';
|
|
3
4
|
import promiseProps from 'promise-props-recursive';
|
|
4
5
|
import semver from 'semver';
|
|
5
6
|
import semverCompare from 'semver-compare';
|
|
6
7
|
import { getCliVersion } from '../../util/getCliVersion.js';
|
|
7
|
-
import { readPackageJson } from '../../util/readPackageJson.js';
|
|
8
8
|
import { buildPackageArray } from './buildPackageArray.js';
|
|
9
9
|
import { filterSanityModules } from './filterSanityModules.js';
|
|
10
10
|
import { versionsDebug } from './versionsDebug.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/actions/versions/findSanityModulesVersions.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {spinner} from '@sanity/cli-core/ux'\nimport promiseProps from 'promise-props-recursive'\nimport semver from 'semver'\nimport semverCompare from 'semver-compare'\n\nimport {getCliVersion} from '../../util/getCliVersion.js'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../../src/actions/versions/findSanityModulesVersions.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {readPackageJson} from '@sanity/cli-core'\nimport {spinner} from '@sanity/cli-core/ux'\nimport promiseProps from 'promise-props-recursive'\nimport semver from 'semver'\nimport semverCompare from 'semver-compare'\n\nimport {getCliVersion} from '../../util/getCliVersion.js'\nimport {buildPackageArray} from './buildPackageArray.js'\nimport {filterSanityModules} from './filterSanityModules.js'\nimport {type ModuleVersionInfo, type ModuleVersionResult} from './types.js'\nimport {versionsDebug} from './versionsDebug.js'\n\n/**\n * @internal\n */\ninterface PrintVersionArgs {\n cwd: string\n}\n\n/**\n * Print the versions of the all sanity and `@sanity/*` packages.\n *\n * @internal\n */\nexport async function findSanityModulesVersions(\n args: PrintVersionArgs,\n): Promise<ModuleVersionResult[]> {\n const {cwd} = args\n const cliVersion = await getCliVersion()\n\n versionsDebug(`Sanity CLI version: ${cliVersion}`)\n\n const packageJsonPath = path.join(cwd, 'package.json')\n versionsDebug(`Reading package.json from ${packageJsonPath}`)\n // Declared @sanity/* modules and their wanted versions in package.json\n const packageJson = await readPackageJson(packageJsonPath)\n versionsDebug('Resolved package.json:', packageJson)\n\n const filteredSanityModules = filterSanityModules(packageJson)\n versionsDebug('sanity modules:', filteredSanityModules)\n\n const spin = spinner('Resolving latest versions').start()\n\n try {\n const versions = await promiseProps<ModuleVersionInfo[]>(\n buildPackageArray(filteredSanityModules, cwd, cliVersion),\n )\n\n const packages = Object.values(versions)\n versionsDebug('packages:', packages)\n\n return packages.map((mod) => {\n const current = mod.installed || semver.minVersion(mod.declared)?.toString() || ''\n const needsUpdate = mod.latest ? semverCompare(current, mod.latest) === -1 : false\n\n return {...mod, needsUpdate}\n })\n } catch (error) {\n versionsDebug('Error finding sanity modules versions:', error)\n throw error\n } finally {\n spin.stop()\n }\n}\n"],"names":["path","readPackageJson","spinner","promiseProps","semver","semverCompare","getCliVersion","buildPackageArray","filterSanityModules","versionsDebug","findSanityModulesVersions","args","cwd","cliVersion","packageJsonPath","join","packageJson","filteredSanityModules","spin","start","versions","packages","Object","values","map","mod","current","installed","minVersion","declared","toString","needsUpdate","latest","error","stop"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B,SAAQC,eAAe,QAAO,mBAAkB;AAChD,SAAQC,OAAO,QAAO,sBAAqB;AAC3C,OAAOC,kBAAkB,0BAAyB;AAClD,OAAOC,YAAY,SAAQ;AAC3B,OAAOC,mBAAmB,iBAAgB;AAE1C,SAAQC,aAAa,QAAO,8BAA6B;AACzD,SAAQC,iBAAiB,QAAO,yBAAwB;AACxD,SAAQC,mBAAmB,QAAO,2BAA0B;AAE5D,SAAQC,aAAa,QAAO,qBAAoB;AAShD;;;;CAIC,GACD,OAAO,eAAeC,0BACpBC,IAAsB;IAEtB,MAAM,EAACC,GAAG,EAAC,GAAGD;IACd,MAAME,aAAa,MAAMP;IAEzBG,cAAc,CAAC,oBAAoB,EAAEI,YAAY;IAEjD,MAAMC,kBAAkBd,KAAKe,IAAI,CAACH,KAAK;IACvCH,cAAc,CAAC,0BAA0B,EAAEK,iBAAiB;IAC5D,uEAAuE;IACvE,MAAME,cAAc,MAAMf,gBAAgBa;IAC1CL,cAAc,0BAA0BO;IAExC,MAAMC,wBAAwBT,oBAAoBQ;IAClDP,cAAc,mBAAmBQ;IAEjC,MAAMC,OAAOhB,QAAQ,6BAA6BiB,KAAK;IAEvD,IAAI;QACF,MAAMC,WAAW,MAAMjB,aACrBI,kBAAkBU,uBAAuBL,KAAKC;QAGhD,MAAMQ,WAAWC,OAAOC,MAAM,CAACH;QAC/BX,cAAc,aAAaY;QAE3B,OAAOA,SAASG,GAAG,CAAC,CAACC;YACnB,MAAMC,UAAUD,IAAIE,SAAS,IAAIvB,OAAOwB,UAAU,CAACH,IAAII,QAAQ,GAAGC,cAAc;YAChF,MAAMC,cAAcN,IAAIO,MAAM,GAAG3B,cAAcqB,SAASD,IAAIO,MAAM,MAAM,CAAC,IAAI;YAE7E,OAAO;gBAAC,GAAGP,GAAG;gBAAEM;YAAW;QAC7B;IACF,EAAE,OAAOE,OAAO;QACdxB,cAAc,0CAA0CwB;QACxD,MAAMA;IACR,SAAU;QACRf,KAAKgB,IAAI;IACX;AACF"}
|
package/dist/commands/build.js
CHANGED
|
@@ -52,16 +52,14 @@ export class BuildCommand extends SanityCommand {
|
|
|
52
52
|
flags,
|
|
53
53
|
output
|
|
54
54
|
});
|
|
55
|
-
const exit = this.exit.bind(this);
|
|
56
55
|
if (isApp) {
|
|
57
56
|
buildDebug(`Building app`);
|
|
58
57
|
await buildApp({
|
|
59
58
|
autoUpdatesEnabled,
|
|
60
59
|
cliConfig,
|
|
61
|
-
exit,
|
|
62
60
|
flags,
|
|
63
61
|
outDir: this.args.outputDir,
|
|
64
|
-
output
|
|
62
|
+
output,
|
|
65
63
|
workDir
|
|
66
64
|
});
|
|
67
65
|
} else {
|
|
@@ -69,10 +67,9 @@ export class BuildCommand extends SanityCommand {
|
|
|
69
67
|
await buildStudio({
|
|
70
68
|
autoUpdatesEnabled,
|
|
71
69
|
cliConfig,
|
|
72
|
-
exit,
|
|
73
70
|
flags,
|
|
74
71
|
outDir: this.args.outputDir,
|
|
75
|
-
output
|
|
72
|
+
output,
|
|
76
73
|
workDir
|
|
77
74
|
});
|
|
78
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/commands/build.ts"],"sourcesContent":["import {Args, Flags} from '@oclif/core'\nimport {SanityCommand} from '@sanity/cli-core'\n\nimport {buildApp} from '../actions/build/buildApp.js'\nimport {buildDebug} from '../actions/build/buildDebug.js'\nimport {buildStudio} from '../actions/build/buildStudio.js'\nimport {shouldAutoUpdate} from '../actions/build/shouldAutoUpdate.js'\nimport {determineIsApp} from '../util/determineIsApp.js'\n\nexport class BuildCommand extends SanityCommand<typeof BuildCommand> {\n static override args = {\n outputDir: Args.directory({description: 'Output directory'}),\n }\n\n static override description = 'Builds the Sanity Studio configuration into a static bundle'\n\n static override examples = [\n '<%= config.bin %> <%= command.id %>',\n '<%= config.bin %> <%= command.id %> --no-minify --source-maps',\n ]\n\n static override flags = {\n 'auto-updates': Flags.boolean({\n allowNo: true,\n description: 'Enable/disable auto updates of studio versions',\n }),\n minify: Flags.boolean({\n allowNo: true,\n default: true,\n description: 'Enable/disable minifying of built bundles',\n }),\n 'source-maps': Flags.boolean({\n allowNo: true,\n default: false,\n description: 'Enable source maps for built bundles (increases size of bundle)',\n }),\n stats: Flags.boolean({\n default: false,\n description: 'Show stats about the built bundles',\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 cliConfig = await this.getCliConfig()\n\n const {flags} = await this.parse(BuildCommand)\n\n const isApp = determineIsApp(cliConfig)\n\n const workDir = (await this.getProjectRoot()).directory\n\n const output = this.output\n\n const autoUpdatesEnabled = shouldAutoUpdate({cliConfig, flags, output})\n
|
|
1
|
+
{"version":3,"sources":["../../src/commands/build.ts"],"sourcesContent":["import {Args, Flags} from '@oclif/core'\nimport {SanityCommand} from '@sanity/cli-core'\n\nimport {buildApp} from '../actions/build/buildApp.js'\nimport {buildDebug} from '../actions/build/buildDebug.js'\nimport {buildStudio} from '../actions/build/buildStudio.js'\nimport {shouldAutoUpdate} from '../actions/build/shouldAutoUpdate.js'\nimport {determineIsApp} from '../util/determineIsApp.js'\n\nexport class BuildCommand extends SanityCommand<typeof BuildCommand> {\n static override args = {\n outputDir: Args.directory({description: 'Output directory'}),\n }\n\n static override description = 'Builds the Sanity Studio configuration into a static bundle'\n\n static override examples = [\n '<%= config.bin %> <%= command.id %>',\n '<%= config.bin %> <%= command.id %> --no-minify --source-maps',\n ]\n\n static override flags = {\n 'auto-updates': Flags.boolean({\n allowNo: true,\n description: 'Enable/disable auto updates of studio versions',\n }),\n minify: Flags.boolean({\n allowNo: true,\n default: true,\n description: 'Enable/disable minifying of built bundles',\n }),\n 'source-maps': Flags.boolean({\n allowNo: true,\n default: false,\n description: 'Enable source maps for built bundles (increases size of bundle)',\n }),\n stats: Flags.boolean({\n default: false,\n description: 'Show stats about the built bundles',\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 cliConfig = await this.getCliConfig()\n\n const {flags} = await this.parse(BuildCommand)\n\n const isApp = determineIsApp(cliConfig)\n\n const workDir = (await this.getProjectRoot()).directory\n\n const output = this.output\n\n const autoUpdatesEnabled = shouldAutoUpdate({cliConfig, flags, output})\n\n if (isApp) {\n buildDebug(`Building app`)\n await buildApp({\n autoUpdatesEnabled,\n cliConfig,\n flags,\n outDir: this.args.outputDir,\n output,\n workDir,\n })\n } else {\n buildDebug(`Building studio`)\n await buildStudio({\n autoUpdatesEnabled,\n cliConfig,\n flags,\n outDir: this.args.outputDir,\n output,\n workDir,\n })\n }\n }\n}\n"],"names":["Args","Flags","SanityCommand","buildApp","buildDebug","buildStudio","shouldAutoUpdate","determineIsApp","BuildCommand","args","outputDir","directory","description","examples","flags","boolean","allowNo","minify","default","stats","yes","char","run","cliConfig","getCliConfig","parse","isApp","workDir","getProjectRoot","output","autoUpdatesEnabled","outDir"],"mappings":"AAAA,SAAQA,IAAI,EAAEC,KAAK,QAAO,cAAa;AACvC,SAAQC,aAAa,QAAO,mBAAkB;AAE9C,SAAQC,QAAQ,QAAO,+BAA8B;AACrD,SAAQC,UAAU,QAAO,iCAAgC;AACzD,SAAQC,WAAW,QAAO,kCAAiC;AAC3D,SAAQC,gBAAgB,QAAO,uCAAsC;AACrE,SAAQC,cAAc,QAAO,4BAA2B;AAExD,OAAO,MAAMC,qBAAqBN;IAChC,OAAgBO,OAAO;QACrBC,WAAWV,KAAKW,SAAS,CAAC;YAACC,aAAa;QAAkB;IAC5D,EAAC;IAED,OAAgBA,cAAc,8DAA6D;IAE3F,OAAgBC,WAAW;QACzB;QACA;KACD,CAAA;IAED,OAAgBC,QAAQ;QACtB,gBAAgBb,MAAMc,OAAO,CAAC;YAC5BC,SAAS;YACTJ,aAAa;QACf;QACAK,QAAQhB,MAAMc,OAAO,CAAC;YACpBC,SAAS;YACTE,SAAS;YACTN,aAAa;QACf;QACA,eAAeX,MAAMc,OAAO,CAAC;YAC3BC,SAAS;YACTE,SAAS;YACTN,aAAa;QACf;QACAO,OAAOlB,MAAMc,OAAO,CAAC;YACnBG,SAAS;YACTN,aAAa;QACf;QACAQ,KAAKnB,MAAMc,OAAO,CAAC;YACjBM,MAAM;YACNH,SAAS;YACTN,aACE;QACJ;IACF,EAAC;IAED,MAAaU,MAAqB;QAChC,MAAMC,YAAY,MAAM,IAAI,CAACC,YAAY;QAEzC,MAAM,EAACV,KAAK,EAAC,GAAG,MAAM,IAAI,CAACW,KAAK,CAACjB;QAEjC,MAAMkB,QAAQnB,eAAegB;QAE7B,MAAMI,UAAU,AAAC,CAAA,MAAM,IAAI,CAACC,cAAc,EAAC,EAAGjB,SAAS;QAEvD,MAAMkB,SAAS,IAAI,CAACA,MAAM;QAE1B,MAAMC,qBAAqBxB,iBAAiB;YAACiB;YAAWT;YAAOe;QAAM;QAErE,IAAIH,OAAO;YACTtB,WAAW,CAAC,YAAY,CAAC;YACzB,MAAMD,SAAS;gBACb2B;gBACAP;gBACAT;gBACAiB,QAAQ,IAAI,CAACtB,IAAI,CAACC,SAAS;gBAC3BmB;gBACAF;YACF;QACF,OAAO;YACLvB,WAAW,CAAC,eAAe,CAAC;YAC5B,MAAMC,YAAY;gBAChByB;gBACAP;gBACAT;gBACAiB,QAAQ,IAAI,CAACtB,IAAI,CAACC,SAAS;gBAC3BmB;gBACAF;YACF;QACF;IACF;AACF"}
|
package/dist/commands/deploy.js
CHANGED
|
@@ -17,8 +17,7 @@ export class DeployCommand extends SanityCommand {
|
|
|
17
17
|
static examples = [
|
|
18
18
|
{
|
|
19
19
|
command: '<%= config.bin %> <%= command.id %>',
|
|
20
|
-
|
|
21
|
-
description: 'Build the studio'
|
|
20
|
+
description: 'Build and deploy the studio to Sanity hosting'
|
|
22
21
|
},
|
|
23
22
|
{
|
|
24
23
|
command: '<%= config.bin %> <%= command.id %> --no-minify --source-maps',
|
|
@@ -92,7 +91,6 @@ export class DeployCommand extends SanityCommand {
|
|
|
92
91
|
deployDebug('Deploying app');
|
|
93
92
|
await deployApp({
|
|
94
93
|
cliConfig,
|
|
95
|
-
exit: this.exit,
|
|
96
94
|
flags,
|
|
97
95
|
output: this.output,
|
|
98
96
|
sourceDir,
|
|
@@ -102,7 +100,6 @@ export class DeployCommand extends SanityCommand {
|
|
|
102
100
|
deployDebug('Deploying studio');
|
|
103
101
|
await deployStudio({
|
|
104
102
|
cliConfig,
|
|
105
|
-
exit: this.exit,
|
|
106
103
|
flags,
|
|
107
104
|
output: this.output,
|
|
108
105
|
sourceDir,
|