@modern-js/utils 1.6.0 → 1.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/compiled/globby/index.d.ts +1 -1
  3. package/compiled/lodash/index.js +4 -8
  4. package/compiled/semver/classes/comparator.d.ts +17 -0
  5. package/compiled/semver/classes/range.d.ts +21 -0
  6. package/compiled/semver/classes/semver.d.ts +62 -0
  7. package/compiled/semver/functions/clean.d.ts +8 -0
  8. package/compiled/semver/functions/cmp.d.ts +16 -0
  9. package/compiled/semver/functions/coerce.d.ts +12 -0
  10. package/compiled/semver/functions/compare-build.d.ts +16 -0
  11. package/compiled/semver/functions/compare-loose.d.ts +5 -0
  12. package/compiled/semver/functions/compare.d.ts +20 -0
  13. package/compiled/semver/functions/diff.d.ts +13 -0
  14. package/compiled/semver/functions/eq.d.ts +9 -0
  15. package/compiled/semver/functions/gt.d.ts +9 -0
  16. package/compiled/semver/functions/gte.d.ts +9 -0
  17. package/compiled/semver/functions/inc.d.ts +15 -0
  18. package/compiled/semver/functions/lt.d.ts +9 -0
  19. package/compiled/semver/functions/lte.d.ts +8 -0
  20. package/compiled/semver/functions/major.d.ts +9 -0
  21. package/compiled/semver/functions/minor.d.ts +9 -0
  22. package/compiled/semver/functions/neq.d.ts +9 -0
  23. package/compiled/semver/functions/parse.d.ts +12 -0
  24. package/compiled/semver/functions/patch.d.ts +9 -0
  25. package/compiled/semver/functions/prerelease.d.ts +12 -0
  26. package/compiled/semver/functions/rcompare.d.ts +15 -0
  27. package/compiled/semver/functions/rsort.d.ts +9 -0
  28. package/compiled/semver/functions/satisfies.d.ts +14 -0
  29. package/compiled/semver/functions/sort.d.ts +9 -0
  30. package/compiled/semver/functions/valid.d.ts +11 -0
  31. package/compiled/semver/index.d.ts +133 -0
  32. package/compiled/semver/index.js +1 -0
  33. package/compiled/semver/internals/identifiers.d.ts +13 -0
  34. package/compiled/semver/license +15 -0
  35. package/compiled/semver/package.json +1 -0
  36. package/compiled/semver/ranges/gtr.d.ts +14 -0
  37. package/compiled/semver/ranges/intersects.d.ts +13 -0
  38. package/compiled/semver/ranges/ltr.d.ts +14 -0
  39. package/compiled/semver/ranges/max-satisfying.d.ts +14 -0
  40. package/compiled/semver/ranges/min-satisfying.d.ts +14 -0
  41. package/compiled/semver/ranges/min-version.d.ts +10 -0
  42. package/compiled/semver/ranges/outside.d.ts +15 -0
  43. package/compiled/semver/ranges/simplify.d.ts +14 -0
  44. package/compiled/semver/ranges/subset.d.ts +13 -0
  45. package/compiled/semver/ranges/to-comparators.d.ts +9 -0
  46. package/compiled/semver/ranges/valid.d.ts +12 -0
  47. package/dist/alias.js +4 -1
  48. package/dist/analyzeProject.js +3 -12
  49. package/dist/compiled.d.ts +1 -0
  50. package/dist/compiled.js +3 -1
  51. package/dist/emptyDir.js +4 -13
  52. package/dist/format.js +6 -1
  53. package/dist/getEntryOptions.js +2 -1
  54. package/dist/getPackageManager.js +19 -30
  55. package/dist/getPort.js +3 -12
  56. package/dist/getServerConfig.js +2 -11
  57. package/dist/logger.d.ts +3 -0
  58. package/dist/logger.js +21 -6
  59. package/dist/monorepo.js +4 -1
  60. package/dist/nodeEnv.js +24 -39
  61. package/dist/runtimeExports.js +1 -1
  62. package/dist/watch.js +9 -18
  63. package/package.json +33 -10
  64. package/tsconfig.json +1 -0
  65. package/compiled/globby/@nodelib/fs.scandir/out/adapters/fs.d.ts +0 -20
  66. package/compiled/globby/@nodelib/fs.scandir/out/index.d.ts +0 -12
  67. package/compiled/globby/@nodelib/fs.scandir/out/providers/async.d.ts +0 -7
  68. package/compiled/globby/@nodelib/fs.scandir/out/settings.d.ts +0 -20
  69. package/compiled/globby/@nodelib/fs.scandir/out/types/index.d.ts +0 -20
  70. package/compiled/globby/@nodelib/fs.stat/out/adapters/fs.d.ts +0 -13
  71. package/compiled/globby/@nodelib/fs.stat/out/index.d.ts +0 -12
  72. package/compiled/globby/@nodelib/fs.stat/out/providers/async.d.ts +0 -4
  73. package/compiled/globby/@nodelib/fs.stat/out/settings.d.ts +0 -16
  74. package/compiled/globby/@nodelib/fs.stat/out/types/index.d.ts +0 -4
  75. package/compiled/globby/@nodelib/fs.walk/out/index.d.ts +0 -14
  76. package/compiled/globby/@nodelib/fs.walk/out/providers/async.d.ts +0 -12
  77. package/compiled/globby/@nodelib/fs.walk/out/readers/async.d.ts +0 -30
  78. package/compiled/globby/@nodelib/fs.walk/out/readers/reader.d.ts +0 -6
  79. package/compiled/globby/@nodelib/fs.walk/out/settings.d.ts +0 -30
  80. package/compiled/globby/@nodelib/fs.walk/out/types/index.d.ts +0 -8
  81. package/compiled/globby/fast-glob/index.d.ts +0 -27
  82. package/compiled/globby/fast-glob/managers/tasks.d.ts +0 -22
  83. package/compiled/globby/fast-glob/settings.d.ts +0 -164
  84. package/compiled/globby/fast-glob/types/index.d.ts +0 -31
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -18,30 +9,28 @@ const path_1 = __importDefault(require("path"));
18
9
  const compiled_1 = require("./compiled");
