@shopify/cli-kit 3.80.7 → 3.81.0
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/dist/private/node/analytics.js +4 -4
- package/dist/private/node/analytics.js.map +1 -1
- package/dist/private/node/api/rest.d.ts +1 -1
- package/dist/private/node/api/rest.js.map +1 -1
- package/dist/private/node/api.d.ts +1 -1
- package/dist/private/node/api.js +3 -9
- package/dist/private/node/api.js.map +1 -1
- package/dist/private/node/conf-store.js +1 -1
- package/dist/private/node/conf-store.js.map +1 -1
- package/dist/private/node/constants.d.ts +0 -2
- package/dist/private/node/constants.js +0 -2
- package/dist/private/node/constants.js.map +1 -1
- package/dist/private/node/output.d.ts +22 -0
- package/dist/private/node/output.js +47 -0
- package/dist/private/node/output.js.map +1 -0
- package/dist/private/node/session/exchange.js +1 -1
- package/dist/private/node/session/exchange.js.map +1 -1
- package/dist/private/node/session/scopes.js +3 -1
- package/dist/private/node/session/scopes.js.map +1 -1
- package/dist/private/node/session/validate.js +1 -1
- package/dist/private/node/session/validate.js.map +1 -1
- package/dist/private/node/session.d.ts +1 -1
- package/dist/private/node/session.js +3 -4
- package/dist/private/node/session.js.map +1 -1
- package/dist/private/node/sleep-with-backoff.js +1 -1
- package/dist/private/node/sleep-with-backoff.js.map +1 -1
- package/dist/private/node/ui/alert.js +1 -8
- package/dist/private/node/ui/alert.js.map +1 -1
- package/dist/private/node/ui/components/Banner.test.js +1 -1
- package/dist/private/node/ui/components/Banner.test.js.map +1 -1
- package/dist/private/node/ui/components/TextPrompt.test.js +1 -1
- package/dist/private/node/ui/components/TextPrompt.test.js.map +1 -1
- package/dist/private/node/ui.d.ts +1 -1
- package/dist/private/node/ui.js +6 -8
- package/dist/private/node/ui.js.map +1 -1
- package/dist/public/common/ts/json-narrowing.js +1 -1
- package/dist/public/common/ts/json-narrowing.js.map +1 -1
- package/dist/public/common/version.d.ts +1 -1
- package/dist/public/common/version.js +1 -1
- package/dist/public/common/version.js.map +1 -1
- package/dist/public/node/api/admin.js +2 -2
- package/dist/public/node/api/admin.js.map +1 -1
- package/dist/public/node/api/app-dev.d.ts +16 -4
- package/dist/public/node/api/app-dev.js +7 -9
- package/dist/public/node/api/app-dev.js.map +1 -1
- package/dist/public/node/api/app-management.d.ts +17 -4
- package/dist/public/node/api/app-management.js +9 -13
- package/dist/public/node/api/app-management.js.map +1 -1
- package/dist/public/node/api/business-platform.d.ts +28 -16
- package/dist/public/node/api/business-platform.js +19 -25
- package/dist/public/node/api/business-platform.js.map +1 -1
- package/dist/public/node/api/functions.d.ts +16 -3
- package/dist/public/node/api/functions.js +6 -9
- package/dist/public/node/api/functions.js.map +1 -1
- package/dist/public/node/api/graphql.d.ts +10 -2
- package/dist/public/node/api/graphql.js +52 -10
- package/dist/public/node/api/graphql.js.map +1 -1
- package/dist/public/node/api/partners.d.ts +5 -3
- package/dist/public/node/api/partners.js +7 -3
- package/dist/public/node/api/partners.js.map +1 -1
- package/dist/public/node/api/rest-api-throttler.js +1 -1
- package/dist/public/node/api/rest-api-throttler.js.map +1 -1
- package/dist/public/node/api/webhooks.d.ts +13 -5
- package/dist/public/node/api/webhooks.js +7 -9
- package/dist/public/node/api/webhooks.js.map +1 -1
- package/dist/public/node/archiver.js +1 -2
- package/dist/public/node/archiver.js.map +1 -1
- package/dist/public/node/base-command.d.ts +5 -0
- package/dist/public/node/base-command.js +27 -10
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/context/local.d.ts +0 -14
- package/dist/public/node/context/local.js +0 -18
- package/dist/public/node/context/local.js.map +1 -1
- package/dist/public/node/environments.d.ts +2 -0
- package/dist/public/node/environments.js +26 -11
- package/dist/public/node/environments.js.map +1 -1
- package/dist/public/node/hooks/deprecations.js +1 -1
- package/dist/public/node/hooks/deprecations.js.map +1 -1
- package/dist/public/node/json-schema.js +30 -11
- package/dist/public/node/json-schema.js.map +1 -1
- package/dist/public/node/logs.js +2 -2
- package/dist/public/node/logs.js.map +1 -1
- package/dist/public/node/node-package-manager.js +12 -4
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/notifications-system.js +1 -1
- package/dist/public/node/notifications-system.js.map +1 -1
- package/dist/public/node/output.d.ts +16 -26
- package/dist/public/node/output.js +24 -55
- package/dist/public/node/output.js.map +1 -1
- package/dist/public/node/themes/api.d.ts +2 -2
- package/dist/public/node/themes/api.js +8 -5
- package/dist/public/node/themes/api.js.map +1 -1
- package/dist/public/node/themes/conf.d.ts +2 -2
- package/dist/public/node/themes/conf.js +2 -2
- package/dist/public/node/themes/conf.js.map +1 -1
- package/dist/public/node/themes/factories.d.ts +1 -1
- package/dist/public/node/themes/factories.js.map +1 -1
- package/dist/public/node/themes/theme-manager.d.ts +3 -3
- package/dist/public/node/themes/theme-manager.js +2 -2
- package/dist/public/node/themes/theme-manager.js.map +1 -1
- package/dist/public/node/themes/urls.d.ts +2 -2
- package/dist/public/node/themes/urls.js.map +1 -1
- package/dist/public/node/themes/utils.d.ts +1 -1
- package/dist/public/node/themes/utils.js +1 -1
- package/dist/public/node/themes/utils.js.map +1 -1
- package/dist/public/node/ui.d.ts +0 -13
- package/dist/public/node/ui.js +2 -18
- package/dist/public/node/ui.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -4
|
@@ -1 +1 @@
|
|
|
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,EAAE,QAAQ,EAAC,MAAM,WAAW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AO,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 const lockfilesByManager: {[key in PackageManager]: Lockfile | undefined} = {\n yarn: yarnLockfile,\n npm: npmLockfile,\n pnpm: pnpmLockfile,\n bun: bunLockfile,\n unknown: undefined,\n}\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)?.value\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"]}
|
|
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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A;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,CAAC;QAC9F,OAAO,qBAAuC,CAAA;IAChD,CAAC;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 const lockfilesByManager: {[key in PackageManager]: Lockfile | undefined} = {\n yarn: yarnLockfile,\n npm: npmLockfile,\n pnpm: pnpmLockfile,\n bun: bunLockfile,\n unknown: undefined,\n}\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 let directory: string | undefined\n let packageJson: string | undefined\n try {\n directory = await captureOutput('npm', ['prefix'], {cwd: fromDirectory})\n outputDebug(outputContent`Obtaining the dependency manager in directory ${outputToken.path(directory)}...`)\n packageJson = joinPath(directory, 'package.json')\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n // if problems locating directoy/package file, we use user agent instead\n }\n\n if (!directory || !packageJson || !(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)?.value\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"]}
|
|
@@ -7,9 +7,9 @@ import { AbortSilentError } from './error.js';
|
|
|
7
7
|
import { isTruthy } from './context/utilities.js';
|
|
8
8
|
import { exec } from './system.js';
|
|
9
9
|
import { jsonOutputEnabled } from './environment.js';
|
|
10
|
+
import { fetch } from './http.js';
|
|
10
11
|
import { CLI_KIT_VERSION } from '../common/version.js';
|
|
11
12
|
import { cacheRetrieve, cacheStore } from '../../private/node/conf-store.js';
|
|
12
|
-
import { fetch } from '@shopify/cli-kit/node/http';
|
|
13
13
|
const URL = 'https://cdn.shopify.com/static/cli/notifications.json';
|
|
14
14
|
const EMPTY_CACHE_MESSAGE = 'Cache is empty';
|
|
15
15
|
const COMMANDS_TO_SKIP = [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notifications-system.js","sourceRoot":"","sources":["../../../src/public/node/notifications-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAA;AAC1D,OAAO,EAAC,WAAW,EAAE,UAAU,EAAE,aAAa,EAAC,MAAM,SAAS,CAAA;AAC9D,OAAO,EAAC,mBAAmB,EAAC,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAA;AACvC,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAA;AAC/B,OAAO,EAAC,gBAAgB,EAAC,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAC,QAAQ,EAAC,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAC,IAAI,EAAC,MAAM,aAAa,CAAA;AAChC,OAAO,EAAC,iBAAiB,EAAC,MAAM,kBAAkB,CAA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from './node-package-manager.js'\nimport {renderError, renderInfo, renderWarning} from './ui.js'\nimport {getCurrentCommandId} from './global-context.js'\nimport {outputDebug} from './output.js'\nimport {zod} from './schema.js'\nimport {AbortSilentError} from './error.js'\nimport {isTruthy} from './context/utilities.js'\nimport {exec} from './system.js'\nimport {jsonOutputEnabled} from './environment.js'\nimport {CLI_KIT_VERSION} from '../common/version.js'\nimport {NotificationKey, NotificationsKey, cacheRetrieve, cacheStore} from '../../private/node/conf-store.js'\nimport {fetch} from '@shopify/cli-kit/node/http'\n\nconst URL = 'https://cdn.shopify.com/static/cli/notifications.json'\nconst EMPTY_CACHE_MESSAGE = 'Cache is empty'\nconst COMMANDS_TO_SKIP = [\n 'notifications:list',\n 'notifications:generate',\n 'init',\n 'app:init',\n 'theme:init',\n 'hydrogen:init',\n 'cache:clear',\n]\n\nfunction url(): string {\n return process.env.SHOPIFY_CLI_NOTIFICATIONS_URL ?? URL\n}\n\nconst NotificationSchema = zod.object({\n id: zod.string(),\n message: zod.string(),\n type: zod.enum(['info', 'warning', 'error']),\n frequency: zod.enum(['always', 'once', 'once_a_day', 'once_a_week']),\n ownerChannel: zod.string(),\n cta: zod\n .object({\n label: zod.string(),\n url: zod.string().url(),\n })\n .optional(),\n title: zod.string().optional(),\n minVersion: zod.string().optional(),\n maxVersion: zod.string().optional(),\n minDate: zod.string().optional(),\n maxDate: zod.string().optional(),\n commands: zod.array(zod.string()).optional(),\n surface: zod.string().optional(),\n})\nexport type Notification = zod.infer<typeof NotificationSchema>\n\nconst NotificationsSchema = zod.object({notifications: zod.array(NotificationSchema)})\nexport type Notifications = zod.infer<typeof NotificationsSchema>\n\n/**\n * Shows notifications to the user if they meet the criteria specified in the notifications.json file.\n *\n * @param currentSurfaces - The surfaces present in the current project (usually for app extensions).\n * @param environment - Process environment variables.\n * @returns - A promise that resolves when the notifications have been shown.\n */\nexport async function showNotificationsIfNeeded(\n currentSurfaces?: string[],\n environment: NodeJS.ProcessEnv = process.env,\n): Promise<void> {\n try {\n const commandId = getCurrentCommandId()\n if (skipNotifications(commandId, environment) || jsonOutputEnabled(environment)) return\n\n const notifications = await getNotifications()\n const notificationsToShow = filterNotifications(notifications.notifications, commandId, currentSurfaces)\n outputDebug(`Notifications to show: ${notificationsToShow.length}`)\n await renderNotifications(notificationsToShow)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.message === EMPTY_CACHE_MESSAGE) {\n outputDebug('Notifications to show: 0 (Cache is empty)')\n return\n }\n if (error.message === 'abort') throw new AbortSilentError()\n const errorMessage = `Error showing notifications: ${error.message}`\n outputDebug(errorMessage)\n // This is very prone to becoming a circular dependency, so we import it dynamically\n const {sendErrorToBugsnag} = await import('./error-handler.js')\n await sendErrorToBugsnag(errorMessage, 'unexpected_error')\n }\n}\n\nfunction skipNotifications(currentCommand: string, environment: NodeJS.ProcessEnv = process.env): boolean {\n return (\n isTruthy(environment.CI) || isTruthy(environment.SHOPIFY_UNIT_TEST) || COMMANDS_TO_SKIP.includes(currentCommand)\n )\n}\n\n/**\n * Renders the first 2 notifications to the user.\n *\n * @param notifications - The notifications to render.\n */\nasync function renderNotifications(notifications: Notification[]) {\n notifications.slice(0, 2).forEach((notification) => {\n const content = {\n headline: notification.title,\n body: notification.message.replaceAll('\\\\n', '\\n'),\n link: notification.cta,\n }\n switch (notification.type) {\n case 'info': {\n renderInfo(content)\n break\n }\n case 'warning': {\n renderWarning(content)\n break\n }\n case 'error': {\n renderError(content)\n throw new Error('abort')\n }\n }\n cacheStore(`notification-${notification.id}`, new Date().getTime().toString())\n })\n}\n\n/**\n * Get notifications list from cache, that is updated in the background from bin/fetch-notifications.json.\n *\n * @returns A Notifications object.\n */\nexport async function getNotifications(): Promise<Notifications> {\n const cacheKey: NotificationsKey = `notifications-${url()}`\n const rawNotifications = cacheRetrieve(cacheKey)?.value as unknown as string\n if (!rawNotifications) throw new Error(EMPTY_CACHE_MESSAGE)\n const notifications: object = JSON.parse(rawNotifications)\n return NotificationsSchema.parse(notifications)\n}\n\n/**\n * Fetch notifications from the CDN and chache them.\n *\n * @returns A string with the notifications.\n */\nexport async function fetchNotifications(): Promise<Notifications> {\n outputDebug(`Fetching notifications...`)\n const response = await fetch(url(), undefined, {\n useNetworkLevelRetry: false,\n useAbortSignal: true,\n timeoutMs: 3 * 1000,\n })\n if (response.status !== 200) throw new Error(`Failed to fetch notifications: ${response.statusText}`)\n const rawNotifications = await response.text()\n const notifications: object = JSON.parse(rawNotifications)\n const result = NotificationsSchema.parse(notifications)\n await cacheNotifications(rawNotifications)\n return result\n}\n\n/**\n * Store the notifications in the cache.\n *\n * @param notifications - String with the notifications to cache.\n * @returns A Notifications object.\n */\nasync function cacheNotifications(notifications: string): Promise<void> {\n cacheStore(`notifications-${url()}`, notifications)\n outputDebug(`Notifications from ${url()} stored in the cache`)\n}\n\n/**\n * Fetch notifications in background as a detached process.\n *\n * @param currentCommand - The current Shopify command being run.\n * @param argv - The arguments passed to the current process.\n * @param environment - Process environment variables.\n */\nexport function fetchNotificationsInBackground(\n currentCommand: string,\n argv = process.argv,\n environment: NodeJS.ProcessEnv = process.env,\n): void {\n if (skipNotifications(currentCommand, environment)) return\n if (!argv[0] || !argv[1]) return\n\n // Run the Shopify command the same way as the current execution\n const nodeBinary = argv[0]\n const shopifyBinary = argv[1]\n const args = [shopifyBinary, 'notifications', 'list', '--ignore-errors']\n\n // eslint-disable-next-line no-void\n void exec(nodeBinary, args, {\n background: true,\n env: {...process.env, SHOPIFY_CLI_NO_ANALYTICS: '1'},\n externalErrorHandler: async (error: unknown) => {\n outputDebug(`Failed to fetch notifications in background: ${(error as Error).message}`)\n },\n })\n}\n\n/**\n * Filters notifications based on the version of the CLI.\n *\n * @param notifications - The notifications to filter.\n * @param commandId - The command ID to filter by.\n * @param currentSurfaces - The surfaces present in the current project (usually for app extensions).\n * @param today - The current date.\n * @param currentVersion - The current version of the CLI.\n * @returns - The filtered notifications.\n */\nexport function filterNotifications(\n notifications: Notification[],\n commandId: string,\n currentSurfaces?: string[],\n today: Date = new Date(new Date().setUTCHours(0, 0, 0, 0)),\n currentVersion: string = CLI_KIT_VERSION,\n): Notification[] {\n return notifications\n .filter((notification) => filterByVersion(notification, currentVersion))\n .filter((notifications) => filterByDate(notifications, today))\n .filter((notification) => filterByCommand(notification, commandId))\n .filter((notification) => filterBySurface(notification, commandId, currentSurfaces))\n .filter((notification) => filterByFrequency(notification))\n}\n\n/**\n * Filters notifications based on the version of the CLI.\n *\n * @param notification - The notification to filter.\n * @param currentVersion - The current version of the CLI.\n */\nfunction filterByVersion(notification: Notification, currentVersion: string) {\n const minVersion = !notification.minVersion || versionSatisfies(currentVersion, `>=${notification.minVersion}`)\n const maxVersion = !notification.maxVersion || versionSatisfies(currentVersion, `<=${notification.maxVersion}`)\n return minVersion && maxVersion\n}\n\n/**\n * Filters notifications based on the date.\n *\n * @param notification - The notification to filter.\n * @param today - The current date.\n */\nfunction filterByDate(notification: Notification, today: Date) {\n const minDate = !notification.minDate || new Date(notification.minDate) <= today\n const maxDate = !notification.maxDate || new Date(notification.maxDate) >= today\n return minDate && maxDate\n}\n\n/**\n * Filters notifications based on the command ID.\n *\n * @param notification - The notification to filter.\n * @param commandId - The command ID to filter by.\n * @returns - A boolean indicating whether the notification should be shown.\n */\nfunction filterByCommand(notification: Notification, commandId: string) {\n if (commandId === '') return true\n return !notification.commands || notification.commands.includes(commandId)\n}\n\n/**\n * Filters notifications based on the surface.\n *\n * @param notification - The notification to filter.\n * @param commandId - The command id.\n * @param surfacesFromContext - The surfaces present in the current project (usually for app extensions).\n * @returns - A boolean indicating whether the notification should be shown.\n */\nfunction filterBySurface(notification: Notification, commandId: string, surfacesFromContext?: string[]) {\n const surfaceFromCommand = commandId.split(':')[0] ?? 'all'\n const notificationSurface = notification.surface ?? 'all'\n\n if (surfacesFromContext) return surfacesFromContext.includes(notificationSurface)\n\n return notificationSurface === surfaceFromCommand || notificationSurface === 'all'\n}\n\n/**\n * Filters notifications based on the frequency.\n *\n * @param notification - The notification to filter.\n * @returns - A boolean indicating whether the notification should be shown.\n */\nfunction filterByFrequency(notification: Notification): boolean {\n if (!notification.frequency) return true\n const cacheKey: NotificationKey = `notification-${notification.id}`\n const lastShown = cacheRetrieve(cacheKey)?.value as unknown as string\n if (!lastShown) return true\n\n switch (notification.frequency) {\n case 'always': {\n return true\n }\n case 'once': {\n return false\n }\n case 'once_a_day': {\n return new Date().getTime() - Number(lastShown) > 24 * 3600 * 1000\n }\n case 'once_a_week': {\n return new Date().getTime() - Number(lastShown) > 7 * 24 * 3600 * 1000\n }\n }\n}\n\n/**\n * Returns a string with the filters from a notification, one by line.\n *\n * @param notification - The notification to get the filters from.\n * @returns A string with human-readable filters from the notification.\n */\nexport function stringifyFilters(notification: Notification): string {\n const filters = []\n if (notification.minDate) filters.push(`from ${notification.minDate}`)\n if (notification.maxDate) filters.push(`to ${notification.maxDate}`)\n if (notification.minVersion) filters.push(`from v${notification.minVersion}`)\n if (notification.maxVersion) filters.push(`to v${notification.maxVersion}`)\n if (notification.frequency === 'once') filters.push('show only once')\n if (notification.frequency === 'once_a_day') filters.push('show once a day')\n if (notification.frequency === 'once_a_week') filters.push('show once a week')\n if (notification.surface) filters.push(`surface = ${notification.surface}`)\n if (notification.commands) filters.push(`commands = ${notification.commands.join(', ')}`)\n return filters.join('\\n')\n}\n"]}
|
|
1
|
+
{"version":3,"file":"notifications-system.js","sourceRoot":"","sources":["../../../src/public/node/notifications-system.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,gBAAgB,EAAC,MAAM,2BAA2B,CAAA;AAC1D,OAAO,EAAC,WAAW,EAAE,UAAU,EAAE,aAAa,EAAC,MAAM,SAAS,CAAA;AAC9D,OAAO,EAAC,mBAAmB,EAAC,MAAM,qBAAqB,CAAA;AACvD,OAAO,EAAC,WAAW,EAAC,MAAM,aAAa,CAAA;AACvC,OAAO,EAAC,GAAG,EAAC,MAAM,aAAa,CAAA;AAC/B,OAAO,EAAC,gBAAgB,EAAC,MAAM,YAAY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,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACzF,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AAC3B,CAAC","sourcesContent":["import {versionSatisfies} from './node-package-manager.js'\nimport {renderError, renderInfo, renderWarning} from './ui.js'\nimport {getCurrentCommandId} from './global-context.js'\nimport {outputDebug} from './output.js'\nimport {zod} from './schema.js'\nimport {AbortSilentError} from './error.js'\nimport {isTruthy} from './context/utilities.js'\nimport {exec} from './system.js'\nimport {jsonOutputEnabled} from './environment.js'\nimport {fetch} from './http.js'\nimport {CLI_KIT_VERSION} from '../common/version.js'\nimport {NotificationKey, NotificationsKey, cacheRetrieve, cacheStore} from '../../private/node/conf-store.js'\n\nconst URL = 'https://cdn.shopify.com/static/cli/notifications.json'\nconst EMPTY_CACHE_MESSAGE = 'Cache is empty'\nconst COMMANDS_TO_SKIP = [\n 'notifications:list',\n 'notifications:generate',\n 'init',\n 'app:init',\n 'theme:init',\n 'hydrogen:init',\n 'cache:clear',\n]\n\nfunction url(): string {\n return process.env.SHOPIFY_CLI_NOTIFICATIONS_URL ?? URL\n}\n\nconst NotificationSchema = zod.object({\n id: zod.string(),\n message: zod.string(),\n type: zod.enum(['info', 'warning', 'error']),\n frequency: zod.enum(['always', 'once', 'once_a_day', 'once_a_week']),\n ownerChannel: zod.string(),\n cta: zod\n .object({\n label: zod.string(),\n url: zod.string().url(),\n })\n .optional(),\n title: zod.string().optional(),\n minVersion: zod.string().optional(),\n maxVersion: zod.string().optional(),\n minDate: zod.string().optional(),\n maxDate: zod.string().optional(),\n commands: zod.array(zod.string()).optional(),\n surface: zod.string().optional(),\n})\nexport type Notification = zod.infer<typeof NotificationSchema>\n\nconst NotificationsSchema = zod.object({notifications: zod.array(NotificationSchema)})\nexport type Notifications = zod.infer<typeof NotificationsSchema>\n\n/**\n * Shows notifications to the user if they meet the criteria specified in the notifications.json file.\n *\n * @param currentSurfaces - The surfaces present in the current project (usually for app extensions).\n * @param environment - Process environment variables.\n * @returns - A promise that resolves when the notifications have been shown.\n */\nexport async function showNotificationsIfNeeded(\n currentSurfaces?: string[],\n environment: NodeJS.ProcessEnv = process.env,\n): Promise<void> {\n try {\n const commandId = getCurrentCommandId()\n if (skipNotifications(commandId, environment) || jsonOutputEnabled(environment)) return\n\n const notifications = await getNotifications()\n const notificationsToShow = filterNotifications(notifications.notifications, commandId, currentSurfaces)\n outputDebug(`Notifications to show: ${notificationsToShow.length}`)\n await renderNotifications(notificationsToShow)\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (error: any) {\n if (error.message === EMPTY_CACHE_MESSAGE) {\n outputDebug('Notifications to show: 0 (Cache is empty)')\n return\n }\n if (error.message === 'abort') throw new AbortSilentError()\n const errorMessage = `Error showing notifications: ${error.message}`\n outputDebug(errorMessage)\n // This is very prone to becoming a circular dependency, so we import it dynamically\n const {sendErrorToBugsnag} = await import('./error-handler.js')\n await sendErrorToBugsnag(errorMessage, 'unexpected_error')\n }\n}\n\nfunction skipNotifications(currentCommand: string, environment: NodeJS.ProcessEnv = process.env): boolean {\n return (\n isTruthy(environment.CI) || isTruthy(environment.SHOPIFY_UNIT_TEST) || COMMANDS_TO_SKIP.includes(currentCommand)\n )\n}\n\n/**\n * Renders the first 2 notifications to the user.\n *\n * @param notifications - The notifications to render.\n */\nasync function renderNotifications(notifications: Notification[]) {\n notifications.slice(0, 2).forEach((notification) => {\n const content = {\n headline: notification.title,\n body: notification.message.replaceAll('\\\\n', '\\n'),\n link: notification.cta,\n }\n switch (notification.type) {\n case 'info': {\n renderInfo(content)\n break\n }\n case 'warning': {\n renderWarning(content)\n break\n }\n case 'error': {\n renderError(content)\n throw new Error('abort')\n }\n }\n cacheStore(`notification-${notification.id}`, new Date().getTime().toString())\n })\n}\n\n/**\n * Get notifications list from cache, that is updated in the background from bin/fetch-notifications.json.\n *\n * @returns A Notifications object.\n */\nexport async function getNotifications(): Promise<Notifications> {\n const cacheKey: NotificationsKey = `notifications-${url()}`\n const rawNotifications = cacheRetrieve(cacheKey)?.value as unknown as string\n if (!rawNotifications) throw new Error(EMPTY_CACHE_MESSAGE)\n const notifications: object = JSON.parse(rawNotifications)\n return NotificationsSchema.parse(notifications)\n}\n\n/**\n * Fetch notifications from the CDN and chache them.\n *\n * @returns A string with the notifications.\n */\nexport async function fetchNotifications(): Promise<Notifications> {\n outputDebug(`Fetching notifications...`)\n const response = await fetch(url(), undefined, {\n useNetworkLevelRetry: false,\n useAbortSignal: true,\n timeoutMs: 3 * 1000,\n })\n if (response.status !== 200) throw new Error(`Failed to fetch notifications: ${response.statusText}`)\n const rawNotifications = await response.text()\n const notifications: object = JSON.parse(rawNotifications)\n const result = NotificationsSchema.parse(notifications)\n await cacheNotifications(rawNotifications)\n return result\n}\n\n/**\n * Store the notifications in the cache.\n *\n * @param notifications - String with the notifications to cache.\n * @returns A Notifications object.\n */\nasync function cacheNotifications(notifications: string): Promise<void> {\n cacheStore(`notifications-${url()}`, notifications)\n outputDebug(`Notifications from ${url()} stored in the cache`)\n}\n\n/**\n * Fetch notifications in background as a detached process.\n *\n * @param currentCommand - The current Shopify command being run.\n * @param argv - The arguments passed to the current process.\n * @param environment - Process environment variables.\n */\nexport function fetchNotificationsInBackground(\n currentCommand: string,\n argv = process.argv,\n environment: NodeJS.ProcessEnv = process.env,\n): void {\n if (skipNotifications(currentCommand, environment)) return\n if (!argv[0] || !argv[1]) return\n\n // Run the Shopify command the same way as the current execution\n const nodeBinary = argv[0]\n const shopifyBinary = argv[1]\n const args = [shopifyBinary, 'notifications', 'list', '--ignore-errors']\n\n // eslint-disable-next-line no-void\n void exec(nodeBinary, args, {\n background: true,\n env: {...process.env, SHOPIFY_CLI_NO_ANALYTICS: '1'},\n externalErrorHandler: async (error: unknown) => {\n outputDebug(`Failed to fetch notifications in background: ${(error as Error).message}`)\n },\n })\n}\n\n/**\n * Filters notifications based on the version of the CLI.\n *\n * @param notifications - The notifications to filter.\n * @param commandId - The command ID to filter by.\n * @param currentSurfaces - The surfaces present in the current project (usually for app extensions).\n * @param today - The current date.\n * @param currentVersion - The current version of the CLI.\n * @returns - The filtered notifications.\n */\nexport function filterNotifications(\n notifications: Notification[],\n commandId: string,\n currentSurfaces?: string[],\n today: Date = new Date(new Date().setUTCHours(0, 0, 0, 0)),\n currentVersion: string = CLI_KIT_VERSION,\n): Notification[] {\n return notifications\n .filter((notification) => filterByVersion(notification, currentVersion))\n .filter((notifications) => filterByDate(notifications, today))\n .filter((notification) => filterByCommand(notification, commandId))\n .filter((notification) => filterBySurface(notification, commandId, currentSurfaces))\n .filter((notification) => filterByFrequency(notification))\n}\n\n/**\n * Filters notifications based on the version of the CLI.\n *\n * @param notification - The notification to filter.\n * @param currentVersion - The current version of the CLI.\n */\nfunction filterByVersion(notification: Notification, currentVersion: string) {\n const minVersion = !notification.minVersion || versionSatisfies(currentVersion, `>=${notification.minVersion}`)\n const maxVersion = !notification.maxVersion || versionSatisfies(currentVersion, `<=${notification.maxVersion}`)\n return minVersion && maxVersion\n}\n\n/**\n * Filters notifications based on the date.\n *\n * @param notification - The notification to filter.\n * @param today - The current date.\n */\nfunction filterByDate(notification: Notification, today: Date) {\n const minDate = !notification.minDate || new Date(notification.minDate) <= today\n const maxDate = !notification.maxDate || new Date(notification.maxDate) >= today\n return minDate && maxDate\n}\n\n/**\n * Filters notifications based on the command ID.\n *\n * @param notification - The notification to filter.\n * @param commandId - The command ID to filter by.\n * @returns - A boolean indicating whether the notification should be shown.\n */\nfunction filterByCommand(notification: Notification, commandId: string) {\n if (commandId === '') return true\n return !notification.commands || notification.commands.includes(commandId)\n}\n\n/**\n * Filters notifications based on the surface.\n *\n * @param notification - The notification to filter.\n * @param commandId - The command id.\n * @param surfacesFromContext - The surfaces present in the current project (usually for app extensions).\n * @returns - A boolean indicating whether the notification should be shown.\n */\nfunction filterBySurface(notification: Notification, commandId: string, surfacesFromContext?: string[]) {\n const surfaceFromCommand = commandId.split(':')[0] ?? 'all'\n const notificationSurface = notification.surface ?? 'all'\n\n if (surfacesFromContext) return surfacesFromContext.includes(notificationSurface)\n\n return notificationSurface === surfaceFromCommand || notificationSurface === 'all'\n}\n\n/**\n * Filters notifications based on the frequency.\n *\n * @param notification - The notification to filter.\n * @returns - A boolean indicating whether the notification should be shown.\n */\nfunction filterByFrequency(notification: Notification): boolean {\n if (!notification.frequency) return true\n const cacheKey: NotificationKey = `notification-${notification.id}`\n const lastShown = cacheRetrieve(cacheKey)?.value as unknown as string\n if (!lastShown) return true\n\n switch (notification.frequency) {\n case 'always': {\n return true\n }\n case 'once': {\n return false\n }\n case 'once_a_day': {\n return new Date().getTime() - Number(lastShown) > 24 * 3600 * 1000\n }\n case 'once_a_week': {\n return new Date().getTime() - Number(lastShown) > 7 * 24 * 3600 * 1000\n }\n }\n}\n\n/**\n * Returns a string with the filters from a notification, one by line.\n *\n * @param notification - The notification to get the filters from.\n * @returns A string with human-readable filters from the notification.\n */\nexport function stringifyFilters(notification: Notification): string {\n const filters = []\n if (notification.minDate) filters.push(`from ${notification.minDate}`)\n if (notification.maxDate) filters.push(`to ${notification.maxDate}`)\n if (notification.minVersion) filters.push(`from v${notification.minVersion}`)\n if (notification.maxVersion) filters.push(`to v${notification.maxVersion}`)\n if (notification.frequency === 'once') filters.push('show only once')\n if (notification.frequency === 'once_a_day') filters.push('show once a day')\n if (notification.frequency === 'once_a_week') filters.push('show once a week')\n if (notification.surface) filters.push(`surface = ${notification.surface}`)\n if (notification.commands) filters.push(`commands = ${notification.commands.join(', ')}`)\n return filters.join('\\n')\n}\n"]}
|
|
@@ -63,9 +63,17 @@ export declare let collectedLogs: {
|
|
|
63
63
|
export declare function collectLog(key: string, content: OutputMessage): void;
|
|
64
64
|
export declare const clearCollectedLogs: () => void;
|
|
65
65
|
/**
|
|
66
|
-
*
|
|
66
|
+
* Outputs command result information to the user.
|
|
67
|
+
* Result messages don't get additional formatting.
|
|
68
|
+
* The messages are logged at info level to stdout.
|
|
69
|
+
*
|
|
70
|
+
* @param content - The content to be output to the user.
|
|
71
|
+
*/
|
|
72
|
+
export declare function outputResult(content: OutputMessage): void;
|
|
73
|
+
/**
|
|
74
|
+
* Logs information at the info level.
|
|
67
75
|
* Info messages don't get additional formatting.
|
|
68
|
-
* Note:
|
|
76
|
+
* Note: By default, info messages are sent through the standard error.
|
|
69
77
|
*
|
|
70
78
|
* @param content - The content to be output to the user.
|
|
71
79
|
* @param logger - The logging function to use to output to the user.
|
|
@@ -74,7 +82,7 @@ export declare function outputInfo(content: OutputMessage, logger?: Logger): voi
|
|
|
74
82
|
/**
|
|
75
83
|
* Outputs a success message to the user.
|
|
76
84
|
* Success messages receive a special formatting to make them stand out in the console.
|
|
77
|
-
* Note: Success messages are sent through the standard
|
|
85
|
+
* Note: Success messages are sent through the standard error.
|
|
78
86
|
*
|
|
79
87
|
* @param content - The content to be output to the user.
|
|
80
88
|
* @param logger - The logging function to use to output to the user.
|
|
@@ -83,25 +91,25 @@ export declare function outputSuccess(content: OutputMessage, logger?: Logger):
|
|
|
83
91
|
/**
|
|
84
92
|
* Outputs a completed message to the user.
|
|
85
93
|
* Completed message receive a special formatting to make them stand out in the console.
|
|
86
|
-
* Note: Completed messages are sent through the standard
|
|
94
|
+
* Note: Completed messages are sent through the standard error.
|
|
87
95
|
*
|
|
88
96
|
* @param content - The content to be output to the user.
|
|
89
97
|
* @param logger - The logging function to use to output to the user.
|
|
90
98
|
*/
|
|
91
99
|
export declare function outputCompleted(content: OutputMessage, logger?: Logger): void;
|
|
92
100
|
/**
|
|
93
|
-
*
|
|
101
|
+
* Logs a message at the debug level. By default these output is hidden unless the user calls the CLI with --verbose.
|
|
94
102
|
* Debug messages don't get additional formatting.
|
|
95
|
-
* Note:
|
|
103
|
+
* Note: By default, debug messages are sent through the standard error.
|
|
96
104
|
*
|
|
97
105
|
* @param content - The content to be output to the user.
|
|
98
106
|
* @param logger - The logging function to use to output to the user.
|
|
99
107
|
*/
|
|
100
108
|
export declare function outputDebug(content: OutputMessage, logger?: Logger): void;
|
|
101
109
|
/**
|
|
102
|
-
*
|
|
110
|
+
* Logs a message at the warning level.
|
|
103
111
|
* Warning messages receive a special formatting to make them stand out in the console.
|
|
104
|
-
* Note:
|
|
112
|
+
* Note: By default, warning messages are sent through the standard error.
|
|
105
113
|
*
|
|
106
114
|
* @param content - The content to be output to the user.
|
|
107
115
|
* @param logger - The logging function to use to output to the user.
|
|
@@ -138,24 +146,6 @@ export interface OutputProcess {
|
|
|
138
146
|
*/
|
|
139
147
|
action: (stdout: Writable, stderr: Writable, signal: AbortSignal) => Promise<void>;
|
|
140
148
|
}
|
|
141
|
-
/**
|
|
142
|
-
* Prints a log message in the console.
|
|
143
|
-
*
|
|
144
|
-
* @param message - The message to print.
|
|
145
|
-
*/
|
|
146
|
-
export declare function consoleLog(message: string): void;
|
|
147
|
-
/**
|
|
148
|
-
* Prints an error message in the console.
|
|
149
|
-
*
|
|
150
|
-
* @param message - The message to print.
|
|
151
|
-
*/
|
|
152
|
-
export declare function consoleError(message: string): void;
|
|
153
|
-
/**
|
|
154
|
-
* Prints a warning message in the console.
|
|
155
|
-
*
|
|
156
|
-
* @param message - The message to print.
|
|
157
|
-
*/
|
|
158
|
-
export declare function consoleWarn(message: string): void;
|
|
159
149
|
/**
|
|
160
150
|
* Writes a message to the appropiated logger.
|
|
161
151
|
*
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/* eslint-disable no-console */
|
|
2
1
|
import { isUnitTest, isVerbose } from './context/local.js';
|
|
3
2
|
import { currentProcessIsGlobal } from './is-global.js';
|
|
4
3
|
import colors from './colors.js';
|
|
5
4
|
import { isTruthy } from './context/utilities.js';
|
|
6
5
|
import { ColorContentToken, CommandContentToken, ErrorContentToken, HeadingContentToken, ItalicContentToken, JsonContentToken, LinesDiffContentToken, LinkContentToken, PathContentToken, RawContentToken, SubHeadingContentToken, } from '../../private/node/content-tokens.js';
|
|
7
6
|
import { tokenItemToString } from '../../private/node/ui/components/TokenizedText.js';
|
|
7
|
+
import { consoleLog, consoleWarn, output } from '../../private/node/output.js';
|
|
8
8
|
import stripAnsi from 'strip-ansi';
|
|
9
9
|
import { Writable } from 'stream';
|
|
10
10
|
export class TokenizedString {
|
|
@@ -204,19 +204,27 @@ export function collectLog(key, content) {
|
|
|
204
204
|
collectedLogs.output = output;
|
|
205
205
|
}
|
|
206
206
|
export const clearCollectedLogs = () => {
|
|
207
|
-
// console.log('clearCollectLogs')
|
|
208
207
|
collectedLogs = {};
|
|
209
|
-
// console.log(collectedLogs)
|
|
210
208
|
};
|
|
211
209
|
/**
|
|
212
|
-
*
|
|
210
|
+
* Outputs command result information to the user.
|
|
211
|
+
* Result messages don't get additional formatting.
|
|
212
|
+
* The messages are logged at info level to stdout.
|
|
213
|
+
*
|
|
214
|
+
* @param content - The content to be output to the user.
|
|
215
|
+
*/
|
|
216
|
+
export function outputResult(content) {
|
|
217
|
+
output(content, 'info', consoleLog);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Logs information at the info level.
|
|
213
221
|
* Info messages don't get additional formatting.
|
|
214
|
-
* Note:
|
|
222
|
+
* Note: By default, info messages are sent through the standard error.
|
|
215
223
|
*
|
|
216
224
|
* @param content - The content to be output to the user.
|
|
217
225
|
* @param logger - The logging function to use to output to the user.
|
|
218
226
|
*/
|
|
219
|
-
export function outputInfo(content, logger =
|
|
227
|
+
export function outputInfo(content, logger = consoleWarn) {
|
|
220
228
|
const message = stringifyMessage(content);
|
|
221
229
|
if (isUnitTest())
|
|
222
230
|
collectLog('info', content);
|
|
@@ -225,12 +233,12 @@ export function outputInfo(content, logger = consoleLog) {
|
|
|
225
233
|
/**
|
|
226
234
|
* Outputs a success message to the user.
|
|
227
235
|
* Success messages receive a special formatting to make them stand out in the console.
|
|
228
|
-
* Note: Success messages are sent through the standard
|
|
236
|
+
* Note: Success messages are sent through the standard error.
|
|
229
237
|
*
|
|
230
238
|
* @param content - The content to be output to the user.
|
|
231
239
|
* @param logger - The logging function to use to output to the user.
|
|
232
240
|
*/
|
|
233
|
-
export function outputSuccess(content, logger =
|
|
241
|
+
export function outputSuccess(content, logger = consoleWarn) {
|
|
234
242
|
const message = colors.bold(`✅ Success! ${stringifyMessage(content)}.`);
|
|
235
243
|
if (isUnitTest())
|
|
236
244
|
collectLog('success', content);
|
|
@@ -239,35 +247,35 @@ export function outputSuccess(content, logger = consoleLog) {
|
|
|
239
247
|
/**
|
|
240
248
|
* Outputs a completed message to the user.
|
|
241
249
|
* Completed message receive a special formatting to make them stand out in the console.
|
|
242
|
-
* Note: Completed messages are sent through the standard
|
|
250
|
+
* Note: Completed messages are sent through the standard error.
|
|
243
251
|
*
|
|
244
252
|
* @param content - The content to be output to the user.
|
|
245
253
|
* @param logger - The logging function to use to output to the user.
|
|
246
254
|
*/
|
|
247
|
-
export function outputCompleted(content, logger =
|
|
255
|
+
export function outputCompleted(content, logger = consoleWarn) {
|
|
248
256
|
const message = `${colors.green('✔')} ${stringifyMessage(content)}`;
|
|
249
257
|
if (isUnitTest())
|
|
250
258
|
collectLog('completed', content);
|
|
251
259
|
outputWhereAppropriate('info', logger, message);
|
|
252
260
|
}
|
|
253
261
|
/**
|
|
254
|
-
*
|
|
262
|
+
* Logs a message at the debug level. By default these output is hidden unless the user calls the CLI with --verbose.
|
|
255
263
|
* Debug messages don't get additional formatting.
|
|
256
|
-
* Note:
|
|
264
|
+
* Note: By default, debug messages are sent through the standard error.
|
|
257
265
|
*
|
|
258
266
|
* @param content - The content to be output to the user.
|
|
259
267
|
* @param logger - The logging function to use to output to the user.
|
|
260
268
|
*/
|
|
261
|
-
export function outputDebug(content, logger =
|
|
269
|
+
export function outputDebug(content, logger = consoleWarn) {
|
|
262
270
|
if (isUnitTest())
|
|
263
271
|
collectLog('debug', content);
|
|
264
272
|
const message = colors.gray(stringifyMessage(content));
|
|
265
273
|
outputWhereAppropriate('debug', logger, `${new Date().toISOString()}: ${message}`);
|
|
266
274
|
}
|
|
267
275
|
/**
|
|
268
|
-
*
|
|
276
|
+
* Logs a message at the warning level.
|
|
269
277
|
* Warning messages receive a special formatting to make them stand out in the console.
|
|
270
|
-
* Note:
|
|
278
|
+
* Note: By default, warning messages are sent through the standard error.
|
|
271
279
|
*
|
|
272
280
|
* @param content - The content to be output to the user.
|
|
273
281
|
* @param logger - The logging function to use to output to the user.
|
|
@@ -282,7 +290,7 @@ export function outputWarn(content, logger = consoleWarn) {
|
|
|
282
290
|
* Prints a new line in the terminal.
|
|
283
291
|
*/
|
|
284
292
|
export function outputNewline() {
|
|
285
|
-
|
|
293
|
+
consoleWarn('');
|
|
286
294
|
}
|
|
287
295
|
/**
|
|
288
296
|
* Converts a Message to string.
|
|
@@ -307,30 +315,6 @@ export function stringifyMessage(message) {
|
|
|
307
315
|
export function itemToString(item) {
|
|
308
316
|
return tokenItemToString(item);
|
|
309
317
|
}
|
|
310
|
-
/**
|
|
311
|
-
* Prints a log message in the console.
|
|
312
|
-
*
|
|
313
|
-
* @param message - The message to print.
|
|
314
|
-
*/
|
|
315
|
-
export function consoleLog(message) {
|
|
316
|
-
process.stdout.write(`${withOrWithoutStyle(message)}\n`);
|
|
317
|
-
}
|
|
318
|
-
/**
|
|
319
|
-
* Prints an error message in the console.
|
|
320
|
-
*
|
|
321
|
-
* @param message - The message to print.
|
|
322
|
-
*/
|
|
323
|
-
export function consoleError(message) {
|
|
324
|
-
process.stderr.write(`${withOrWithoutStyle(message)}\n`);
|
|
325
|
-
}
|
|
326
|
-
/**
|
|
327
|
-
* Prints a warning message in the console.
|
|
328
|
-
*
|
|
329
|
-
* @param message - The message to print.
|
|
330
|
-
*/
|
|
331
|
-
export function consoleWarn(message) {
|
|
332
|
-
process.stderr.write(`${withOrWithoutStyle(message)}\n`);
|
|
333
|
-
}
|
|
334
318
|
/**
|
|
335
319
|
* Writes a message to the appropiated logger.
|
|
336
320
|
*
|
|
@@ -348,20 +332,6 @@ export function outputWhereAppropriate(logLevel, logger, message) {
|
|
|
348
332
|
}
|
|
349
333
|
}
|
|
350
334
|
}
|
|
351
|
-
/**
|
|
352
|
-
* Returns a colored or uncolored version of a message, depending on the environment.
|
|
353
|
-
*
|
|
354
|
-
* @param message - The message to color or not.
|
|
355
|
-
* @returns The message with or without colors.
|
|
356
|
-
*/
|
|
357
|
-
function withOrWithoutStyle(message) {
|
|
358
|
-
if (shouldDisplayColors()) {
|
|
359
|
-
return message;
|
|
360
|
-
}
|
|
361
|
-
else {
|
|
362
|
-
return unstyled(message);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
335
|
/**
|
|
366
336
|
* Returns a message without styles (colors or any ANSI escape codes).
|
|
367
337
|
*
|
|
@@ -397,5 +367,4 @@ export function formatSection(title, body) {
|
|
|
397
367
|
const formattedTitle = `${title.toUpperCase()}${' '.repeat(35 - title.length)}`;
|
|
398
368
|
return outputContent `${outputToken.heading(formattedTitle)}\n${body}`.value;
|
|
399
369
|
}
|
|
400
|
-
/* eslint-enable no-console */
|
|
401
370
|
//# sourceMappingURL=output.js.map
|