@youcan/cli-kit 2.8.1 → 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 -44
- 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/crypto.js
CHANGED
|
@@ -1,28 +1,39 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import crypto from "node:crypto";
|
|
3
|
+
//#region lib/node/crypto.ts
|
|
4
|
+
var crypto_exports = /* @__PURE__ */ __exportAll({
|
|
5
|
+
base64URLEncode: () => base64URLEncode,
|
|
6
|
+
fileHash: () => fileHash,
|
|
7
|
+
hashString: () => hashString,
|
|
8
|
+
randomBytes: () => randomBytes,
|
|
9
|
+
randomHex: () => randomHex,
|
|
10
|
+
randomUUID: () => randomUUID,
|
|
11
|
+
sha1: () => sha1,
|
|
12
|
+
sha256: () => sha256
|
|
13
|
+
});
|
|
3
14
|
function randomHex(size) {
|
|
4
|
-
|
|
15
|
+
return crypto.randomBytes(size).toString("hex");
|
|
5
16
|
}
|
|
6
17
|
function base64URLEncode(str) {
|
|
7
|
-
|
|
18
|
+
return str.toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/[=]/g, "");
|
|
8
19
|
}
|
|
9
20
|
function sha256(str) {
|
|
10
|
-
|
|
21
|
+
return crypto.createHash("sha256").update(str).digest();
|
|
11
22
|
}
|
|
12
23
|
function sha1(str) {
|
|
13
|
-
|
|
24
|
+
return crypto.createHash("sha1").update(str).digest("hex");
|
|
14
25
|
}
|
|
15
26
|
function hashString(str) {
|
|
16
|
-
|
|
27
|
+
return crypto.createHash("sha1").update(str).digest("hex");
|
|
17
28
|
}
|
|
18
29
|
function fileHash(buff) {
|
|
19
|
-
|
|
30
|
+
return crypto.createHash("md5").update(buff).digest("hex");
|
|
20
31
|
}
|
|
21
32
|
function randomBytes(size) {
|
|
22
|
-
|
|
33
|
+
return crypto.randomBytes(size);
|
|
23
34
|
}
|
|
24
35
|
function randomUUID() {
|
|
25
|
-
|
|
36
|
+
return crypto.randomUUID();
|
|
26
37
|
}
|
|
27
|
-
|
|
28
|
-
export { base64URLEncode, fileHash, hashString, randomBytes, randomHex, randomUUID, sha1, sha256 };
|
|
38
|
+
//#endregion
|
|
39
|
+
export { base64URLEncode, crypto_exports, fileHash, hashString, randomBytes, randomHex, randomUUID, sha1, sha256 };
|
package/dist/node/env.js
CHANGED
|
@@ -1,41 +1,36 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ENV_VARS } from
|
|
3
|
-
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { ENV_VARS } from "../internal/node/constants.js";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
//#region lib/node/env.ts
|
|
5
|
+
var env_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
apiHostname: () => apiHostname,
|
|
7
|
+
get: () => get,
|
|
8
|
+
oauthClientId: () => oauthClientId,
|
|
9
|
+
sellerAreaHostname: () => sellerAreaHostname
|
|
10
|
+
});
|
|
4
11
|
function get(key) {
|
|
5
|
-
|
|
12
|
+
return process.env[ENV_VARS[key]];
|
|
6
13
|
}
|
|
7
14
|
function oauthClientId() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
case 'prod':
|
|
14
|
-
default:
|
|
15
|
-
return '398';
|
|
16
|
-
}
|
|
15
|
+
switch (get("HOST_ENV")) {
|
|
16
|
+
case "dev": return "1";
|
|
17
|
+
case "test": return "11";
|
|
18
|
+
default: return "398";
|
|
19
|
+
}
|
|
17
20
|
}
|
|
18
21
|
function sellerAreaHostname() {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
case 'prod':
|
|
25
|
-
default:
|
|
26
|
-
return 'seller-area.youcan.shop';
|
|
27
|
-
}
|
|
22
|
+
switch (get("HOST_ENV")) {
|
|
23
|
+
case "dev": return "seller-area.dotshop.com";
|
|
24
|
+
case "test": return "seller-area.testyoucan.shop";
|
|
25
|
+
default: return "seller-area.youcan.shop";
|
|
26
|
+
}
|
|
28
27
|
}
|
|
29
28
|
function apiHostname() {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
case 'prod':
|
|
36
|
-
default:
|
|
37
|
-
return 'api.youcan.shop';
|
|
38
|
-
}
|
|
29
|
+
switch (get("HOST_ENV")) {
|
|
30
|
+
case "dev": return "api.dotshop.com";
|
|
31
|
+
case "test": return "api.testyoucan.shop";
|
|
32
|
+
default: return "api.youcan.shop";
|
|
33
|
+
}
|
|
39
34
|
}
|
|
40
|
-
|
|
41
|
-
export { apiHostname, get, oauthClientId, sellerAreaHostname };
|
|
35
|
+
//#endregion
|
|
36
|
+
export { apiHostname, env_exports, get, oauthClientId, sellerAreaHostname };
|
package/dist/node/filesystem.js
CHANGED
|
@@ -1,138 +1,144 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { resolve } from "./path.js";
|
|
3
|
+
import "../index.js";
|
|
4
|
+
import { createReadStream, createWriteStream } from "node:fs";
|
|
5
|
+
import FilesystemPromises from "node:fs/promises";
|
|
6
|
+
import { pipeline } from "node:stream/promises";
|
|
7
|
+
import { createGunzip } from "node:zlib";
|
|
8
|
+
import archiver from "archiver";
|
|
9
|
+
import chokidar from "chokidar";
|
|
10
|
+
import FsExtra from "fs-extra";
|
|
11
|
+
import { glob as glob$1 } from "glob";
|
|
12
|
+
import * as tar from "tar";
|
|
13
|
+
import { temporaryDirectoryTask } from "tempy";
|
|
14
|
+
//#region lib/node/filesystem.ts
|
|
15
|
+
var filesystem_exports = /* @__PURE__ */ __exportAll({
|
|
16
|
+
archived: () => archived,
|
|
17
|
+
chmod: () => chmod,
|
|
18
|
+
decompressGzip: () => decompressGzip,
|
|
19
|
+
exists: () => exists,
|
|
20
|
+
extractTar: () => extractTar,
|
|
21
|
+
glob: () => glob,
|
|
22
|
+
isDirectory: () => isDirectory,
|
|
23
|
+
isExecutable: () => isExecutable,
|
|
24
|
+
mkdir: () => mkdir,
|
|
25
|
+
move: () => move,
|
|
26
|
+
readFile: () => readFile,
|
|
27
|
+
readJsonFile: () => readJsonFile,
|
|
28
|
+
readdir: () => readdir,
|
|
29
|
+
rm: () => rm,
|
|
30
|
+
stat: () => stat,
|
|
31
|
+
tapIntoTmp: () => tapIntoTmp,
|
|
32
|
+
unlink: () => unlink,
|
|
33
|
+
watch: () => watch,
|
|
34
|
+
writeFile: () => writeFile,
|
|
35
|
+
writeJsonFile: () => writeJsonFile
|
|
36
|
+
});
|
|
31
37
|
async function exists(path) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
38
|
+
try {
|
|
39
|
+
await FilesystemPromises.access(path);
|
|
40
|
+
return true;
|
|
41
|
+
} catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
39
44
|
}
|
|
40
45
|
async function isExecutable(path) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
catch {
|
|
49
|
-
return false;
|
|
50
|
-
}
|
|
46
|
+
if (!await exists(path)) return false;
|
|
47
|
+
try {
|
|
48
|
+
await FilesystemPromises.access(path, FilesystemPromises.constants.X_OK);
|
|
49
|
+
return true;
|
|
50
|
+
} catch {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
51
53
|
}
|
|
52
54
|
async function isDirectory(path) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
return false;
|
|
59
|
-
}
|
|
55
|
+
try {
|
|
56
|
+
return (await FilesystemPromises.stat(path)).isDirectory();
|
|
57
|
+
} catch {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
60
|
}
|
|
61
61
|
async function tapIntoTmp(callback) {
|
|
62
|
-
|
|
62
|
+
return temporaryDirectoryTask(callback);
|
|
63
63
|
}
|
|
64
64
|
async function mkdir(path) {
|
|
65
|
-
|
|
65
|
+
await FilesystemPromises.mkdir(path, { recursive: true });
|
|
66
66
|
}
|
|
67
67
|
async function rm(path) {
|
|
68
|
-
|
|
68
|
+
await FilesystemPromises.rm(path, { recursive: true });
|
|
69
69
|
}
|
|
70
70
|
async function move(src, dest, options = {}) {
|
|
71
|
-
|
|
71
|
+
await FsExtra.move(src, dest, options);
|
|
72
72
|
}
|
|
73
|
-
async function readFile(path, options = {
|
|
74
|
-
|
|
73
|
+
async function readFile(path, options = {
|
|
74
|
+
encoding: "utf-8",
|
|
75
|
+
flag: "r"
|
|
76
|
+
}) {
|
|
77
|
+
return await FilesystemPromises.readFile(path, options);
|
|
75
78
|
}
|
|
76
|
-
async function writeFile(path, data, options = {
|
|
77
|
-
|
|
79
|
+
async function writeFile(path, data, options = {
|
|
80
|
+
encoding: "utf-8",
|
|
81
|
+
flag: "w"
|
|
82
|
+
}) {
|
|
83
|
+
return await FilesystemPromises.writeFile(path, data, options);
|
|
78
84
|
}
|
|
79
85
|
async function readJsonFile(path) {
|
|
80
|
-
|
|
81
|
-
|
|
86
|
+
const content = await readFile(path, { encoding: "utf8" });
|
|
87
|
+
return JSON.parse(content);
|
|
82
88
|
}
|
|
83
89
|
async function writeJsonFile(path, data) {
|
|
84
|
-
|
|
90
|
+
return writeFile(path, JSON.stringify(data, null, 4));
|
|
85
91
|
}
|
|
86
92
|
async function glob(pattern, options) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
93
|
+
let _options = options;
|
|
94
|
+
if (options?.dot == null) _options = {
|
|
95
|
+
...options,
|
|
96
|
+
dot: true
|
|
97
|
+
};
|
|
98
|
+
return glob$1.glob(pattern, _options || {});
|
|
99
|
+
}
|
|
100
|
+
async function archived(path, name, glob = "**/*") {
|
|
101
|
+
return new Promise((resolve$1, reject) => {
|
|
102
|
+
try {
|
|
103
|
+
const archivePath = resolve(path, `${name}.zip`);
|
|
104
|
+
const output = createWriteStream(archivePath);
|
|
105
|
+
const _archiver = archiver("zip", { zlib: { level: 9 } });
|
|
106
|
+
output.on("close", () => resolve$1(archivePath));
|
|
107
|
+
_archiver.on("error", () => (err) => reject(err));
|
|
108
|
+
_archiver.pipe(output);
|
|
109
|
+
_archiver.glob(glob, {
|
|
110
|
+
ignore: [`${name}.zip`],
|
|
111
|
+
cwd: path
|
|
112
|
+
});
|
|
113
|
+
_archiver.finalize();
|
|
114
|
+
} catch (err) {
|
|
115
|
+
reject(err);
|
|
116
|
+
}
|
|
117
|
+
});
|
|
112
118
|
}
|
|
113
119
|
async function unlink(path) {
|
|
114
|
-
|
|
115
|
-
await FilesystemPromises.unlink(path);
|
|
116
|
-
}
|
|
120
|
+
if (await exists(path)) await FilesystemPromises.unlink(path);
|
|
117
121
|
}
|
|
118
122
|
async function readdir(path) {
|
|
119
|
-
|
|
123
|
+
return await FilesystemPromises.readdir(path);
|
|
120
124
|
}
|
|
121
125
|
async function stat(path) {
|
|
122
|
-
|
|
126
|
+
return await FilesystemPromises.stat(path);
|
|
123
127
|
}
|
|
124
128
|
async function chmod(path, mode) {
|
|
125
|
-
|
|
129
|
+
return await FilesystemPromises.chmod(path, mode);
|
|
126
130
|
}
|
|
127
131
|
const watch = chokidar.watch;
|
|
128
|
-
async function decompressGzip(file, destination, mode =
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
const writeStream = createWriteStream(destination, { mode });
|
|
132
|
-
await pipeline(readStream, unzip, writeStream);
|
|
132
|
+
async function decompressGzip(file, destination, mode = 493) {
|
|
133
|
+
const unzip = createGunzip();
|
|
134
|
+
await pipeline(createReadStream(file), unzip, createWriteStream(destination, { mode }));
|
|
133
135
|
}
|
|
134
136
|
async function extractTar(file, cwd, mode) {
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
137
|
+
await tar.extract({
|
|
138
|
+
cwd,
|
|
139
|
+
file,
|
|
140
|
+
mode
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
//#endregion
|
|
144
|
+
export { archived, chmod, decompressGzip, exists, extractTar, filesystem_exports, glob, isDirectory, isExecutable, mkdir, move, readFile, readJsonFile, readdir, rm, stat, tapIntoTmp, unlink, watch, writeFile, writeJsonFile };
|
package/dist/node/form.js
CHANGED
|
@@ -1,45 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { File, FormData } from "formdata-node";
|
|
3
|
+
import { fileFromPath } from "formdata-node/file-from-path";
|
|
4
|
+
//#region lib/node/form.ts
|
|
5
|
+
var form_exports = /* @__PURE__ */ __exportAll({
|
|
6
|
+
convert: () => convert,
|
|
7
|
+
file: () => file
|
|
8
|
+
});
|
|
4
9
|
const file = fileFromPath;
|
|
5
10
|
function convert(source, form = new FormData(), parentKey = null) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
append(form, toKey(parentKey, key), source[key]);
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
return form;
|
|
11
|
+
source = source || {};
|
|
12
|
+
for (const key in source) if (Object.prototype.hasOwnProperty.call(source, key)) append(form, toKey(parentKey, key), source[key]);
|
|
13
|
+
return form;
|
|
13
14
|
}
|
|
14
15
|
function append(form, key, value) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
else if (value instanceof Blob) {
|
|
25
|
-
return form.append(key, value);
|
|
26
|
-
}
|
|
27
|
-
else if (typeof value === 'boolean') {
|
|
28
|
-
return form.append(key, value ? '1' : '0');
|
|
29
|
-
}
|
|
30
|
-
else if (typeof value === 'string') {
|
|
31
|
-
return form.append(key, value);
|
|
32
|
-
}
|
|
33
|
-
else if (typeof value === 'number') {
|
|
34
|
-
return form.append(key, `${value}`);
|
|
35
|
-
}
|
|
36
|
-
else if (value === null || value === undefined) {
|
|
37
|
-
return form.append(key, '');
|
|
38
|
-
}
|
|
39
|
-
convert(value, form, key);
|
|
16
|
+
if (Array.isArray(value)) return Array.from(value.keys()).forEach((index) => append(form, toKey(key, index.toString()), value[index]));
|
|
17
|
+
else if (value instanceof Date) return form.append(key, value.toISOString());
|
|
18
|
+
else if (value instanceof File) return form.append(key, value, value.name);
|
|
19
|
+
else if (value instanceof Blob) return form.append(key, value);
|
|
20
|
+
else if (typeof value === "boolean") return form.append(key, value ? "1" : "0");
|
|
21
|
+
else if (typeof value === "string") return form.append(key, value);
|
|
22
|
+
else if (typeof value === "number") return form.append(key, `${value}`);
|
|
23
|
+
else if (value === null || value === void 0) return form.append(key, "");
|
|
24
|
+
convert(value, form, key);
|
|
40
25
|
}
|
|
41
26
|
function toKey(parent, key) {
|
|
42
|
-
|
|
27
|
+
return parent ? `${parent}[${key}]` : key;
|
|
43
28
|
}
|
|
44
|
-
|
|
45
|
-
export { convert, file };
|
|
29
|
+
//#endregion
|
|
30
|
+
export { convert, file, form_exports };
|
package/dist/node/git.js
CHANGED
|
@@ -1,52 +1,47 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
import { exec } from "./system.js";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
import git from "simple-git";
|
|
5
|
+
//#region lib/node/git.ts
|
|
6
|
+
var git_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
+
assertGitExists: () => assertGitExists,
|
|
8
|
+
binaryExists: () => binaryExists,
|
|
9
|
+
clone: () => clone
|
|
10
|
+
});
|
|
5
11
|
async function binaryExists() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
12
|
+
try {
|
|
13
|
+
await exec("git", ["--version"]);
|
|
14
|
+
return true;
|
|
15
|
+
} catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
13
18
|
}
|
|
14
19
|
async function assertGitExists() {
|
|
15
|
-
|
|
16
|
-
throw new Error('Git is required for the setup to continue.');
|
|
17
|
-
}
|
|
20
|
+
if (!await binaryExists()) throw new Error("Git is required for the setup to continue.");
|
|
18
21
|
}
|
|
19
22
|
async function clone(cloneOptions) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
.clone(repository, destination, options);
|
|
38
|
-
if (latestTag) {
|
|
39
|
-
const localRepo = git(destination);
|
|
40
|
-
const latestTag = await getLocalLatestTag(localRepo, url);
|
|
41
|
-
await localRepo.checkout(latestTag);
|
|
42
|
-
}
|
|
23
|
+
await assertGitExists();
|
|
24
|
+
const { url, destination, shallow, latestTag } = cloneOptions;
|
|
25
|
+
const [repository, branch] = url.split("#");
|
|
26
|
+
const options = { "--recurse-submodules": null };
|
|
27
|
+
if (branch) options["--branch"] = branch;
|
|
28
|
+
if (shallow && latestTag) throw new Error("Cannot get a shallow clone of the latest branch.");
|
|
29
|
+
if (shallow) options["--depth"] = 1;
|
|
30
|
+
const { GIT_ASKPASS, SSH_ASKPASS, ...env } = process.env;
|
|
31
|
+
await git({ config: [] }).env({
|
|
32
|
+
...env,
|
|
33
|
+
GIT_TERMINAL_PROMPT: "0"
|
|
34
|
+
}).clone(repository, destination, options);
|
|
35
|
+
if (latestTag) {
|
|
36
|
+
const localRepo = git(destination);
|
|
37
|
+
const latestTag = await getLocalLatestTag(localRepo, url);
|
|
38
|
+
await localRepo.checkout(latestTag);
|
|
39
|
+
}
|
|
43
40
|
}
|
|
44
41
|
async function getLocalLatestTag(repository, url) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
return latest;
|
|
42
|
+
const latest = (await repository.tags()).latest;
|
|
43
|
+
if (!latest) throw new Error(`Couldn't infer the latest tag from ${url}`);
|
|
44
|
+
return latest;
|
|
50
45
|
}
|
|
51
|
-
|
|
52
|
-
export { assertGitExists, binaryExists, clone };
|
|
46
|
+
//#endregion
|
|
47
|
+
export { assertGitExists, binaryExists, clone, git_exports };
|
package/dist/node/github.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
+
import { __exportAll } from "../_virtual/_rolldown/runtime.js";
|
|
2
|
+
//#region lib/node/github.ts
|
|
3
|
+
var github_exports = /* @__PURE__ */ __exportAll({ parseRepositoryReference: () => parseRepositoryReference });
|
|
1
4
|
function parseRepositoryReference(reference) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
const url = new URL(reference);
|
|
6
|
+
const [, user, repo, ...repoPath] = url.pathname.split("/");
|
|
7
|
+
return {
|
|
8
|
+
baseUrl: `${url.origin}/${user}/${repo}`,
|
|
9
|
+
branch: url.hash ? url.hash.slice(1) : void 0,
|
|
10
|
+
path: repoPath.length > 0 ? repoPath.join("/") : void 0
|
|
11
|
+
};
|
|
9
12
|
}
|
|
10
|
-
|
|
11
|
-
export { parseRepositoryReference };
|
|
13
|
+
//#endregion
|
|
14
|
+
export { github_exports, parseRepositoryReference };
|