19
10
  const nodeEnv_1 = require("./nodeEnv");
20
11
  const MAX_TIMES = 5;
21
- function getPackageManager(cwd = process.cwd()) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- let appDirectory = cwd;
24
- let times = 0;
25
- while (os_1.default.homedir() !== appDirectory && times < MAX_TIMES) {
26
- times++;
27
- if (compiled_1.fs.existsSync(path_1.default.resolve(appDirectory, 'pnpm-lock.yaml'))) {
28
- return 'pnpm';
29
- }
30
- if (compiled_1.fs.existsSync(path_1.default.resolve(appDirectory, 'yarn.lock'))) {
31
- return 'yarn';
32
- }
33
- if (compiled_1.fs.existsSync(path_1.default.resolve(appDirectory, 'package-lock.json'))) {
34
- return 'npm';
35
- }
36
- appDirectory = path_1.default.join(appDirectory, '..');
37
- }
38
- if (yield (0, nodeEnv_1.canUsePnpm)()) {
12
+ async function getPackageManager(cwd = process.cwd()) {
13
+ let appDirectory = cwd;
14
+ let times = 0;
15
+ while (os_1.default.homedir() !== appDirectory && times < MAX_TIMES) {
16
+ times++;
17
+ if (compiled_1.fs.existsSync(path_1.default.resolve(appDirectory, 'pnpm-lock.yaml'))) {
39
18
  return 'pnpm';
40
19
  }
41
- if (yield (0, nodeEnv_1.canUseYarn)()) {
20
+ if (compiled_1.fs.existsSync(path_1.default.resolve(appDirectory, 'yarn.lock'))) {
42
21
  return 'yarn';
43
22
  }
44
- return 'npm';
45
- });
23
+ if (compiled_1.fs.existsSync(path_1.default.resolve(appDirectory, 'package-lock.json'))) {
24
+ return 'npm';
25
+ }
26
+ appDirectory = path_1.default.join(appDirectory, '..');
27
+ }
28
+ if (await (0, nodeEnv_1.canUsePnpm)()) {
29
+ return 'pnpm';
30
+ }
31
+ if (await (0, nodeEnv_1.canUseYarn)()) {
32
+ return 'yarn';
33
+ }
34
+ return 'npm';
46
35
  }
