@oclif/core 3.0.0-beta.17 → 3.0.0-beta.19

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 (69) hide show
  1. package/lib/args.js +4 -4
  2. package/lib/cli-ux/action/base.js +8 -7
  3. package/lib/cli-ux/action/simple.js +1 -4
  4. package/lib/cli-ux/action/spinner.js +8 -7
  5. package/lib/cli-ux/action/spinners.js +1 -1
  6. package/lib/cli-ux/config.js +11 -12
  7. package/lib/cli-ux/exit.js +3 -0
  8. package/lib/cli-ux/flush.js +7 -6
  9. package/lib/cli-ux/index.js +2 -2
  10. package/lib/cli-ux/list.js +3 -3
  11. package/lib/cli-ux/prompt.js +8 -3
  12. package/lib/cli-ux/stream.js +1 -0
  13. package/lib/cli-ux/styled/json.js +5 -3
  14. package/lib/cli-ux/styled/object.js +2 -2
  15. package/lib/cli-ux/styled/table.js +26 -20
  16. package/lib/cli-ux/styled/tree.js +1 -3
  17. package/lib/cli-ux/wait.js +1 -1
  18. package/lib/command.d.ts +6 -14
  19. package/lib/command.js +86 -73
  20. package/lib/config/config.d.ts +8 -9
  21. package/lib/config/config.js +85 -199
  22. package/lib/config/index.d.ts +0 -1
  23. package/lib/config/index.js +1 -3
  24. package/lib/config/plugin-loader.js +12 -11
  25. package/lib/config/plugin.d.ts +1 -0
  26. package/lib/config/plugin.js +54 -34
  27. package/lib/config/ts-node.js +17 -13
  28. package/lib/config/util.d.ts +0 -6
  29. package/lib/config/util.js +3 -15
  30. package/lib/errors/errors/cli.js +4 -1
  31. package/lib/errors/errors/exit.js +1 -1
  32. package/lib/errors/errors/module-load.js +1 -1
  33. package/lib/errors/errors/pretty-print.js +2 -1
  34. package/lib/errors/handle.js +4 -3
  35. package/lib/errors/logger.js +5 -4
  36. package/lib/flags.d.ts +6 -6
  37. package/lib/flags.js +3 -3
  38. package/lib/help/command.js +46 -32
  39. package/lib/help/docopts.js +8 -5
  40. package/lib/help/formatter.js +19 -8
  41. package/lib/help/index.d.ts +5 -1
  42. package/lib/help/index.js +70 -49
  43. package/lib/help/root.js +7 -9
  44. package/lib/help/util.d.ts +1 -7
  45. package/lib/help/util.js +2 -22
  46. package/lib/index.d.ts +2 -2
  47. package/lib/index.js +2 -3
  48. package/lib/interfaces/hooks.d.ts +3 -3
  49. package/lib/interfaces/index.d.ts +1 -1
  50. package/lib/interfaces/parser.d.ts +19 -18
  51. package/lib/interfaces/pjson.d.ts +1 -1
  52. package/lib/interfaces/plugin.d.ts +5 -0
  53. package/lib/module-loader.d.ts +8 -8
  54. package/lib/module-loader.js +13 -10
  55. package/lib/parser/errors.d.ts +1 -1
  56. package/lib/parser/errors.js +15 -9
  57. package/lib/parser/help.js +2 -3
  58. package/lib/parser/parse.js +72 -44
  59. package/lib/parser/validate.js +37 -21
  60. package/lib/performance.js +20 -9
  61. package/lib/util/aggregate-flags.d.ts +2 -0
  62. package/lib/util/aggregate-flags.js +13 -0
  63. package/lib/util/cache-command.d.ts +3 -0
  64. package/lib/util/cache-command.js +108 -0
  65. package/lib/util/cache-default-value.d.ts +2 -0
  66. package/lib/util/cache-default-value.js +28 -0
  67. package/lib/{util.d.ts → util/index.d.ts} +7 -2
  68. package/lib/{util.js → util/index.js} +15 -20
  69. package/package.json +19 -13
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.readJsonSync = exports.readJson = exports.getPlatform = exports.getHomeDir = exports.uniq = exports.ensureArgObject = exports.requireJson = exports.isNotFalsy = exports.isTruthy = exports.fileExists = exports.dirExists = exports.exists = exports.capitalize = exports.sumBy = exports.maxBy = exports.isProd = exports.castArray = exports.sortBy = exports.last = exports.uniqBy = exports.compact = exports.pickBy = void 0;
3
+ exports.mapValues = exports.readJsonSync = exports.readJson = exports.getPlatform = exports.getHomeDir = exports.uniq = exports.ensureArgObject = exports.requireJson = exports.isNotFalsy = exports.isTruthy = exports.fileExists = exports.dirExists = exports.exists = exports.capitalize = exports.sumBy = exports.maxBy = exports.isProd = exports.castArray = exports.sortBy = exports.last = exports.uniqBy = exports.compact = exports.pickBy = void 0;
4
4
  const promises_1 = require("node:fs/promises");
