@shopify/cli-kit 3.0.26 → 3.2.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/CHANGELOG.md +25 -0
- package/dist/analytics.d.ts +3 -1
- package/dist/analytics.js +20 -5
- package/dist/analytics.js.map +1 -1
- package/dist/api/graphql/find_store_by_domain.d.ts +21 -0
- package/dist/api/graphql/find_store_by_domain.js +24 -0
- package/dist/api/graphql/find_store_by_domain.js.map +1 -0
- package/dist/api/graphql/index.d.ts +1 -0
- package/dist/api/graphql/index.js +1 -0
- package/dist/api/graphql/index.js.map +1 -1
- package/dist/api/identity.js +3 -0
- package/dist/api/identity.js.map +1 -1
- package/dist/error.js +4 -0
- package/dist/error.js.map +1 -1
- package/dist/index.d.ts +0 -4
- package/dist/index.js +0 -4
- package/dist/index.js.map +1 -1
- package/dist/node/base-command.d.ts +6 -0
- package/dist/node/base-command.js +9 -0
- package/dist/node/base-command.js.map +1 -0
- package/dist/{checksum.d.ts → node/checksum.d.ts} +6 -1
- package/dist/{checksum.js → node/checksum.js} +8 -3
- package/dist/node/checksum.js.map +1 -0
- package/dist/node/cli.js +5 -45
- package/dist/node/cli.js.map +1 -1
- package/dist/{colors.d.ts → node/colors.d.ts} +0 -0
- package/dist/{colors.js → node/colors.js} +0 -0
- package/dist/node/colors.js.map +1 -0
- package/dist/{dot-env.d.ts → node/dot-env.d.ts} +8 -3
- package/dist/{dot-env.js → node/dot-env.js} +10 -5
- package/dist/node/dot-env.js.map +1 -0
- package/dist/node/error-handler.d.ts +3 -0
- package/dist/node/error-handler.js +79 -0
- package/dist/node/error-handler.js.map +1 -0
- package/dist/node/hooks/postrun.d.ts +2 -0
- package/dist/node/hooks/postrun.js +6 -0
- package/dist/node/hooks/postrun.js.map +1 -0
- package/dist/node/hooks/prerun.d.ts +2 -0
- package/dist/node/hooks/prerun.js +9 -0
- package/dist/node/hooks/prerun.js.map +1 -0
- package/dist/{dependency.d.ts → node/node-package-manager.d.ts} +92 -23
- package/dist/{dependency.js → node/node-package-manager.js} +56 -49
- package/dist/node/node-package-manager.js.map +1 -0
- package/dist/{ruby.d.ts → node/ruby.d.ts} +11 -2
- package/dist/{ruby.js → node/ruby.js} +15 -10
- package/dist/node/ruby.js.map +1 -0
- package/dist/output.d.ts +9 -2
- package/dist/output.js +17 -7
- package/dist/output.js.map +1 -1
- package/dist/port.js +23 -1
- package/dist/port.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/autocomplete.js +1 -1
- package/dist/ui/autocomplete.js.map +1 -1
- package/dist/ui/input.js +1 -1
- package/dist/ui/input.js.map +1 -1
- package/dist/ui/select.js +1 -1
- package/dist/ui/select.js.map +1 -1
- package/dist/ui.js +3 -3
- package/dist/ui.js.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +7 -3
- package/dist/checksum.js.map +0 -1
- package/dist/colors.js.map +0 -1
- package/dist/dependency.js.map +0 -1
- package/dist/dot-env.js.map +0 -1
- package/dist/ruby.js.map +0 -1
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { AbortSilent, CancelExecution, mapper as errorMapper, shouldReport as shouldReportError, handler, } from '../error.js';
|
|
2
|
+
import { info } from '../output.js';
|
|
3
|
+
import { reportEvent } from '../analytics.js';
|
|
4
|
+
import { normalize } from '../path.js';
|
|
5
|
+
import { settings } from '@oclif/core';
|
|
6
|
+
import StackTracey from 'stacktracey';
|
|
7
|
+
import Bugsnag from '@bugsnag/js';
|
|
8
|
+
export function errorHandler(error) {
|
|
9
|
+
if (error instanceof CancelExecution) {
|
|
10
|
+
if (error.message && error.message !== '') {
|
|
11
|
+
info(`✨ ${error.message}`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
else if (error instanceof AbortSilent) {
|
|
15
|
+
process.exit(1);
|
|
16
|
+
}
|
|
17
|
+
else {
|
|
18
|
+
return errorMapper(error)
|
|
19
|
+
.then((error) => {
|
|
20
|
+
return handler(error);
|
|
21
|
+
})
|
|
22
|
+
.then(reportError)
|
|
23
|
+
.then(() => {
|
|
24
|
+
process.exit(1);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const reportError = async (error) => {
|
|
29
|
+
await reportEvent({ errorMessage: error.message });
|
|
30
|
+
if (settings.debug || !shouldReportError(error))
|
|
31
|
+
return error;
|
|
32
|
+
let reportableError;
|
|
33
|
+
let stacktrace;
|
|
34
|
+
let report = false;
|
|
35
|
+
// eslint-disable-next-line no-prototype-builtins
|
|
36
|
+
if (Error.prototype.isPrototypeOf(error)) {
|
|
37
|
+
report = true;
|
|
38
|
+
reportableError = new Error(error.message);
|
|
39
|
+
stacktrace = error.stack;
|
|
40
|
+
/**
|
|
41
|
+
* Some errors that reach this point have an empty string. For example:
|
|
42
|
+
* https://app.bugsnag.com/shopify/cli/errors/62cd5d31fd5040000814086c?filters[event.since]=30d&filters[error.status]=new&filters[release.seen_in]=3.1.0
|
|
43
|
+
*
|
|
44
|
+
* Because at this point we have neither the error message nor a stack trace reporting them
|
|
45
|
+
* to Bugsnag is pointless and adds noise.
|
|
46
|
+
*/
|
|
47
|
+
}
|
|
48
|
+
else if (typeof error === 'string' && error.trim().length !== 0) {
|
|
49
|
+
report = true;
|
|
50
|
+
reportableError = new Error(error);
|
|
51
|
+
stacktrace = reportableError.stack;
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
report = false;
|
|
55
|
+
reportableError = new Error('Unknown error');
|
|
56
|
+
}
|
|
57
|
+
const formattedStacktrace = new StackTracey(stacktrace ?? '')
|
|
58
|
+
.clean()
|
|
59
|
+
.items.map((item) => {
|
|
60
|
+
const filePath = normalize(item.file).replace('file:/', '/').replace('C:/', '');
|
|
61
|
+
return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`;
|
|
62
|
+
})
|
|
63
|
+
.join('\n');
|
|
64
|
+
reportableError.stack = `Error: ${reportableError.message}\n${formattedStacktrace}`;
|
|
65
|
+
if (report) {
|
|
66
|
+
await new Promise((resolve, reject) => {
|
|
67
|
+
Bugsnag.notify(reportableError, undefined, (error, event) => {
|
|
68
|
+
if (error) {
|
|
69
|
+
reject(error);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
resolve(reportableError);
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return reportableError;
|
|
78
|
+
};
|
|
79
|
+
//# sourceMappingURL=error-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/node/error-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,eAAe,EACf,MAAM,IAAI,WAAW,EACrB,YAAY,IAAI,iBAAiB,EACjC,OAAO,GACR,MAAM,aAAa,CAAA;AACpB,OAAO,EAAC,IAAI,EAAC,MAAM,cAAc,CAAA;AACjC,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAA;AAC3C,OAAO,EAAC,SAAS,EAAC,MAAM,YAAY,CAAA;AACpC,OAAO,EAAC,QAAQ,EAAC,MAAM,aAAa,CAAA;AACpC,OAAO,WAAW,MAAM,aAAa,CAAA;AACrC,OAAO,OAAO,MAAM,aAAa,CAAA;AAEjC,MAAM,UAAU,YAAY,CAAC,KAA8C;IACzE,IAAI,KAAK,YAAY,eAAe,EAAE;QACpC,IAAI,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,KAAK,EAAE,EAAE;YACzC,IAAI,CAAC,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;SAC5B;KACF;SAAM,IAAI,KAAK,YAAY,WAAW,EAAE;QACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;KAChB;SAAM;QACL,OAAO,WAAW,CAAC,KAAK,CAAC;aACtB,IAAI,CAAC,CAAC,KAAY,EAAE,EAAE;YACrB,OAAO,OAAO,CAAC,KAAK,CAAC,CA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I,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAA;QAC/E,OAAO,UAAU,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,MAAM,GAAG,CAAA;IAC1E,CAAC,CAAC;SACD,IAAI,CAAC,IAAI,CAAC,CAAA;IACb,eAAe,CAAC,KAAK,GAAG,UAAU,eAAe,CAAC,OAAO,KAAK,mBAAmB,EAAE,CAAA;IAEnF,IAAI,MAAM,EAAE;QACV,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACpC,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,SAAS,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE;gBAC1D,IAAI,KAAK,EAAE;oBACT,MAAM,CAAC,KAAK,CAAC,CAAA;iBACd;qBAAM;oBACL,OAAO,CAAC,eAAe,CAAC,CAAA;iBACzB;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;KACH;IACD,OAAO,eAAe,CAAA;AACxB,CAAC,CAAA","sourcesContent":["import {\n AbortSilent,\n CancelExecution,\n mapper as errorMapper,\n shouldReport as shouldReportError,\n handler,\n} from '../error.js'\nimport {info} from '../output.js'\nimport {reportEvent} from '../analytics.js'\nimport {normalize} from '../path.js'\nimport {settings} from '@oclif/core'\nimport StackTracey from 'stacktracey'\nimport Bugsnag from '@bugsnag/js'\n\nexport function errorHandler(error: Error & {exitCode?: number | undefined}) {\n if (error instanceof CancelExecution) {\n if (error.message && error.message !== '') {\n info(`✨ ${error.message}`)\n }\n } else if (error instanceof AbortSilent) {\n process.exit(1)\n } else {\n return errorMapper(error)\n .then((error: Error) => {\n return handler(error)\n })\n .then(reportError)\n .then(() => {\n process.exit(1)\n })\n }\n}\n\nconst reportError = async (error: Error): Promise<Error> => {\n await reportEvent({errorMessage: error.message})\n if (settings.debug || !shouldReportError(error)) return error\n\n let reportableError: Error\n let stacktrace: string | undefined\n let report = false\n\n // eslint-disable-next-line no-prototype-builtins\n if (Error.prototype.isPrototypeOf(error)) {\n report = true\n reportableError = new Error(error.message)\n stacktrace = error.stack\n\n /**\n * Some errors that reach this point have an empty string. For example:\n * https://app.bugsnag.com/shopify/cli/errors/62cd5d31fd5040000814086c?filters[event.since]=30d&filters[error.status]=new&filters[release.seen_in]=3.1.0\n *\n * Because at this point we have neither the error message nor a stack trace reporting them\n * to Bugsnag is pointless and adds noise.\n */\n } else if (typeof error === 'string' && (error as string).trim().length !== 0) {\n report = true\n reportableError = new Error(error)\n stacktrace = reportableError.stack\n } else {\n report = false\n reportableError = new Error('Unknown error')\n }\n\n const formattedStacktrace = new StackTracey(stacktrace ?? '')\n .clean()\n .items.map((item) => {\n const filePath = normalize(item.file).replace('file:/', '/').replace('C:/', '')\n return ` at ${item.callee} (${filePath}:${item.line}:${item.column})`\n })\n .join('\\n')\n reportableError.stack = `Error: ${reportableError.message}\\n${formattedStacktrace}`\n\n if (report) {\n await new Promise((resolve, reject) => {\n Bugsnag.notify(reportableError, undefined, (error, event) => {\n if (error) {\n reject(error)\n } else {\n resolve(reportableError)\n }\n })\n })\n }\n return reportableError\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postrun.js","sourceRoot":"","sources":["../../../src/node/hooks/postrun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,oBAAoB,CAAA;AAG9C,gGAAgG;AAChG,MAAM,CAAC,MAAM,QAAQ,GAAiB,KAAK,EAAE,QAAQ,EAAE,EAAE;IACvD,MAAM,WAAW,EAAE,CAAA;AACrB,CAAC,CAAA","sourcesContent":["import {reportEvent} from '../../analytics.js'\nimport {Hook} from '@oclif/core'\n\n// This hook is called after each successful command run. More info: https://oclif.io/docs/hooks\nexport const hookPost: Hook.Postrun = async (_options) => {\n await reportEvent()\n}\n"]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { start } from '../../analytics.js';
|
|
2
|
+
// This hook is called before each command run. More info: https://oclif.io/docs/hooks
|
|
3
|
+
export const hook = async (options) => {
|
|
4
|
+
const cmd = options.Command.aliases.length === 0 ? options.Command.id : options.Command.aliases[0];
|
|
5
|
+
const command = cmd.replace(/:/g, ' ');
|
|
6
|
+
const args = options.argv;
|
|
7
|
+
start({ command, args });
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=prerun.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prerun.js","sourceRoot":"","sources":["../../../src/node/hooks/prerun.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAA;AAGxC,sFAAsF;AACtF,MAAM,CAAC,MAAM,IAAI,GAAgB,KAAK,EAAE,OAAO,EAAE,EAAE;IACjD,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAA;IAClG,MAAM,OAAO,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;IACtC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;IACzB,KAAK,CAAC,EAAC,OAAO,EAAE,IAAI,EAAC,CAAC,CAAA;AACxB,CAAC,CAAA","sourcesContent":["import {start} from '../../analytics.js'\nimport {Hook} from '@oclif/core'\n\n// This hook is called before each command run. More info: https://oclif.io/docs/hooks\nexport const hook: Hook.Prerun = async (options) => {\n const cmd = options.Command.aliases.length === 0 ? options.Command.id : options.Command.aliases[0]\n const command = cmd.replace(/:/g, ' ')\n const args = options.argv\n start({command, args})\n}\n"]}
|
|
@@ -1,37 +1,57 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
/// <reference types="node" />
|
|
3
|
-
import { Abort, Bug } from '
|
|
3
|
+
import { Abort, Bug } from '../error.js';
|
|
4
4
|
import { AbortSignal } from 'abort-controller';
|
|
5
5
|
import type { Writable } from 'node:stream';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
/** The name of the Yarn lock file */
|
|
7
|
+
export declare const yarnLockfile = "yarn.lock";
|
|
8
|
+
/** The name of the pnpm lock file */
|
|
9
|
+
export declare const pnpmLockfile = "pnpm-lock.yaml";
|
|
10
|
+
/** An array containing the lockfiles from all the package managers */
|
|
11
|
+
export declare const lockfiles: string[];
|
|
12
|
+
/**
|
|
13
|
+
* A union type that represents the type of dependencies in the package.json
|
|
14
|
+
* - dev: devDependencies
|
|
15
|
+
* - prod: dependencies
|
|
16
|
+
* - peer: peerDependencies
|
|
17
|
+
*/
|
|
18
|
+
export declare type DependencyType = 'dev' | 'prod' | 'peer';
|
|
19
|
+
/**
|
|
20
|
+
* A union that represents the package managers available.
|
|
21
|
+
*/
|
|
22
|
+
export declare const packageManager: readonly ["yarn", "npm", "pnpm"];
|
|
23
|
+
export declare type PackageManager = typeof packageManager[number];
|
|
24
|
+
/**
|
|
25
|
+
* Returns an abort error that's thrown when a directory that's expected to have
|
|
26
|
+
* a package.json doesn't have it.
|
|
27
|
+
* @param directory {string} The path to the directory that should contain a package.json
|
|
28
|
+
* @returns {Abort} An abort error.
|
|
29
|
+
*/
|
|
16
30
|
export declare const PackageJsonNotFoundError: (directory: string) => Abort;
|
|
31
|
+
/**
|
|
32
|
+
* Returns a bug error that's thrown when the lookup of the package.json traversing the directory
|
|
33
|
+
* hierarchy up can't find a package.json
|
|
34
|
+
* @param directory {string} The directory from which the traverse has been done
|
|
35
|
+
* @returns {Abort} An abort error.
|
|
36
|
+
*/
|
|
17
37
|
export declare const FindUpAndReadPackageJsonNotFoundError: (directory: string) => Bug;
|
|
18
38
|
/**
|
|
19
39
|
* Returns the dependency manager used to run the create workflow.
|
|
20
40
|
* @param env {Object} The environment variables of the process in which the CLI runs.
|
|
21
41
|
* @returns The dependency manager
|
|
22
42
|
*/
|
|
23
|
-
export declare function
|
|
43
|
+
export declare function packageManagerUsedForCreating(env?: NodeJS.ProcessEnv): PackageManager;
|
|
24
44
|
/**
|
|
25
45
|
* Returns the dependency manager used by an existing project.
|
|
26
46
|
* @param directory {string} The root directory of the project.
|
|
27
47
|
* @returns The dependency manager
|
|
28
48
|
*/
|
|
29
|
-
export declare function
|
|
49
|
+
export declare function getPackageManager(directory: string): Promise<PackageManager>;
|
|
30
50
|
interface InstallNPMDependenciesRecursivelyOptions {
|
|
31
51
|
/**
|
|
32
52
|
* The dependency manager to use to install the dependencies.
|
|
33
53
|
*/
|
|
34
|
-
|
|
54
|
+
packageManager: PackageManager;
|
|
35
55
|
/**
|
|
36
56
|
* The directory from where we'll find package.json's recursively
|
|
37
57
|
*/
|
|
@@ -51,13 +71,13 @@ export declare function installNPMDependenciesRecursively(options: InstallNPMDep
|
|
|
51
71
|
/**
|
|
52
72
|
* Installs the dependencies in the given directory.
|
|
53
73
|
* @param directory {string} The directory that contains the package.json
|
|
54
|
-
* @param
|
|
74
|
+
* @param packageManager {PackageManager} The package manager to use to install the dependencies.
|
|
55
75
|
* @param stdout {Writable} Standard output stream.
|
|
56
76
|
* @param stderr {Writable} Standard error stream.
|
|
57
77
|
* @param signal {AbortSignal} Abort signal.
|
|
58
78
|
* @returns stderr {Writable} Standard error stream.
|
|
59
79
|
*/
|
|
60
|
-
export declare function
|
|
80
|
+
export declare function installNodeModules(directory: string, packageManager: PackageManager, stdout?: Writable, stderr?: Writable, signal?: AbortSignal): Promise<void>;
|
|
61
81
|
/**
|
|
62
82
|
* Returns the name of the package configured in its package.json
|
|
63
83
|
* @param packageJsonPath {string} Path to the package.json file
|
|
@@ -72,25 +92,55 @@ export declare function getPackageName(packageJsonPath: string): Promise<string>
|
|
|
72
92
|
export declare function getDependencies(packageJsonPath: string): Promise<{
|
|
73
93
|
[key: string]: string;
|
|
74
94
|
}>;
|
|
95
|
+
/**
|
|
96
|
+
* Given an NPM dependency, it checks if there's a more recent version, and if there is, it returns its value.
|
|
97
|
+
* @param dependency {string} The dependency name (e.g. react)
|
|
98
|
+
* @param currentVersion {string} The current version.
|
|
99
|
+
* @returns {Promise<string>} A promise that resolves with a more recent version or undefined if there's no more recent version.
|
|
100
|
+
*/
|
|
75
101
|
export declare function checkForNewVersion(dependency: string, currentVersion: string): Promise<string | undefined>;
|
|
76
|
-
|
|
77
|
-
interface
|
|
102
|
+
/**
|
|
103
|
+
* An interface that represents a package.json
|
|
104
|
+
*/
|
|
105
|
+
interface PackageJson {
|
|
106
|
+
/**
|
|
107
|
+
* The absolute path to the package.json
|
|
108
|
+
*/
|
|
109
|
+
path: string;
|
|
110
|
+
/**
|
|
111
|
+
* The name attribute of the package.json
|
|
112
|
+
*/
|
|
78
113
|
name: string;
|
|
114
|
+
/**
|
|
115
|
+
* The version attribute of the package.json
|
|
116
|
+
*/
|
|
79
117
|
version?: string;
|
|
118
|
+
/**
|
|
119
|
+
* The dependencies attribute of the package.json
|
|
120
|
+
*/
|
|
80
121
|
dependencies?: {
|
|
81
122
|
[key: string]: string;
|
|
82
123
|
};
|
|
124
|
+
/**
|
|
125
|
+
* The devDependencies attribute of the package.json
|
|
126
|
+
*/
|
|
83
127
|
devDependencies?: {
|
|
84
128
|
[key: string]: string;
|
|
85
129
|
};
|
|
86
130
|
}
|
|
87
|
-
|
|
88
|
-
|
|
131
|
+
/**
|
|
132
|
+
* Reads and parses a package.json
|
|
133
|
+
* @param packageJsonPath {string} Path to the package.json
|
|
134
|
+
* @returns {Promise<PackageJson>} An promise that resolves with an in-memory representation
|
|
135
|
+
* of the package.json or rejects with an error if the file is not found or the content is
|
|
136
|
+
* not decodable.
|
|
137
|
+
*/
|
|
138
|
+
export declare function readAndParsePackageJson(packageJsonPath: string): Promise<PackageJson>;
|
|
89
139
|
interface AddNPMDependenciesIfNeededOptions {
|
|
90
140
|
/** How dependencies should be added */
|
|
91
141
|
type: DependencyType;
|
|
92
142
|
/** The dependency manager to use to add dependencies */
|
|
93
|
-
|
|
143
|
+
packageManager: PackageManager;
|
|
94
144
|
/** The directory that contains the package.json where dependencies will be added */
|
|
95
145
|
directory: string;
|
|
96
146
|
/** Standard output coming from the underlying installation process */
|
|
@@ -100,8 +150,29 @@ interface AddNPMDependenciesIfNeededOptions {
|
|
|
100
150
|
/** Abort signal to stop the process */
|
|
101
151
|
signal?: AbortSignal;
|
|
102
152
|
}
|
|
153
|
+
/**
|
|
154
|
+
* An interface that represents a dependency name with its version
|
|
155
|
+
*/
|
|
103
156
|
export interface DependencyVersion {
|
|
157
|
+
/**
|
|
158
|
+
* The name of the NPM dependency as it's reflected in the package.json:
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* In the example below name would be "react"
|
|
162
|
+
* {
|
|
163
|
+
* "react": "1.2.3"
|
|
164
|
+
* }
|
|
165
|
+
*/
|
|
104
166
|
name: string;
|
|
167
|
+
/**
|
|
168
|
+
* The version of the NPM dependency as it's reflected in the package.json:
|
|
169
|
+
*
|
|
170
|
+
* @example
|
|
171
|
+
* In the example below version would be "1.2.3"
|
|
172
|
+
* {
|
|
173
|
+
* "react": "1.2.3"
|
|
174
|
+
* }
|
|
175
|
+
*/
|
|
105
176
|
version: string | undefined;
|
|
106
177
|
}
|
|
107
178
|
/**
|
|
@@ -112,8 +183,6 @@ export interface DependencyVersion {
|
|
|
112
183
|
export declare function addNPMDependenciesIfNeeded(dependencies: DependencyVersion[], options: AddNPMDependenciesIfNeededOptions, force?: boolean): Promise<void>;
|
|
113
184
|
export declare function addNPMDependenciesWithoutVersionIfNeeded(dependencies: string[], options: AddNPMDependenciesIfNeededOptions): Promise<void>;
|
|
114
185
|
export declare function addLatestNPMDependencies(dependencies: string[], options: AddNPMDependenciesIfNeededOptions): Promise<void>;
|
|
115
|
-
export declare type ProjectType = 'node' | 'php' | 'ruby' | undefined;
|
|
116
|
-
export declare function getProjectType(directory: string): Promise<ProjectType>;
|
|
117
186
|
/**
|
|
118
187
|
* Given a directory it traverses the directory up looking for a package.json and if found, it reads it
|
|
119
188
|
* decodes the JSON, and returns its content as a Javascript object.
|
|
@@ -1,23 +1,36 @@
|
|
|
1
|
-
import { exec } from '
|
|
2
|
-
import { exists as fileExists, read as readFile } from '
|
|
3
|
-
import { glob, dirname, join as pathJoin, findUp } from '
|
|
4
|
-
import { Abort, Bug } from '
|
|
5
|
-
import { latestNpmPackageVersion } from '
|
|
6
|
-
import { Version } from '
|
|
7
|
-
import { content, token, debug } from '
|
|
1
|
+
import { exec } from '../system.js';
|
|
2
|
+
import { exists as fileExists, read as readFile } from '../file.js';
|
|
3
|
+
import { glob, dirname, join as pathJoin, findUp } from '../path.js';
|
|
4
|
+
import { Abort, Bug } from '../error.js';
|
|
5
|
+
import { latestNpmPackageVersion } from '../version.js';
|
|
6
|
+
import { Version } from '../semver.js';
|
|
7
|
+
import { content, token, debug } from '../output.js';
|
|
8
8
|
import { AbortController } from 'abort-controller';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
/** The name of the Yarn lock file */
|
|
10
|
+
export const yarnLockfile = 'yarn.lock';
|
|
11
|
+
/** The name of the pnpm lock file */
|
|
12
|
+
export const pnpmLockfile = 'pnpm-lock.yaml';
|
|
13
|
+
/** An array containing the lockfiles from all the package managers */
|
|
14
|
+
export const lockfiles = [yarnLockfile, pnpmLockfile];
|
|
15
|
+
/**
|
|
16
|
+
* A union that represents the package managers available.
|
|
17
|
+
*/
|
|
18
|
+
export const packageManager = ['yarn', 'npm', 'pnpm'];
|
|
19
|
+
/**
|
|
20
|
+
* Returns an abort error that's thrown when a directory that's expected to have
|
|
21
|
+
* a package.json doesn't have it.
|
|
22
|
+
* @param directory {string} The path to the directory that should contain a package.json
|
|
23
|
+
* @returns {Abort} An abort error.
|
|
24
|
+
*/
|
|
18
25
|
export const PackageJsonNotFoundError = (directory) => {
|
|
19
26
|
return new Abort(`The directory ${directory} doesn't have a package.json.`);
|
|
20
27
|
};
|
|
28
|
+
/**
|
|
29
|
+
* Returns a bug error that's thrown when the lookup of the package.json traversing the directory
|
|
30
|
+
* hierarchy up can't find a package.json
|
|
31
|
+
* @param directory {string} The directory from which the traverse has been done
|
|
32
|
+
* @returns {Abort} An abort error.
|
|
33
|
+
*/
|
|
21
34
|
export const FindUpAndReadPackageJsonNotFoundError = (directory) => {
|
|
22
35
|
return new Bug(content `Couldn't find a a package.json traversing directories from ${token.path(directory)}`);
|
|
23
36
|
};
|
|
@@ -26,7 +39,7 @@ export const FindUpAndReadPackageJsonNotFoundError = (directory) => {
|
|
|
26
39
|
* @param env {Object} The environment variables of the process in which the CLI runs.
|
|
27
40
|
* @returns The dependency manager
|
|
28
41
|
*/
|
|
29
|
-
export function
|
|
42
|
+
export function packageManagerUsedForCreating(env = process.env) {
|
|
30
43
|
if (env.npm_config_user_agent?.includes('yarn')) {
|
|
31
44
|
return 'yarn';
|
|
32
45
|
}
|
|
@@ -42,10 +55,10 @@ export function dependencyManagerUsedForCreating(env = process.env) {
|
|
|
42
55
|
* @param directory {string} The root directory of the project.
|
|
43
56
|
* @returns The dependency manager
|
|
44
57
|
*/
|
|
45
|
-
export async function
|
|
58
|
+
export async function getPackageManager(directory) {
|
|
46
59
|
debug(content `Obtaining the dependency manager in directory ${token.path(directory)}...`);
|
|
47
|
-
const yarnLockPath = pathJoin(directory,
|
|
48
|
-
const pnpmLockPath = pathJoin(directory,
|
|
60
|
+
const yarnLockPath = pathJoin(directory, yarnLockfile);
|
|
61
|
+
const pnpmLockPath = pathJoin(directory, pnpmLockfile);
|
|
49
62
|
if (await fileExists(yarnLockPath)) {
|
|
50
63
|
return 'yarn';
|
|
51
64
|
}
|
|
@@ -73,7 +86,7 @@ export async function installNPMDependenciesRecursively(options) {
|
|
|
73
86
|
try {
|
|
74
87
|
await Promise.all(packageJsons.map(async (packageJsonPath) => {
|
|
75
88
|
const directory = dirname(packageJsonPath);
|
|
76
|
-
await
|
|
89
|
+
await installNodeModules(directory, options.packageManager, undefined, undefined, abortController.signal);
|
|
77
90
|
}));
|
|
78
91
|
}
|
|
79
92
|
catch (error) {
|
|
@@ -84,15 +97,15 @@ export async function installNPMDependenciesRecursively(options) {
|
|
|
84
97
|
/**
|
|
85
98
|
* Installs the dependencies in the given directory.
|
|
86
99
|
* @param directory {string} The directory that contains the package.json
|
|
87
|
-
* @param
|
|
100
|
+
* @param packageManager {PackageManager} The package manager to use to install the dependencies.
|
|
88
101
|
* @param stdout {Writable} Standard output stream.
|
|
89
102
|
* @param stderr {Writable} Standard error stream.
|
|
90
103
|
* @param signal {AbortSignal} Abort signal.
|
|
91
104
|
* @returns stderr {Writable} Standard error stream.
|
|
92
105
|
*/
|
|
93
|
-
export async function
|
|
106
|
+
export async function installNodeModules(directory, packageManager, stdout, stderr, signal) {
|
|
94
107
|
const options = { cwd: directory, stdin: undefined, stdout, stderr, signal };
|
|
95
|
-
await exec(
|
|
108
|
+
await exec(packageManager, ['install'], options);
|
|
96
109
|
}
|
|
97
110
|
/**
|
|
98
111
|
* Returns the name of the package configured in its package.json
|
|
@@ -100,7 +113,7 @@ export async function install(directory, dependencyManager, stdout, stderr, sign
|
|
|
100
113
|
* @returns A promise that resolves with the name.
|
|
101
114
|
*/
|
|
102
115
|
export async function getPackageName(packageJsonPath) {
|
|
103
|
-
const packageJsonContent = await
|
|
116
|
+
const packageJsonContent = await readAndParsePackageJson(packageJsonPath);
|
|
104
117
|
return packageJsonContent.name;
|
|
105
118
|
}
|
|
106
119
|
/**
|
|
@@ -109,11 +122,17 @@ export async function getPackageName(packageJsonPath) {
|
|
|
109
122
|
* @returns A promise that resolves with the list of dependencies.
|
|
110
123
|
*/
|
|
111
124
|
export async function getDependencies(packageJsonPath) {
|
|
112
|
-
const packageJsonContent = await
|
|
125
|
+
const packageJsonContent = await readAndParsePackageJson(packageJsonPath);
|
|
113
126
|
const dependencies = packageJsonContent.dependencies ?? {};
|
|
114
127
|
const devDependencies = packageJsonContent.devDependencies ?? {};
|
|
115
128
|
return { ...dependencies, ...devDependencies };
|
|
116
129
|
}
|
|
130
|
+
/**
|
|
131
|
+
* Given an NPM dependency, it checks if there's a more recent version, and if there is, it returns its value.
|
|
132
|
+
* @param dependency {string} The dependency name (e.g. react)
|
|
133
|
+
* @param currentVersion {string} The current version.
|
|
134
|
+
* @returns {Promise<string>} A promise that resolves with a more recent version or undefined if there's no more recent version.
|
|
135
|
+
*/
|
|
117
136
|
export async function checkForNewVersion(dependency, currentVersion) {
|
|
118
137
|
debug(content `Checking if there's a version of ${dependency} newer than ${currentVersion}`);
|
|
119
138
|
try {
|
|
@@ -130,11 +149,14 @@ export async function checkForNewVersion(dependency, currentVersion) {
|
|
|
130
149
|
return undefined;
|
|
131
150
|
}
|
|
132
151
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
137
|
-
|
|
152
|
+
/**
|
|
153
|
+
* Reads and parses a package.json
|
|
154
|
+
* @param packageJsonPath {string} Path to the package.json
|
|
155
|
+
* @returns {Promise<PackageJson>} An promise that resolves with an in-memory representation
|
|
156
|
+
* of the package.json or rejects with an error if the file is not found or the content is
|
|
157
|
+
* not decodable.
|
|
158
|
+
*/
|
|
159
|
+
export async function readAndParsePackageJson(packageJsonPath) {
|
|
138
160
|
if (!(await fileExists(packageJsonPath))) {
|
|
139
161
|
throw PackageJsonNotFoundError(dirname(packageJsonPath));
|
|
140
162
|
}
|
|
@@ -169,7 +191,7 @@ ${token.json(options)}
|
|
|
169
191
|
const depedenciesWithVersion = dependenciesToAdd.map((dep) => {
|
|
170
192
|
return dep.version ? `${dep.name}@${dep.version}` : dep.name;
|
|
171
193
|
});
|
|
172
|
-
switch (options.
|
|
194
|
+
switch (options.packageManager) {
|
|
173
195
|
case 'npm':
|
|
174
196
|
args = argumentsToAddDependenciesWithNPM(depedenciesWithVersion, options.type);
|
|
175
197
|
break;
|
|
@@ -181,7 +203,7 @@ ${token.json(options)}
|
|
|
181
203
|
break;
|
|
182
204
|
}
|
|
183
205
|
options.stdout?.write(`Executing...${args.join(' ')}`);
|
|
184
|
-
await exec(options.
|
|
206
|
+
await exec(options.packageManager, args, {
|
|
185
207
|
cwd: options.directory,
|
|
186
208
|
stdout: options.stdout,
|
|
187
209
|
stderr: options.stderr,
|
|
@@ -267,21 +289,6 @@ function argumentsToAddDependenciesWithPNPM(dependencies, type) {
|
|
|
267
289
|
}
|
|
268
290
|
return command;
|
|
269
291
|
}
|
|
270
|
-
export async function getProjectType(directory) {
|
|
271
|
-
const nodeConfigFile = pathJoin(directory, 'package.json');
|
|
272
|
-
const rubyConfigFile = pathJoin(directory, 'Gemfile');
|
|
273
|
-
const phpConfigFile = pathJoin(directory, 'composer.json');
|
|
274
|
-
if (await fileExists(nodeConfigFile)) {
|
|
275
|
-
return 'node';
|
|
276
|
-
}
|
|
277
|
-
else if (await fileExists(rubyConfigFile)) {
|
|
278
|
-
return 'ruby';
|
|
279
|
-
}
|
|
280
|
-
else if (await fileExists(phpConfigFile)) {
|
|
281
|
-
return 'php';
|
|
282
|
-
}
|
|
283
|
-
return undefined;
|
|
284
|
-
}
|
|
285
292
|
/**
|
|
286
293
|
* Given a directory it traverses the directory up looking for a package.json and if found, it reads it
|
|
287
294
|
* decodes the JSON, and returns its content as a Javascript object.
|
|
@@ -299,4 +306,4 @@ export async function findUpAndReadPackageJson(fromDirectory) {
|
|
|
299
306
|
throw FindUpAndReadPackageJsonNotFoundError(fromDirectory);
|
|
300
307
|
}
|
|
301
308
|
}
|
|
302
|
-
//# sourceMappingURL=
|
|
309
|
+
//# sourceMappingURL=node-package-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"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,OAAO,EAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,WAAW,EAAC,CAAA;KACrD;SAAM;QACL,MAAM,qCAAqC,CAAC,aAAa,CAAC,CAAA;KAC3D;AACH,CAAC","sourcesContent":["import {exec} from '../system.js'\nimport {exists as fileExists, read as readFile} from '../file.js'\nimport {glob, dirname, join as pathJoin, findUp} from '../path.js'\nimport {Abort, Bug} from '../error.js'\nimport {latestNpmPackageVersion} from '../version.js'\nimport {Version} from '../semver.js'\nimport {content, token, debug} from '../output.js'\nimport {AbortController, AbortSignal} from 'abort-controller'\nimport type {Writable} from 'node: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 pnpm lock file */\nexport const pnpmLockfile = 'pnpm-lock.yaml'\n\n/** An array containing the lockfiles from all the package managers */\nexport const lockfiles = [yarnLockfile, pnpmLockfile]\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 {string} The path to the directory that should contain a package.json\n * @returns {Abort} An abort error.\n */\nexport const PackageJsonNotFoundError = (directory: string) => {\n return new Abort(`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 {string} The directory from which the traverse has been done\n * @returns {Abort} An abort error.\n */\nexport const FindUpAndReadPackageJsonNotFoundError = (directory: string) => {\n return new Bug(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 {Object} The environment variables of the process in which the CLI runs.\n * @returns The dependency manager\n */\nexport function packageManagerUsedForCreating(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 {\n return 'npm'\n }\n}\n\n/**\n * Returns the dependency manager used by an existing project.\n * @param directory {string} The root directory of the project.\n * @returns The dependency manager\n */\nexport async function getPackageManager(directory: string): Promise<PackageManager> {\n debug(content`Obtaining the dependency manager in directory ${token.path(directory)}...`)\n const yarnLockPath = pathJoin(directory, yarnLockfile)\n const pnpmLockPath = pathJoin(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 {InstallNPMDependenciesRecursivelyOptions} Options to install dependencies recursively.\n */\nexport async function installNPMDependenciesRecursively(options: InstallNPMDependenciesRecursivelyOptions) {\n const packageJsons = await glob(pathJoin(options.directory, '**/package.json'), {\n ignore: [pathJoin(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(directory, options.packageManager, undefined, undefined, abortController.signal)\n }),\n )\n } catch (error) {\n abortController.abort()\n throw error\n }\n}\n\n/**\n * Installs the dependencies in the given directory.\n * @param directory {string} The directory that contains the package.json\n * @param packageManager {PackageManager} The package manager to use to install the dependencies.\n * @param stdout {Writable} Standard output stream.\n * @param stderr {Writable} Standard error stream.\n * @param signal {AbortSignal} Abort signal.\n * @returns stderr {Writable} Standard error stream.\n */\nexport async function installNodeModules(\n directory: string,\n packageManager: PackageManager,\n stdout?: Writable,\n stderr?: Writable,\n signal?: AbortSignal,\n) {\n const options: ExecOptions = {cwd: directory, stdin: undefined, stdout, stderr, signal}\n await exec(packageManager, ['install'], options)\n}\n\n/**\n * Returns the name of the package configured in its package.json\n * @param packageJsonPath {string} Path to the package.json file\n * @returns A promise that resolves with the name.\n */\nexport async function getPackageName(packageJsonPath: string): Promise<string> {\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 {string} 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 * Given an NPM dependency, it checks if there's a more recent version, and if there is, it returns its value.\n * @param dependency {string} The dependency name (e.g. react)\n * @param currentVersion {string} The current version.\n * @returns {Promise<string>} 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 latestNpmPackageVersion(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 */\ninterface PackageJson {\n /**\n * The absolute path to the package.json\n */\n path: string\n\n /**\n * The name attribute of the package.json\n */\n name: string\n\n /**\n * The version attribute of the package.json\n */\n version?: 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/**\n * Reads and parses a package.json\n * @param packageJsonPath {string} Path to the package.json\n * @returns {Promise<PackageJson>} 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 * \"react\": \"1.2.3\"\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 * \"react\": \"1.2.3\"\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 {string[]} List of dependencies to be added.\n * @param options {AddNPMDependenciesIfNeededOptions} Options for adding dependencies.\n */\nexport async function addNPMDependenciesIfNeeded(\n dependencies: DependencyVersion[],\n options: AddNPMDependenciesIfNeededOptions,\n force = false,\n) {\n debug(content`Adding the following dependencies if needed:\n${token.json(dependencies)}\nWith options:\n${token.json(options)}\n `)\n const packageJsonPath = pathJoin(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 if (!force) {\n dependenciesToAdd = dependencies.filter((dep) => {\n return !existingDependencies.includes(dep.name)\n })\n }\n if (dependenciesToAdd.length === 0) {\n return\n }\n let args: string[]\n const depedenciesWithVersion = dependenciesToAdd.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...${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) {\n await addNPMDependenciesIfNeeded(\n dependencies.map((dependency) => {\n return {name: dependency, version: undefined}\n }),\n options,\n )\n}\n\n// eslint-disable-next-line no-warning-comments\n// TODO: Switch it around so add-if-needed depends on this, rather than calling\n// if-needed with force: true which is counterintuitive.\nexport async function addLatestNPMDependencies(dependencies: string[], options: AddNPMDependenciesIfNeededOptions) {\n await addNPMDependenciesIfNeeded(\n dependencies.map((dependency) => {\n return {name: dependency, version: 'latest'}\n }),\n options,\n true,\n )\n}\n\n/**\n * Returns the arguments to add dependencies using NPM.\n * @param dependencies {string[]} The list of dependencies to add\n * @param type {DependencyType} The dependency type.\n * @returns {string[]} 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 {string[]} The list of dependencies to add\n * @param type {DependencyType} The dependency type.\n * @returns {string[]} 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 {string[]} The list of dependencies to add\n * @param type {DependencyType} The dependency type.\n * @returns {string[]} 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 {string} The directory from which traverse up.\n * @returns {Promise<{path: string; content: unknown}>} 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: unknown}> {\n const packageJsonPath = await findUp('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"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { AdminSession } from '
|
|
2
|
+
import { AdminSession } from '../session.js';
|
|
3
3
|
import { Writable } from 'node:stream';
|
|
4
4
|
/**
|
|
5
5
|
* Execute CLI 2.0 commands.
|
|
@@ -9,13 +9,22 @@ import { Writable } from 'node:stream';
|
|
|
9
9
|
* @param args {string[]} List of argumets to execute. (ex: ['theme', 'pull'])
|
|
10
10
|
* @param adminSession {AdminSession} Contains token and store to pass to CLI 2.0, which will be set as environment variables
|
|
11
11
|
*/
|
|
12
|
-
export declare function
|
|
12
|
+
export declare function execCLI2(args: string[], adminSession?: AdminSession): Promise<void>;
|
|
13
13
|
interface ExecThemeCheckCLIOptions {
|
|
14
|
+
/** A list of directories in which theme-check should run */
|
|
14
15
|
directories: string[];
|
|
16
|
+
/** Arguments to pass to the theme-check CLI */
|
|
15
17
|
args?: string[];
|
|
18
|
+
/** Writable to send standard output content through */
|
|
16
19
|
stdout: Writable;
|
|
20
|
+
/** Writable to send standard error content through */
|
|
17
21
|
stderr: Writable;
|
|
18
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* A function that installs (if needed) and runs the theme-check CLI.
|
|
25
|
+
* @param options {ExecThemeCheckCLIOptions} Options to customize the execution of theme-check.
|
|
26
|
+
* @returns {Promise<void>} A promise that resolves or rejects depending on the result of the underlying theme-check process.
|
|
27
|
+
*/
|
|
19
28
|
export declare function execThemeCheckCLI({ directories, args, stdout, stderr, }: ExecThemeCheckCLIOptions): Promise<void[]>;
|
|
20
29
|
export declare function version(): Promise<string | undefined>;
|
|
21
30
|
export {};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import * as file from '
|
|
2
|
-
import * as ui from '
|
|
3
|
-
import * as system from '
|
|
4
|
-
import { Abort } from '
|
|
5
|
-
import { glob, join } from '
|
|
6
|
-
import constants from '
|
|
7
|
-
import { coerce } from '
|
|
8
|
-
import { content, token } from '
|
|
1
|
+
import * as file from '../file.js';
|
|
2
|
+
import * as ui from '../ui.js';
|
|
3
|
+
import * as system from '../system.js';
|
|
4
|
+
import { Abort } from '../error.js';
|
|
5
|
+
import { glob, join } from '../path.js';
|
|
6
|
+
import constants from '../constants.js';
|
|
7
|
+
import { coerce } from '../semver.js';
|
|
8
|
+
import { content, token } from '../output.js';
|
|
9
9
|
// eslint-disable-next-line no-restricted-imports
|
|
10
10
|
import { spawn } from 'child_process';
|
|
11
11
|
import { Writable } from 'node:stream';
|
|
12
12
|
const RubyCLIVersion = '2.16.0';
|
|
13
|
-
const ThemeCheckVersion = '1.10.
|
|
13
|
+
const ThemeCheckVersion = '1.10.3';
|
|
14
14
|
const MinBundlerVersion = '2.3.8';
|
|
15
15
|
const MinRubyVersion = '2.3.0';
|
|
16
16
|
const MinRubyGemVersion = '2.5.0';
|
|
@@ -22,7 +22,7 @@ const MinRubyGemVersion = '2.5.0';
|
|
|
22
22
|
* @param args {string[]} List of argumets to execute. (ex: ['theme', 'pull'])
|
|
23
23
|
* @param adminSession {AdminSession} Contains token and store to pass to CLI 2.0, which will be set as environment variables
|
|
24
24
|
*/
|
|
25
|
-
export async function
|
|
25
|
+
export async function execCLI2(args, adminSession) {
|
|
26
26
|
await installCLIDependencies();
|
|
27
27
|
const env = {
|
|
28
28
|
...process.env,
|
|
@@ -36,6 +36,11 @@ export async function execCLI(args, adminSession) {
|
|
|
36
36
|
env,
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* A function that installs (if needed) and runs the theme-check CLI.
|
|
41
|
+
* @param options {ExecThemeCheckCLIOptions} Options to customize the execution of theme-check.
|
|
42
|
+
* @returns {Promise<void>} A promise that resolves or rejects depending on the result of the underlying theme-check process.
|
|
43
|
+
*/
|
|
39
44
|
export async function execThemeCheckCLI({ directories, args, stdout, stderr, }) {
|
|
40
45
|
await installThemeCheckCLIDependencies(stdout);
|
|
41
46
|
const processes = directories.map(async (directory) => {
|