@sanity/cli 3.72.2-canary.32 → 3.72.2-corel.23
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 +73 -127
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/lib/index.d.mts +0 -9
- package/lib/index.d.ts +0 -9
- package/package.json +9 -9
- package/src/actions/init-project/bootstrapLocalTemplate.ts +20 -32
- package/src/actions/init-project/createCliConfig.ts +47 -5
- package/src/actions/init-project/createPackageManifest.ts +1 -1
- package/src/actions/init-project/createStudioConfig.ts +27 -4
- package/src/actions/init-project/initProject.ts +2 -21
- package/src/actions/init-project/templates/index.ts +0 -2
- package/src/types.ts +0 -10
- package/src/actions/init-project/createCoreAppCliConfig.ts +0 -23
- package/src/actions/init-project/determineCoreAppTemplate.ts +0 -13
- package/src/actions/init-project/processTemplate.ts +0 -55
- package/src/actions/init-project/templates/coreApp.ts +0 -31
- package/templates/core-app/src/App.tsx +0 -26
package/lib/_chunks-cjs/cli.js
CHANGED
@@ -46514,38 +46514,6 @@ var typescriptExports = requireTypescript(), typescript = /* @__PURE__ */ loadEn
|
|
46514
46514
|
__proto__: null,
|
46515
46515
|
default: typescript
|
46516
46516
|
}, [typescriptExports]);
|
46517
|
-
function processTemplate(options2) {
|
46518
|
-
const { template, variables, includeBooleanTransform = !1 } = options2, ast = mainExports.parse(template.trimStart(), { parser });
|
46519
|
-
return traverse__default.default(ast, {
|
46520
|
-
StringLiteral: {
|
46521
|
-
enter({ node }) {
|
46522
|
-
const value = node.value;
|
46523
|
-
if (!value.startsWith("%") || !value.endsWith("%"))
|
46524
|
-
return;
|
46525
|
-
const variableName = value.slice(1, -1);
|
46526
|
-
if (!(variableName in variables))
|
46527
|
-
throw new Error(`Template variable '${value}' not defined`);
|
46528
|
-
const newValue = variables[variableName];
|
46529
|
-
node.value = typeof newValue == "string" ? newValue : "";
|
46530
|
-
}
|
46531
|
-
},
|
46532
|
-
...includeBooleanTransform && {
|
46533
|
-
Identifier: {
|
46534
|
-
enter(path2) {
|
46535
|
-
if (!path2.node.name.startsWith("__BOOL__"))
|
46536
|
-
return;
|
46537
|
-
const variableName = path2.node.name.replace(/^__BOOL__(.+?)__$/, "$1");
|
46538
|
-
if (!(variableName in variables))
|
46539
|
-
throw new Error(`Template variable '${variableName.toString()}' not defined`);
|
46540
|
-
const value = variables[variableName];
|
46541
|
-
if (typeof value != "boolean")
|
46542
|
-
throw new Error(`Expected boolean value for '${variableName.toString()}'`);
|
46543
|
-
path2.replaceWith({ type: "BooleanLiteral", value });
|
46544
|
-
}
|
46545
|
-
}
|
46546
|
-
}
|
46547
|
-
}), mainExports.print(ast, { quote: "single" }).code;
|
46548
|
-
}
|
46549
46517
|
const defaultTemplate$1 = `
|
46550
46518
|
import {defineCliConfig} from 'sanity/cli'
|
46551
46519
|
|
@@ -46562,26 +46530,37 @@ export default defineCliConfig({
|
|
46562
46530
|
})
|
46563
46531
|
`;
|
46564
46532
|
function createCliConfig(options2) {
|
46565
|
-
|
46566
|
-
|
46567
|
-
|
46568
|
-
|
46569
|
-
|
46570
|
-
|
46571
|
-
|
46572
|
-
|
46573
|
-
|
46574
|
-
|
46575
|
-
|
46576
|
-
|
46577
|
-
|
46578
|
-
}
|
46579
|
-
|
46580
|
-
|
46581
|
-
|
46582
|
-
|
46583
|
-
|
46584
|
-
|
46533
|
+
const variables = options2, template = defaultTemplate$1.trimStart(), ast = mainExports.parse(template, { parser });
|
46534
|
+
return traverse__default.default(ast, {
|
46535
|
+
StringLiteral: {
|
46536
|
+
enter({ node }) {
|
46537
|
+
const value = node.value;
|
46538
|
+
if (!value.startsWith("%") || !value.endsWith("%"))
|
46539
|
+
return;
|
46540
|
+
const variableName = value.slice(1, -1);
|
46541
|
+
if (!(variableName in variables))
|
46542
|
+
throw new Error(`Template variable '${value}' not defined`);
|
46543
|
+
const newValue = variables[variableName];
|
46544
|
+
node.value = typeof newValue == "string" ? newValue : "";
|
46545
|
+
}
|
46546
|
+
},
|
46547
|
+
Identifier: {
|
46548
|
+
enter(path2) {
|
46549
|
+
if (!path2.node.name.startsWith("__BOOL__"))
|
46550
|
+
return;
|
46551
|
+
const variableName = path2.node.name.replace(
|
46552
|
+
/^__BOOL__(.+?)__$/,
|
46553
|
+
"$1"
|
46554
|
+
);
|
46555
|
+
if (!(variableName in variables))
|
46556
|
+
throw new Error(`Template variable '${variableName}' not defined`);
|
46557
|
+
const value = variables[variableName];
|
46558
|
+
if (typeof value != "boolean")
|
46559
|
+
throw new Error(`Expected boolean value for '${variableName}'`);
|
46560
|
+
path2.replaceWith({ type: "BooleanLiteral", value });
|
46561
|
+
}
|
46562
|
+
}
|
46563
|
+
}), mainExports.print(ast, { quote: "single" }).code;
|
46585
46564
|
}
|
46586
46565
|
/*!
|
46587
46566
|
* isobject <https://github.com/jonschlinkert/isobject>
|
@@ -46651,7 +46630,7 @@ function createPackageManifest(data) {
|
|
46651
46630
|
...getCommonManifest(data),
|
46652
46631
|
main: "package.json",
|
46653
46632
|
keywords: ["sanity"],
|
46654
|
-
scripts:
|
46633
|
+
scripts: {
|
46655
46634
|
dev: "sanity dev",
|
46656
46635
|
start: "sanity start",
|
46657
46636
|
build: "sanity build",
|
@@ -46720,42 +46699,25 @@ export default defineConfig({
|
|
46720
46699
|
};
|
46721
46700
|
function createStudioConfig(options2) {
|
46722
46701
|
const variables = { ...defaultVariables, ...options2.variables };
|
46723
|
-
|
46724
|
-
|
46725
|
-
|
46726
|
-
|
46727
|
-
|
46728
|
-
|
46729
|
-
|
46730
|
-
|
46702
|
+
if (typeof options2.template == "function")
|
46703
|
+
return options2.template(variables).trimStart();
|
46704
|
+
const template = (options2.template || defaultTemplate).trimStart(), ast = mainExports.parse(template, { parser });
|
46705
|
+
return traverse__default.default(ast, {
|
46706
|
+
StringLiteral: {
|
46707
|
+
enter({ node }) {
|
46708
|
+
const value = node.value;
|
46709
|
+
if (!value.startsWith("%") || !value.endsWith("%"))
|
46710
|
+
return;
|
46711
|
+
const variableName = value.slice(1, -1);
|
46712
|
+
if (!(variableName in variables))
|
46713
|
+
throw new Error(`Template variable '${value}' not defined`);
|
46714
|
+
const newValue = variables[variableName];
|
46715
|
+
node.value = typeof newValue == "string" ? newValue : "";
|
46716
|
+
}
|
46717
|
+
}
|
46718
|
+
}), mainExports.print(ast, { quote: "single" }).code;
|
46731
46719
|
}
|
46732
|
-
const blogTemplate = {}, cleanTemplate = {},
|
46733
|
-
dependencies: {
|
46734
|
-
"@sanity/sdk": "^0.0.0-alpha",
|
46735
|
-
"@sanity/sdk-react": "^0.0.0-alpha",
|
46736
|
-
react: "^19",
|
46737
|
-
"react-dom": "^19"
|
46738
|
-
},
|
46739
|
-
devDependencies: {
|
46740
|
-
/*
|
46741
|
-
* this will be changed to eslint-config sanity,
|
46742
|
-
* eslint.config generation will be a fast follow
|
46743
|
-
*/
|
46744
|
-
"@sanity/eslint-config-studio": "^5.0.1",
|
46745
|
-
"@types/react": "^18.0.25",
|
46746
|
-
eslint: "^9.9.0",
|
46747
|
-
prettier: "^3.0.2",
|
46748
|
-
sanity: "^3",
|
46749
|
-
typescript: "^5.1.6"
|
46750
|
-
},
|
46751
|
-
appLocation: "./src/App.tsx",
|
46752
|
-
scripts: {
|
46753
|
-
// this will eventually run a concurrently process with another in-flight utility
|
46754
|
-
dev: "sanity app dev",
|
46755
|
-
build: "sanity app build",
|
46756
|
-
start: "sanity app start"
|
46757
|
-
}
|
46758
|
-
}, configTemplate$3 = `
|
46720
|
+
const blogTemplate = {}, cleanTemplate = {}, configTemplate$3 = `
|
46759
46721
|
import {defineConfig, isDev} from 'sanity'
|
46760
46722
|
import {visionTool} from '@sanity/vision'
|
46761
46723
|
import {structureTool} from 'sanity/structure'
|
@@ -46933,7 +46895,6 @@ export default defineConfig({
|
|
46933
46895
|
}, templates = {
|
46934
46896
|
blog: blogTemplate,
|
46935
46897
|
clean: cleanTemplate,
|
46936
|
-
"core-app": coreAppTemplate,
|
46937
46898
|
"get-started": getStartedTemplate,
|
46938
46899
|
moviedb: movieTemplate,
|
46939
46900
|
shopify: shopifyTemplate$1,
|
@@ -46954,7 +46915,7 @@ async function updateInitialTemplateMetadata(apiClient, projectId, templateName)
|
|
46954
46915
|
}
|
46955
46916
|
}
|
46956
46917
|
async function bootstrapLocalTemplate(opts, context) {
|
46957
|
-
const { apiClient, cliRoot, output } = context, templatesDir = path__default.default.join(cliRoot, "templates"), { outputPath, templateName, useTypeScript, packageName, variables } = opts, sourceDir = path__default.default.join(templatesDir, templateName), sharedDir = path__default.default.join(templatesDir, "shared"),
|
46918
|
+
const { apiClient, cliRoot, output } = context, templatesDir = path__default.default.join(cliRoot, "templates"), { outputPath, templateName, useTypeScript, packageName, variables } = opts, sourceDir = path__default.default.join(templatesDir, templateName), sharedDir = path__default.default.join(templatesDir, "shared"), template = templates[templateName];
|
46958
46919
|
if (!template)
|
46959
46920
|
throw new Error(`Template "${templateName}" not defined`);
|
46960
46921
|
loadEnv.debug('Copying files from template "%s" to "%s"', templateName, outputPath);
|
@@ -46969,20 +46930,19 @@ async function bootstrapLocalTemplate(opts, context) {
|
|
46969
46930
|
schemaUrl: opts.schemaUrl
|
46970
46931
|
})), spinner.succeed(), spinner = output.spinner("Resolving latest module versions").start();
|
46971
46932
|
const dependencyVersions = await resolveLatestVersions({
|
46972
|
-
...
|
46973
|
-
...
|
46974
|
-
...template.dependencies || {}
|
46975
|
-
...template.devDependencies || {}
|
46933
|
+
...studioDependencies.dependencies,
|
46934
|
+
...studioDependencies.devDependencies,
|
46935
|
+
...template.dependencies || {}
|
46976
46936
|
});
|
46977
46937
|
spinner.succeed();
|
46978
46938
|
const dependencies = Object.keys({
|
46979
|
-
...
|
46939
|
+
...studioDependencies.dependencies,
|
46980
46940
|
...template.dependencies
|
46981
46941
|
}).reduce(
|
46982
46942
|
(deps, dependency) => (deps[dependency] = dependencyVersions[dependency], deps),
|
46983
46943
|
{}
|
46984
46944
|
), devDependencies = Object.keys({
|
46985
|
-
...
|
46945
|
+
...studioDependencies.devDependencies,
|
46986
46946
|
...template.devDependencies
|
46987
46947
|
}).reduce(
|
46988
46948
|
(deps, dependency) => (deps[dependency] = dependencyVersions[dependency], deps),
|
@@ -46992,30 +46952,27 @@ async function bootstrapLocalTemplate(opts, context) {
|
|
46992
46952
|
const packageManifest = await createPackageManifest({
|
46993
46953
|
name: packageName,
|
46994
46954
|
dependencies,
|
46995
|
-
devDependencies
|
46996
|
-
|
46997
|
-
}), studioConfig = createStudioConfig({
|
46955
|
+
devDependencies
|
46956
|
+
}), studioConfig = await createStudioConfig({
|
46998
46957
|
template: template.configTemplate,
|
46999
46958
|
variables
|
47000
|
-
}), cliConfig =
|
46959
|
+
}), cliConfig = await createCliConfig({
|
47001
46960
|
projectId: variables.projectId,
|
47002
46961
|
dataset: variables.dataset,
|
47003
46962
|
autoUpdates: variables.autoUpdates
|
47004
46963
|
}), codeExt = useTypeScript ? "ts" : "js";
|
47005
|
-
return await Promise.all(
|
47006
|
-
|
47007
|
-
|
47008
|
-
|
47009
|
-
|
47010
|
-
|
47011
|
-
|
47012
|
-
`import studio from '@sanity/eslint-config-studio'
|
46964
|
+
return await Promise.all([
|
46965
|
+
writeFileIfNotExists(`sanity.config.${codeExt}`, studioConfig),
|
46966
|
+
writeFileIfNotExists(`sanity.cli.${codeExt}`, cliConfig),
|
46967
|
+
writeFileIfNotExists("package.json", packageManifest),
|
46968
|
+
writeFileIfNotExists(
|
46969
|
+
"eslint.config.mjs",
|
46970
|
+
`import studio from '@sanity/eslint-config-studio'
|
47013
46971
|
|
47014
46972
|
export default [...studio]
|
47015
46973
|
`
|
47016
|
-
|
47017
|
-
|
47018
|
-
), loadEnv.debug("Updating initial template metadata"), await updateInitialTemplateMetadata(apiClient, variables.projectId, `cli-${templateName}`), spinner.succeed(), template;
|
46974
|
+
)
|
46975
|
+
]), loadEnv.debug("Updating initial template metadata"), await updateInitialTemplateMetadata(apiClient, variables.projectId, `cli-${templateName}`), spinner.succeed(), template;
|
47019
46976
|
async function writeFileIfNotExists(fileName, content) {
|
47020
46977
|
const filePath = path__default.default.join(outputPath, fileName);
|
47021
46978
|
try {
|
@@ -52634,7 +52591,7 @@ ${err.message}`);
|
|
52634
52591
|
} else unattended || (trace.log({ step: "login" }), await getOrCreateUser());
|
52635
52592
|
let introMessage = "Fetching existing projects";
|
52636
52593
|
cliFlags.quickstart && (introMessage = "Eject your existing project's Sanity configuration"), success(introMessage), print("");
|
52637
|
-
const flags = await prepareFlags(),
|
52594
|
+
const flags = await prepareFlags(), { projectId, displayName, isFirstProject, datasetName, schemaUrl } = await getProjectDetails(), sluggedName = lodashExports.deburr(displayName.toLowerCase()).replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "");
|
52638
52595
|
if (bareOutput) {
|
52639
52596
|
success("Below are your project details"), print(""), print(`Project ID: ${chalk2.cyan(projectId)}`), print(`Dataset: ${chalk2.cyan(datasetName)}`), print(
|
52640
52597
|
`
|
@@ -52824,15 +52781,11 @@ ${chalk2.green("Success!")} Your Sanity configuration files has been added to th
|
|
52824
52781
|
}[pkgManager];
|
52825
52782
|
outputPath === process.cwd() ? (print(`
|
52826
52783
|
${chalk2.green("Success!")} Now, use this command to continue:
|
52827
|
-
`), print(
|
52828
|
-
|
52829
|
-
`
|
52830
|
-
)) : (print(`
|
52784
|
+
`), print(`${chalk2.cyan(devCommand)} - to run Sanity Studio
|
52785
|
+
`)) : (print(`
|
52831
52786
|
${chalk2.green("Success!")} Now, use these commands to continue:
|
52832
|
-
`), print(`First: ${chalk2.cyan(`cd ${outputPath}`)} - to enter project\u2019s directory`), print(
|
52833
|
-
|
52834
|
-
`
|
52835
|
-
)), print("Other helpful commands"), print("npx sanity docs - to open the documentation in a browser"), print("npx sanity manage - to open the project settings in a browser"), print("npx sanity help - to explore the CLI manual");
|
52787
|
+
`), print(`First: ${chalk2.cyan(`cd ${outputPath}`)} - to enter project\u2019s directory`), print(`Then: ${chalk2.cyan(devCommand)} - to run Sanity Studio
|
52788
|
+
`)), print("Other helpful commands"), print("npx sanity docs - to open the documentation in a browser"), print("npx sanity manage - to open the project settings in a browser"), print("npx sanity help - to explore the CLI manual");
|
52836
52789
|
const sendInvite = isFirstProject && await prompt2.single({
|
52837
52790
|
type: "confirm",
|
52838
52791
|
message: "We have an excellent developer community, would you like us to send you an invitation to join?",
|
@@ -52859,13 +52812,6 @@ ${chalk2.green("Success!")} Now, use these commands to continue:
|
|
52859
52812
|
isFirstProject: data.isFirstProject
|
52860
52813
|
}), data;
|
52861
52814
|
}
|
52862
|
-
if (isCoreAppTemplate)
|
52863
|
-
return {
|
52864
|
-
projectId: "",
|
52865
|
-
displayName: "",
|
52866
|
-
isFirstProject: !1,
|
52867
|
-
datasetName: ""
|
52868
|
-
};
|
52869
52815
|
loadEnv.debug("Prompting user to select or create a project");
|
52870
52816
|
const project = await getOrCreateProject();
|
52871
52817
|
loadEnv.debug(`Project with name ${project.displayName} selected`), loadEnv.debug("Prompting user to select or create a dataset");
|