New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@sanity/cli

Package Overview
Dependencies
Maintainers
0
Versions
1662
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@sanity/cli - npm Package Compare versions

Comparing version 3.75.0 to 3.75.1-canary.110

templates/core-app/src/ExampleComponent.tsx

16

lib/_chunks-cjs/loadEnv.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc