@oclif/core 1.8.2 → 1.9.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
@@ -2,6 +2,13 @@
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.9.0](https://github.com/oclif/core/compare/v1.8.2...v1.9.0) (2022-05-20)
6
+
7
+
8
+ ### Features
9
+
10
+ * support TS directory imports for ESM ([#422](https://github.com/oclif/core/issues/422)) ([4c58e78](https://github.com/oclif/core/commit/4c58e782e86dd7ecf91294bac0d2c759b4454596))
11
+
5
12
  ### [1.8.2](https://github.com/oclif/core/compare/v1.8.1...v1.8.2) (2022-05-18)
6
13
 
7
14
 
@@ -2,7 +2,7 @@
2
2
  // tslint:disable
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.renderList = void 0;
5
- const maxBy_1 = require("lodash/maxBy");
5
+ const util_1 = require("../util");
6
6
  const deps_1 = require("./deps");
7
7
  function linewrap(length, s) {
8
8
  const lw = require('@oclif/linewrap');
@@ -11,10 +11,11 @@ function linewrap(length, s) {
11
11
  })(s).trim();
12
12
  }
13
13
  function renderList(items) {
14
+ var _a, _b;
14
15
  if (items.length === 0) {
15
16
  return '';
16
17
  }
17
- const maxLength = (0, maxBy_1.default)(items, '[0].length')[0].length;
18
+ const maxLength = (_b = (_a = (0, util_1.maxBy)(items, item => item[0].length)) === null || _a === void 0 ? void 0 : _a[0].length) !== null && _b !== void 0 ? _b : 0;
18
19
  const lines = items.map(i => {
19
20
  let left = i[0];
20
21
  let right = i[1];
@@ -2,7 +2,6 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  // this code is largely taken from opn
4
4
  const childProcess = require("child_process");
5
- const _ = require("lodash");
6
5
  const isWsl = require('is-wsl');
7
6
  function open(target, opts = {}) {
8
7
  // opts = {wait: true, ...opts}
@@ -59,7 +58,7 @@ function open(target, opts = {}) {
59
58
  return new Promise((resolve, reject) => {
60
59
  cp.once('error', reject);
61
60
  cp.once('close', code => {
62
- if (_.isNumber(code) && code > 0) {
61
+ if (Number.isInteger(code) && code > 0) {
63
62
  reject(new Error('Exited with code ' + code));
64
63
  return;
65
64
  }
@@ -4,9 +4,9 @@ exports.table = void 0;
4
4
  const F = require("../../flags");
5
5
  const screen_1 = require("@oclif/screen");
6
6
  const chalk = require("chalk");
7
- const lodash_1 = require("lodash");
7
+ const util_1 = require("../../util");
8
8
  const js_yaml_1 = require("js-yaml");
9
- const util_1 = require("util");
9
+ const util_2 = require("util");
10
10
  const sw = require('string-width');
11
11
  const { orderBy } = require('natural-orderby');
12
12
  class Table {
@@ -17,7 +17,7 @@ class Table {
17
17
  const col = columns[key];
18
18
  const extended = col.extended || false;
19
19
  const get = col.get || ((row) => row[key]);
20
- const header = typeof col.header === 'string' ? col.header : (0, lodash_1.capitalize)(key.replace(/_/g, ' '));
20
+ const header = typeof col.header === 'string' ? col.header : (0, util_1.capitalize)(key.replace(/_/g, ' '));
21
21
  const minWidth = Math.max(col.minWidth || 0, sw(header) + 1);
22
22
  return {
23
23
  extended,
@@ -49,7 +49,7 @@ class Table {
49
49
  for (const col of this.columns) {
50
50
  let val = col.get(d);
51
51
  if (typeof val !== 'string')
52
- val = (0, util_1.inspect)(val, { breakLength: Number.POSITIVE_INFINITY });
52
+ val = (0, util_2.inspect)(val, { breakLength: Number.POSITIVE_INFINITY });
53
53
  row[col.key] = val;
54
54
  }
55
55
  return row;
@@ -183,7 +183,7 @@ class Table {
183
183
  if (options['no-truncate'] || (!process.stdout.isTTY && !process.env.CLI_UX_SKIP_TTY_CHECK))
184
184
  return;
185
185
  // don't shorten if there is enough screen width
186
- const dataMaxWidth = (0, lodash_1.sumBy)(columns, c => c.width);
186
+ const dataMaxWidth = (0, util_1.sumBy)(columns, c => c.width);
187
187
  const overWidth = dataMaxWidth - maxWidth;
188
188
  if (overWidth <= 0)
189
189
  return;
@@ -194,7 +194,7 @@ class Table {
194
194
  // if sum(minWidth's) is greater than term width
195
195
  // nothing can be done so
196
196
  // display all as minWidth
197
- const dataMinWidth = (0, lodash_1.sumBy)(columns, c => c.minWidth);
197
+ const dataMinWidth = (0, util_1.sumBy)(columns, c => c.minWidth);
198
198
  if (dataMinWidth >= maxWidth)
199
199
  return;
200
200
  // some wiggle room left, add it back to "needy" columns
@@ -10,7 +10,7 @@ const getPackageType = require('get-package-type');
10
10
  * Defines file extension resolution when source files do not have an extension.
11
11
  */
12
12
  // eslint-disable-next-line camelcase
13
- const s_EXTENSIONS = ['.js', '.mjs', '.cjs'];
13
+ const s_EXTENSIONS = ['.ts', '.js', '.mjs', '.cjs'];
14
14
  /**
15
15
  * Provides a mechanism to use dynamic import / import() with tsconfig -> module: commonJS as otherwise import() gets
16
16
  * transpiled to require().
@@ -101,6 +101,8 @@ class ModuleLoader {
101
101
  switch (extension) {
102
102
  case '.js':
103
103
  return getPackageType.sync(filePath) === 'module';
104
+ case '.ts':
105
+ return getPackageType.sync(filePath) === 'module';
104
106
  case '.mjs':
105
107
  return true;
106
108
  default:
@@ -144,7 +146,7 @@ class ModuleLoader {
144
146
  // Try all supported extensions.
145
147
  let foundPath = ModuleLoader.findFile(filePath);
146
148
  if (!foundPath && isDirectory) {
147
- // Since filePath is a directory, try looking for index.js file.
149
+ // Since filePath is a directory, try looking for index file.
148
150
  foundPath = ModuleLoader.findFile(path.join(filePath, 'index'));
149
151
  }
150
152
  if (foundPath) {
package/lib/util.d.ts CHANGED
@@ -4,4 +4,7 @@ declare type SortTypes = string | number | undefined | boolean;
4
4
  export declare function sortBy<T>(arr: T[], fn: (i: T) => SortTypes | SortTypes[]): T[];
5
5
  export declare function castArray<T>(input?: T | T[]): T[];
6
6
  export declare function isProd(): boolean;
7
+ export declare function maxBy<T>(arr: T[], fn: (i: T) => number): T | undefined;
8
+ export declare function sumBy<T>(arr: T[], fn: (i: T) => number): number;
9
+ export declare function capitalize(s: string): string;
7
10
  export {};
package/lib/util.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isProd = exports.castArray = exports.sortBy = exports.uniqBy = exports.compact = void 0;
3
+ exports.capitalize = exports.sumBy = exports.maxBy = exports.isProd = exports.castArray = exports.sortBy = exports.uniqBy = exports.compact = void 0;
4
4
  function compact(a) {
5
5
  return a.filter((a) => Boolean(a));
6
6
  }
@@ -44,3 +44,22 @@ function isProd() {
44
44
  return !['development', 'test'].includes((_a = process.env.NODE_ENV) !== null && _a !== void 0 ? _a : '');
45
45
  }
46
46
  exports.isProd = isProd;
47
+ function maxBy(arr, fn) {
48
+ if (arr.length === 0) {
49
+ return undefined;
50
+ }
51
+ return arr.reduce((maxItem, i) => {
52
+ const curr = fn(i);
53
+ const max = fn(maxItem);
54
+ return curr > max ? i : maxItem;
55
+ });
56
+ }
57
+ exports.maxBy = maxBy;
58
+ function sumBy(arr, fn) {
59
+ return arr.reduce((sum, i) => sum + fn(i), 0);
60
+ }
61
+ exports.sumBy = sumBy;
62
+ function capitalize(s) {
63
+ return s ? s.charAt(0).toUpperCase() + s.slice(1).toLowerCase() : '';
64
+ }
65
+ exports.capitalize = capitalize;
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": "1.8.2",
4
+ "version": "1.9.0",
5
5
  "author": "Salesforce",
6
6
  "bugs": "https://github.com/oclif/core/issues",
7
7
  "dependencies": {
@@ -22,7 +22,6 @@
22
22
  "indent-string": "^4.0.0",
23
23
  "is-wsl": "^2.2.0",
24
24
  "js-yaml": "^3.14.1",
25
- "lodash": "^4.17.21",
26
25
  "natural-orderby": "^2.0.3",
27
26
  "object-treeify": "^1.1.33",
28
27
  "password-prompt": "^1.1.2",
@@ -49,7 +48,6 @@
49
48
  "@types/fs-extra": "^9.0.13",
50
49
  "@types/indent-string": "^4.0.1",
51
50
  "@types/js-yaml": "^3.12.7",
52
- "@types/lodash": "^4.14.182",
53
51
  "@types/mocha": "^8.2.3",
54
52
  "@types/nock": "^11.1.0",
55
53
  "@types/node": "^15.14.9",