@bmfk/api 0.0.0-stage → 1.0.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.
- package/CHANGELOG.md +83 -0
- package/LICENSE +21 -0
- package/README.md +1293 -2
- package/dist/apiServer/APIService.d.ts +125 -0
- package/dist/apiServer/APIService.js +769 -0
- package/dist/apiServer/BaseEndpoint.d.ts +90 -0
- package/dist/apiServer/BaseEndpoint.js +314 -0
- package/dist/apiServer/BaseService.d.ts +17 -0
- package/dist/apiServer/BaseService.js +39 -0
- package/dist/apiServer/DBService.d.ts +131 -0
- package/dist/apiServer/DBService.js +290 -0
- package/dist/apiServer/DocumentService.d.ts +9 -0
- package/dist/apiServer/DocumentService.js +65 -0
- package/dist/apiServer/LocalRequest.d.ts +3 -0
- package/dist/apiServer/LocalRequest.js +6 -0
- package/dist/apiServer/LogService.d.ts +78 -0
- package/dist/apiServer/LogService.js +349 -0
- package/dist/apiServer/MonitorService.d.ts +102 -0
- package/dist/apiServer/MonitorService.js +615 -0
- package/dist/apiServer/StatService.d.ts +4 -0
- package/dist/apiServer/StatService.js +10 -0
- package/dist/apiServer/TimeframeService.d.ts +28 -0
- package/dist/apiServer/TimeframeService.js +97 -0
- package/dist/apiServer/WebSocketServer.d.ts +39 -0
- package/dist/apiServer/WebSocketServer.js +173 -0
- package/dist/apiServer/db/IDBAdapter.d.ts +14 -0
- package/dist/apiServer/db/IDBAdapter.js +2 -0
- package/dist/apiServer/db/MysqlAdapter.d.ts +72 -0
- package/dist/apiServer/db/MysqlAdapter.js +869 -0
- package/dist/apiServer/db/PostgresAdapter.d.ts +41 -0
- package/dist/apiServer/db/PostgresAdapter.js +73 -0
- package/dist/apiServer/deployment/AccessConfigWizard.d.ts +5 -0
- package/dist/apiServer/deployment/AccessConfigWizard.js +254 -0
- package/dist/apiServer/deployment/Activate.d.ts +4 -0
- package/dist/apiServer/deployment/Activate.js +124 -0
- package/dist/apiServer/deployment/BackupManager.d.ts +33 -0
- package/dist/apiServer/deployment/BackupManager.js +174 -0
- package/dist/apiServer/deployment/Backups.d.ts +2 -0
- package/dist/apiServer/deployment/Backups.js +44 -0
- package/dist/apiServer/deployment/BlueGreenState.d.ts +31 -0
- package/dist/apiServer/deployment/BlueGreenState.js +150 -0
- package/dist/apiServer/deployment/Bundler.d.ts +12 -0
- package/dist/apiServer/deployment/Bundler.js +178 -0
- package/dist/apiServer/deployment/ConfigService.d.ts +203 -0
- package/dist/apiServer/deployment/ConfigService.js +195 -0
- package/dist/apiServer/deployment/Deploy.d.ts +4 -0
- package/dist/apiServer/deployment/Deploy.js +404 -0
- package/dist/apiServer/deployment/DeployKeyWizard.d.ts +2 -0
- package/dist/apiServer/deployment/DeployKeyWizard.js +84 -0
- package/dist/apiServer/deployment/Deployer.d.ts +13 -0
- package/dist/apiServer/deployment/Deployer.js +96 -0
- package/dist/apiServer/deployment/DeployerInit.d.ts +25 -0
- package/dist/apiServer/deployment/DeployerInit.js +214 -0
- package/dist/apiServer/deployment/DeployerService.d.ts +378 -0
- package/dist/apiServer/deployment/DeployerService.js +1553 -0
- package/dist/apiServer/deployment/HashPassword.d.ts +3 -0
- package/dist/apiServer/deployment/HashPassword.js +126 -0
- package/dist/apiServer/deployment/MigrateConfigsWizard.d.ts +1 -0
- package/dist/apiServer/deployment/MigrateConfigsWizard.js +202 -0
- package/dist/apiServer/deployment/MigrateProject.d.ts +31 -0
- package/dist/apiServer/deployment/MigrateProject.js +335 -0
- package/dist/apiServer/deployment/NginxHelper.d.ts +10 -0
- package/dist/apiServer/deployment/NginxHelper.js +111 -0
- package/dist/apiServer/deployment/Notifier.d.ts +30 -0
- package/dist/apiServer/deployment/Notifier.js +82 -0
- package/dist/apiServer/deployment/ProjectConfigWizard.d.ts +1 -0
- package/dist/apiServer/deployment/ProjectConfigWizard.js +148 -0
- package/dist/apiServer/deployment/Restore.d.ts +2 -0
- package/dist/apiServer/deployment/Restore.js +89 -0
- package/dist/apiServer/deployment/ReviewStore.d.ts +62 -0
- package/dist/apiServer/deployment/ReviewStore.js +186 -0
- package/dist/apiServer/deployment/SecretsInjector.d.ts +21 -0
- package/dist/apiServer/deployment/SecretsInjector.js +189 -0
- package/dist/apiServer/deployment/SetupConfigWizard.d.ts +1 -0
- package/dist/apiServer/deployment/SetupConfigWizard.js +238 -0
- package/dist/apiServer/deployment/Status.d.ts +2 -0
- package/dist/apiServer/deployment/Status.js +83 -0
- package/dist/apiServer/deployment/TelegramNotifier.d.ts +8 -0
- package/dist/apiServer/deployment/TelegramNotifier.js +23 -0
- package/dist/apiServer/deployment/Watchdog.d.ts +15 -0
- package/dist/apiServer/deployment/Watchdog.js +65 -0
- package/dist/apiServer/deployment/Wizards.d.ts +1 -0
- package/dist/apiServer/deployment/Wizards.js +83 -0
- package/dist/apiServer/deployment/cli.d.ts +2 -0
- package/dist/apiServer/deployment/cli.js +224 -0
- package/dist/apiServer/deployment/cliCommon.d.ts +27 -0
- package/dist/apiServer/deployment/cliCommon.js +110 -0
- package/dist/apiServer/deployment/cliPrompt.d.ts +5 -0
- package/dist/apiServer/deployment/cliPrompt.js +38 -0
- package/dist/apiServer/deployment/resolveConfig.d.ts +19 -0
- package/dist/apiServer/deployment/resolveConfig.js +139 -0
- package/dist/apiServer/documentation/Documentation.d.ts +18 -0
- package/dist/apiServer/documentation/Documentation.js +143 -0
- package/dist/apiServer/documentation/index.html +460 -0
- package/dist/apiServer/external/MicroserviceClient.d.ts +28 -0
- package/dist/apiServer/external/MicroserviceClient.js +144 -0
- package/dist/apiServer/external/MicroserviceHost.d.ts +52 -0
- package/dist/apiServer/external/MicroserviceHost.js +183 -0
- package/dist/apiServer/external/MicroserviceHostController.d.ts +6 -0
- package/dist/apiServer/external/MicroserviceHostController.js +65 -0
- package/dist/apiServer/helper/AppDataPath.d.ts +9 -0
- package/dist/apiServer/helper/AppDataPath.js +81 -0
- package/dist/apiServer/helper/ClientIp.d.ts +3 -0
- package/dist/apiServer/helper/ClientIp.js +33 -0
- package/dist/apiServer/helper/DataProvider.d.ts +18 -0
- package/dist/apiServer/helper/DataProvider.js +57 -0
- package/dist/apiServer/helper/IpAllowList.d.ts +8 -0
- package/dist/apiServer/helper/IpAllowList.js +40 -0
- package/dist/apiServer/helper/JSONStableStringify.d.ts +1 -0
- package/dist/apiServer/helper/JSONStableStringify.js +15 -0
- package/dist/apiServer/helper/PasswordHash.d.ts +5 -0
- package/dist/apiServer/helper/PasswordHash.js +52 -0
- package/dist/apiServer/helper/Sleep.d.ts +1 -0
- package/dist/apiServer/helper/Sleep.js +5 -0
- package/dist/apiServer/helper/Trace.d.ts +8 -0
- package/dist/apiServer/helper/Trace.js +30 -0
- package/dist/apiServer/helper/UID.d.ts +16 -0
- package/dist/apiServer/helper/UID.js +98 -0
- package/dist/apiServer/helper/Validator.d.ts +86 -0
- package/dist/apiServer/helper/Validator.js +560 -0
- package/dist/apiServer/helper/YYYYMMDDHH.d.ts +2 -0
- package/dist/apiServer/helper/YYYYMMDDHH.js +31 -0
- package/dist/apiServer/helper/ZipUtils.d.ts +6 -0
- package/dist/apiServer/helper/ZipUtils.js +28 -0
- package/dist/apiServer/http/Http.d.ts +183 -0
- package/dist/apiServer/http/Http.js +627 -0
- package/dist/apiServer/interceptors/InterceptorPayAuth.d.ts +19 -0
- package/dist/apiServer/interceptors/InterceptorPayAuth.js +124 -0
- package/dist/apiServer/interceptors/InterceptorSignedAuth.d.ts +40 -0
- package/dist/apiServer/interceptors/InterceptorSignedAuth.js +150 -0
- package/dist/apiServer/monitor/AccessStore.d.ts +27 -0
- package/dist/apiServer/monitor/AccessStore.js +163 -0
- package/dist/apiServer/monitor/LogFiles.d.ts +34 -0
- package/dist/apiServer/monitor/LogFiles.js +109 -0
- package/dist/apiServer/monitor/Monitor.d.ts +54 -0
- package/dist/apiServer/monitor/Monitor.js +447 -0
- package/dist/apiServer/monitor/MonitorAuth.d.ts +87 -0
- package/dist/apiServer/monitor/MonitorAuth.js +474 -0
- package/dist/apiServer/monitor/ProcessMonitor.d.ts +177 -0
- package/dist/apiServer/monitor/ProcessMonitor.js +468 -0
- package/dist/apiServer/monitor/SystemInfo.d.ts +70 -0
- package/dist/apiServer/monitor/SystemInfo.js +217 -0
- package/dist/apiServer/monitor/ThreatMonitor.d.ts +73 -0
- package/dist/apiServer/monitor/ThreatMonitor.js +239 -0
- package/dist/apiServer/monitor/index.html +591 -0
- package/dist/apiServer/review/Review.d.ts +23 -0
- package/dist/apiServer/review/Review.js +149 -0
- package/dist/apiServer/review/ReviewAuth.d.ts +56 -0
- package/dist/apiServer/review/ReviewAuth.js +147 -0
- package/dist/apiServer/review/ReviewDiff.d.ts +43 -0
- package/dist/apiServer/review/ReviewDiff.js +175 -0
- package/dist/apiServer/review/index.html +501 -0
- package/dist/apiServer/routes/Liveness.d.ts +7 -0
- package/dist/apiServer/routes/Liveness.js +27 -0
- package/dist/apiServer/routes/Readiness.d.ts +13 -0
- package/dist/apiServer/routes/Readiness.js +20 -0
- package/dist/apiServer/security/BlockedIps.d.ts +46 -0
- package/dist/apiServer/security/BlockedIps.js +185 -0
- package/dist/apiServer/structures/DefaultErrors.d.ts +36 -0
- package/dist/apiServer/structures/DefaultErrors.js +52 -0
- package/dist/apiServer/structures/HTTPStatus.d.ts +7 -0
- package/dist/apiServer/structures/HTTPStatus.js +11 -0
- package/dist/apiServer/structures/Interfaces.d.ts +55 -0
- package/dist/apiServer/structures/Interfaces.js +2 -0
- package/dist/index.d.ts +45 -0
- package/dist/index.js +110 -0
- package/dist/signal/Signal.d.ts +23 -0
- package/dist/signal/Signal.js +85 -0
- package/package.json +88 -4
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.BackupManager = exports.MAX_BACKUPS = exports.BACKUP_META = void 0;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const child_process_1 = require("child_process");
|
|
10
|
+
const util_1 = require("util");
|
|
11
|
+
const execFileAsync = (0, util_1.promisify)(child_process_1.execFile);
|
|
12
|
+
exports.BACKUP_META = ".bmfk-backup.json";
|
|
13
|
+
exports.MAX_BACKUPS = 10;
|
|
14
|
+
const NAME_RE = /^(\d{4}-\d{2}-\d{2}_\d{2}-\d{2}-\d{2})(?:_(\d+))?-([A-Za-z0-9._-]+)$/;
|
|
15
|
+
const PARTIAL_PREFIX = ".partial-";
|
|
16
|
+
class BackupManager {
|
|
17
|
+
static fileSafe(s) {
|
|
18
|
+
const v = String(s || "").replace(/[^A-Za-z0-9._-]+/g, "_").replace(/^_+|_+$/g, "");
|
|
19
|
+
return v.length > 0 ? v.slice(0, 80) : "project";
|
|
20
|
+
}
|
|
21
|
+
static stamp(d = new Date()) {
|
|
22
|
+
const p = (n) => String(n).padStart(2, "0");
|
|
23
|
+
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}_${p(d.getHours())}-${p(d.getMinutes())}-${p(d.getSeconds())}`;
|
|
24
|
+
}
|
|
25
|
+
static isValidName(name) {
|
|
26
|
+
return typeof name === "string" && NAME_RE.test(name);
|
|
27
|
+
}
|
|
28
|
+
static hasContent(dir) {
|
|
29
|
+
try {
|
|
30
|
+
return fs_1.default.readdirSync(dir).some(f => f !== "__tmp");
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
static readMeta(dir) {
|
|
37
|
+
try {
|
|
38
|
+
const m = JSON.parse(fs_1.default.readFileSync(path_1.default.join(dir, exports.BACKUP_META), "utf-8"));
|
|
39
|
+
return m && typeof m.project === "string" ? m : null;
|
|
40
|
+
}
|
|
41
|
+
catch {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
static readAppVersion(dir) {
|
|
46
|
+
try {
|
|
47
|
+
const v = JSON.parse(fs_1.default.readFileSync(path_1.default.join(dir, "package.json"), "utf-8"))?.version;
|
|
48
|
+
return typeof v === "string" ? v : null;
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static assertSafeRoot(root) {
|
|
55
|
+
const r = path_1.default.resolve(root);
|
|
56
|
+
if (r === path_1.default.parse(r).root || r.length < 5)
|
|
57
|
+
throw new Error(`refusing to keep backups in "${r}"`);
|
|
58
|
+
}
|
|
59
|
+
static async create(target, project, slot, user, reason) {
|
|
60
|
+
target = path_1.default.resolve(target);
|
|
61
|
+
if (!fs_1.default.existsSync(target) || !BackupManager.hasContent(target))
|
|
62
|
+
return null;
|
|
63
|
+
const root = path_1.default.dirname(target);
|
|
64
|
+
BackupManager.assertSafeRoot(root);
|
|
65
|
+
const label = BackupManager.fileSafe(slot ? `${project}-${slot}` : project);
|
|
66
|
+
const st = BackupManager.stamp();
|
|
67
|
+
let name = `${st}-${label}`;
|
|
68
|
+
for (let n = 2; fs_1.default.existsSync(path_1.default.join(root, name)); n++)
|
|
69
|
+
name = `${st}_${n}-${label}`;
|
|
70
|
+
const finalDir = path_1.default.join(root, name);
|
|
71
|
+
const partial = path_1.default.join(root, PARTIAL_PREFIX + name);
|
|
72
|
+
try {
|
|
73
|
+
await fs_1.default.promises.mkdir(partial, { recursive: true });
|
|
74
|
+
await execFileAsync("cp", ["-a", target + "/.", partial + "/"]);
|
|
75
|
+
await fs_1.default.promises.rm(path_1.default.join(partial, "__tmp"), { recursive: true, force: true });
|
|
76
|
+
const meta = {
|
|
77
|
+
version: 1, project, slot, createdAt: Date.now(), user, reason,
|
|
78
|
+
appVersion: BackupManager.readAppVersion(target),
|
|
79
|
+
};
|
|
80
|
+
await fs_1.default.promises.writeFile(path_1.default.join(partial, exports.BACKUP_META), JSON.stringify(meta, null, 2), "utf-8");
|
|
81
|
+
await fs_1.default.promises.rename(partial, finalDir);
|
|
82
|
+
}
|
|
83
|
+
catch (e) {
|
|
84
|
+
await fs_1.default.promises.rm(partial, { recursive: true, force: true }).catch(() => { });
|
|
85
|
+
throw e;
|
|
86
|
+
}
|
|
87
|
+
return name;
|
|
88
|
+
}
|
|
89
|
+
static async list(root, project, withSize = false) {
|
|
90
|
+
root = path_1.default.resolve(root);
|
|
91
|
+
if (!fs_1.default.existsSync(root))
|
|
92
|
+
return [];
|
|
93
|
+
const out = [];
|
|
94
|
+
for (const e of fs_1.default.readdirSync(root, { withFileTypes: true })) {
|
|
95
|
+
if (!e.isDirectory() || !NAME_RE.test(e.name))
|
|
96
|
+
continue;
|
|
97
|
+
const meta = BackupManager.readMeta(path_1.default.join(root, e.name));
|
|
98
|
+
if (!meta || meta.project !== project)
|
|
99
|
+
continue;
|
|
100
|
+
out.push({ ...meta, name: e.name, sizeKb: null });
|
|
101
|
+
}
|
|
102
|
+
out.sort((a, b) => b.createdAt - a.createdAt);
|
|
103
|
+
if (withSize && out.length > 0) {
|
|
104
|
+
try {
|
|
105
|
+
const { stdout } = await execFileAsync("du", ["-sk", ...out.map(b => path_1.default.join(root, b.name))], { timeout: 20000 });
|
|
106
|
+
for (const line of String(stdout).split("\n")) {
|
|
107
|
+
const m = line.match(/^(\d+)\s+(.+)$/);
|
|
108
|
+
if (!m)
|
|
109
|
+
continue;
|
|
110
|
+
const item = out.find(b => path_1.default.join(root, b.name) === m[2].trim());
|
|
111
|
+
if (item)
|
|
112
|
+
item.sizeKb = parseInt(m[1], 10);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
catch { }
|
|
116
|
+
}
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
static async prune(root, project, keep = exports.MAX_BACKUPS, protect = []) {
|
|
120
|
+
const all = await BackupManager.list(root, project);
|
|
121
|
+
const removed = [];
|
|
122
|
+
let kept = 0;
|
|
123
|
+
for (const b of all) {
|
|
124
|
+
if (kept < keep || protect.includes(b.name)) {
|
|
125
|
+
kept++;
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
await fs_1.default.promises.rm(path_1.default.join(path_1.default.resolve(root), b.name), { recursive: true, force: true });
|
|
129
|
+
removed.push(b.name);
|
|
130
|
+
}
|
|
131
|
+
return removed;
|
|
132
|
+
}
|
|
133
|
+
static resolve(root, project, name) {
|
|
134
|
+
if (!BackupManager.isValidName(name))
|
|
135
|
+
return null;
|
|
136
|
+
const r = path_1.default.resolve(root);
|
|
137
|
+
const dir = path_1.default.resolve(r, name);
|
|
138
|
+
if (path_1.default.dirname(dir) !== r)
|
|
139
|
+
return null;
|
|
140
|
+
const meta = BackupManager.readMeta(dir);
|
|
141
|
+
if (!meta || meta.project !== project)
|
|
142
|
+
return null;
|
|
143
|
+
return { dir, meta };
|
|
144
|
+
}
|
|
145
|
+
static async restoreInto(backupDir, target) {
|
|
146
|
+
target = path_1.default.resolve(target);
|
|
147
|
+
const staging = target + ".restore-tmp";
|
|
148
|
+
const old = target + ".restore-old";
|
|
149
|
+
await fs_1.default.promises.rm(staging, { recursive: true, force: true });
|
|
150
|
+
await fs_1.default.promises.rm(old, { recursive: true, force: true });
|
|
151
|
+
await fs_1.default.promises.mkdir(staging, { recursive: true });
|
|
152
|
+
try {
|
|
153
|
+
await execFileAsync("cp", ["-a", backupDir + "/.", staging + "/"]);
|
|
154
|
+
await fs_1.default.promises.rm(path_1.default.join(staging, exports.BACKUP_META), { force: true });
|
|
155
|
+
}
|
|
156
|
+
catch (e) {
|
|
157
|
+
await fs_1.default.promises.rm(staging, { recursive: true, force: true }).catch(() => { });
|
|
158
|
+
throw e;
|
|
159
|
+
}
|
|
160
|
+
const hadTarget = fs_1.default.existsSync(target);
|
|
161
|
+
if (hadTarget)
|
|
162
|
+
await fs_1.default.promises.rename(target, old);
|
|
163
|
+
try {
|
|
164
|
+
await fs_1.default.promises.rename(staging, target);
|
|
165
|
+
}
|
|
166
|
+
catch (e) {
|
|
167
|
+
if (hadTarget)
|
|
168
|
+
await fs_1.default.promises.rename(old, target).catch(() => { });
|
|
169
|
+
throw e;
|
|
170
|
+
}
|
|
171
|
+
await fs_1.default.promises.rm(old, { recursive: true, force: true }).catch(() => { });
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
exports.BackupManager = BackupManager;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Backups = Backups;
|
|
4
|
+
const Http_1 = require("../http/Http");
|
|
5
|
+
const resolveConfig_1 = require("./resolveConfig");
|
|
6
|
+
const cliCommon_1 = require("./cliCommon");
|
|
7
|
+
async function Backups(opt) {
|
|
8
|
+
opt = await (0, resolveConfig_1.resolveConfig)(opt);
|
|
9
|
+
const { red, yellow, blue, green, dim, bold } = (0, cliCommon_1.palette)();
|
|
10
|
+
const url = (0, cliCommon_1.deployerUrl)(opt, "backups"), body = { name: opt.name };
|
|
11
|
+
const r = await Http_1.Http.post(url, body, {
|
|
12
|
+
headers: (0, cliCommon_1.deployerHeaders)(opt, url, body), timeoutMs: 30000, retry: { enabled: false },
|
|
13
|
+
});
|
|
14
|
+
const err = (0, cliCommon_1.responseError)(r);
|
|
15
|
+
if (err) {
|
|
16
|
+
console.error(red(bold("✗ Cannot list backups: ")) + err);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
const info = r.data?.data ?? {};
|
|
20
|
+
const list = info.backups ?? [];
|
|
21
|
+
const slotColor = (s) => s === "blue" ? blue(s) : s === "green" ? green(s) : dim("—");
|
|
22
|
+
const line = dim("─".repeat(72));
|
|
23
|
+
console.log("");
|
|
24
|
+
console.log(`${bold("●")} ${bold(info.project ?? opt.name)} ${dim("backups:")} ${list.length}/${info.keep ?? "?"}` +
|
|
25
|
+
(info.bluegreen ? ` ${dim("active:")} ${slotColor(info.activeSlot)}` : ""));
|
|
26
|
+
if (!info.backupEnabled)
|
|
27
|
+
console.log(yellow(" ⚠ backup is disabled for this project — new deploys are not backed up"));
|
|
28
|
+
console.log(line);
|
|
29
|
+
if (list.length === 0) {
|
|
30
|
+
console.log(dim(" no backups yet"));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
for (const b of list) {
|
|
34
|
+
const reason = b.reason === "pre-restore" ? yellow("pre-restore") : dim("deploy ");
|
|
35
|
+
console.log(` ${bold(b.name)}`);
|
|
36
|
+
console.log(` ${dim("ver")} ${String(b.appVersion ?? "?").padEnd(12)}` +
|
|
37
|
+
(info.bluegreen ? `${dim("slot")} ${slotColor(b.slot).padEnd(15)}` : "") +
|
|
38
|
+
`${reason} ${dim("by")} ${b.user} ${dim((0, cliCommon_1.fmtDate)(b.createdAt))} ${dim((0, cliCommon_1.fmtSize)(b.sizeKb))}`);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
console.log(line);
|
|
42
|
+
console.log("");
|
|
43
|
+
return list;
|
|
44
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Signal } from "../../signal/Signal";
|
|
2
|
+
export declare const BLUEGREEN_FILE = ".bluegreen.json";
|
|
3
|
+
export type TSlot = "blue" | "green";
|
|
4
|
+
export interface IBlueGreenState {
|
|
5
|
+
live: boolean | null;
|
|
6
|
+
bluegreen: boolean;
|
|
7
|
+
project: string | null;
|
|
8
|
+
slot: TSlot | null;
|
|
9
|
+
active: TSlot | null;
|
|
10
|
+
isActive: boolean | null;
|
|
11
|
+
lastDeployed: TSlot | null;
|
|
12
|
+
readyToSwitch: boolean | null;
|
|
13
|
+
checkedAt: number;
|
|
14
|
+
cached: boolean;
|
|
15
|
+
stale?: boolean;
|
|
16
|
+
error?: string;
|
|
17
|
+
}
|
|
18
|
+
export declare const S_BLUEGREEN_STATE_CHANGED: Signal<{
|
|
19
|
+
current: IBlueGreenState;
|
|
20
|
+
previous: IBlueGreenState | null;
|
|
21
|
+
}>;
|
|
22
|
+
export interface IBlueGreenStateOptions {
|
|
23
|
+
force?: boolean;
|
|
24
|
+
ttlMs?: number;
|
|
25
|
+
timeoutMs?: number;
|
|
26
|
+
}
|
|
27
|
+
export declare function onLiveChange(cb: (live: boolean, state: IBlueGreenState) => void): () => void;
|
|
28
|
+
export declare function getBlueGreenStateSync(): IBlueGreenState | null;
|
|
29
|
+
export declare function startBlueGreenWatcher(intervalMs?: number): void;
|
|
30
|
+
export declare function stopBlueGreenWatcher(): void;
|
|
31
|
+
export declare function getBlueGreenActiveState(opts?: IBlueGreenStateOptions): Promise<IBlueGreenState>;
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.S_BLUEGREEN_STATE_CHANGED = exports.BLUEGREEN_FILE = void 0;
|
|
7
|
+
exports.onLiveChange = onLiveChange;
|
|
8
|
+
exports.getBlueGreenStateSync = getBlueGreenStateSync;
|
|
9
|
+
exports.startBlueGreenWatcher = startBlueGreenWatcher;
|
|
10
|
+
exports.stopBlueGreenWatcher = stopBlueGreenWatcher;
|
|
11
|
+
exports.getBlueGreenActiveState = getBlueGreenActiveState;
|
|
12
|
+
const fs_1 = __importDefault(require("fs"));
|
|
13
|
+
const path_1 = __importDefault(require("path"));
|
|
14
|
+
const Signal_1 = require("../../signal/Signal");
|
|
15
|
+
exports.BLUEGREEN_FILE = ".bluegreen.json";
|
|
16
|
+
exports.S_BLUEGREEN_STATE_CHANGED = new Signal_1.Signal();
|
|
17
|
+
let cache = null;
|
|
18
|
+
let inflight = null;
|
|
19
|
+
let lastKnown = null;
|
|
20
|
+
let watchTimer = null;
|
|
21
|
+
function remember(fresh) {
|
|
22
|
+
const previous = lastKnown;
|
|
23
|
+
if (fresh.live === null && previous && previous.live !== null && fresh.bluegreen) {
|
|
24
|
+
lastKnown = { ...previous, checkedAt: fresh.checkedAt, stale: true, error: fresh.error };
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
lastKnown = { ...fresh, cached: false, stale: false };
|
|
28
|
+
if (!previous || previous.live !== lastKnown.live || previous.isActive !== lastKnown.isActive
|
|
29
|
+
|| previous.active !== lastKnown.active) {
|
|
30
|
+
try {
|
|
31
|
+
exports.S_BLUEGREEN_STATE_CHANGED.invoke({ current: lastKnown, previous });
|
|
32
|
+
}
|
|
33
|
+
catch { }
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
function onLiveChange(cb) {
|
|
37
|
+
let delivered = null;
|
|
38
|
+
const deliver = (s) => {
|
|
39
|
+
if (!s || s.live === null || s.live === delivered)
|
|
40
|
+
return;
|
|
41
|
+
delivered = s.live;
|
|
42
|
+
try {
|
|
43
|
+
cb(s.live, s);
|
|
44
|
+
}
|
|
45
|
+
catch { }
|
|
46
|
+
};
|
|
47
|
+
const id = exports.S_BLUEGREEN_STATE_CHANGED.subscribe(({ current }) => deliver(current));
|
|
48
|
+
deliver(lastKnown);
|
|
49
|
+
return () => { exports.S_BLUEGREEN_STATE_CHANGED.unsubscribe(id); };
|
|
50
|
+
}
|
|
51
|
+
function getBlueGreenStateSync() {
|
|
52
|
+
return lastKnown;
|
|
53
|
+
}
|
|
54
|
+
function startBlueGreenWatcher(intervalMs = 5000) {
|
|
55
|
+
if (watchTimer || intervalMs <= 0)
|
|
56
|
+
return;
|
|
57
|
+
const tick = async () => {
|
|
58
|
+
const s = await getBlueGreenActiveState({ force: true });
|
|
59
|
+
if (!s.bluegreen)
|
|
60
|
+
stopBlueGreenWatcher();
|
|
61
|
+
};
|
|
62
|
+
watchTimer = setInterval(() => { tick().catch(() => { }); }, intervalMs);
|
|
63
|
+
watchTimer.unref?.();
|
|
64
|
+
tick().catch(() => { });
|
|
65
|
+
}
|
|
66
|
+
function stopBlueGreenWatcher() {
|
|
67
|
+
if (watchTimer)
|
|
68
|
+
clearInterval(watchTimer);
|
|
69
|
+
watchTimer = null;
|
|
70
|
+
}
|
|
71
|
+
function findFile() {
|
|
72
|
+
const override = process.env.BLUEGREEN_FILE;
|
|
73
|
+
if (override)
|
|
74
|
+
return fs_1.default.existsSync(override) ? override : null;
|
|
75
|
+
const main = require.main?.filename ?? process.argv[1];
|
|
76
|
+
if (!main)
|
|
77
|
+
return null;
|
|
78
|
+
let dir = path_1.default.dirname(path_1.default.resolve(main));
|
|
79
|
+
for (let i = 0; i < 6; i++) {
|
|
80
|
+
const candidate = path_1.default.join(dir, exports.BLUEGREEN_FILE);
|
|
81
|
+
if (fs_1.default.existsSync(candidate))
|
|
82
|
+
return candidate;
|
|
83
|
+
const parent = path_1.default.dirname(dir);
|
|
84
|
+
if (parent === dir)
|
|
85
|
+
break;
|
|
86
|
+
dir = parent;
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
function readFile(file) {
|
|
91
|
+
try {
|
|
92
|
+
const j = JSON.parse(fs_1.default.readFileSync(file, "utf-8"));
|
|
93
|
+
if (j && typeof j.project === "string" && (j.slot === "blue" || j.slot === "green")
|
|
94
|
+
&& typeof j.statusUrl === "string" && typeof j.token === "string")
|
|
95
|
+
return j;
|
|
96
|
+
}
|
|
97
|
+
catch { }
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
async function query(timeoutMs) {
|
|
101
|
+
const base = {
|
|
102
|
+
live: true, bluegreen: false, project: null, slot: null, active: null, isActive: null,
|
|
103
|
+
lastDeployed: null, readyToSwitch: null, checkedAt: Date.now(), cached: false,
|
|
104
|
+
};
|
|
105
|
+
const file = findFile();
|
|
106
|
+
if (!file)
|
|
107
|
+
return base;
|
|
108
|
+
const cfg = readFile(file);
|
|
109
|
+
if (!cfg)
|
|
110
|
+
return { ...base, live: null, bluegreen: true, error: `${exports.BLUEGREEN_FILE} at ${file} is unreadable or malformed` };
|
|
111
|
+
const known = { ...base, live: null, bluegreen: true, project: cfg.project, slot: cfg.slot };
|
|
112
|
+
try {
|
|
113
|
+
const res = await fetch(cfg.statusUrl, {
|
|
114
|
+
method: "POST",
|
|
115
|
+
headers: { "content-type": "application/json" },
|
|
116
|
+
body: JSON.stringify({ name: cfg.project, token: cfg.token, slot: cfg.slot }),
|
|
117
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
118
|
+
});
|
|
119
|
+
const body = await res.json().catch(() => null);
|
|
120
|
+
const d = body?.data;
|
|
121
|
+
if (!res.ok || body?.error || !d) {
|
|
122
|
+
const reason = body?.error?.message ?? `HTTP ${res.status}`;
|
|
123
|
+
return { ...known, error: `deployer rejected the status query: ${reason}` };
|
|
124
|
+
}
|
|
125
|
+
const slotOrNull = (v) => (v === "blue" || v === "green" ? v : null);
|
|
126
|
+
const active = slotOrNull(d.active);
|
|
127
|
+
return {
|
|
128
|
+
...known,
|
|
129
|
+
live: active ? active === cfg.slot : null,
|
|
130
|
+
active,
|
|
131
|
+
lastDeployed: slotOrNull(d.lastDeployed),
|
|
132
|
+
readyToSwitch: typeof d.readyToSwitch === "boolean" ? d.readyToSwitch : null,
|
|
133
|
+
isActive: active ? active === cfg.slot : null,
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
catch (e) {
|
|
137
|
+
return { ...known, error: `deployer unreachable at ${cfg.statusUrl}: ${e?.message ?? e}` };
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
async function getBlueGreenActiveState(opts) {
|
|
141
|
+
const ttl = opts?.ttlMs ?? 10_000;
|
|
142
|
+
if (!opts?.force && cache && Date.now() - cache.at < ttl)
|
|
143
|
+
return { ...cache.value, cached: true };
|
|
144
|
+
if (inflight)
|
|
145
|
+
return inflight;
|
|
146
|
+
inflight = query(opts?.timeoutMs ?? 3000)
|
|
147
|
+
.then(value => { cache = { at: Date.now(), value }; remember(value); return value; })
|
|
148
|
+
.finally(() => { inflight = null; });
|
|
149
|
+
return inflight;
|
|
150
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface IBundleOptions {
|
|
2
|
+
entry?: string;
|
|
3
|
+
sourcemap?: boolean;
|
|
4
|
+
minify?: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface IBundleResult {
|
|
7
|
+
stageDir: string;
|
|
8
|
+
outFile: string;
|
|
9
|
+
modules: number;
|
|
10
|
+
warnings: string[];
|
|
11
|
+
}
|
|
12
|
+
export declare function Bundle(opt: boolean | IBundleOptions, pkg: any): Promise<IBundleResult>;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Bundle = Bundle;
|
|
7
|
+
const fs_1 = __importDefault(require("fs"));
|
|
8
|
+
const path_1 = __importDefault(require("path"));
|
|
9
|
+
const os_1 = __importDefault(require("os"));
|
|
10
|
+
const SRC_EXT = /\.(c|m)?(t|j)sx?$/;
|
|
11
|
+
async function Bundle(opt, pkg) {
|
|
12
|
+
const o = typeof opt === "object" && opt ? opt : {};
|
|
13
|
+
if (!fs_1.default.existsSync("bin"))
|
|
14
|
+
throw new Error("bundle: ./bin not found — bundle replaces the tsc output in ./bin, so the project must build there");
|
|
15
|
+
const main = typeof pkg.main === "string" && pkg.main.length > 0 ? norm(pkg.main) : null;
|
|
16
|
+
const entry = o.entry ? norm(o.entry) : guessEntry(main);
|
|
17
|
+
if (!entry)
|
|
18
|
+
throw new Error(`bundle: can't tell the entry file from package.json "main" (${main ?? "missing"}) — set "bundle": { "entry": "src/Main.ts" } in deploy.json`);
|
|
19
|
+
if (!fs_1.default.existsSync(entry))
|
|
20
|
+
throw new Error(`bundle: entry file not found: ${entry}`);
|
|
21
|
+
const outFile = main ?? "bin/" + entry.replace(/^src\//, "").replace(SRC_EXT, ".js");
|
|
22
|
+
if (!outFile.startsWith("bin/") || outFile.split("/").includes(".."))
|
|
23
|
+
throw new Error(`bundle: package.json "main" must point inside ./bin (it is "${main}") — that is the file pm2 starts`);
|
|
24
|
+
let esbuild;
|
|
25
|
+
let parse;
|
|
26
|
+
try {
|
|
27
|
+
esbuild = require("esbuild");
|
|
28
|
+
parse = require("@babel/parser").parse;
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
throw new Error("bundle: install the bundler in this project — npm i -D esbuild @babel/parser (" + (e?.message ?? e) + ")");
|
|
32
|
+
}
|
|
33
|
+
const result = await esbuild.build({
|
|
34
|
+
entryPoints: [entry],
|
|
35
|
+
outfile: path_1.default.resolve(outFile),
|
|
36
|
+
bundle: true,
|
|
37
|
+
platform: "node",
|
|
38
|
+
format: "cjs",
|
|
39
|
+
packages: "external",
|
|
40
|
+
keepNames: true,
|
|
41
|
+
minify: o.minify === true,
|
|
42
|
+
sourcemap: o.sourcemap !== false,
|
|
43
|
+
sourcesContent: false,
|
|
44
|
+
metafile: true,
|
|
45
|
+
write: false,
|
|
46
|
+
logLevel: "warning",
|
|
47
|
+
});
|
|
48
|
+
const inputs = Object.keys(result.metafile.inputs).map(norm).filter(f => !f.startsWith("node_modules/"));
|
|
49
|
+
const dropped = new Set();
|
|
50
|
+
for (const f of inputs) {
|
|
51
|
+
if (!f.startsWith("src/") || !SRC_EXT.test(f))
|
|
52
|
+
continue;
|
|
53
|
+
const base = "bin/" + f.slice(4).replace(SRC_EXT, "");
|
|
54
|
+
for (const ext of [".js", ".js.map", ".d.ts", ".d.ts.map"])
|
|
55
|
+
dropped.add(base + ext);
|
|
56
|
+
}
|
|
57
|
+
const stageDir = fs_1.default.mkdtempSync(path_1.default.join(os_1.default.tmpdir(), "bmfk-bundle-"));
|
|
58
|
+
try {
|
|
59
|
+
fs_1.default.cpSync("bin", path_1.default.join(stageDir, "bin"), {
|
|
60
|
+
recursive: true,
|
|
61
|
+
filter: src => !dropped.has(norm(path_1.default.relative(process.cwd(), src))),
|
|
62
|
+
});
|
|
63
|
+
for (const file of result.outputFiles) {
|
|
64
|
+
const target = path_1.default.join(stageDir, path_1.default.relative(process.cwd(), file.path));
|
|
65
|
+
fs_1.default.mkdirSync(path_1.default.dirname(target), { recursive: true });
|
|
66
|
+
fs_1.default.writeFileSync(target, file.contents);
|
|
67
|
+
}
|
|
68
|
+
const warnings = scanSources(inputs, entry, parse);
|
|
69
|
+
const leftovers = listFiles(path_1.default.join(stageDir, "bin"))
|
|
70
|
+
.map(f => "bin/" + norm(path_1.default.relative(path_1.default.join(stageDir, "bin"), f)))
|
|
71
|
+
.filter(f => f.endsWith(".js") && f !== outFile);
|
|
72
|
+
if (leftovers.length) {
|
|
73
|
+
const shown = leftovers.slice(0, 10).join(", ") + (leftovers.length > 10 ? `, … (${leftovers.length} in all)` : "");
|
|
74
|
+
warnings.push(`${leftovers.length} .js file(s) in ./bin are not in the bundle and ship as they are: ${shown} — `
|
|
75
|
+
+ `if one of them requires the project's own modules it will fail on the server (they exist only inside the bundle now)`);
|
|
76
|
+
}
|
|
77
|
+
return { stageDir, outFile, modules: inputs.length, warnings };
|
|
78
|
+
}
|
|
79
|
+
catch (e) {
|
|
80
|
+
fs_1.default.rmSync(stageDir, { recursive: true, force: true });
|
|
81
|
+
throw e;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function guessEntry(main) {
|
|
85
|
+
if (!main || !main.startsWith("bin/"))
|
|
86
|
+
return null;
|
|
87
|
+
const base = "src/" + main.slice(4).replace(/\.(c|m)?js$/, "");
|
|
88
|
+
for (const ext of [".ts", ".tsx", ".mts", ".js"])
|
|
89
|
+
if (fs_1.default.existsSync(base + ext))
|
|
90
|
+
return base + ext;
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
function scanSources(files, entry, parse) {
|
|
94
|
+
const warnings = [];
|
|
95
|
+
const entryBase = path_1.default.resolve(entry).replace(SRC_EXT, "");
|
|
96
|
+
for (const file of files) {
|
|
97
|
+
if (file === entry || !SRC_EXT.test(file) || file.endsWith(".d.ts"))
|
|
98
|
+
continue;
|
|
99
|
+
let ast;
|
|
100
|
+
try {
|
|
101
|
+
ast = parse(fs_1.default.readFileSync(file, "utf-8"), {
|
|
102
|
+
sourceType: "module",
|
|
103
|
+
plugins: ["typescript", "decorators-legacy", ...(file.endsWith("x") ? ["jsx"] : [])],
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
warnings.push(`${file} — not checked, can't parse: ${e?.message ?? e}`);
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
const fromEntry = new Set();
|
|
111
|
+
for (const st of ast.program.body) {
|
|
112
|
+
if (st.type !== "ImportDeclaration" || st.importKind === "type" || !st.source.value.startsWith("."))
|
|
113
|
+
continue;
|
|
114
|
+
const target = path_1.default.resolve(path_1.default.dirname(path_1.default.resolve(file)), st.source.value);
|
|
115
|
+
if (target.replace(SRC_EXT, "") !== entryBase && path_1.default.join(target, "index") !== entryBase)
|
|
116
|
+
continue;
|
|
117
|
+
for (const s of st.specifiers)
|
|
118
|
+
if (s.type !== "ImportSpecifier" || s.importKind !== "type")
|
|
119
|
+
fromEntry.add(s.local.name);
|
|
120
|
+
}
|
|
121
|
+
const reported = new Set();
|
|
122
|
+
const report = (msg) => { if (!reported.has(msg)) {
|
|
123
|
+
reported.add(msg);
|
|
124
|
+
warnings.push(msg);
|
|
125
|
+
} };
|
|
126
|
+
const visit = (node, loading) => {
|
|
127
|
+
if (!node || typeof node.type !== "string" || NOT_RUN.has(node.type))
|
|
128
|
+
return;
|
|
129
|
+
if (node.type === "Identifier") {
|
|
130
|
+
const line = node.loc?.start.line ?? 0;
|
|
131
|
+
if (node.name === "__dirname" || node.name === "__filename")
|
|
132
|
+
report(`${file}:${line} — __dirname/__filename: in the bundle this is the folder of the bundle (bin/), not of ${file}`);
|
|
133
|
+
else if (loading && fromEntry.has(node.name))
|
|
134
|
+
report(`${file}:${line} — "${node.name}" from ${entry} is read while modules load, before ${entry} has run: `
|
|
135
|
+
+ `in the bundle that is undefined or a "Cannot access before initialization" crash — read it inside a function`);
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (FUNCTIONS.has(node.type) || (CLASS_FIELDS.has(node.type) && !node.static))
|
|
139
|
+
loading = false;
|
|
140
|
+
for (const key of Object.keys(node)) {
|
|
141
|
+
if (NOT_CODE_KEYS.has(key))
|
|
142
|
+
continue;
|
|
143
|
+
if (!node.computed && (key === "key" || (key === "property" && MEMBER_ACCESS.has(node.type))))
|
|
144
|
+
continue;
|
|
145
|
+
const v = node[key];
|
|
146
|
+
if (Array.isArray(v))
|
|
147
|
+
for (const c of v)
|
|
148
|
+
visit(c, loading);
|
|
149
|
+
else if (v && typeof v === "object")
|
|
150
|
+
visit(v, loading);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
for (const st of ast.program.body)
|
|
154
|
+
visit(st, true);
|
|
155
|
+
}
|
|
156
|
+
return warnings;
|
|
157
|
+
}
|
|
158
|
+
const NOT_RUN = new Set(["ImportDeclaration", "ExportSpecifier", "TSInterfaceDeclaration", "TSTypeAliasDeclaration",
|
|
159
|
+
"TSDeclareFunction", "TSDeclareMethod", "TSTypeAnnotation"]);
|
|
160
|
+
const NOT_CODE_KEYS = new Set(["loc", "start", "end", "range", "extra", "leadingComments", "trailingComments", "innerComments",
|
|
161
|
+
"typeAnnotation", "returnType", "typeParameters", "superTypeParameters", "typeArguments", "implements", "label"]);
|
|
162
|
+
const FUNCTIONS = new Set(["FunctionDeclaration", "FunctionExpression", "ArrowFunctionExpression", "ObjectMethod", "ClassMethod", "ClassPrivateMethod"]);
|
|
163
|
+
const CLASS_FIELDS = new Set(["ClassProperty", "ClassPrivateProperty", "ClassAccessorProperty"]);
|
|
164
|
+
const MEMBER_ACCESS = new Set(["MemberExpression", "OptionalMemberExpression"]);
|
|
165
|
+
function listFiles(dir) {
|
|
166
|
+
const out = [];
|
|
167
|
+
for (const e of fs_1.default.readdirSync(dir, { withFileTypes: true })) {
|
|
168
|
+
const full = path_1.default.join(dir, e.name);
|
|
169
|
+
if (e.isDirectory())
|
|
170
|
+
out.push(...listFiles(full));
|
|
171
|
+
else
|
|
172
|
+
out.push(full);
|
|
173
|
+
}
|
|
174
|
+
return out;
|
|
175
|
+
}
|
|
176
|
+
function norm(p) {
|
|
177
|
+
return p.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
178
|
+
}
|