@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.
Files changed (186) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/compiled/address/index.js +1 -0
  3. package/compiled/address/lib/address.d.ts +28 -0
  4. package/compiled/address/package.json +1 -0
  5. package/compiled/browserslist/index.js +1 -1
  6. package/compiled/dotenv/index.js +1 -0
  7. package/compiled/dotenv/license +23 -0
  8. package/compiled/dotenv/package.json +1 -0
  9. package/compiled/dotenv/types/index.d.ts +59 -0
  10. package/compiled/dotenv-expand/index.d.ts +15 -0
  11. package/compiled/dotenv-expand/index.js +1 -0
  12. package/compiled/dotenv-expand/license +24 -0
  13. package/compiled/dotenv-expand/package.json +1 -0
  14. package/compiled/fast-glob/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
  15. package/compiled/fast-glob/@nodelib/fs.scandir/out/index.d.ts +12 -0
  16. package/compiled/fast-glob/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
  17. package/compiled/fast-glob/@nodelib/fs.scandir/out/settings.d.ts +20 -0
  18. package/compiled/fast-glob/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
  19. package/compiled/fast-glob/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
  20. package/compiled/fast-glob/@nodelib/fs.stat/out/index.d.ts +12 -0
  21. package/compiled/fast-glob/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
  22. package/compiled/fast-glob/@nodelib/fs.stat/out/settings.d.ts +16 -0
  23. package/compiled/fast-glob/@nodelib/fs.stat/out/types/index.d.ts +4 -0
  24. package/compiled/fast-glob/@nodelib/fs.walk/out/index.d.ts +14 -0
  25. package/compiled/fast-glob/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
  26. package/compiled/fast-glob/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
  27. package/compiled/fast-glob/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
  28. package/compiled/fast-glob/@nodelib/fs.walk/out/settings.d.ts +30 -0
  29. package/compiled/fast-glob/@nodelib/fs.walk/out/types/index.d.ts +8 -0
  30. package/compiled/fast-glob/index.js +37 -0
  31. package/compiled/fast-glob/license +21 -0
  32. package/compiled/fast-glob/out/index.d.ts +27 -0
  33. package/compiled/fast-glob/out/managers/tasks.d.ts +22 -0
  34. package/compiled/fast-glob/out/settings.d.ts +164 -0
  35. package/compiled/fast-glob/out/types/index.d.ts +31 -0
  36. package/compiled/fast-glob/package.json +1 -0
  37. package/compiled/globby/@nodelib/fs.scandir/out/adapters/fs.d.ts +20 -0
  38. package/compiled/globby/@nodelib/fs.scandir/out/index.d.ts +12 -0
  39. package/compiled/globby/@nodelib/fs.scandir/out/providers/async.d.ts +7 -0
  40. package/compiled/globby/@nodelib/fs.scandir/out/settings.d.ts +20 -0
  41. package/compiled/globby/@nodelib/fs.scandir/out/types/index.d.ts +20 -0
  42. package/compiled/globby/@nodelib/fs.stat/out/adapters/fs.d.ts +13 -0
  43. package/compiled/globby/@nodelib/fs.stat/out/index.d.ts +12 -0
  44. package/compiled/globby/@nodelib/fs.stat/out/providers/async.d.ts +4 -0
  45. package/compiled/globby/@nodelib/fs.stat/out/settings.d.ts +16 -0
  46. package/compiled/globby/@nodelib/fs.stat/out/types/index.d.ts +4 -0
  47. package/compiled/globby/@nodelib/fs.walk/out/index.d.ts +14 -0
  48. package/compiled/globby/@nodelib/fs.walk/out/providers/async.d.ts +12 -0
  49. package/compiled/globby/@nodelib/fs.walk/out/readers/async.d.ts +30 -0
  50. package/compiled/globby/@nodelib/fs.walk/out/readers/reader.d.ts +6 -0
  51. package/compiled/globby/@nodelib/fs.walk/out/settings.d.ts +30 -0
  52. package/compiled/globby/@nodelib/fs.walk/out/types/index.d.ts +8 -0
  53. package/compiled/globby/fast-glob/index.d.ts +27 -0
  54. package/compiled/globby/fast-glob/managers/tasks.d.ts +22 -0
  55. package/compiled/globby/fast-glob/settings.d.ts +164 -0
  56. package/compiled/globby/fast-glob/types/index.d.ts +31 -0
  57. package/compiled/globby/index.d.ts +186 -0
  58. package/compiled/globby/index.js +1 -0
  59. package/compiled/globby/license +9 -0
  60. package/compiled/globby/package.json +1 -0
  61. package/compiled/inquirer/index.d.ts +997 -0
  62. package/compiled/inquirer/index.js +9 -0
  63. package/compiled/inquirer/lib/objects/choice.d.ts +65 -0
  64. package/compiled/inquirer/lib/objects/choices.d.ts +206 -0
  65. package/compiled/inquirer/lib/objects/separator.d.ts +37 -0
  66. package/compiled/inquirer/lib/ui/baseUI.d.ts +37 -0
  67. package/compiled/inquirer/lib/ui/bottom-bar.d.ts +65 -0
  68. package/compiled/inquirer/lib/ui/prompt.d.ts +104 -0
  69. package/compiled/inquirer/license +22 -0
  70. package/compiled/inquirer/package.json +1 -0
  71. package/compiled/inquirer/through/index.d.ts +25 -0
  72. package/compiled/json5/index.js +1 -0
  73. package/compiled/json5/lib/index.d.ts +4 -0
  74. package/compiled/json5/lib/parse.d.ts +15 -0
  75. package/compiled/json5/lib/stringify.d.ts +89 -0
  76. package/compiled/json5/package.json +1 -0
  77. package/compiled/mime-types/index.d.ts +14 -0
  78. package/compiled/mime-types/index.js +14 -0
  79. package/compiled/mime-types/license +23 -0
  80. package/compiled/mime-types/package.json +1 -0
  81. package/compiled/minimist/index.d.ts +95 -0
  82. package/compiled/minimist/index.js +1 -0
  83. package/compiled/minimist/license +18 -0
  84. package/compiled/minimist/package.json +1 -0
  85. package/compiled/ora/cli-spinners/index.d.ts +125 -0
  86. package/compiled/ora/index.d.ts +277 -0
  87. package/compiled/ora/index.js +3 -0
  88. package/compiled/ora/license +9 -0
  89. package/compiled/ora/package.json +1 -0
  90. package/compiled/slash/index.d.ts +25 -0
  91. package/compiled/slash/index.js +1 -0
  92. package/compiled/slash/license +9 -0
  93. package/compiled/slash/package.json +1 -0
  94. package/compiled/url-join/index.d.ts +17 -0
  95. package/compiled/url-join/index.js +1 -0
  96. package/compiled/url-join/license +21 -0
  97. package/compiled/url-join/package.json +1 -0
  98. package/dist/analyzeProject.d.ts +1 -0
  99. package/dist/analyzeProject.js +40 -0
  100. package/dist/compiled.d.ts +33 -17
  101. package/dist/compiled.js +57 -21
  102. package/dist/constants.d.ts +1 -1
  103. package/dist/constants.js +1 -1
  104. package/dist/index.d.ts +2 -2
  105. package/dist/index.js +2 -2
  106. package/dist/prettyInstructions.js +3 -3
  107. package/dist/{ssrHelpers.d.ts → ssr.d.ts} +3 -0
  108. package/dist/{ssrHelpers.js → ssr.js} +0 -0
  109. package/dist/storage.js +1 -1
  110. package/package.json +12 -30
  111. package/dist/getCacheIdentifier.d.ts +0 -7
  112. package/dist/getCacheIdentifier.js +0 -24
  113. package/dist/js/modern/monorepo.js +0 -83
  114. package/dist/js/node/monorepo.js +0 -116
  115. package/dist/js/treeshaking/monorepo.js +0 -96
  116. package/dist/pkgUp.d.ts +0 -2
  117. package/dist/pkgUp.js +0 -8
  118. package/dist/types/FileSizeReporter.d.ts +0 -16
  119. package/dist/types/alias.d.ts +0 -21
  120. package/dist/types/applyOptionsChain.d.ts +0 -6
  121. package/dist/types/clearConsole.d.ts +0 -1
  122. package/dist/types/compatRequire.d.ts +0 -8
  123. package/dist/types/compiled.d.ts +0 -17
  124. package/dist/types/constants.d.ts +0 -222
  125. package/dist/types/debug.d.ts +0 -6
  126. package/dist/types/emptyDir.d.ts +0 -1
  127. package/dist/types/ensureAbsolutePath.d.ts +0 -7
  128. package/dist/types/findExists.d.ts +0 -6
  129. package/dist/types/format.d.ts +0 -16
  130. package/dist/types/generateMetaTags.d.ts +0 -16
  131. package/dist/types/getBrowserslist.d.ts +0 -2
  132. package/dist/types/getCacheIdentifier.d.ts +0 -7
  133. package/dist/types/getEntryOptions.d.ts +0 -1
  134. package/dist/types/getPackageManager.d.ts +0 -1
  135. package/dist/types/getPort.d.ts +0 -7
  136. package/dist/types/getServerConfig.d.ts +0 -1
  137. package/dist/types/import.d.ts +0 -5
  138. package/dist/types/index.d.ts +0 -32
  139. package/dist/types/is/index.d.ts +0 -34
  140. package/dist/types/is/node-env.d.ts +0 -4
  141. package/dist/types/is/platform.d.ts +0 -2
  142. package/dist/types/is/type.d.ts +0 -8
  143. package/dist/types/logger.d.ts +0 -63
  144. package/dist/types/monorepo.d.ts +0 -11
  145. package/dist/types/nodeEnv.d.ts +0 -3
  146. package/dist/types/path.d.ts +0 -3
  147. package/dist/types/prettyInstructions.d.ts +0 -6
  148. package/dist/types/printBuildError.d.ts +0 -8
  149. package/dist/types/readTsConfig.d.ts +0 -2
  150. package/dist/types/removeSlash.d.ts +0 -3
  151. package/dist/types/runtimeExports.d.ts +0 -4
  152. package/dist/types/wait.d.ts +0 -2
  153. package/dist/types/watch.d.ts +0 -8
  154. package/modern.config.js +0 -6
  155. package/tests/.eslintrc.js +0 -6
  156. package/tests/__snapshots__/prettyInstructions.test.ts.snap +0 -19
  157. package/tests/applyOptionsChain.test.ts +0 -100
  158. package/tests/compatRequire.test.ts +0 -32
  159. package/tests/debug.test.ts +0 -25
  160. package/tests/ensureAbsolutePath.test.ts +0 -16
  161. package/tests/findExists.test.ts +0 -22
  162. package/tests/fixtures/browserlist/develop/package.json +0 -11
  163. package/tests/fixtures/browserlist/dotfile/.browserslistrc +0 -3
  164. package/tests/fixtures/browserlist/pkg/package.json +0 -7
  165. package/tests/fixtures/compat-require/cjs.js +0 -1
  166. package/tests/fixtures/compat-require/empty.js +0 -1
  167. package/tests/fixtures/compat-require/esm.js +0 -5
  168. package/tests/fixtures/compat-require/foo.js +0 -3
  169. package/tests/fixtures/file-exists/a.ejs +0 -0
  170. package/tests/fixtures/file-exists/a.js/.gitkeep +0 -0
  171. package/tests/fixtures/file-exists/a.mjs +0 -0
  172. package/tests/fixtures/file-exists/a.ts +0 -0
  173. package/tests/format.test.ts +0 -60
  174. package/tests/generateMetaTags.test.ts +0 -19
  175. package/tests/getBrowserslist.test.ts +0 -32
  176. package/tests/getCacheIdentifier.test.ts +0 -37
  177. package/tests/getEntryOptions.test.ts +0 -53
  178. package/tests/index.test.ts +0 -18
  179. package/tests/is.test.ts +0 -27
  180. package/tests/isPlatform.test.ts +0 -19
  181. package/tests/isType.test.ts +0 -85
  182. package/tests/logger.test.ts +0 -53
  183. package/tests/prettyInstructions.test.ts +0 -139
  184. package/tests/removeSlash.test.ts +0 -19
  185. package/tests/tsconfig.json +0 -11
  186. 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
- });
@@ -1,11 +0,0 @@
1
- {
2
- "extends": "@modern-js/tsconfig/base",
3
- "compilerOptions": {
4
- "declaration": false,
5
- "jsx": "preserve",
6
- "baseUrl": "./",
7
- "isolatedModules": true,
8
- "paths": {},
9
- "types": ["node", "jest"]
10
- }
11
- }
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
- });