5
5
  const node_os_1 = require("node:os");
6
- const node_fs_1 = require("node:fs");
7
6
  const node_path_1 = require("node:path");
7
+ const node_fs_1 = require("node:fs");
8
8
  const debug = require('debug');
9
9
  function pickBy(obj, fn) {
10
- return Object.entries(obj)
11
- .reduce((o, [k, v]) => {
10
+ return Object.entries(obj).reduce((o, [k, v]) => {
12
11
  if (fn(v))
13
12
  o[k] = v;
14
13
  return o;
@@ -94,7 +93,7 @@ async function exists(path) {
94
93
  }
95
94
  exports.exists = exists;
96
95
  const dirExists = async (input) => {
97
- if (!await exists(input)) {
96
+ if (!(await exists(input))) {
98
97
  throw new Error(`No directory found at ${input}`);
99
98
  }
100
99
  const fileStat = await (0, promises_1.stat)(input);
@@ -105,7 +104,7 @@ const dirExists = async (input) => {
105
104
  };
106
105
  exports.dirExists = dirExists;
107
106
  const fileExists = async (input) => {
108
- if (!await exists(input)) {
107
+ if (!(await exists(input))) {
109
108
  throw new Error(`No file found at ${input}`);
110
109
  }
111
110
  const fileStat = await (0, promises_1.stat)(input);
@@ -166,21 +165,10 @@ function getPlatform() {
166
165
  return (0, node_os_1.platform)();
167
166
  }
168
167
  exports.getPlatform = getPlatform;
169
- function readJson(path) {
168
+ async function readJson(path) {
170
169
  debug('config')('readJson %s', path);
171
- return new Promise((resolve, reject) => {
172
- (0, node_fs_1.readFile)(path, 'utf8', (err, d) => {
173
- try {
174
- if (err)
175
- reject(err);
176
- else
177
- resolve(JSON.parse(d));
178
- }
179
- catch (error) {
180
- reject(error);
181
- }
182
- });
183
- });
170
+ const contents = await (0, promises_1.readFile)(path, 'utf8');
171
+ return JSON.parse(contents);
184
172
  }
185
173
  exports.readJson = readJson;
186
174
  function readJsonSync(path, parse = true) {
@@ -188,3 +176,10 @@ function readJsonSync(path, parse = true) {
188
176
  return parse ? JSON.parse(contents) : contents;
189
177
  }
190
178
  exports.readJsonSync = readJsonSync;
179
+ function mapValues(obj, fn) {
180
+ return Object.entries(obj).reduce((o, [k, v]) => {
181
+ o[k] = fn(v, k);
182
+ return o;
183
+ }, {});
184
+ }
185
+ exports.mapValues = mapValues;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@oclif/core",
3
3
  "description": "base library for oclif CLIs",
4
- "version": "3.0.0-beta.17",
4
+ "version": "3.0.0-beta.19",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {
@@ -33,10 +33,11 @@
33
33
  "wrap-ansi": "^7.0.0"
34
34
  },
35
35
  "devDependencies": {
36
- "@commitlint/config-conventional": "^12.1.4",
36
+ "@commitlint/config-conventional": "^17.7.0",
37
37
  "@oclif/plugin-help": "^5.2.8",
38
38
  "@oclif/plugin-plugins": "^3.3.0",
39
- "@oclif/test": "^2.4.7",
39
+ "@oclif/prettier-config": "^0.2.1",
40
+ "@oclif/test": "^3.0.1",
40
41
  "@types/ansi-styles": "^3.2.1",
41
42
  "@types/benchmark": "^2.1.2",
42
43
  "@types/chai": "^4.3.4",
@@ -45,8 +46,7 @@
45
46
  "@types/ejs": "^3.1.2",
46
47
  "@types/indent-string": "^4.0.1",
47
48
  "@types/js-yaml": "^3.12.7",
48
- "@types/mocha": "^8.2.3",
49
- "@types/nock": "^11.1.0",
49
+ "@types/mocha": "^10.0.2",
50
50
  "@types/node": "^18",
51
51
  "@types/node-notifier": "^8.0.2",
52
52
  "@types/slice-ansi": "^4.0.0",
@@ -57,20 +57,24 @@
57
57
  "benchmark": "^2.1.4",
58
58
  "chai": "^4.3.7",
59
59
  "chai-as-promised": "^7.1.1",
60
- "commitlint": "^12.1.4",
60
+ "commitlint": "^17.7.2",
61
61
  "cross-env": "^7.0.3",
62
62
  "eslint": "^8.49.0",
63
63
  "eslint-config-oclif": "^5.0.0",
64
64
  "eslint-config-oclif-typescript": "^2.0.1",
65
- "fancy-test": "^3.0.0-beta.2",
65
+ "eslint-config-prettier": "^9.0.0",
66
+ "fancy-test": "^3.0.1",
66
67
  "globby": "^11.1.0",
67
- "husky": "6",
68
+ "husky": "^8",
69
+ "lint-staged": "^14.0.1",
70
+ "madge": "^6.1.0",
68
71
  "mocha": "^10.2.0",
69
- "nock": "^13.3.0",
72
+ "nyc": "^15.1.0",
73
+ "prettier": "^3.0.3",
70
74
  "shx": "^0.3.4",
71
75
  "sinon": "^11.1.2",
72
- "tsd": "^0.29.0",
73
76
  "ts-node": "^10.9.1",
77
+ "tsd": "^0.29.0",
74
78
  "tslib": "^2.5.0",
75
79
  "typescript": "^5"
76
80
  },
@@ -104,14 +108,16 @@
104
108
  "build": "shx rm -rf lib && tsc",
105
109
  "commitlint": "commitlint",
106
110
  "compile": "tsc",
111
+ "format": "prettier --write \"+(src|test)/**/*.+(ts|js|json)\"",
107
112
  "lint": "eslint . --ext .ts",
108
- "posttest": "yarn lint",
113
+ "posttest": "yarn lint && yarn test:circular-deps",
109
114
  "prepack": "yarn run build",
110
- "pretest": "yarn build --noEmit && tsc -p test --noEmit --skipLibCheck",
115
+ "pretest": "yarn build && tsc -p test --noEmit --skipLibCheck",
116
+ "test:circular-deps": "madge lib/ -c",
111
117
  "test:e2e": "mocha --forbid-only \"test/**/*.e2e.ts\" --parallel --timeout 1200000",
112
118
  "test:esm-cjs": "cross-env DEBUG=e2e:* ts-node test/integration/esm-cjs.ts",
113
119
  "test:perf": "ts-node test/perf/parser.perf.ts",
114
- "test": "mocha --forbid-only \"test/**/*.test.ts\""
120
+ "test": "nyc mocha --forbid-only \"test/**/*.test.ts\""
115
121
  },
116
122
  "types": "lib/index.d.ts"
117
123
  }