@modern-js/utils 1.7.5 → 1.7.8

Sign up to get free protection for your applications and to get access to all the features.
package/dist/index.js CHANGED
@@ -20,6 +20,7 @@ __exportStar(require("./is"), exports);
20
20
  __exportStar(require("./compatRequire"), exports);
21
21
  __exportStar(require("./logger"), exports);
22
22
  __exportStar(require("./constants"), exports);
23
+ __exportStar(require("./ensureArray"), exports);
23
24
  __exportStar(require("./ensureAbsolutePath"), exports);
24
25
  __exportStar(require("./clearConsole"), exports);
25
26
  __exportStar(require("./applyOptionsChain"), exports);
@@ -43,3 +44,4 @@ __exportStar(require("./emptyDir"), exports);
43
44
  __exportStar(require("./getServerConfig"), exports);
44
45
  __exportStar(require("./ssr"), exports);
45
46
  __exportStar(require("./analyzeProject"), exports);
47
+ __exportStar(require("./chainId"), exports);
package/dist/monorepo.js CHANGED
@@ -30,7 +30,11 @@ exports.isPnpmWorkspaces = isPnpmWorkspaces;
30
30
  const isMonorepo = (root) => (0, exports.isLerna)(root) || (0, exports.isYarnWorkspaces)(root) || (0, exports.isPnpmWorkspaces)(root);
31
31
  exports.isMonorepo = isMonorepo;
