just-scripts 2.4.1 → 2.5.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.
Files changed (64) hide show
  1. package/CHANGELOG.json +52 -1
  2. package/CHANGELOG.md +19 -2
  3. package/lib/index.d.ts +1 -1
  4. package/lib/index.d.ts.map +1 -1
  5. package/lib/index.js +4 -3
  6. package/lib/index.js.map +1 -1
  7. package/lib/interfaces/PackageJson.d.ts +16 -0
  8. package/lib/interfaces/PackageJson.d.ts.map +1 -0
  9. package/lib/interfaces/PackageJson.js +3 -0
  10. package/lib/interfaces/PackageJson.js.map +1 -0
  11. package/lib/tasks/eslintTask.d.ts +4 -0
  12. package/lib/tasks/eslintTask.d.ts.map +1 -1
  13. package/lib/tasks/eslintTask.js +4 -3
  14. package/lib/tasks/eslintTask.js.map +1 -1
  15. package/lib/tasks/jestTask.js +4 -4
  16. package/lib/tasks/jestTask.js.map +1 -1
  17. package/lib/tasks/nodeExecTask.js +2 -2
  18. package/lib/tasks/nodeExecTask.js.map +1 -1
  19. package/lib/tasks/prettierTask.js +2 -2
  20. package/lib/tasks/prettierTask.js.map +1 -1
  21. package/lib/tasks/tscTask.js +5 -5
  22. package/lib/tasks/tscTask.js.map +1 -1
  23. package/lib/tasks/tslintTask.js +3 -3
  24. package/lib/tasks/tslintTask.js.map +1 -1
  25. package/lib/tasks/webpackCliTask.js +2 -2
  26. package/lib/tasks/webpackCliTask.js.map +1 -1
  27. package/lib/tasks/webpackDevServerTask.js +3 -3
  28. package/lib/tasks/webpackDevServerTask.js.map +1 -1
  29. package/lib/utils/exec.d.ts +48 -0
  30. package/lib/utils/exec.d.ts.map +1 -0
  31. package/lib/utils/exec.js +115 -0
  32. package/lib/utils/exec.js.map +1 -0
  33. package/lib/utils/index.d.ts +5 -0
  34. package/lib/utils/index.d.ts.map +1 -0
  35. package/lib/utils/index.js +19 -0
  36. package/lib/utils/index.js.map +1 -0
  37. package/lib/utils/mergePackageJson.d.ts +20 -0
  38. package/lib/utils/mergePackageJson.d.ts.map +1 -0
  39. package/lib/utils/mergePackageJson.js +61 -0
  40. package/lib/utils/mergePackageJson.js.map +1 -0
  41. package/lib/utils/paths.d.ts +13 -0
  42. package/lib/utils/paths.d.ts.map +1 -0
  43. package/lib/utils/paths.js +26 -0
  44. package/lib/utils/paths.js.map +1 -0
  45. package/lib/utils/readPackageJson.d.ts +8 -0
  46. package/lib/utils/readPackageJson.d.ts.map +1 -0
  47. package/lib/utils/readPackageJson.js +19 -0
  48. package/lib/utils/readPackageJson.js.map +1 -0
  49. package/package.json +2 -3
  50. package/src/index.ts +1 -1
  51. package/src/interfaces/PackageJson.ts +16 -0
  52. package/src/tasks/eslintTask.ts +6 -1
  53. package/src/tasks/jestTask.ts +2 -2
  54. package/src/tasks/nodeExecTask.ts +1 -1
  55. package/src/tasks/prettierTask.ts +1 -1
  56. package/src/tasks/tscTask.ts +1 -1
  57. package/src/tasks/tslintTask.ts +1 -1
  58. package/src/tasks/webpackCliTask.ts +1 -1
  59. package/src/tasks/webpackDevServerTask.ts +1 -1
  60. package/src/utils/exec.ts +126 -0
  61. package/src/utils/index.ts +4 -0
  62. package/src/utils/mergePackageJson.ts +64 -0
  63. package/src/utils/paths.ts +26 -0
  64. package/src/utils/readPackageJson.ts +16 -0
