@rife/plugin-test 0.0.1-beta.1 → 0.0.1-beta.2
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/app.mjs +10 -0
- package/package.json +15 -12
- package/src/index.proof.ts +10 -10
- package/src/index.test.ts +7 -7
- package/src/index.ts +0 -73
- package/tsconfig.json +12 -12
- package/vitest.config.ts +18 -0
- package/src/test/resolve.test.ts +0 -104
package/app.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rife/plugin-test",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.2",
|
|
4
4
|
"description": "",
|
|
5
|
-
"
|
|
6
|
-
"author": "",
|
|
7
|
-
"license": "ISC",
|
|
5
|
+
"type": "module",
|
|
8
6
|
"dependencies": {
|
|
9
|
-
"typroof": "^0.
|
|
10
|
-
"vitest": "^
|
|
11
|
-
"@vitejs/plugin-react": "^
|
|
12
|
-
"@vitest/browser": "^
|
|
13
|
-
"
|
|
14
|
-
"vitest
|
|
7
|
+
"typroof": "^0.6.0",
|
|
8
|
+
"vitest": "^4.0.0",
|
|
9
|
+
"@vitejs/plugin-react": "^5.1.1",
|
|
10
|
+
"@vitest/browser": "^4.0.8",
|
|
11
|
+
"vitest-browser-react": "^2.0.2",
|
|
12
|
+
"@vitest/browser-playwright": "^4.0.8"
|
|
13
|
+
},
|
|
14
|
+
"devDependencies": {
|
|
15
|
+
"@rife/cli": "0.0.6-beta.16",
|
|
16
|
+
"@rife/config": "0.0.6-beta.10"
|
|
15
17
|
},
|
|
16
18
|
"rife": {
|
|
17
19
|
"hostDependencies": {
|
|
@@ -19,12 +21,13 @@
|
|
|
19
21
|
"vitest": true,
|
|
20
22
|
"@vitejs/plugin-react": true,
|
|
21
23
|
"@vitest/browser": true,
|
|
22
|
-
"
|
|
23
|
-
"vitest
|
|
24
|
+
"vitest-browser-react": true,
|
|
25
|
+
"@vitest/browser-playwright": true
|
|
24
26
|
}
|
|
25
27
|
},
|
|
26
28
|
"scripts": {
|
|
27
29
|
"test": "vitest",
|
|
30
|
+
"type": "typroof",
|
|
28
31
|
"release": "rife release"
|
|
29
32
|
}
|
|
30
33
|
}
|
package/src/index.proof.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { describe, equal, error, expect, extend, it, test } from 'typroof';
|
|
2
|
-
|
|
3
|
-
type A = { a: number };
|
|
4
|
-
type B = { a: number };
|
|
5
|
-
|
|
6
|
-
describe('
|
|
7
|
-
it('
|
|
8
|
-
expect<A>().to(equal<B>);
|
|
9
|
-
});
|
|
10
|
-
});
|
|
1
|
+
import { describe, equal, error, expect, extend, it, test } from 'typroof';
|
|
2
|
+
|
|
3
|
+
type A = { a: number };
|
|
4
|
+
type B = { a: number };
|
|
5
|
+
|
|
6
|
+
describe('type', () => {
|
|
7
|
+
it('A = B', () => {
|
|
8
|
+
expect<A>().to(equal<B>);
|
|
9
|
+
});
|
|
10
|
+
});
|
package/src/index.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { expect, test
|
|
2
|
-
|
|
3
|
-
describe('
|
|
4
|
-
test('
|
|
5
|
-
expect(1).toBe(1);
|
|
6
|
-
});
|
|
7
|
-
});
|
|
1
|
+
import { describe, expect, test } from 'vitest';
|
|
2
|
+
|
|
3
|
+
describe('demo', () => {
|
|
4
|
+
test('case', () => {
|
|
5
|
+
expect(1).toBe(1);
|
|
6
|
+
});
|
|
7
|
+
});
|
package/src/index.ts
CHANGED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
const isPlugin = name => {
|
|
2
|
-
return name.startsWith('@rife/');
|
|
3
|
-
};
|
|
4
|
-
|
|
5
|
-
interface Resolved {
|
|
6
|
-
[key: string]: {
|
|
7
|
-
hostDependencies: {
|
|
8
|
-
[key: string]: {
|
|
9
|
-
version: string;
|
|
10
|
-
isDev?: boolean;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function resolveHost() {
|
|
17
|
-
const resolved: Resolved = {};
|
|
18
|
-
const resolver = (pkg, context) => {
|
|
19
|
-
if (isPlugin(pkg.name)) {
|
|
20
|
-
const current = (resolved[pkg.name] = resolved[pkg.name] || {
|
|
21
|
-
hostDependencies: {},
|
|
22
|
-
});
|
|
23
|
-
Object.keys(pkg.rife?.hostDependencies || {}).forEach(name => {
|
|
24
|
-
const version = pkg.dependencies?.[name] || pkg.devDependencies?.[name];
|
|
25
|
-
const isDev = Boolean(pkg.devDependencies?.[name]);
|
|
26
|
-
if (version) {
|
|
27
|
-
current.hostDependencies[name] = { version, isDev };
|
|
28
|
-
} else {
|
|
29
|
-
context.log(`cannot find host dependency ${name}`);
|
|
30
|
-
process.exit(1);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const expand = (name: string) => {
|
|
36
|
-
const current = resolved[name];
|
|
37
|
-
if (!current) {
|
|
38
|
-
context.log(`${name} not found, required by ${pkg.name}`);
|
|
39
|
-
process.exit(1);
|
|
40
|
-
}
|
|
41
|
-
Object.entries(current.hostDependencies).forEach(([key, value]) => {
|
|
42
|
-
if (value.isDev) {
|
|
43
|
-
pkg.devDependencies = pkg.devDependencies || {};
|
|
44
|
-
pkg.devDependencies = {
|
|
45
|
-
[key]: value.version,
|
|
46
|
-
...pkg.devDependencies,
|
|
47
|
-
};
|
|
48
|
-
} else {
|
|
49
|
-
pkg.dependencies = pkg.dependencies || {};
|
|
50
|
-
pkg.dependencies = {
|
|
51
|
-
[key]: value.version,
|
|
52
|
-
...pkg.dependencies,
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
if (isPlugin(key)) {
|
|
56
|
-
expand(key);
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
Object.entries({ ...pkg.devDependencies, ...pkg.dependencies }).forEach(([name, version]) => {
|
|
62
|
-
if (!isPlugin(name)) return;
|
|
63
|
-
expand(name);
|
|
64
|
-
});
|
|
65
|
-
};
|
|
66
|
-
return resolver;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export function resolveHostList(list: any[]) {
|
|
70
|
-
const resolver = resolveHost();
|
|
71
|
-
list.map(t => resolver(t, { log: console.log }));
|
|
72
|
-
return list[list.length - 1];
|
|
73
|
-
}
|
package/tsconfig.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@rife/config/tsconfig.json", // 继承 packages 目录下通用配置
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "dist",
|
|
5
|
-
"declaration": true,
|
|
6
|
-
"baseUrl": ".",
|
|
7
|
-
"paths": {
|
|
8
|
-
"@/*": ["./src/*"]
|
|
9
|
-
}
|
|
10
|
-
},
|
|
11
|
-
"include": ["./src/**/*"]
|
|
12
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "@rife/config/tsconfig.json", // 继承 packages 目录下通用配置
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"outDir": "dist",
|
|
5
|
+
"declaration": true,
|
|
6
|
+
"baseUrl": ".",
|
|
7
|
+
"paths": {
|
|
8
|
+
"@/*": ["./src/*"]
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
"include": ["./src/**/*"]
|
|
12
|
+
}
|
package/vitest.config.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { defineConfig } from 'vitest/config';
|
|
2
|
+
|
|
3
|
+
export default defineConfig({
|
|
4
|
+
test: {
|
|
5
|
+
environment: 'node', // 让 Vitest 运行在 Node.js 环境
|
|
6
|
+
server: {
|
|
7
|
+
deps: {
|
|
8
|
+
// https://github.com/fastify/fastify-autoload/issues/366
|
|
9
|
+
// inline: ['@fastify/autoload'],
|
|
10
|
+
inline: true,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
// include: [
|
|
14
|
+
// // './dist/**/*.test.js', //
|
|
15
|
+
// // './src/test/sign.test.ts',
|
|
16
|
+
// ],
|
|
17
|
+
},
|
|
18
|
+
});
|
package/src/test/resolve.test.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { expect, test, describe } from 'vitest';
|
|
2
|
-
import { resolveHostList } from '../index';
|
|
3
|
-
|
|
4
|
-
describe('依赖提升1层', () => {
|
|
5
|
-
test('举例', () => {
|
|
6
|
-
const a = {
|
|
7
|
-
name: '@rife/a',
|
|
8
|
-
dependencies: {
|
|
9
|
-
a1: '^1.0.0',
|
|
10
|
-
},
|
|
11
|
-
devDependencies: {
|
|
12
|
-
a2: '^1.0.0',
|
|
13
|
-
},
|
|
14
|
-
rife: {
|
|
15
|
-
hostDependencies: {
|
|
16
|
-
a1: true,
|
|
17
|
-
a2: true,
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
const b = {
|
|
22
|
-
name: '@rife/b',
|
|
23
|
-
dependencies: {
|
|
24
|
-
'@rife/a': 'workspace:*',
|
|
25
|
-
b: '^1.0.0',
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
const z = {
|
|
29
|
-
name: '@rife/b',
|
|
30
|
-
dependencies: {
|
|
31
|
-
'@rife/a': 'workspace:*',
|
|
32
|
-
a1: '^1.0.0',
|
|
33
|
-
b: '^1.0.0',
|
|
34
|
-
},
|
|
35
|
-
devDependencies: {
|
|
36
|
-
a2: '^1.0.0',
|
|
37
|
-
},
|
|
38
|
-
};
|
|
39
|
-
expect(resolveHostList([a, b])).toStrictEqual(z);
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe('依赖提升2层', () => {
|
|
44
|
-
test('举例', () => {
|
|
45
|
-
const a = {
|
|
46
|
-
name: '@rife/a',
|
|
47
|
-
dependencies: {
|
|
48
|
-
a1: '^1.0.0',
|
|
49
|
-
},
|
|
50
|
-
devDependencies: {
|
|
51
|
-
a2: '^1.0.0',
|
|
52
|
-
},
|
|
53
|
-
rife: {
|
|
54
|
-
hostDependencies: {
|
|
55
|
-
a1: true,
|
|
56
|
-
a2: true,
|
|
57
|
-
},
|
|
58
|
-
},
|
|
59
|
-
};
|
|
60
|
-
const b = {
|
|
61
|
-
name: '@rife/b',
|
|
62
|
-
dependencies: {
|
|
63
|
-
'@rife/a': 'workspace:*',
|
|
64
|
-
b1: '^1.0.0',
|
|
65
|
-
},
|
|
66
|
-
devDependencies: {
|
|
67
|
-
b2: '^1.0.0',
|
|
68
|
-
},
|
|
69
|
-
rife: {
|
|
70
|
-
hostDependencies: {
|
|
71
|
-
b1: true,
|
|
72
|
-
b2: true,
|
|
73
|
-
'@rife/a': true,
|
|
74
|
-
},
|
|
75
|
-
},
|
|
76
|
-
};
|
|
77
|
-
const c = {
|
|
78
|
-
name: '@rife/c',
|
|
79
|
-
dependencies: {
|
|
80
|
-
'@rife/b': 'workspace:*',
|
|
81
|
-
c1: '^1.0.0',
|
|
82
|
-
},
|
|
83
|
-
devDependencies: {
|
|
84
|
-
c2: '^1.0.0',
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
const z = {
|
|
88
|
-
name: '@rife/c',
|
|
89
|
-
dependencies: {
|
|
90
|
-
'@rife/b': 'workspace:*',
|
|
91
|
-
'@rife/a': 'workspace:*',
|
|
92
|
-
a1: '^1.0.0',
|
|
93
|
-
b1: '^1.0.0',
|
|
94
|
-
c1: '^1.0.0',
|
|
95
|
-
},
|
|
96
|
-
devDependencies: {
|
|
97
|
-
a2: '^1.0.0',
|
|
98
|
-
b2: '^1.0.0',
|
|
99
|
-
c2: '^1.0.0',
|
|
100
|
-
},
|
|
101
|
-
};
|
|
102
|
-
expect(resolveHostList([a, b, c])).toStrictEqual(z);
|
|
103
|
-
});
|
|
104
|
-
});
|