@sanity/cli 3.93.0 → 3.93.1-bump-pkg-utils.34.5d0c0b3d22
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/lib/_chunks-cjs/cli.js +5 -5
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/lib/_chunks-cjs/cliWorker.js.map +1 -1
- package/lib/_chunks-cjs/generateAction.js.map +1 -1
- package/lib/_chunks-cjs/getCliConfig.js.map +1 -1
- package/lib/_chunks-cjs/journeyConfig.js.map +1 -1
- package/lib/_chunks-cjs/loadEnv.js.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/run.js.map +1 -1
- package/lib/workers/getAndWriteJourneySchema.js.map +1 -1
- package/lib/workers/getCliConfig.js.map +1 -1
- package/lib/workers/typegenGenerate.js.map +1 -1
- package/package.json +6 -7
- package/templates/blog/README.md +1 -1
- package/templates/clean/README.md +1 -1
- package/templates/ecommerce/README.md +1 -1
- package/templates/get-started/README.md +1 -1
- package/templates/moviedb/README.md +1 -1
- package/templates/quickstart/README.md +1 -1
- package/src/CommandRunner.ts +0 -219
- package/src/__telemetry__/cli.telemetry.ts +0 -29
- package/src/__telemetry__/init.telemetry.ts +0 -95
- package/src/actions/codemod/codemodAction.ts +0 -109
- package/src/actions/codemod/mods/deskRename.ts +0 -19
- package/src/actions/codemod/mods/index.ts +0 -9
- package/src/actions/codemod/mods/partsTypeDirective.ts +0 -28
- package/src/actions/codemod/mods/reactIconsV3.ts +0 -54
- package/src/actions/codemod/types.ts +0 -10
- package/src/actions/init-plugin/bootstrapFromTemplate.ts +0 -196
- package/src/actions/init-project/bootstrapLocalTemplate.ts +0 -201
- package/src/actions/init-project/bootstrapRemoteTemplate.ts +0 -118
- package/src/actions/init-project/createAppCliConfig.ts +0 -24
- package/src/actions/init-project/createCliConfig.ts +0 -31
- package/src/actions/init-project/createPackageManifest.ts +0 -102
- package/src/actions/init-project/createStudioConfig.ts +0 -53
- package/src/actions/init-project/determineAppTemplate.ts +0 -13
- package/src/actions/init-project/fsUtils.ts +0 -40
- package/src/actions/init-project/git.ts +0 -59
- package/src/actions/init-project/initProject.ts +0 -1708
- package/src/actions/init-project/processTemplate.ts +0 -55
- package/src/actions/init-project/promptForDatasetName.ts +0 -68
- package/src/actions/init-project/prompts/index.ts +0 -51
- package/src/actions/init-project/prompts/nextjs.ts +0 -59
- package/src/actions/init-project/readPackageJson.ts +0 -17
- package/src/actions/init-project/templates/appQuickstart.ts +0 -23
- package/src/actions/init-project/templates/appSanityUi.ts +0 -25
- package/src/actions/init-project/templates/blog.ts +0 -5
- package/src/actions/init-project/templates/clean.ts +0 -5
- package/src/actions/init-project/templates/getStarted.ts +0 -37
- package/src/actions/init-project/templates/index.ts +0 -24
- package/src/actions/init-project/templates/moviedb.ts +0 -35
- package/src/actions/init-project/templates/nextjs/index.ts +0 -238
- package/src/actions/init-project/templates/nextjs/schemaTypes/blog.ts +0 -252
- package/src/actions/init-project/templates/quickstart.ts +0 -5
- package/src/actions/init-project/templates/shopify.ts +0 -78
- package/src/actions/init-project/templates/shopifyOnline.ts +0 -50
- package/src/actions/init-project/updateInitialTemplateMetadata.ts +0 -24
- package/src/actions/login/login.telemetry.ts +0 -18
- package/src/actions/login/login.ts +0 -350
- package/src/actions/login/types.ts +0 -19
- package/src/actions/project/createProject.ts +0 -36
- package/src/actions/telemetry/setTelemetryConsent.ts +0 -101
- package/src/actions/typegen/generate.telemetry.ts +0 -20
- package/src/actions/typegen/generateAction.ts +0 -210
- package/src/actions/versions/findSanityModuleVersions.ts +0 -185
- package/src/actions/yarn/events.ts +0 -73
- package/src/cli.ts +0 -350
- package/src/cliClient.ts +0 -62
- package/src/commands/blueprints/addBlueprintsCommand.ts +0 -155
- package/src/commands/blueprints/blueprintsGroup.ts +0 -10
- package/src/commands/blueprints/configBlueprintsCommand.ts +0 -86
- package/src/commands/blueprints/deployBlueprintsCommand.ts +0 -63
- package/src/commands/blueprints/destroyBlueprintsCommand.ts +0 -78
- package/src/commands/blueprints/infoBlueprintsCommand.ts +0 -55
- package/src/commands/blueprints/initBlueprintsCommand.ts +0 -99
- package/src/commands/blueprints/logsBlueprintsCommand.ts +0 -66
- package/src/commands/blueprints/planBlueprintsCommand.ts +0 -51
- package/src/commands/blueprints/stacksBlueprintsCommand.ts +0 -66
- package/src/commands/codemod/codemodCommand.ts +0 -32
- package/src/commands/debug/debugCommand.ts +0 -26
- package/src/commands/debug/printDebugInfo.ts +0 -243
- package/src/commands/docs/docsCommand.ts +0 -20
- package/src/commands/functions/devFunctionsCommand.ts +0 -73
- package/src/commands/functions/envFunctionsCommand.ts +0 -105
- package/src/commands/functions/functionsGroup.ts +0 -10
- package/src/commands/functions/logsFunctionsCommand.ts +0 -94
- package/src/commands/functions/testFunctionsCommand.ts +0 -93
- package/src/commands/help/helpCommand.ts +0 -21
- package/src/commands/help/showHelp.ts +0 -58
- package/src/commands/index.ts +0 -72
- package/src/commands/init/initCommand.ts +0 -123
- package/src/commands/install/installCommand.ts +0 -38
- package/src/commands/learn/learnCommand.ts +0 -20
- package/src/commands/login/loginCommand.ts +0 -29
- package/src/commands/logout/logoutCommand.ts +0 -52
- package/src/commands/manage/manageCommand.ts +0 -24
- package/src/commands/projects/listProjectsCommand.ts +0 -62
- package/src/commands/projects/projectsGroup.ts +0 -10
- package/src/commands/telemetry/disableTelemetryCommand.ts +0 -19
- package/src/commands/telemetry/enableTelemetryCommand.ts +0 -19
- package/src/commands/telemetry/telemetryGroup.ts +0 -10
- package/src/commands/telemetry/telemetryStatusCommand.ts +0 -89
- package/src/commands/typegen/generateTypesCommand.ts +0 -56
- package/src/commands/typegen/typegenGroup.ts +0 -10
- package/src/commands/versions/printVersionResult.ts +0 -51
- package/src/commands/versions/versionsCommand.ts +0 -13
- package/src/config.ts +0 -14
- package/src/debug.ts +0 -3
- package/src/index.ts +0 -6
- package/src/outputters/cliOutputter.ts +0 -47
- package/src/packageManager/getInstallCommand.ts +0 -26
- package/src/packageManager/getUpgradeCommand.ts +0 -52
- package/src/packageManager/index.ts +0 -33
- package/src/packageManager/installPackages.ts +0 -99
- package/src/packageManager/packageManagerChoice.ts +0 -204
- package/src/packageManager/uninstallPackages.ts +0 -44
- package/src/packageManager/yarnStub.ts +0 -22
- package/src/prompters/cliPrompter.ts +0 -9
- package/src/run.ts +0 -8
- package/src/studioDependencies.ts +0 -25
- package/src/types.ts +0 -387
- package/src/util/canLaunchBrowser.ts +0 -12
- package/src/util/cliWorker.ts +0 -34
- package/src/util/clientWrapper.ts +0 -119
- package/src/util/copy.ts +0 -50
- package/src/util/createExpiringConfig.ts +0 -80
- package/src/util/createTelemetryStore.ts +0 -204
- package/src/util/detectRuntime.ts +0 -12
- package/src/util/dynamicRequire.ts +0 -17
- package/src/util/frameworkPort.ts +0 -63
- package/src/util/generateCommandsDocumentation.ts +0 -62
- package/src/util/getCliConfig.ts +0 -172
- package/src/util/getCliVersion.ts +0 -22
- package/src/util/getLocalVersion.ts +0 -35
- package/src/util/getProjectDefaults.ts +0 -103
- package/src/util/getProviderName.ts +0 -9
- package/src/util/getUserConfig.ts +0 -15
- package/src/util/isCi.ts +0 -7
- package/src/util/isCommandGroup.ts +0 -7
- package/src/util/isInteractive.ts +0 -3
- package/src/util/isTrueish.ts +0 -8
- package/src/util/journeyConfig.ts +0 -280
- package/src/util/loadEnv.ts +0 -110
- package/src/util/mergeCommands.ts +0 -78
- package/src/util/neatStack.ts +0 -30
- package/src/util/noSuchCommandText.ts +0 -91
- package/src/util/parseArguments.ts +0 -76
- package/src/util/pathExists.ts +0 -14
- package/src/util/readJson.ts +0 -6
- package/src/util/readdirRecursive.ts +0 -26
- package/src/util/remoteTemplate.ts +0 -320
- package/src/util/resolveLatestVersions.ts +0 -24
- package/src/util/resolveRootDir.ts +0 -59
- package/src/util/telemetryDisclosure.ts +0 -45
- package/src/util/updateNotifier.ts +0 -158
- package/src/util/writeJson.ts +0 -6
- package/src/workers/getAndWriteJourneySchema.ts +0 -7
- package/src/workers/getCliConfig.ts +0 -14
- package/src/workers/typegenGenerate.ts +0 -228
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typegenGenerate.js","sources":["../../src/workers/typegenGenerate.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData as _workerData} from 'node:worker_threads'\n\nimport {\n findQueriesInPath,\n getResolver,\n readSchema,\n registerBabel,\n safeParseQuery,\n TypeGenerator,\n} from '@sanity/codegen'\nimport createDebug from 'debug'\nimport {typeEvaluate, type TypeNode} from 'groq-js'\n\nconst $info = createDebug('sanity:codegen:generate:info')\n\nexport interface TypegenGenerateTypesWorkerData {\n workDir: string\n workspaceName?: string\n schemaPath: string\n searchPath: string | string[]\n overloadClientMethods?: boolean\n}\n\nexport type TypegenGenerateTypesWorkerMessage =\n | {\n type: 'error'\n error: Error\n fatal: boolean\n query?: string\n filename?: string\n }\n | {\n type: 'types'\n filename: string\n types: {\n queryName: string\n query: string\n type: string\n unknownTypeNodesGenerated: number\n typeNodesGenerated: number\n emptyUnionTypeNodesGenerated: number\n }[]\n }\n | {\n type: 'schema'\n filename: string\n schema: string\n length: number\n }\n | {\n type: 'typemap'\n typeMap: string\n }\n | {\n type: 'complete'\n }\n\nif (isMainThread || !parentPort) {\n throw new Error('This module must be run as a worker thread')\n}\n\nconst opts = _workerData as TypegenGenerateTypesWorkerData\n\nregisterBabel()\n\nasync function main() {\n const schema = await readSchema(opts.schemaPath)\n\n const typeGenerator = new TypeGenerator(schema)\n const schemaTypes = [typeGenerator.generateSchemaTypes(), TypeGenerator.generateKnownTypes()]\n .join('\\n')\n .trim()\n const resolver = getResolver()\n\n parentPort?.postMessage({\n type: 'schema',\n schema: `${schemaTypes.trim()}\\n`,\n filename: 'schema.json',\n length: schema.length,\n } satisfies TypegenGenerateTypesWorkerMessage)\n\n const queries = findQueriesInPath({\n path: opts.searchPath,\n resolver,\n })\n\n const allQueries = []\n\n for await (const result of queries) {\n if (result.type === 'error') {\n parentPort?.postMessage({\n type: 'error',\n error: result.error,\n fatal: false,\n filename: result.filename,\n } satisfies TypegenGenerateTypesWorkerMessage)\n continue\n }\n $info(`Processing ${result.queries.length} queries in \"${result.filename}\"...`)\n\n const fileQueryTypes: {\n queryName: string\n query: string\n type: string\n typeName: string\n typeNode: TypeNode\n unknownTypeNodesGenerated: number\n typeNodesGenerated: number\n emptyUnionTypeNodesGenerated: number\n }[] = []\n for (const {name: queryName, result: query} of result.queries) {\n try {\n const ast = safeParseQuery(query)\n const queryTypes = typeEvaluate(ast, schema)\n\n const typeName = `${queryName}Result`\n const type = typeGenerator.generateTypeNodeTypes(typeName, queryTypes)\n\n const queryTypeStats = walkAndCountQueryTypeNodeStats(queryTypes)\n fileQueryTypes.push({\n queryName,\n query,\n typeName,\n typeNode: queryTypes,\n type: `${type.trim()}\\n`,\n unknownTypeNodesGenerated: queryTypeStats.unknownTypes,\n typeNodesGenerated: queryTypeStats.allTypes,\n emptyUnionTypeNodesGenerated: queryTypeStats.emptyUnions,\n })\n } catch (err) {\n parentPort?.postMessage({\n type: 'error',\n error: new Error(\n `Error generating types for query \"${queryName}\" in \"${result.filename}\": ${err.message}`,\n {cause: err},\n ),\n fatal: false,\n query,\n } satisfies TypegenGenerateTypesWorkerMessage)\n }\n }\n\n if (fileQueryTypes.length > 0) {\n $info(`Generated types for ${fileQueryTypes.length} queries in \"${result.filename}\"\\n`)\n parentPort?.postMessage({\n type: 'types',\n types: fileQueryTypes,\n filename: result.filename,\n } satisfies TypegenGenerateTypesWorkerMessage)\n }\n\n if (fileQueryTypes.length > 0) {\n allQueries.push(...fileQueryTypes)\n }\n }\n\n if (opts.overloadClientMethods && allQueries.length > 0) {\n const typeMap = `${typeGenerator.generateQueryMap(allQueries).trim()}\\n`\n parentPort?.postMessage({\n type: 'typemap',\n typeMap,\n } satisfies TypegenGenerateTypesWorkerMessage)\n }\n\n parentPort?.postMessage({\n type: 'complete',\n } satisfies TypegenGenerateTypesWorkerMessage)\n}\n\nfunction walkAndCountQueryTypeNodeStats(typeNode: TypeNode): {\n allTypes: number\n unknownTypes: number\n emptyUnions: number\n} {\n switch (typeNode.type) {\n case 'unknown': {\n return {allTypes: 1, unknownTypes: 1, emptyUnions: 0}\n }\n case 'array': {\n const acc = walkAndCountQueryTypeNodeStats(typeNode.of)\n acc.allTypes += 1 // count the array type itself\n return acc\n }\n case 'object': {\n // if the rest is unknown, we count it as one unknown type\n if (typeNode.rest && typeNode.rest.type === 'unknown') {\n return {allTypes: 2, unknownTypes: 1, emptyUnions: 0} // count the object type itself as well\n }\n\n const restStats = typeNode.rest\n ? walkAndCountQueryTypeNodeStats(typeNode.rest)\n : {allTypes: 1, unknownTypes: 0, emptyUnions: 0} // count the object type itself\n\n return Object.values(typeNode.attributes).reduce((acc, attribute) => {\n const {allTypes, unknownTypes, emptyUnions} = walkAndCountQueryTypeNodeStats(\n attribute.value,\n )\n return {\n allTypes: acc.allTypes + allTypes,\n unknownTypes: acc.unknownTypes + unknownTypes,\n emptyUnions: acc.emptyUnions + emptyUnions,\n }\n }, restStats)\n }\n case 'union': {\n if (typeNode.of.length === 0) {\n return {allTypes: 1, unknownTypes: 0, emptyUnions: 1}\n }\n\n return typeNode.of.reduce(\n (acc, type) => {\n const {allTypes, unknownTypes, emptyUnions} = walkAndCountQueryTypeNodeStats(type)\n return {\n allTypes: acc.allTypes + allTypes,\n unknownTypes: acc.unknownTypes + unknownTypes,\n emptyUnions: acc.emptyUnions + emptyUnions,\n }\n },\n {allTypes: 1, unknownTypes: 0, emptyUnions: 0}, // count the union type itself\n )\n }\n default: {\n return {allTypes: 1, unknownTypes: 0, emptyUnions: 0}\n }\n }\n}\n\nmain()\n"],"names":["createDebug","isMainThread","parentPort","_workerData","registerBabel","readSchema","TypeGenerator","getResolver","findQueriesInPath","safeParseQuery","typeEvaluate"],"mappings":";;;;;;AAaA,MAAM,QAAQA,
|
|
1
|
+
{"version":3,"file":"typegenGenerate.js","sources":["../../src/workers/typegenGenerate.ts"],"sourcesContent":["import {isMainThread, parentPort, workerData as _workerData} from 'node:worker_threads'\n\nimport {\n findQueriesInPath,\n getResolver,\n readSchema,\n registerBabel,\n safeParseQuery,\n TypeGenerator,\n} from '@sanity/codegen'\nimport createDebug from 'debug'\nimport {typeEvaluate, type TypeNode} from 'groq-js'\n\nconst $info = createDebug('sanity:codegen:generate:info')\n\nexport interface TypegenGenerateTypesWorkerData {\n workDir: string\n workspaceName?: string\n schemaPath: string\n searchPath: string | string[]\n overloadClientMethods?: boolean\n}\n\nexport type TypegenGenerateTypesWorkerMessage =\n | {\n type: 'error'\n error: Error\n fatal: boolean\n query?: string\n filename?: string\n }\n | {\n type: 'types'\n filename: string\n types: {\n queryName: string\n query: string\n type: string\n unknownTypeNodesGenerated: number\n typeNodesGenerated: number\n emptyUnionTypeNodesGenerated: number\n }[]\n }\n | {\n type: 'schema'\n filename: string\n schema: string\n length: number\n }\n | {\n type: 'typemap'\n typeMap: string\n }\n | {\n type: 'complete'\n }\n\nif (isMainThread || !parentPort) {\n throw new Error('This module must be run as a worker thread')\n}\n\nconst opts = _workerData as TypegenGenerateTypesWorkerData\n\nregisterBabel()\n\nasync function main() {\n const schema = await readSchema(opts.schemaPath)\n\n const typeGenerator = new TypeGenerator(schema)\n const schemaTypes = [typeGenerator.generateSchemaTypes(), TypeGenerator.generateKnownTypes()]\n .join('\\n')\n .trim()\n const resolver = getResolver()\n\n parentPort?.postMessage({\n type: 'schema',\n schema: `${schemaTypes.trim()}\\n`,\n filename: 'schema.json',\n length: schema.length,\n } satisfies TypegenGenerateTypesWorkerMessage)\n\n const queries = findQueriesInPath({\n path: opts.searchPath,\n resolver,\n })\n\n const allQueries = []\n\n for await (const result of queries) {\n if (result.type === 'error') {\n parentPort?.postMessage({\n type: 'error',\n error: result.error,\n fatal: false,\n filename: result.filename,\n } satisfies TypegenGenerateTypesWorkerMessage)\n continue\n }\n $info(`Processing ${result.queries.length} queries in \"${result.filename}\"...`)\n\n const fileQueryTypes: {\n queryName: string\n query: string\n type: string\n typeName: string\n typeNode: TypeNode\n unknownTypeNodesGenerated: number\n typeNodesGenerated: number\n emptyUnionTypeNodesGenerated: number\n }[] = []\n for (const {name: queryName, result: query} of result.queries) {\n try {\n const ast = safeParseQuery(query)\n const queryTypes = typeEvaluate(ast, schema)\n\n const typeName = `${queryName}Result`\n const type = typeGenerator.generateTypeNodeTypes(typeName, queryTypes)\n\n const queryTypeStats = walkAndCountQueryTypeNodeStats(queryTypes)\n fileQueryTypes.push({\n queryName,\n query,\n typeName,\n typeNode: queryTypes,\n type: `${type.trim()}\\n`,\n unknownTypeNodesGenerated: queryTypeStats.unknownTypes,\n typeNodesGenerated: queryTypeStats.allTypes,\n emptyUnionTypeNodesGenerated: queryTypeStats.emptyUnions,\n })\n } catch (err) {\n parentPort?.postMessage({\n type: 'error',\n error: new Error(\n `Error generating types for query \"${queryName}\" in \"${result.filename}\": ${err.message}`,\n {cause: err},\n ),\n fatal: false,\n query,\n } satisfies TypegenGenerateTypesWorkerMessage)\n }\n }\n\n if (fileQueryTypes.length > 0) {\n $info(`Generated types for ${fileQueryTypes.length} queries in \"${result.filename}\"\\n`)\n parentPort?.postMessage({\n type: 'types',\n types: fileQueryTypes,\n filename: result.filename,\n } satisfies TypegenGenerateTypesWorkerMessage)\n }\n\n if (fileQueryTypes.length > 0) {\n allQueries.push(...fileQueryTypes)\n }\n }\n\n if (opts.overloadClientMethods && allQueries.length > 0) {\n const typeMap = `${typeGenerator.generateQueryMap(allQueries).trim()}\\n`\n parentPort?.postMessage({\n type: 'typemap',\n typeMap,\n } satisfies TypegenGenerateTypesWorkerMessage)\n }\n\n parentPort?.postMessage({\n type: 'complete',\n } satisfies TypegenGenerateTypesWorkerMessage)\n}\n\nfunction walkAndCountQueryTypeNodeStats(typeNode: TypeNode): {\n allTypes: number\n unknownTypes: number\n emptyUnions: number\n} {\n switch (typeNode.type) {\n case 'unknown': {\n return {allTypes: 1, unknownTypes: 1, emptyUnions: 0}\n }\n case 'array': {\n const acc = walkAndCountQueryTypeNodeStats(typeNode.of)\n acc.allTypes += 1 // count the array type itself\n return acc\n }\n case 'object': {\n // if the rest is unknown, we count it as one unknown type\n if (typeNode.rest && typeNode.rest.type === 'unknown') {\n return {allTypes: 2, unknownTypes: 1, emptyUnions: 0} // count the object type itself as well\n }\n\n const restStats = typeNode.rest\n ? walkAndCountQueryTypeNodeStats(typeNode.rest)\n : {allTypes: 1, unknownTypes: 0, emptyUnions: 0} // count the object type itself\n\n return Object.values(typeNode.attributes).reduce((acc, attribute) => {\n const {allTypes, unknownTypes, emptyUnions} = walkAndCountQueryTypeNodeStats(\n attribute.value,\n )\n return {\n allTypes: acc.allTypes + allTypes,\n unknownTypes: acc.unknownTypes + unknownTypes,\n emptyUnions: acc.emptyUnions + emptyUnions,\n }\n }, restStats)\n }\n case 'union': {\n if (typeNode.of.length === 0) {\n return {allTypes: 1, unknownTypes: 0, emptyUnions: 1}\n }\n\n return typeNode.of.reduce(\n (acc, type) => {\n const {allTypes, unknownTypes, emptyUnions} = walkAndCountQueryTypeNodeStats(type)\n return {\n allTypes: acc.allTypes + allTypes,\n unknownTypes: acc.unknownTypes + unknownTypes,\n emptyUnions: acc.emptyUnions + emptyUnions,\n }\n },\n {allTypes: 1, unknownTypes: 0, emptyUnions: 0}, // count the union type itself\n )\n }\n default: {\n return {allTypes: 1, unknownTypes: 0, emptyUnions: 0}\n }\n }\n}\n\nmain()\n"],"names":["createDebug","isMainThread","parentPort","_workerData","registerBabel","readSchema","TypeGenerator","getResolver","findQueriesInPath","safeParseQuery","typeEvaluate"],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/cli",
|
|
3
|
-
"version": "3.93.
|
|
3
|
+
"version": "3.93.1-bump-pkg-utils.34.5d0c0b3d22",
|
|
4
4
|
"description": "Sanity CLI tool for managing Sanity installations, managing plugins, schemas and datasets",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sanity",
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
"bin",
|
|
44
44
|
"codemods",
|
|
45
45
|
"lib",
|
|
46
|
-
"src",
|
|
47
46
|
"templates"
|
|
48
47
|
],
|
|
49
48
|
"scripts": {
|
|
@@ -59,11 +58,11 @@
|
|
|
59
58
|
"dependencies": {
|
|
60
59
|
"@babel/traverse": "^7.27.4",
|
|
61
60
|
"@sanity/client": "^7.6.0",
|
|
62
|
-
"@sanity/codegen": "3.93.
|
|
61
|
+
"@sanity/codegen": "3.93.1-bump-pkg-utils.34.5d0c0b3d22",
|
|
63
62
|
"@sanity/runtime-cli": "^8.1.0",
|
|
64
63
|
"@sanity/telemetry": "^0.8.0",
|
|
65
64
|
"@sanity/template-validator": "^2.4.3",
|
|
66
|
-
"@sanity/util": "3.93.
|
|
65
|
+
"@sanity/util": "3.93.1-bump-pkg-utils.34.5d0c0b3d22",
|
|
67
66
|
"chalk": "^4.1.2",
|
|
68
67
|
"debug": "^4.3.4",
|
|
69
68
|
"decompress": "^4.2.0",
|
|
@@ -81,10 +80,10 @@
|
|
|
81
80
|
"@repo/package.config": "3.93.0",
|
|
82
81
|
"@repo/test-config": "3.93.0",
|
|
83
82
|
"@rexxars/gitconfiglocal": "^3.0.1",
|
|
84
|
-
"@rollup/plugin-node-resolve": "^
|
|
83
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
85
84
|
"@sanity/eslint-config-studio": "^5.0.2",
|
|
86
85
|
"@sanity/generate-help-url": "^3.0.0",
|
|
87
|
-
"@sanity/types": "3.93.
|
|
86
|
+
"@sanity/types": "3.93.1-bump-pkg-utils.34.5d0c0b3d22",
|
|
88
87
|
"@types/babel__traverse": "^7.20.5",
|
|
89
88
|
"@types/configstore": "^5.0.1",
|
|
90
89
|
"@types/cpx": "^1.5.2",
|
|
@@ -137,5 +136,5 @@
|
|
|
137
136
|
"engines": {
|
|
138
137
|
"node": ">=18"
|
|
139
138
|
},
|
|
140
|
-
"gitHead": "
|
|
139
|
+
"gitHead": "5d0c0b3d2247f0daedb6846bae52ea62470c9a6d"
|
|
141
140
|
}
|
package/templates/blog/README.md
CHANGED
|
@@ -7,5 +7,5 @@ Now you can do the following things:
|
|
|
7
7
|
- [Read “getting started” in the docs](https://www.sanity.io/docs/introduction/getting-started?utm_source=readme)
|
|
8
8
|
- Check out the example frontend: [React/Next.js](https://github.com/sanity-io/tutorial-sanity-blog-react-next)
|
|
9
9
|
- [Read the blog post about this template](https://www.sanity.io/blog/build-your-own-blog-with-sanity-and-next-js?utm_source=readme)
|
|
10
|
-
- [Join the community
|
|
10
|
+
- [Join the Sanity community](https://www.sanity.io/community/join?utm_source=readme)
|
|
11
11
|
- [Extend and build plugins](https://www.sanity.io/docs/content-studio/extending?utm_source=readme)
|
|
@@ -5,5 +5,5 @@ Congratulations, you have now installed the Sanity Content Studio, an open-sourc
|
|
|
5
5
|
Now you can do the following things:
|
|
6
6
|
|
|
7
7
|
- [Read “getting started” in the docs](https://www.sanity.io/docs/introduction/getting-started?utm_source=readme)
|
|
8
|
-
- [Join the community
|
|
8
|
+
- [Join the Sanity community](https://www.sanity.io/community/join?utm_source=readme)
|
|
9
9
|
- [Extend and build plugins](https://www.sanity.io/docs/content-studio/extending?utm_source=readme)
|
|
@@ -7,5 +7,5 @@ Now you can do the following things:
|
|
|
7
7
|
- [Read “getting started” in the docs](https://www.sanity.io/docs/introduction/getting-started?utm_source=readme)
|
|
8
8
|
- Check out the example frontend: [Vue/Nuxt.js](https://github.com/sanity-io/example-ecommerce-snipcart-vue)
|
|
9
9
|
- [Read the blog post about this template](https://www.sanity.io/blog/e-commerce-vue-nuxt-snipcart?uutm_source=readme)
|
|
10
|
-
- [Join the community
|
|
10
|
+
- [Join the Sanity community](https://www.sanity.io/community/join?utm_source=readme)
|
|
11
11
|
- [Extend and build plugins](https://www.sanity.io/docs/content-studio/extending?utm_source=readme)
|
|
@@ -5,5 +5,5 @@ Congratulations, you have now installed the Sanity Content Studio, an open-sourc
|
|
|
5
5
|
Now you can do the following things:
|
|
6
6
|
|
|
7
7
|
- [Read “getting started” in the docs](https://www.sanity.io/docs/introduction/getting-started?utm_source=readme)
|
|
8
|
-
- [Join the community
|
|
8
|
+
- [Join the Sanity community](https://www.sanity.io/community/join?utm_source=readme)
|
|
9
9
|
- [Extend and build plugins](https://www.sanity.io/docs/content-studio/extending?utm_source=readme)
|
|
@@ -6,5 +6,5 @@ Now you can do the following things:
|
|
|
6
6
|
|
|
7
7
|
- [Read “getting started” in the docs](https://www.sanity.io/docs/introduction/getting-started?utm_source=readme)
|
|
8
8
|
- Check out one of the example frontends: [React](https://github.com/sanity-io/example-frontend-next-js) | [React Native](https://github.com/sanity-io/example-app-react-native) | [Vue](https://github.com/sanity-io/example-frontend-vue-js) | [PHP](https://github.com/sanity-io/example-frontend-silex-twig)
|
|
9
|
-
- [Join the community
|
|
9
|
+
- [Join the Sanity community](https://www.sanity.io/community/join?utm_source=readme)
|
|
10
10
|
- [Extend and build plugins](https://www.sanity.io/docs/content-studio/extending?utm_source=readme)
|
|
@@ -5,5 +5,5 @@ Congratulations, you have now installed Sanity Studio, an open-source real-time
|
|
|
5
5
|
Now you can do the following things:
|
|
6
6
|
|
|
7
7
|
- [Read “getting started” in the docs](https://www.sanity.io/docs/introduction/getting-started?utm_source=readme)
|
|
8
|
-
- [Join the community
|
|
8
|
+
- [Join the Sanity community](https://www.sanity.io/community/join?utm_source=readme)
|
|
9
9
|
- [Extend and build plugins](https://www.sanity.io/docs/content-studio/extending?utm_source=readme)
|
package/src/CommandRunner.ts
DELETED
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
import {cloneDeep, sortBy} from 'lodash'
|
|
3
|
-
|
|
4
|
-
import {baseCommands} from './commands'
|
|
5
|
-
import {debug} from './debug'
|
|
6
|
-
import cliOutputter from './outputters/cliOutputter'
|
|
7
|
-
import {cliPackageManager} from './packageManager'
|
|
8
|
-
import {prompt as cliPrompter} from './prompters/cliPrompter'
|
|
9
|
-
import {
|
|
10
|
-
type CliCommandArguments,
|
|
11
|
-
type CliCommandContext,
|
|
12
|
-
type CliCommandDefinition,
|
|
13
|
-
type CliCommandGroupDefinition,
|
|
14
|
-
type CliConfig,
|
|
15
|
-
type CliOutputter,
|
|
16
|
-
type CliPrompter,
|
|
17
|
-
type CommandRunnerOptions,
|
|
18
|
-
type ResolvedCliCommand,
|
|
19
|
-
type SanityJson,
|
|
20
|
-
} from './types'
|
|
21
|
-
import {getClientWrapper} from './util/clientWrapper'
|
|
22
|
-
import {
|
|
23
|
-
generateCommandDocumentation,
|
|
24
|
-
generateCommandsDocumentation,
|
|
25
|
-
} from './util/generateCommandsDocumentation'
|
|
26
|
-
import {type CliConfigResult} from './util/getCliConfig'
|
|
27
|
-
import {isCommandGroup} from './util/isCommandGroup'
|
|
28
|
-
import {getNoSuchCommandText} from './util/noSuchCommandText'
|
|
29
|
-
|
|
30
|
-
interface Handlers {
|
|
31
|
-
outputter: CliOutputter
|
|
32
|
-
prompter: CliPrompter
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
type CommandOrGroup = CliCommandDefinition | CliCommandGroupDefinition
|
|
36
|
-
|
|
37
|
-
export class CommandRunner {
|
|
38
|
-
public handlers: Handlers
|
|
39
|
-
public commands: CommandOrGroup[]
|
|
40
|
-
public commandGroups: Record<string, (CliCommandDefinition | CliCommandGroupDefinition)[]>
|
|
41
|
-
|
|
42
|
-
constructor(handlers: Handlers, commands: CommandOrGroup[] = baseCommands) {
|
|
43
|
-
this.handlers = handlers
|
|
44
|
-
this.commands = sortBy(commands, 'name')
|
|
45
|
-
this.commandGroups = {}
|
|
46
|
-
for (const cmd of this.commands) {
|
|
47
|
-
const group = ('group' in cmd && cmd.group) || 'default'
|
|
48
|
-
this.commandGroups[group] = this.commandGroups[group] || []
|
|
49
|
-
this.commandGroups[group].push(cmd)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
if (!handlers.outputter || !handlers.prompter) {
|
|
53
|
-
throw new Error('`prompter` and `outputter` handlers must be defined')
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
async runCommand(
|
|
58
|
-
commandOrGroup: string,
|
|
59
|
-
args: CliCommandArguments,
|
|
60
|
-
options: CommandRunnerOptions,
|
|
61
|
-
): Promise<unknown> {
|
|
62
|
-
if (!commandOrGroup) {
|
|
63
|
-
this.handlers.outputter.print(generateCommandsDocumentation(this.commandGroups))
|
|
64
|
-
return Promise.resolve()
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// We might modify arguments for easier parsing in subcommand
|
|
68
|
-
const cmdArgs = cloneDeep(args)
|
|
69
|
-
const subCommandName = args.argsWithoutOptions[0]
|
|
70
|
-
|
|
71
|
-
const commandInfo = this.resolveCommand(commandOrGroup, subCommandName)
|
|
72
|
-
if (!commandInfo) {
|
|
73
|
-
throw new Error(getNoSuchCommandText(commandOrGroup, subCommandName, this.commandGroups))
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const command = commandInfo.command
|
|
77
|
-
|
|
78
|
-
if (!isCommandGroup(command) && command.group && command.group !== 'default') {
|
|
79
|
-
cmdArgs.argsWithoutOptions = args.argsWithoutOptions.slice(1)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const output = this.handlers.outputter
|
|
83
|
-
const prompt = this.handlers.prompter
|
|
84
|
-
|
|
85
|
-
const {cliConfig, ...commandOptions} = options
|
|
86
|
-
const apiClient = getClientWrapper(
|
|
87
|
-
cliConfig?.config?.api || null,
|
|
88
|
-
cliConfig?.path || (cliConfig?.version === 2 ? 'sanity.json' : 'sanity.cli.js'),
|
|
89
|
-
)
|
|
90
|
-
|
|
91
|
-
const context: CliCommandContext = {
|
|
92
|
-
output,
|
|
93
|
-
prompt,
|
|
94
|
-
apiClient,
|
|
95
|
-
chalk,
|
|
96
|
-
cliPackageManager,
|
|
97
|
-
...commandOptions,
|
|
98
|
-
commandRunner: this,
|
|
99
|
-
...getVersionedContextParams(cliConfig),
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
if (isCommandGroup(command)) {
|
|
103
|
-
return context.output.print(generateCommandsDocumentation(this.commandGroups, command.name))
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
if (typeof command.action !== 'function') {
|
|
107
|
-
const cmdName = command.name || commandOrGroup || '<unknown>'
|
|
108
|
-
debug(`Command "${cmdName}" doesnt have a valid "action"-property, showing help`)
|
|
109
|
-
const groupName = command.group && command.group !== 'default' ? command.group : null
|
|
110
|
-
return context.output.print(generateCommandDocumentation(command, groupName, subCommandName))
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
debug(`Running command "${command.name}"`)
|
|
114
|
-
return command.action(cmdArgs, context)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
resolveCommand(commandOrGroup: string, subCommandName?: string): ResolvedCliCommand | null {
|
|
118
|
-
// First, see if there is a group with the given name, if a subcommand is provided
|
|
119
|
-
if (this.commandGroups[commandOrGroup] && subCommandName) {
|
|
120
|
-
debug(`Found group for name "${commandOrGroup}", resolving subcommand`)
|
|
121
|
-
|
|
122
|
-
const subCommand = this.resolveSubcommand(
|
|
123
|
-
this.commandGroups[commandOrGroup],
|
|
124
|
-
subCommandName,
|
|
125
|
-
commandOrGroup,
|
|
126
|
-
)
|
|
127
|
-
|
|
128
|
-
debug(
|
|
129
|
-
subCommand
|
|
130
|
-
? `Subcommand resolved to "${subCommand.commandName}"`
|
|
131
|
-
: `Subcommand with name "${subCommandName}" not found`,
|
|
132
|
-
)
|
|
133
|
-
|
|
134
|
-
return subCommand
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// No group? See if there's a command within the default group
|
|
138
|
-
debug(`No group found with name "${commandOrGroup}", looking for command`)
|
|
139
|
-
const command = this.commandGroups.default.find((cmd) => cmd.name === commandOrGroup)
|
|
140
|
-
if (command) {
|
|
141
|
-
debug(`Found command in default group with name "${commandOrGroup}"`)
|
|
142
|
-
return {
|
|
143
|
-
command: command,
|
|
144
|
-
commandName: command.name,
|
|
145
|
-
parentName: 'default',
|
|
146
|
-
isGroup: false,
|
|
147
|
-
isCommand: true,
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
debug(`No default command with name "${commandOrGroup}" found, giving up`)
|
|
152
|
-
return null
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
resolveSubcommand(
|
|
156
|
-
group: (CliCommandDefinition | CliCommandGroupDefinition)[],
|
|
157
|
-
subCommandName: string,
|
|
158
|
-
parentGroupName: string,
|
|
159
|
-
): ResolvedCliCommand | null {
|
|
160
|
-
if (!subCommandName) {
|
|
161
|
-
return null
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
const subCommand = group.find((cmd) => cmd.name === subCommandName)
|
|
165
|
-
if (!subCommand) {
|
|
166
|
-
throw new Error(getNoSuchCommandText(subCommandName, parentGroupName, this.commandGroups))
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
return {
|
|
170
|
-
command: subCommand,
|
|
171
|
-
commandName: subCommandName,
|
|
172
|
-
parentName: parentGroupName,
|
|
173
|
-
isGroup: false,
|
|
174
|
-
isCommand: true,
|
|
175
|
-
}
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
resolveHelpForGroup(): ResolvedCliCommand {
|
|
179
|
-
const command = this.commandGroups.default.find((cmd) => cmd.name === 'help')
|
|
180
|
-
if (!command) {
|
|
181
|
-
throw new Error('Failed to find default `help` command')
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
return {
|
|
185
|
-
command,
|
|
186
|
-
commandName: 'help',
|
|
187
|
-
isGroup: false,
|
|
188
|
-
isCommand: true,
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
export function getCliRunner(commands: CommandOrGroup[]): CommandRunner {
|
|
194
|
-
return new CommandRunner(
|
|
195
|
-
{
|
|
196
|
-
outputter: cliOutputter,
|
|
197
|
-
prompter: cliPrompter,
|
|
198
|
-
},
|
|
199
|
-
commands,
|
|
200
|
-
)
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
function getVersionedContextParams(
|
|
204
|
-
cliConfig: CliConfigResult | null,
|
|
205
|
-
):
|
|
206
|
-
| {sanityMajorVersion: 2; cliConfig?: SanityJson; cliConfigPath?: string}
|
|
207
|
-
| {sanityMajorVersion: 3; cliConfig?: CliConfig; cliConfigPath?: string} {
|
|
208
|
-
return cliConfig?.version === 2
|
|
209
|
-
? {
|
|
210
|
-
sanityMajorVersion: 2,
|
|
211
|
-
cliConfig: cliConfig?.config || undefined,
|
|
212
|
-
cliConfigPath: cliConfig?.path || undefined,
|
|
213
|
-
}
|
|
214
|
-
: {
|
|
215
|
-
sanityMajorVersion: 3,
|
|
216
|
-
cliConfig: cliConfig?.config || undefined,
|
|
217
|
-
cliConfigPath: cliConfig?.path || undefined,
|
|
218
|
-
}
|
|
219
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import {defineTrace} from '@sanity/telemetry'
|
|
2
|
-
|
|
3
|
-
interface CLITraceData {
|
|
4
|
-
/**
|
|
5
|
-
* Command flags, without the core options (help, debug, version etc)
|
|
6
|
-
*/
|
|
7
|
-
groupOrCommand: string
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Command arguments, eg any arguments after `sanity <command>` (no flags)
|
|
11
|
-
*/
|
|
12
|
-
commandArguments: string[]
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Arguments after the ended argument list (--)
|
|
16
|
-
*/
|
|
17
|
-
extraArguments: string[]
|
|
18
|
-
coreOptions: {
|
|
19
|
-
help?: boolean
|
|
20
|
-
debug?: boolean
|
|
21
|
-
version?: boolean
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const CliCommand = defineTrace<CLITraceData>({
|
|
26
|
-
name: 'CLI Command Executed',
|
|
27
|
-
version: 1,
|
|
28
|
-
description: 'A CLI command was executed',
|
|
29
|
-
})
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import {defineTrace} from '@sanity/telemetry'
|
|
2
|
-
|
|
3
|
-
interface StartStep {
|
|
4
|
-
step: 'start'
|
|
5
|
-
flags: Record<string, string | number | undefined | boolean>
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
interface LoginStep {
|
|
9
|
-
step: 'login'
|
|
10
|
-
alreadyLoggedIn?: boolean
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
interface FetchJourneyConfigStep {
|
|
14
|
-
step: 'fetchJourneyConfig'
|
|
15
|
-
projectId: string
|
|
16
|
-
datasetName: string
|
|
17
|
-
displayName: string
|
|
18
|
-
isFirstProject: boolean
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface CreateOrSelectProjectStep {
|
|
22
|
-
step: 'createOrSelectProject'
|
|
23
|
-
projectId: string
|
|
24
|
-
selectedOption: 'create' | 'select' | 'none'
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
interface CreateOrSelectDatasetStep {
|
|
28
|
-
step: 'createOrSelectDataset'
|
|
29
|
-
datasetName: string
|
|
30
|
-
selectedOption: 'create' | 'select' | 'none'
|
|
31
|
-
visibility: 'private' | 'public'
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface UseDefaultPlanCoupon {
|
|
35
|
-
step: 'useDefaultPlanCoupon'
|
|
36
|
-
selectedOption: 'yes' | 'no'
|
|
37
|
-
coupon?: string
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
interface UseDefaultPlanId {
|
|
41
|
-
step: 'useDefaultPlanId'
|
|
42
|
-
selectedOption: 'yes' | 'no'
|
|
43
|
-
planId?: string
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
interface UseDetectedFrameworkStep {
|
|
47
|
-
step: 'useDetectedFramework'
|
|
48
|
-
selectedOption: 'yes' | 'no'
|
|
49
|
-
detectedFramework?: string
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
interface UseTypeScriptStep {
|
|
53
|
-
step: 'useTypeScript'
|
|
54
|
-
selectedOption: 'yes' | 'no'
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
interface SelectTemplateStep {
|
|
58
|
-
step: 'selectProjectTemplate'
|
|
59
|
-
selectedOption: string
|
|
60
|
-
}
|
|
61
|
-
interface ImportTemplateDatasetStep {
|
|
62
|
-
step: 'importTemplateDataset'
|
|
63
|
-
selectedOption: 'yes' | 'no'
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
interface SendCommunityInviteStep {
|
|
67
|
-
step: 'sendCommunityInvite'
|
|
68
|
-
selectedOption: 'yes' | 'no'
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
interface SelectPackageManagerStep {
|
|
72
|
-
step: 'selectPackageManager'
|
|
73
|
-
selectedOption: string
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
type InitStepResult =
|
|
77
|
-
| StartStep
|
|
78
|
-
| LoginStep
|
|
79
|
-
| FetchJourneyConfigStep
|
|
80
|
-
| CreateOrSelectProjectStep
|
|
81
|
-
| CreateOrSelectDatasetStep
|
|
82
|
-
| UseDetectedFrameworkStep
|
|
83
|
-
| UseTypeScriptStep
|
|
84
|
-
| ImportTemplateDatasetStep
|
|
85
|
-
| SendCommunityInviteStep
|
|
86
|
-
| SelectPackageManagerStep
|
|
87
|
-
| SelectTemplateStep
|
|
88
|
-
| UseDefaultPlanCoupon
|
|
89
|
-
| UseDefaultPlanId
|
|
90
|
-
|
|
91
|
-
export const CLIInitStepCompleted = defineTrace<InitStepResult>({
|
|
92
|
-
name: 'CLI Init Step Completed',
|
|
93
|
-
version: 1,
|
|
94
|
-
description: 'User completed a step in the CLI init flow',
|
|
95
|
-
})
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-process-exit, no-sync */
|
|
2
|
-
import childProcess from 'node:child_process'
|
|
3
|
-
import fs from 'node:fs'
|
|
4
|
-
import path from 'node:path'
|
|
5
|
-
|
|
6
|
-
import {type CliCommandAction, type CliCommandContext} from '../../types'
|
|
7
|
-
import mods from './mods'
|
|
8
|
-
import {type CodeMod} from './types'
|
|
9
|
-
|
|
10
|
-
export interface CodeModFlags {
|
|
11
|
-
extensions?: string
|
|
12
|
-
verify?: boolean
|
|
13
|
-
dry?: boolean
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const codemodAction: CliCommandAction<CodeModFlags> = async function codemodAction(
|
|
17
|
-
args,
|
|
18
|
-
context,
|
|
19
|
-
) {
|
|
20
|
-
const {output, cliRoot, workDir} = context
|
|
21
|
-
const [name] = args.argsWithoutOptions
|
|
22
|
-
const cliFlags = args.extOptions
|
|
23
|
-
if (!name) {
|
|
24
|
-
printMods(output)
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Make a record where all the keys of the available codemods are lowercased,
|
|
29
|
-
// eg `reactIconsV3` turns into `{reacticonsv3: CodeMod}`
|
|
30
|
-
const normalizedMods: Record<string, CodeMod> = {}
|
|
31
|
-
for (const [originalName, mod] of Object.entries(mods)) {
|
|
32
|
-
normalizedMods[originalName.toLowerCase()] = mod
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Verify that mod exists
|
|
36
|
-
const mod = normalizedMods[name.toLowerCase()]
|
|
37
|
-
if (!mod) {
|
|
38
|
-
throw new Error(`Codemod with name "${name}" not found`)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Verify if there is any verification deefined, and user has not opted out of it
|
|
42
|
-
if (typeof mod.verify === 'function' && cliFlags.verify !== false) {
|
|
43
|
-
await mod.verify(context)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// If extensions are defined, they come in as CSV, so split and normalize them
|
|
47
|
-
const exts = cliFlags.extensions
|
|
48
|
-
? cliFlags.extensions.split(',').map((ext) => ext.trim().replace(/^\./, ''))
|
|
49
|
-
: ['js', 'ts', 'tsx']
|
|
50
|
-
|
|
51
|
-
const dryRun = Boolean(typeof cliFlags.dry === 'undefined' ? false : cliFlags.dry)
|
|
52
|
-
|
|
53
|
-
// We use npx to run jscodeshift, so verify that it exists and works before using it
|
|
54
|
-
ensureNpx()
|
|
55
|
-
|
|
56
|
-
// If there is a gitignore in the target folder, we want to use that to know
|
|
57
|
-
// which folders to ignore - eg `dist`, `coverage` or whatever
|
|
58
|
-
const hasGitIgnore = fs.existsSync(path.join(workDir, '.gitignore'))
|
|
59
|
-
|
|
60
|
-
// Build the CLI command arguments
|
|
61
|
-
const modPath = path.resolve(path.join(cliRoot, 'codemods', mod.filename))
|
|
62
|
-
const cmdArgs = [
|
|
63
|
-
'jscodeshift',
|
|
64
|
-
'--ignore-pattern',
|
|
65
|
-
'node_modules',
|
|
66
|
-
'--ignore-pattern',
|
|
67
|
-
'dist',
|
|
68
|
-
hasGitIgnore && '--ignore-config',
|
|
69
|
-
hasGitIgnore && '.gitignore',
|
|
70
|
-
'-t',
|
|
71
|
-
modPath,
|
|
72
|
-
'--extensions',
|
|
73
|
-
exts.join(','),
|
|
74
|
-
dryRun && '--dry',
|
|
75
|
-
workDir,
|
|
76
|
-
].filter((item): item is string => typeof item === 'string')
|
|
77
|
-
|
|
78
|
-
const child = childProcess.spawn('npx', cmdArgs, {
|
|
79
|
-
stdio: 'inherit',
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
process.on('SIGINT', () => {
|
|
83
|
-
child.kill(2)
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
child.on('close', (code) => {
|
|
87
|
-
process.exit(code || undefined)
|
|
88
|
-
})
|
|
89
|
-
}
|
|
90
|
-
function printMods(output: CliCommandContext['output']) {
|
|
91
|
-
output.print('Available code modifications:\n')
|
|
92
|
-
|
|
93
|
-
for (const [modName, mod] of Object.entries(mods)) {
|
|
94
|
-
output.print(`${modName} - ${mod.purpose}`)
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
function ensureNpx() {
|
|
99
|
-
try {
|
|
100
|
-
const npxHelp = childProcess.execSync('npx --help', {encoding: 'utf8'})
|
|
101
|
-
if (!npxHelp.includes('npm')) {
|
|
102
|
-
throw new Error('Not the npx we expected')
|
|
103
|
-
}
|
|
104
|
-
} catch {
|
|
105
|
-
throw new Error(
|
|
106
|
-
`Failed to run "npx" - required to run codemods. Do you have a recent version of npm installed?`,
|
|
107
|
-
)
|
|
108
|
-
}
|
|
109
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import {type CodeMod} from '../types'
|
|
2
|
-
|
|
3
|
-
const purpose = 'Transform `sanity/desk` imports to `sanity/structure`'
|
|
4
|
-
const description = `
|
|
5
|
-
Modifies all code paths that are found to import from 'sanity/desk' to instead import from
|
|
6
|
-
'sanity/structure', and renames any renamed members.
|
|
7
|
-
|
|
8
|
-
from: import {deskTool} from 'sanity/desk'
|
|
9
|
-
to: import {structureTool} from 'sanity/structure'
|
|
10
|
-
|
|
11
|
-
from: import {StructureBuilder} from 'sanity/desk'
|
|
12
|
-
to: import {StructureBuilder} from 'sanity/structure'
|
|
13
|
-
`.trim()
|
|
14
|
-
|
|
15
|
-
export const deskRename: CodeMod = {
|
|
16
|
-
purpose,
|
|
17
|
-
description,
|
|
18
|
-
filename: 'deskRename.js',
|
|
19
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import {type CodeMod} from '../types'
|
|
2
|
-
|
|
3
|
-
const purpose = 'Add parts types directive to all ts/tsx files that has one or more part imports'
|
|
4
|
-
const description = `
|
|
5
|
-
Adds a '///<reference types="@sanity/types/parts" />' header to all source files that has one or more part imports.
|
|
6
|
-
For example:
|
|
7
|
-
|
|
8
|
-
Before:
|
|
9
|
-
---- somefile.ts
|
|
10
|
-
import client from 'part:@sanity/base/client'
|
|
11
|
-
//…
|
|
12
|
-
----
|
|
13
|
-
|
|
14
|
-
After:
|
|
15
|
-
---- somefile.ts
|
|
16
|
-
///<reference types="@sanity/types/parts" />
|
|
17
|
-
import client from 'part:@sanity/base/client'
|
|
18
|
-
//…
|
|
19
|
-
----
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
`.trim()
|
|
23
|
-
|
|
24
|
-
export const partsTypeDirective: CodeMod = {
|
|
25
|
-
purpose,
|
|
26
|
-
description,
|
|
27
|
-
filename: 'partsTypeDirective.js',
|
|
28
|
-
}
|