@shopify/cli-kit 3.37.0 → 3.38.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/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/private/node/api/graphql.js +7 -7
- package/dist/private/node/api/graphql.js.map +1 -1
- package/dist/{network → private/node}/api.d.ts +0 -0
- package/dist/{network → private/node}/api.js +0 -0
- package/dist/private/node/api.js.map +1 -0
- package/dist/private/node/conf-store.js +4 -4
- package/dist/private/node/conf-store.js.map +1 -1
- package/dist/{content-tokens.d.ts → private/node/content-tokens.d.ts} +11 -11
- package/dist/{content-tokens.js → private/node/content-tokens.js} +3 -3
- package/dist/private/node/content-tokens.js.map +1 -0
- package/dist/private/node/secure-store.js +4 -4
- package/dist/private/node/secure-store.js.map +1 -1
- package/dist/private/node/session/authorize.js +3 -3
- package/dist/private/node/session/authorize.js.map +1 -1
- package/dist/private/node/session/device-authorization.js +6 -6
- package/dist/private/node/session/device-authorization.js.map +1 -1
- package/dist/private/node/session/exchange.js.map +1 -1
- package/dist/private/node/session/identity-token-validation.js +5 -5
- package/dist/private/node/session/identity-token-validation.js.map +1 -1
- package/dist/private/node/session/identity.d.ts +1 -1
- package/dist/private/node/session/identity.js.map +1 -1
- package/dist/private/node/session/redirect-listener.js +2 -2
- package/dist/private/node/session/redirect-listener.js.map +1 -1
- package/dist/private/node/session/scopes.d.ts +1 -1
- package/dist/private/node/session/scopes.js +1 -1
- package/dist/private/node/session/scopes.js.map +1 -1
- package/dist/private/node/session/store.js +4 -4
- package/dist/private/node/session/store.js.map +1 -1
- package/dist/private/node/session/validate.js +2 -2
- package/dist/private/node/session/validate.js.map +1 -1
- package/dist/private/node/session.js +19 -19
- package/dist/private/node/session.js.map +1 -1
- package/dist/private/node/ui/alert.js +1 -1
- package/dist/private/node/ui/alert.js.map +1 -1
- package/dist/private/node/ui/components/Alert.test.js +1 -1
- package/dist/private/node/ui/components/Alert.test.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.d.ts +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.js.map +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.test.js +1 -1
- package/dist/private/node/ui/components/ConcurrentOutput.test.js.map +1 -1
- package/dist/private/node/ui/components/FatalError.test.js +1 -1
- package/dist/private/node/ui/components/FatalError.test.js.map +1 -1
- package/dist/private/node/ui/components/List.test.js +1 -1
- package/dist/private/node/ui/components/List.test.js.map +1 -1
- package/dist/private/node/ui/components/SelectPrompt.test.js +1 -1
- package/dist/private/node/ui/components/SelectPrompt.test.js.map +1 -1
- package/dist/private/node/ui/components/Tasks.test.js +1 -1
- package/dist/private/node/ui/components/Tasks.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/components/TokenizedText.test.js +1 -1
- package/dist/private/node/ui/components/TokenizedText.test.js.map +1 -1
- package/dist/private/node/ui.d.ts +1 -1
- package/dist/private/node/ui.js +1 -1
- package/dist/private/node/ui.js.map +1 -1
- package/dist/public/common/string.js +1 -1
- package/dist/public/common/string.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/analytics.js +5 -5
- package/dist/public/node/analytics.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/archiver.js +2 -2
- package/dist/public/node/archiver.js.map +1 -1
- package/dist/public/node/base-command.js +4 -4
- package/dist/public/node/base-command.js.map +1 -1
- package/dist/public/node/dot-env.js +2 -2
- package/dist/public/node/dot-env.js.map +1 -1
- package/dist/public/node/environment/spin.js +2 -2
- package/dist/public/node/environment/spin.js.map +1 -1
- package/dist/public/node/error-handler.js +3 -3
- package/dist/public/node/error-handler.js.map +1 -1
- package/dist/public/node/error.d.ts +5 -5
- package/dist/public/node/error.js +1 -1
- package/dist/public/node/error.js.map +1 -1
- package/dist/public/node/fs.js +19 -19
- package/dist/public/node/fs.js.map +1 -1
- package/dist/public/node/git.js +8 -8
- package/dist/public/node/git.js.map +1 -1
- package/dist/public/node/github.js +2 -2
- package/dist/public/node/github.js.map +1 -1
- package/dist/public/node/hooks/postrun.js +2 -2
- package/dist/public/node/hooks/postrun.js.map +1 -1
- package/dist/public/node/hooks/prerun.js +2 -2
- package/dist/public/node/hooks/prerun.js.map +1 -1
- package/dist/public/node/http.js +3 -3
- package/dist/public/node/http.js.map +1 -1
- package/dist/public/node/liquid.js +2 -2
- package/dist/public/node/liquid.js.map +1 -1
- package/dist/public/node/monorail.js +4 -4
- package/dist/public/node/monorail.js.map +1 -1
- package/dist/public/node/node-package-manager.js +9 -9
- package/dist/public/node/node-package-manager.js.map +1 -1
- package/dist/public/node/os.js +2 -2
- package/dist/public/node/os.js.map +1 -1
- package/dist/{output.d.ts → public/node/output.d.ts} +100 -41
- package/dist/{output.js → public/node/output.js} +129 -50
- package/dist/public/node/output.js.map +1 -0
- package/dist/public/node/ruby.js +7 -5
- package/dist/public/node/ruby.js.map +1 -1
- package/dist/public/node/session.js +9 -9
- package/dist/public/node/session.js.map +1 -1
- package/dist/public/node/system.js +2 -2
- package/dist/public/node/system.js.map +1 -1
- package/dist/public/node/tcp.js +4 -4
- package/dist/public/node/tcp.js.map +1 -1
- package/dist/public/node/testing/output.js +10 -9
- package/dist/public/node/testing/output.js.map +1 -1
- package/dist/public/node/ui.d.ts +1 -1
- package/dist/public/node/ui.js +1 -1
- package/dist/public/node/ui.js.map +1 -1
- package/dist/public/node/vscode.js +4 -4
- package/dist/public/node/vscode.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui.js +9 -9
- package/dist/ui.js.map +1 -1
- package/package.json +1 -1
- package/dist/content-tokens.js.map +0 -1
- package/dist/network/api.js.map +0 -1
- package/dist/output.js.map +0 -1
|
@@ -4,7 +4,7 @@ import { AbortController } from './abort.js';
|
|
|
4
4
|
import { exec } from './system.js';
|
|
5
5
|
import { fileExists, readFile, writeFile, findPathUp, glob } from './fs.js';
|
|
6
6
|
import { dirname, joinPath } from './path.js';
|
|
7
|
-
import {
|
|
7
|
+
import { outputToken, outputContent, outputDebug } from '../../public/node/output.js';
|
|
8
8
|
import latestVersion from 'latest-version';
|
|
9
9
|
/** The name of the Yarn lock file */
|
|
10
10
|
export const yarnLockfile = 'yarn.lock';
|
|
@@ -36,7 +36,7 @@ export const PackageJsonNotFoundError = (directory) => {
|
|
|
36
36
|
* @returns An abort error.
|
|
37
37
|
*/
|
|
38
38
|
export const FindUpAndReadPackageJsonNotFoundError = (directory) => {
|
|
39
|
-
return new BugError(
|
|
39
|
+
return new BugError(outputContent `Couldn't find a a package.json traversing directories from ${outputToken.path(directory)}`);
|
|
40
40
|
};
|
|
41
41
|
/**
|
|
42
42
|
* Returns the dependency manager used to run the create workflow.
|
|
@@ -66,7 +66,7 @@ export async function getPackageManager(fromDirectory) {
|
|
|
66
66
|
throw FindUpAndReadPackageJsonNotFoundError(fromDirectory);
|
|
67
67
|
}
|
|
68
68
|
const directory = dirname(packageJson);
|
|
69
|
-
|
|
69
|
+
outputDebug(outputContent `Obtaining the dependency manager in directory ${outputToken.path(directory)}...`);
|
|
70
70
|
const yarnLockPath = joinPath(directory, yarnLockfile);
|
|
71
71
|
const pnpmLockPath = joinPath(directory, pnpmLockfile);
|
|
72
72
|
if (await fileExists(yarnLockPath)) {
|
|
@@ -164,7 +164,7 @@ export async function usesWorkspaces(appDirectory) {
|
|
|
164
164
|
* @returns A promise that resolves with a more recent version or undefined if there's no more recent version.
|
|
165
165
|
*/
|
|
166
166
|
export async function checkForNewVersion(dependency, currentVersion) {
|
|
167
|
-
|
|
167
|
+
outputDebug(outputContent `Checking if there's a version of ${dependency} newer than ${currentVersion}`);
|
|
168
168
|
try {
|
|
169
169
|
const lastVersion = await getLatestNPMPackageVersion(dependency);
|
|
170
170
|
if (lastVersion && new Version(currentVersion).compare(lastVersion) < 0) {
|
|
@@ -198,10 +198,10 @@ export async function readAndParsePackageJson(packageJsonPath) {
|
|
|
198
198
|
* @param options - Options for adding dependencies.
|
|
199
199
|
*/
|
|
200
200
|
export async function addNPMDependenciesIfNeeded(dependencies, options) {
|
|
201
|
-
|
|
202
|
-
${
|
|
201
|
+
outputDebug(outputContent `Adding the following dependencies if needed:
|
|
202
|
+
${outputToken.json(dependencies)}
|
|
203
203
|
With options:
|
|
204
|
-
${
|
|
204
|
+
${outputToken.json(options)}
|
|
205
205
|
`);
|
|
206
206
|
const packageJsonPath = joinPath(options.directory, 'package.json');
|
|
207
207
|
if (!(await fileExists(packageJsonPath))) {
|
|
@@ -351,7 +351,7 @@ export async function addResolutionOrOverride(directory, dependencies) {
|
|
|
351
351
|
* @returns A promise to get the latest available version of a package.
|
|
352
352
|
*/
|
|
353
353
|
async function getLatestNPMPackageVersion(name) {
|
|
354
|
-
|
|
354
|
+
outputDebug(outputContent `Getting the latest version of NPM package: ${outputToken.raw(name)}`);
|
|
355
355
|
return latestVersion(name);
|
|
356
356
|
}
|
|
357
357
|
/**
|
|
@@ -361,7 +361,7 @@ async function getLatestNPMPackageVersion(name) {
|
|
|
361
361
|
* @param packageJSON - Package.json file to write.
|
|
362
362
|
*/
|
|
363
363
|
export async function writePackageJSON(directory, packageJSON) {
|
|
364
|
-
|
|
364
|
+
outputDebug(outputContent `JSON-encoding and writing content to package.json at ${outputToken.path(directory)}...`);
|
|
365
365
|
const packagePath = joinPath(directory, 'package.json');
|
|
366
366
|
await writeFile(packagePath, JSON.stringify(packageJSON, null, 2));
|
|
367
367
|
}
|
|
@@ -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,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;YAC7D,CAAC,CAAC,EAAC,GAAG,kBAAkB,CAAC,WAAW,EAAE,GAAG,YAAY,EAAC;YACtD,CAAC,CAAC,YAAY,CAAA;KACjB;IACD,IAAI,cAAc,KAAK,KAAK,IAAI,cAAc,KAAK,MAAM,EAAE;QACzD,kBAAkB,CAAC,SAAS,GAAG,kBAAkB,CAAC,SAAS;YACzD,CAAC,CAAC,EAAC,GAAG,kBAAkB,CAAC,SAAS,EAAE,GAAG,YAAY,EAAC;YACpD,CAAC,CAAC,YAAY,CAAA;KACjB;IAED,MAAM,SAAS,CAAC,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AAC/E,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,0BAA0B,CAAC,IAAY;IACpD,KAAK,CAAC,OAAO,CAAA,8CAA8C,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC7E,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;AAC5B,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,SAAiB,EAAE,WAAwB;IAChF,KAAK,CAAC,OAAO,CAAA,wDAAwD,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAChG,MAAM,WAAW,GAAG,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;IACvD,MAAM,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AACpE,CAAC","sourcesContent":["import {AbortError, BugError} from './error.js'\nimport {Version} from './semver.js'\nimport {AbortController, AbortSignal} from './abort.js'\nimport {exec} from './system.js'\nimport {fileExists, readFile, writeFile, findPathUp, glob} from './fs.js'\nimport {dirname, joinPath} from './path.js'\nimport {token, content, debug} from '../../output.js'\nimport latestVersion from 'latest-version'\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 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]\nexport type Lockfile = 'yarn.lock' | 'package-lock.json' | 'pnpm-lock.yaml'\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'] as const\nexport type PackageManager = typeof packageManager[number]\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 const PackageJsonNotFoundError = (directory: string): AbortError => {\n return new AbortError(`The directory ${directory} doesn't have a package.json.`)\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 const FindUpAndReadPackageJsonNotFoundError = (directory: string): BugError => {\n return new BugError(content`Couldn't find a a package.json traversing directories from ${token.path(directory)}`)\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 packageManagerUsedForCreating(env = process.env): PackageManager | 'unknown' {\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('npm')) {\n return 'npm'\n }\n return 'unknown'\n}\n\n/**\n * Returns the dependency manager used by an existing project.\n * @param fromDirectory - The starting directory\n * @returns The dependency manager\n */\nexport async function getPackageManager(fromDirectory: string): Promise<PackageManager> {\n const packageJson = await findPathUp('package.json', {cwd: fromDirectory, type: 'file'})\n if (!packageJson) {\n throw FindUpAndReadPackageJsonNotFoundError(fromDirectory)\n }\n const directory = dirname(packageJson)\n debug(content`Obtaining the dependency manager in directory ${token.path(directory)}...`)\n const yarnLockPath = joinPath(directory, yarnLockfile)\n const pnpmLockPath = joinPath(directory, pnpmLockfile)\n if (await fileExists(yarnLockPath)) {\n return 'yarn'\n } else if (await fileExists(pnpmLockPath)) {\n return 'pnpm'\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 exec(options.packageManager, args, execOptions)\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/**\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 * @returns A promise that resolves with a more recent version or undefined if there's no more recent version.\n */\nexport async function checkForNewVersion(dependency: string, currentVersion: string): Promise<string | undefined> {\n debug(content`Checking if there's a version of ${dependency} newer than ${currentVersion}`)\n try {\n const lastVersion = await getLatestNPMPackageVersion(dependency)\n if (lastVersion && new Version(currentVersion).compare(lastVersion) < 0) {\n return lastVersion\n } else {\n return undefined\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n return undefined\n }\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 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/**\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 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\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 debug(content`Adding the following dependencies if needed:\n${token.json(dependencies)}\nWith options:\n${token.json(options)}\n `)\n const packageJsonPath = joinPath(options.directory, 'package.json')\n if (!(await fileExists(packageJsonPath))) {\n throw PackageJsonNotFoundError(options.directory)\n }\n const existingDependencies = Object.keys(await getDependencies(packageJsonPath))\n let dependenciesToAdd = dependencies\n 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 let args: string[]\n const depedenciesWithVersion = dependencies.map((dep) => {\n return dep.version ? `${dep.name}@${dep.version}` : dep.name\n })\n switch (options.packageManager) {\n case 'npm':\n args = argumentsToAddDependenciesWithNPM(depedenciesWithVersion, options.type)\n break\n case 'yarn':\n args = argumentsToAddDependenciesWithYarn(depedenciesWithVersion, options.type)\n break\n case 'pnpm':\n args = argumentsToAddDependenciesWithPNPM(depedenciesWithVersion, options.type)\n break\n }\n options.stdout?.write(`Executing... ${[options.packageManager, ...args].join(' ')}`)\n await exec(options.packageManager, args, {\n cwd: options.directory,\n stdout: options.stdout,\n stderr: options.stderr,\n signal: options.signal,\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(dependencies: string[], type: DependencyType): string[] {\n let command = ['install']\n command = command.concat(dependencies)\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 Yarn.\n * @param dependencies - The list of dependencies to add\n * @param type - The dependency type.\n * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithYarn(dependencies: string[], type: DependencyType): string[] {\n let command = ['add']\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 * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithPNPM(dependencies: string[], type: DependencyType): string[] {\n let command = ['add']\n command = command.concat(dependencies)\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 * 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 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') {\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 debug(content`Getting the latest version of NPM package: ${token.raw(name)}`)\n return latestVersion(name)\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 debug(content`JSON-encoding and writing content to package.json at ${token.path(directory)}...`)\n const packagePath = joinPath(directory, 'package.json')\n await writeFile(packagePath, JSON.stringify(packageJSON, null, 2))\n}\n"]}
|
|
1
|
+
{"version":3,"file":"node-package-manager.js","sourceRoot":"","sources":["../../../src/public/node/node-package-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAE,QAAQ,EAAC,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAC,OAAO,EAAC,MAAM,aAAa,CAAA;AACnC,OAAO,EAAC,eAAe,EAAc,MAAM,YAAY,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EAAC;YACtD,CAAC,CAAC,YAAY,CAAA;KACjB;IACD,IAAI,cAAc,KAAK,KAAK,IAAI,cAAc,KAAK,MAAM,EAAE;QACzD,kBAAkB,CAAC,SAAS,GAAG,kBAAkB,CAAC,SAAS;YACzD,CAAC,CAAC,EAAC,GAAG,kBAAkB,CAAC,SAAS,EAAE,GAAG,YAAY,EAAC;YACpD,CAAC,CAAC,YAAY,CAAA;KACjB;IAED,MAAM,SAAS,CAAC,eAAe,EAAE,IAAI,CAAC,SAAS,CAAC,kBAAkB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AAC/E,CAAC;AAED;;;;GAIG;AACH,KAAK,UAAU,0BAA0B,CAAC,IAAY;IACpD,WAAW,CAAC,aAAa,CAAA,8CAA8C,WAAW,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC/F,OAAO,aAAa,CAAC,IAAI,CAAC,CAAA;AAC5B,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,SAAiB,EAAE,WAAwB;IAChF,WAAW,CAAC,aAAa,CAAA,wDAAwD,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAClH,MAAM,WAAW,GAAG,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC,CAAA;IACvD,MAAM,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAA;AACpE,CAAC","sourcesContent":["import {AbortError, BugError} from './error.js'\nimport {Version} from './semver.js'\nimport {AbortController, AbortSignal} from './abort.js'\nimport {exec} from './system.js'\nimport {fileExists, readFile, writeFile, findPathUp, glob} from './fs.js'\nimport {dirname, joinPath} from './path.js'\nimport {outputToken, outputContent, outputDebug} from '../../public/node/output.js'\nimport latestVersion from 'latest-version'\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 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]\nexport type Lockfile = 'yarn.lock' | 'package-lock.json' | 'pnpm-lock.yaml'\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'] as const\nexport type PackageManager = typeof packageManager[number]\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 const PackageJsonNotFoundError = (directory: string): AbortError => {\n return new AbortError(`The directory ${directory} doesn't have a package.json.`)\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 const FindUpAndReadPackageJsonNotFoundError = (directory: string): BugError => {\n return new BugError(\n 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 packageManagerUsedForCreating(env = process.env): PackageManager | 'unknown' {\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('npm')) {\n return 'npm'\n }\n return 'unknown'\n}\n\n/**\n * Returns the dependency manager used by an existing project.\n * @param fromDirectory - The starting directory\n * @returns The dependency manager\n */\nexport async function getPackageManager(fromDirectory: string): Promise<PackageManager> {\n const packageJson = await findPathUp('package.json', {cwd: fromDirectory, type: 'file'})\n if (!packageJson) {\n throw FindUpAndReadPackageJsonNotFoundError(fromDirectory)\n }\n const directory = dirname(packageJson)\n outputDebug(outputContent`Obtaining the dependency manager in directory ${outputToken.path(directory)}...`)\n const yarnLockPath = joinPath(directory, yarnLockfile)\n const pnpmLockPath = joinPath(directory, pnpmLockfile)\n if (await fileExists(yarnLockPath)) {\n return 'yarn'\n } else if (await fileExists(pnpmLockPath)) {\n return 'pnpm'\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 exec(options.packageManager, args, execOptions)\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/**\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 * @returns A promise that resolves with a more recent version or undefined if there's no more recent version.\n */\nexport async function checkForNewVersion(dependency: string, currentVersion: string): Promise<string | undefined> {\n outputDebug(outputContent`Checking if there's a version of ${dependency} newer than ${currentVersion}`)\n try {\n const lastVersion = await getLatestNPMPackageVersion(dependency)\n if (lastVersion && new Version(currentVersion).compare(lastVersion) < 0) {\n return lastVersion\n } else {\n return undefined\n }\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch (error) {\n return undefined\n }\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 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/**\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 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\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 PackageJsonNotFoundError(options.directory)\n }\n const existingDependencies = Object.keys(await getDependencies(packageJsonPath))\n let dependenciesToAdd = dependencies\n 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 let args: string[]\n const depedenciesWithVersion = dependencies.map((dep) => {\n return dep.version ? `${dep.name}@${dep.version}` : dep.name\n })\n switch (options.packageManager) {\n case 'npm':\n args = argumentsToAddDependenciesWithNPM(depedenciesWithVersion, options.type)\n break\n case 'yarn':\n args = argumentsToAddDependenciesWithYarn(depedenciesWithVersion, options.type)\n break\n case 'pnpm':\n args = argumentsToAddDependenciesWithPNPM(depedenciesWithVersion, options.type)\n break\n }\n options.stdout?.write(`Executing... ${[options.packageManager, ...args].join(' ')}`)\n await exec(options.packageManager, args, {\n cwd: options.directory,\n stdout: options.stdout,\n stderr: options.stderr,\n signal: options.signal,\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(dependencies: string[], type: DependencyType): string[] {\n let command = ['install']\n command = command.concat(dependencies)\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 Yarn.\n * @param dependencies - The list of dependencies to add\n * @param type - The dependency type.\n * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithYarn(dependencies: string[], type: DependencyType): string[] {\n let command = ['add']\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 * @returns An array with the arguments.\n */\nfunction argumentsToAddDependenciesWithPNPM(dependencies: string[], type: DependencyType): string[] {\n let command = ['add']\n command = command.concat(dependencies)\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 * 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 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') {\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 latestVersion(name)\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"]}
|
package/dist/public/node/os.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { outputDebug, outputContent } from '../../public/node/output.js';
|
|
2
2
|
import { execa } from 'execa';
|
|
3
3
|
import { userInfo as osUserInfo } from 'os';
|
|
4
4
|
// This code has been vendored from https://github.com/sindresorhus/username
|
|
@@ -9,7 +9,7 @@ import { userInfo as osUserInfo } from 'os';
|
|
|
9
9
|
* @returns The username of the current user.
|
|
10
10
|
*/
|
|
11
11
|
export async function username(platform = process.platform) {
|
|
12
|
-
|
|
12
|
+
outputDebug(outputContent `Obtaining user name...`);
|
|
13
13
|
const environmentVariable = getEnvironmentVariable();
|
|
14
14
|
if (environmentVariable) {
|
|
15
15
|
return environmentVariable;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"os.js","sourceRoot":"","sources":["../../../src/public/node/os.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,
|
|
1
|
+
{"version":3,"file":"os.js","sourceRoot":"","sources":["../../../src/public/node/os.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAE,aAAa,EAAC,MAAM,6BAA6B,CAAA;AACtE,OAAO,EAAC,KAAK,EAAC,MAAM,OAAO,CAAA;AAC3B,OAAO,EAAC,QAAQ,IAAI,UAAU,EAAC,MAAM,IAAI,CAAA;AAEzC,4EAA4E;AAC5E,0EAA0E;AAC1E,iEAAiE;AACjE;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAAC,WAAoC,OAAO,CAAC,QAAQ;IACjF,WAAW,CAAC,aAAa,CAAA,wBAAwB,CAAC,CAAA;IAClD,MAAM,mBAAmB,GAAG,sBAAsB,EAAE,CAAA;IACpD,IAAI,mBAAmB,EAAE;QACvB,OAAO,mBAAmB,CAAA;KAC3B;IAED,MAAM,gBAAgB,GAAG,yBAAyB,EAAE,CAAA;IACpD,IAAI,gBAAgB,EAAE;QACpB,OAAO,gBAAgB,CAAA;KACxB;IAED;;QAEI;IACJ,IAAI;QACF,IAAI,QAAQ,KAAK,OAAO,EAAE;YACxB,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM,KAAK,CAAC,QAAQ,CAAC,CAAA;YACtC,OAAO,mBAAmB,CAAC,MAAM,CAAC,CAAA;SACnC;QAED,MAAM,EAAC,MAAM,EAAE,MAAM,EAAC,GAAG,MA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H,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;AACnC,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAc;IACxC,OAAO,eAAe,MAAM,EAAE,CAAA;AAChC,CAAC","sourcesContent":["import {outputDebug, outputContent} from '../../public/node/output.js'\nimport {execa} from 'execa'\nimport {userInfo as osUserInfo} from 'os'\n\n// This code has been vendored from https://github.com/sindresorhus/username\n// because adding it as a transtive dependency causes conflicts with other\n// packages that haven't been yet migrated to the latest version.\n/**\n * @param platform - The platform to get the username for. Defaults to the current platform.\n * @returns The username of the current user.\n */\nexport async function username(platform: typeof process.platform = process.platform): Promise<string | null> {\n outputDebug(outputContent`Obtaining user name...`)\n const environmentVariable = getEnvironmentVariable()\n if (environmentVariable) {\n return environmentVariable\n }\n\n const userInfoUsername = getUsernameFromOsUserInfo()\n if (userInfoUsername) {\n return userInfoUsername\n }\n\n /**\n First we try to get the ID of the user and then the actual username. We do this because in `docker run --user <uid>:<gid>` context, we don't have \"username\" available. Therefore, we have a fallback to `makeUsernameFromId` for such scenario. Applies also to the `sync()` method below.\n */\n try {\n if (platform === 'win32') {\n const {stdout} = await execa('whoami')\n return cleanWindowsCommand(stdout)\n }\n\n const {stdout: userId} = await execa('id', ['-u'])\n try {\n const {stdout} = await execa('id', ['-un', userId])\n return stdout\n\n // eslint-disable-next-line no-catch-all/no-catch-all,no-empty\n } catch {}\n return makeUsernameFromId(userId)\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return null\n }\n}\n\ntype PlatformArch = Exclude<typeof process.arch, 'x64' | 'ia32'> | 'amd64' | '386'\ntype PlatformStrings = Exclude<typeof process.platform, 'win32'> | 'windows'\n/**\n * Returns the platform and architecture.\n * @returns Returns the current platform and architecture.\n */\nexport function platformAndArch(\n platform: typeof process.platform = process.platform,\n arch: typeof process.arch = process.arch,\n): {\n platform: PlatformStrings\n arch: PlatformArch\n} {\n let archString = arch\n if (arch === 'x64') {\n archString = 'amd64'\n }\n if (arch === 'ia32') {\n archString = '386'\n }\n const platformString = (platform.match(/^win.+/) ? 'windows' : platform) as PlatformStrings\n return {platform: platformString, arch: archString}\n}\n\nfunction getEnvironmentVariable() {\n const {env} = process\n\n return env.SUDO_USER || env.C9_USER || env.LOGNAME || env.USER || env.LNAME || env.USERNAME\n}\n\nfunction getUsernameFromOsUserInfo(): string | null {\n try {\n return osUserInfo().username\n // eslint-disable-next-line no-catch-all/no-catch-all\n } catch {\n return null\n }\n}\n\nfunction cleanWindowsCommand(value: string) {\n return value.replace(/^.*\\\\/, '')\n}\n\nfunction makeUsernameFromId(userId: string) {\n return `no-username-${userId}`\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { PackageManager } from './
|
|
3
|
-
import { ColorContentToken, CommandContentToken, ContentToken, ErrorContentToken, HeadingContentToken, ItalicContentToken, JsonContentToken, LinesDiffContentToken, LinkContentToken, PathContentToken, RawContentToken, SubHeadingContentToken } from '
|
|
2
|
+
import { PackageManager } from './node-package-manager.js';
|
|
3
|
+
import { ColorContentToken, CommandContentToken, ContentToken, ErrorContentToken, HeadingContentToken, ItalicContentToken, JsonContentToken, LinesDiffContentToken, LinkContentToken, PathContentToken, RawContentToken, SubHeadingContentToken } from '../../private/node/content-tokens.js';
|
|
4
4
|
import { AbortSignal } from '@shopify/cli-kit/node/abort';
|
|
5
5
|
import { Writable } from 'stream';
|
|
6
6
|
import type { Change } from 'diff';
|
|
@@ -10,36 +10,45 @@ export declare class TokenizedString {
|
|
|
10
10
|
value: string;
|
|
11
11
|
constructor(value: string);
|
|
12
12
|
}
|
|
13
|
-
export declare type
|
|
14
|
-
export declare const
|
|
15
|
-
raw
|
|
16
|
-
genericShellCommand
|
|
17
|
-
json
|
|
18
|
-
path
|
|
19
|
-
link
|
|
20
|
-
heading
|
|
21
|
-
subheading
|
|
22
|
-
italic
|
|
23
|
-
errorText
|
|
24
|
-
cyan
|
|
25
|
-
yellow
|
|
26
|
-
magenta
|
|
27
|
-
green
|
|
28
|
-
packagejsonScript
|
|
29
|
-
successIcon
|
|
30
|
-
failIcon
|
|
31
|
-
linesDiff
|
|
13
|
+
export declare type OutputMessage = string | TokenizedString;
|
|
14
|
+
export declare const outputToken: {
|
|
15
|
+
raw(value: string): RawContentToken;
|
|
16
|
+
genericShellCommand(value: OutputMessage): CommandContentToken;
|
|
17
|
+
json(value: unknown): JsonContentToken;
|
|
18
|
+
path(value: OutputMessage): PathContentToken;
|
|
19
|
+
link(value: OutputMessage, link: string): LinkContentToken;
|
|
20
|
+
heading(value: OutputMessage): HeadingContentToken;
|
|
21
|
+
subheading(value: OutputMessage): SubHeadingContentToken;
|
|
22
|
+
italic(value: OutputMessage): ItalicContentToken;
|
|
23
|
+
errorText(value: OutputMessage): ErrorContentToken;
|
|
24
|
+
cyan(value: OutputMessage): ColorContentToken;
|
|
25
|
+
yellow(value: OutputMessage): ColorContentToken;
|
|
26
|
+
magenta(value: OutputMessage): ColorContentToken;
|
|
27
|
+
green(value: OutputMessage): ColorContentToken;
|
|
28
|
+
packagejsonScript(packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]): CommandContentToken;
|
|
29
|
+
successIcon(): ColorContentToken;
|
|
30
|
+
failIcon(): ErrorContentToken;
|
|
31
|
+
linesDiff(value: Change[]): LinesDiffContentToken;
|
|
32
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Given a command and its arguments, it formats it depending on the package manager.
|
|
35
|
+
*
|
|
36
|
+
* @param packageManager - The package manager to use (pnpm, npm, yarn).
|
|
37
|
+
* @param scriptName - The name of the script to run.
|
|
38
|
+
* @param scriptArgs - The arguments to pass to the script.
|
|
39
|
+
* @returns The formatted command.
|
|
40
|
+
*/
|
|
33
41
|
export declare function formatPackageManagerCommand(packageManager: PackageManager, scriptName: string, ...scriptArgs: string[]): string;
|
|
34
|
-
export declare function content(strings: TemplateStringsArray, ...keys: (ContentToken<unknown> | string)[]): TokenizedString;
|
|
35
|
-
/** Log levels */
|
|
36
|
-
export declare type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent';
|
|
37
42
|
/**
|
|
43
|
+
* Creates a tokenized string from an array of strings and tokens.
|
|
38
44
|
*
|
|
39
|
-
* @
|
|
45
|
+
* @param strings - The strings to join.
|
|
46
|
+
* @param keys - Array of tokens or strings to join.
|
|
47
|
+
* @returns The tokenized string.
|
|
40
48
|
*/
|
|
41
|
-
export declare
|
|
42
|
-
|
|
49
|
+
export declare function outputContent(strings: TemplateStringsArray, ...keys: (ContentToken<unknown> | string)[]): TokenizedString;
|
|
50
|
+
/** Log levels. */
|
|
51
|
+
export declare type LogLevel = 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace' | 'silent';
|
|
43
52
|
export declare let collectedLogs: {
|
|
44
53
|
[key: string]: string[];
|
|
45
54
|
};
|
|
@@ -47,83 +56,133 @@ export declare let collectedLogs: {
|
|
|
47
56
|
* This is only used during UnitTesting.
|
|
48
57
|
* If we are in a testing context, instead of printing the logs to the console,
|
|
49
58
|
* we will store them in a variable that can be accessed from the tests.
|
|
59
|
+
*
|
|
50
60
|
* @param key - The key of the log.
|
|
51
61
|
* @param content - The content of the log.
|
|
52
62
|
*/
|
|
53
|
-
export declare
|
|
63
|
+
export declare function collectLog(key: string, content: OutputMessage): void;
|
|
54
64
|
export declare const clearCollectedLogs: () => void;
|
|
55
65
|
/**
|
|
56
66
|
* Ouputs information to the user.
|
|
57
67
|
* Info messages don't get additional formatting.
|
|
58
68
|
* Note: Info messages are sent through the standard output.
|
|
69
|
+
*
|
|
59
70
|
* @param content - The content to be output to the user.
|
|
60
71
|
* @param logger - The logging function to use to output to the user.
|
|
61
72
|
*/
|
|
62
|
-
export declare
|
|
73
|
+
export declare function outputInfo(content: OutputMessage, logger?: Logger): void;
|
|
63
74
|
/**
|
|
64
75
|
* Outputs a success message to the user.
|
|
65
76
|
* Success messages receive a special formatting to make them stand out in the console.
|
|
66
77
|
* Note: Success messages are sent through the standard output.
|
|
78
|
+
*
|
|
67
79
|
* @param content - The content to be output to the user.
|
|
68
80
|
* @param logger - The logging function to use to output to the user.
|
|
69
81
|
*/
|
|
70
|
-
export declare
|
|
82
|
+
export declare function outputSuccess(content: OutputMessage, logger?: Logger): void;
|
|
71
83
|
/**
|
|
72
84
|
* Outputs a completed message to the user.
|
|
73
85
|
* Completed message receive a special formatting to make them stand out in the console.
|
|
74
86
|
* Note: Completed messages are sent through the standard output.
|
|
87
|
+
*
|
|
75
88
|
* @param content - The content to be output to the user.
|
|
76
89
|
* @param logger - The logging function to use to output to the user.
|
|
77
90
|
*/
|
|
78
|
-
export declare
|
|
91
|
+
export declare function outputCompleted(content: OutputMessage, logger?: Logger): void;
|
|
79
92
|
/**
|
|
80
93
|
* Ouputs debug information to the user. By default these output is hidden unless the user calls the CLI with --verbose.
|
|
81
94
|
* Debug messages don't get additional formatting.
|
|
82
95
|
* Note: Debug messages are sent through the standard output.
|
|
96
|
+
*
|
|
83
97
|
* @param content - The content to be output to the user.
|
|
84
98
|
* @param logger - The logging function to use to output to the user.
|
|
85
99
|
*/
|
|
86
|
-
export declare
|
|
100
|
+
export declare function outputDebug(content: OutputMessage, logger?: Logger): void;
|
|
87
101
|
/**
|
|
88
102
|
* Outputs a warning message to the user.
|
|
89
103
|
* Warning messages receive a special formatting to make them stand out in the console.
|
|
90
104
|
* Note: Warning messages are sent through the standard output.
|
|
105
|
+
*
|
|
91
106
|
* @param content - The content to be output to the user.
|
|
92
107
|
* @param logger - The logging function to use to output to the user.
|
|
93
108
|
*/
|
|
94
|
-
export declare
|
|
109
|
+
export declare function outputWarn(content: OutputMessage, logger?: Logger): void;
|
|
95
110
|
/**
|
|
96
111
|
* Prints a new line in the terminal.
|
|
97
112
|
*/
|
|
98
|
-
export declare
|
|
99
|
-
|
|
113
|
+
export declare function outputNewline(): void;
|
|
114
|
+
/**
|
|
115
|
+
* Converts a Message to string.
|
|
116
|
+
*
|
|
117
|
+
* @param message - The message to convert to string.
|
|
118
|
+
* @returns The string representation of the message.
|
|
119
|
+
*/
|
|
120
|
+
export declare function stringifyMessage(message: OutputMessage): string;
|
|
100
121
|
export interface OutputProcess {
|
|
101
|
-
/**
|
|
102
|
-
*
|
|
122
|
+
/**
|
|
123
|
+
* The prefix to include in the logs
|
|
124
|
+
* [vite] Output coming from Vite.
|
|
103
125
|
*/
|
|
104
126
|
prefix: string;
|
|
105
127
|
/**
|
|
106
|
-
* A callback to invoke the process.
|
|
128
|
+
* A callback to invoke the process. Stdout and stderr should be used
|
|
107
129
|
* to send standard output and error data that gets formatted with the
|
|
108
130
|
* right prefix.
|
|
109
131
|
*/
|
|
110
132
|
action: (stdout: Writable, stderr: Writable, signal: AbortSignal) => Promise<void>;
|
|
111
133
|
}
|
|
134
|
+
/**
|
|
135
|
+
* Prints a log message in the console.
|
|
136
|
+
*
|
|
137
|
+
* @param message - The message to print.
|
|
138
|
+
*/
|
|
112
139
|
export declare function consoleLog(message: string): void;
|
|
140
|
+
/**
|
|
141
|
+
* Prints an error message in the console.
|
|
142
|
+
*
|
|
143
|
+
* @param message - The message to print.
|
|
144
|
+
*/
|
|
113
145
|
export declare function consoleError(message: string): void;
|
|
146
|
+
/**
|
|
147
|
+
* Prints a warning message in the console.
|
|
148
|
+
*
|
|
149
|
+
* @param message - The message to print.
|
|
150
|
+
*/
|
|
114
151
|
export declare function consoleWarn(message: string): void;
|
|
152
|
+
/**
|
|
153
|
+
* Writes a message to the appropiated logger.
|
|
154
|
+
*
|
|
155
|
+
* @param logLevel - The log level to use to determine if the message should be output.
|
|
156
|
+
* @param logger - The logger to use to output the message.
|
|
157
|
+
* @param message - The message to output.
|
|
158
|
+
*/
|
|
115
159
|
export declare function outputWhereAppropriate(logLevel: LogLevel, logger: Logger, message: string): void;
|
|
160
|
+
/**
|
|
161
|
+
* Returns a message without styles (colors or any ANSI escape codes).
|
|
162
|
+
*
|
|
163
|
+
* @param message - The message to remove styles from.
|
|
164
|
+
* @returns The message without styles.
|
|
165
|
+
*/
|
|
116
166
|
export declare function unstyled(message: string): string;
|
|
167
|
+
/**
|
|
168
|
+
* Checks if the console outputs should display colors or not.
|
|
169
|
+
*
|
|
170
|
+
* @returns True if the console outputs should display colors, false otherwise.
|
|
171
|
+
*/
|
|
117
172
|
export declare function shouldDisplayColors(): boolean;
|
|
118
173
|
/**
|
|
174
|
+
* Generates a message to remind the user to update the CLI.
|
|
175
|
+
*
|
|
119
176
|
* @param packageManager - The package manager that is being used.
|
|
120
|
-
* @param version - The version to update to
|
|
177
|
+
* @param version - The version to update to.
|
|
178
|
+
* @returns The message to remind the user to update the CLI.
|
|
121
179
|
*/
|
|
122
180
|
export declare function getOutputUpdateCLIReminder(packageManager: PackageManager | 'unknown' | undefined, version: string): string;
|
|
123
181
|
/**
|
|
124
|
-
* Parse title and body to be a single formatted string
|
|
182
|
+
* Parse title and body to be a single formatted string.
|
|
183
|
+
*
|
|
125
184
|
* @param title - The title of the message. Will be formatted as a heading.
|
|
126
185
|
* @param body - The body of the message. Will respect the original formatting.
|
|
127
186
|
* @returns The formatted message.
|
|
128
187
|
*/
|
|
129
|
-
export declare function
|
|
188
|
+
export declare function formatSection(title: string, body: string): string;
|