@shopify/cli-kit 3.67.3 → 3.68.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.
Files changed (38) hide show
  1. package/dist/private/node/analytics.d.ts +1 -0
  2. package/dist/private/node/analytics.js +2 -0
  3. package/dist/private/node/analytics.js.map +1 -1
  4. package/dist/private/node/api/rest.d.ts +1 -0
  5. package/dist/private/node/api/rest.js +1 -1
  6. package/dist/private/node/api/rest.js.map +1 -1
  7. package/dist/private/node/session/exchange.d.ts +4 -1
  8. package/dist/private/node/session/exchange.js +7 -1
  9. package/dist/private/node/session/exchange.js.map +1 -1
  10. package/dist/private/node/session.d.ts +29 -0
  11. package/dist/private/node/session.js +65 -1
  12. package/dist/private/node/session.js.map +1 -1
  13. package/dist/public/common/url.d.ts +7 -0
  14. package/dist/public/common/url.js +15 -0
  15. package/dist/public/common/url.js.map +1 -1
  16. package/dist/public/common/version.d.ts +1 -1
  17. package/dist/public/common/version.js +1 -1
  18. package/dist/public/common/version.js.map +1 -1
  19. package/dist/public/node/analytics.js +2 -0
  20. package/dist/public/node/analytics.js.map +1 -1
  21. package/dist/public/node/context/local.d.ts +7 -0
  22. package/dist/public/node/context/local.js +9 -0
  23. package/dist/public/node/context/local.js.map +1 -1
  24. package/dist/public/node/fs.d.ts +1 -0
  25. package/dist/public/node/fs.js +1 -1
  26. package/dist/public/node/fs.js.map +1 -1
  27. package/dist/public/node/local-storage.d.ts +1 -1
  28. package/dist/public/node/local-storage.js.map +1 -1
  29. package/dist/public/node/monorail.d.ts +3 -1
  30. package/dist/public/node/monorail.js +1 -1
  31. package/dist/public/node/monorail.js.map +1 -1
  32. package/dist/public/node/node-package-manager.d.ts +13 -0
  33. package/dist/public/node/node-package-manager.js +25 -0
  34. package/dist/public/node/node-package-manager.js.map +1 -1
  35. package/dist/public/node/session.js +17 -5
  36. package/dist/public/node/session.js.map +1 -1
  37. package/dist/tsconfig.tsbuildinfo +1 -1
  38. package/package.json +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AAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AAC/E,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,0BAA0B,CAAC,IAAY;IACpD,WAAW,CAAC,aAAa,CAAA,8CAA8C,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC/F,OAAO,YAAY,CAAC,2BAA2B,CAAC,CAAC,GAAG,EAAE;QACpD,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;IAC5B,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,SAAiB,EAAE,WAAwB;IAChF,WAAW,CAAC,aAAa,CAAA,wDAAwD,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAClH,MAAM,WAAW,GAAG,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;IACvD,MAAM,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AACpE,CAAC","sourcesContent":["import {AbortError, BugError} from './error.js'\nimport {AbortController, AbortSignal} from './abort.js'\nimport {captureOutput, exec} from './system.js'\nimport {fileExists, readFile, writeFile, findPathUp, glob} from './fs.js'\nimport {dirname, joinPath} from './path.js'\nimport {runWithTimer} from './metadata.js'\nimport {outputToken, outputContent, outputDebug} from '../../public/node/output.js'\nimport {PackageVersionKey, cacheRetrieve, cacheRetrieveOrRepopulate} from '../../private/node/conf-store.js'\nimport latestVersion from 'latest-version'\nimport {SemVer, satisfies as semverSatisfies} from 'semver'\nimport type {Writable} from 'stream'\nimport type {ExecOptions} from './system.js'\n\n/** The name of the Yarn lock file */\nexport const yarnLockfile = 'yarn.lock'\n\n/** The name of the npm lock file */\nexport const npmLockfile = 'package-lock.json'\n\n/** The name of the pnpm lock file */\nexport const pnpmLockfile = 'pnpm-lock.yaml'\n\n/** The name of the bun lock file */\nexport const bunLockfile = 'bun.lockb'\n\n/** The name of the pnpm workspace file */\nexport const pnpmWorkspaceFile = 'pnpm-workspace.yaml'\n\n/** An array containing the lockfiles from all the package managers */\nexport const lockfiles: Lockfile[] = [yarnLockfile, pnpmLockfile, npmLockfile, bunLockfile]\nexport type Lockfile = 'yarn.lock' | 'package-lock.json' | 'pnpm-lock.yaml' | 'bun.lockb'\n\n/**\n * A union type that represents the type of dependencies in the package.json\n * - dev: devDependencies\n * - prod: dependencies\n * - peer: peerDependencies\n */\nexport type DependencyType = 'dev' | 'prod' | 'peer'\n\n/**\n * A union that represents the package managers available.\n */\nexport const packageManager = ['yarn', 'npm', 'pnpm', 'bun', 'unknown'] as const\nexport type PackageManager = (typeof packageManager)[number]\n\n/**\n * Returns an abort error that's thrown when the package manager can't be determined.\n * @returns An abort error.\n */\nexport class UnknownPackageManagerError extends AbortError {\n constructor() {\n super('Unknown package manager')\n }\n}\n\n/**\n * Returns an abort error that's thrown when a directory that's expected to have\n * a package.json doesn't have it.\n * @param directory - The path to the directory that should contain a package.json\n * @returns An abort error.\n */\nexport class PackageJsonNotFoundError extends AbortError {\n constructor(directory: string) {\n super(outputContent`The directory ${outputToken.path(directory)} doesn't have a package.json.`)\n }\n}\n\n/**\n * Returns a bug error that's thrown when the lookup of the package.json traversing the directory\n * hierarchy up can't find a package.json\n * @param directory - The directory from which the traverse has been done\n * @returns An abort error.\n */\nexport class FindUpAndReadPackageJsonNotFoundError extends BugError {\n constructor(directory: string) {\n super(outputContent`Couldn't find a a package.json traversing directories from ${outputToken.path(directory)}`)\n }\n}\n\n/**\n * Returns the dependency manager used to run the create workflow.\n * @param env - The environment variables of the process in which the CLI runs.\n * @returns The dependency manager\n */\nexport function packageManagerFromUserAgent(env = process.env): PackageManager {\n if (env.npm_config_user_agent?.includes('yarn')) {\n return 'yarn'\n } else if (env.npm_config_user_agent?.includes('pnpm')) {\n return 'pnpm'\n } else if (env.npm_config_user_agent?.includes('bun')) {\n return 'bun'\n } else if (env.npm_config_user_agent?.includes('npm')) {\n return 'npm'\n }\n return 'unknown'\n}\n\n/**\n * Returns the dependency manager used in a directory.\n * @param fromDirectory - The starting directory\n * @returns The dependency manager\n */\nexport async function getPackageManager(fromDirectory: string): Promise<PackageManager> {\n const directory = await captureOutput('npm', ['prefix'], {cwd: fromDirectory})\n outputDebug(outputContent`Obtaining the dependency manager in directory ${outputToken.path(directory)}...`)\n const packageJson = joinPath(directory, 'package.json')\n if (!(await fileExists(packageJson))) {\n return packageManagerFromUserAgent()\n }\n const yarnLockPath = joinPath(directory, yarnLockfile)\n const pnpmLockPath = joinPath(directory, pnpmLockfile)\n const bunLockPath = joinPath(directory, bunLockfile)\n if (await fileExists(yarnLockPath)) {\n return 'yarn'\n } else if (await fileExists(pnpmLockPath)) {\n return 'pnpm'\n } else if (await fileExists(bunLockPath)) {\n return 'bun'\n } else {\n return 'npm'\n }\n}\n\ninterface InstallNPMDependenciesRecursivelyOptions {\n /**\n * The dependency manager to use to install the dependencies.\n */\n packageManager: PackageManager\n /**\n * The directory from where we'll find package.json's recursively\n */\n directory: string\n\n /**\n * Specifies the maximum depth of the glob search.\n */\n deep?: number\n}\n\n/**\n * This function traverses down a directory tree to find directories containing a package.json\n * and installs the dependencies if needed. To know if it's needed, it uses the \"check\" command\n * provided by dependency managers.\n * @param options - Options to install dependencies recursively.\n */\nexport async function installNPMDependenciesRecursively(\n options: InstallNPMDependenciesRecursivelyOptions,\n): Promise<void> {\n const packageJsons = await glob(joinPath(options.directory, '**/package.json'), {\n ignore: [joinPath(options.directory, 'node_modules/**/package.json')],\n cwd: options.directory,\n onlyFiles: true,\n deep: options.deep,\n })\n const abortController = new AbortController()\n try {\n await Promise.all(\n packageJsons.map(async (packageJsonPath) => {\n const directory = dirname(packageJsonPath)\n await installNodeModules({\n directory,\n packageManager: options.packageManager,\n stdout: undefined,\n stderr: undefined,\n signal: abortController.signal,\n args: [],\n })\n }),\n )\n } catch (error) {\n abortController.abort()\n throw error\n }\n}\n\ninterface InstallNodeModulesOptions {\n directory: string\n args?: string[]\n packageManager: PackageManager\n stdout?: Writable\n stderr?: Writable\n signal?: AbortSignal\n}\n\nexport async function installNodeModules(options: InstallNodeModulesOptions): Promise<void> {\n const execOptions: ExecOptions = {\n cwd: options.directory,\n stdin: undefined,\n stdout: options.stdout,\n stderr: options.stderr,\n signal: options.signal,\n }\n let args = ['install']\n if (options.args) {\n args = args.concat(options.args)\n }\n await runWithTimer('cmd_all_timing_network_ms')(async () => {\n await exec(options.packageManager, args, execOptions)\n })\n}\n\n/**\n * Returns the name of the package configured in its package.json\n * @param packageJsonPath - Path to the package.json file\n * @returns A promise that resolves with the name.\n */\nexport async function getPackageName(packageJsonPath: string): Promise<string | undefined> {\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n return packageJsonContent.name\n}\n/**\n * Returns the version of the package configured in its package.json\n * @param packageJsonPath - Path to the package.json file\n * @returns A promise that resolves with the version.\n */\nexport async function getPackageVersion(packageJsonPath: string): Promise<string | undefined> {\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n return packageJsonContent.version\n}\n\n/**\n * Returns the list of production and dev dependencies of a package.json\n * @param packageJsonPath - Path to the package.json file\n * @returns A promise that resolves with the list of dependencies.\n */\nexport async function getDependencies(packageJsonPath: string): Promise<{[key: string]: string}> {\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n const dependencies: {[key: string]: string} = packageJsonContent.dependencies ?? {}\n const devDependencies: {[key: string]: string} = packageJsonContent.devDependencies ?? {}\n\n return {...dependencies, ...devDependencies}\n}\n\n/**\n * Returns true if the app uses workspaces, false otherwise.\n * @param packageJsonPath - Path to the package.json file\n * @param pnpmWorkspacePath - Path to the pnpm-workspace.yaml file\n * @returns A promise that resolves with true if the app uses workspaces, false otherwise.\n */\nexport async function usesWorkspaces(appDirectory: string): Promise<boolean> {\n const packageJsonPath = joinPath(appDirectory, 'package.json')\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n const pnpmWorkspacePath = joinPath(appDirectory, pnpmWorkspaceFile)\n return Boolean(packageJsonContent.workspaces) || fileExists(pnpmWorkspacePath)\n}\n\n/**\n * Given an NPM dependency, it checks if there's a more recent version, and if there is, it returns its value.\n * @param dependency - The dependency name (e.g. react)\n * @param currentVersion - The current version.\n * @param cacheExpiryInHours - If the last check was done more than this amount of hours ago, it will\n * refresh the cache. Defaults to always refreshing.\n * @returns A promise that resolves with a more recent version or undefined if there's no more recent version.\n */\nexport async function checkForNewVersion(\n dependency: string,\n currentVersion: string,\n {cacheExpiryInHours = 0} = {},\n): Promise<string | undefined> {\n const getLatestVersion = async () => {\n outputDebug(outputContent`Checking if there's a version of ${dependency} newer than ${currentVersion}`)\n return getLatestNPMPackageVersion(dependency)\n }\n\n const cacheKey: PackageVersionKey = `npm-package-${dependency}`\n let lastVersion\n try {\n lastVersion = await cacheRetrieveOrRepopulate(cacheKey, getLatestVersion, cacheExpiryInHours * 3600 * 1000)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n return undefined\n }\n\n if (lastVersion && new SemVer(currentVersion).compare(lastVersion) < 0) {\n return lastVersion\n } else {\n return undefined\n }\n}\n\n/**\n * Given an NPM dependency, it checks if there's a cached more recent version, and if there is, it returns its value.\n * @param dependency - The dependency name (e.g. react)\n * @param currentVersion - The current version.\n * @returns A more recent version or undefined if there's no more recent version.\n */\nexport function checkForCachedNewVersion(dependency: string, currentVersion: string): string | undefined {\n const cacheKey: PackageVersionKey = `npm-package-${dependency}`\n const lastVersion = cacheRetrieve(cacheKey)\n\n if (lastVersion && new SemVer(currentVersion).compare(lastVersion) < 0) {\n return lastVersion\n } else {\n return undefined\n }\n}\n\n/**\n * Utility function used to check whether a package version satisfies some requirements\n * @param version - The version to check\n * @param requirements - The requirements to check against, e.g. \"\\>=1.0.0\" - see https://www.npmjs.com/package/semver#ranges\n * @returns A boolean indicating whether the version satisfies the requirements\n */\nexport function versionSatisfies(version: string, requirements: string): boolean {\n return semverSatisfies(version, requirements)\n}\n\n/**\n * An interface that represents a package.json\n */\nexport interface PackageJson {\n /**\n * The name attribute of the package.json\n */\n name?: string\n\n /**\n * The author attribute of the package.json\n */\n author?: string\n\n /**\n * The version attribute of the package.json\n */\n version?: string\n\n /**\n * The scripts attribute of the package.json\n */\n scripts?: {[key: string]: string}\n\n /**\n * The dependencies attribute of the package.json\n */\n dependencies?: {[key: string]: string}\n\n /**\n * The devDependencies attribute of the package.json\n */\n devDependencies?: {[key: string]: string}\n\n /**\n * The peerDependencies attribute of the package.json\n */\n peerDependencies?: {[key: string]: string}\n\n /**\n * The optional oclif settings attribute of the package.json\n */\n oclif?: {\n plugins?: string[]\n }\n\n /**\n * The workspaces attribute of the package.json\n */\n workspaces?: string[]\n\n /**\n * The resolutions attribute of the package.json. Only useful when using yarn as package manager\n */\n resolutions?: {[key: string]: string}\n\n /**\n * The overrides attribute of the package.json. Only useful when using npm o npmn as package managers\n */\n overrides?: {[key: string]: string}\n\n /**\n * The prettier attribute of the package.json\n */\n prettier?: string\n\n /**\n * The private attribute of the package.json.\n * https://docs.npmjs.com/cli/v9/configuring-npm/package-json#private\n */\n private?: boolean\n}\n\n/**\n * Reads and parses a package.json\n * @param packageJsonPath - Path to the package.json\n * @returns An promise that resolves with an in-memory representation\n * of the package.json or rejects with an error if the file is not found or the content is\n * not decodable.\n */\nexport async function readAndParsePackageJson(packageJsonPath: string): Promise<PackageJson> {\n if (!(await fileExists(packageJsonPath))) {\n throw new PackageJsonNotFoundError(dirname(packageJsonPath))\n }\n return JSON.parse(await readFile(packageJsonPath))\n}\n\ninterface AddNPMDependenciesIfNeededOptions {\n /** How dependencies should be added */\n type: DependencyType\n\n /** The dependency manager to use to add dependencies */\n packageManager: PackageManager\n\n /** The directory that contains the package.json where dependencies will be added */\n directory: string\n\n /** Standard output coming from the underlying installation process */\n stdout?: Writable\n\n /** Standard error coming from the underlying installation process */\n stderr?: Writable\n\n /** Abort signal to stop the process */\n signal?: AbortSignal\n\n /** Whether to add the dependencies to the root package.json or to the package.json of the directory */\n addToRootDirectory?: boolean\n}\n\n/**\n * An interface that represents a dependency name with its version\n */\nexport interface DependencyVersion {\n /**\n * The name of the NPM dependency as it's reflected in the package.json:\n *\n * @example\n * In the example below name would be \"react\"\n * ```\n * {\n * \"react\": \"1.2.3\"\n * }\n * ```\n */\n name: string\n\n /**\n * The version of the NPM dependency as it's reflected in the package.json:\n *\n * @example\n * In the example below version would be \"1.2.3\"\n * ```\n * {\n * \"react\": \"1.2.3\"\n * }\n * ```\n */\n version: string | undefined\n}\n\n/**\n * Adds dependencies to a Node project (i.e. a project that has a package.json)\n * @param dependencies - List of dependencies to be added.\n * @param options - Options for adding dependencies.\n */\nexport async function addNPMDependenciesIfNeeded(\n dependencies: DependencyVersion[],\n options: AddNPMDependenciesIfNeededOptions,\n): Promise<void> {\n outputDebug(outputContent`Adding the following dependencies if needed:\n${outputToken.json(dependencies)}\nWith options:\n${outputToken.json(options)}\n `)\n const packageJsonPath = joinPath(options.directory, 'package.json')\n if (!(await fileExists(packageJsonPath))) {\n throw new PackageJsonNotFoundError(options.directory)\n }\n const existingDependencies = Object.keys(await getDependencies(packageJsonPath))\n const dependenciesToAdd = dependencies.filter((dep) => {\n return !existingDependencies.includes(dep.name)\n })\n if (dependenciesToAdd.length === 0) {\n return\n }\n await addNPMDependencies(dependenciesToAdd, options)\n}\n\nexport async function addNPMDependencies(\n dependencies: DependencyVersion[],\n options: AddNPMDependenciesIfNeededOptions,\n): Promise<void> {\n const dependenciesWithVersion = dependencies.map((dep) => {\n return dep.version ? `${dep.name}@${dep.version}` : dep.name\n })\n options.stdout?.write(`Installing ${[dependenciesWithVersion].join(' ')} with ${options.packageManager}`)\n switch (options.packageManager) {\n case 'npm':\n // npm isn't too smart when resolving the dependency tree. For example, admin ui extensions include react as\n // a peer dependency, but npm can't figure out the relationship and fails. Installing dependencies one by one\n // makes the task easier and npm can then proceed.\n for (const dep of dependenciesWithVersion) {\n // eslint-disable-next-line no-await-in-loop\n await installDependencies(options, argumentsToAddDependenciesWithNPM(dep, options.type))\n }\n break\n case 'yarn':\n await installDependencies(\n options,\n argumentsToAddDependenciesWithYarn(dependenciesWithVersion, options.type, Boolean(options.addToRootDirectory)),\n )\n break\n case 'pnpm':\n await installDependencies(\n options,\n argumentsToAddDependenciesWithPNPM(dependenciesWithVersion, options.type, Boolean(options.addToRootDirectory)),\n )\n break\n case 'bun':\n await installDependencies(options, argumentsToAddDependenciesWithBun(dependenciesWithVersion, options.type))\n await installDependencies(options, ['install'])\n break\n case 'unknown':\n throw new UnknownPackageManagerError()\n }\n}\n\nasync function installDependencies(options: AddNPMDependenciesIfNeededOptions, args: string[]) {\n return runWithTimer('cmd_all_timing_network_ms')(async () => {\n return exec(options.packageManager, args, {\n cwd: options.directory,\n stdout: options.stdout,\n stderr: options.stderr,\n signal: options.signal,\n })\n })\n}\n\nexport async function addNPMDependenciesWithoutVersionIfNeeded(\n dependencies: string[],\n options: AddNPMDependenciesIfNeededOptions,\n): Promise<void> {\n await addNPMDependenciesIfNeeded(\n dependencies.map((dependency) => {\n return {name: dependency, version: undefined}\n }),\n options,\n )\n}\n\n/**\n * Returns the arguments to add dependencies using NPM.\n * @param dependencies - The list of dependencies to add\n * @param type - The dependency type.\n * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithNPM(dependency: string, type: DependencyType): string[] {\n let command = ['install']\n command = command.concat(dependency)\n switch (type) {\n case 'dev':\n command.push('--save-dev')\n break\n case 'peer':\n command.push('--save-peer')\n break\n case 'prod':\n command.push('--save-prod')\n break\n }\n // NPM adds ^ to the installed version by default. We want to install exact versions unless specified otherwise.\n if (dependency.match(/@\\d/g)) {\n command.push('--save-exact')\n }\n return command\n}\n\n/**\n * Returns the arguments to add dependencies using Yarn.\n * @param dependencies - The list of dependencies to add\n * @param type - The dependency type.\n * @param addAtRoot - Force to install the dependencies in the workspace root (optional, default = false)\n * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithYarn(dependencies: string[], type: DependencyType, addAtRoot = false): string[] {\n let command = ['add']\n\n if (addAtRoot) {\n command.push('-W')\n }\n\n command = command.concat(dependencies)\n switch (type) {\n case 'dev':\n command.push('--dev')\n break\n case 'peer':\n command.push('--peer')\n break\n case 'prod':\n command.push('--prod')\n break\n }\n return command\n}\n\n/**\n * Returns the arguments to add dependencies using PNPM.\n * @param dependencies - The list of dependencies to add\n * @param type - The dependency type.\n * @param addAtRoot - Force to install the dependencies in the workspace root (optional, default = false)\n * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithPNPM(dependencies: string[], type: DependencyType, addAtRoot = false): string[] {\n let command = ['add']\n\n if (addAtRoot) {\n command.push('-w')\n }\n\n command = command.concat(dependencies)\n\n switch (type) {\n case 'dev':\n command.push('--save-dev')\n break\n case 'peer':\n command.push('--save-peer')\n break\n case 'prod':\n command.push('--save-prod')\n break\n }\n return command\n}\n\n/**\n * Returns the arguments to add dependencies using Bun.\n * @param dependencies - The list of dependencies to add\n * @param type - The dependency type.\n * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithBun(dependencies: string[], type: DependencyType): string[] {\n let command = ['add']\n\n command = command.concat(dependencies)\n\n switch (type) {\n case 'dev':\n command.push('--development')\n break\n case 'peer':\n command.push('--optional')\n break\n case 'prod':\n break\n }\n return command\n}\n\n/**\n * Given a directory it traverses the directory up looking for a package.json and if found, it reads it\n * decodes the JSON, and returns its content as a Javascript object.\n * @param options - The directory from which traverse up.\n * @returns If found, the promise resolves with the path to the\n * package.json and its content. If not found, it throws a FindUpAndReadPackageJsonNotFoundError error.\n */\nexport async function findUpAndReadPackageJson(fromDirectory: string): Promise<{path: string; content: PackageJson}> {\n const packageJsonPath = await findPathUp('package.json', {cwd: fromDirectory, type: 'file'})\n if (packageJsonPath) {\n const packageJson = JSON.parse(await readFile(packageJsonPath))\n return {path: packageJsonPath, content: packageJson}\n } else {\n throw new FindUpAndReadPackageJsonNotFoundError(fromDirectory)\n }\n}\n\nexport async function addResolutionOrOverride(directory: string, dependencies: {[key: string]: string}): Promise<void> {\n const packageManager = await getPackageManager(directory)\n const packageJsonPath = joinPath(directory, 'package.json')\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n\n if (packageManager === 'yarn') {\n packageJsonContent.resolutions = packageJsonContent.resolutions\n ? {...packageJsonContent.resolutions, ...dependencies}\n : dependencies\n }\n if (packageManager === 'npm' || packageManager === 'pnpm' || packageManager === 'bun') {\n packageJsonContent.overrides = packageJsonContent.overrides\n ? {...packageJsonContent.overrides, ...dependencies}\n : dependencies\n }\n\n await writeFile(packageJsonPath, JSON.stringify(packageJsonContent, null, 2))\n}\n\n/**\n * Returns the latest available version of an NPM package.\n * @param name - The name of the NPM package.\n * @returns A promise to get the latest available version of a package.\n */\nasync function getLatestNPMPackageVersion(name: string) {\n outputDebug(outputContent`Getting the latest version of NPM package: ${outputToken.raw(name)}`)\n return runWithTimer('cmd_all_timing_network_ms')(() => {\n return latestVersion(name)\n })\n}\n\n/**\n * Writes the package.json file to the given directory.\n *\n * @param directory - Directory where the package.json file will be written.\n * @param packageJSON - Package.json file to write.\n */\nexport async function writePackageJSON(directory: string, packageJSON: PackageJson): Promise<void> {\n outputDebug(outputContent`JSON-encoding and writing content to package.json at ${outputToken.path(directory)}...`)\n const packagePath = joinPath(directory, 'package.json')\n await writeFile(packagePath, JSON.stringify(packageJSON, null, 2))\n}\n"]}
1
+ {"version":3,"file":"node-package-manager.js","sourceRoot":"","sources":["../../../src/public/node/node-package-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAC,eAAe,EAAc,MAAM,YAAY,CAAA;AACvD,OAAO,EAAC,aAAa,EAAE,IAAI,EAAC,MAAM,aAAa,CAAA;AAC/C,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,IAAI,EAAC,MAAM,SAAS,CAAA;AACzE,OAAO,EAAC,OAAO,E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;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,SAAiB,EAAE,WAAwB;IAChF,WAAW,CAAC,aAAa,CAAA,wDAAwD,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAClH,MAAM,WAAW,GAAG,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;IACvD,MAAM,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AACpE,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,mBAAmB,CAAC,qBAAyC,EAAE,GAAG,GAAG,OAAO,CAAC,GAAG;IAC9F,IAAI,qBAAqB,IAAI,cAAc,CAAC,QAAQ,CAAC,qBAAuC,CAAC,EAAE;QAC7F,OAAO,qBAAuC,CAAA;KAC/C;IACD,MAAM,kBAAkB,GAAG,2BAA2B,CAAC,GAAG,CAAC,CAAA;IAC3D,IAAI,kBAAkB,KAAK,SAAS;QAAE,OAAO,kBAAkB,CAAA;IAE/D,MAAM,oBAAoB,GAAG,+BAA+B,EAAE,CAAA;IAC9D,IAAI,oBAAoB,KAAK,SAAS;QAAE,OAAO,oBAAoB,CAAA;IAEnE,OAAO,KAAK,CAAA;AACd,CAAC","sourcesContent":["import {AbortError, BugError} from './error.js'\nimport {AbortController, AbortSignal} from './abort.js'\nimport {captureOutput, exec} from './system.js'\nimport {fileExists, readFile, writeFile, findPathUp, glob} from './fs.js'\nimport {dirname, joinPath} from './path.js'\nimport {runWithTimer} from './metadata.js'\nimport {inferPackageManagerForGlobalCLI} from './is-global.js'\nimport {outputToken, outputContent, outputDebug} from '../../public/node/output.js'\nimport {PackageVersionKey, cacheRetrieve, cacheRetrieveOrRepopulate} from '../../private/node/conf-store.js'\nimport latestVersion from 'latest-version'\nimport {SemVer, satisfies as semverSatisfies} from 'semver'\nimport type {Writable} from 'stream'\nimport type {ExecOptions} from './system.js'\n\n/** The name of the Yarn lock file */\nexport const yarnLockfile = 'yarn.lock'\n\n/** The name of the npm lock file */\nexport const npmLockfile = 'package-lock.json'\n\n/** The name of the pnpm lock file */\nexport const pnpmLockfile = 'pnpm-lock.yaml'\n\n/** The name of the bun lock file */\nexport const bunLockfile = 'bun.lockb'\n\n/** The name of the pnpm workspace file */\nexport const pnpmWorkspaceFile = 'pnpm-workspace.yaml'\n\n/** An array containing the lockfiles from all the package managers */\nexport const lockfiles: Lockfile[] = [yarnLockfile, pnpmLockfile, npmLockfile, bunLockfile]\nexport type Lockfile = 'yarn.lock' | 'package-lock.json' | 'pnpm-lock.yaml' | 'bun.lockb'\n\n/**\n * A union type that represents the type of dependencies in the package.json\n * - dev: devDependencies\n * - prod: dependencies\n * - peer: peerDependencies\n */\nexport type DependencyType = 'dev' | 'prod' | 'peer'\n\n/**\n * A union that represents the package managers available.\n */\nexport const packageManager = ['yarn', 'npm', 'pnpm', 'bun', 'unknown'] as const\nexport type PackageManager = (typeof packageManager)[number]\n\n/**\n * Returns an abort error that's thrown when the package manager can't be determined.\n * @returns An abort error.\n */\nexport class UnknownPackageManagerError extends AbortError {\n constructor() {\n super('Unknown package manager')\n }\n}\n\n/**\n * Returns an abort error that's thrown when a directory that's expected to have\n * a package.json doesn't have it.\n * @param directory - The path to the directory that should contain a package.json\n * @returns An abort error.\n */\nexport class PackageJsonNotFoundError extends AbortError {\n constructor(directory: string) {\n super(outputContent`The directory ${outputToken.path(directory)} doesn't have a package.json.`)\n }\n}\n\n/**\n * Returns a bug error that's thrown when the lookup of the package.json traversing the directory\n * hierarchy up can't find a package.json\n * @param directory - The directory from which the traverse has been done\n * @returns An abort error.\n */\nexport class FindUpAndReadPackageJsonNotFoundError extends BugError {\n constructor(directory: string) {\n super(outputContent`Couldn't find a a package.json traversing directories from ${outputToken.path(directory)}`)\n }\n}\n\n/**\n * Returns the dependency manager used to run the create workflow.\n * @param env - The environment variables of the process in which the CLI runs.\n * @returns The dependency manager\n */\nexport function packageManagerFromUserAgent(env = process.env): PackageManager {\n if (env.npm_config_user_agent?.includes('yarn')) {\n return 'yarn'\n } else if (env.npm_config_user_agent?.includes('pnpm')) {\n return 'pnpm'\n } else if (env.npm_config_user_agent?.includes('bun')) {\n return 'bun'\n } else if (env.npm_config_user_agent?.includes('npm')) {\n return 'npm'\n }\n return 'unknown'\n}\n\n/**\n * Returns the dependency manager used in a directory.\n * @param fromDirectory - The starting directory\n * @returns The dependency manager\n */\nexport async function getPackageManager(fromDirectory: string): Promise<PackageManager> {\n const directory = await captureOutput('npm', ['prefix'], {cwd: fromDirectory})\n outputDebug(outputContent`Obtaining the dependency manager in directory ${outputToken.path(directory)}...`)\n const packageJson = joinPath(directory, 'package.json')\n if (!(await fileExists(packageJson))) {\n return packageManagerFromUserAgent()\n }\n const yarnLockPath = joinPath(directory, yarnLockfile)\n const pnpmLockPath = joinPath(directory, pnpmLockfile)\n const bunLockPath = joinPath(directory, bunLockfile)\n if (await fileExists(yarnLockPath)) {\n return 'yarn'\n } else if (await fileExists(pnpmLockPath)) {\n return 'pnpm'\n } else if (await fileExists(bunLockPath)) {\n return 'bun'\n } else {\n return 'npm'\n }\n}\n\ninterface InstallNPMDependenciesRecursivelyOptions {\n /**\n * The dependency manager to use to install the dependencies.\n */\n packageManager: PackageManager\n /**\n * The directory from where we'll find package.json's recursively\n */\n directory: string\n\n /**\n * Specifies the maximum depth of the glob search.\n */\n deep?: number\n}\n\n/**\n * This function traverses down a directory tree to find directories containing a package.json\n * and installs the dependencies if needed. To know if it's needed, it uses the \"check\" command\n * provided by dependency managers.\n * @param options - Options to install dependencies recursively.\n */\nexport async function installNPMDependenciesRecursively(\n options: InstallNPMDependenciesRecursivelyOptions,\n): Promise<void> {\n const packageJsons = await glob(joinPath(options.directory, '**/package.json'), {\n ignore: [joinPath(options.directory, 'node_modules/**/package.json')],\n cwd: options.directory,\n onlyFiles: true,\n deep: options.deep,\n })\n const abortController = new AbortController()\n try {\n await Promise.all(\n packageJsons.map(async (packageJsonPath) => {\n const directory = dirname(packageJsonPath)\n await installNodeModules({\n directory,\n packageManager: options.packageManager,\n stdout: undefined,\n stderr: undefined,\n signal: abortController.signal,\n args: [],\n })\n }),\n )\n } catch (error) {\n abortController.abort()\n throw error\n }\n}\n\ninterface InstallNodeModulesOptions {\n directory: string\n args?: string[]\n packageManager: PackageManager\n stdout?: Writable\n stderr?: Writable\n signal?: AbortSignal\n}\n\nexport async function installNodeModules(options: InstallNodeModulesOptions): Promise<void> {\n const execOptions: ExecOptions = {\n cwd: options.directory,\n stdin: undefined,\n stdout: options.stdout,\n stderr: options.stderr,\n signal: options.signal,\n }\n let args = ['install']\n if (options.args) {\n args = args.concat(options.args)\n }\n await runWithTimer('cmd_all_timing_network_ms')(async () => {\n await exec(options.packageManager, args, execOptions)\n })\n}\n\n/**\n * Returns the name of the package configured in its package.json\n * @param packageJsonPath - Path to the package.json file\n * @returns A promise that resolves with the name.\n */\nexport async function getPackageName(packageJsonPath: string): Promise<string | undefined> {\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n return packageJsonContent.name\n}\n/**\n * Returns the version of the package configured in its package.json\n * @param packageJsonPath - Path to the package.json file\n * @returns A promise that resolves with the version.\n */\nexport async function getPackageVersion(packageJsonPath: string): Promise<string | undefined> {\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n return packageJsonContent.version\n}\n\n/**\n * Returns the list of production and dev dependencies of a package.json\n * @param packageJsonPath - Path to the package.json file\n * @returns A promise that resolves with the list of dependencies.\n */\nexport async function getDependencies(packageJsonPath: string): Promise<{[key: string]: string}> {\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n const dependencies: {[key: string]: string} = packageJsonContent.dependencies ?? {}\n const devDependencies: {[key: string]: string} = packageJsonContent.devDependencies ?? {}\n\n return {...dependencies, ...devDependencies}\n}\n\n/**\n * Returns true if the app uses workspaces, false otherwise.\n * @param packageJsonPath - Path to the package.json file\n * @param pnpmWorkspacePath - Path to the pnpm-workspace.yaml file\n * @returns A promise that resolves with true if the app uses workspaces, false otherwise.\n */\nexport async function usesWorkspaces(appDirectory: string): Promise<boolean> {\n const packageJsonPath = joinPath(appDirectory, 'package.json')\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n const pnpmWorkspacePath = joinPath(appDirectory, pnpmWorkspaceFile)\n return Boolean(packageJsonContent.workspaces) || fileExists(pnpmWorkspacePath)\n}\n\n/**\n * Given an NPM dependency, it checks if there's a more recent version, and if there is, it returns its value.\n * @param dependency - The dependency name (e.g. react)\n * @param currentVersion - The current version.\n * @param cacheExpiryInHours - If the last check was done more than this amount of hours ago, it will\n * refresh the cache. Defaults to always refreshing.\n * @returns A promise that resolves with a more recent version or undefined if there's no more recent version.\n */\nexport async function checkForNewVersion(\n dependency: string,\n currentVersion: string,\n {cacheExpiryInHours = 0} = {},\n): Promise<string | undefined> {\n const getLatestVersion = async () => {\n outputDebug(outputContent`Checking if there's a version of ${dependency} newer than ${currentVersion}`)\n return getLatestNPMPackageVersion(dependency)\n }\n\n const cacheKey: PackageVersionKey = `npm-package-${dependency}`\n let lastVersion\n try {\n lastVersion = await cacheRetrieveOrRepopulate(cacheKey, getLatestVersion, cacheExpiryInHours * 3600 * 1000)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n return undefined\n }\n\n if (lastVersion && new SemVer(currentVersion).compare(lastVersion) < 0) {\n return lastVersion\n } else {\n return undefined\n }\n}\n\n/**\n * Given an NPM dependency, it checks if there's a cached more recent version, and if there is, it returns its value.\n * @param dependency - The dependency name (e.g. react)\n * @param currentVersion - The current version.\n * @returns A more recent version or undefined if there's no more recent version.\n */\nexport function checkForCachedNewVersion(dependency: string, currentVersion: string): string | undefined {\n const cacheKey: PackageVersionKey = `npm-package-${dependency}`\n const lastVersion = cacheRetrieve(cacheKey)\n\n if (lastVersion && new SemVer(currentVersion).compare(lastVersion) < 0) {\n return lastVersion\n } else {\n return undefined\n }\n}\n\n/**\n * Utility function used to check whether a package version satisfies some requirements\n * @param version - The version to check\n * @param requirements - The requirements to check against, e.g. \"\\>=1.0.0\" - see https://www.npmjs.com/package/semver#ranges\n * @returns A boolean indicating whether the version satisfies the requirements\n */\nexport function versionSatisfies(version: string, requirements: string): boolean {\n return semverSatisfies(version, requirements)\n}\n\n/**\n * An interface that represents a package.json\n */\nexport interface PackageJson {\n /**\n * The name attribute of the package.json\n */\n name?: string\n\n /**\n * The author attribute of the package.json\n */\n author?: string\n\n /**\n * The version attribute of the package.json\n */\n version?: string\n\n /**\n * The scripts attribute of the package.json\n */\n scripts?: {[key: string]: string}\n\n /**\n * The dependencies attribute of the package.json\n */\n dependencies?: {[key: string]: string}\n\n /**\n * The devDependencies attribute of the package.json\n */\n devDependencies?: {[key: string]: string}\n\n /**\n * The peerDependencies attribute of the package.json\n */\n peerDependencies?: {[key: string]: string}\n\n /**\n * The optional oclif settings attribute of the package.json\n */\n oclif?: {\n plugins?: string[]\n }\n\n /**\n * The workspaces attribute of the package.json\n */\n workspaces?: string[]\n\n /**\n * The resolutions attribute of the package.json. Only useful when using yarn as package manager\n */\n resolutions?: {[key: string]: string}\n\n /**\n * The overrides attribute of the package.json. Only useful when using npm o npmn as package managers\n */\n overrides?: {[key: string]: string}\n\n /**\n * The prettier attribute of the package.json\n */\n prettier?: string\n\n /**\n * The private attribute of the package.json.\n * https://docs.npmjs.com/cli/v9/configuring-npm/package-json#private\n */\n private?: boolean\n}\n\n/**\n * Reads and parses a package.json\n * @param packageJsonPath - Path to the package.json\n * @returns An promise that resolves with an in-memory representation\n * of the package.json or rejects with an error if the file is not found or the content is\n * not decodable.\n */\nexport async function readAndParsePackageJson(packageJsonPath: string): Promise<PackageJson> {\n if (!(await fileExists(packageJsonPath))) {\n throw new PackageJsonNotFoundError(dirname(packageJsonPath))\n }\n return JSON.parse(await readFile(packageJsonPath))\n}\n\ninterface AddNPMDependenciesIfNeededOptions {\n /** How dependencies should be added */\n type: DependencyType\n\n /** The dependency manager to use to add dependencies */\n packageManager: PackageManager\n\n /** The directory that contains the package.json where dependencies will be added */\n directory: string\n\n /** Standard output coming from the underlying installation process */\n stdout?: Writable\n\n /** Standard error coming from the underlying installation process */\n stderr?: Writable\n\n /** Abort signal to stop the process */\n signal?: AbortSignal\n\n /** Whether to add the dependencies to the root package.json or to the package.json of the directory */\n addToRootDirectory?: boolean\n}\n\n/**\n * An interface that represents a dependency name with its version\n */\nexport interface DependencyVersion {\n /**\n * The name of the NPM dependency as it's reflected in the package.json:\n *\n * @example\n * In the example below name would be \"react\"\n * ```\n * {\n * \"react\": \"1.2.3\"\n * }\n * ```\n */\n name: string\n\n /**\n * The version of the NPM dependency as it's reflected in the package.json:\n *\n * @example\n * In the example below version would be \"1.2.3\"\n * ```\n * {\n * \"react\": \"1.2.3\"\n * }\n * ```\n */\n version: string | undefined\n}\n\n/**\n * Adds dependencies to a Node project (i.e. a project that has a package.json)\n * @param dependencies - List of dependencies to be added.\n * @param options - Options for adding dependencies.\n */\nexport async function addNPMDependenciesIfNeeded(\n dependencies: DependencyVersion[],\n options: AddNPMDependenciesIfNeededOptions,\n): Promise<void> {\n outputDebug(outputContent`Adding the following dependencies if needed:\n${outputToken.json(dependencies)}\nWith options:\n${outputToken.json(options)}\n `)\n const packageJsonPath = joinPath(options.directory, 'package.json')\n if (!(await fileExists(packageJsonPath))) {\n throw new PackageJsonNotFoundError(options.directory)\n }\n const existingDependencies = Object.keys(await getDependencies(packageJsonPath))\n const dependenciesToAdd = dependencies.filter((dep) => {\n return !existingDependencies.includes(dep.name)\n })\n if (dependenciesToAdd.length === 0) {\n return\n }\n await addNPMDependencies(dependenciesToAdd, options)\n}\n\nexport async function addNPMDependencies(\n dependencies: DependencyVersion[],\n options: AddNPMDependenciesIfNeededOptions,\n): Promise<void> {\n const dependenciesWithVersion = dependencies.map((dep) => {\n return dep.version ? `${dep.name}@${dep.version}` : dep.name\n })\n options.stdout?.write(`Installing ${[dependenciesWithVersion].join(' ')} with ${options.packageManager}`)\n switch (options.packageManager) {\n case 'npm':\n // npm isn't too smart when resolving the dependency tree. For example, admin ui extensions include react as\n // a peer dependency, but npm can't figure out the relationship and fails. Installing dependencies one by one\n // makes the task easier and npm can then proceed.\n for (const dep of dependenciesWithVersion) {\n // eslint-disable-next-line no-await-in-loop\n await installDependencies(options, argumentsToAddDependenciesWithNPM(dep, options.type))\n }\n break\n case 'yarn':\n await installDependencies(\n options,\n argumentsToAddDependenciesWithYarn(dependenciesWithVersion, options.type, Boolean(options.addToRootDirectory)),\n )\n break\n case 'pnpm':\n await installDependencies(\n options,\n argumentsToAddDependenciesWithPNPM(dependenciesWithVersion, options.type, Boolean(options.addToRootDirectory)),\n )\n break\n case 'bun':\n await installDependencies(options, argumentsToAddDependenciesWithBun(dependenciesWithVersion, options.type))\n await installDependencies(options, ['install'])\n break\n case 'unknown':\n throw new UnknownPackageManagerError()\n }\n}\n\nasync function installDependencies(options: AddNPMDependenciesIfNeededOptions, args: string[]) {\n return runWithTimer('cmd_all_timing_network_ms')(async () => {\n return exec(options.packageManager, args, {\n cwd: options.directory,\n stdout: options.stdout,\n stderr: options.stderr,\n signal: options.signal,\n })\n })\n}\n\nexport async function addNPMDependenciesWithoutVersionIfNeeded(\n dependencies: string[],\n options: AddNPMDependenciesIfNeededOptions,\n): Promise<void> {\n await addNPMDependenciesIfNeeded(\n dependencies.map((dependency) => {\n return {name: dependency, version: undefined}\n }),\n options,\n )\n}\n\n/**\n * Returns the arguments to add dependencies using NPM.\n * @param dependencies - The list of dependencies to add\n * @param type - The dependency type.\n * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithNPM(dependency: string, type: DependencyType): string[] {\n let command = ['install']\n command = command.concat(dependency)\n switch (type) {\n case 'dev':\n command.push('--save-dev')\n break\n case 'peer':\n command.push('--save-peer')\n break\n case 'prod':\n command.push('--save-prod')\n break\n }\n // NPM adds ^ to the installed version by default. We want to install exact versions unless specified otherwise.\n if (dependency.match(/@\\d/g)) {\n command.push('--save-exact')\n }\n return command\n}\n\n/**\n * Returns the arguments to add dependencies using Yarn.\n * @param dependencies - The list of dependencies to add\n * @param type - The dependency type.\n * @param addAtRoot - Force to install the dependencies in the workspace root (optional, default = false)\n * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithYarn(dependencies: string[], type: DependencyType, addAtRoot = false): string[] {\n let command = ['add']\n\n if (addAtRoot) {\n command.push('-W')\n }\n\n command = command.concat(dependencies)\n switch (type) {\n case 'dev':\n command.push('--dev')\n break\n case 'peer':\n command.push('--peer')\n break\n case 'prod':\n command.push('--prod')\n break\n }\n return command\n}\n\n/**\n * Returns the arguments to add dependencies using PNPM.\n * @param dependencies - The list of dependencies to add\n * @param type - The dependency type.\n * @param addAtRoot - Force to install the dependencies in the workspace root (optional, default = false)\n * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithPNPM(dependencies: string[], type: DependencyType, addAtRoot = false): string[] {\n let command = ['add']\n\n if (addAtRoot) {\n command.push('-w')\n }\n\n command = command.concat(dependencies)\n\n switch (type) {\n case 'dev':\n command.push('--save-dev')\n break\n case 'peer':\n command.push('--save-peer')\n break\n case 'prod':\n command.push('--save-prod')\n break\n }\n return command\n}\n\n/**\n * Returns the arguments to add dependencies using Bun.\n * @param dependencies - The list of dependencies to add\n * @param type - The dependency type.\n * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithBun(dependencies: string[], type: DependencyType): string[] {\n let command = ['add']\n\n command = command.concat(dependencies)\n\n switch (type) {\n case 'dev':\n command.push('--development')\n break\n case 'peer':\n command.push('--optional')\n break\n case 'prod':\n break\n }\n return command\n}\n\n/**\n * Given a directory it traverses the directory up looking for a package.json and if found, it reads it\n * decodes the JSON, and returns its content as a Javascript object.\n * @param options - The directory from which traverse up.\n * @returns If found, the promise resolves with the path to the\n * package.json and its content. If not found, it throws a FindUpAndReadPackageJsonNotFoundError error.\n */\nexport async function findUpAndReadPackageJson(fromDirectory: string): Promise<{path: string; content: PackageJson}> {\n const packageJsonPath = await findPathUp('package.json', {cwd: fromDirectory, type: 'file'})\n if (packageJsonPath) {\n const packageJson = JSON.parse(await readFile(packageJsonPath))\n return {path: packageJsonPath, content: packageJson}\n } else {\n throw new FindUpAndReadPackageJsonNotFoundError(fromDirectory)\n }\n}\n\nexport async function addResolutionOrOverride(directory: string, dependencies: {[key: string]: string}): Promise<void> {\n const packageManager = await getPackageManager(directory)\n const packageJsonPath = joinPath(directory, 'package.json')\n const packageJsonContent = await readAndParsePackageJson(packageJsonPath)\n\n if (packageManager === 'yarn') {\n packageJsonContent.resolutions = packageJsonContent.resolutions\n ? {...packageJsonContent.resolutions, ...dependencies}\n : dependencies\n }\n if (packageManager === 'npm' || packageManager === 'pnpm' || packageManager === 'bun') {\n packageJsonContent.overrides = packageJsonContent.overrides\n ? {...packageJsonContent.overrides, ...dependencies}\n : dependencies\n }\n\n await writeFile(packageJsonPath, JSON.stringify(packageJsonContent, null, 2))\n}\n\n/**\n * Returns the latest available version of an NPM package.\n * @param name - The name of the NPM package.\n * @returns A promise to get the latest available version of a package.\n */\nasync function getLatestNPMPackageVersion(name: string) {\n outputDebug(outputContent`Getting the latest version of NPM package: ${outputToken.raw(name)}`)\n return runWithTimer('cmd_all_timing_network_ms')(() => {\n return latestVersion(name)\n })\n}\n\n/**\n * Writes the package.json file to the given directory.\n *\n * @param directory - Directory where the package.json file will be written.\n * @param packageJSON - Package.json file to write.\n */\nexport async function writePackageJSON(directory: string, packageJSON: PackageJson): Promise<void> {\n outputDebug(outputContent`JSON-encoding and writing content to package.json at ${outputToken.path(directory)}...`)\n const packagePath = joinPath(directory, 'package.json')\n await writeFile(packagePath, JSON.stringify(packageJSON, null, 2))\n}\n\n/**\n * Infers the package manager to be used based on the provided options and environment.\n *\n * This function determines the package manager in the following order of precedence:\n * 1. Uses the package manager specified in the options, if valid.\n * 2. Infers the package manager from the user agent string.\n * 3. Infers the package manager used for the global CLI installation.\n * 4. Defaults to 'npm' if no other method succeeds.\n *\n * @param optionsPackageManager - The package manager specified in the options (if any).\n * @returns The inferred package manager as a PackageManager type.\n */\nexport function inferPackageManager(optionsPackageManager: string | undefined, env = process.env): PackageManager {\n if (optionsPackageManager && packageManager.includes(optionsPackageManager as PackageManager)) {\n return optionsPackageManager as PackageManager\n }\n const usedPackageManager = packageManagerFromUserAgent(env)\n if (usedPackageManager !== 'unknown') return usedPackageManager\n\n const globalPackageManager = inferPackageManagerForGlobalCLI()\n if (globalPackageManager !== 'unknown') return globalPackageManager\n\n return 'npm'\n}\n"]}
@@ -5,7 +5,8 @@ import { nonRandomUUID } from './crypto.js';
5
5
  import * as secureStore from '../../private/node/session/store.js';
6
6
  import { exchangeCustomPartnerToken } from '../../private/node/session/exchange.js';
7
7
  import { outputContent, outputToken, outputDebug } from '../../public/node/output.js';
8
- import { ensureAuthenticated } from '../../private/node/session.js';
8
+ import { ensureAuthenticated, setLastSeenAuthMethod, setLastSeenUserIdAfterAuth } from '../../private/node/session.js';
9
+ import { isThemeAccessSession } from '../../private/node/api/rest.js';
9
10
  /**
10
11
  * Ensure that we have a valid session to access the Partners API.
11
12
  * If SHOPIFY_CLI_PARTNERS_TOKEN exists, that token will be used to obtain a valid Partners Token
@@ -22,7 +23,8 @@ ${outputToken.json(scopes)}
22
23
  `);
23
24
  const envToken = getPartnersToken();
24
25
  if (envToken) {
25
- return { token: (await exchangeCustomPartnerToken(envToken)).accessToken, userId: nonRandomUUID(envToken) };
26
+ const result = await exchangeCustomPartnerToken(envToken);
27
+ return { token: result.accessToken, userId: result.userId };
26
28
  }
27
29
  const tokens = await ensureAuthenticated({ partnersApi: { scopes } }, env, options);
28
30
  if (!tokens.partners) {
@@ -57,8 +59,13 @@ ${outputToken.json(scopes)}
57
59
  * @returns The access token for the Storefront API.
58
60
  */
59
61
  export async function ensureAuthenticatedStorefront(scopes = [], password = undefined, forceRefresh = false) {
60
- if (password)
62
+ if (password) {
63
+ const session = { token: password, storeFqdn: '' };
64
+ const authMethod = isThemeAccessSession(session) ? 'theme_access_token' : 'custom_app_token';
65
+ setLastSeenAuthMethod(authMethod);
66
+ setLastSeenUserIdAfterAuth(nonRandomUUID(password));
61
67
  return password;
68
+ }
62
69
  outputDebug(outputContent `Ensuring that the user is authenticated with the Storefront API with the following scopes:
63
70
  ${outputToken.json(scopes)}
64
71
  `);
@@ -105,8 +112,13 @@ export async function ensureAuthenticatedThemes(store, password, scopes = [], fo
105
112
  outputDebug(outputContent `Ensuring that the user is authenticated with the Theme API with the following scopes:
106
113
  ${outputToken.json(scopes)}
107
114
  `);
108
- if (password)
109
- return { token: password, storeFqdn: await normalizeStoreFqdn(store) };
115
+ if (password) {
116
+ const session = { token: password, storeFqdn: await normalizeStoreFqdn(store) };
117
+ const authMethod = isThemeAccessSession(session) ? 'theme_access_token' : 'custom_app_token';
118
+ setLastSeenAuthMethod(authMethod);
119
+ setLastSeenUserIdAfterAuth(nonRandomUUID(password));
120
+ return session;
121
+ }
110
122
  return ensureAuthenticatedAdmin(store, scopes, forceRefresh);
111
123
  }
112
124
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/public/node/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAA;AACnC,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,WAAW,MAAM,qCAAqC,CAAA;AAClE,OAAO,EAAC,0BAA0B,EAAC,MAAM,wCAAwC,CAAA;AACjF,OAAO,EAAC,aAAa,EAAE,WAAW,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACnF,OAAO,EAAC,mBAAmB,EAAC,MAAM,+BAA+B,CAAA;AAcjE;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,SAAmB,EAAE,EACrB,GAAG,GAAG,OAAO,CAAC,GAAG,EACjB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,GAAG,KAAK;IAEpB,WAAW,CAAC,aAAa,CAAA;EACzB,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC;CACzB,CAAC,CAAA;IACA,IAAI,QAAQ;QAAE,OAAO,EAAC,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC,KAAK,CAAC,EAAC,CAAA;IAClF,OAAO,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,CAAA;AAC9D,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mCAAmC,CAAC,SAAmB,EAAE;IAC7E,WAAW,CAAC,aAAa,CAAA;EACzB,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC;CACzB,CAAC,CAAA;IACA,MAAM,MAAM,GAAG,MAAM,mBAAmB,CAAC,EAAC,mBAAmB,EAAE,EAAC,MAAM,EAAC,EAAC,EAAE,OAAO,CAAC,GAAG,CAAC,CAAA;IACtF,IAAI,CAAC,MAAM,CAAC,gBAAgB,EAAE;QAC5B,MAAM,IAAI,QAAQ,CAAC,+DAA+D,CAAC,CAAA;KACpF;IACD,OAAO,MAAM,CAAC,gBAAgB,CAAA;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,MAAM;IACpB,OAAO,WAAW,CAAC,MAAM,EAAE,CAAA;AAC7B,CAAC","sourcesContent":["import {normalizeStoreFqdn} from './context/fqdn.js'\nimport {BugError} from './error.js'\nimport {getPartnersToken} from './environment.js'\nimport {nonRandomUUID} from './crypto.js'\nimport * as secureStore from '../../private/node/session/store.js'\nimport {exchangeCustomPartnerToken} from '../../private/node/session/exchange.js'\nimport {outputContent, outputToken, outputDebug} from '../../public/node/output.js'\nimport {ensureAuthenticated} from '../../private/node/session.js'\n\n/**\n * Session Object to access the Admin API, includes the token and the store FQDN.\n */\nexport interface AdminSession {\n token: string\n storeFqdn: string\n}\n\ninterface EnsureAuthenticatedAdditionalOptions {\n noPrompt?: boolean\n}\n\n/**\n * Ensure that we have a valid session to access the Partners API.\n * If SHOPIFY_CLI_PARTNERS_TOKEN exists, that token will be used to obtain a valid Partners Token\n * If SHOPIFY_CLI_PARTNERS_TOKEN exists, scopes will be ignored.\n *\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param env - Optional environment variables to use.\n * @param options - Optional extra options to use.\n * @returns The access token for the Partners API.\n */\nexport async function ensureAuthenticatedPartners(\n scopes: string[] = [],\n env = process.env,\n options: EnsureAuthenticatedAdditionalOptions = {},\n): Promise<{token: string; userId: string}> {\n outputDebug(outputContent`Ensuring that the user is authenticated with the Partners API with the following scopes:\n${outputToken.json(scopes)}\n`)\n const envToken = getPartnersToken()\n if (envToken) {\n return {token: (await exchangeCustomPartnerToken(envToken)).accessToken, userId: nonRandomUUID(envToken)}\n }\n const tokens = await ensureAuthenticated({partnersApi: {scopes}}, env, options)\n if (!tokens.partners) {\n throw new BugError('No partners token found after ensuring authenticated')\n }\n return {token: tokens.partners, userId: tokens.userId}\n}\n\n/**\n * Ensure that we have a valid session to access the App Management API.\n *\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param env - Optional environment variables to use.\n * @param options - Optional extra options to use.\n * @returns The access token for the App Management API.\n */\nexport async function ensureAuthenticatedAppManagement(\n scopes: string[] = [],\n env = process.env,\n options: EnsureAuthenticatedAdditionalOptions = {},\n): Promise<{token: string; userId: string}> {\n outputDebug(outputContent`Ensuring that the user is authenticated with the App Management API with the following scopes:\n${outputToken.json(scopes)}\n`)\n const tokens = await ensureAuthenticated({appManagementApi: {scopes}}, env, options)\n if (!tokens) {\n throw new BugError('No App Management token found after ensuring authenticated')\n }\n return {token: tokens.appManagement!, userId: tokens.userId}\n}\n\n/**\n * Ensure that we have a valid session to access the Storefront API.\n *\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param password - Optional password to use.\n * @param forceRefresh - Optional flag to force a refresh of the token.\n * @returns The access token for the Storefront API.\n */\nexport async function ensureAuthenticatedStorefront(\n scopes: string[] = [],\n password: string | undefined = undefined,\n forceRefresh = false,\n): Promise<string> {\n if (password) return password\n\n outputDebug(outputContent`Ensuring that the user is authenticated with the Storefront API with the following scopes:\n${outputToken.json(scopes)}\n`)\n const tokens = await ensureAuthenticated({storefrontRendererApi: {scopes}}, process.env, {forceRefresh})\n if (!tokens.storefront) {\n throw new BugError('No storefront token found after ensuring authenticated')\n }\n return tokens.storefront\n}\n\n/**\n * Ensure that we have a valid Admin session for the given store.\n *\n * @param store - Store fqdn to request auth for.\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param forceRefresh - Optional flag to force a refresh of the token.\n * @param options - Optional extra options to use.\n * @returns The access token for the Admin API.\n */\nexport async function ensureAuthenticatedAdmin(\n store: string,\n scopes: string[] = [],\n forceRefresh = false,\n options: EnsureAuthenticatedAdditionalOptions = {},\n): Promise<AdminSession> {\n outputDebug(outputContent`Ensuring that the user is authenticated with the Admin API with the following scopes for the store ${outputToken.raw(\n store,\n )}:\n${outputToken.json(scopes)}\n`)\n const tokens = await ensureAuthenticated({adminApi: {scopes, storeFqdn: store}}, process.env, {\n forceRefresh,\n ...options,\n })\n if (!tokens.admin) {\n throw new BugError('No admin token found after ensuring authenticated')\n }\n return tokens.admin\n}\n\n/**\n * Ensure that we have a valid session to access the Theme API.\n * If a password is provided, that token will be used against Theme Access API.\n * Otherwise, it will ensure that the user is authenticated with the Admin API.\n *\n * @param store - Store fqdn to request auth for.\n * @param password - Password generated from Theme Access app.\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param forceRefresh - Optional flag to force a refresh of the token.\n * @returns The access token and store.\n */\nexport async function ensureAuthenticatedThemes(\n store: string,\n password: string | undefined,\n scopes: string[] = [],\n forceRefresh = false,\n): Promise<AdminSession> {\n outputDebug(outputContent`Ensuring that the user is authenticated with the Theme API with the following scopes:\n${outputToken.json(scopes)}\n`)\n if (password) return {token: password, storeFqdn: await normalizeStoreFqdn(store)}\n return ensureAuthenticatedAdmin(store, scopes, forceRefresh)\n}\n\n/**\n * Ensure that we have a valid session to access the Business Platform API.\n *\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @returns The access token for the Business Platform API.\n */\nexport async function ensureAuthenticatedBusinessPlatform(scopes: string[] = []): Promise<string> {\n outputDebug(outputContent`Ensuring that the user is authenticated with the Business Platform API with the following scopes:\n${outputToken.json(scopes)}\n`)\n const tokens = await ensureAuthenticated({businessPlatformApi: {scopes}}, process.env)\n if (!tokens.businessPlatform) {\n throw new BugError('No business-platform token found after ensuring authenticated')\n }\n return tokens.businessPlatform\n}\n\n/**\n * Logout from Shopify.\n *\n * @returns A promise that resolves when the logout is complete.\n */\nexport function logout(): Promise<void> {\n return secureStore.remove()\n}\n"]}
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../../src/public/node/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,mBAAmB,CAAA;AACpD,OAAO,EAAC,QAAQ,EAAC,MAAM,YAAY,CAAA;AACnC,OAAO,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAC,aAAa,EAAC,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,WAAW,MAAM,qCAAqC,CAAA;AAClE,OAAO,EAAC,0BAA0B,EAAC,MAAM,wCAAwC,CAAA;AACjF,OAAO,EAAC,aAAa,EAAE,WAAW,EAAE,WAAW,EAAC,MAAM,6BAA6B,CAAA;AACnF,OAAO,EAAC,mBAAmB,EAAE,qBAAqB,EAAE,0BAA0B,EAAC,MAAM,+BAA+B,CAAA;AACpH,OAAO,EAAC,oBAAoB,EAAC,MAAM,gCAAgC,CAAA;AAcnE;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,SAAmB,EAAE,EACrB,GAAG,GAAG,OAAO,CAAC,GAAG,EACjB,UAAgD,EAAE;IAElD,WAAW,CAAC,aAAa,CAAA;EACzB,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC;CACzB,CAAC,CAAA;IACA,MAAM,Q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MAAM;IACpB,OAAO,WAAW,CAAC,MAAM,EAAE,CAAA;AAC7B,CAAC","sourcesContent":["import {normalizeStoreFqdn} from './context/fqdn.js'\nimport {BugError} from './error.js'\nimport {getPartnersToken} from './environment.js'\nimport {nonRandomUUID} from './crypto.js'\nimport * as secureStore from '../../private/node/session/store.js'\nimport {exchangeCustomPartnerToken} from '../../private/node/session/exchange.js'\nimport {outputContent, outputToken, outputDebug} from '../../public/node/output.js'\nimport {ensureAuthenticated, setLastSeenAuthMethod, setLastSeenUserIdAfterAuth} from '../../private/node/session.js'\nimport {isThemeAccessSession} from '../../private/node/api/rest.js'\n\n/**\n * Session Object to access the Admin API, includes the token and the store FQDN.\n */\nexport interface AdminSession {\n token: string\n storeFqdn: string\n}\n\ninterface EnsureAuthenticatedAdditionalOptions {\n noPrompt?: boolean\n}\n\n/**\n * Ensure that we have a valid session to access the Partners API.\n * If SHOPIFY_CLI_PARTNERS_TOKEN exists, that token will be used to obtain a valid Partners Token\n * If SHOPIFY_CLI_PARTNERS_TOKEN exists, scopes will be ignored.\n *\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param env - Optional environment variables to use.\n * @param options - Optional extra options to use.\n * @returns The access token for the Partners API.\n */\nexport async function ensureAuthenticatedPartners(\n scopes: string[] = [],\n env = process.env,\n options: EnsureAuthenticatedAdditionalOptions = {},\n): Promise<{token: string; userId: string}> {\n outputDebug(outputContent`Ensuring that the user is authenticated with the Partners API with the following scopes:\n${outputToken.json(scopes)}\n`)\n const envToken = getPartnersToken()\n if (envToken) {\n const result = await exchangeCustomPartnerToken(envToken)\n return {token: result.accessToken, userId: result.userId}\n }\n const tokens = await ensureAuthenticated({partnersApi: {scopes}}, env, options)\n if (!tokens.partners) {\n throw new BugError('No partners token found after ensuring authenticated')\n }\n return {token: tokens.partners, userId: tokens.userId}\n}\n\n/**\n * Ensure that we have a valid session to access the App Management API.\n *\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param env - Optional environment variables to use.\n * @param options - Optional extra options to use.\n * @returns The access token for the App Management API.\n */\nexport async function ensureAuthenticatedAppManagement(\n scopes: string[] = [],\n env = process.env,\n options: EnsureAuthenticatedAdditionalOptions = {},\n): Promise<{token: string; userId: string}> {\n outputDebug(outputContent`Ensuring that the user is authenticated with the App Management API with the following scopes:\n${outputToken.json(scopes)}\n`)\n const tokens = await ensureAuthenticated({appManagementApi: {scopes}}, env, options)\n if (!tokens) {\n throw new BugError('No App Management token found after ensuring authenticated')\n }\n return {token: tokens.appManagement!, userId: tokens.userId}\n}\n\n/**\n * Ensure that we have a valid session to access the Storefront API.\n *\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param password - Optional password to use.\n * @param forceRefresh - Optional flag to force a refresh of the token.\n * @returns The access token for the Storefront API.\n */\nexport async function ensureAuthenticatedStorefront(\n scopes: string[] = [],\n password: string | undefined = undefined,\n forceRefresh = false,\n): Promise<string> {\n if (password) {\n const session = {token: password, storeFqdn: ''}\n const authMethod = isThemeAccessSession(session) ? 'theme_access_token' : 'custom_app_token'\n setLastSeenAuthMethod(authMethod)\n setLastSeenUserIdAfterAuth(nonRandomUUID(password))\n return password\n }\n\n outputDebug(outputContent`Ensuring that the user is authenticated with the Storefront API with the following scopes:\n${outputToken.json(scopes)}\n`)\n const tokens = await ensureAuthenticated({storefrontRendererApi: {scopes}}, process.env, {forceRefresh})\n if (!tokens.storefront) {\n throw new BugError('No storefront token found after ensuring authenticated')\n }\n return tokens.storefront\n}\n\n/**\n * Ensure that we have a valid Admin session for the given store.\n *\n * @param store - Store fqdn to request auth for.\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param forceRefresh - Optional flag to force a refresh of the token.\n * @param options - Optional extra options to use.\n * @returns The access token for the Admin API.\n */\nexport async function ensureAuthenticatedAdmin(\n store: string,\n scopes: string[] = [],\n forceRefresh = false,\n options: EnsureAuthenticatedAdditionalOptions = {},\n): Promise<AdminSession> {\n outputDebug(outputContent`Ensuring that the user is authenticated with the Admin API with the following scopes for the store ${outputToken.raw(\n store,\n )}:\n${outputToken.json(scopes)}\n`)\n const tokens = await ensureAuthenticated({adminApi: {scopes, storeFqdn: store}}, process.env, {\n forceRefresh,\n ...options,\n })\n if (!tokens.admin) {\n throw new BugError('No admin token found after ensuring authenticated')\n }\n return tokens.admin\n}\n\n/**\n * Ensure that we have a valid session to access the Theme API.\n * If a password is provided, that token will be used against Theme Access API.\n * Otherwise, it will ensure that the user is authenticated with the Admin API.\n *\n * @param store - Store fqdn to request auth for.\n * @param password - Password generated from Theme Access app.\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @param forceRefresh - Optional flag to force a refresh of the token.\n * @returns The access token and store.\n */\nexport async function ensureAuthenticatedThemes(\n store: string,\n password: string | undefined,\n scopes: string[] = [],\n forceRefresh = false,\n): Promise<AdminSession> {\n outputDebug(outputContent`Ensuring that the user is authenticated with the Theme API with the following scopes:\n${outputToken.json(scopes)}\n`)\n if (password) {\n const session = {token: password, storeFqdn: await normalizeStoreFqdn(store)}\n const authMethod = isThemeAccessSession(session) ? 'theme_access_token' : 'custom_app_token'\n setLastSeenAuthMethod(authMethod)\n setLastSeenUserIdAfterAuth(nonRandomUUID(password))\n return session\n }\n return ensureAuthenticatedAdmin(store, scopes, forceRefresh)\n}\n\n/**\n * Ensure that we have a valid session to access the Business Platform API.\n *\n * @param scopes - Optional array of extra scopes to authenticate with.\n * @returns The access token for the Business Platform API.\n */\nexport async function ensureAuthenticatedBusinessPlatform(scopes: string[] = []): Promise<string> {\n outputDebug(outputContent`Ensuring that the user is authenticated with the Business Platform API with the following scopes:\n${outputToken.json(scopes)}\n`)\n const tokens = await ensureAuthenticated({businessPlatformApi: {scopes}}, process.env)\n if (!tokens.businessPlatform) {\n throw new BugError('No business-platform token found after ensuring authenticated')\n }\n return tokens.businessPlatform\n}\n\n/**\n * Logout from Shopify.\n *\n * @returns A promise that resolves when the logout is complete.\n */\nexport function logout(): Promise<void> {\n return secureStore.remove()\n}\n"]}