@youcan/cli-kit 2.8.0 → 2.8.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/_virtual/_rolldown/runtime.js +13 -0
- package/dist/common/string.js +16 -12
- package/dist/index.js +20 -37
- package/dist/internal/node/constants.js +9 -11
- package/dist/internal/node/ui.js +57 -46
- package/dist/node/callback.js +61 -56
- package/dist/node/cli.js +70 -94
- package/dist/node/config.js +25 -23
- package/dist/node/context/helpers.js +12 -5
- package/dist/node/context/local.js +5 -5
- package/dist/node/crypto.js +23 -12
- package/dist/node/env.js +28 -33
- package/dist/node/filesystem.js +111 -105
- package/dist/node/form.js +23 -38
- package/dist/node/git.js +39 -43
- package/dist/node/github.js +12 -9
- package/dist/node/http.js +41 -47
- package/dist/node/path.js +18 -10
- package/dist/node/session.js +80 -99
- package/dist/node/system.js +87 -103
- package/dist/node/tasks.js +30 -35
- package/dist/node/worker.js +37 -53
- package/dist/services/cloudflared.js +159 -200
- package/dist/services/cloudflared.test.js +92 -110
- package/dist/services/index.js +6 -1
- package/dist/ui/components/DevOutput.js +52 -56
- package/dist/ui/components/Error.js +14 -15
- package/dist/ui/components/HotKeys.js +14 -20
- package/dist/ui/components/utils/symbols.js +6 -6
- package/dist/ui/index.js +12 -3
- package/package.json +5 -5
package/dist/node/http.js
CHANGED
|
@@ -1,57 +1,51 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import 'get-port';
|
|
16
|
-
import 'tcp-port-used';
|
|
17
|
-
import { get as get$1 } from './session.js';
|
|
18
|
-
import 'kleur';
|
|
19
|
-
import 'dayjs';
|
|
20
|
-
import '../ui/components/DevOutput.js';
|
|
21
|
-
import 'react';
|
|
22
|
-
import 'ink';
|
|
23
|
-
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { isJson } from "../common/string.js";
|
|
3
|
+
import { get as get$1 } from "./env.js";
|
|
4
|
+
import { get as get$2 } from "./session.js";
|
|
5
|
+
import "../index.js";
|
|
6
|
+
import process from "node:process";
|
|
7
|
+
import https from "node:https";
|
|
8
|
+
import fetch from "node-fetch";
|
|
9
|
+
import { is, mergeDeepLeft } from "ramda";
|
|
10
|
+
//#region lib/node/http.ts
|
|
11
|
+
var http_exports = /* @__PURE__ */ __exportAll({
|
|
12
|
+
get: () => get,
|
|
13
|
+
post: () => post
|
|
14
|
+
});
|
|
24
15
|
async function agent() {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
if (get$1("HOST_ENV") === "dev") process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0";
|
|
17
|
+
return new https.Agent({
|
|
18
|
+
keepAlive: true,
|
|
19
|
+
keepAliveMsecs: 300 * 1e3
|
|
20
|
+
});
|
|
29
21
|
}
|
|
30
22
|
async function defaults() {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
23
|
+
const session = await get$2();
|
|
24
|
+
return {
|
|
25
|
+
agent: await agent(),
|
|
26
|
+
headers: {
|
|
27
|
+
Accept: "application/json",
|
|
28
|
+
Authorization: session ? `Bearer ${session.access_token}` : void 0
|
|
29
|
+
}
|
|
30
|
+
};
|
|
39
31
|
}
|
|
40
32
|
async function request(endpoint, options = {}) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (!response.ok) {
|
|
46
|
-
throw new Error(await response.text(), { cause: response });
|
|
47
|
-
}
|
|
48
|
-
return response.json();
|
|
33
|
+
if (is(String)(options.body) && isJson(options.body)) options = mergeDeepLeft(options, { headers: { "Content-Type": "application/json" } });
|
|
34
|
+
const response = await fetch(endpoint, mergeDeepLeft(options, await defaults()));
|
|
35
|
+
if (!response.ok) throw new Error(await response.text(), { cause: response });
|
|
36
|
+
return response.json();
|
|
49
37
|
}
|
|
50
38
|
async function get(endpoint, options = {}) {
|
|
51
|
-
|
|
39
|
+
return request(`https://${endpoint}`, {
|
|
40
|
+
...options,
|
|
41
|
+
method: "GET"
|
|
42
|
+
});
|
|
52
43
|
}
|
|
53
44
|
async function post(endpoint, options = {}) {
|
|
54
|
-
|
|
45
|
+
return request(`https://${endpoint}`, {
|
|
46
|
+
...options,
|
|
47
|
+
method: "POST"
|
|
48
|
+
});
|
|
55
49
|
}
|
|
56
|
-
|
|
57
|
-
export { get, post };
|
|
50
|
+
//#endregion
|
|
51
|
+
export { get, http_exports, post };
|
package/dist/node/path.js
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
|
-
import
|
|
2
|
-
import process from
|
|
3
|
-
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
//#region lib/node/path.ts
|
|
5
|
+
var path_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
basename: () => basename,
|
|
7
|
+
cwd: () => cwd,
|
|
8
|
+
dirname: () => dirname,
|
|
9
|
+
join: () => join,
|
|
10
|
+
resolve: () => resolve
|
|
11
|
+
});
|
|
4
12
|
function resolve(...paths) {
|
|
5
|
-
|
|
13
|
+
return path.resolve(...paths);
|
|
6
14
|
}
|
|
7
15
|
function cwd() {
|
|
8
|
-
|
|
16
|
+
return path.normalize(process.env.INIT_CWD ? process.env.INIT_CWD : process.cwd());
|
|
9
17
|
}
|
|
10
18
|
function join(...paths) {
|
|
11
|
-
|
|
19
|
+
return path.join(...paths);
|
|
12
20
|
}
|
|
13
21
|
function dirname(filepath) {
|
|
14
|
-
|
|
22
|
+
return path.dirname(filepath);
|
|
15
23
|
}
|
|
16
24
|
function basename(filepath) {
|
|
17
|
-
|
|
25
|
+
return path.basename(filepath);
|
|
18
26
|
}
|
|
19
|
-
|
|
20
|
-
export { basename, cwd, dirname, join, resolve };
|
|
27
|
+
//#endregion
|
|
28
|
+
export { basename, cwd, dirname, join, path_exports, resolve };
|
package/dist/node/session.js
CHANGED
|
@@ -1,111 +1,92 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { listen } from
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
import 'react';
|
|
17
|
-
import 'ink';
|
|
18
|
-
|
|
19
|
-
const LS_PORT = 3000;
|
|
20
|
-
const LS_HOST = 'localhost';
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { listen } from "./callback.js";
|
|
3
|
+
import { manager } from "./config.js";
|
|
4
|
+
import { base64URLEncode, randomHex, sha256 } from "./crypto.js";
|
|
5
|
+
import { apiHostname, oauthClientId, sellerAreaHostname } from "./env.js";
|
|
6
|
+
import { getPortProcessName, isPortAvailable, killPortProcess, open } from "./system.js";
|
|
7
|
+
import { get as get$1, post } from "./http.js";
|
|
8
|
+
import "../index.js";
|
|
9
|
+
//#region lib/node/session.ts
|
|
10
|
+
var session_exports = /* @__PURE__ */ __exportAll({
|
|
11
|
+
authenticate: () => authenticate,
|
|
12
|
+
get: () => get
|
|
13
|
+
});
|
|
14
|
+
const LS_PORT = 3e3;
|
|
15
|
+
const LS_HOST = "localhost";
|
|
21
16
|
function generatePkcePair(length) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const data = encoder.encode(verifier);
|
|
25
|
-
const hash = sha256(data);
|
|
26
|
-
return [verifier, base64URLEncode(hash)];
|
|
17
|
+
const verifier = randomHex(length);
|
|
18
|
+
return [verifier, base64URLEncode(sha256(new TextEncoder().encode(verifier)))];
|
|
27
19
|
}
|
|
28
20
|
async function isSessionValid(session) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
21
|
+
try {
|
|
22
|
+
return (await get$1(`${apiHostname()}/me`, { headers: { Authorization: `Bearer ${session.access_token}` } })).status === 1;
|
|
23
|
+
} catch (err) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
36
26
|
}
|
|
37
27
|
async function exchange(code, verifier) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
return result.access_token;
|
|
28
|
+
const params = {
|
|
29
|
+
code,
|
|
30
|
+
client_id: oauthClientId(),
|
|
31
|
+
grant_type: "authorization_code",
|
|
32
|
+
redirect_uri: `http://${LS_HOST}:${LS_PORT}/`,
|
|
33
|
+
code_verifier: verifier
|
|
34
|
+
};
|
|
35
|
+
return (await post(`${apiHostname()}/oauth/token`, {
|
|
36
|
+
body: new URLSearchParams(Object.entries(params)),
|
|
37
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" }
|
|
38
|
+
})).access_token;
|
|
50
39
|
}
|
|
51
40
|
async function authorize(command, state = randomHex(30)) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return { code: result.code, verifier };
|
|
41
|
+
const AUTHORIZATION_URL = sellerAreaHostname();
|
|
42
|
+
if (!await isPortAvailable(LS_PORT)) {
|
|
43
|
+
command.output.warn(`Port ${LS_PORT} is unavailable, but it is required for authentication.`);
|
|
44
|
+
const { confirmed } = await command.prompt({
|
|
45
|
+
type: "confirm",
|
|
46
|
+
name: "confirmed",
|
|
47
|
+
initial: true,
|
|
48
|
+
message: `Would you like to terminate ${await getPortProcessName(LS_PORT)}?`
|
|
49
|
+
});
|
|
50
|
+
if (!confirmed) throw new Error("Exiting..");
|
|
51
|
+
await killPortProcess(LS_PORT);
|
|
52
|
+
}
|
|
53
|
+
const [verifier, challenge] = await generatePkcePair(64);
|
|
54
|
+
const params = {
|
|
55
|
+
state,
|
|
56
|
+
response_type: "code",
|
|
57
|
+
scope: "*",
|
|
58
|
+
client_id: oauthClientId(),
|
|
59
|
+
redirect_uri: `http://${LS_HOST}:${LS_PORT}/`,
|
|
60
|
+
code_challenge: challenge,
|
|
61
|
+
code_challenge_method: "S256"
|
|
62
|
+
};
|
|
63
|
+
await command.output.anykey("Press any key to open the login page on your browser");
|
|
64
|
+
const url = `http://${AUTHORIZATION_URL}/admin/oauth/authorize?${new URLSearchParams(params).toString()}`;
|
|
65
|
+
open(url);
|
|
66
|
+
const result = await listen(command, LS_HOST, LS_PORT, url);
|
|
67
|
+
if (result.state !== state) throw new Error("Authorization state mismatch..");
|
|
68
|
+
return {
|
|
69
|
+
code: result.code,
|
|
70
|
+
verifier
|
|
71
|
+
};
|
|
84
72
|
}
|
|
85
73
|
async function get() {
|
|
86
|
-
|
|
87
|
-
.get('store_session') ?? null;
|
|
74
|
+
return manager({ projectName: "youcan-cli" }).get("store_session") ?? null;
|
|
88
75
|
}
|
|
89
76
|
async function authenticate(command) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
id: store.id,
|
|
104
|
-
access_token: accessToken,
|
|
105
|
-
};
|
|
106
|
-
manager({ projectName: 'youcan-cli' })
|
|
107
|
-
.set('store_session', session);
|
|
108
|
-
return session;
|
|
77
|
+
const existingSession = manager({ projectName: "youcan-cli" }).get("store_session");
|
|
78
|
+
if (existingSession && await isSessionValid(existingSession)) return existingSession;
|
|
79
|
+
const { code, verifier } = await authorize(command);
|
|
80
|
+
const accessToken = await exchange(code, verifier);
|
|
81
|
+
const store = await get$1(`${apiHostname()}/me`, { headers: { Authorization: `Bearer ${accessToken}` } });
|
|
82
|
+
if (!store.is_dev) throw new Error("The CLI can only be used with dev stores, you create one through YouCan Partners.");
|
|
83
|
+
const session = {
|
|
84
|
+
slug: store.slug,
|
|
85
|
+
id: store.id,
|
|
86
|
+
access_token: accessToken
|
|
87
|
+
};
|
|
88
|
+
manager({ projectName: "youcan-cli" }).set("store_session", session);
|
|
89
|
+
return session;
|
|
109
90
|
}
|
|
110
|
-
|
|
111
|
-
export { authenticate, get };
|
|
91
|
+
//#endregion
|
|
92
|
+
export { authenticate, get, session_exports };
|
package/dist/node/system.js
CHANGED
|
@@ -1,121 +1,105 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import { execa } from "execa";
|
|
4
|
+
import findProcess from "find-process";
|
|
5
|
+
import getPort, { portNumbers } from "get-port";
|
|
6
|
+
import tpu from "tcp-port-used";
|
|
7
|
+
//#region lib/node/system.ts
|
|
8
|
+
var system_exports = /* @__PURE__ */ __exportAll({
|
|
9
|
+
exec: () => exec,
|
|
10
|
+
getPortOrNextOrRandom: () => getPortOrNextOrRandom,
|
|
11
|
+
getPortProcessName: () => getPortProcessName,
|
|
12
|
+
inferUserPackageManager: () => inferUserPackageManager,
|
|
13
|
+
isPortAvailable: () => isPortAvailable,
|
|
14
|
+
killPortProcess: () => killPortProcess,
|
|
15
|
+
open: () => open,
|
|
16
|
+
sleep: () => sleep
|
|
17
|
+
});
|
|
7
18
|
function buildExec(command, args, options) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
});
|
|
20
|
-
return commandProcess;
|
|
19
|
+
return execa(command, args, {
|
|
20
|
+
env: options?.env ?? process.env,
|
|
21
|
+
cwd: options?.cwd,
|
|
22
|
+
input: options?.input,
|
|
23
|
+
stdio: options?.stdio,
|
|
24
|
+
stdin: options?.stdin,
|
|
25
|
+
signal: options?.signal,
|
|
26
|
+
stdout: options?.stdout === "inherit" ? "inherit" : void 0,
|
|
27
|
+
stderr: options?.stderr === "inherit" ? "inherit" : void 0,
|
|
28
|
+
windowsHide: false
|
|
29
|
+
});
|
|
21
30
|
}
|
|
22
31
|
async function exec(command, args, options) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
commandProcess.kill('SIGTERM');
|
|
62
|
-
setTimeout(killProcess, 500);
|
|
63
|
-
}
|
|
64
|
-
catch (err) {
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
try {
|
|
69
|
-
await commandProcess;
|
|
70
|
-
}
|
|
71
|
-
catch (err) {
|
|
72
|
-
if (aborted) {
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (options?.errorHandler) {
|
|
76
|
-
await options?.errorHandler(err);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
throw err;
|
|
80
|
-
}
|
|
32
|
+
const commandProcess = buildExec(command, args, options);
|
|
33
|
+
if (options?.stderr && options.stderr !== "inherit") commandProcess.stderr?.pipe(options.stderr, { end: false });
|
|
34
|
+
if (options?.stdout && options.stdout !== "inherit") commandProcess.stdout?.pipe(options.stdout, { end: false });
|
|
35
|
+
let aborted = false;
|
|
36
|
+
process.once("SIGINT", () => {
|
|
37
|
+
if (commandProcess.pid) try {
|
|
38
|
+
commandProcess.kill("SIGTERM");
|
|
39
|
+
} catch (err) {}
|
|
40
|
+
});
|
|
41
|
+
process.once("SIGTERM", () => {
|
|
42
|
+
if (commandProcess.pid) try {
|
|
43
|
+
commandProcess.kill("SIGTERM");
|
|
44
|
+
} catch (err) {}
|
|
45
|
+
});
|
|
46
|
+
options?.signal?.addEventListener("abort", () => {
|
|
47
|
+
if (commandProcess.pid) {
|
|
48
|
+
aborted = true;
|
|
49
|
+
try {
|
|
50
|
+
const killProcess = () => {
|
|
51
|
+
try {
|
|
52
|
+
commandProcess.kill("SIGKILL");
|
|
53
|
+
} catch (err) {}
|
|
54
|
+
};
|
|
55
|
+
commandProcess.kill("SIGTERM");
|
|
56
|
+
setTimeout(killProcess, 500);
|
|
57
|
+
} catch (err) {}
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
try {
|
|
61
|
+
await commandProcess;
|
|
62
|
+
} catch (err) {
|
|
63
|
+
if (aborted) return;
|
|
64
|
+
if (options?.errorHandler) {
|
|
65
|
+
await options?.errorHandler(err);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
throw err;
|
|
69
|
+
}
|
|
81
70
|
}
|
|
82
71
|
async function isPortAvailable(port) {
|
|
83
|
-
|
|
72
|
+
return !await tpu.check(port);
|
|
84
73
|
}
|
|
85
74
|
async function getPortOrNextOrRandom(port) {
|
|
86
|
-
|
|
75
|
+
return await getPort({ port: portNumbers(port, port + 1e3) });
|
|
87
76
|
}
|
|
88
77
|
async function getPortProcessName(port) {
|
|
89
|
-
|
|
90
|
-
|
|
78
|
+
const info = await findProcess("port", port);
|
|
79
|
+
return info && info.length > 0 ? `(${info[0]?.name})` : "";
|
|
91
80
|
}
|
|
92
81
|
async function killPortProcess(port) {
|
|
93
|
-
|
|
94
|
-
|
|
82
|
+
const { killPortProcess: kill } = await import("kill-port-process");
|
|
83
|
+
await kill(port);
|
|
95
84
|
}
|
|
96
85
|
async function open(url) {
|
|
97
|
-
|
|
98
|
-
await _open.default(url);
|
|
86
|
+
await (await import("open")).default(url);
|
|
99
87
|
}
|
|
100
88
|
async function sleep(seconds) {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
89
|
+
return new Promise((resolve) => {
|
|
90
|
+
setTimeout(resolve, 1e3 * seconds);
|
|
91
|
+
});
|
|
104
92
|
}
|
|
105
93
|
function inferUserPackageManager() {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return packageManagersMap[key];
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
return defaultPackageManager;
|
|
94
|
+
const defaultPackageManager = "npm";
|
|
95
|
+
const packageManagersMap = {
|
|
96
|
+
"^npm/.*": "npm",
|
|
97
|
+
"^pnpm/.*": "pnpm",
|
|
98
|
+
"^yarn/.*": "yarn"
|
|
99
|
+
};
|
|
100
|
+
const packageManagerUserAgent = process.env.npm_config_user_agent;
|
|
101
|
+
for (const key in packageManagersMap) if (new RegExp(key).test(packageManagerUserAgent)) return packageManagersMap[key];
|
|
102
|
+
return defaultPackageManager;
|
|
119
103
|
}
|
|
120
|
-
|
|
121
|
-
export { exec, getPortOrNextOrRandom, getPortProcessName, inferUserPackageManager, isPortAvailable, killPortProcess, open, sleep };
|
|
104
|
+
//#endregion
|
|
105
|
+
export { exec, getPortOrNextOrRandom, getPortProcessName, inferUserPackageManager, isPortAvailable, killPortProcess, open, sleep, system_exports };
|
package/dist/node/tasks.js
CHANGED
|
@@ -1,39 +1,34 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Loader } from
|
|
3
|
-
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { Loader } from "../internal/node/ui.js";
|
|
3
|
+
import process, { exit } from "node:process";
|
|
4
|
+
//#region lib/node/tasks.ts
|
|
5
|
+
var tasks_exports = /* @__PURE__ */ __exportAll({ run: () => run });
|
|
4
6
|
async function runTask(task, ctx) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
return await task.task(ctx, task);
|
|
7
|
+
if (task.skip?.(ctx)) return;
|
|
8
|
+
return await task.task(ctx, task);
|
|
9
9
|
}
|
|
10
10
|
async function run(ctx, tasks) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
exit(1);
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
return ctx;
|
|
11
|
+
for await (const task of tasks) {
|
|
12
|
+
const runner = async () => {
|
|
13
|
+
const subtasks = await runTask(task, ctx);
|
|
14
|
+
if (Array.isArray(subtasks) && subtasks.length > 0 && subtasks.every((t) => "task" in t)) for await (const subtask of subtasks) await runTask(subtask, ctx);
|
|
15
|
+
};
|
|
16
|
+
if (task.loadable === false) {
|
|
17
|
+
process.stdout.write(`${task.title}\n`);
|
|
18
|
+
await runner();
|
|
19
|
+
return ctx;
|
|
20
|
+
}
|
|
21
|
+
await Loader.exec(task.title, async (loader) => {
|
|
22
|
+
try {
|
|
23
|
+
await runner();
|
|
24
|
+
loader.stop();
|
|
25
|
+
} catch (err) {
|
|
26
|
+
loader.error(String(err));
|
|
27
|
+
exit(1);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
return ctx;
|
|
37
32
|
}
|
|
38
|
-
|
|
39
|
-
export { run };
|
|
33
|
+
//#endregion
|
|
34
|
+
export { run, tasks_exports };
|