@sanity/cli 6.5.0 → 6.5.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/README.md +190 -98
- package/dist/actions/build/buildApp.js +35 -14
- package/dist/actions/build/buildApp.js.map +1 -1
- package/dist/actions/build/buildStudio.js +54 -26
- package/dist/actions/build/buildStudio.js.map +1 -1
- package/dist/actions/build/buildVendorDependencies.js +3 -2
- package/dist/actions/build/buildVendorDependencies.js.map +1 -1
- package/dist/actions/build/checkRequiredDependencies.js +2 -5
- package/dist/actions/build/checkRequiredDependencies.js.map +1 -1
- package/dist/actions/build/checkStudioDependencyVersions.js +1 -2
- package/dist/actions/build/checkStudioDependencyVersions.js.map +1 -1
- package/dist/actions/build/getViteConfig.js +2 -1
- package/dist/actions/build/getViteConfig.js.map +1 -1
- package/dist/actions/codemods/reactIconsV3.js +1 -1
- package/dist/actions/codemods/reactIconsV3.js.map +1 -1
- package/dist/actions/deploy/deployApp.js +1 -1
- package/dist/actions/deploy/deployApp.js.map +1 -1
- package/dist/actions/deploy/deployStudio.js +1 -2
- package/dist/actions/deploy/deployStudio.js.map +1 -1
- package/dist/actions/dev/startStudioDevServer.js +1 -2
- package/dist/actions/dev/startStudioDevServer.js.map +1 -1
- package/dist/actions/manifest/extractAppManifest.js +3 -2
- package/dist/actions/manifest/extractAppManifest.js.map +1 -1
- package/dist/actions/manifest/types.js +9 -0
- package/dist/actions/manifest/types.js.map +1 -1
- package/dist/actions/manifest/writeManifestFile.js +1 -2
- package/dist/actions/manifest/writeManifestFile.js.map +1 -1
- package/dist/actions/schema/uploadSchemaToLexicon.js +1 -2
- package/dist/actions/schema/uploadSchemaToLexicon.js.map +1 -1
- package/dist/actions/versions/buildPackageArray.js +1 -1
- package/dist/actions/versions/buildPackageArray.js.map +1 -1
- package/dist/constants.js +8 -0
- package/dist/constants.js.map +1 -0
- package/dist/server/previewServer.js +1 -1
- package/dist/server/previewServer.js.map +1 -1
- package/dist/services/userApplications.js.map +1 -1
- package/dist/util/compareDependencyVersions.js +1 -2
- package/dist/util/compareDependencyVersions.js.map +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +9 -9
- package/dist/util/getLocalPackageVersion.js +0 -55
- package/dist/util/getLocalPackageVersion.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { styleText } from 'node:util';
|
|
4
|
+
import { getLocalPackageVersion } from '@sanity/cli-core';
|
|
4
5
|
import { preview } from 'vite';
|
|
5
6
|
import { extendViteConfigWithUserConfig } from '../actions/build/getViteConfig.js';
|
|
6
|
-
import { getLocalPackageVersion } from '../util/getLocalPackageVersion.js';
|
|
7
7
|
import { serverDebug } from './serverDebug.js';
|
|
8
8
|
import { sanityBasePathRedirectPlugin } from './vite/plugin-sanity-basepath-redirect.js';
|
|
9
9
|
const debug = serverDebug.extend('preview');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/server/previewServer.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {type UserViteConfig} from '@sanity/cli-core'\nimport {type InlineConfig, preview} from 'vite'\n\nimport {extendViteConfigWithUserConfig} from '../actions/build/getViteConfig.js'\nimport {
|
|
1
|
+
{"version":3,"sources":["../../src/server/previewServer.ts"],"sourcesContent":["import {readFile} from 'node:fs/promises'\nimport path from 'node:path'\nimport {styleText} from 'node:util'\n\nimport {getLocalPackageVersion, type UserViteConfig} from '@sanity/cli-core'\nimport {type InlineConfig, preview} from 'vite'\n\nimport {extendViteConfigWithUserConfig} from '../actions/build/getViteConfig.js'\nimport {serverDebug} from './serverDebug.js'\nimport {sanityBasePathRedirectPlugin} from './vite/plugin-sanity-basepath-redirect.js'\n\nconst debug = serverDebug.extend('preview')\n\n/**\n * @internal\n */\nexport interface PreviewServer {\n close(): Promise<void>\n urls: {local: string[]; network: string[]}\n}\n\ninterface PreviewServerOptions {\n cwd: string\n httpPort: number\n\n root: string\n\n workDir: string\n\n httpHost?: string\n isApp?: boolean\n vite?: UserViteConfig\n}\n\n/**\n * Starts a Vite preview server for the given build output directory\n *\n * @param options - Preview server options\n * @returns A promise that resolves to the started preview server\n * @internal\n */\nexport async function startPreviewServer(options: PreviewServerOptions): Promise<PreviewServer> {\n const {httpHost, httpPort, isApp, root, vite: extendViteConfig, workDir} = options\n const startTime = Date.now()\n\n const indexPath = path.join(root, 'index.html')\n let basePath: string | undefined\n try {\n const index = await readFile(indexPath, 'utf8')\n basePath = tryResolveBasePathFromIndex(index)\n } catch (err: unknown) {\n if (err instanceof Error && 'code' in err && err.code === 'ENOENT') {\n const error = new Error(`Could not find a production build in the '${root}' directory.`)\n error.name = 'BUILD_NOT_FOUND'\n throw error\n }\n\n throw err\n }\n\n const mode = 'production'\n let previewConfig: InlineConfig = {\n base: basePath || '/',\n // Needed for vite to not serve `root/dist`\n build: {\n outDir: root,\n },\n configFile: false,\n mode,\n plugins: [sanityBasePathRedirectPlugin(basePath)],\n preview: {\n host: httpHost,\n port: httpPort,\n strictPort: true,\n },\n root: workDir,\n }\n\n // Extend Vite configuration with user-provided config\n if (extendViteConfig) {\n previewConfig = await extendViteConfigWithUserConfig(\n {command: 'serve', mode},\n previewConfig,\n extendViteConfig,\n )\n }\n\n debug('Creating vite server')\n const server = await preview(previewConfig)\n const warn = server.config.logger.warn\n const info = server.config.logger.info\n const url = server.resolvedUrls!.local[0]\n\n if (basePath === undefined) {\n warn('Could not determine base path from index.html, using \"/\" as default')\n } else if (basePath && basePath !== '/') {\n info(`Using resolved base path from static build: ${styleText('cyan', basePath)}`)\n }\n\n const startupDuration = Date.now() - startTime\n\n const viteVersion = await getLocalPackageVersion('vite', import.meta.url)\n\n info(\n `Sanity ${isApp ? 'application' : 'Studio'} ` +\n `using ${styleText('cyan', `vite@${viteVersion}`)} ` +\n `ready in ${styleText('cyan', `${Math.ceil(startupDuration)}ms`)} ` +\n `and running at ${styleText('cyan', url)} (production preview mode)`,\n )\n\n return {\n close: () =>\n new Promise((resolve, reject) =>\n server.httpServer.close((err) => (err ? reject(err) : resolve())),\n ),\n urls: server.resolvedUrls!,\n }\n}\n\nfunction tryResolveBasePathFromIndex(index: string): string | undefined {\n // <script ... src=\"/some-base-path/static/sanity-a3cc3d86.js\"></script>\n const basePath = index.match(/<script[^>]+src=\"(.*?)\\/static\\/sanity-/)?.[1]\n\n // We _expect_ to be able to find the base path. If we can't, we should warn.\n // Note that we're checking for `undefined` here, since an empty string is a\n // valid base path.\n if (basePath === undefined) {\n return undefined\n }\n\n // In the case of an empty base path, we still want to return `/` to indicate\n // that we _found_ the basepath - it just happens to be empty. Eg:\n // <script ... src = \"/static/sanity-a3cc3d86.js\"></script>\n // Which differs from not being able to find the script tag at all, in which\n // case we'll want to show a warning to indicate that it is an abnormality.\n return basePath === '' ? '/' : basePath\n}\n"],"names":["readFile","path","styleText","getLocalPackageVersion","preview","extendViteConfigWithUserConfig","serverDebug","sanityBasePathRedirectPlugin","debug","extend","startPreviewServer","options","httpHost","httpPort","isApp","root","vite","extendViteConfig","workDir","startTime","Date","now","indexPath","join","basePath","index","tryResolveBasePathFromIndex","err","Error","code","error","name","mode","previewConfig","base","build","outDir","configFile","plugins","host","port","strictPort","command","server","warn","config","logger","info","url","resolvedUrls","local","undefined","startupDuration","viteVersion","Math","ceil","close","Promise","resolve","reject","httpServer","urls","match"],"mappings":"AAAA,SAAQA,QAAQ,QAAO,mBAAkB;AACzC,OAAOC,UAAU,YAAW;AAC5B,SAAQC,SAAS,QAAO,YAAW;AAEnC,SAAQC,sBAAsB,QAA4B,mBAAkB;AAC5E,SAA2BC,OAAO,QAAO,OAAM;AAE/C,SAAQC,8BAA8B,QAAO,oCAAmC;AAChF,SAAQC,WAAW,QAAO,mBAAkB;AAC5C,SAAQC,4BAA4B,QAAO,4CAA2C;AAEtF,MAAMC,QAAQF,YAAYG,MAAM,CAAC;AA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Aa,KAAK;QACvCuB,KAAK,CAAC,4CAA4C,EAAE7C,UAAU,QAAQsB,WAAW;IACnF;IAEA,MAAM4B,kBAAkBhC,KAAKC,GAAG,KAAKF;IAErC,MAAMkC,cAAc,MAAMlD,uBAAuB,QAAQ,YAAY6C,GAAG;IAExED,KACE,CAAC,OAAO,EAAEjC,QAAQ,gBAAgB,SAAS,CAAC,CAAC,GAC3C,CAAC,MAAM,EAAEZ,UAAU,QAAQ,CAAC,KAAK,EAAEmD,aAAa,EAAE,CAAC,CAAC,GACpD,CAAC,SAAS,EAAEnD,UAAU,QAAQ,GAAGoD,KAAKC,IAAI,CAACH,iBAAiB,EAAE,CAAC,EAAE,CAAC,CAAC,GACnE,CAAC,eAAe,EAAElD,UAAU,QAAQ8C,KAAK,0BAA0B,CAAC;IAGxE,OAAO;QACLQ,OAAO,IACL,IAAIC,QAAQ,CAACC,SAASC,SACpBhB,OAAOiB,UAAU,CAACJ,KAAK,CAAC,CAAC7B,MAASA,MAAMgC,OAAOhC,OAAO+B;QAE1DG,MAAMlB,OAAOM,YAAY;IAC3B;AACF;AAEA,SAASvB,4BAA4BD,KAAa;IAChD,wEAAwE;IACxE,MAAMD,WAAWC,MAAMqC,KAAK,CAAC,4CAA4C,CAAC,EAAE;IAE5E,6EAA6E;IAC7E,4EAA4E;IAC5E,mBAAmB;IACnB,IAAItC,aAAa2B,WAAW;QAC1B,OAAOA;IACT;IAEA,6EAA6E;IAC7E,kEAAkE;IAClE,2DAA2D;IAC3D,4EAA4E;IAC5E,2EAA2E;IAC3E,OAAO3B,aAAa,KAAK,MAAMA;AACjC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/services/userApplications.ts"],"sourcesContent":["import {PassThrough} from 'node:stream'\nimport {type Gzip} from 'node:zlib'\n\nimport {debug, getGlobalCliClient} from '@sanity/cli-core'\nimport FormData from 'form-data'\nimport {type StudioManifest} from 'sanity'\n\nimport {type AppManifest} from '../actions/manifest/types.js'\n\nexport const USER_APPLICATIONS_API_VERSION = 'v2024-08-01'\n\ninterface ActiveDeployment {\n createdAt: string\n deployedAt: string\n deployedBy: string\n isActiveDeployment: boolean\n isAutoUpdating: boolean | null\n size: string | null\n updatedAt: string\n version: string\n}\n\nexport interface UserApplication {\n appHost: string\n createdAt: string\n id: string\n organizationId: string | null\n projectId: string | null\n title: string | null\n type: 'coreApp' | 'studio'\n updatedAt: string\n urlType: 'external' | 'internal'\n\n activeDeployment?: ActiveDeployment | null\n}\n\ntype GetUserApplicationOptions =\n | {appHost?: never; appId: string; isSdkApp: true; projectId?: never}\n | {appHost?: string; appId?: string; isSdkApp: false; projectId: string}\n\nexport async function getUserApplication({\n appHost,\n appId,\n isSdkApp,\n projectId,\n}: GetUserApplicationOptions): Promise<UserApplication | null> {\n let query: Record<string, string | string[]> | undefined\n let uri: string\n\n // set the uri\n if (isSdkApp) {\n uri = appId ? `/user-applications/${appId}` : '/user-applications'\n } else {\n uri = appId\n ? `/projects/${projectId}/user-applications/${appId}`\n : `/projects/${projectId}/user-applications`\n }\n\n // set the query\n if (isSdkApp) {\n query = {appType: 'coreApp'}\n } else if (!appId) {\n // In practice, this function isn't called if we don't have at least one of appHost or appId,\n // so the default case won't be called. But leaving this ternary in for now (from old CLI code) just in case.\n query = appHost ? {appHost, appType: 'studio'} : {default: 'true'}\n }\n\n const client = await getGlobalCliClient({\n apiVersion: USER_APPLICATIONS_API_VERSION,\n requireUser: true,\n })\n\n try {\n const options = query ? {query, uri} : {uri}\n return await client.request(options)\n } catch (err) {\n if (err?.statusCode === 404) {\n return null\n }\n\n debug('Error getting user application', err)\n throw err\n }\n}\n\ninterface DeleteUserApplicationOptions {\n applicationId: string\n appType: 'coreApp' | 'studio'\n}\n\nexport async function deleteUserApplication({\n applicationId,\n appType,\n}: DeleteUserApplicationOptions): Promise<void> {\n const client = await getGlobalCliClient({\n apiVersion: USER_APPLICATIONS_API_VERSION,\n requireUser: true,\n })\n\n await client.request({\n method: 'DELETE',\n query: {appType},\n uri: `/user-applications/${applicationId}`,\n })\n}\n\ninterface UpdateUserApplicationBody {\n title?: string\n}\n\ninterface UpdateUserApplicationOptions {\n applicationId: string\n // Updating studio properties requires further UX thought\n // (because of workspaces et al.)\n appType: 'coreApp'\n body: UpdateUserApplicationBody\n}\n\nexport async function updateUserApplication({\n applicationId,\n appType,\n body,\n}: UpdateUserApplicationOptions): Promise<UserApplication> {\n const client = await getGlobalCliClient({\n apiVersion: USER_APPLICATIONS_API_VERSION,\n requireUser: true,\n })\n\n return client.request({\n body,\n method: 'PATCH',\n query: {appType},\n uri: `/user-applications/${applicationId}`,\n })\n}\n\nexport async function getUserApplications(options: {\n appType: 'studio'\n projectId: string\n}): Promise<UserApplication[]>\nexport async function getUserApplications(options: {\n appType: 'coreApp'\n organizationId: string\n}): Promise<UserApplication[]>\nexport async function getUserApplications(\n options:\n | {\n appType: 'coreApp'\n organizationId?: string\n }\n | {\n appType: 'studio'\n projectId?: string\n },\n): Promise<UserApplication[] | null> {\n const {appType} = options\n const client = await getGlobalCliClient({\n apiVersion: USER_APPLICATIONS_API_VERSION,\n requireUser: true,\n })\n\n if (appType === 'studio') {\n const {projectId} = options as {appType: 'studio'; projectId?: string}\n return await client.request({\n query: {appType: 'studio'},\n uri: `/projects/${projectId}/user-applications`,\n })\n }\n\n const {organizationId} = options as {appType: 'coreApp'; organizationId?: string}\n\n try {\n return await client.request({\n query: {appType: 'coreApp', organizationId: organizationId!},\n uri: `/user-applications`,\n })\n } catch (error) {\n // User doesn't have permission to view applications for the org,\n // or the organization ID doesn’t exist\n if (error?.statusCode === 403) {\n throw error\n }\n\n debug('Error finding user applications', error)\n return null\n }\n}\n\nexport async function createUserApplication(options: {\n appType: 'coreApp'\n body: Pick<UserApplication, 'appHost' | 'type' | 'urlType'> & {\n title?: string\n }\n organizationId?: string\n}): Promise<UserApplication>\nexport async function createUserApplication(options: {\n appType: 'studio'\n body: Pick<UserApplication, 'appHost' | 'type' | 'urlType'> & {\n title?: string\n }\n projectId: string\n}): Promise<UserApplication>\nexport async function createUserApplication(options: {\n appType: 'coreApp' | 'studio'\n body: Pick<UserApplication, 'appHost' | 'type' | 'urlType'> & {\n title?: string\n }\n organizationId?: string\n projectId?: string\n}): Promise<UserApplication> {\n const {appType, body} = options\n\n const client = await getGlobalCliClient({\n apiVersion: USER_APPLICATIONS_API_VERSION,\n requireUser: true,\n })\n\n let uri\n let query\n\n // If we have an organizationId, we're creating a core app\n if (appType === 'coreApp') {\n const {organizationId} = options as {appType: 'coreApp'; organizationId?: string}\n uri = '/user-applications'\n query = {appType: 'coreApp', organizationId: organizationId!}\n } else {\n const {projectId} = options as {appType: 'studio'; projectId?: string}\n uri = `/projects/${projectId}/user-applications`\n query = {appType: 'studio'}\n }\n\n return client.request({body, method: 'POST', query, uri})\n}\n\ninterface CreateDeploymentOptions {\n applicationId: string\n isAutoUpdating: boolean\n version: string\n\n isApp?: boolean\n\n manifest?: AppManifest | StudioManifest | null\n\n projectId?: string\n\n tarball?: Gzip\n}\n\nexport async function createDeployment({\n applicationId,\n isApp,\n isAutoUpdating,\n manifest,\n projectId,\n tarball,\n version,\n}: CreateDeploymentOptions): Promise<{location: string}> {\n const client = await getGlobalCliClient({\n apiVersion: USER_APPLICATIONS_API_VERSION,\n requireUser: true,\n })\n\n const formData = new FormData()\n formData.append('isAutoUpdating', isAutoUpdating.toString())\n formData.append('version', version)\n if (manifest) {\n formData.append('manifest', JSON.stringify(manifest))\n }\n\n if (tarball) {\n formData.append('tarball', tarball, {contentType: 'application/gzip', filename: 'app.tar.gz'})\n }\n\n let uri\n let query\n\n if (isApp) {\n uri = `/user-applications/${applicationId}/deployments`\n query = {appType: 'coreApp'}\n } else {\n uri = `/projects/${projectId}/user-applications/${applicationId}/deployments`\n query = {appType: 'studio'}\n }\n\n return client.request({\n body: formData.pipe(new PassThrough()),\n headers: formData.getHeaders(),\n method: 'POST',\n query,\n uri,\n })\n}\n"],"names":["PassThrough","debug","getGlobalCliClient","FormData","USER_APPLICATIONS_API_VERSION","getUserApplication","appHost","appId","isSdkApp","projectId","query","uri","appType","default","client","apiVersion","requireUser","options","request","err","statusCode","deleteUserApplication","applicationId","method","updateUserApplication","body","getUserApplications","organizationId","error","createUserApplication","createDeployment","isApp","isAutoUpdating","manifest","tarball","version","formData","append","toString","JSON","stringify","contentType","filename","pipe","headers","getHeaders"],"mappings":"AAAA,SAAQA,WAAW,QAAO,cAAa;AAGvC,SAAQC,KAAK,EAAEC,kBAAkB,QAAO,mBAAkB;AAC1D,OAAOC,cAAc,YAAW;AAKhC,OAAO,MAAMC,gCAAgC,cAAa;AA+B1D,OAAO,eAAeC,mBAAmB,EACvCC,OAAO,EACPC,KAAK,EACLC,QAAQ,EACRC,SAAS,EACiB;IAC1B,IAAIC;IACJ,IAAIC;IAEJ,cAAc;IACd,IAAIH,UAAU;QACZG,MAAMJ,QAAQ,CAAC,mBAAmB,EAAEA,OAAO,GAAG;IAChD,OAAO;QACLI,MAAMJ,QACF,CAAC,UAAU,EAAEE,UAAU,mBAAmB,EAAEF,OAAO,GACnD,CAAC,UAAU,EAAEE,UAAU,kBAAkB,CAAC;IAChD;IAEA,gBAAgB;IAChB,IAAID,UAAU;QACZE,QAAQ;YAACE,SAAS;QAAS;IAC7B,OAAO,IAAI,CAACL,OAAO;QACjB,6FAA6F;QAC7F,6GAA6G;QAC7GG,QAAQJ,UAAU;YAACA;YAASM,SAAS;QAAQ,IAAI;YAACC,SAAS;QAAM;IACnE;IAEA,MAAMC,SAAS,MAAMZ,mBAAmB;QACtCa,YAAYX;QACZY,aAAa;IACf;IAEA,IAAI;QACF,MAAMC,UAAUP,QAAQ;YAACA;YAAOC;QAAG,IAAI;YAACA;QAAG;QAC3C,OAAO,MAAMG,OAAOI,OAAO,CAACD;IAC9B,EAAE,OAAOE,KAAK;QACZ,IAAIA,KAAKC,eAAe,KAAK;YAC3B,OAAO;QACT;QAEAnB,MAAM,kCAAkCkB;QACxC,MAAMA;IACR;AACF;AAOA,OAAO,eAAeE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;IAEA,OAAOE,OAAOI,OAAO,CAAC;QACpBO,MAAMW,SAASO,IAAI,CAAC,IAAI3C;QACxB4C,SAASR,SAASS,UAAU;QAC5BtB,QAAQ;QACRb;QACAC;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../src/services/userApplications.ts"],"sourcesContent":["import {PassThrough} from 'node:stream'\nimport {type Gzip} from 'node:zlib'\n\nimport {debug, getGlobalCliClient} from '@sanity/cli-core'\nimport FormData from 'form-data'\nimport {type StudioManifest} from 'sanity'\n\nimport {type CoreAppManifest} from '../actions/manifest/types.js'\n\nexport const USER_APPLICATIONS_API_VERSION = 'v2024-08-01'\n\ninterface ActiveDeployment {\n createdAt: string\n deployedAt: string\n deployedBy: string\n isActiveDeployment: boolean\n isAutoUpdating: boolean | null\n size: string | null\n updatedAt: string\n version: string\n}\n\nexport interface UserApplication {\n appHost: string\n createdAt: string\n id: string\n organizationId: string | null\n projectId: string | null\n title: string | null\n type: 'coreApp' | 'studio'\n updatedAt: string\n urlType: 'external' | 'internal'\n\n activeDeployment?: ActiveDeployment | null\n}\n\ntype GetUserApplicationOptions =\n | {appHost?: never; appId: string; isSdkApp: true; projectId?: never}\n | {appHost?: string; appId?: string; isSdkApp: false; projectId: string}\n\nexport async function getUserApplication({\n appHost,\n appId,\n isSdkApp,\n projectId,\n}: GetUserApplicationOptions): Promise<UserApplication | null> {\n let query: Record<string, string | string[]> | undefined\n let uri: string\n\n // set the uri\n if (isSdkApp) {\n uri = appId ? `/user-applications/${appId}` : '/user-applications'\n } else {\n uri = appId\n ? `/projects/${projectId}/user-applications/${appId}`\n : `/projects/${projectId}/user-applications`\n }\n\n // set the query\n if (isSdkApp) {\n query = {appType: 'coreApp'}\n } else if (!appId) {\n // In practice, this function isn't called if we don't have at least one of appHost or appId,\n // so the default case won't be called. But leaving this ternary in for now (from old CLI code) just in case.\n query = appHost ? {appHost, appType: 'studio'} : {default: 'true'}\n }\n\n const client = await getGlobalCliClient({\n apiVersion: USER_APPLICATIONS_API_VERSION,\n requireUser: true,\n })\n\n try {\n const options = query ? {query, uri} : {uri}\n return await client.request(options)\n } catch (err) {\n if (err?.statusCode === 404) {\n return null\n }\n\n debug('Error getting user application', err)\n throw err\n }\n}\n\ninterface DeleteUserApplicationOptions {\n applicationId: string\n appType: 'coreApp' | 'studio'\n}\n\nexport async function deleteUserApplication({\n applicationId,\n appType,\n}: DeleteUserApplicationOptions): Promise<void> {\n const client = await getGlobalCliClient({\n apiVersion: USER_APPLICATIONS_API_VERSION,\n requireUser: true,\n })\n\n await client.request({\n method: 'DELETE',\n query: {appType},\n uri: `/user-applications/${applicationId}`,\n })\n}\n\ninterface UpdateUserApplicationBody {\n title?: string\n}\n\ninterface UpdateUserApplicationOptions {\n applicationId: string\n // Updating studio properties requires further UX thought\n // (because of workspaces et al.)\n appType: 'coreApp'\n body: UpdateUserApplicationBody\n}\n\nexport async function updateUserApplication({\n applicationId,\n appType,\n body,\n}: UpdateUserApplicationOptions): Promise<UserApplication> {\n const client = await getGlobalCliClient({\n apiVersion: USER_APPLICATIONS_API_VERSION,\n requireUser: true,\n })\n\n return client.request({\n body,\n method: 'PATCH',\n query: {appType},\n uri: `/user-applications/${applicationId}`,\n })\n}\n\nexport async function getUserApplications(options: {\n appType: 'studio'\n projectId: string\n}): Promise<UserApplication[]>\nexport async function getUserApplications(options: {\n appType: 'coreApp'\n organizationId: string\n}): Promise<UserApplication[]>\nexport async function getUserApplications(\n options:\n | {\n appType: 'coreApp'\n organizationId?: string\n }\n | {\n appType: 'studio'\n projectId?: string\n },\n): Promise<UserApplication[] | null> {\n const {appType} = options\n const client = await getGlobalCliClient({\n apiVersion: USER_APPLICATIONS_API_VERSION,\n requireUser: true,\n })\n\n if (appType === 'studio') {\n const {projectId} = options as {appType: 'studio'; projectId?: string}\n return await client.request({\n query: {appType: 'studio'},\n uri: `/projects/${projectId}/user-applications`,\n })\n }\n\n const {organizationId} = options as {appType: 'coreApp'; organizationId?: string}\n\n try {\n return await client.request({\n query: {appType: 'coreApp', organizationId: organizationId!},\n uri: `/user-applications`,\n })\n } catch (error) {\n // User doesn't have permission to view applications for the org,\n // or the organization ID doesn’t exist\n if (error?.statusCode === 403) {\n throw error\n }\n\n debug('Error finding user applications', error)\n return null\n }\n}\n\nexport async function createUserApplication(options: {\n appType: 'coreApp'\n body: Pick<UserApplication, 'appHost' | 'type' | 'urlType'> & {\n title?: string\n }\n organizationId?: string\n}): Promise<UserApplication>\nexport async function createUserApplication(options: {\n appType: 'studio'\n body: Pick<UserApplication, 'appHost' | 'type' | 'urlType'> & {\n title?: string\n }\n projectId: string\n}): Promise<UserApplication>\nexport async function createUserApplication(options: {\n appType: 'coreApp' | 'studio'\n body: Pick<UserApplication, 'appHost' | 'type' | 'urlType'> & {\n title?: string\n }\n organizationId?: string\n projectId?: string\n}): Promise<UserApplication> {\n const {appType, body} = options\n\n const client = await getGlobalCliClient({\n apiVersion: USER_APPLICATIONS_API_VERSION,\n requireUser: true,\n })\n\n let uri\n let query\n\n // If we have an organizationId, we're creating a core app\n if (appType === 'coreApp') {\n const {organizationId} = options as {appType: 'coreApp'; organizationId?: string}\n uri = '/user-applications'\n query = {appType: 'coreApp', organizationId: organizationId!}\n } else {\n const {projectId} = options as {appType: 'studio'; projectId?: string}\n uri = `/projects/${projectId}/user-applications`\n query = {appType: 'studio'}\n }\n\n return client.request({body, method: 'POST', query, uri})\n}\n\ninterface CreateDeploymentOptions {\n applicationId: string\n isAutoUpdating: boolean\n version: string\n\n isApp?: boolean\n\n manifest?: CoreAppManifest | StudioManifest | null\n\n projectId?: string\n\n tarball?: Gzip\n}\n\nexport async function createDeployment({\n applicationId,\n isApp,\n isAutoUpdating,\n manifest,\n projectId,\n tarball,\n version,\n}: CreateDeploymentOptions): Promise<{location: string}> {\n const client = await getGlobalCliClient({\n apiVersion: USER_APPLICATIONS_API_VERSION,\n requireUser: true,\n })\n\n const formData = new FormData()\n formData.append('isAutoUpdating', isAutoUpdating.toString())\n formData.append('version', version)\n if (manifest) {\n formData.append('manifest', JSON.stringify(manifest))\n }\n\n if (tarball) {\n formData.append('tarball', tarball, {contentType: 'application/gzip', filename: 'app.tar.gz'})\n }\n\n let uri\n let query\n\n if (isApp) {\n uri = `/user-applications/${applicationId}/deployments`\n query = {appType: 'coreApp'}\n } else {\n uri = `/projects/${projectId}/user-applications/${applicationId}/deployments`\n query = {appType: 'studio'}\n }\n\n return client.request({\n body: formData.pipe(new PassThrough()),\n headers: formData.getHeaders(),\n method: 'POST',\n query,\n uri,\n })\n}\n"],"names":["PassThrough","debug","getGlobalCliClient","FormData","USER_APPLICATIONS_API_VERSION","getUserApplication","appHost","appId","isSdkApp","projectId","query","uri","appType","default","client","apiVersion","requireUser","options","request","err","statusCode","deleteUserApplication","applicationId","method","updateUserApplication","body","getUserApplications","organizationId","error","createUserApplication","createDeployment","isApp","isAutoUpdating","manifest","tarball","version","formData","append","toString","JSON","stringify","contentType","filename","pipe","headers","getHeaders"],"mappings":"AAAA,SAAQA,WAAW,QAAO,cAAa;AAGvC,SAAQC,KAAK,EAAEC,kBAAkB,QAAO,mBAAkB;AAC1D,OAAOC,cAAc,YAAW;AAKhC,OAAO,MAAMC,gCAAgC,cAAa;AA+B1D,OAAO,eAAeC,mBAAmB,EACvCC,OAAO,EACPC,KAAK,EACLC,QAAQ,EACRC,SAAS,EACiB;IAC1B,IAAIC;IACJ,IAAIC;IAEJ,cAAc;IACd,IAAIH,UAAU;QACZG,MAAMJ,QAAQ,CAAC,mBAAmB,EAAEA,OAAO,GAAG;IAChD,OAAO;QACLI,MAAMJ,QACF,CAAC,UAAU,EAAEE,UAAU,mBAAmB,EAAEF,OAAO,GACnD,CAAC,UAAU,EAAEE,UAAU,kBAAkB,CAAC;IAChD;IAEA,gBAAgB;IAChB,IAAID,UAAU;QACZE,QAAQ;YAACE,SAAS;QAAS;IAC7B,OAAO,IAAI,CAACL,OAAO;QACjB,6FAA6F;QAC7F,6GAA6G;QAC7GG,QAAQJ,UAAU;YAACA;YAASM,SAAS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IAC7C;IAEA,IAAIC,SAAS;QACXE,SAASC,MAAM,CAAC,WAAWH,SAAS;YAACO,aAAa;YAAoBC,UAAU;QAAY;IAC9F;IAEA,IAAI/B;IACJ,IAAID;IAEJ,IAAIqB,OAAO;QACTpB,MAAM,CAAC,mBAAmB,EAAEW,cAAc,YAAY,CAAC;QACvDZ,QAAQ;YAACE,SAAS;QAAS;IAC7B,OAAO;QACLD,MAAM,CAAC,UAAU,EAAEF,UAAU,mBAAmB,EAAEa,cAAc,YAAY,CAAC;QAC7EZ,QAAQ;YAACE,SAAS;QAAQ;IAC5B;IAEA,OAAOE,OAAOI,OAAO,CAAC;QACpBO,MAAMW,SAASO,IAAI,CAAC,IAAI3C;QACxB4C,SAASR,SAASS,UAAU;QAC5BtB,QAAQ;QACRb;QACAC;IACF;AACF"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { readPackageJson } from '@sanity/cli-core';
|
|
2
|
+
import { getLocalPackageVersion, readPackageJson } from '@sanity/cli-core';
|
|
3
3
|
import { createRequester } from '@sanity/cli-core/request';
|
|
4
4
|
import { coerce, eq, prerelease, parse as semverParse } from 'semver';
|
|
5
5
|
import { getModuleUrl } from '../actions/build/getAutoUpdatesImportMap.js';
|
|
6
|
-
import { getLocalPackageVersion } from './getLocalPackageVersion.js';
|
|
7
6
|
const defaultRequester = createRequester({
|
|
8
7
|
middleware: {
|
|
9
8
|
httpErrors: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/compareDependencyVersions.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {readPackageJson} from '@sanity/cli-core'\nimport {createRequester} from '@sanity/cli-core/request'\nimport {coerce, eq, prerelease, parse as semverParse} from 'semver'\n\nimport {getModuleUrl} from '../actions/build/getAutoUpdatesImportMap.js'\
|
|
1
|
+
{"version":3,"sources":["../../src/util/compareDependencyVersions.ts"],"sourcesContent":["import path from 'node:path'\n\nimport {getLocalPackageVersion, readPackageJson} from '@sanity/cli-core'\nimport {createRequester} from '@sanity/cli-core/request'\nimport {coerce, eq, prerelease, parse as semverParse} from 'semver'\n\nimport {getModuleUrl} from '../actions/build/getAutoUpdatesImportMap.js'\n\nconst defaultRequester = createRequester({\n middleware: {httpErrors: false, promise: {onlyBody: false}},\n})\n\ninterface CompareDependencyVersions {\n installed: string\n pkg: string\n remote: string\n}\n\nexport interface UnresolvedPrerelease {\n pkg: string\n version: string\n}\n\ninterface CompareDependencyVersionsResult {\n mismatched: Array<CompareDependencyVersions>\n unresolvedPrerelease: Array<UnresolvedPrerelease>\n}\n\ninterface CompareDependencyVersionsOptions {\n /** When provided, uses the app-specific module endpoint instead of the default endpoint. */\n appId?: string\n /** Optional requester for dependency injection (primarily for testing). */\n requester?: typeof defaultRequester\n}\n\n/**\n * @internal\n *\n * Compares the versions of dependencies in the studio or app with their remote versions.\n *\n * This function reads the package.json file in the provided working directory, and compares the versions of the dependencies\n * specified in the `autoUpdatesImports` parameter with their remote versions. If the versions do not match, the dependency is\n * added to a list of failed dependencies, which is returned by the function.\n *\n * The failed dependencies are anything that does not strictly match the remote version.\n * This means that if a version is lower or greater by even a patch it will be marked as failed.\n *\n * @param packages - An array of packages with their name and version to compare against remote.\n * @param workDir - The path to the working directory containing the package.json file.\n * @param options - Optional configuration for version comparison.\n *\n * @returns A promise that resolves to an object containing `mismatched` (packages whose local and remote versions differ)\n * and `unresolvedPrerelease` (packages with prerelease versions that could not be resolved remotely).\n *\n * @throws Throws an error if the remote version of a non-prerelease package cannot be fetched, or if the local version\n * of a package cannot be parsed.\n */\nexport async function compareDependencyVersions(\n packages: {name: string; version: string}[],\n workDir: string,\n {appId, requester = defaultRequester}: CompareDependencyVersionsOptions = {},\n): Promise<CompareDependencyVersionsResult> {\n const manifest = await readPackageJson(path.join(workDir, 'package.json'), {\n skipSchemaValidation: true,\n })\n const dependencies = {...manifest?.dependencies, ...manifest?.devDependencies}\n\n const mismatched: Array<CompareDependencyVersions> = []\n const unresolvedPrerelease: Array<UnresolvedPrerelease> = []\n\n for (const pkg of packages) {\n // Skip packages that are not declared in the local package.json\n if (!dependencies[pkg.name]) {\n continue\n }\n\n const resolvedVersion = await getRemoteResolvedVersion(getModuleUrl(pkg, {appId}), requester)\n\n if (resolvedVersion === null) {\n if (prerelease(pkg.version)) {\n unresolvedPrerelease.push({pkg: pkg.name, version: pkg.version})\n continue\n }\n throw new Error(\n `Failed to resolve remote version for ${pkg.name}@${pkg.version}: package not found`,\n )\n }\n\n const packageVersion = await getLocalPackageVersion(pkg.name, workDir)\n\n const manifestVersion = dependencies[pkg.name]\n\n const installed = coerce(packageVersion ? semverParse(packageVersion) : coerce(manifestVersion))\n\n if (!installed) {\n throw new Error(`Failed to parse installed version for ${pkg.name}`)\n }\n\n if (!eq(resolvedVersion, installed.version)) {\n mismatched.push({\n installed: installed.version,\n pkg: pkg.name,\n remote: resolvedVersion,\n })\n }\n }\n\n return {mismatched, unresolvedPrerelease}\n}\n\nasync function getRemoteResolvedVersion(\n url: string,\n request: typeof defaultRequester,\n): Promise<string | null> {\n let response\n try {\n response = await request({\n maxRedirects: 0,\n method: 'HEAD',\n url,\n })\n } catch (err) {\n const message = err instanceof Error ? err.message : String(err)\n throw new Error(`Failed to fetch remote version for ${url}: ${message}`, {cause: err})\n }\n\n // 302 is expected, but lets also handle 2xx\n if (response.statusCode < 400) {\n const resolved = response.headers['x-resolved-version']\n if (!resolved) {\n throw new Error(`Missing 'x-resolved-version' header on response from HEAD ${url}`)\n }\n return resolved\n }\n\n if (response.statusCode === 404) {\n return null\n }\n\n throw new Error(`Unexpected HTTP response: ${response.statusCode} ${response.statusMessage}`)\n}\n"],"names":["path","getLocalPackageVersion","readPackageJson","createRequester","coerce","eq","prerelease","parse","semverParse","getModuleUrl","defaultRequester","middleware","httpErrors","promise","onlyBody","compareDependencyVersions","packages","workDir","appId","requester","manifest","join","skipSchemaValidation","dependencies","devDependencies","mismatched","unresolvedPrerelease","pkg","name","resolvedVersion","getRemoteResolvedVersion","version","push","Error","packageVersion","manifestVersion","installed","remote","url","request","response","maxRedirects","method","err","message","String","cause","statusCode","resolved","headers","statusMessage"],"mappings":"AAAA,OAAOA,UAAU,YAAW;AAE5B,SAAQC,sBAAsB,EAAEC,eAAe,QAAO,mBAAkB;AACxE,SAAQC,eAAe,QAAO,2BAA0B;AACxD,SAAQC,MAAM,EAAEC,EAAE,EAAEC,UAAU,EAAEC,SAASC,WAAW,QAAO,SAAQ;AAEnE,SAAQC,YAAY,QAAO,8CAA6C;AAExE,MAAMC,mBAAmBP,gBAAgB;IACvCQ,YAAY;QAACC,YAAY;QAAOC,SAAS;YAACC,UAAU;QAAK;IAAC;AAC5D;AAyBA;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,eAAeC,0BACpBC,QAA2C,EAC3CC,OAAe,EACf,EAACC,KAAK,EAAEC,YAAYT,gBAAgB,EAAmC,GAAG,CAAC,CAAC;IAE5E,MAAMU,WAAW,MAAMlB,gBAAgBF,KAAKqB,IAAI,CAACJ,SAAS,iBAAiB;QACzEK,sBAAsB;IACxB;IACA,MAAMC,eAAe;QAAC,GAAGH,UAAUG,YAAY;QAAE,GAAGH,UAAUI,eAAe;IAAA;IAE7E,MAAMC,aAA+C,EAAE;IACvD,MAAMC,uBAAoD,EAAE;IAE5D,KAAK,MAAMC,OAAOX,SAAU;QAC1B,gEAAgE;QAChE,IAAI,CAACO,YAAY,CAACI,IAAIC,IAAI,CAAC,EAAE;YAC3B;QACF;QAEA,MAAMC,kBAAkB,MAAMC,yBAAyBrB,aAAakB,KAAK;YAACT;QAAK,IAAIC;QAEnF,IAAIU,oBAAoB,MAAM;YAC5B,IAAIvB,WAAWqB,IAAII,OAAO,GAAG;gBAC3BL,qBAAqBM,IAAI,CAAC;oBAACL,KAAKA,IAAIC,IAAI;oBAAEG,SAASJ,IAAII,OAAO;gBAAA;gBAC9D;YACF;YACA,MAAM,IAAIE,MACR,CAAC,qCAAqC,EAAEN,IAAIC,I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E;AAC9F"}
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/cli",
|
|
3
|
-
"version": "6.5.
|
|
3
|
+
"version": "6.5.1",
|
|
4
4
|
"description": "Sanity CLI tool for managing Sanity projects and organizations",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"cli",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"@sanity/id-utils": "^1.0.0",
|
|
64
64
|
"@sanity/import": "^6.0.1",
|
|
65
65
|
"@sanity/migrate": "^6.1.2",
|
|
66
|
-
"@sanity/runtime-cli": "^
|
|
66
|
+
"@sanity/runtime-cli": "^15.0.2",
|
|
67
67
|
"@sanity/schema": "^5.23.0",
|
|
68
68
|
"@sanity/telemetry": "^0.9.0",
|
|
69
69
|
"@sanity/template-validator": "^3.1.0",
|
|
@@ -116,15 +116,15 @@
|
|
|
116
116
|
"typeid-js": "^1.2.0",
|
|
117
117
|
"vite": "^7.3.2",
|
|
118
118
|
"which": "^6.0.1",
|
|
119
|
-
"yaml": "^2.8.
|
|
119
|
+
"yaml": "^2.8.4",
|
|
120
120
|
"zod": "^4.3.6",
|
|
121
|
-
"@sanity/cli-core": "^1.3.
|
|
121
|
+
"@sanity/cli-core": "^1.3.2"
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
124
|
"@eslint/compat": "^2.0.5",
|
|
125
125
|
"@sanity/pkg-utils": "^10.4.18",
|
|
126
126
|
"@swc/cli": "^0.8.1",
|
|
127
|
-
"@swc/core": "^1.15.
|
|
127
|
+
"@swc/core": "^1.15.33",
|
|
128
128
|
"@types/debug": "^4.1.13",
|
|
129
129
|
"@types/gunzip-maybe": "^1.4.3",
|
|
130
130
|
"@types/jsdom": "^28.0.1",
|
|
@@ -143,7 +143,7 @@
|
|
|
143
143
|
"babel-plugin-react-compiler": "^1.0.0",
|
|
144
144
|
"eslint": "^10.2.1",
|
|
145
145
|
"jsdom": "^29.0.2",
|
|
146
|
-
"nock": "^14.0.
|
|
146
|
+
"nock": "^14.0.14",
|
|
147
147
|
"oclif": "^4.23.0",
|
|
148
148
|
"publint": "^0.3.18",
|
|
149
149
|
"rimraf": "^6.0.1",
|
|
@@ -151,10 +151,10 @@
|
|
|
151
151
|
"typescript": "^5.9.3",
|
|
152
152
|
"vite-tsconfig-paths": "^6.1.1",
|
|
153
153
|
"vitest": "^4.1.5",
|
|
154
|
-
"@repo/package.config": "0.0.1",
|
|
155
154
|
"@repo/tsconfig": "3.70.0",
|
|
156
|
-
"@
|
|
157
|
-
"@sanity/cli-test": "0.3.
|
|
155
|
+
"@repo/package.config": "0.0.1",
|
|
156
|
+
"@sanity/cli-test": "0.3.3",
|
|
157
|
+
"@sanity/eslint-config-cli": "1.1.1"
|
|
158
158
|
},
|
|
159
159
|
"engines": {
|
|
160
160
|
"node": ">=20.19.1 <22 || >=22.12"
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { dirname, join, normalize, resolve } from 'node:path';
|
|
2
|
-
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
3
|
-
import { readPackageJson } from '@sanity/cli-core';
|
|
4
|
-
import { moduleResolve } from 'import-meta-resolve';
|
|
5
|
-
/**
|
|
6
|
-
* Get the version of a package installed locally.
|
|
7
|
-
*
|
|
8
|
-
* @param moduleName - The name of the package in npm.
|
|
9
|
-
* @param workDir - The working directory to resolve the module from. (aka project root)
|
|
10
|
-
* @returns The version of the package installed locally.
|
|
11
|
-
* @internal
|
|
12
|
-
*/ export async function getLocalPackageVersion(moduleName, workDir) {
|
|
13
|
-
try {
|
|
14
|
-
const packageDir = getLocalPackageDir(moduleName, workDir);
|
|
15
|
-
return (await readPackageJson(join(packageDir, 'package.json'))).version;
|
|
16
|
-
} catch {
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Resolve the filesystem directory of a locally installed package using Node
|
|
22
|
-
* module resolution. Works correctly with hoisted packages in monorepos/workspaces,
|
|
23
|
-
* pnpm symlinks, and other non-standard node_modules layouts.
|
|
24
|
-
*
|
|
25
|
-
* @param moduleName - The name of the package in npm.
|
|
26
|
-
* @param workDir - The working directory to resolve the module from. (aka project root)
|
|
27
|
-
* @returns The absolute path to the package directory.
|
|
28
|
-
* @internal
|
|
29
|
-
*/ export function getLocalPackageDir(moduleName, workDir) {
|
|
30
|
-
// Handle import.meta.url being passed instead of a directory path
|
|
31
|
-
const dir = workDir.startsWith('file://') ? dirname(fileURLToPath(workDir)) : workDir;
|
|
32
|
-
const dirUrl = pathToFileURL(resolve(dir, 'noop.js'));
|
|
33
|
-
try {
|
|
34
|
-
const packageJsonUrl = moduleResolve(`${moduleName}/package.json`, dirUrl);
|
|
35
|
-
return dirname(fileURLToPath(packageJsonUrl));
|
|
36
|
-
} catch (err) {
|
|
37
|
-
if (!isErrPackagePathNotExported(err)) {
|
|
38
|
-
throw err;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
// Fallback: resolve main entry point and derive package root
|
|
42
|
-
const mainUrl = moduleResolve(moduleName, dirUrl);
|
|
43
|
-
const mainPath = fileURLToPath(mainUrl);
|
|
44
|
-
const normalizedName = normalize(moduleName);
|
|
45
|
-
const idx = mainPath.lastIndexOf(normalizedName);
|
|
46
|
-
if (idx === -1) {
|
|
47
|
-
throw new Error(`Could not determine package directory for '${moduleName}'`);
|
|
48
|
-
}
|
|
49
|
-
return mainPath.slice(0, idx + normalizedName.length);
|
|
50
|
-
}
|
|
51
|
-
function isErrPackagePathNotExported(err) {
|
|
52
|
-
return err instanceof Error && 'code' in err && err.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED';
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
//# sourceMappingURL=getLocalPackageVersion.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/util/getLocalPackageVersion.ts"],"sourcesContent":["import {dirname, join, normalize, resolve} from 'node:path'\nimport {fileURLToPath, pathToFileURL} from 'node:url'\n\nimport {readPackageJson} from '@sanity/cli-core'\nimport {moduleResolve} from 'import-meta-resolve'\n\n/**\n * Get the version of a package installed locally.\n *\n * @param moduleName - The name of the package in npm.\n * @param workDir - The working directory to resolve the module from. (aka project root)\n * @returns The version of the package installed locally.\n * @internal\n */\nexport async function getLocalPackageVersion(\n moduleName: string,\n workDir: string,\n): Promise<string | null> {\n try {\n const packageDir = getLocalPackageDir(moduleName, workDir)\n return (await readPackageJson(join(packageDir, 'package.json'))).version\n } catch {\n return null\n }\n}\n\n/**\n * Resolve the filesystem directory of a locally installed package using Node\n * module resolution. Works correctly with hoisted packages in monorepos/workspaces,\n * pnpm symlinks, and other non-standard node_modules layouts.\n *\n * @param moduleName - The name of the package in npm.\n * @param workDir - The working directory to resolve the module from. (aka project root)\n * @returns The absolute path to the package directory.\n * @internal\n */\nexport function getLocalPackageDir(moduleName: string, workDir: string): string {\n // Handle import.meta.url being passed instead of a directory path\n const dir = workDir.startsWith('file://') ? dirname(fileURLToPath(workDir)) : workDir\n const dirUrl = pathToFileURL(resolve(dir, 'noop.js'))\n\n try {\n const packageJsonUrl = moduleResolve(`${moduleName}/package.json`, dirUrl)\n return dirname(fileURLToPath(packageJsonUrl))\n } catch (err: unknown) {\n if (!isErrPackagePathNotExported(err)) {\n throw err\n }\n }\n\n // Fallback: resolve main entry point and derive package root\n const mainUrl = moduleResolve(moduleName, dirUrl)\n const mainPath = fileURLToPath(mainUrl)\n const normalizedName = normalize(moduleName)\n const idx = mainPath.lastIndexOf(normalizedName)\n if (idx === -1) {\n throw new Error(`Could not determine package directory for '${moduleName}'`)\n }\n return mainPath.slice(0, idx + normalizedName.length)\n}\n\nfunction isErrPackagePathNotExported(err: unknown): boolean {\n return err instanceof Error && 'code' in err && err.code === 'ERR_PACKAGE_PATH_NOT_EXPORTED'\n}\n"],"names":["dirname","join","normalize","resolve","fileURLToPath","pathToFileURL","readPackageJson","moduleResolve","getLocalPackageVersion","moduleName","workDir","packageDir","getLocalPackageDir","version","dir","startsWith","dirUrl","packageJsonUrl","err","isErrPackagePathNotExported","mainUrl","mainPath","normalizedName","idx","lastIndexOf","Error","slice","length","code"],"mappings":"AAAA,SAAQA,OAAO,EAAEC,IAAI,EAAEC,SAAS,EAAEC,OAAO,QAAO,YAAW;AAC3D,SAAQC,aAAa,EAAEC,aAAa,QAAO,WAAU;AAErD,SAAQC,eAAe,QAAO,mBAAkB;AAChD,SAAQC,aAAa,QAAO,sBAAqB;AAEjD;;;;;;;CAOC,GACD,OAAO,eAAeC,uBACpBC,UAAkB,EAClBC,OAAe;IAEf,IAAI;QACF,MAAMC,aAAaC,mBAAmBH,YAAYC;QAClD,OAAO,AAAC,CAAA,MAAMJ,gBAAgBL,KAAKU,YAAY,gBAAe,EAAGE,OAAO;IAC1E,EAAE,OAAM;QACN,OAAO;IACT;AACF;AAEA;;;;;;;;;CASC,GACD,OAAO,SAASD,mBAAmBH,UAAkB,EAAEC,OAAe;IACpE,kEAAkE;IAClE,MAAMI,MAAMJ,QAAQK,UAAU,CAAC,aAAaf,QAAQI,cAAcM,YAAYA;IAC9E,MAAMM,SAASX,cAAcF,QAAQW,KAAK;IAE1C,IAAI;QACF,MAAMG,iBAAiBV,cAAc,GAAGE,WAAW,aAAa,CAAC,EAAEO;QACnE,OAAOhB,QAAQI,cAAca;IAC/B,EAAE,OAAOC,KAAc;QACrB,IAAI,CAACC,4BAA4BD,MAAM;YACrC,MAAMA;QACR;IACF;IAEA,6DAA6D;IAC7D,MAAME,UAAUb,cAAcE,YAAYO;IAC1C,MAAMK,WAAWjB,cAAcgB;IAC/B,MAAME,iBAAiBpB,UAAUO;IACjC,MAAMc,MAAMF,SAASG,WAAW,CAACF;IACjC,IAAIC,QAAQ,CAAC,GAAG;QACd,MAAM,IAAIE,MAAM,CAAC,2CAA2C,EAAEhB,WAAW,CAAC,CAAC;IAC7E;IACA,OAAOY,SAASK,KAAK,CAAC,GAAGH,MAAMD,eA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