@modern-js/utils 1.1.6-alpha.0 → 1.2.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 +17 -0
- package/dist/js/modern/constants.js +1 -1
- package/dist/js/modern/getBrowserslist.js +1 -1
- package/dist/js/modern/prettyInstructions.js +1 -1
- package/dist/js/node/constants.js +1 -1
- package/dist/js/node/getBrowserslist.js +2 -2
- package/dist/js/node/prettyInstructions.js +1 -1
- package/dist/js/treeshaking/constants.js +1 -1
- package/dist/js/treeshaking/getBrowserslist.js +1 -1
- package/dist/js/treeshaking/prettyInstructions.js +1 -1
- package/dist/types/getBrowserslist.d.ts +1 -1
- package/jest.config.js +8 -0
- package/package.json +20 -13
- package/src/constants.ts +1 -1
- package/src/getBrowserslist.ts +1 -1
- package/src/prettyInstructions.ts +1 -1
- package/tests/applyOptionsChain.test.ts +1 -1
- package/tests/compatRequire.test.ts +1 -1
- package/tests/debug.test.ts +4 -2
- package/tests/ensureAbsolutePath.test.ts +1 -1
- package/tests/findExists.test.ts +1 -1
- package/tests/getBrowserslist.test.ts +1 -1
- package/tests/getCacheIdentifier.test.ts +1 -1
- package/tests/getEntryOptions.test.ts +1 -1
- package/tests/index.test.ts +16 -0
- package/tests/logger.test.ts +1 -1
- package/tests/removeSlash.test.ts +1 -1
- package/tests/tsconfig.json +1 -3
- package/tsconfig.json +1 -3
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,22 @@
|
|
1
1
|
# @modern-js/utils
|
2
2
|
|
3
|
+
## 1.2.0
|
4
|
+
|
5
|
+
### Minor Changes
|
6
|
+
|
7
|
+
- cfe11628: Make Modern.js self bootstraping
|
8
|
+
|
9
|
+
### Patch Changes
|
10
|
+
|
11
|
+
- 2da09c69: Add "typescript" to the dependency list
|
12
|
+
- c3d46ee4: fix: test config invalid
|
13
|
+
|
14
|
+
## 1.1.6
|
15
|
+
|
16
|
+
### Patch Changes
|
17
|
+
|
18
|
+
- b7fb82ec: fix: get package manager function
|
19
|
+
|
3
20
|
## 1.1.5
|
4
21
|
|
5
22
|
### Patch Changes
|
@@ -21,7 +21,7 @@ const getAddressUrls = (protocol = 'http', port) => {
|
|
21
21
|
let type = 'Network: ';
|
22
22
|
let url = `${protocol}://${detail.address}:${port}`;
|
23
23
|
|
24
|
-
if (detail.address.includes(`
|
24
|
+
if (detail.address.includes(`localhost`)) {
|
25
25
|
type = 'Local: ';
|
26
26
|
url = `${protocol}://localhost:${port}`;
|
27
27
|
}
|
@@ -5,12 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.getBrowserslist = exports.defaults = void 0;
|
7
7
|
|
8
|
-
var
|
8
|
+
var _browserslist = require("browserslist");
|
9
9
|
|
10
10
|
const defaults = ['> 0.01%', 'not dead', 'not op_mini all'];
|
11
11
|
exports.defaults = defaults;
|
12
12
|
|
13
|
-
const getBrowserslist = appDirectory => (0,
|
13
|
+
const getBrowserslist = appDirectory => (0, _browserslist.loadConfig)({
|
14
14
|
path: appDirectory
|
15
15
|
}) || defaults;
|
16
16
|
|
@@ -35,7 +35,7 @@ const getAddressUrls = (protocol = 'http', port) => {
|
|
35
35
|
let type = 'Network: ';
|
36
36
|
let url = `${protocol}://${detail.address}:${port}`;
|
37
37
|
|
38
|
-
if (detail.address.includes(`
|
38
|
+
if (detail.address.includes(`localhost`)) {
|
39
39
|
type = 'Local: ';
|
40
40
|
url = `${protocol}://localhost:${port}`;
|
41
41
|
}
|
@@ -39,7 +39,7 @@ var getAddressUrls = function getAddressUrls() {
|
|
39
39
|
var type = 'Network: ';
|
40
40
|
var url = "".concat(protocol, "://").concat(detail.address, ":").concat(port);
|
41
41
|
|
42
|
-
if (detail.address.includes("
|
42
|
+
if (detail.address.includes("localhost")) {
|
43
43
|
type = 'Local: ';
|
44
44
|
url = "".concat(protocol, "://localhost:").concat(port);
|
45
45
|
}
|
@@ -1,2 +1,2 @@
|
|
1
1
|
export declare const defaults: string[];
|
2
|
-
export declare const getBrowserslist: (appDirectory: string) =>
|
2
|
+
export declare const getBrowserslist: (appDirectory: string) => string[];
|
package/jest.config.js
ADDED
package/package.json
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
"modern",
|
12
12
|
"modern.js"
|
13
13
|
],
|
14
|
-
"version": "1.
|
14
|
+
"version": "1.2.0",
|
15
15
|
"jsnext:source": "./src/index.ts",
|
16
16
|
"types": "./dist/types/index.d.ts",
|
17
17
|
"main": "./dist/js/node/index.js",
|
@@ -20,13 +20,20 @@
|
|
20
20
|
"exports": {
|
21
21
|
".": {
|
22
22
|
"node": {
|
23
|
+
"jsnext:source": "./src/index.ts",
|
23
24
|
"import": "./dist/js/modern/index.js",
|
24
25
|
"require": "./dist/js/node/index.js"
|
25
26
|
},
|
26
27
|
"default": "./dist/js/treeshaking/index.js"
|
27
28
|
},
|
28
|
-
"./formatWebpackMessages":
|
29
|
-
|
29
|
+
"./formatWebpackMessages": {
|
30
|
+
"jsnext:source": "./src/formatWebpackMessages.ts",
|
31
|
+
"default": "./dist/js/treeshaking/formatWebpackMessages.js"
|
32
|
+
},
|
33
|
+
"./constants": {
|
34
|
+
"jsnext:source": "./src/constants.ts",
|
35
|
+
"default": "./dist/js/treeshaking/constants.js"
|
36
|
+
}
|
30
37
|
},
|
31
38
|
"typesVersions": {
|
32
39
|
"*": {
|
@@ -55,7 +62,8 @@
|
|
55
62
|
"strip-ansi": "6.0.0",
|
56
63
|
"upath": "^2.0.1",
|
57
64
|
"yaml": "^1.10.2",
|
58
|
-
"execa": "5"
|
65
|
+
"execa": "5",
|
66
|
+
"typescript": "^4"
|
59
67
|
},
|
60
68
|
"devDependencies": {
|
61
69
|
"@types/debug": "^4.1.7",
|
@@ -64,22 +72,21 @@
|
|
64
72
|
"@types/jest": "^26",
|
65
73
|
"@types/node": "^14",
|
66
74
|
"@types/recursive-readdir": "^2.2.0",
|
67
|
-
"typescript": "^4",
|
68
75
|
"webpack": "^5.54.0",
|
69
|
-
"@
|
70
|
-
"
|
71
|
-
|
72
|
-
"peerDependencies": {
|
73
|
-
"typescript": "^4.4.3"
|
76
|
+
"@scripts/build": "0.0.0",
|
77
|
+
"jest": "^27",
|
78
|
+
"@scripts/jest-config": "0.0.0"
|
74
79
|
},
|
75
80
|
"sideEffects": false,
|
76
81
|
"publishConfig": {
|
77
82
|
"registry": "https://registry.npmjs.org/",
|
78
|
-
"access": "public"
|
83
|
+
"access": "public",
|
84
|
+
"types": "./dist/types/index.d.ts"
|
79
85
|
},
|
80
86
|
"scripts": {
|
81
87
|
"new": "modern new",
|
82
88
|
"build": "modern build",
|
83
|
-
"test": "
|
84
|
-
}
|
89
|
+
"test": "jest --passWithNoTests"
|
90
|
+
},
|
91
|
+
"readme": "\n<p align=\"center\">\n <a href=\"https://modernjs.dev\" target=\"blank\"><img src=\"https://lf3-static.bytednsdoc.com/obj/eden-cn/ylaelkeh7nuhfnuhf/modernjs-cover.png\" width=\"300\" alt=\"Modern.js Logo\" /></a>\n</p>\n<p align=\"center\">\n现代 Web 工程体系\n <br/>\n <a href=\"https://modernjs.dev\" target=\"blank\">\n modernjs.dev\n </a>\n</p>\n<p align=\"center\">\n The meta-framework suite designed from scratch for frontend-focused modern web development\n</p>\n\n# Introduction\n\n> The doc site ([modernjs.dev](https://modernjs.dev)) and articles are only available in Chinese for now, we are planning to add English versions soon.\n\n- [Modern.js: Hello, World!](https://zhuanlan.zhihu.com/p/426707646)\n\n## Getting Started\n\n- [Quick Start](https://modernjs.dev/docs/start)\n- [Guides](https://modernjs.dev/docs/guides)\n- [API References](https://modernjs.dev/docs/apis)\n\n## Contributing\n\n- [Contributing Guide](https://github.com/modern-js-dev/modern.js/blob/main/CONTRIBUTING.md)\n"
|
85
92
|
}
|
package/src/constants.ts
CHANGED
package/src/getBrowserslist.ts
CHANGED
@@ -34,7 +34,7 @@ const getAddressUrls = (protocol = 'http', port: number) => {
|
|
34
34
|
(memo: { type: string; url: string }[], detail) => {
|
35
35
|
let type = 'Network: ';
|
36
36
|
let url = `${protocol}://${detail.address}:${port}`;
|
37
|
-
if (detail.address.includes(`
|
37
|
+
if (detail.address.includes(`localhost`)) {
|
38
38
|
type = 'Local: ';
|
39
39
|
url = `${protocol}://localhost:${port}`;
|
40
40
|
}
|
package/tests/debug.test.ts
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
import debug from 'debug';
|
2
|
-
import
|
2
|
+
import stripAnsi from 'strip-ansi';
|
3
|
+
import { createDebugger } from '../src/debug';
|
3
4
|
|
4
5
|
describe('debug utility', () => {
|
5
6
|
test('should return file path', () => {
|
@@ -10,7 +11,8 @@ describe('debug utility', () => {
|
|
10
11
|
debug.enable('modern-js:test2');
|
11
12
|
|
12
13
|
debug.log = (...args) => {
|
13
|
-
|
14
|
+
// XXX: args[0] 的内容有时候是 ' \x1B[38;5;167;1mmodern-js:test2 \x1B[0m22222' 这种格式
|
15
|
+
expect(stripAnsi(args[0])).toContain('modern-js:test2 22222');
|
14
16
|
};
|
15
17
|
|
16
18
|
debug1('11111');
|
package/tests/findExists.test.ts
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
import { canUseNpm, canUsePnpm, canUseYarn } from '../src';
|
2
|
+
|
3
|
+
describe('test generator utils', () => {
|
4
|
+
test('test canUseNpm', async () => {
|
5
|
+
const npmAbility = await canUseNpm();
|
6
|
+
expect(typeof npmAbility === 'boolean').toBe(true);
|
7
|
+
});
|
8
|
+
test('test canUsePnpm', async () => {
|
9
|
+
const pnpmAbility = await canUsePnpm();
|
10
|
+
expect(typeof pnpmAbility === 'boolean').toBe(true);
|
11
|
+
});
|
12
|
+
test('test canUseYarn', async () => {
|
13
|
+
const yarnAbility = await canUseYarn();
|
14
|
+
expect(typeof yarnAbility === 'boolean').toBe(true);
|
15
|
+
});
|
16
|
+
});
|
package/tests/logger.test.ts
CHANGED
package/tests/tsconfig.json
CHANGED