@oclif/core 1.0.7 → 1.0.11

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
@@ -2,6 +2,29 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [1.0.11](https://github.com/oclif/core/compare/v1.0.10...v1.0.11) (2021-12-17)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * update imports in errors/cli.ts ([#325](https://github.com/oclif/core/issues/325)) ([b3d6e9b](https://github.com/oclif/core/commit/b3d6e9bf34928ac59486807576a2ee2643b22464))
11
+
12
+ ### [1.0.10](https://github.com/oclif/core/compare/v1.0.9...v1.0.10) (2021-12-08)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * bump deps ([#317](https://github.com/oclif/core/issues/317)) ([3e656e0](https://github.com/oclif/core/commit/3e656e0b6909bedb879a267bf341cfb992f4d208))
18
+
19
+ ### [1.0.9](https://github.com/oclif/core/compare/v1.0.8...v1.0.9) (2021-12-08)
20
+
21
+ ### [1.0.8](https://github.com/oclif/core/compare/v1.0.7...v1.0.8) (2021-12-07)
22
+
23
+
24
+ ### Bug Fixes
25
+
26
+ * bump deps ([#314](https://github.com/oclif/core/issues/314)) ([e989d1c](https://github.com/oclif/core/commit/e989d1c078d24df3023f2abf61dd454435f08956))
27
+
5
28
  ### [1.0.7](https://github.com/oclif/core/compare/v1.0.6...v1.0.7) (2021-12-02)
6
29
 
7
30
 
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  @oclif/core
2
- ==============
2
+ ===========
3
3
 
4
4
  base library for oclif CLIs
5
5
 
@@ -9,6 +9,11 @@ base library for oclif CLIs
9
9
  [![License](https://img.shields.io/npm/l/@oclif/core.svg)](https://github.com/oclif/core/blob/main/package.json)
10
10
 
11
11
 
12
+ Migrating
13
+ =====
14
+
15
+ If you're migrating from the old oclif libraries (`@oclif/config`, `@oclif/command`, `@oclif/error`, `@oclif/parser`), see the [migration guide](./MIGRATION.md).
16
+
12
17
  Usage
13
18
  =====
14
19
 
@@ -33,7 +38,7 @@ class LS extends Command {
33
38
  }
34
39
 
35
40
  async run() {
36
- const {flags} = this.parse(LS)
41
+ const {flags} = await this.parse(LS)
37
42
  let files = fs.readdirSync(flags.dir)
38
43
  for (let f of files) {
39
44
  this.log(f)
@@ -23,23 +23,34 @@ function topicsToArray(input, base) {
23
23
  return [{ ...input[k], name: `${base}${k}` }].concat(topicsToArray(input[k].subtopics, `${base}${input[k].name}`));
24
24
  });
25
25
  }
26
- // eslint-disable-next-line valid-jsdoc
26
+ // essentially just "cd .."
27
+ function* up(from) {
28
+ while (path.dirname(from) !== from) {
29
+ yield from;
30
+ from = path.dirname(from);
31
+ }
32
+ yield from;
33
+ }
34
+ async function findSourcesRoot(root) {
35
+ for (const next of up(root)) {
36
+ const cur = path.join(next, 'package.json');
37
+ // eslint-disable-next-line no-await-in-loop
38
+ if (await (0, util_3.exists)(cur))
39
+ return path.dirname(cur);
40
+ }
41
+ }
27
42
  /**
43
+ * @returns string
44
+ * @param name string
45
+ * @param root string
28
46
  * find package root
29
47
  * for packages installed into node_modules this will go up directories until
30
48
  * it finds a node_modules directory with the plugin installed into it
31
49
  *
32
- * This is needed because of the deduping npm does
50
+ * This is needed because some oclif plugins do not declare the `main` field in their package.json
51
+ * https://github.com/oclif/config/pull/289#issuecomment-983904051
33
52
  */
34
- async function findRoot(name, root) {
35
- // essentially just "cd .."
36
- function* up(from) {
37
- while (path.dirname(from) !== from) {
38
- yield from;
39
- from = path.dirname(from);
40
- }
41
- yield from;
42
- }
53
+ async function findRootLegacy(name, root) {
43
54
  for (const next of up(root)) {
44
55
  let cur;
45
56
  if (name) {
@@ -63,6 +74,17 @@ async function findRoot(name, root) {
63
74
  }
64
75
  }
65
76
  }
77
+ async function findRoot(name, root) {
78
+ if (name) {
79
+ let pkgPath;
80
+ try {
81
+ pkgPath = (0, util_3.resolvePackage)(name, { paths: [__dirname, root] });
82
+ }
83
+ catch { }
84
+ return pkgPath ? findSourcesRoot(path.dirname(pkgPath)) : findRootLegacy(name, root);
85
+ }
86
+ return findSourcesRoot(root);
87
+ }
66
88
  class Plugin {
67
89
  // eslint-disable-next-line no-useless-constructor
68
90
  constructor(options) {
@@ -5,6 +5,9 @@ export declare function mapValues<T extends Record<string, any>, TResult>(obj: {
5
5
  [P in keyof T]: TResult;
6
6
  };
7
7
  export declare function exists(path: string): Promise<boolean>;
8
+ export declare function resolvePackage(id: string, paths: {
9
+ paths: string[];
10
+ }): string;
8
11
  export declare function loadJSON(path: string): Promise<any>;
9
12
  export declare function compact<T>(a: (T | undefined)[]): T[];
10
13
  export declare function uniq<T>(arr: T[]): T[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Debug = exports.uniq = exports.compact = exports.loadJSON = exports.exists = exports.mapValues = exports.flatMap = void 0;
3
+ exports.Debug = exports.uniq = exports.compact = exports.loadJSON = exports.resolvePackage = exports.exists = exports.mapValues = exports.flatMap = void 0;
4
4
  const fs = require("fs");
5
5
  const debug = require('debug');
6
6
  function flatMap(arr, fn) {
@@ -20,6 +20,10 @@ function exists(path) {
20
20
  return new Promise(resolve => resolve(fs.existsSync(path)));
21
21
  }
22
22
  exports.exists = exists;
23
+ function resolvePackage(id, paths) {
24
+ return require.resolve(id, paths);
25
+ }
26
+ exports.resolvePackage = resolvePackage;
23
27
  function loadJSON(path) {
24
28
  debug('config')('loadJSON %s', path);
25
29
  return new Promise((resolve, reject) => {
@@ -17,11 +17,11 @@ export declare class CLIError extends Error implements OclifError {
17
17
  * @return {string} returns a string representing the dispay of the error
18
18
  */
19
19
  render(): string;
20
- get bang(): string;
20
+ get bang(): string | undefined;
21
21
  }
22
22
  export declare namespace CLIError {
23
23
  class Warn extends CLIError {
24
24
  constructor(err: string | Error);
25
- get bang(): string;
25
+ get bang(): string | undefined;
26
26
  }
27
27
  }
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
- // tslint:disable no-implicit-dependencies
3
2
  Object.defineProperty(exports, "__esModule", { value: true });
4
3
  exports.CLIError = exports.addOclifExitCode = void 0;
4
+ const chalk = require("chalk");
5
+ const indent = require("indent-string");
6
+ const cs = require("clean-stack");
7
+ const wrap = require("wrap-ansi");
8
+ const screen = require("../../screen");
5
9
  const config_1 = require("../config");
6
10
  /**
7
11
  * properties specific to internal oclif error handling
@@ -22,8 +26,7 @@ class CLIError extends Error {
22
26
  this.code = options.code;
23
27
  }
24
28
  get stack() {
25
- const clean = require('clean-stack');
26
- return clean(super.stack, { pretty: true });
29
+ return cs(super.stack, { pretty: true });
27
30
  }
28
31
  /**
29
32
  * @deprecated `render` Errors display should be handled by display function, like pretty-print
@@ -33,23 +36,18 @@ class CLIError extends Error {
33
36
  if (config_1.config.debug) {
34
37
  return this.stack;
35
38
  }
36
- const wrap = require('wrap-ansi');
37
- const indent = require('indent-string');
38
39
  let output = `${this.name}: ${this.message}`;
39
- // eslint-disable-next-line node/no-missing-require
40
- output = wrap(output, require('../screen').errtermwidth - 6, { trim: false, hard: true });
40
+ output = wrap(output, screen.errtermwidth - 6, { trim: false, hard: true });
41
41
  output = indent(output, 3);
42
42
  output = indent(output, 1, { indent: this.bang, includeEmptyLines: true });
43
43
  output = indent(output, 1);
44
44
  return output;
45
45
  }
46
46
  get bang() {
47
- let red = ((s) => s);
48
47
  try {
49
- red = require('chalk').red;
48
+ return chalk.red(process.platform === 'win32' ? '»' : '›');
50
49
  }
51
50
  catch { }
52
- return red(process.platform === 'win32' ? '»' : '›');
53
51
  }
54
52
  }
55
53
  exports.CLIError = CLIError;
@@ -60,12 +58,10 @@ exports.CLIError = CLIError;
60
58
  this.name = 'Warning';
61
59
  }
62
60
  get bang() {
63
- let yellow = ((s) => s);
64
61
  try {
65
- yellow = require('chalk').yellow;
62
+ return chalk.yellow(process.platform === 'win32' ? '»' : '›');
66
63
  }
67
64
  catch { }
68
- return yellow(process.platform === 'win32' ? '»' : '›');
69
65
  }
70
66
  }
71
67
  CLIError.Warn = Warn;
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@oclif/core",
3
3
  "description": "base library for oclif CLIs",
4
- "version": "1.0.7",
4
+ "version": "1.0.11",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {
8
8
  "@oclif/linewrap": "^1.0.0",
9
9
  "chalk": "^4.1.2",
10
10
  "clean-stack": "^3.0.1",
11
- "cli-ux": "^6.0.3",
11
+ "cli-ux": "6.0.5",
12
12
  "debug": "^4.3.3",
13
13
  "fs-extra": "^9.1.0",
14
14
  "get-package-type": "^0.1.0",
@@ -25,8 +25,8 @@
25
25
  },
26
26
  "devDependencies": {
27
27
  "@commitlint/config-conventional": "^12.1.4",
28
- "@oclif/plugin-help": "^5.1.5",
29
- "@oclif/plugin-plugins": "^2.0.2",
28
+ "@oclif/plugin-help": "^5.1.7",
29
+ "@oclif/plugin-plugins": "^2.0.8",
30
30
  "@oclif/test": "^1.2.8",
31
31
  "@types/chai": "^4.2.22",
32
32
  "@types/chai-as-promised": "^7.1.4",
@@ -62,7 +62,7 @@
62
62
  "typescript": "4.5.2"
63
63
  },
64
64
  "resolutions": {
65
- "@oclif/command": "1.8.6",
65
+ "@oclif/command": "1.8.9",
66
66
  "@oclif/parser": "3.8.6"
67
67
  },
68
68
  "engines": {