@sanity/cli
Advanced tools
Comparing version 3.75.0 to 3.75.1-canary.110
@@ -8,5 +8,5 @@ "use strict"; | ||
const debug = createDebug__default.default("sanity:cli"); | ||
function resolveRootDir(cwd) { | ||
function resolveRootDir(cwd, isCoreApp = !1) { | ||
try { | ||
return resolveProjectRoot(cwd) || cwd; | ||
return resolveProjectRoot(cwd, 0, isCoreApp) || cwd; | ||
} catch (err) { | ||
@@ -17,14 +17,14 @@ throw new Error(`Error occurred trying to resolve project root: | ||
} | ||
function hasStudioConfig(basePath) { | ||
function hasSanityConfig(basePath, configName) { | ||
return [ | ||
fileExists(path__default.default.join(basePath, "sanity.config.js")), | ||
fileExists(path__default.default.join(basePath, "sanity.config.ts")), | ||
fileExists(path__default.default.join(basePath, `${configName}.js`)), | ||
fileExists(path__default.default.join(basePath, `${configName}.ts`)), | ||
isSanityV2StudioRoot(basePath) | ||
].some(Boolean); | ||
} | ||
function resolveProjectRoot(basePath, iterations = 0) { | ||
if (hasStudioConfig(basePath)) | ||
function resolveProjectRoot(basePath, iterations = 0, isCoreApp = !1) { | ||
if (hasSanityConfig(basePath, isCoreApp ? "sanity.cli" : "sanity.config")) | ||
return basePath; | ||
const parentDir = path__default.default.resolve(basePath, ".."); | ||
return parentDir === basePath || iterations > 30 ? !1 : resolveProjectRoot(parentDir, iterations + 1); | ||
return parentDir === basePath || iterations > 30 ? !1 : resolveProjectRoot(parentDir, iterations + 1, isCoreApp); | ||
} | ||
@@ -31,0 +31,0 @@ function isSanityV2StudioRoot(basePath) { |
@@ -123,3 +123,5 @@ import {Answers} from 'inquirer' | ||
__experimental_coreAppConfiguration?: { | ||
organizationId?: string | ||
appLocation?: string | ||
appId?: string | ||
} | ||
@@ -224,2 +226,3 @@ } | ||
telemetry: TelemetryLogger<TelemetryUserProperties> | ||
isCoreApp: boolean | ||
} | ||
@@ -226,0 +229,0 @@ |
@@ -60,5 +60,5 @@ import { createClient } from "@sanity/client"; | ||
const debug = debugIt("sanity:cli"); | ||
function resolveRootDir(cwd) { | ||
function resolveRootDir(cwd, isCoreApp = !1) { | ||
try { | ||
return resolveProjectRoot(cwd) || cwd; | ||
return resolveProjectRoot(cwd, 0, isCoreApp) || cwd; | ||
} catch (err) { | ||
@@ -69,14 +69,14 @@ throw new Error(`Error occurred trying to resolve project root: | ||
} | ||
function hasStudioConfig(basePath) { | ||
function hasSanityConfig(basePath, configName) { | ||
return [ | ||
fileExists(path.join(basePath, "sanity.config.js")), | ||
fileExists(path.join(basePath, "sanity.config.ts")), | ||
fileExists(path.join(basePath, `${configName}.js`)), | ||
fileExists(path.join(basePath, `${configName}.ts`)), | ||
isSanityV2StudioRoot(basePath) | ||
].some(Boolean); | ||
} | ||
function resolveProjectRoot(basePath, iterations = 0) { | ||
if (hasStudioConfig(basePath)) | ||
function resolveProjectRoot(basePath, iterations = 0, isCoreApp = !1) { | ||
if (hasSanityConfig(basePath, isCoreApp ? "sanity.cli" : "sanity.config")) | ||
return basePath; | ||
const parentDir = path.resolve(basePath, ".."); | ||
return parentDir === basePath || iterations > 30 ? !1 : resolveProjectRoot(parentDir, iterations + 1); | ||
return parentDir === basePath || iterations > 30 ? !1 : resolveProjectRoot(parentDir, iterations + 1, isCoreApp); | ||
} | ||
@@ -83,0 +83,0 @@ function isSanityV2StudioRoot(basePath) { |
{ | ||
"name": "@sanity/cli", | ||
"version": "3.75.0", | ||
"version": "3.75.1-canary.110+88c2d8ff30", | ||
"description": "Sanity CLI tool for managing Sanity installations, managing plugins, schemas and datasets", | ||
@@ -60,7 +60,7 @@ "keywords": [ | ||
"@babel/traverse": "^7.23.5", | ||
"@sanity/client": "^6.27.2", | ||
"@sanity/codegen": "3.75.0", | ||
"@sanity/client": "^6.28.0", | ||
"@sanity/codegen": "3.75.1-canary.110+88c2d8ff30", | ||
"@sanity/telemetry": "^0.7.7", | ||
"@sanity/template-validator": "^2.4.0", | ||
"@sanity/util": "3.75.0", | ||
"@sanity/util": "3.75.1-canary.110+88c2d8ff30", | ||
"chalk": "^4.1.2", | ||
@@ -79,4 +79,4 @@ "debug": "^4.3.4", | ||
"devDependencies": { | ||
"@repo/package.config": "3.75.0", | ||
"@repo/test-config": "3.75.0", | ||
"@repo/package.config": "3.76.3", | ||
"@repo/test-config": "3.76.3", | ||
"@rexxars/gitconfiglocal": "^3.0.1", | ||
@@ -86,3 +86,3 @@ "@rollup/plugin-node-resolve": "^15.2.3", | ||
"@sanity/generate-help-url": "^3.0.0", | ||
"@sanity/types": "3.75.0", | ||
"@sanity/types": "3.75.1-canary.110+88c2d8ff30", | ||
"@types/babel__traverse": "^7.20.5", | ||
@@ -139,3 +139,3 @@ "@types/configstore": "^5.0.1", | ||
}, | ||
"gitHead": "55dcf1e4f131ce2b009fd683dd563a9b262eacbf" | ||
"gitHead": "88c2d8ff306b7289a7ed6c4c35300011b968df77" | ||
} |
@@ -133,3 +133,6 @@ import fs from 'node:fs/promises' | ||
const cliConfig = isCoreAppTemplate | ||
? createCoreAppCliConfig({appLocation: template.appLocation!}) | ||
? createCoreAppCliConfig({ | ||
appLocation: template.appLocation!, | ||
organizationId: variables.organizationId, | ||
}) | ||
: createCliConfig({ | ||
@@ -136,0 +139,0 @@ projectId: variables.projectId, |
@@ -8,3 +8,4 @@ import {processTemplate} from './processTemplate' | ||
__experimental_coreAppConfiguration: { | ||
appLocation: '%appLocation%' | ||
organizationId: '%organizationId%', | ||
appLocation: '%appLocation%', | ||
}, | ||
@@ -11,0 +12,0 @@ }) |
@@ -39,2 +39,3 @@ import {processTemplate} from './processTemplate' | ||
sourceTitle?: string | ||
organizationId?: string | ||
} | ||
@@ -41,0 +42,0 @@ } |
@@ -269,2 +269,5 @@ import {existsSync} from 'node:fs' | ||
// skip project / dataset prompting | ||
const isCoreAppTemplate = cliFlags.template ? determineCoreAppTemplate(cliFlags.template) : false // Default to false | ||
let introMessage = 'Fetching existing projects' | ||
@@ -274,11 +277,13 @@ if (cliFlags.quickstart) { | ||
} | ||
success(introMessage) | ||
print('') | ||
if (!isCoreAppTemplate) { | ||
success(introMessage) | ||
print('') | ||
} | ||
const flags = await prepareFlags() | ||
// skip project / dataset prompting | ||
const isCoreAppTemplate = cliFlags.template ? determineCoreAppTemplate(cliFlags.template) : false // Default to false | ||
// We're authenticated, now lets select or create a project | ||
const {projectId, displayName, isFirstProject, datasetName, schemaUrl} = await getProjectDetails() | ||
// We're authenticated, now lets select or create a project (for studios) or org (for core apps) | ||
const {projectId, displayName, isFirstProject, datasetName, schemaUrl, organizationId} = | ||
await getProjectDetails() | ||
@@ -720,2 +725,3 @@ const sluggedName = deburr(displayName.toLowerCase()) | ||
schemaUrl?: string | ||
organizationId?: string | ||
}> { | ||
@@ -737,7 +743,13 @@ // If we're doing a quickstart, we don't need to prompt for project details | ||
if (isCoreAppTemplate) { | ||
const client = apiClient({requireUser: true, requireProject: false}) | ||
const organizations = await client.request({uri: '/organizations'}) | ||
const coreAppOrganizationId = await getOrganizationId(organizations) | ||
return { | ||
projectId: '', | ||
displayName: '', | ||
datasetName: '', | ||
isFirstProject: false, | ||
datasetName: '', | ||
organizationId: coreAppOrganizationId, | ||
} | ||
@@ -1098,2 +1110,3 @@ } | ||
projectName: displayName || answers.projectName, | ||
organizationId, | ||
} | ||
@@ -1238,8 +1251,8 @@ | ||
async function getOrganizationId(organizations: ProjectOrganization[]) { | ||
let organizationId = flags.organization | ||
let orgId = flags.organization | ||
if (unattended) { | ||
return organizationId || undefined | ||
return orgId || undefined | ||
} | ||
const shouldPrompt = organizations.length > 0 && !organizationId | ||
const shouldPrompt = organizations.length > 0 && !orgId | ||
if (shouldPrompt) { | ||
@@ -1270,6 +1283,6 @@ debug(`User has ${organizations.length} organization(s), checking attach access`) | ||
if (chosenOrg && chosenOrg !== 'none') { | ||
organizationId = chosenOrg | ||
orgId = chosenOrg | ||
} | ||
} else if (organizationId) { | ||
debug(`User has defined organization flag explicitly (%s)`, organizationId) | ||
} else if (orgId) { | ||
debug(`User has defined organization flag explicitly (%s)`, orgId) | ||
} else if (organizations.length === 0) { | ||
@@ -1279,6 +1292,6 @@ debug('User has no organizations, skipping selection prompt') | ||
return organizationId || undefined | ||
return orgId || undefined | ||
} | ||
async function hasProjectAttachGrant(organizationId: string) { | ||
async function hasProjectAttachGrant(orgId: string) { | ||
const requiredGrantGroup = 'sanity.organization.projects' | ||
@@ -1291,3 +1304,3 @@ const requiredGrant = 'attach' | ||
const grants = await client.request({uri: `organizations/${organizationId}/grants`}) | ||
const grants = await client.request({uri: `organizations/${orgId}/grants`}) | ||
const group: {grants: {name: string}[]}[] = grants[requiredGrantGroup] || [] | ||
@@ -1294,0 +1307,0 @@ return group.some( |
@@ -50,6 +50,7 @@ /* eslint-disable no-console, no-process-exit, no-sync */ | ||
const isInit = args.groupOrCommand === 'init' && args.argsWithoutOptions[0] !== 'plugin' | ||
const isCoreApp = args.groupOrCommand === 'app' | ||
const cwd = getCurrentWorkingDirectory() | ||
let workDir: string | undefined | ||
try { | ||
workDir = isInit ? process.cwd() : resolveRootDir(cwd) | ||
workDir = isInit ? process.cwd() : resolveRootDir(cwd, isCoreApp) | ||
} catch (err) { | ||
@@ -60,3 +61,3 @@ console.error(chalk.red(err.message)) | ||
loadAndSetEnvFromDotEnvFiles({workDir, cmd: args.groupOrCommand}) | ||
loadAndSetEnvFromDotEnvFiles({workDir, cmd: args.groupOrCommand, isCoreApp}) | ||
maybeFixMissingWindowsEnvVar() | ||
@@ -104,2 +105,3 @@ | ||
telemetry, | ||
isCoreApp, | ||
} | ||
@@ -280,3 +282,11 @@ | ||
function loadAndSetEnvFromDotEnvFiles({workDir, cmd}: {workDir: string; cmd: string}) { | ||
function loadAndSetEnvFromDotEnvFiles({ | ||
workDir, | ||
cmd, | ||
isCoreApp, | ||
}: { | ||
workDir: string | ||
cmd: string | ||
isCoreApp: boolean | ||
}) { | ||
/* eslint-disable no-process-env */ | ||
@@ -316,3 +326,3 @@ | ||
const studioEnv = loadEnv(mode, workDir, ['SANITY_STUDIO_']) | ||
const studioEnv = loadEnv(mode, workDir, isCoreApp ? ['VITE_'] : ['SANITY_STUDIO_']) | ||
process.env = {...process.env, ...studioEnv} | ||
@@ -319,0 +329,0 @@ /* eslint-disable no-process-env */ |
@@ -150,2 +150,3 @@ import {type SanityClient} from '@sanity/client' | ||
telemetry: TelemetryLogger<TelemetryUserProperties> | ||
isCoreApp: boolean | ||
} | ||
@@ -356,3 +357,5 @@ | ||
__experimental_coreAppConfiguration?: { | ||
organizationId?: string | ||
appLocation?: string | ||
appId?: string | ||
} | ||
@@ -359,0 +362,0 @@ } |
@@ -10,5 +10,5 @@ /* eslint-disable no-sync */ | ||
*/ | ||
export function resolveRootDir(cwd: string): string { | ||
export function resolveRootDir(cwd: string, isCoreApp = false): string { | ||
try { | ||
return resolveProjectRoot(cwd) || cwd | ||
return resolveProjectRoot(cwd, 0, isCoreApp) || cwd | ||
} catch (err) { | ||
@@ -19,6 +19,6 @@ throw new Error(`Error occurred trying to resolve project root:\n${err.message}`) | ||
function hasStudioConfig(basePath: string): boolean { | ||
function hasSanityConfig(basePath: string, configName: string): boolean { | ||
const buildConfigs = [ | ||
fileExists(path.join(basePath, 'sanity.config.js')), | ||
fileExists(path.join(basePath, 'sanity.config.ts')), | ||
fileExists(path.join(basePath, `${configName}.js`)), | ||
fileExists(path.join(basePath, `${configName}.ts`)), | ||
isSanityV2StudioRoot(basePath), | ||
@@ -30,4 +30,5 @@ ] | ||
function resolveProjectRoot(basePath: string, iterations = 0): string | false { | ||
if (hasStudioConfig(basePath)) { | ||
function resolveProjectRoot(basePath: string, iterations = 0, isCoreApp = false): string | false { | ||
const configName = isCoreApp ? 'sanity.cli' : 'sanity.config' | ||
if (hasSanityConfig(basePath, configName)) { | ||
return basePath | ||
@@ -42,3 +43,3 @@ } | ||
return resolveProjectRoot(parentDir, iterations + 1) | ||
return resolveProjectRoot(parentDir, iterations + 1, isCoreApp) | ||
} | ||
@@ -45,0 +46,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
11183631
336
98382
1
1
- Removed@babel/helper-create-regexp-features-plugin@7.26.3(transitive)
- Removed@babel/helper-define-polyfill-provider@0.6.3(transitive)
- Removed@babel/helper-remap-async-to-generator@7.25.9(transitive)
- Removed@babel/helper-wrap-function@7.25.9(transitive)
- Removed@babel/plugin-bugfix-firefox-class-in-computed-class-key@7.25.9(transitive)
- Removed@babel/plugin-bugfix-safari-class-field-initializer-scope@7.25.9(transitive)
- Removed@babel/plugin-bugfix-safari-id-destructuring-collision-in-function-expression@7.25.9(transitive)
- Removed@babel/plugin-bugfix-v8-spread-parameters-in-optional-chaining@7.25.9(transitive)
- Removed@babel/plugin-bugfix-v8-static-class-fields-redefine-readonly@7.25.9(transitive)
- Removed@babel/plugin-proposal-private-property-in-object@7.21.0-placeholder-for-preset-env.2(transitive)
- Removed@babel/plugin-syntax-import-assertions@7.26.0(transitive)
- Removed@babel/plugin-syntax-import-attributes@7.26.0(transitive)
- Removed@babel/plugin-syntax-unicode-sets-regex@7.18.6(transitive)
- Removed@babel/plugin-transform-arrow-functions@7.25.9(transitive)
- Removed@babel/plugin-transform-async-generator-functions@7.26.8(transitive)
- Removed@babel/plugin-transform-async-to-generator@7.25.9(transitive)
- Removed@babel/plugin-transform-block-scoped-functions@7.26.5(transitive)
- Removed@babel/plugin-transform-block-scoping@7.25.9(transitive)
- Removed@babel/plugin-transform-class-properties@7.25.9(transitive)
- Removed@babel/plugin-transform-class-static-block@7.26.0(transitive)
- Removed@babel/plugin-transform-classes@7.25.9(transitive)
- Removed@babel/plugin-transform-computed-properties@7.25.9(transitive)
- Removed@babel/plugin-transform-destructuring@7.25.9(transitive)
- Removed@babel/plugin-transform-dotall-regex@7.25.9(transitive)
- Removed@babel/plugin-transform-duplicate-keys@7.25.9(transitive)
- Removed@babel/plugin-transform-duplicate-named-capturing-groups-regex@7.25.9(transitive)
- Removed@babel/plugin-transform-dynamic-import@7.25.9(transitive)
- Removed@babel/plugin-transform-exponentiation-operator@7.26.3(transitive)
- Removed@babel/plugin-transform-export-namespace-from@7.25.9(transitive)
- Removed@babel/plugin-transform-for-of@7.26.9(transitive)
- Removed@babel/plugin-transform-function-name@7.25.9(transitive)
- Removed@babel/plugin-transform-json-strings@7.25.9(transitive)
- Removed@babel/plugin-transform-literals@7.25.9(transitive)
- Removed@babel/plugin-transform-logical-assignment-operators@7.25.9(transitive)
- Removed@babel/plugin-transform-member-expression-literals@7.25.9(transitive)
- Removed@babel/plugin-transform-modules-amd@7.25.9(transitive)
- Removed@babel/plugin-transform-modules-systemjs@7.25.9(transitive)
- Removed@babel/plugin-transform-modules-umd@7.25.9(transitive)
- Removed@babel/plugin-transform-named-capturing-groups-regex@7.25.9(transitive)
- Removed@babel/plugin-transform-new-target@7.25.9(transitive)
- Removed@babel/plugin-transform-nullish-coalescing-operator@7.26.6(transitive)
- Removed@babel/plugin-transform-numeric-separator@7.25.9(transitive)
- Removed@babel/plugin-transform-object-rest-spread@7.25.9(transitive)
- Removed@babel/plugin-transform-object-super@7.25.9(transitive)
- Removed@babel/plugin-transform-optional-catch-binding@7.25.9(transitive)
- Removed@babel/plugin-transform-optional-chaining@7.25.9(transitive)
- Removed@babel/plugin-transform-parameters@7.25.9(transitive)
- Removed@babel/plugin-transform-private-methods@7.25.9(transitive)
- Removed@babel/plugin-transform-private-property-in-object@7.25.9(transitive)
- Removed@babel/plugin-transform-property-literals@7.25.9(transitive)
- Removed@babel/plugin-transform-react-display-name@7.25.9(transitive)
- Removed@babel/plugin-transform-react-jsx@7.25.9(transitive)
- Removed@babel/plugin-transform-react-jsx-development@7.25.9(transitive)
- Removed@babel/plugin-transform-react-pure-annotations@7.25.9(transitive)
- Removed@babel/plugin-transform-regenerator@7.25.9(transitive)
- Removed@babel/plugin-transform-regexp-modifiers@7.26.0(transitive)
- Removed@babel/plugin-transform-reserved-words@7.25.9(transitive)
- Removed@babel/plugin-transform-shorthand-properties@7.25.9(transitive)
- Removed@babel/plugin-transform-spread@7.25.9(transitive)
- Removed@babel/plugin-transform-sticky-regex@7.25.9(transitive)
- Removed@babel/plugin-transform-template-literals@7.26.8(transitive)
- Removed@babel/plugin-transform-typeof-symbol@7.26.7(transitive)
- Removed@babel/plugin-transform-unicode-escapes@7.25.9(transitive)
- Removed@babel/plugin-transform-unicode-property-regex@7.25.9(transitive)
- Removed@babel/plugin-transform-unicode-regex@7.25.9(transitive)
- Removed@babel/plugin-transform-unicode-sets-regex@7.25.9(transitive)
- Removed@babel/preset-env@7.26.9(transitive)
- Removed@babel/preset-modules@0.1.6-no-external-plugins(transitive)
- Removed@babel/preset-react@7.26.3(transitive)
- Removed@babel/register@7.25.9(transitive)
- Removed@babel/runtime@7.26.9(transitive)
- Removed@sanity/codegen@3.75.0(transitive)
- Removed@sanity/types@3.75.0(transitive)
- Removed@sanity/util@3.75.0(transitive)
- Removed@types/react@19.0.10(transitive)
- Removedbabel-plugin-polyfill-corejs2@0.4.12(transitive)
- Removedbabel-plugin-polyfill-corejs3@0.11.1(transitive)
- Removedbabel-plugin-polyfill-regenerator@0.6.3(transitive)
- Removedclone-deep@4.0.1(transitive)
- Removedcore-js-compat@3.41.0(transitive)
- Removedcsstype@3.1.3(transitive)
- Removeddom-walk@0.1.2(transitive)
- Removedesutils@2.0.3(transitive)
- Removedfind-cache-dir@2.1.0(transitive)
- Removedget-random-values@1.2.2(transitive)
- Removedget-random-values-esm@1.0.2(transitive)
- Removedglobal@4.4.0(transitive)
- Removedgroq@3.75.0(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedisobject@3.0.1(transitive)
- Removedjsesc@3.0.2(transitive)
- Removedkind-of@6.0.3(transitive)
- Removedlodash.debounce@4.0.8(transitive)
- Removedmake-dir@2.1.0(transitive)
- Removedmin-document@2.19.0(transitive)
- Removedmoment@2.30.1(transitive)
- Removedpify@4.0.1(transitive)
- Removedpirates@4.0.6(transitive)
- Removedpkg-dir@3.0.0(transitive)
- Removedprocess@0.11.10(transitive)
- Removedregenerate@1.4.2(transitive)
- Removedregenerate-unicode-properties@10.2.0(transitive)
- Removedregenerator-runtime@0.14.1(transitive)
- Removedregenerator-transform@0.15.2(transitive)
- Removedregexpu-core@6.2.0(transitive)
- Removedregjsgen@0.8.0(transitive)
- Removedregjsparser@0.12.0(transitive)
- Removedsemver@5.7.2(transitive)
- Removedshallow-clone@3.0.1(transitive)
- Removedstrip-bom@3.0.0(transitive)
- Removedtsconfig-paths@4.2.0(transitive)
- Removedunicode-canonical-property-names-ecmascript@2.0.1(transitive)
- Removedunicode-match-property-ecmascript@2.0.0(transitive)
- Removedunicode-match-property-value-ecmascript@2.2.0(transitive)
- Removedunicode-property-aliases-ecmascript@2.1.0(transitive)
- Removedzod@3.24.2(transitive)
Updated@sanity/client@^6.28.0