@rife/cli 0.0.6-beta.1 → 0.0.6-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/dist/pnpmfile.js +11 -2
- package/dist/sync.js +1 -0
- package/dist/sync.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +9 -13
- package/src/cli.ts +19 -19
- package/src/index.ts +3 -3
- package/src/logger.ts +34 -34
- package/src/plugin/commander.ts +44 -44
- package/src/plugin/compiler/swc.ts +55 -55
- package/src/plugin/compiler/tsc.ts +101 -101
- package/src/plugin/release.ts +32 -32
- package/src/pnpmfile.ts +147 -121
- package/src/runner.ts +88 -88
- package/src/sync.ts +63 -62
- package/src/test/pnpmfile.test.ts +223 -223
- package/dist/compiler.js +0 -82
- package/dist/compiler.js.map +0 -1
- package/dist/plugin/package copy.js +0 -32
- package/dist/plugin/package copy.js.map +0 -1
- package/dist/plugin.js +0 -161
- package/dist/plugin.js.map +0 -1
- package/dist/swc.js +0 -78
- package/dist/swc.js.map +0 -1
- package/dist/tsc.js +0 -94
- package/dist/tsc.js.map +0 -1
package/src/runner.ts
CHANGED
|
@@ -1,88 +1,88 @@
|
|
|
1
|
-
import { AsyncSeriesHook } from 'tapable';
|
|
2
|
-
import zod from 'zod';
|
|
3
|
-
|
|
4
|
-
import { Logger, createLogger } from './logger';
|
|
5
|
-
|
|
6
|
-
export interface Config {
|
|
7
|
-
name: string;
|
|
8
|
-
plugins: Plugin[];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export interface Runner {
|
|
12
|
-
env: 'prod' | 'dev';
|
|
13
|
-
hook: {
|
|
14
|
-
loadPackage: AsyncSeriesHook<[]>;
|
|
15
|
-
loadConfig: AsyncSeriesHook<[]>;
|
|
16
|
-
validateConfig: AsyncSeriesHook<[]>;
|
|
17
|
-
applyConfig: AsyncSeriesHook<[any]>;
|
|
18
|
-
startCommand: AsyncSeriesHook<[]>;
|
|
19
|
-
finishCommand: AsyncSeriesHook<[]>;
|
|
20
|
-
dev: AsyncSeriesHook<[]>;
|
|
21
|
-
build: AsyncSeriesHook<[]>;
|
|
22
|
-
test: AsyncSeriesHook<[]>;
|
|
23
|
-
release: AsyncSeriesHook<[]>;
|
|
24
|
-
deploy: AsyncSeriesHook<[any]>;
|
|
25
|
-
lint: AsyncSeriesHook<[]>;
|
|
26
|
-
};
|
|
27
|
-
logger: Logger;
|
|
28
|
-
config: {
|
|
29
|
-
all: Config[];
|
|
30
|
-
current: Config;
|
|
31
|
-
};
|
|
32
|
-
package: any;
|
|
33
|
-
z: typeof zod;
|
|
34
|
-
fs: typeof import('fs-extra');
|
|
35
|
-
tapable: typeof import('tapable');
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface Plugin {
|
|
39
|
-
name: string;
|
|
40
|
-
apply: (runner: Runner) => any;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
if (typeof Promise.withResolvers === 'undefined') {
|
|
44
|
-
Promise.withResolvers = <T>() => {
|
|
45
|
-
let resolve: (value: T | PromiseLike<T>) => void;
|
|
46
|
-
let reject: (reason?: unknown) => void;
|
|
47
|
-
const promise = new Promise<T>((res, rej) => {
|
|
48
|
-
resolve = res;
|
|
49
|
-
reject = rej;
|
|
50
|
-
});
|
|
51
|
-
return { promise, resolve: resolve!, reject: reject! };
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export function createRunner() {
|
|
56
|
-
const runner: Runner = {
|
|
57
|
-
env: 'prod',
|
|
58
|
-
hook: {
|
|
59
|
-
loadPackage: new AsyncSeriesHook([]),
|
|
60
|
-
loadConfig: new AsyncSeriesHook([]),
|
|
61
|
-
validateConfig: new AsyncSeriesHook([]),
|
|
62
|
-
applyConfig: new AsyncSeriesHook(['options']),
|
|
63
|
-
startCommand: new AsyncSeriesHook([]),
|
|
64
|
-
finishCommand: new AsyncSeriesHook([]),
|
|
65
|
-
dev: new AsyncSeriesHook([]),
|
|
66
|
-
build: new AsyncSeriesHook([]),
|
|
67
|
-
test: new AsyncSeriesHook([]),
|
|
68
|
-
release: new AsyncSeriesHook([]),
|
|
69
|
-
deploy: new AsyncSeriesHook(['options']),
|
|
70
|
-
lint: new AsyncSeriesHook([]),
|
|
71
|
-
},
|
|
72
|
-
logger: createLogger(),
|
|
73
|
-
config: {
|
|
74
|
-
all: [],
|
|
75
|
-
// @ts-expect-error
|
|
76
|
-
current: undefined,
|
|
77
|
-
},
|
|
78
|
-
package: {},
|
|
79
|
-
z: zod,
|
|
80
|
-
fs: require('fs-extra') as typeof import('fs-extra'),
|
|
81
|
-
tapable: require('tapable') as typeof import('tapable'),
|
|
82
|
-
};
|
|
83
|
-
return runner;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
export function defineConfig(all: Config[]) {
|
|
87
|
-
return all;
|
|
88
|
-
}
|
|
1
|
+
import { AsyncSeriesHook } from 'tapable';
|
|
2
|
+
import zod from 'zod';
|
|
3
|
+
|
|
4
|
+
import { Logger, createLogger } from './logger';
|
|
5
|
+
|
|
6
|
+
export interface Config {
|
|
7
|
+
name: string;
|
|
8
|
+
plugins: Plugin[];
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface Runner {
|
|
12
|
+
env: 'prod' | 'dev';
|
|
13
|
+
hook: {
|
|
14
|
+
loadPackage: AsyncSeriesHook<[]>;
|
|
15
|
+
loadConfig: AsyncSeriesHook<[]>;
|
|
16
|
+
validateConfig: AsyncSeriesHook<[]>;
|
|
17
|
+
applyConfig: AsyncSeriesHook<[any]>;
|
|
18
|
+
startCommand: AsyncSeriesHook<[]>;
|
|
19
|
+
finishCommand: AsyncSeriesHook<[]>;
|
|
20
|
+
dev: AsyncSeriesHook<[]>;
|
|
21
|
+
build: AsyncSeriesHook<[]>;
|
|
22
|
+
test: AsyncSeriesHook<[]>;
|
|
23
|
+
release: AsyncSeriesHook<[]>;
|
|
24
|
+
deploy: AsyncSeriesHook<[any]>;
|
|
25
|
+
lint: AsyncSeriesHook<[]>;
|
|
26
|
+
};
|
|
27
|
+
logger: Logger;
|
|
28
|
+
config: {
|
|
29
|
+
all: Config[];
|
|
30
|
+
current: Config;
|
|
31
|
+
};
|
|
32
|
+
package: any;
|
|
33
|
+
z: typeof zod;
|
|
34
|
+
fs: typeof import('fs-extra');
|
|
35
|
+
tapable: typeof import('tapable');
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface Plugin {
|
|
39
|
+
name: string;
|
|
40
|
+
apply: (runner: Runner) => any;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (typeof Promise.withResolvers === 'undefined') {
|
|
44
|
+
Promise.withResolvers = <T>() => {
|
|
45
|
+
let resolve: (value: T | PromiseLike<T>) => void;
|
|
46
|
+
let reject: (reason?: unknown) => void;
|
|
47
|
+
const promise = new Promise<T>((res, rej) => {
|
|
48
|
+
resolve = res;
|
|
49
|
+
reject = rej;
|
|
50
|
+
});
|
|
51
|
+
return { promise, resolve: resolve!, reject: reject! };
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function createRunner() {
|
|
56
|
+
const runner: Runner = {
|
|
57
|
+
env: 'prod',
|
|
58
|
+
hook: {
|
|
59
|
+
loadPackage: new AsyncSeriesHook([]),
|
|
60
|
+
loadConfig: new AsyncSeriesHook([]),
|
|
61
|
+
validateConfig: new AsyncSeriesHook([]),
|
|
62
|
+
applyConfig: new AsyncSeriesHook(['options']),
|
|
63
|
+
startCommand: new AsyncSeriesHook([]),
|
|
64
|
+
finishCommand: new AsyncSeriesHook([]),
|
|
65
|
+
dev: new AsyncSeriesHook([]),
|
|
66
|
+
build: new AsyncSeriesHook([]),
|
|
67
|
+
test: new AsyncSeriesHook([]),
|
|
68
|
+
release: new AsyncSeriesHook([]),
|
|
69
|
+
deploy: new AsyncSeriesHook(['options']),
|
|
70
|
+
lint: new AsyncSeriesHook([]),
|
|
71
|
+
},
|
|
72
|
+
logger: createLogger(),
|
|
73
|
+
config: {
|
|
74
|
+
all: [],
|
|
75
|
+
// @ts-expect-error
|
|
76
|
+
current: undefined,
|
|
77
|
+
},
|
|
78
|
+
package: {},
|
|
79
|
+
z: zod,
|
|
80
|
+
fs: require('fs-extra') as typeof import('fs-extra'),
|
|
81
|
+
tapable: require('tapable') as typeof import('tapable'),
|
|
82
|
+
};
|
|
83
|
+
return runner;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function defineConfig(all: Config[]) {
|
|
87
|
+
return all;
|
|
88
|
+
}
|
package/src/sync.ts
CHANGED
|
@@ -1,62 +1,63 @@
|
|
|
1
|
-
async function sync(name: string) {
|
|
2
|
-
const res = await fetch(`https://registry-direct.npmmirror.com/-/package/${name}/syncs`, {
|
|
3
|
-
headers: {
|
|
4
|
-
accept: '*/*',
|
|
5
|
-
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
|
|
6
|
-
'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
|
|
7
|
-
'sec-ch-ua-mobile': '?0',
|
|
8
|
-
'sec-ch-ua-platform': '"Windows"',
|
|
9
|
-
'sec-fetch-dest': 'empty',
|
|
10
|
-
'sec-fetch-mode': 'cors',
|
|
11
|
-
'sec-fetch-site': 'same-site',
|
|
12
|
-
Referer: 'https://npmmirror.com/',
|
|
13
|
-
'Referrer-Policy': 'strict-origin-when-cross-origin',
|
|
14
|
-
},
|
|
15
|
-
body: null,
|
|
16
|
-
method: 'PUT',
|
|
17
|
-
});
|
|
18
|
-
const body = await res.json();
|
|
19
|
-
if (body.ok === true) {
|
|
20
|
-
console.log(`同步 ${name} 成功`);
|
|
21
|
-
}
|
|
22
|
-
return body;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const list = [
|
|
26
|
-
'@rife/config', //
|
|
27
|
-
|
|
28
|
-
'@rife/
|
|
29
|
-
|
|
30
|
-
// '@rife/
|
|
31
|
-
// '@rife/
|
|
32
|
-
// '@rife/
|
|
33
|
-
'@rife/
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
1
|
+
async function sync(name: string) {
|
|
2
|
+
const res = await fetch(`https://registry-direct.npmmirror.com/-/package/${name}/syncs`, {
|
|
3
|
+
headers: {
|
|
4
|
+
accept: '*/*',
|
|
5
|
+
'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8',
|
|
6
|
+
'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
|
|
7
|
+
'sec-ch-ua-mobile': '?0',
|
|
8
|
+
'sec-ch-ua-platform': '"Windows"',
|
|
9
|
+
'sec-fetch-dest': 'empty',
|
|
10
|
+
'sec-fetch-mode': 'cors',
|
|
11
|
+
'sec-fetch-site': 'same-site',
|
|
12
|
+
Referer: 'https://npmmirror.com/',
|
|
13
|
+
'Referrer-Policy': 'strict-origin-when-cross-origin',
|
|
14
|
+
},
|
|
15
|
+
body: null,
|
|
16
|
+
method: 'PUT',
|
|
17
|
+
});
|
|
18
|
+
const body = await res.json();
|
|
19
|
+
if (body.ok === true) {
|
|
20
|
+
console.log(`同步 ${name} 成功`);
|
|
21
|
+
}
|
|
22
|
+
return body;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const list = [
|
|
26
|
+
'@rife/config', //
|
|
27
|
+
'@rife/cli', //
|
|
28
|
+
// '@rife/infra',
|
|
29
|
+
'@rife/logger',
|
|
30
|
+
// '@rife/react',
|
|
31
|
+
// '@rife/next',
|
|
32
|
+
// '@rife/nest',
|
|
33
|
+
// '@rife/wxa',
|
|
34
|
+
'@rife/fast',
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
async function main() {
|
|
38
|
+
for (const item of list) {
|
|
39
|
+
// https://registry.npmmirror.com/-/package/@rife/infra/syncs/65a255a2afa293666acf6655/log
|
|
40
|
+
await sync(item);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
poll();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
main();
|
|
47
|
+
|
|
48
|
+
async function get(name: string) {
|
|
49
|
+
try {
|
|
50
|
+
const res = await fetch(`https://r.cnpmjs.org/${name}?t=${Date.now()}&cache=0`);
|
|
51
|
+
const data = await res.json();
|
|
52
|
+
return `${name} ${data?.['dist-tags']?.['latest']}`;
|
|
53
|
+
} catch (e) {
|
|
54
|
+
return `${name} error`;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async function poll() {
|
|
59
|
+
const res = await Promise.all(list.map(get));
|
|
60
|
+
console.log(`${res.join('\n')}\n`);
|
|
61
|
+
|
|
62
|
+
setTimeout(poll, 1000);
|
|
63
|
+
}
|