@sanity/cli 3.75.1 → 3.76.1
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 +22 -14
- package/lib/_chunks-cjs/cli.js.map +1 -1
- package/lib/index.d.mts +1 -0
- package/lib/index.d.ts +1 -0
- package/package.json +8 -8
- package/src/actions/init-project/bootstrapLocalTemplate.ts +4 -1
- package/src/actions/init-project/createCoreAppCliConfig.ts +2 -1
- package/src/actions/init-project/createStudioConfig.ts +1 -0
- package/src/actions/init-project/initProject.ts +21 -12
- package/src/types.ts +1 -0
package/lib/_chunks-cjs/cli.js
CHANGED
@@ -46584,7 +46584,8 @@ import {defineCliConfig} from 'sanity/cli'
|
|
46584
46584
|
|
46585
46585
|
export default defineCliConfig({
|
46586
46586
|
__experimental_coreAppConfiguration: {
|
46587
|
-
|
46587
|
+
organizationId: '%organizationId%',
|
46588
|
+
appLocation: '%appLocation%',
|
46588
46589
|
},
|
46589
46590
|
})
|
46590
46591
|
`;
|
@@ -47008,7 +47009,10 @@ async function bootstrapLocalTemplate(opts, context) {
|
|
47008
47009
|
}), studioConfig = createStudioConfig({
|
47009
47010
|
template: template.configTemplate,
|
47010
47011
|
variables
|
47011
|
-
}), cliConfig = isCoreAppTemplate ? createCoreAppCliConfig({
|
47012
|
+
}), cliConfig = isCoreAppTemplate ? createCoreAppCliConfig({
|
47013
|
+
appLocation: template.appLocation,
|
47014
|
+
organizationId: variables.organizationId
|
47015
|
+
}) : createCliConfig({
|
47012
47016
|
projectId: variables.projectId,
|
47013
47017
|
dataset: variables.dataset,
|
47014
47018
|
autoUpdates: variables.autoUpdates
|
@@ -52644,7 +52648,7 @@ ${err.message}`);
|
|
52644
52648
|
} else unattended || (trace.log({ step: "login" }), await getOrCreateUser());
|
52645
52649
|
let introMessage = "Fetching existing projects";
|
52646
52650
|
cliFlags.quickstart && (introMessage = "Eject your existing project's Sanity configuration"), success(introMessage), print("");
|
52647
|
-
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, "");
|
52651
|
+
const flags = await prepareFlags(), isCoreAppTemplate = cliFlags.template ? determineCoreAppTemplate(cliFlags.template) : !1, { projectId, displayName, isFirstProject, datasetName, schemaUrl, organizationId } = await getProjectDetails(), sluggedName = lodashExports.deburr(displayName.toLowerCase()).replace(/\s+/g, "-").replace(/[^a-z0-9-]/g, "");
|
52648
52652
|
if (bareOutput) {
|
52649
52653
|
success("Below are your project details"), print(""), print(`Project ID: ${chalk2.cyan(projectId)}`), print(`Dataset: ${chalk2.cyan(datasetName)}`), print(
|
52650
52654
|
`
|
@@ -52867,13 +52871,16 @@ ${chalk2.green("Success!")} Now, use these commands to continue:
|
|
52867
52871
|
isFirstProject: data.isFirstProject
|
52868
52872
|
}), data;
|
52869
52873
|
}
|
52870
|
-
if (isCoreAppTemplate)
|
52874
|
+
if (isCoreAppTemplate) {
|
52875
|
+
const organizations = await apiClient({ requireUser: !0, requireProject: !1 }).request({ uri: "/organizations" });
|
52871
52876
|
return {
|
52872
52877
|
projectId: "",
|
52873
52878
|
displayName: "",
|
52879
|
+
datasetName: "",
|
52874
52880
|
isFirstProject: !1,
|
52875
|
-
|
52881
|
+
organizationId: await getOrganizationId(organizations)
|
52876
52882
|
};
|
52883
|
+
}
|
52877
52884
|
loadEnv.debug("Prompting user to select or create a project");
|
52878
52885
|
const project = await getOrCreateProject();
|
52879
52886
|
loadEnv.debug(`Project with name ${project.displayName} selected`), loadEnv.debug("Prompting user to select or create a dataset");
|
@@ -53090,7 +53097,8 @@ The default dataset configuration has a public dataset named "production".`;
|
|
53090
53097
|
autoUpdates,
|
53091
53098
|
dataset: datasetName,
|
53092
53099
|
projectId,
|
53093
|
-
projectName: displayName || answers.projectName
|
53100
|
+
projectName: displayName || answers.projectName,
|
53101
|
+
organizationId
|
53094
53102
|
};
|
53095
53103
|
return remoteTemplateInfo ? bootstrapRemoteTemplate(
|
53096
53104
|
{
|
@@ -53176,10 +53184,10 @@ The default dataset configuration has a public dataset named "production".`;
|
|
53176
53184
|
return cliFlags;
|
53177
53185
|
}
|
53178
53186
|
async function getOrganizationId(organizations) {
|
53179
|
-
let
|
53187
|
+
let orgId = flags.organization;
|
53180
53188
|
if (unattended)
|
53181
|
-
return
|
53182
|
-
if (organizations.length > 0 && !
|
53189
|
+
return orgId || void 0;
|
53190
|
+
if (organizations.length > 0 && !orgId) {
|
53183
53191
|
loadEnv.debug(`User has ${organizations.length} organization(s), checking attach access`);
|
53184
53192
|
const withGrant = await getOrganizationsWithAttachGrant(organizations);
|
53185
53193
|
if (withGrant.length === 0) {
|
@@ -53199,13 +53207,13 @@ The default dataset configuration has a public dataset named "production".`;
|
|
53199
53207
|
type: "list",
|
53200
53208
|
choices: organizationChoices
|
53201
53209
|
});
|
53202
|
-
chosenOrg && chosenOrg !== "none" && (
|
53203
|
-
} else
|
53204
|
-
return
|
53210
|
+
chosenOrg && chosenOrg !== "none" && (orgId = chosenOrg);
|
53211
|
+
} else orgId ? loadEnv.debug("User has defined organization flag explicitly (%s)", orgId) : organizations.length === 0 && loadEnv.debug("User has no organizations, skipping selection prompt");
|
53212
|
+
return orgId || void 0;
|
53205
53213
|
}
|
53206
|
-
async function hasProjectAttachGrant(
|
53214
|
+
async function hasProjectAttachGrant(orgId) {
|
53207
53215
|
const requiredGrantGroup = "sanity.organization.projects", requiredGrant = "attach";
|
53208
|
-
return ((await apiClient({ requireProject: !1, requireUser: !0 }).clone().config({ apiVersion: "v2021-06-07" }).request({ uri: `organizations/${
|
53216
|
+
return ((await apiClient({ requireProject: !1, requireUser: !0 }).clone().config({ apiVersion: "v2021-06-07" }).request({ uri: `organizations/${orgId}/grants` }))[requiredGrantGroup] || []).some(
|
53209
53217
|
(resource) => resource.grants && resource.grants.some((grant) => grant.name === requiredGrant)
|
53210
53218
|
);
|
53211
53219
|
}
|