@modern-js/core 1.7.1 → 1.8.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/js/modern/config/types/electron.js +1 -0
  3. package/dist/js/modern/context.js +1 -1
  4. package/dist/js/modern/index.js +2 -1
  5. package/dist/js/modern/loadPlugins.js +9 -4
  6. package/dist/js/node/config/types/electron.js +5 -0
  7. package/dist/js/node/context.js +1 -1
  8. package/dist/js/node/index.js +2 -1
  9. package/dist/js/node/loadPlugins.js +9 -4
  10. package/dist/types/config/types/electron.d.ts +13 -0
  11. package/dist/types/config/types/index.d.ts +14 -1
  12. package/dist/types/index.d.ts +3 -0
  13. package/dist/types/loadPlugins.d.ts +3 -0
  14. package/dist/types/manager.d.ts +7 -6
  15. package/package.json +7 -6
  16. package/tests/.eslintrc.js +0 -6
  17. package/tests/btsm.test.ts +0 -20
  18. package/tests/config.test.ts +0 -146
  19. package/tests/context.test.ts +0 -85
  20. package/tests/fixtures/index-test/modern.server-runtime.config.js +0 -0
  21. package/tests/fixtures/index-test/package.json +0 -3
  22. package/tests/fixtures/load-plugin/not-found/package.json +0 -3
  23. package/tests/fixtures/load-plugin/not-found/test-plugin-a.js +0 -1
  24. package/tests/fixtures/load-plugin/user-plugins/package.json +0 -3
  25. package/tests/fixtures/load-plugin/user-plugins/test-plugin-a.js +0 -1
  26. package/tests/fixtures/load-plugin/user-plugins/test-plugin-b.js +0 -3
  27. package/tests/fixtures/load-plugin/user-plugins/test-plugin-c.js +0 -3
  28. package/tests/index.test.ts +0 -83
  29. package/tests/initWatcher.test.ts +0 -63
  30. package/tests/loadEnv.test.ts +0 -173
  31. package/tests/loadPlugin.test.ts +0 -116
  32. package/tests/mergeConfig.test.ts +0 -97
  33. package/tests/pluginAPI.test.ts +0 -19
  34. package/tests/repeatKeyWarning.test.ts +0 -68
  35. package/tests/schema.test.ts +0 -107
  36. package/tests/tsconfig.json +0 -11
  37. package/tests/utils.test.ts +0 -7
@@ -1,107 +0,0 @@
1
- import { patchSchema, traverseSchema } from '../src/config/schema';
2
-
3
- describe('patch schemas', () => {
4
- test('should add schema succcessfully', () => {
5
- const schema = patchSchema([
6
- {
7
- target: 'foo',
8
- schema: { type: 'string' },
9
- },
10
- {
11
- target: 'deploy.foo',
12
- schema: { type: 'number' },
13
- },
14
- ]);
15
-
16
- expect(schema.properties).toHaveProperty('foo');
17
-
18
- expect(schema.properties.deploy.properties).toHaveProperty('foo');
19
- });
20
-
21
- test('should throw error when node is undefined', () => {
22
- expect(() => {
23
- patchSchema([
24
- {
25
- target: 'deploy.a.foo',
26
- schema: { type: 'string' },
27
- },
28
- ]);
29
- }).toThrowError(/^add schema deploy\.a error$/);
30
- });
31
-
32
- test(`should throw error on empty target property`, () => {
33
- expect(() => {
34
- patchSchema([
35
- {
36
- target: '',
37
- schema: { type: 'object' },
38
- },
39
- ]);
40
- }).toThrowError('should return target property in plugin schema.');
41
- });
42
-
43
- test(`support schema array in one schema`, () => {
44
- const schema = patchSchema([
45
- [
46
- {
47
- target: 'foo',
48
- schema: { type: 'string' },
49
- },
50
- {
51
- target: 'tools.foo',
52
- schema: { type: 'number' },
53
- },
54
- ],
55
- {
56
- target: 'bar',
57
- schema: { type: 'string' },
58
- },
59
- ]);
60
-
61
- expect(schema.properties).toHaveProperty('foo');
62
- expect(schema.properties).toHaveProperty('bar');
63
- expect(schema.properties.tools.properties).toHaveProperty('foo');
64
- });
65
- });
66
-
67
- describe(`traverse schema`, () => {
68
- test(`should return all avaliable keys of current schema`, () => {
69
- const schema = {
70
- type: 'object',
71
- properties: {
72
- source: {
73
- type: 'object',
74
- properties: { alias: { type: ['object', 'function'] } },
75
- },
76
- a: {
77
- type: 'object',
78
- properties: {
79
- b: {
80
- type: 'object',
81
- properties: { c: { type: 'object' } },
82
- },
83
- d: { type: 'string' },
84
- },
85
- },
86
- runtime: {
87
- type: 'object',
88
- properties: {
89
- router: { type: ['object', 'boolean'] },
90
- state: { type: ['object', 'boolean'] },
91
- },
92
- },
93
- runtimeByEntries: { patternProperties: { '^$': { type: 'string' } } },
94
- dev: { type: ['function', 'string'] },
95
- },
96
- };
97
- expect(traverseSchema(schema as any)).toEqual([
98
- 'source.alias',
99
- 'a.b.c',
100
- 'a.d',
101
- 'runtime.router',
102
- 'runtime.state',
103
- 'runtimeByEntries',
104
- 'dev',
105
- ]);
106
- });
107
- });
@@ -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
- "esModuleInterop": true,
9
- "paths": {}
10
- }
11
- }
@@ -1,7 +0,0 @@
1
- import { program } from '../src/utils/commander';
2
-
3
- describe('utils', () => {
4
- it('default', () => {
5
- expect(program).toBeDefined();
6
- });
7
- });