32
32
  const isModernjsMonorepo = (root) => {
33
- const json = JSON.parse(fs_1.default.readFileSync(path_1.default.join(root, 'package.json'), 'utf8'));
33
+ const pkgJsonPath = path_1.default.join(root, 'package.json');
34
+ if (!fs_1.default.existsSync(pkgJsonPath)) {
35
+ return false;
36
+ }
37
+ const json = JSON.parse(fs_1.default.readFileSync(pkgJsonPath, 'utf8'));
34
38
  const deps = {
35
39
  ...(json.dependencies || {}),
36
40
  ...(json.devDependencies || {}),
package/dist/path.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  export declare const isRelativePath: (test: string) => boolean;
2
2
  export declare const normalizeOutputPath: (s: string) => string;
3
- export declare const normalizeToPosixPath: (p: string) => string;
3
+ export declare const normalizeToPosixPath: (p: string | undefined) => string;
package/dist/path.js CHANGED
@@ -10,5 +10,5 @@ const isRelativePath = (test) => /^\.\.?($|[\\/])/.test(test);
10
10
  exports.isRelativePath = isRelativePath;
11
11
  const normalizeOutputPath = (s) => s.replace(/\\/g, '\\\\');
12
12
  exports.normalizeOutputPath = normalizeOutputPath;
13
- const normalizeToPosixPath = (p) => compiled_1.upath.normalizeSafe(path_1.default.normalize(p));
13
+ const normalizeToPosixPath = (p) => compiled_1.upath.normalizeSafe(path_1.default.normalize(p || ''));
14
14
  exports.normalizeToPosixPath = normalizeToPosixPath;
@@ -1,6 +1,9 @@
1
+ /// <reference types="node" />
2
+ import os from 'os';
1
3
  interface EntryPoint {
2
4
  entryName: string;
3
5
  }
4
6
  export declare const isSingleEntry: (entrypoints: EntryPoint[]) => boolean;
7
+ export declare const getIpv4Interfaces: () => os.NetworkInterfaceInfo[];
5
8
  export declare const prettyInstructions: (appContext: any, config: any) => string;
6
9
  export {};
@@ -3,7 +3,7 @@ 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.prettyInstructions = exports.isSingleEntry = void 0;
6
+ exports.prettyInstructions = exports.getIpv4Interfaces = exports.isSingleEntry = void 0;
7
7
  const os_1 = __importDefault(require("os"));
8
8
  const compiled_1 = require("./compiled");
9
9
  const is_1 = require("./is");
@@ -11,20 +11,27 @@ const is_1 = require("./is");
11
11
  const isSingleEntry = (entrypoints) => entrypoints.length === 1 && entrypoints[0].entryName === 'main';
12
12
  exports.isSingleEntry = isSingleEntry;
13
13
  const normalizeUrl = (url) => url.replace(/([^:]\/)\/+/g, '$1');
14
- const getAddressUrls = (protocol = 'http', port) => {
14
+ const getIpv4Interfaces = () => {
15
15
  const interfaces = os_1.default.networkInterfaces();
16
16
  const ipv4Interfaces = [];
17
17
  Object.keys(interfaces).forEach(key => {
18
18
  interfaces[key].forEach(detail => {
19
- if (detail.family === 'IPv4') {
19
+ // 'IPv4' is in Node <= 17, from 18 it's a number 4 or 6
20
+ const familyV4Value = typeof detail.family === 'string' ? 'IPv4' : 4;
21
+ if (detail.family === familyV4Value) {
20
22
  ipv4Interfaces.push(detail);
21
23
  }
22
24
  });
23
25
  });
26
+ return ipv4Interfaces;
27
+ };
28
+ exports.getIpv4Interfaces = getIpv4Interfaces;
29
+ const getAddressUrls = (protocol = 'http', port) => {
30
+ const ipv4Interfaces = (0, exports.getIpv4Interfaces)();
24
31
  return ipv4Interfaces.reduce((memo, detail) => {
25
32
  let type = 'Network: ';
26
33
  let url = `${protocol}://${detail.address}:${port}`;
27
- if (detail.address.includes(`localhost`)) {
34
+ if (detail.address.includes(`localhost`) || detail.internal) {
28
35
  type = 'Local: ';
29
36
  url = `${protocol}://localhost:${port}`;
30
37
  }
package/package.json CHANGED
@@ -11,7 +11,7 @@
11
11
  "modern",
12
12
  "modern.js"
13
13
  ],
14
- "version": "1.7.5",
14
+ "version": "1.7.8",
15
15
  "jsnext:source": "./src/index.ts",
16
16
  "types": "./dist/index.d.ts",
17
17
  "main": "./dist/index.js",
@@ -23,6 +23,7 @@
23
23
  "./format": "./dist/format.js",
24
24
  "./constants": "./dist/constants.js",
25
25
  "./ssr": "./dist/ssr.js",
26
+ "./glob": "./compiled/glob/index.js",
26
27
  "./chalk": "./compiled/chalk/index.js",
27
28
  "./json5": "./compiled/json5/index.js",
28
29
  "./semver": "./compiled/semver/index.js",
@@ -33,6 +34,7 @@
33
34
  "./mime-types": "./compiled/mime-types/index.js",
34
35
  "./strip-ansi": "./compiled/strip-ansi/index.js",
35
36
  "./browserslist": "./compiled/browserslist/index.js",
37
+ "./webpack-chain": "./compiled/webpack-chain/index.js",
36
38
  "./tsconfig-paths": "./compiled/tsconfig-paths/index.js"
37
39
  },
38
40
  "publishConfig": {
@@ -50,6 +52,9 @@
50
52
  "ssr": [
51
53
  "./dist/ssr.d.ts"
52
54
  ],
55
+ "glob": [
56
+ "./compiled/glob/index.d.ts"
57
+ ],
53
58
  "chalk": [
54
59
  "./compiled/chalk/index.d.ts"
55
60
  ],
@@ -80,6 +85,9 @@
80
85
  "browserslist": [
81
86
  "./compiled/browserslist/index.d.ts"
82
87
  ],
88
+ "webpack-chain": [
89
+ "./compiled/webpack-chain/types/index.d.ts"
90
+ ],
83
91
  "tsconfig-paths": [
84
92
  "./compiled/tsconfig-paths/lib/index.d.ts"
85
93
  ]
@@ -90,7 +98,7 @@
90
98
  "lodash": "^4.17.21"
91
99
  },
92
100
  "devDependencies": {
93
- "@modern-js/types": "1.5.3",
101
+ "@modern-js/types": "1.5.4",
94
102
  "@scripts/build": "0.0.0",
95
103
  "@scripts/jest-config": "0.0.0",
96
104
  "@types/jest": "^27",