@@ -0,0 +1,115 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.spawn = exports.execSync = exports.encodeArgs = exports.exec = void 0;
4
+ const cp = require("child_process");
5
+ const path_1 = require("path");
6
+ const SEPARATOR = process.platform === 'win32' ? ';' : ':';
7
+ /**
8
+ * Execute a command.
9
+ *
10
+ * @param cmd Command to execute
11
+ * @param opts Normal exec options plus stdout/stderr for piping output. Can pass `process` for this param.
12
+ * @returns Promise which will settle when the command completes. If output was not piped, it will be
13
+ * returned as the promise's value. If the promise was rejected, the error will be of type `ExecError`.
14
+ */
15
+ function exec(cmd, opts = {}) {
16
+ return new Promise((resolve, reject) => {
17
+ var _a, _b;
18
+ const child = cp.exec(cmd, opts, (error, stdout, stderr) => {
19
+ if (error) {
20
+ error.stdout = stdout;
21
+ error.stderr = stderr;
22
+ reject(error);
23
+ }
24
+ else {
25
+ resolve(stdout);
26
+ }
27
+ });
28
+ if (opts.stdout) {
29
+ (_a = child.stdout) === null || _a === void 0 ? void 0 : _a.pipe(opts.stdout);
30
+ }
31
+ if (opts.stderr) {
32
+ (_b = child.stderr) === null || _b === void 0 ? void 0 : _b.pipe(opts.stderr);
33
+ }
34
+ });
35
+ }
36
+ exports.exec = exec;
37
+ /**
38
+ * Encode args for a shell command.
39
+ * @param cmdArgs Args to encode
40
+ * @returns Encoded args
41
+ */
42
+ function encodeArgs(cmdArgs) {
43
+ // Taken from https://github.com/xxorax/node-shell-escape/blob/master/shell-escape.js
44
+ // However, we needed to use double quotes because that's the norm in more platforms
45
+ if (!cmdArgs) {
46
+ return cmdArgs;
47
+ }
48
+ return cmdArgs.map(arg => {
49
+ if (/[^\w/:=-]/.test(arg)) {
50
+ arg = `"${arg.replace(/"/g, '"\\"')}"`;
51
+ arg = arg.replace(/^(?:"")+/g, '').replace(/\\"""/g, '\\"');
52
+ }
53
+ return arg;
54
+ });
55
+ }
56
+ exports.encodeArgs = encodeArgs;
57
+ /**
58
+ * Execute a command synchronously.
59
+ *
60
+ * @param cmd Command to execute
61
+ * @param cwd Working directory in which to run the command (default: `process.cwd()`)
62
+ * @param returnOutput If true, return the command's output. If false/unspecified,
63
+ * inherit stdio from the parent process (so the child's output goes to the console).
64
+ * @returns If `returnOutput` is true, returns the command's output. Otherwise returns undefined.
65
+ */
66
+ function execSync(cmd, cwd, returnOutput) {
67
+ cwd = cwd || process.cwd();
68
+ const env = { ...process.env };
69
+ env.PATH = (0, path_1.resolve)('./node_modules/.bin') + SEPARATOR + env.PATH;
70
+ const output = cp.execSync(cmd, {
71
+ cwd,
72
+ env,
73
+ stdio: returnOutput ? undefined : 'inherit',
74
+ });
75
+ return returnOutput ? (output || '').toString('utf8') : undefined;
76
+ }
77
+ exports.execSync = execSync;
78
+ /**
79
+ * Execute a command in a new process.
80
+ *
81
+ * @param cmd Command to execute
82
+ * @param args Args for the command
83
+ * @param opts Normal spawn options plus stdout/stderr for piping output. Can pass `process` for this param.
84
+ * @returns Promise which will settle when the command completes. If the promise is rejected, the error will
85
+ * include the child process's exit code.
86
+ */
87
+ function spawn(cmd, args = [], opts = {}) {
88
+ return new Promise((resolve, reject) => {
89
+ var _a, _b;
90
+ const child = cp.spawn(cmd, args, opts);
91
+ child.on('exit', (code, signal) => {
92
+ if (code) {
93
+ const error = new Error('Command failed: ' + [cmd, ...args].join(' '));
94
+ error.code = code;
95
+ reject(error);
96
+ }
97
+ else if (signal) {
98
+ const error = new Error(`Command terminated by signal ${signal}: ` + [cmd, ...args].join(' '));
99
+ error.signal = signal;
100
+ reject(error);
101
+ }
102
+ else {
103
+ resolve();
104
+ }
105
+ });
106
+ if (opts.stdout) {
107
+ (_a = child.stdout) === null || _a === void 0 ? void 0 : _a.pipe(opts.stdout);
108
+ }
109
+ if (opts.stderr) {
110
+ (_b = child.stderr) === null || _b === void 0 ? void 0 : _b.pipe(opts.stderr);
111
+ }
112
+ });
113
+ }
114
+ exports.spawn = spawn;
115
+ //# sourceMappingURL=exec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"exec.js","sourceRoot":"","sources":["../../src/utils/exec.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;AACpC,+BAA+B;AAO/B,MAAM,SAAS,GAAG,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AAE3D;;;;;;;GAOG;AACH,SAAgB,IAAI,CAClB,GAAW,EACX,OAA4F,EAAE;IAE9F,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;;QACrC,MAAM,KAAK,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,C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;gBAC9F,KAAa,CAAC,MAAM,GAAG,MAAM,CAAC;gBAC/B,MAAM,CAAC,KAAK,CAAC,CAAC;aACf;iBAAM;gBACL,OAAO,EAAE,CAAC;aACX;QACH,CAAC,CAAC,CAAC;QAEH,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,MAAA,KAAK,CAAC,MAAM,0CAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACjC;QACD,IAAI,IAAI,CAAC,MAAM,EAAE;YACf,MAAA,KAAK,CAAC,MAAM,0CAAE,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;SACjC;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AA5BD,sBA4BC"}
@@ -0,0 +1,5 @@
1
+ export * from './exec';
2
+ export { mergePackageJson } from './mergePackageJson';
3
+ export * from './paths';
4
+ export * from './readPackageJson';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.mergePackageJson = void 0;
14
+ __exportStar(require("./exec"), exports);
15
+ var mergePackageJson_1 = require("./mergePackageJson");
16
+ Object.defineProperty(exports, "mergePackageJson", { enumerable: true, get: function () { return mergePackageJson_1.mergePackageJson; } });
17
+ __exportStar(require("./paths"), exports);
18
+ __exportStar(require("./readPackageJson"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,yCAAuB;AACvB,uDAAsD;AAA7C,oHAAA,gBAAgB,OAAA;AACzB,0CAAwB;AACxB,oDAAkC"}
@@ -0,0 +1,20 @@
1
+ import { PackageJson } from '../interfaces/PackageJson';
2
+ /**
3
+ * Merges an incoming package.json with an original semantically. It can only handle merging
4
+ * dependencies and devDependencies for ranges that look like "^x.y.z" or "~x.y.z" or "x.y.z".
5
+ *
6
+ * @param original Original package.json contents.
7
+ * @param incoming Incoming package.json contents.
8
+ * @returns Returns a new package.json object if any changes were needed, or returns `original`
9
+ * if not. (You can tell if changes were made by checking the object identity.)
10
+ */
11
+ export declare function mergePackageJson(original: PackageJson, incoming: PackageJson): PackageJson;
12
+ /**
13
+ * Exported for testing only. Determines whether a dep should be updated.
14
+ * Returns false if either version includes semver elements we don't understand
15
+ * (any characters besides number and ~ ^).
16
+ * @param originalVersion The original dep version (default 0.0.0)
17
+ * @param incomingVersion The incoming dep version
18
+ */
19
+ export declare function _shouldUpdateDep(originalVersion: string | undefined, incomingVersion: string): boolean;
20
+ //# sourceMappingURL=mergePackageJson.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergePackageJson.d.ts","sourceRoot":"","sources":["../../src/utils/mergePackageJson.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,GAAG,WAAW,CA4B1F;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CActG"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports._shouldUpdateDep = exports.mergePackageJson = void 0;
4
+ const semver = require("semver");
5
+ /**
6
+ * Merges an incoming package.json with an original semantically. It can only handle merging
7
+ * dependencies and devDependencies for ranges that look like "^x.y.z" or "~x.y.z" or "x.y.z".
8
+ *
9
+ * @param original Original package.json contents.
10
+ * @param incoming Incoming package.json contents.
11
+ * @returns Returns a new package.json object if any changes were needed, or returns `original`
12
+ * if not. (You can tell if changes were made by checking the object identity.)
13
+ */
14
+ function mergePackageJson(original, incoming) {
15
+ if (!original.just) {
16
+ return original;
17
+ }
18
+ // deep copy the deps and devDeps
19
+ const newPackageJson = {
20
+ ...original,
21
+ dependencies: { ...(original.dependencies || {}) },
22
+ devDependencies: { ...(original.devDependencies || {}) },
23
+ };
24
+ const depTypes = ['dependencies', 'devDependencies'];
25
+ let packageJsonModified = false;
26
+ depTypes.forEach(depType => {
27
+ const incomingDeps = incoming[depType] || {};
28
+ const originalDeps = original[depType] || {};
29
+ Object.keys(incomingDeps).forEach(dep => {
30
+ // TODO: should this handle deleting deps that exist in originalDeps but not incomingDeps?
31
+ if (_shouldUpdateDep(originalDeps[dep], incomingDeps[dep])) {
32
+ newPackageJson[depType][dep] = incomingDeps[dep];
33
+ packageJsonModified = true;
34
+ }
35
+ });
36
+ });
37
+ return packageJsonModified ? newPackageJson : original;
38
+ }
39
+ exports.mergePackageJson = mergePackageJson;
40
+ /**
41
+ * Exported for testing only. Determines whether a dep should be updated.
42
+ * Returns false if either version includes semver elements we don't understand
43
+ * (any characters besides number and ~ ^).
44
+ * @param originalVersion The original dep version (default 0.0.0)
45
+ * @param incomingVersion The incoming dep version
46
+ */
47
+ function _shouldUpdateDep(originalVersion, incomingVersion) {
48
+ const strippedOriginalVersion = (originalVersion || '0.0.0').replace(/^[~^]/, '');
49
+ const strippedIncomingVersion = incomingVersion.replace(/^[~^]/, '');
50
+ // semver.valid only returns true for a valid SINGLE version, not any type of range
51
+ if (!semver.valid(strippedOriginalVersion) || !semver.valid(strippedIncomingVersion)) {
52
+ // The original and/or incoming versions (with ~ and ^ removed) can't be understood as a single
53
+ // semver version. They might be valid ranges of some other form (like with x or ||), but we
54
+ // don't currently handle those. Do nothing.
55
+ return false;
56
+ }
57
+ // Modify the version if the range is comparable and is greater
58
+ return semver.gt(strippedIncomingVersion, strippedOriginalVersion);
59
+ }
60
+ exports._shouldUpdateDep = _shouldUpdateDep;
61
+ //# sourceMappingURL=mergePackageJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mergePackageJson.js","sourceRoot":"","sources":["../../src/utils/mergePackageJson.ts"],"names":[],"mappings":";;;AACA,iCAAkC;AAElC;;;;;;;;GAQG;AACH,SAAgB,gBAAgB,CAAC,QAAqB,EAAE,QAAqB;IAC3E,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE;QAClB,OAAO,QAAQ,CAAC;KACjB;IAED,iCAAiC;IACjC,MAAM,cAAc,GAAgB;QAClC,GAAG,QAAQ;QACX,YAAY,EAAE,EAAE,GAAG,CAAC,QAAQ,CAAC,YAAY,IAAI,EAAE,CAAC,EAAE;QAClD,eAAe,EAAE,EAAE,GAAG,CAAC,QAAQ,CAAC,eAAe,IAAI,EAAE,CAAC,EAAE;KACzD,CAAC;IAEF,MAAM,QAAQ,GAAG,CAAC,cAAc,EAAE,iBAAiB,CAAC,CAAC;IACrD,IAAI,mBAAmB,GAAG,KAAK,CAAC;IAChC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACzB,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAC7C,MAAM,YAAY,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;QAE7C,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE;YACtC,0FAA0F;YAC1F,IAAI,gBAAgB,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE;gBAC1D,cAAc,CAAC,OAAO,CAAC,CAAC,GAAG,CAAC,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC;gBACjD,mBAAmB,GAAG,IAAI,CAAC;aAC5B;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,mBAAmB,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,QAAQ,CAAC;AACzD,CAAC;AA5BD,4CA4BC;AAED;;;;;;GAMG;AACH,SAAgB,gBAAgB,CAAC,eAAmC,EAAE,eAAuB;IAC3F,MAAM,uBAAuB,GAAG,CAAC,eAAe,IAAI,OAAO,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAClF,MAAM,uBAAuB,GAAG,eAAe,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;IAErE,mFAAmF;IACnF,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,uBAAuB,CAAC,EAAE;QACpF,+FAA+F;QAC/F,4FAA4F;QAC5F,4CAA4C;QAC5C,OAAO,KAAK,CAAC;KACd;IAED,+DAA+D;IAC/D,OAAO,MAAM,CAAC,EAAE,CAAC,uBAAuB,EAAE,uBAAuB,CAAC,CAAC;AACrE,CAAC;AAdD,4CAcC"}
@@ -0,0 +1,13 @@
1
+ export declare const paths: {
2
+ /**
3
+ * Location where the generated project will go. Defaults to `process.cwd()`.
4
+ */
5
+ projectPath: string;
6
+ /**
7
+ * Gets a directory path under `${os.tmpdir()}/just-stack` for temporarily storing files.
8
+ * @param segments Names of extra directory segments to include.
9
+ * @returns The directory path.
10
+ */
11
+ tempPath(...segments: string[]): string;
12
+ };
13
+ //# sourceMappingURL=paths.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../src/utils/paths.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,KAAK;IAChB;;OAEG;;IASH;;;;OAIG;0BACmB,MAAM,EAAE,GAAG,MAAM;CAGxC,CAAC"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.paths = void 0;
4
+ const path = require("path");
5
+ const os = require("os");
6
+ let projectPath = '';
7
+ exports.paths = {
8
+ /**
9
+ * Location where the generated project will go. Defaults to `process.cwd()`.
10
+ */
11
+ get projectPath() {
12
+ return projectPath || process.cwd();
13
+ },
14
+ set projectPath(value) {
15
+ projectPath = value;
16
+ },
17
+ /**
18
+ * Gets a directory path under `${os.tmpdir()}/just-stack` for temporarily storing files.
19
+ * @param segments Names of extra directory segments to include.
20
+ * @returns The directory path.
21
+ */
22
+ tempPath(...segments) {
23
+ return path.resolve(os.tmpdir(), 'just-stack', ...segments);
24
+ },
25
+ };
26
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../../src/utils/paths.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAC7B,yBAAyB;AAEzB,IAAI,WAAW,GAAG,EAAE,CAAC;AAER,QAAA,KAAK,GAAG;IACnB;;OAEG;IACH,IAAI,WAAW;QACb,OAAO,WAAW,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;IACtC,CAAC;IAED,IAAI,WAAW,CAAC,KAAa;QAC3B,WAAW,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,QAAQ,CAAC,GAAG,QAAkB;QAC5B,OAAO,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAC,CAAC;IAC9D,CAAC;CACF,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { PackageJson } from '../interfaces/PackageJson';
2
+ /**
3
+ * Reads and parses the package.json file from the given folder.
4
+ * @param folderPath The folder path to look for a package.json in.
5
+ * @returns The parsed file contents, or undefined if the file doesn't exist.
6
+ */
7
+ export declare function readPackageJson(folderPath: string): PackageJson | undefined;
8
+ //# sourceMappingURL=readPackageJson.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readPackageJson.d.ts","sourceRoot":"","sources":["../../src/utils/readPackageJson.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS,CAM3E"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readPackageJson = void 0;
4
+ const path = require("path");
5
+ const fse = require("fs-extra");
6
+ /**
7
+ * Reads and parses the package.json file from the given folder.
8
+ * @param folderPath The folder path to look for a package.json in.
9
+ * @returns The parsed file contents, or undefined if the file doesn't exist.
10
+ */
11
+ function readPackageJson(folderPath) {
12
+ const packageJsonPath = path.join(folderPath, 'package.json');
13
+ if (fse.existsSync(packageJsonPath)) {
14
+ return fse.readJsonSync(packageJsonPath, { throws: false }) || undefined;
15
+ }
16
+ return undefined;
17
+ }
18
+ exports.readPackageJson = readPackageJson;
19
+ //# sourceMappingURL=readPackageJson.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readPackageJson.js","sourceRoot":"","sources":["../../src/utils/readPackageJson.ts"],"names":[],"mappings":";;;AAAA,6BAA6B;AAE7B,gCAAiC;AAEjC;;;;GAIG;AACH,SAAgB,eAAe,CAAC,UAAkB;IAChD,MAAM,eAAe,GAAG,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC;IAC9D,IAAI,GAAG,CAAC,UAAU,CAAC,eAAe,CAAC,EAAE;QACnC,OAAO,GAAG,CAAC,YAAY,CAAC,eAAe,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,IAAI,SAAS,CAAC;KAC1E;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAND,0CAMC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "just-scripts",
3
- "version": "2.4.1",
3
+ "version": "2.5.0",
4
4
  "description": "Just Stack Scripts",
5
5
  "keywords": [],
6
6
  "repository": {
@@ -31,8 +31,7 @@
31
31
  "diff-match-patch": "1.0.5",
32
32
  "fs-extra": "^11.0.0",
33
33
  "glob": "^7.1.3",
34
- "just-scripts-utils": "^2.1.0",
35
- "just-task": ">=1.12.0 <2.0.0",
34
+ "just-task": ">=1.13.0 <2.0.0",
36
35
  "prompts": "^2.4.0",
37
36
  "run-parallel-limit": "^1.0.6",
38
37
  "semver": "^7.0.0",
package/src/index.ts CHANGED
@@ -43,4 +43,4 @@ export { copyInstructions };
43
43
 
44
44
  export * from 'just-task';
45
45
 
46
- export { spawn } from 'just-scripts-utils';
46
+ export { encodeArgs, spawn } from './utils';
@@ -0,0 +1,16 @@
1
+ export interface Dependencies {
2
+ [key: string]: string;
3
+ }
4
+
5
+ export interface PackageJson {
6
+ name: string;
7
+ description?: string;
8
+ dependencies?: Dependencies;
9
+ devDependencies?: Dependencies;
10
+ keywords?: string;
11
+ just?: {
12
+ /** Stack that the package is tracking */
13
+ stack?: string;
14
+ };
15
+ [key: string]: any;
16
+ }
@@ -1,5 +1,5 @@
1
1
  import { resolve, logger, resolveCwd, TaskFunction } from 'just-task';
2
- import { encodeArgs, spawn } from 'just-scripts-utils';
2
+ import { encodeArgs, spawn } from '../utils';
3
3
  import * as fs from 'fs';
4
4
 
5
5
  /**
@@ -33,6 +33,10 @@ export interface EsLintTaskOptions {
33
33
  * This will be passed as an environment variable to eslint with the value ESLINT_USE_FLAT_CONFIG (https://eslint.org/blog/2024/04/eslint-v9.0.0-released/#flat-config-is-now-the-default-and-has-some-changes).
34
34
  */
35
35
  useFlatConfig?: boolean;
36
+ /**
37
+ * When set to true, eslint will report any eslint-disable comments that are not used as an error.
38
+ */
39
+ reportUnusedDisableDirectives?: boolean;
36
40
  }
37
41
 
38
42
  export function eslintTask(options: EsLintTaskOptions = {}): TaskFunction {
@@ -77,6 +81,7 @@ export function eslintTask(options: EsLintTaskOptions = {}): TaskFunction {
77
81
  ...(outputFile ? ['--output-file', outputFile] : []),
78
82
  ...(format ? ['--format', format] : []),
79
83
  ...(quiet ? ['--quiet'] : []),
84
+ ...(options.reportUnusedDisableDirectives ? ['--report-unused-disable-directives'] : []),
80
85
  '--color',
81
86
  ];
82
87
 
@@ -1,5 +1,5 @@
1
1
  import { resolve, logger, resolveCwd, TaskFunction, argv } from 'just-task';
2
- import { spawn, encodeArgs, readPackageJson } from 'just-scripts-utils';
2
+ import { spawn, encodeArgs, readPackageJson } from '../utils';
3
3
  import { existsSync } from 'fs';
4
4
  import * as supportsColor from 'supports-color';
5
5
 
@@ -72,7 +72,7 @@ export function jestTask(options: JestTaskOptions = {}): TaskFunction {
72
72
  ...(options.silent ? ['--silent'] : []),
73
73
  ...(options.testPathPattern ? ['--testPathPattern', options.testPathPattern] : []),
74
74
  ...(options.testNamePattern ? ['--testNamePattern', options.testNamePattern] : []),
75
- ...(options.maxWorkers ? ['--maxWorkers', options.maxWorkers]: []),
75
+ ...(options.maxWorkers ? ['--maxWorkers', options.maxWorkers] : []),
76
76
  ...(options.u || options.updateSnapshot ? ['--updateSnapshot'] : ['']),
77
77
  // Only include the positional args if `options._` wasn't specified
78
78
  // (to avoid possibly including them twice)
@@ -1,5 +1,5 @@
1
1
  import { SpawnOptions } from 'child_process';
2
- import { spawn } from 'just-scripts-utils';
2
+ import { spawn } from '../utils';
3
3
  import { logger, TaskFunction } from 'just-task';
4
4
  import { resolveCwd, _tryResolve } from 'just-task/lib/resolve';
5
5
  import { getTsNodeEnv } from '../typescript/getTsNodeEnv';
@@ -1,5 +1,5 @@
1
1
  import { logger, resolve, TaskFunction } from 'just-task';
2
- import { spawn } from 'just-scripts-utils';
2
+ import { spawn } from '../utils';
3
3
  import { splitArrayIntoChunks } from '../arrayUtils/splitArrayIntoChunks';
4
4
  import * as path from 'path';
5
5
  import { arrayify } from '../arrayUtils/arrayify';
@@ -1,6 +1,6 @@
1
1
  import * as ts from 'typescript';
2
2
  import { resolve, logger, resolveCwd, TaskFunction } from 'just-task';
3
- import { exec, encodeArgs, spawn } from 'just-scripts-utils';
3
+ import { exec, encodeArgs, spawn } from '../utils';
4
4
  import * as fs from 'fs';
5
5
 
6
6
  export type TscTaskOptions = { [key in keyof ts.CompilerOptions]?: string | boolean | string[] } & {
@@ -1,5 +1,5 @@
1
1
  import { resolve, logger, resolveCwd, TaskFunction } from 'just-task';
2
- import { exec, encodeArgs } from 'just-scripts-utils';
2
+ import { exec, encodeArgs } from '../utils';
3
3
  import * as path from 'path';
4
4
  import * as fs from 'fs';
5
5
 
@@ -1,5 +1,5 @@
1
1
  import { logger, TaskFunction, resolve } from 'just-task';
2
- import { spawn } from 'just-scripts-utils';
2
+ import { spawn } from '../utils';
3
3
  import { getTsNodeEnv } from '../typescript/getTsNodeEnv';
4
4
  import { findWebpackConfig } from '../webpack/findWebpackConfig';
5
5
 
@@ -1,6 +1,6 @@
1
1
  // // WARNING: Careful about add more imports - only import types from webpack
2
2
  import { Configuration } from 'webpack';
3
- import { encodeArgs, spawn } from 'just-scripts-utils';
3
+ import { encodeArgs, spawn } from '../utils';
4
4
  import { logger, resolve, resolveCwd, TaskFunction } from 'just-task';
5
5
  import * as fs from 'fs';
6
6
  import * as path from 'path';
@@ -0,0 +1,126 @@
1
+ import * as cp from 'child_process';
2
+ import { resolve } from 'path';
3
+
4
+ export interface ExecError extends cp.ExecException {
5
+ stdout?: string;
6
+ stderr?: string;
7
+ }
8
+
9
+ const SEPARATOR = process.platform === 'win32' ? ';' : ':';
10
+
11
+ /**
12
+ * Execute a command.
13
+ *
14
+ * @param cmd Command to execute
15
+ * @param opts Normal exec options plus stdout/stderr for piping output. Can pass `process` for this param.
16
+ * @returns Promise which will settle when the command completes. If output was not piped, it will be
17
+ * returned as the promise's value. If the promise was rejected, the error will be of type `ExecError`.
18
+ */
19
+ export function exec(
20
+ cmd: string,
21
+ opts: cp.ExecOptions & { stdout?: NodeJS.WritableStream; stderr?: NodeJS.WritableStream } = {},
22
+ ): Promise<string | undefined> {
23
+ return new Promise((resolve, reject) => {
24
+ const child = cp.exec(cmd, opts, (error: ExecError | null, stdout?: string, stderr?: string) => {
25
+ if (error) {
26
+ error.stdout = stdout;
27
+ error.stderr = stderr;
28
+ reject(error);
29
+ } else {
30
+ resolve(stdout);
31
+ }
32
+ });
33
+
34
+ if (opts.stdout) {
35
+ child.stdout?.pipe(opts.stdout);
36
+ }
37
+
38
+ if (opts.stderr) {
39
+ child.stderr?.pipe(opts.stderr);
40
+ }
41
+ });
42
+ }
43
+
44
+ /**
45
+ * Encode args for a shell command.
46
+ * @param cmdArgs Args to encode
47
+ * @returns Encoded args
48
+ */
49
+ export function encodeArgs(cmdArgs: string[]): string[] {
50
+ // Taken from https://github.com/xxorax/node-shell-escape/blob/master/shell-escape.js
51
+ // However, we needed to use double quotes because that's the norm in more platforms
52
+ if (!cmdArgs) {
53
+ return cmdArgs;
54
+ }
55
+
56
+ return cmdArgs.map(arg => {
57
+ if (/[^\w/:=-]/.test(arg)) {
58
+ arg = `"${arg.replace(/"/g, '"\\"')}"`;
59
+ arg = arg.replace(/^(?:"")+/g, '').replace(/\\"""/g, '\\"');
60
+ }
61
+
62
+ return arg;
63
+ });
64
+ }
65
+
66
+ /**
67
+ * Execute a command synchronously.
68
+ *
69
+ * @param cmd Command to execute
70
+ * @param cwd Working directory in which to run the command (default: `process.cwd()`)
71
+ * @param returnOutput If true, return the command's output. If false/unspecified,
72
+ * inherit stdio from the parent process (so the child's output goes to the console).
73
+ * @returns If `returnOutput` is true, returns the command's output. Otherwise returns undefined.
74
+ */
75
+ export function execSync(cmd: string, cwd?: string, returnOutput?: boolean): string | undefined {
76
+ cwd = cwd || process.cwd();
77
+
78
+ const env = { ...process.env };
79
+ env.PATH = resolve('./node_modules/.bin') + SEPARATOR + env.PATH;
80
+
81
+ const output = cp.execSync(cmd, {
82
+ cwd,
83
+ env,
84
+ stdio: returnOutput ? undefined : 'inherit',
85
+ });
86
+ return returnOutput ? (output || '').toString('utf8') : undefined;
87
+ }
88
+
89
+ /**
90
+ * Execute a command in a new process.
91
+ *
92
+ * @param cmd Command to execute
93
+ * @param args Args for the command
94
+ * @param opts Normal spawn options plus stdout/stderr for piping output. Can pass `process` for this param.
95
+ * @returns Promise which will settle when the command completes. If the promise is rejected, the error will
96
+ * include the child process's exit code.
97
+ */
98
+ export function spawn(
99
+ cmd: string,
100
+ args: ReadonlyArray<string> = [],
101
+ opts: cp.SpawnOptions & { stdout?: NodeJS.WritableStream; stderr?: NodeJS.WritableStream } = {},
102
+ ): Promise<void> {
103
+ return new Promise((resolve, reject) => {
104
+ const child = cp.spawn(cmd, args, opts);
105
+ child.on('exit', (code: number | null, signal: string | null) => {
106
+ if (code) {
107
+ const error = new Error('Command failed: ' + [cmd, ...args].join(' '));
108
+ (error as any).code = code;
109
+ reject(error);
110
+ } else if (signal) {
111
+ const error = new Error(`Command terminated by signal ${signal}: ` + [cmd, ...args].join(' '));
112
+ (error as any).signal = signal;
113
+ reject(error);
114
+ } else {
115
+ resolve();
116
+ }
117
+ });
118
+
119
+ if (opts.stdout) {
120
+ child.stdout?.pipe(opts.stdout);
121
+ }
122
+ if (opts.stderr) {
123
+ child.stderr?.pipe(opts.stderr);
124
+ }
125
+ });
126
+ }
@@ -0,0 +1,4 @@
1
+ export * from './exec';
2
+ export { mergePackageJson } from './mergePackageJson';
3
+ export * from './paths';
4
+ export * from './readPackageJson';