@modern-js/utils 1.3.8-canary.0 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +49 -0
- package/compiled/address/index.js +1 -0
- package/compiled/address/lib/address.d.ts +28 -0
- package/compiled/address/package.json +1 -0
- package/compiled/browserslist/index.js +1 -1
- package/compiled/dotenv/index.js +1 -0
- package/compiled/dotenv/license +23 -0
- package/compiled/dotenv/package.json +1 -0
- package/compiled/dotenv/types/index.d.ts +59 -0
- package/compiled/dotenv-expand/index.d.ts +15 -0
- package/compiled/dotenv-expand/index.js +1 -0
- package/compiled/dotenv-expand/license +24 -0
- package/compiled/dotenv-expand/package.json +1 -0
- package/compiled/fast-glob/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
- package/compiled/fast-glob/@nodelib/fs.scandir/out/index.d.ts +12 -0
- package/compiled/fast-glob/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
- package/compiled/fast-glob/@nodelib/fs.scandir/out/settings.d.ts +20 -0
- package/compiled/fast-glob/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
- package/compiled/fast-glob/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
- package/compiled/fast-glob/@nodelib/fs.stat/out/index.d.ts +12 -0
- package/compiled/fast-glob/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
- package/compiled/fast-glob/@nodelib/fs.stat/out/settings.d.ts +16 -0
- package/compiled/fast-glob/@nodelib/fs.stat/out/types/index.d.ts +4 -0
- package/compiled/fast-glob/@nodelib/fs.walk/out/index.d.ts +14 -0
- package/compiled/fast-glob/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
- package/compiled/fast-glob/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
- package/compiled/fast-glob/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
- package/compiled/fast-glob/@nodelib/fs.walk/out/settings.d.ts +30 -0
- package/compiled/fast-glob/@nodelib/fs.walk/out/types/index.d.ts +8 -0
- package/compiled/fast-glob/index.js +37 -0
- package/compiled/fast-glob/license +21 -0
- package/compiled/fast-glob/out/index.d.ts +27 -0
- package/compiled/fast-glob/out/managers/tasks.d.ts +22 -0
- package/compiled/fast-glob/out/settings.d.ts +164 -0
- package/compiled/fast-glob/out/types/index.d.ts +31 -0
- package/compiled/fast-glob/package.json +1 -0
- package/compiled/globby/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
- package/compiled/globby/@nodelib/fs.scandir/out/index.d.ts +12 -0
- package/compiled/globby/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
- package/compiled/globby/@nodelib/fs.scandir/out/settings.d.ts +20 -0
- package/compiled/globby/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
- package/compiled/globby/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
- package/compiled/globby/@nodelib/fs.stat/out/index.d.ts +12 -0
- package/compiled/globby/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
- package/compiled/globby/@nodelib/fs.stat/out/settings.d.ts +16 -0
- package/compiled/globby/@nodelib/fs.stat/out/types/index.d.ts +4 -0
- package/compiled/globby/@nodelib/fs.walk/out/index.d.ts +14 -0
- package/compiled/globby/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
- package/compiled/globby/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
- package/compiled/globby/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
- package/compiled/globby/@nodelib/fs.walk/out/settings.d.ts +30 -0
- package/compiled/globby/@nodelib/fs.walk/out/types/index.d.ts +8 -0
- package/compiled/globby/fast-glob/index.d.ts +27 -0
- package/compiled/globby/fast-glob/managers/tasks.d.ts +22 -0
- package/compiled/globby/fast-glob/settings.d.ts +164 -0
- package/compiled/globby/fast-glob/types/index.d.ts +31 -0
- package/compiled/globby/index.d.ts +186 -0
- package/compiled/globby/index.js +1 -0
- package/compiled/globby/license +9 -0
- package/compiled/globby/package.json +1 -0
- package/compiled/inquirer/index.d.ts +997 -0
- package/compiled/inquirer/index.js +9 -0
- package/compiled/inquirer/lib/objects/choice.d.ts +65 -0
- package/compiled/inquirer/lib/objects/choices.d.ts +206 -0
- package/compiled/inquirer/lib/objects/separator.d.ts +37 -0
- package/compiled/inquirer/lib/ui/baseUI.d.ts +37 -0
- package/compiled/inquirer/lib/ui/bottom-bar.d.ts +65 -0
- package/compiled/inquirer/lib/ui/prompt.d.ts +104 -0
- package/compiled/inquirer/license +22 -0
- package/compiled/inquirer/package.json +1 -0
- package/compiled/inquirer/through/index.d.ts +25 -0
- package/compiled/json5/index.js +1 -0
- package/compiled/json5/lib/index.d.ts +4 -0
- package/compiled/json5/lib/parse.d.ts +15 -0
- package/compiled/json5/lib/stringify.d.ts +89 -0
- package/compiled/json5/package.json +1 -0
- package/compiled/mime-types/index.d.ts +14 -0
- package/compiled/mime-types/index.js +14 -0
- package/compiled/mime-types/license +23 -0
- package/compiled/mime-types/package.json +1 -0
- package/compiled/minimist/index.d.ts +95 -0
- package/compiled/minimist/index.js +1 -0
- package/compiled/minimist/license +18 -0
- package/compiled/minimist/package.json +1 -0
- package/compiled/ora/cli-spinners/index.d.ts +125 -0
- package/compiled/ora/index.d.ts +277 -0
- package/compiled/ora/index.js +3 -0
- package/compiled/ora/license +9 -0
- package/compiled/ora/package.json +1 -0
- package/compiled/slash/index.d.ts +25 -0
- package/compiled/slash/index.js +1 -0
- package/compiled/slash/license +9 -0
- package/compiled/slash/package.json +1 -0
- package/compiled/url-join/index.d.ts +17 -0
- package/compiled/url-join/index.js +1 -0
- package/compiled/url-join/license +21 -0
- package/compiled/url-join/package.json +1 -0
- package/dist/analyzeProject.d.ts +1 -0
- package/dist/analyzeProject.js +40 -0
- package/dist/compiled.d.ts +33 -17
- package/dist/compiled.js +57 -21
- package/dist/constants.d.ts +1 -1
- package/dist/constants.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/prettyInstructions.js +3 -3
- package/dist/{ssrHelpers.d.ts → ssr.d.ts} +3 -0
- package/dist/{ssrHelpers.js → ssr.js} +0 -0
- package/dist/storage.js +1 -1
- package/package.json +12 -30
- package/dist/getCacheIdentifier.d.ts +0 -7
- package/dist/getCacheIdentifier.js +0 -24
- package/dist/js/modern/monorepo.js +0 -83
- package/dist/js/node/monorepo.js +0 -116
- package/dist/js/treeshaking/monorepo.js +0 -96
- package/dist/pkgUp.d.ts +0 -2
- package/dist/pkgUp.js +0 -8
- package/dist/types/FileSizeReporter.d.ts +0 -16
- package/dist/types/alias.d.ts +0 -21
- package/dist/types/applyOptionsChain.d.ts +0 -6
- package/dist/types/clearConsole.d.ts +0 -1
- package/dist/types/compatRequire.d.ts +0 -8
- package/dist/types/compiled.d.ts +0 -17
- package/dist/types/constants.d.ts +0 -222
- package/dist/types/debug.d.ts +0 -6
- package/dist/types/emptyDir.d.ts +0 -1
- package/dist/types/ensureAbsolutePath.d.ts +0 -7
- package/dist/types/findExists.d.ts +0 -6
- package/dist/types/format.d.ts +0 -16
- package/dist/types/generateMetaTags.d.ts +0 -16
- package/dist/types/getBrowserslist.d.ts +0 -2
- package/dist/types/getCacheIdentifier.d.ts +0 -7
- package/dist/types/getEntryOptions.d.ts +0 -1
- package/dist/types/getPackageManager.d.ts +0 -1
- package/dist/types/getPort.d.ts +0 -7
- package/dist/types/getServerConfig.d.ts +0 -1
- package/dist/types/import.d.ts +0 -5
- package/dist/types/index.d.ts +0 -32
- package/dist/types/is/index.d.ts +0 -34
- package/dist/types/is/node-env.d.ts +0 -4
- package/dist/types/is/platform.d.ts +0 -2
- package/dist/types/is/type.d.ts +0 -8
- package/dist/types/logger.d.ts +0 -63
- package/dist/types/monorepo.d.ts +0 -11
- package/dist/types/nodeEnv.d.ts +0 -3
- package/dist/types/path.d.ts +0 -3
- package/dist/types/prettyInstructions.d.ts +0 -6
- package/dist/types/printBuildError.d.ts +0 -8
- package/dist/types/readTsConfig.d.ts +0 -2
- package/dist/types/removeSlash.d.ts +0 -3
- package/dist/types/runtimeExports.d.ts +0 -4
- package/dist/types/wait.d.ts +0 -2
- package/dist/types/watch.d.ts +0 -8
- package/modern.config.js +0 -6
- package/tests/.eslintrc.js +0 -6
- package/tests/__snapshots__/prettyInstructions.test.ts.snap +0 -19
- package/tests/applyOptionsChain.test.ts +0 -100
- package/tests/compatRequire.test.ts +0 -32
- package/tests/debug.test.ts +0 -25
- package/tests/ensureAbsolutePath.test.ts +0 -16
- package/tests/findExists.test.ts +0 -22
- package/tests/fixtures/browserlist/develop/package.json +0 -11
- package/tests/fixtures/browserlist/dotfile/.browserslistrc +0 -3
- package/tests/fixtures/browserlist/pkg/package.json +0 -7
- package/tests/fixtures/compat-require/cjs.js +0 -1
- package/tests/fixtures/compat-require/empty.js +0 -1
- package/tests/fixtures/compat-require/esm.js +0 -5
- package/tests/fixtures/compat-require/foo.js +0 -3
- package/tests/fixtures/file-exists/a.ejs +0 -0
- package/tests/fixtures/file-exists/a.js/.gitkeep +0 -0
- package/tests/fixtures/file-exists/a.mjs +0 -0
- package/tests/fixtures/file-exists/a.ts +0 -0
- package/tests/format.test.ts +0 -60
- package/tests/generateMetaTags.test.ts +0 -19
- package/tests/getBrowserslist.test.ts +0 -32
- package/tests/getCacheIdentifier.test.ts +0 -37
- package/tests/getEntryOptions.test.ts +0 -53
- package/tests/index.test.ts +0 -18
- package/tests/is.test.ts +0 -27
- package/tests/isPlatform.test.ts +0 -19
- package/tests/isType.test.ts +0 -85
- package/tests/logger.test.ts +0 -53
- package/tests/prettyInstructions.test.ts +0 -139
- package/tests/removeSlash.test.ts +0 -19
- package/tests/tsconfig.json +0 -11
- package/tests/wait.ts +0 -38
@@ -1,139 +0,0 @@
|
|
1
|
-
import { prettyInstructions } from '../src/prettyInstructions';
|
2
|
-
|
3
|
-
const mockNetworkInterfaces = {
|
4
|
-
lo0: [
|
5
|
-
{
|
6
|
-
address: '127.0.0.1',
|
7
|
-
netmask: '255.0.0.0',
|
8
|
-
family: 'IPv4',
|
9
|
-
mac: '00:00:00:00:00:00',
|
10
|
-
internal: true,
|
11
|
-
cidr: '127.0.0.1/8',
|
12
|
-
},
|
13
|
-
],
|
14
|
-
en5: [
|
15
|
-
{
|
16
|
-
address: 'fe80::aede:48ff:fe00:1122',
|
17
|
-
netmask: 'ffff:ffff:ffff:ffff::',
|
18
|
-
family: 'IPv6',
|
19
|
-
mac: 'ac:de:48:00:11:22',
|
20
|
-
internal: false,
|
21
|
-
cidr: 'fe80::aede:48ff:fe00:1122/64',
|
22
|
-
scopeid: 4,
|
23
|
-
},
|
24
|
-
],
|
25
|
-
en0: [
|
26
|
-
{
|
27
|
-
address: '11.11.111.11',
|
28
|
-
netmask: '255.255.252.0',
|
29
|
-
family: 'IPv4',
|
30
|
-
mac: '90:9c:4a:cf:11:d2',
|
31
|
-
internal: false,
|
32
|
-
cidr: '10.85.117.60/22',
|
33
|
-
},
|
34
|
-
],
|
35
|
-
utun2: [
|
36
|
-
{
|
37
|
-
address: '10.100.100.100',
|
38
|
-
netmask: '255.255.224.0',
|
39
|
-
family: 'IPv4',
|
40
|
-
mac: '00:00:00:00:00:00',
|
41
|
-
internal: false,
|
42
|
-
cidr: '10.255.182.172/19',
|
43
|
-
},
|
44
|
-
],
|
45
|
-
};
|
46
|
-
|
47
|
-
jest.mock('os', () => {
|
48
|
-
const originalModule = jest.requireActual('os');
|
49
|
-
return {
|
50
|
-
__esModule: true,
|
51
|
-
...originalModule,
|
52
|
-
default: {
|
53
|
-
networkInterfaces() {
|
54
|
-
return mockNetworkInterfaces;
|
55
|
-
},
|
56
|
-
},
|
57
|
-
};
|
58
|
-
});
|
59
|
-
|
60
|
-
jest.mock('../compiled/chalk', () => ({
|
61
|
-
__esModule: true,
|
62
|
-
default: {
|
63
|
-
bold: jest.fn(str => str),
|
64
|
-
green: jest.fn(str => str),
|
65
|
-
red: jest.fn(str => str),
|
66
|
-
yellow: jest.fn(str => str),
|
67
|
-
cyanBright: jest.fn(str => str),
|
68
|
-
},
|
69
|
-
}));
|
70
|
-
|
71
|
-
describe('prettyInstructions', () => {
|
72
|
-
test('basic usage', () => {
|
73
|
-
const mockAppContext = {
|
74
|
-
entrypoints: [
|
75
|
-
{
|
76
|
-
entryName: 'main',
|
77
|
-
entry: '/example/node_modules/.modern-js/main/index.js',
|
78
|
-
isAutoMount: true,
|
79
|
-
customBootstrap: false,
|
80
|
-
},
|
81
|
-
],
|
82
|
-
serverRoutes: [
|
83
|
-
{
|
84
|
-
urlPath: '/',
|
85
|
-
entryName: 'main',
|
86
|
-
entryPath: 'html/main/index.html',
|
87
|
-
isSPA: true,
|
88
|
-
isSSR: false,
|
89
|
-
enableModernMode: false,
|
90
|
-
},
|
91
|
-
{
|
92
|
-
urlPath: '/api',
|
93
|
-
isApi: true,
|
94
|
-
entryPath: '',
|
95
|
-
isSPA: false,
|
96
|
-
isSSR: false,
|
97
|
-
},
|
98
|
-
],
|
99
|
-
port: 8080,
|
100
|
-
existSrc: true,
|
101
|
-
};
|
102
|
-
const mockConfig = {
|
103
|
-
dev: {
|
104
|
-
https: true,
|
105
|
-
},
|
106
|
-
};
|
107
|
-
|
108
|
-
const message = prettyInstructions(mockAppContext, mockConfig);
|
109
|
-
|
110
|
-
expect(message).toMatchSnapshot();
|
111
|
-
});
|
112
|
-
|
113
|
-
test('The src directory does not exist', () => {
|
114
|
-
const mockAppContext = {
|
115
|
-
entrypoints: [],
|
116
|
-
serverRoutes: [
|
117
|
-
{
|
118
|
-
urlPath: '/api',
|
119
|
-
isApi: true,
|
120
|
-
entryPath: '',
|
121
|
-
isSPA: false,
|
122
|
-
isSSR: false,
|
123
|
-
},
|
124
|
-
],
|
125
|
-
port: 8080,
|
126
|
-
existSrc: false,
|
127
|
-
};
|
128
|
-
|
129
|
-
const mockConfig = {
|
130
|
-
dev: {
|
131
|
-
https: true,
|
132
|
-
},
|
133
|
-
};
|
134
|
-
|
135
|
-
const message = prettyInstructions(mockAppContext, mockConfig);
|
136
|
-
|
137
|
-
expect(message).toMatchSnapshot();
|
138
|
-
});
|
139
|
-
});
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import {
|
2
|
-
removeLeadingSlash,
|
3
|
-
removeSlash,
|
4
|
-
removeTailSlash,
|
5
|
-
} from '../src/removeSlash';
|
6
|
-
|
7
|
-
describe('remove slash', () => {
|
8
|
-
test(`should remove leading slash`, () => {
|
9
|
-
expect(removeLeadingSlash('///yuck/example//')).toEqual('yuck/example//');
|
10
|
-
});
|
11
|
-
|
12
|
-
test(`should remove tail slash`, () => {
|
13
|
-
expect(removeTailSlash('///yuck/example//')).toEqual('///yuck/example');
|
14
|
-
});
|
15
|
-
|
16
|
-
test(`should remove slash`, () => {
|
17
|
-
expect(removeSlash('///yuck/example//')).toEqual('yuck/example');
|
18
|
-
});
|
19
|
-
});
|
package/tests/tsconfig.json
DELETED
package/tests/wait.ts
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
import { wait } from '../src/wait';
|
2
|
-
|
3
|
-
jest.useRealTimers();
|
4
|
-
|
5
|
-
describe('wait', () => {
|
6
|
-
test('basic usage', async () => {
|
7
|
-
const fn1 = jest.fn();
|
8
|
-
const fn2 = jest.fn();
|
9
|
-
const fn3 = async () => {
|
10
|
-
fn1();
|
11
|
-
await wait();
|
12
|
-
fn2();
|
13
|
-
};
|
14
|
-
|
15
|
-
fn3();
|
16
|
-
expect(fn1).toBeCalled();
|
17
|
-
expect(fn2).not.toBeCalled();
|
18
|
-
await wait();
|
19
|
-
expect(fn2).toBeCalled();
|
20
|
-
});
|
21
|
-
|
22
|
-
test('delay', async () => {
|
23
|
-
const fn1 = jest.fn();
|
24
|
-
const fn2 = jest.fn();
|
25
|
-
const time = 100;
|
26
|
-
const fn3 = async () => {
|
27
|
-
fn1();
|
28
|
-
await wait(time);
|
29
|
-
fn2();
|
30
|
-
};
|
31
|
-
|
32
|
-
fn3();
|
33
|
-
expect(fn1).toBeCalled();
|
34
|
-
expect(fn2).not.toBeCalled();
|
35
|
-
await wait(time);
|
36
|
-
expect(fn2).toBeCalled();
|
37
|
-
});
|
38
|
-
});
|