@resourcexjs/cli 2.12.0 → 2.14.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/dist/index.js +92 -3
- package/dist/index.js.map +4 -4
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -4962,6 +4962,31 @@ class FolderSourceLoader {
|
|
|
4962
4962
|
const files = await this.readFolderFiles(source);
|
|
4963
4963
|
return { source, files };
|
|
4964
4964
|
}
|
|
4965
|
+
async isFresh(source, cachedAt) {
|
|
4966
|
+
try {
|
|
4967
|
+
const maxMtime = await this.getMaxMtime(source);
|
|
4968
|
+
return maxMtime <= cachedAt;
|
|
4969
|
+
} catch {
|
|
4970
|
+
return false;
|
|
4971
|
+
}
|
|
4972
|
+
}
|
|
4973
|
+
async getMaxMtime(folderPath) {
|
|
4974
|
+
let max = new Date(0);
|
|
4975
|
+
const entries = await readdir2(folderPath, { withFileTypes: true });
|
|
4976
|
+
for (const entry of entries) {
|
|
4977
|
+
const fullPath = join2(folderPath, entry.name);
|
|
4978
|
+
if (entry.isFile()) {
|
|
4979
|
+
const stats = await stat2(fullPath);
|
|
4980
|
+
if (stats.mtime > max)
|
|
4981
|
+
max = stats.mtime;
|
|
4982
|
+
} else if (entry.isDirectory()) {
|
|
4983
|
+
const subMax = await this.getMaxMtime(fullPath);
|
|
4984
|
+
if (subMax > max)
|
|
4985
|
+
max = subMax;
|
|
4986
|
+
}
|
|
4987
|
+
}
|
|
4988
|
+
return max;
|
|
4989
|
+
}
|
|
4965
4990
|
async readFolderFiles(folderPath, basePath = folderPath) {
|
|
4966
4991
|
const files = {};
|
|
4967
4992
|
const entries = await readdir2(folderPath, { withFileTypes: true });
|
|
@@ -14963,9 +14988,9 @@ import { mkdir, readdir as readdir3, stat as stat3, unlink, writeFile } from "fs
|
|
|
14963
14988
|
import { join as join3 } from "path";
|
|
14964
14989
|
import { mkdir as mkdir2, readdir as readdir22, readFile as readFile3, rm, stat as stat22, unlink as unlink2, writeFile as writeFile2 } from "fs/promises";
|
|
14965
14990
|
import { join as join22 } from "path";
|
|
14966
|
-
import { existsSync, readFileSync } from "fs";
|
|
14991
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
14967
14992
|
import { homedir } from "os";
|
|
14968
|
-
import { join as join32 } from "path";
|
|
14993
|
+
import { dirname, join as join32 } from "path";
|
|
14969
14994
|
|
|
14970
14995
|
class FileSystemRXAStore {
|
|
14971
14996
|
basePath;
|
|
@@ -15222,6 +15247,70 @@ class NodeProvider {
|
|
|
15222
15247
|
} catch {}
|
|
15223
15248
|
return {};
|
|
15224
15249
|
}
|
|
15250
|
+
configPath(config2) {
|
|
15251
|
+
const basePath = config2.path ?? DEFAULT_BASE_PATH;
|
|
15252
|
+
return join32(basePath, "config.json");
|
|
15253
|
+
}
|
|
15254
|
+
readConfig(config2) {
|
|
15255
|
+
const configPath = this.configPath(config2);
|
|
15256
|
+
try {
|
|
15257
|
+
if (existsSync(configPath)) {
|
|
15258
|
+
const raw = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
15259
|
+
if (raw.registry && !raw.registries) {
|
|
15260
|
+
raw.registries = [{ name: "default", url: raw.registry, default: true }];
|
|
15261
|
+
delete raw.registry;
|
|
15262
|
+
}
|
|
15263
|
+
return raw;
|
|
15264
|
+
}
|
|
15265
|
+
} catch {}
|
|
15266
|
+
return {};
|
|
15267
|
+
}
|
|
15268
|
+
writeConfig(config2, data) {
|
|
15269
|
+
const configPath = this.configPath(config2);
|
|
15270
|
+
mkdirSync(dirname(configPath), { recursive: true });
|
|
15271
|
+
writeFileSync(configPath, JSON.stringify(data, null, 2));
|
|
15272
|
+
}
|
|
15273
|
+
getRegistries(config2) {
|
|
15274
|
+
return this.readConfig(config2).registries ?? [];
|
|
15275
|
+
}
|
|
15276
|
+
addRegistry(config2, name, url2, setDefault) {
|
|
15277
|
+
const data = this.readConfig(config2);
|
|
15278
|
+
const registries = data.registries ?? [];
|
|
15279
|
+
if (registries.some((r3) => r3.name === name)) {
|
|
15280
|
+
throw new Error(`Registry "${name}" already exists`);
|
|
15281
|
+
}
|
|
15282
|
+
const isDefault = setDefault || registries.length === 0;
|
|
15283
|
+
if (isDefault) {
|
|
15284
|
+
for (const r3 of registries)
|
|
15285
|
+
r3.default = false;
|
|
15286
|
+
}
|
|
15287
|
+
registries.push({ name, url: url2, default: isDefault });
|
|
15288
|
+
data.registries = registries;
|
|
15289
|
+
this.writeConfig(config2, data);
|
|
15290
|
+
}
|
|
15291
|
+
removeRegistry(config2, name) {
|
|
15292
|
+
const data = this.readConfig(config2);
|
|
15293
|
+
const registries = data.registries ?? [];
|
|
15294
|
+
const idx = registries.findIndex((r3) => r3.name === name);
|
|
15295
|
+
if (idx === -1) {
|
|
15296
|
+
throw new Error(`Registry "${name}" not found`);
|
|
15297
|
+
}
|
|
15298
|
+
registries.splice(idx, 1);
|
|
15299
|
+
data.registries = registries;
|
|
15300
|
+
this.writeConfig(config2, data);
|
|
15301
|
+
}
|
|
15302
|
+
setDefaultRegistry(config2, name) {
|
|
15303
|
+
const data = this.readConfig(config2);
|
|
15304
|
+
const registries = data.registries ?? [];
|
|
15305
|
+
const entry = registries.find((r3) => r3.name === name);
|
|
15306
|
+
if (!entry) {
|
|
15307
|
+
throw new Error(`Registry "${name}" not found`);
|
|
15308
|
+
}
|
|
15309
|
+
for (const r3 of registries)
|
|
15310
|
+
r3.default = r3.name === name;
|
|
15311
|
+
data.registries = registries;
|
|
15312
|
+
this.writeConfig(config2, data);
|
|
15313
|
+
}
|
|
15225
15314
|
}
|
|
15226
15315
|
var LOCAL_DIR = "_local", LATEST_FILE = ".latest", DEFAULT_BASE_PATH;
|
|
15227
15316
|
var init_dist2 = __esm(() => {
|
|
@@ -17899,4 +17988,4 @@ var main = defineCommand({
|
|
|
17899
17988
|
});
|
|
17900
17989
|
runMain(main);
|
|
17901
17990
|
|
|
17902
|
-
//# debugId=
|
|
17991
|
+
//# debugId=2856F8DBC43B5B9B64756E2164756E21
|