47
36
  exports.getPackageManager = getPackageManager;
package/dist/getPort.js CHANGED
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -23,7 +14,7 @@ const logger_1 = require("./logger");
23
14
  * @returns Available port number.
24
15
  */
25
16
  /* eslint-disable no-param-reassign, @typescript-eslint/no-loop-func */
26
- const getPort = (port, tryLimits = 20) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const getPort = async (port, tryLimits = 20) => {
27
18
  if (typeof port === 'string') {
28
19
  port = parseInt(port, 10);
29
20
  }
@@ -32,7 +23,7 @@ const getPort = (port, tryLimits = 20) => __awaiter(void 0, void 0, void 0, func
32
23
  let attempts = 0;
33
24
  while (!found && attempts <= tryLimits) {
34
25
  try {
35
- yield new Promise((resolve, reject) => {
26
+ await new Promise((resolve, reject) => {
36
27
  const server = net_1.default.createServer();
37
28
  server.unref();
38
29
  server.on('error', reject);
@@ -57,6 +48,6 @@ const getPort = (port, tryLimits = 20) => __awaiter(void 0, void 0, void 0, func
57
48
  logger_1.logger.info(compiled_1.chalk.red(`Something is already running on port ${original}. ${compiled_1.chalk.yellow(`Use port ${port} instead.`)}`));
58
49
  }
59
50
  return port;
60
- });
51
+ };
61
52
  exports.getPort = getPort;
62
53
  /* eslint-enable no-param-reassign, @typescript-eslint/no-loop-func */
@@ -18,22 +18,13 @@ var __importStar = (this && this.__importStar) || function (mod) {
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
21
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
- return new (P || (P = Promise))(function (resolve, reject) {
24
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
- step((generator = generator.apply(thisArg, _arguments || [])).next());
28
- });
29
- };
30
21
  Object.defineProperty(exports, "__esModule", { value: true });
31
22
  exports.getServerConfig = void 0;
32
23
  const path = __importStar(require("path"));
33
24
  const constants_1 = require("./constants");
34
25
  const findExists_1 = require("./findExists");
35
- const getServerConfig = (appDirectory, configFile) => __awaiter(void 0, void 0, void 0, function* () {
26
+ const getServerConfig = async (appDirectory, configFile) => {
36
27
  const configFilePath = (0, findExists_1.findExists)(constants_1.CONFIG_FILE_EXTENSIONS.map(extension => path.resolve(appDirectory, `${configFile}${extension}`)));
37
28
  return configFilePath;
38
- });
29
+ };
39
30
  exports.getServerConfig = getServerConfig;
package/dist/logger.d.ts CHANGED
@@ -12,6 +12,7 @@ interface InstanceConfiguration {
12
12
  }
13
13
  interface ConstructorOptions {
14
14
  config?: InstanceConfiguration;
15
+ level?: string;
15
16
  types?: Record<string, LoggerConfiguration>;
16
17
  }
17
18
  declare type LoggerFunction = (message?: number | string | Error, ...args: any[]) => void;
@@ -42,6 +43,7 @@ declare const LOG_TYPES: {
42
43
  };
43
44
  declare class Logger {
44
45
  private readonly logCount;
46
+ private readonly level;
45
47
  private history;
46
48
  private readonly config;
47
49
  private readonly types;
@@ -59,5 +61,6 @@ declare type LoggerInterface = {
59
61
  [key in keyof typeof LOG_TYPES]: LoggerFunction;
60
62
  };
61
63
  declare const logger: Logger & LoggerInterface;
64
+ export { Logger };
62
65
  export { logger };
63
66
  export type { LoggerInterface };
package/dist/logger.js CHANGED
@@ -3,9 +3,16 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.logger = void 0;
6
+ exports.logger = exports.Logger = void 0;
7
7
  const chalk_1 = __importDefault(require("../compiled/chalk"));
8
8
  const { grey, underline } = chalk_1.default;
9
+ const LOG_LEVEL = {
10
+ error: 0,
11
+ warn: 1,
12
+ info: 2,
13
+ debug: 3,
14
+ log: 4,
15
+ };
9
16
  const LOG_TYPES = {
10
17
  error: {
11
18
  color: 'red',
@@ -27,7 +34,7 @@ const LOG_TYPES = {
27
34
  label: 'debug',
28
35
  level: 'debug',
29
36
  },
30
- log: { level: 'info' },
37
+ log: { level: 'log' },
31
38
  };
32
39
  const DEFAULT_CONFIG = {
33
40
  displayLabel: true,
@@ -38,8 +45,12 @@ class Logger {
38
45
  constructor(options = {}) {
39
46
  this.logCount = 200;
40
47
  this.history = {};
41
- this.config = Object.assign(Object.assign({}, DEFAULT_CONFIG), (options.config || {}));
42
- this.types = Object.assign(Object.assign({}, LOG_TYPES), (options.types || {}));
48
+ this.level = options.level || LOG_TYPES.log.level;
49
+ this.config = { ...DEFAULT_CONFIG, ...(options.config || {}) };
50
+ this.types = {
51
+ ...LOG_TYPES,
52
+ ...(options.types || {}),
53
+ };
43
54
  this.longestLabel = this.getLongestLabel();
44
55
  Object.keys(this.types).forEach(type => {
45
56
  this[type] = this._log.bind(this, type);
@@ -54,12 +65,15 @@ class Logger {
54
65
  this.history[type].shift();
55
66
  }
56
67
  }
57
- _log(type, message) {
68
+ _log(type, message, ...args) {
58
69
  if (message === undefined) {
59
70
  // eslint-disable-next-line no-console
60
71
  console.log();
61
72
  return;
62
73
  }
74
+ if (LOG_LEVEL[type] > LOG_LEVEL[this.level]) {
75
+ return;
76
+ }
63
77
  let label = '';
64
78
  let text = '';
65
79
  const logType = this.types[type];
@@ -94,7 +108,7 @@ class Logger {
94
108
  }
95
109
  const log = label.length > 0 ? `${label} ${text}` : text;
96
110
  // eslint-disable-next-line no-console
97
- console.log(log);
111
+ console.log(log, ...args);
98
112
  }
99
113
  getLongestLabel() {
100
114
  let longestLabel = '';
@@ -123,6 +137,7 @@ class Logger {
123
137
  }
124
138
  }
125
139
  }
140
+ exports.Logger = Logger;
126
141
  const logger = new Logger();
127
142
  exports.logger = logger;
128
143
  logger.Logger = Logger;
package/dist/monorepo.js CHANGED
@@ -31,7 +31,10 @@ const isMonorepo = (root) => (0, exports.isLerna)(root) || (0, exports.isYarnWor
31
31
  exports.isMonorepo = isMonorepo;
32
32
  const isModernjsMonorepo = (root) => {
33
33
  const json = JSON.parse(fs_1.default.readFileSync(path_1.default.join(root, 'package.json'), 'utf8'));
34
- const deps = Object.assign(Object.assign({}, (json.dependencies || {})), (json.devDependencies || {}));
34
+ const deps = {
35
+ ...(json.dependencies || {}),
36
+ ...(json.devDependencies || {}),
37
+ };
35
38
  return Boolean(deps['@modern-js/monorepo-tools']);
36
39
  };
37
40
  exports.isModernjsMonorepo = isModernjsMonorepo;
package/dist/nodeEnv.js CHANGED
@@ -1,49 +1,34 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.canUsePnpm = exports.canUseYarn = exports.canUseNpm = void 0;
13
4
  const compiled_1 = require("./compiled");
14
- function canUseNpm() {
15
- return __awaiter(this, void 0, void 0, function* () {
16
- try {
17
- yield (0, compiled_1.execa)('npm', ['--version'], { env: process.env });
18
- return true;
19
- }
20
- catch (e) {
21
- return false;
22
- }
23
- });
5
+ async function canUseNpm() {
6
+ try {
7
+ await (0, compiled_1.execa)('npm', ['--version'], { env: process.env });
8
+ return true;
9
+ }
10
+ catch (e) {
11
+ return false;
12
+ }
24
13
  }
25
14
  exports.canUseNpm = canUseNpm;
26
- function canUseYarn() {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- try {
29
- yield (0, compiled_1.execa)('yarn', ['--version'], { env: process.env });
30
- return true;
31
- }
32
- catch (e) {
33
- return false;
34
- }
35
- });
15
+ async function canUseYarn() {
16
+ try {
17
+ await (0, compiled_1.execa)('yarn', ['--version'], { env: process.env });
18
+ return true;
19
+ }
20
+ catch (e) {
21
+ return false;
22
+ }
36
23
  }
37
24
  exports.canUseYarn = canUseYarn;
38
- function canUsePnpm() {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- try {
41
- yield (0, compiled_1.execa)('pnpm', ['--version'], { env: process.env });
42
- return true;
43
- }
44
- catch (e) {
45
- return false;
46
- }
47
- });
25
+ async function canUsePnpm() {
26
+ try {
27
+ await (0, compiled_1.execa)('pnpm', ['--version'], { env: process.env });
28
+ return true;
29
+ }
30
+ catch (e) {
31
+ return false;
32
+ }
48
33
  }
49
34
  exports.canUsePnpm = canUsePnpm;
@@ -41,7 +41,7 @@ exports.createRuntimeExportsUtils = memo((pwd = '', namespace, ts = false) => {
41
41
  compiled_1.fs.appendFileSync(entryExportTsFile, `${statement.replace('.js', '.d')}\n`);
42
42
  }
43
43
  }
44
- catch (_a) {
44
+ catch {
45
45
  // FIXME:
46
46
  }
47
47
  };
package/dist/watch.js CHANGED
@@ -18,15 +18,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
18
18
  __setModuleDefault(result, mod);
19
19
  return result;
20
20
  };
21
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
- return new (P || (P = Promise))(function (resolve, reject) {
24
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
- step((generator = generator.apply(thisArg, _arguments || [])).next());
28
- });
29
- };
30
21
  Object.defineProperty(exports, "__esModule", { value: true });
31
22
  exports.watch = exports.WatchChangeType = void 0;
32
23
  const path = __importStar(require("path"));
@@ -42,20 +33,20 @@ const watch = (watchDir, runTask, ignored = []) => {
42
33
  ignored,
43
34
  });
44
35
  watcher.on('ready', () => (ready = true));
45
- watcher.on('change', (filePath) => __awaiter(void 0, void 0, void 0, function* () {
36
+ watcher.on('change', async (filePath) => {
46
37
  const changedFilePath = path.resolve(filePath);
47
- yield runTask({ changedFilePath, changeType: exports.WatchChangeType.CHANGE });
48
- }));
49
- watcher.on('add', (filePath) => __awaiter(void 0, void 0, void 0, function* () {
38
+ await runTask({ changedFilePath, changeType: exports.WatchChangeType.CHANGE });
39
+ });
40
+ watcher.on('add', async (filePath) => {
50
41
  const changedFilePath = path.resolve(filePath);
51
42
  if (ready) {
52
- yield runTask({ changedFilePath, changeType: exports.WatchChangeType.ADD });
43
+ await runTask({ changedFilePath, changeType: exports.WatchChangeType.ADD });
53
44
  }
54
- }));
55
- watcher.on('unlink', (filePath) => __awaiter(void 0, void 0, void 0, function* () {
45
+ });
46
+ watcher.on('unlink', async (filePath) => {
56
47
  const changedFilePath = path.resolve(filePath);
57
- yield runTask({ changedFilePath, changeType: exports.WatchChangeType.UNLINK });
58
- }));
48
+ await runTask({ changedFilePath, changeType: exports.WatchChangeType.UNLINK });
49
+ });
59
50
  watcher.on('error', err => {
60
51
  throw err;
61
52
  });
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.6.0",
14
+ "version": "1.7.0",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/index.d.ts",
17
17
  "main": "./dist/index.js",
@@ -35,14 +35,15 @@
35
35
  "jsnext:source": "./src/ssr.ts",
36
36
  "default": "./dist/ssr.js"
37
37
  },
38
- "./lodash": {
39
- "jsnext:source": "./compiled/lodash/index.js",
40
- "default": "./compiled/lodash/index.js"
41
- },
42
- "./strip-ansi": {
43
- "jsnext:source": "./compiled/strip-ansi/index.js",
44
- "default": "./compiled/strip-ansi/index.js"
45
- }
38
+ "./chalk": "./compiled/chalk/index.js",
39
+ "./json5": "./compiled/json5/index.js",
40
+ "./semver": "./compiled/semver/index.js",
41
+ "./lodash": "./compiled/lodash/index.js",
42
+ "./globby": "./compiled/globby/index.js",
43
+ "./fast-glob": "./compiled/fast-glob/index.js",
44
+ "./gzip-size": "./compiled/gzip-size/index.js",
45
+ "./mime-types": "./compiled/mime-types/index.js",
46
+ "./strip-ansi": "./compiled/strip-ansi/index.js"
46
47
  },
47
48
  "typesVersions": {
48
49
  "*": {
@@ -55,9 +56,30 @@
55
56
  "ssr": [
56
57
  "./dist/ssr.d.ts"
57
58
  ],
59
+ "chalk": [
60
+ "./compiled/chalk/index.d.ts"
61
+ ],
62
+ "json5": [
63
+ "./compiled/json5/index.d.ts"
64
+ ],
65
+ "semver": [
66
+ "./compiled/semver/index.d.ts"
67
+ ],
58
68
  "lodash": [
59
69
  "./compiled/lodash/index.d.ts"
60
70
  ],
71
+ "globby": [
72
+ "./compiled/globby/index.d.ts"
73
+ ],
74
+ "fast-glob": [
75
+ "./compiled/fast-glob/index.d.ts"
76
+ ],
77
+ "gzip-size": [
78
+ "./compiled/gzip-size/index.d.ts"
79
+ ],
80
+ "mime-types": [
81
+ "./compiled/mime-types/index.d.ts"
82
+ ],
61
83
  "strip-ansi": [
62
84
  "./compiled/strip-ansi/index.d.ts"
63
85
  ]
@@ -65,10 +87,11 @@
65
87
  },
66
88
  "dependencies": {
67
89
  "caniuse-lite": "^1.0.30001332",
90
+ "lodash": "^4.17.21",
68
91
  "typescript": "^4"
69
92
  },
70
93
  "devDependencies": {
71
- "@modern-js/types": "1.5.1",
94
+ "@modern-js/types": "1.5.2",
72
95
  "@scripts/build": "0.0.0",
73
96
  "@scripts/jest-config": "0.0.0",
74
97
  "@types/jest": "^26",
package/tsconfig.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "extends": "@modern-js/tsconfig/base",
3
3
  "compilerOptions": {
4
+ "target": "ES2019",
4
5
  "declaration": true,
5
6
  "outDir": "./dist",
6
7
  "baseUrl": "./",
@@ -1,20 +0,0 @@
1
- import type * as fsStat from '../../../@nodelib/fs.stat';
2
- import type { Dirent, ErrnoException } from '../types';
3
- export interface ReaddirAsynchronousMethod {
4
- (filepath: string, options: {
5
- withFileTypes: true;
6
- }, callback: (error: ErrnoException | null, files: Dirent[]) => void): void;
7
- (filepath: string, callback: (error: ErrnoException | null, files: string[]) => void): void;
8
- }
9
- export interface ReaddirSynchronousMethod {
10
- (filepath: string, options: {
11
- withFileTypes: true;
12
- }): Dirent[];
13
- (filepath: string): string[];
14
- }
15
- export declare type FileSystemAdapter = fsStat.FileSystemAdapter & {
16
- readdir: ReaddirAsynchronousMethod;
17
- readdirSync: ReaddirSynchronousMethod;
18
- };
19
- export declare const FILE_SYSTEM_ADAPTER: FileSystemAdapter;
20
- export declare function createFileSystemAdapter(fsMethods?: Partial<FileSystemAdapter>): FileSystemAdapter;
@@ -1,12 +0,0 @@
1
- import type { FileSystemAdapter, ReaddirAsynchronousMethod, ReaddirSynchronousMethod } from './adapters/fs';
2
- import * as async from './providers/async';
3
- import Settings, { Options } from './settings';
4
- import type { Dirent, Entry } from './types';
5
- declare type AsyncCallback = async.AsyncCallback;
6
- declare function scandir(path: string, callback: AsyncCallback): void;
7
- declare function scandir(path: string, optionsOrSettings: Options | Settings, callback: AsyncCallback): void;
8
- declare namespace scandir {
9
- function __promisify__(path: string, optionsOrSettings?: Options | Settings): Promise<Entry[]>;
10
- }
11
- declare function scandirSync(path: string, optionsOrSettings?: Options | Settings): Entry[];
12
- export { scandir, scandirSync, Settings, AsyncCallback, Dirent, Entry, FileSystemAdapter, ReaddirAsynchronousMethod, ReaddirSynchronousMethod, Options };
@@ -1,7 +0,0 @@
1
- /// <reference types="node" />
2
- import type Settings from '../settings';
3
- import type { Entry } from '../types';
4
- export declare type AsyncCallback = (error: NodeJS.ErrnoException, entries: Entry[]) => void;
5
- export declare function read(directory: string, settings: Settings, callback: AsyncCallback): void;
6
- export declare function readdirWithFileTypes(directory: string, settings: Settings, callback: AsyncCallback): void;
7
- export declare function readdir(directory: string, settings: Settings, callback: AsyncCallback): void;
@@ -1,20 +0,0 @@
1
- import * as fsStat from '../../@nodelib/fs.stat';
2
- import * as fs from './adapters/fs';
3
- export interface Options {
4
- followSymbolicLinks?: boolean;
5
- fs?: Partial<fs.FileSystemAdapter>;
6
- pathSegmentSeparator?: string;
7
- stats?: boolean;
8
- throwErrorOnBrokenSymbolicLink?: boolean;
9
- }
10
- export default class Settings {
11
- private readonly _options;
12
- readonly followSymbolicLinks: boolean;
13
- readonly fs: fs.FileSystemAdapter;
14
- readonly pathSegmentSeparator: string;
15
- readonly stats: boolean;
16
- readonly throwErrorOnBrokenSymbolicLink: boolean;
17
- readonly fsStatSettings: fsStat.Settings;
18
- constructor(_options?: Options);
19
- private _getValue;
20
- }
@@ -1,20 +0,0 @@
1
- /// <reference types="node" />
2
- import type * as fs from 'fs';
3
- export interface Entry {
4
- dirent: Dirent;
5
- name: string;
6
- path: string;
7
- stats?: Stats;
8
- }
9
- export declare type Stats = fs.Stats;
10
- export declare type ErrnoException = NodeJS.ErrnoException;
11
- export interface Dirent {
12
- isBlockDevice: () => boolean;
13
- isCharacterDevice: () => boolean;
14
- isDirectory: () => boolean;
15
- isFIFO: () => boolean;
16
- isFile: () => boolean;
17
- isSocket: () => boolean;
18
- isSymbolicLink: () => boolean;
19
- name: string;
20
- }
@@ -1,13 +0,0 @@
1
- /// <reference types="node" />
2
- import * as fs from 'fs';
3
- import type { ErrnoException } from '../types';
4
- export declare type StatAsynchronousMethod = (path: string, callback: (error: ErrnoException | null, stats: fs.Stats) => void) => void;
5
- export declare type StatSynchronousMethod = (path: string) => fs.Stats;
6
- export interface FileSystemAdapter {
7
- lstat: StatAsynchronousMethod;
8
- stat: StatAsynchronousMethod;
9
- lstatSync: StatSynchronousMethod;
10
- statSync: StatSynchronousMethod;
11
- }
12
- export declare const FILE_SYSTEM_ADAPTER: FileSystemAdapter;
13
- export declare function createFileSystemAdapter(fsMethods?: Partial<FileSystemAdapter>): FileSystemAdapter;
@@ -1,12 +0,0 @@
1
- import type { FileSystemAdapter, StatAsynchronousMethod, StatSynchronousMethod } from './adapters/fs';
2
- import * as async from './providers/async';
3
- import Settings, { Options } from './settings';
4
- import type { Stats } from './types';
5
- declare type AsyncCallback = async.AsyncCallback;
6
- declare function stat(path: string, callback: AsyncCallback): void;
7
- declare function stat(path: string, optionsOrSettings: Options | Settings, callback: AsyncCallback): void;
8
- declare namespace stat {
9
- function __promisify__(path: string, optionsOrSettings?: Options | Settings): Promise<Stats>;
10
- }
11
- declare function statSync(path: string, optionsOrSettings?: Options | Settings): Stats;
12
- export { Settings, stat, statSync, AsyncCallback, FileSystemAdapter, StatAsynchronousMethod, StatSynchronousMethod, Options, Stats };
@@ -1,4 +0,0 @@
1
- import type Settings from '../settings';
2
- import type { ErrnoException, Stats } from '../types';
3
- export declare type AsyncCallback = (error: ErrnoException, stats: Stats) => void;
4
- export declare function read(path: string, settings: Settings, callback: AsyncCallback): void;
@@ -1,16 +0,0 @@
1
- import * as fs from './adapters/fs';
2
- export interface Options {
3
- followSymbolicLink?: boolean;
4
- fs?: Partial<fs.FileSystemAdapter>;
5
- markSymbolicLink?: boolean;
6
- throwErrorOnBrokenSymbolicLink?: boolean;
7
- }
8
- export default class Settings {
9
- private readonly _options;
10
- readonly followSymbolicLink: boolean;
11
- readonly fs: fs.FileSystemAdapter;
12
- readonly markSymbolicLink: boolean;
13
- readonly throwErrorOnBrokenSymbolicLink: boolean;
14
- constructor(_options?: Options);
15
- private _getValue;
16
- }
@@ -1,4 +0,0 @@
1
- /// <reference types="node" />
2
- import type * as fs from 'fs';
3
- export declare type Stats = fs.Stats;
4
- export declare type ErrnoException = NodeJS.ErrnoException;
@@ -1,14 +0,0 @@
1
- /// <reference types="node" />
2
- import type { Readable } from 'stream';
3
- import type { Dirent, FileSystemAdapter } from '../../@nodelib/fs.scandir';
4
- import { AsyncCallback } from './providers/async';
5
- import Settings, { DeepFilterFunction, EntryFilterFunction, ErrorFilterFunction, Options } from './settings';
6
- import type { Entry } from './types';
7
- declare function walk(directory: string, callback: AsyncCallback): void;
8
- declare function walk(directory: string, optionsOrSettings: Options | Settings, callback: AsyncCallback): void;
9
- declare namespace walk {
10
- function __promisify__(directory: string, optionsOrSettings?: Options | Settings): Promise<Entry[]>;
11
- }
12
- declare function walkSync(directory: string, optionsOrSettings?: Options | Settings): Entry[];
13
- declare function walkStream(directory: string, optionsOrSettings?: Options | Settings): Readable;
14
- export { walk, walkSync, walkStream, Settings, AsyncCallback, Dirent, Entry, FileSystemAdapter, Options, DeepFilterFunction, EntryFilterFunction, ErrorFilterFunction };
@@ -1,12 +0,0 @@
1
- import AsyncReader from '../readers/async';
2
- import type Settings from '../settings';
3
- import type { Entry, Errno } from '../types';
4
- export declare type AsyncCallback = (error: Errno, entries: Entry[]) => void;
5
- export default class AsyncProvider {
6
- private readonly _root;
7
- private readonly _settings;
8
- protected readonly _reader: AsyncReader;
9
- private readonly _storage;
10
- constructor(_root: string, _settings: Settings);
11
- read(callback: AsyncCallback): void;
12
- }