@smarlhens/npm-check-engines 0.6.0 → 0.7.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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.7.0](https://github.com/smarlhens/npm-check-engines/compare/v0.6.0...v0.7.0) (2022-07-03)
4
+
5
+
6
+ ### Features
7
+
8
+ * tips to upgrade package.json when new computed range constraints are available ([17ea35f](https://github.com/smarlhens/npm-check-engines/commit/17ea35f2e0eb2240c85c46fc16fdef25411d0188))
9
+
10
+
11
+ ### Documentation
12
+
13
+ * **readme:** add missing thanks link in toc ([0e579a4](https://github.com/smarlhens/npm-check-engines/commit/0e579a4d475936c59595ac18301c0ac0c600fe76))
14
+
3
15
  ## [0.6.0](https://github.com/smarlhens/npm-check-engines/compare/v0.5.0...v0.6.0) (2022-07-03)
4
16
 
5
17
 
package/README.md CHANGED
@@ -19,6 +19,7 @@
19
19
  - [Usage](#usage)
20
20
  - [Options](#options)
21
21
  - [Debug](#debug)
22
+ - [Thanks](#thanks)
22
23
 
23
24
  ---
24
25
 
@@ -53,6 +54,8 @@ $ nce
53
54
  ✔ Computed engines range constraints:
54
55
 
55
56
  node * → ^14.17.0 || ^16.10.0 || >=17.0.0
57
+
58
+ Run nce -u to upgrade package.json.
56
59
  ```
57
60
 
58
61
  Upgrade a project's `package.json` file:
@@ -166,12 +169,16 @@ $ DEBUG=* nce -d
166
169
  [TITLE] Computed engines range constraints:
167
170
  [TITLE]
168
171
  [TITLE] node * → ^14.17.0 || ^16.10.0 || >=17.0.0
172
+ [TITLE]
173
+ [TITLE] Run nce -p examples -d -u to upgrade package.json.
169
174
  [SUCCESS] Output computed engines range constraints...
170
175
  [STARTED] Update package.json file...
171
176
  [SKIPPED] Update is disabled by default.
172
177
  [SUCCESS] Computed engines range constraints:
173
178
  [SUCCESS]
174
179
  [SUCCESS] node * → ^14.17.0 || ^16.10.0 || >=17.0.0
180
+ [SUCCESS]
181
+ [SUCCESS] Run nce -p examples -d -u to upgrade package.json.
175
182
  ```
176
183
 
177
184
  </details>
package/dist/lib/tasks.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.cliCommandTask = exports.checkCommandTasks = exports.updatePackageJson = exports.outputComputedConstraints = exports.computeEnginesConstraints = exports.loadPackageLockFile = exports.loadPackageFile = exports.humanizeRange = exports.restrictiveRange = exports.applyMinVersionToRangeSet = exports.setToRange = exports.sortRangeSet = exports.rangeOptions = void 0;
3
+ exports.cliCommandTask = exports.checkCommandTasks = exports.updatePackageJson = exports.outputComputedConstraints = exports.generateUpdateCommandFromContext = exports.computeEnginesConstraints = exports.loadPackageLockFile = exports.loadPackageFile = exports.humanizeRange = exports.restrictiveRange = exports.applyMinVersionToRangeSet = exports.setToRange = exports.sortRangeSet = exports.rangeOptions = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const cli_table_1 = tslib_1.__importDefault(require("cli-table"));
6
6
  const colorette_1 = require("colorette");
@@ -244,8 +244,33 @@ const createEnginesTable = (colWidths) => {
244
244
  },
245
245
  });
246
246
  };
247
+ const generateUpdateCommandFromContext = (ctx) => {
248
+ const argv = ['nce'];
249
+ let path = undefined;
250
+ if (typeof ctx.path === 'string' && ctx.path.length > 0) {
251
+ path = (0, utils_1.getRelativePath)({ path: ctx.path, workingDir: ctx.workingDir });
252
+ }
253
+ if (typeof path === 'string' && path.length > 0) {
254
+ argv.push(...['-p', path]);
255
+ }
256
+ if (ctx.engines) {
257
+ argv.push(...ctx.engines.map(e => ['-e', e]).flat());
258
+ }
259
+ if (ctx.quiet) {
260
+ argv.push('-q');
261
+ }
262
+ if (ctx.debug) {
263
+ argv.push('-d');
264
+ }
265
+ if (ctx.verbose) {
266
+ argv.push('-v');
267
+ }
268
+ argv.push('-u');
269
+ return argv.join(' ');
270
+ };
271
+ exports.generateUpdateCommandFromContext = generateUpdateCommandFromContext;
247
272
  const outputComputedConstraints = ({ ctx, parent, debug }) => {
248
- const { ranges } = ctx;
273
+ const { ranges, packageObject, update } = ctx;
249
274
  if (!ranges) {
250
275
  throw new Error(`Computed engines range constraints are not defined.`);
251
276
  }
@@ -275,7 +300,11 @@ const outputComputedConstraints = ({ ctx, parent, debug }) => {
275
300
  else {
276
301
  const table = createEnginesTable(colWidths);
277
302
  table.push(...colValues);
278
- parent.title = `Computed engines range constraints:\n\n${table.toString()}`;
303
+ let title = `Computed engines range constraints:\n\n${table.toString()}`;
304
+ if (!update) {
305
+ title += `\n\nRun ${(0, colorette_1.cyan)((0, exports.generateUpdateCommandFromContext)(ctx))} to upgrade ${packageObject.filename}.`;
306
+ }
307
+ parent.title = title;
279
308
  }
280
309
  ctx.rangesSimplified = rangesSimplified;
281
310
  };
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smarlhens/npm-check-engines",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Node.JS engines constraint checker written in TypeScript.",
5
5
  "keywords": [
6
6
  "node",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smarlhens/npm-check-engines",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Node.JS engines constraint checker written in TypeScript.",
5
5
  "keywords": [
6
6
  "node",