@sanity/cli 3.72.1-corel.567 → 3.72.2-canary.32
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 +164 -101
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/lib/index.d.mts +9 -0
- package/lib/index.d.ts +9 -0
- package/package.json +10 -10
- package/src/actions/init-project/bootstrapLocalTemplate.ts +32 -20
- package/src/actions/init-project/bootstrapRemoteTemplate.ts +1 -1
- package/src/actions/init-project/createCliConfig.ts +5 -47
- package/src/actions/init-project/createCoreAppCliConfig.ts +23 -0
- package/src/actions/init-project/createPackageManifest.ts +1 -1
- package/src/actions/init-project/createStudioConfig.ts +4 -27
- package/src/actions/init-project/determineCoreAppTemplate.ts +13 -0
- package/src/actions/init-project/initProject.ts +21 -2
- package/src/actions/init-project/processTemplate.ts +55 -0
- package/src/actions/init-project/templates/coreApp.ts +31 -0
- package/src/actions/init-project/templates/index.ts +2 -0
- package/src/types.ts +10 -0
- package/src/util/remoteTemplate.ts +2 -1
- package/templates/core-app/src/App.tsx +26 -0
package/lib/_chunks-cjs/cli.js
CHANGED
@@ -26706,7 +26706,7 @@ async function applyEnvVariables(root2, envData, targetName = ".env") {
|
|
26706
26706
|
});
|
26707
26707
|
if (templatePath)
|
26708
26708
|
try {
|
26709
|
-
const templateContent = await fs.readFile(path$3.join(root2, templatePath), "utf8"), { projectId, dataset, readToken = "" } = envData, findAndReplaceVariable = (content, varRegex, value, useQuotes2) => {
|
26709
|
+
const templateContent = await fs.readFile(path$3.join(root2, templatePath), "utf8"), { projectId, dataset, readToken = "", writeToken = "" } = envData, findAndReplaceVariable = (content, varRegex, value, useQuotes2) => {
|
26710
26710
|
const varPattern = typeof varRegex == "string" ? varRegex : varRegex.source, pattern = new RegExp(`.*${varPattern}=.*$`, "gm"), matches = content.matchAll(pattern);
|
26711
26711
|
return Array.from(matches).reduce((updatedContent, match2) => {
|
26712
26712
|
if (!match2[0]) return updatedContent;
|
@@ -26721,7 +26721,8 @@ async function applyEnvVariables(root2, envData, targetName = ".env") {
|
|
26721
26721
|
const vars = [
|
26722
26722
|
{ pattern: ENV_VAR.PROJECT_ID, value: projectId },
|
26723
26723
|
{ pattern: ENV_VAR.DATASET, value: dataset },
|
26724
|
-
{ pattern: ENV_VAR.READ_TOKEN, value: readToken }
|
26724
|
+
{ pattern: ENV_VAR.READ_TOKEN, value: readToken },
|
26725
|
+
{ pattern: ENV_VAR.WRITE_TOKEN, value: writeToken }
|
26725
26726
|
], useQuotes = templateContent.includes('="');
|
26726
26727
|
for (const { pattern, value } of vars)
|
26727
26728
|
envContent = findAndReplaceVariable(envContent, pattern, value, useQuotes);
|
@@ -37615,7 +37616,7 @@ function requireLib$1() {
|
|
37615
37616
|
StrictWith: "'with' in strict mode."
|
37616
37617
|
};
|
37617
37618
|
const UnparenthesizedPipeBodyDescriptions = /* @__PURE__ */ new Set(["ArrowFunctionExpression", "AssignmentExpression", "ConditionalExpression", "YieldExpression"]);
|
37618
|
-
var PipelineOperatorErrors = {
|
37619
|
+
var PipelineOperatorErrors = Object.assign({
|
37619
37620
|
PipeBodyIsTighter: "Unexpected yield after pipeline body; any yield expression acting as Hack-style pipe body must be parenthesized due to its loose operator precedence.",
|
37620
37621
|
PipeTopicRequiresHackPipes: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.',
|
37621
37622
|
PipeTopicUnbound: "Topic reference is unbound; it must be inside a pipe body.",
|
@@ -37627,14 +37628,15 @@ function requireLib$1() {
|
|
37627
37628
|
type: type2
|
37628
37629
|
}) => `Hack-style pipe body cannot be an unparenthesized ${toNodeDescription({
|
37629
37630
|
type: type2
|
37630
|
-
})}; please wrap it in parentheses
|
37631
|
+
})}; please wrap it in parentheses.`
|
37632
|
+
}, {
|
37631
37633
|
PipelineBodyNoArrow: 'Unexpected arrow "=>" after pipeline body; arrow function in pipeline body must be parenthesized.',
|
37632
37634
|
PipelineBodySequenceExpression: "Pipeline body may not be a comma-separated sequence expression.",
|
37633
37635
|
PipelineHeadSequenceExpression: "Pipeline head should not be a comma-separated sequence expression.",
|
37634
37636
|
PipelineTopicUnused: "Pipeline is in topic style but does not use topic reference.",
|
37635
37637
|
PrimaryTopicNotAllowed: "Topic reference was used in a lexical context without topic binding.",
|
37636
37638
|
PrimaryTopicRequiresSmartPipeline: 'Topic reference is used, but the pipelineOperator plugin was not passed a "proposal": "hack" or "smart" option.'
|
37637
|
-
};
|
37639
|
+
});
|
37638
37640
|
const _excluded = ["message"];
|
37639
37641
|
function defineHidden(obj, key2, value) {
|
37640
37642
|
Object.defineProperty(obj, key2, {
|
@@ -37858,7 +37860,7 @@ function requireLib$1() {
|
|
37858
37860
|
const {
|
37859
37861
|
typeParameters
|
37860
37862
|
} = node;
|
37861
|
-
return typeParameters && (delete node.typeParameters, funcNode.typeParameters = typeParameters, funcNode
|
37863
|
+
return typeParameters && (delete node.typeParameters, funcNode.typeParameters = typeParameters, this.resetStartLocationFromNode(funcNode, typeParameters)), type2 === "ClassPrivateMethod" && (node.computed = !1), this.finishNode(node, "MethodDefinition");
|
37862
37864
|
}
|
37863
37865
|
nameIsConstructor(key2) {
|
37864
37866
|
return key2.type === "Literal" ? key2.value === "constructor" : super.nameIsConstructor(key2);
|
@@ -42776,19 +42778,28 @@ function requireLib$1() {
|
|
42776
42778
|
}
|
42777
42779
|
tsParseImportType() {
|
42778
42780
|
const node = this.startNode();
|
42779
|
-
return this.expect(83), this.expect(10), this.match(134) ? node.argument = this.parseStringLiteral(this.state.value) : (this.raise(TSErrors.UnsupportedImportTypeArgument, this.state.startLoc), node.argument = super.parseExprAtom()), this.eat(12) && !this.match(11) ? (node.options = super.parseMaybeAssignAllowIn(), this.eat(12)) : node.options = null, this.expect(11), this.eat(16) && (node.qualifier = this.tsParseEntityName()), this.match(47) && (node.typeParameters = this.tsParseTypeArguments()), this.finishNode(node, "TSImportType");
|
42781
|
+
return this.expect(83), this.expect(10), this.match(134) ? node.argument = this.parseStringLiteral(this.state.value) : (this.raise(TSErrors.UnsupportedImportTypeArgument, this.state.startLoc), node.argument = super.parseExprAtom()), this.eat(12) && !this.match(11) ? (node.options = super.parseMaybeAssignAllowIn(), this.eat(12)) : node.options = null, this.expect(11), this.eat(16) && (node.qualifier = this.tsParseEntityName(3)), this.match(47) && (node.typeParameters = this.tsParseTypeArguments()), this.finishNode(node, "TSImportType");
|
42780
42782
|
}
|
42781
|
-
tsParseEntityName(
|
42782
|
-
let entity
|
42783
|
+
tsParseEntityName(flags) {
|
42784
|
+
let entity;
|
42785
|
+
if (flags & 1 && this.match(78))
|
42786
|
+
if (flags & 2)
|
42787
|
+
entity = this.parseIdentifier(!0);
|
42788
|
+
else {
|
42789
|
+
const node = this.startNode();
|
42790
|
+
this.next(), entity = this.finishNode(node, "ThisExpression");
|
42791
|
+
}
|
42792
|
+
else
|
42793
|
+
entity = this.parseIdentifier(!!(flags & 1));
|
42783
42794
|
for (; this.eat(16); ) {
|
42784
42795
|
const node = this.startNodeAtNode(entity);
|
42785
|
-
node.left = entity, node.right = this.parseIdentifier(
|
42796
|
+
node.left = entity, node.right = this.parseIdentifier(!!(flags & 1)), entity = this.finishNode(node, "TSQualifiedName");
|
42786
42797
|
}
|
42787
42798
|
return entity;
|
42788
42799
|
}
|
42789
42800
|
tsParseTypeReference() {
|
42790
42801
|
const node = this.startNode();
|
42791
|
-
return node.typeName = this.tsParseEntityName(), !this.hasPrecedingLineBreak() && this.match(47) && (node.typeParameters = this.tsParseTypeArguments()), this.finishNode(node, "TSTypeReference");
|
42802
|
+
return node.typeName = this.tsParseEntityName(1), !this.hasPrecedingLineBreak() && this.match(47) && (node.typeParameters = this.tsParseTypeArguments()), this.finishNode(node, "TSTypeReference");
|
42792
42803
|
}
|
42793
42804
|
tsParseThisTypePredicate(lhs) {
|
42794
42805
|
this.next();
|
@@ -42801,7 +42812,7 @@ function requireLib$1() {
|
|
42801
42812
|
}
|
42802
42813
|
tsParseTypeQuery() {
|
42803
42814
|
const node = this.startNode();
|
42804
|
-
return this.expect(87), this.match(83) ? node.exprName = this.tsParseImportType() : node.exprName = this.tsParseEntityName(), !this.hasPrecedingLineBreak() && this.match(47) && (node.typeParameters = this.tsParseTypeArguments()), this.finishNode(node, "TSTypeQuery");
|
42815
|
+
return this.expect(87), this.match(83) ? node.exprName = this.tsParseImportType() : node.exprName = this.tsParseEntityName(3), !this.hasPrecedingLineBreak() && this.match(47) && (node.typeParameters = this.tsParseTypeArguments()), this.finishNode(node, "TSTypeQuery");
|
42805
42816
|
}
|
42806
42817
|
tsParseTypeParameter(parseModifiers) {
|
42807
42818
|
const node = this.startNode();
|
@@ -43187,7 +43198,7 @@ function requireLib$1() {
|
|
43187
43198
|
tsParseHeritageClause(token2) {
|
43188
43199
|
const originalStartLoc = this.state.startLoc, delimitedList = this.tsParseDelimitedList("HeritageClauseElement", () => {
|
43189
43200
|
const node = this.startNode();
|
43190
|
-
return node.expression = this.tsParseEntityName(), this.match(47) && (node.typeParameters = this.tsParseTypeArguments()), this.finishNode(node, "TSExpressionWithTypeArguments");
|
43201
|
+
return node.expression = this.tsParseEntityName(3), this.match(47) && (node.typeParameters = this.tsParseTypeArguments()), this.finishNode(node, "TSExpressionWithTypeArguments");
|
43191
43202
|
});
|
43192
43203
|
return delimitedList.length || this.raise(TSErrors.EmptyHeritageClauseType, originalStartLoc, {
|
43193
43204
|
token: token2
|
@@ -43292,7 +43303,7 @@ function requireLib$1() {
|
|
43292
43303
|
return this.isContextual(119) && this.lookaheadCharCode() === 40;
|
43293
43304
|
}
|
43294
43305
|
tsParseModuleReference() {
|
43295
|
-
return this.tsIsExternalModuleReference() ? this.tsParseExternalModuleReference() : this.tsParseEntityName(
|
43306
|
+
return this.tsIsExternalModuleReference() ? this.tsParseExternalModuleReference() : this.tsParseEntityName(0);
|
43296
43307
|
}
|
43297
43308
|
tsParseExternalModuleReference() {
|
43298
43309
|
const node = this.startNode();
|
@@ -44410,15 +44421,15 @@ function requireLib$1() {
|
|
44410
44421
|
switch (this.getPluginOption("pipelineOperator", "proposal")) {
|
44411
44422
|
case "hack":
|
44412
44423
|
return this.withTopicBindingContext(() => this.parseHackPipeBody());
|
44413
|
-
case "smart":
|
44414
|
-
return this.withTopicBindingContext(() => {
|
44415
|
-
if (this.prodParam.hasYield && this.isContextual(108))
|
44416
|
-
throw this.raise(Errors.PipeBodyIsTighter, this.state.startLoc);
|
44417
|
-
return this.parseSmartPipelineBodyInStyle(this.parseExprOpBaseRightExpr(op, prec), startLoc);
|
44418
|
-
});
|
44419
44424
|
case "fsharp":
|
44420
44425
|
return this.withSoloAwaitPermittingContext(() => this.parseFSharpPipelineBody(prec));
|
44421
44426
|
}
|
44427
|
+
if (this.getPluginOption("pipelineOperator", "proposal") === "smart")
|
44428
|
+
return this.withTopicBindingContext(() => {
|
44429
|
+
if (this.prodParam.hasYield && this.isContextual(108))
|
44430
|
+
throw this.raise(Errors.PipeBodyIsTighter, this.state.startLoc);
|
44431
|
+
return this.parseSmartPipelineBodyInStyle(this.parseExprOpBaseRightExpr(op, prec), startLoc);
|
44432
|
+
});
|
44422
44433
|
default:
|
44423
44434
|
return this.parseExprOpBaseRightExpr(op, prec);
|
44424
44435
|
}
|
@@ -44704,13 +44715,11 @@ function requireLib$1() {
|
|
44704
44715
|
return this.next(), this.finishTopicReference(node, startLoc, pipeProposal, tokenType);
|
44705
44716
|
}
|
44706
44717
|
finishTopicReference(node, startLoc, pipeProposal, tokenType) {
|
44707
|
-
if (this.testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType))
|
44708
|
-
|
44709
|
-
|
44710
|
-
|
44711
|
-
|
44712
|
-
token: tokenLabelName(tokenType)
|
44713
|
-
});
|
44718
|
+
if (this.testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType))
|
44719
|
+
return pipeProposal === "hack" ? (this.topicReferenceIsAllowedInCurrentContext() || this.raise(Errors.PipeTopicUnbound, startLoc), this.registerTopicReference(), this.finishNode(node, "TopicReference")) : (this.topicReferenceIsAllowedInCurrentContext() || this.raise(Errors.PrimaryTopicNotAllowed, startLoc), this.registerTopicReference(), this.finishNode(node, "PipelinePrimaryTopicReference"));
|
44720
|
+
throw this.raise(Errors.PipeTopicUnconfiguredToken, startLoc, {
|
44721
|
+
token: tokenLabelName(tokenType)
|
44722
|
+
});
|
44714
44723
|
}
|
44715
44724
|
testTopicReferenceConfiguration(pipeProposal, startLoc, tokenType) {
|
44716
44725
|
switch (pipeProposal) {
|
@@ -46505,23 +46514,8 @@ var typescriptExports = requireTypescript(), typescript = /* @__PURE__ */ loadEn
|
|
46505
46514
|
__proto__: null,
|
46506
46515
|
default: typescript
|
46507
46516
|
}, [typescriptExports]);
|
46508
|
-
|
46509
|
-
|
46510
|
-
|
46511
|
-
export default defineCliConfig({
|
46512
|
-
api: {
|
46513
|
-
projectId: '%projectId%',
|
46514
|
-
dataset: '%dataset%'
|
46515
|
-
},
|
46516
|
-
/**
|
46517
|
-
* Enable auto-updates for studios.
|
46518
|
-
* Learn more at https://www.sanity.io/docs/cli#auto-updates
|
46519
|
-
*/
|
46520
|
-
autoUpdates: __BOOL__autoUpdates__,
|
46521
|
-
})
|
46522
|
-
`;
|
46523
|
-
function createCliConfig(options2) {
|
46524
|
-
const variables = options2, template = defaultTemplate$1.trimStart(), ast = mainExports.parse(template, { parser });
|
46517
|
+
function processTemplate(options2) {
|
46518
|
+
const { template, variables, includeBooleanTransform = !1 } = options2, ast = mainExports.parse(template.trimStart(), { parser });
|
46525
46519
|
return traverse__default.default(ast, {
|
46526
46520
|
StringLiteral: {
|
46527
46521
|
enter({ node }) {
|
@@ -46535,24 +46529,60 @@ function createCliConfig(options2) {
|
|
46535
46529
|
node.value = typeof newValue == "string" ? newValue : "";
|
46536
46530
|
}
|
46537
46531
|
},
|
46538
|
-
|
46539
|
-
|
46540
|
-
|
46541
|
-
|
46542
|
-
|
46543
|
-
/^__BOOL__(.+?)__$/,
|
46544
|
-
|
46545
|
-
|
46546
|
-
|
46547
|
-
|
46548
|
-
|
46549
|
-
|
46550
|
-
|
46551
|
-
path2.replaceWith({ type: "BooleanLiteral", value });
|
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
|
+
}
|
46552
46545
|
}
|
46553
46546
|
}
|
46554
46547
|
}), mainExports.print(ast, { quote: "single" }).code;
|
46555
46548
|
}
|
46549
|
+
const defaultTemplate$1 = `
|
46550
|
+
import {defineCliConfig} from 'sanity/cli'
|
46551
|
+
|
46552
|
+
export default defineCliConfig({
|
46553
|
+
api: {
|
46554
|
+
projectId: '%projectId%',
|
46555
|
+
dataset: '%dataset%'
|
46556
|
+
},
|
46557
|
+
/**
|
46558
|
+
* Enable auto-updates for studios.
|
46559
|
+
* Learn more at https://www.sanity.io/docs/cli#auto-updates
|
46560
|
+
*/
|
46561
|
+
autoUpdates: __BOOL__autoUpdates__,
|
46562
|
+
})
|
46563
|
+
`;
|
46564
|
+
function createCliConfig(options2) {
|
46565
|
+
return processTemplate({
|
46566
|
+
template: defaultTemplate$1,
|
46567
|
+
variables: options2,
|
46568
|
+
includeBooleanTransform: !0
|
46569
|
+
});
|
46570
|
+
}
|
46571
|
+
const defaultCoreAppTemplate = `
|
46572
|
+
import {defineCliConfig} from 'sanity/cli'
|
46573
|
+
|
46574
|
+
export default defineCliConfig({
|
46575
|
+
__experimental_coreAppConfiguration: {
|
46576
|
+
appLocation: '%appLocation%'
|
46577
|
+
},
|
46578
|
+
})
|
46579
|
+
`;
|
46580
|
+
function createCoreAppCliConfig(options2) {
|
46581
|
+
return processTemplate({
|
46582
|
+
template: defaultCoreAppTemplate,
|
46583
|
+
variables: options2
|
46584
|
+
});
|
46585
|
+
}
|
46556
46586
|
/*!
|
46557
46587
|
* isobject <https://github.com/jonschlinkert/isobject>
|
46558
46588
|
*
|
@@ -46621,7 +46651,7 @@ function createPackageManifest(data) {
|
|
46621
46651
|
...getCommonManifest(data),
|
46622
46652
|
main: "package.json",
|
46623
46653
|
keywords: ["sanity"],
|
46624
|
-
scripts: {
|
46654
|
+
scripts: data.scripts || {
|
46625
46655
|
dev: "sanity dev",
|
46626
46656
|
start: "sanity start",
|
46627
46657
|
build: "sanity build",
|
@@ -46690,25 +46720,42 @@ export default defineConfig({
|
|
46690
46720
|
};
|
46691
46721
|
function createStudioConfig(options2) {
|
46692
46722
|
const variables = { ...defaultVariables, ...options2.variables };
|
46693
|
-
|
46694
|
-
|
46695
|
-
|
46696
|
-
|
46697
|
-
StringLiteral: {
|
46698
|
-
enter({ node }) {
|
46699
|
-
const value = node.value;
|
46700
|
-
if (!value.startsWith("%") || !value.endsWith("%"))
|
46701
|
-
return;
|
46702
|
-
const variableName = value.slice(1, -1);
|
46703
|
-
if (!(variableName in variables))
|
46704
|
-
throw new Error(`Template variable '${value}' not defined`);
|
46705
|
-
const newValue = variables[variableName];
|
46706
|
-
node.value = typeof newValue == "string" ? newValue : "";
|
46707
|
-
}
|
46708
|
-
}
|
46709
|
-
}), mainExports.print(ast, { quote: "single" }).code;
|
46723
|
+
return typeof options2.template == "function" ? options2.template(variables).trimStart() : processTemplate({
|
46724
|
+
template: options2.template || defaultTemplate,
|
46725
|
+
variables
|
46726
|
+
});
|
46710
46727
|
}
|
46711
|
-
const
|
46728
|
+
const coreAppTemplates = ["core-app"];
|
46729
|
+
function determineCoreAppTemplate(templateName) {
|
46730
|
+
return coreAppTemplates.includes(templateName);
|
46731
|
+
}
|
46732
|
+
const blogTemplate = {}, cleanTemplate = {}, coreAppTemplate = {
|
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 = `
|
46712
46759
|
import {defineConfig, isDev} from 'sanity'
|
46713
46760
|
import {visionTool} from '@sanity/vision'
|
46714
46761
|
import {structureTool} from 'sanity/structure'
|
@@ -46886,6 +46933,7 @@ export default defineConfig({
|
|
46886
46933
|
}, templates = {
|
46887
46934
|
blog: blogTemplate,
|
46888
46935
|
clean: cleanTemplate,
|
46936
|
+
"core-app": coreAppTemplate,
|
46889
46937
|
"get-started": getStartedTemplate,
|
46890
46938
|
moviedb: movieTemplate,
|
46891
46939
|
shopify: shopifyTemplate$1,
|
@@ -46906,7 +46954,7 @@ async function updateInitialTemplateMetadata(apiClient, projectId, templateName)
|
|
46906
46954
|
}
|
46907
46955
|
}
|
46908
46956
|
async function bootstrapLocalTemplate(opts, context) {
|
46909
|
-
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];
|
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"), isCoreAppTemplate = determineCoreAppTemplate(templateName), template = templates[templateName];
|
46910
46958
|
if (!template)
|
46911
46959
|
throw new Error(`Template "${templateName}" not defined`);
|
46912
46960
|
loadEnv.debug('Copying files from template "%s" to "%s"', templateName, outputPath);
|
@@ -46921,19 +46969,20 @@ async function bootstrapLocalTemplate(opts, context) {
|
|
46921
46969
|
schemaUrl: opts.schemaUrl
|
46922
46970
|
})), spinner.succeed(), spinner = output.spinner("Resolving latest module versions").start();
|
46923
46971
|
const dependencyVersions = await resolveLatestVersions({
|
46924
|
-
...studioDependencies.dependencies,
|
46925
|
-
...studioDependencies.devDependencies,
|
46926
|
-
...template.dependencies || {}
|
46972
|
+
...isCoreAppTemplate ? {} : studioDependencies.dependencies,
|
46973
|
+
...isCoreAppTemplate ? {} : studioDependencies.devDependencies,
|
46974
|
+
...template.dependencies || {},
|
46975
|
+
...template.devDependencies || {}
|
46927
46976
|
});
|
46928
46977
|
spinner.succeed();
|
46929
46978
|
const dependencies = Object.keys({
|
46930
|
-
...studioDependencies.dependencies,
|
46979
|
+
...isCoreAppTemplate ? {} : studioDependencies.dependencies,
|
46931
46980
|
...template.dependencies
|
46932
46981
|
}).reduce(
|
46933
46982
|
(deps, dependency) => (deps[dependency] = dependencyVersions[dependency], deps),
|
46934
46983
|
{}
|
46935
46984
|
), devDependencies = Object.keys({
|
46936
|
-
...studioDependencies.devDependencies,
|
46985
|
+
...isCoreAppTemplate ? {} : studioDependencies.devDependencies,
|
46937
46986
|
...template.devDependencies
|
46938
46987
|
}).reduce(
|
46939
46988
|
(deps, dependency) => (deps[dependency] = dependencyVersions[dependency], deps),
|
@@ -46943,27 +46992,30 @@ async function bootstrapLocalTemplate(opts, context) {
|
|
46943
46992
|
const packageManifest = await createPackageManifest({
|
46944
46993
|
name: packageName,
|
46945
46994
|
dependencies,
|
46946
|
-
devDependencies
|
46947
|
-
|
46995
|
+
devDependencies,
|
46996
|
+
scripts: template.scripts
|
46997
|
+
}), studioConfig = createStudioConfig({
|
46948
46998
|
template: template.configTemplate,
|
46949
46999
|
variables
|
46950
|
-
}), cliConfig =
|
47000
|
+
}), cliConfig = isCoreAppTemplate ? createCoreAppCliConfig({ appLocation: template.appLocation }) : createCliConfig({
|
46951
47001
|
projectId: variables.projectId,
|
46952
47002
|
dataset: variables.dataset,
|
46953
47003
|
autoUpdates: variables.autoUpdates
|
46954
47004
|
}), codeExt = useTypeScript ? "ts" : "js";
|
46955
|
-
return await Promise.all(
|
46956
|
-
|
46957
|
-
|
46958
|
-
|
46959
|
-
|
46960
|
-
|
46961
|
-
|
47005
|
+
return await Promise.all(
|
47006
|
+
[
|
47007
|
+
isCoreAppTemplate ? Promise.resolve(null) : writeFileIfNotExists(`sanity.config.${codeExt}`, studioConfig),
|
47008
|
+
writeFileIfNotExists(`sanity.cli.${codeExt}`, cliConfig),
|
47009
|
+
writeFileIfNotExists("package.json", packageManifest),
|
47010
|
+
writeFileIfNotExists(
|
47011
|
+
"eslint.config.mjs",
|
47012
|
+
`import studio from '@sanity/eslint-config-studio'
|
46962
47013
|
|
46963
47014
|
export default [...studio]
|
46964
47015
|
`
|
46965
|
-
|
46966
|
-
|
47016
|
+
)
|
47017
|
+
].filter(Boolean)
|
47018
|
+
), loadEnv.debug("Updating initial template metadata"), await updateInitialTemplateMetadata(apiClient, variables.projectId, `cli-${templateName}`), spinner.succeed(), template;
|
46967
47019
|
async function writeFileIfNotExists(fileName, content) {
|
46968
47020
|
const filePath = path__default.default.join(outputPath, fileName);
|
46969
47021
|
try {
|
@@ -51917,7 +51969,7 @@ async function bootstrapRemoteTemplate(opts, context) {
|
|
51917
51969
|
}), port = getDefaultPortForFramework(packageFramework?.slug);
|
51918
51970
|
corsAdded.includes(port) === !1 && (loadEnv.debug("Setting CORS origin to http://localhost:%d", port), await setCorsOrigin(`http://localhost:${port}`, variables.projectId, apiClient), corsAdded.push(port)), loadEnv.debug("Applying environment variables to %s", pkg);
|
51919
51971
|
const envName = packageFramework?.slug === "nextjs" ? ".env.local" : ".env";
|
51920
|
-
await applyEnvVariables(packagePath, { ...variables, readToken }, envName);
|
51972
|
+
await applyEnvVariables(packagePath, { ...variables, readToken, writeToken }, envName);
|
51921
51973
|
}
|
51922
51974
|
loadEnv.debug("Setting package name to %s", packageName), await tryApplyPackageName(outputPath, packageName), loadEnv.debug("Initializing git repository"), tryGitInit(outputPath, INITIAL_COMMIT_MESSAGE), loadEnv.debug("Updating initial template metadata"), await updateInitialTemplateMetadata(apiClient, variables.projectId, `external-${name}`), spinner.succeed(), corsAdded.length && output.success(`CORS origins added (${corsAdded.map((p) => `localhost:${p}`).join(", ")})`), readToken && output.success(`API token generated (${READ_TOKEN_LABEL})`), writeToken && output.success(`API token generated (${WRITE_TOKEN_LABEL})`);
|
51923
51975
|
}
|
@@ -52582,7 +52634,7 @@ ${err.message}`);
|
|
52582
52634
|
} else unattended || (trace.log({ step: "login" }), await getOrCreateUser());
|
52583
52635
|
let introMessage = "Fetching existing projects";
|
52584
52636
|
cliFlags.quickstart && (introMessage = "Eject your existing project's Sanity configuration"), success(introMessage), print("");
|
52585
|
-
const flags = await prepareFlags(), { projectId, displayName, isFirstProject, datasetName, schemaUrl } = await getProjectDetails(), sluggedName = lodashExports.deburr(displayName.toLowerCase()).replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "");
|
52637
|
+
const flags = await prepareFlags(), isCoreAppTemplate = cliFlags.template ? determineCoreAppTemplate(cliFlags.template) : !1, { projectId, displayName, isFirstProject, datasetName, schemaUrl } = await getProjectDetails(), sluggedName = lodashExports.deburr(displayName.toLowerCase()).replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "");
|
52586
52638
|
if (bareOutput) {
|
52587
52639
|
success("Below are your project details"), print(""), print(`Project ID: ${chalk2.cyan(projectId)}`), print(`Dataset: ${chalk2.cyan(datasetName)}`), print(
|
52588
52640
|
`
|
@@ -52772,11 +52824,15 @@ ${chalk2.green("Success!")} Your Sanity configuration files has been added to th
|
|
52772
52824
|
}[pkgManager];
|
52773
52825
|
outputPath === process.cwd() ? (print(`
|
52774
52826
|
${chalk2.green("Success!")} Now, use this command to continue:
|
52775
|
-
`), print(
|
52776
|
-
|
52827
|
+
`), print(
|
52828
|
+
`${chalk2.cyan(devCommand)} - to run ${isCoreAppTemplate ? "your Sanity application" : "Sanity Studio"}
|
52829
|
+
`
|
52830
|
+
)) : (print(`
|
52777
52831
|
${chalk2.green("Success!")} Now, use these commands to continue:
|
52778
|
-
`), print(`First: ${chalk2.cyan(`cd ${outputPath}`)} - to enter project\u2019s directory`), print(
|
52779
|
-
`
|
52832
|
+
`), print(`First: ${chalk2.cyan(`cd ${outputPath}`)} - to enter project\u2019s directory`), print(
|
52833
|
+
`Then: ${chalk2.cyan(devCommand)} -to run ${isCoreAppTemplate ? "your Sanity application" : "Sanity Studio"}
|
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");
|
52780
52836
|
const sendInvite = isFirstProject && await prompt2.single({
|
52781
52837
|
type: "confirm",
|
52782
52838
|
message: "We have an excellent developer community, would you like us to send you an invitation to join?",
|
@@ -52803,6 +52859,13 @@ ${chalk2.green("Success!")} Now, use these commands to continue:
|
|
52803
52859
|
isFirstProject: data.isFirstProject
|
52804
52860
|
}), data;
|
52805
52861
|
}
|
52862
|
+
if (isCoreAppTemplate)
|
52863
|
+
return {
|
52864
|
+
projectId: "",
|
52865
|
+
displayName: "",
|
52866
|
+
isFirstProject: !1,
|
52867
|
+
datasetName: ""
|
52868
|
+
};
|
52806
52869
|
loadEnv.debug("Prompting user to select or create a project");
|
52807
52870
|
const project = await getOrCreateProject();
|
52808
52871
|
loadEnv.debug(`Project with name ${project.displayName} selected`), loadEnv.debug("Prompting user to select or create a dataset");
|