@resourcexjs/cli 2.12.0 → 2.13.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 +67 -3
- package/dist/index.js.map +3 -3
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -14963,9 +14963,9 @@ import { mkdir, readdir as readdir3, stat as stat3, unlink, writeFile } from "fs
|
|
|
14963
14963
|
import { join as join3 } from "path";
|
|
14964
14964
|
import { mkdir as mkdir2, readdir as readdir22, readFile as readFile3, rm, stat as stat22, unlink as unlink2, writeFile as writeFile2 } from "fs/promises";
|
|
14965
14965
|
import { join as join22 } from "path";
|
|
14966
|
-
import { existsSync, readFileSync } from "fs";
|
|
14966
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
14967
14967
|
import { homedir } from "os";
|
|
14968
|
-
import { join as join32 } from "path";
|
|
14968
|
+
import { dirname, join as join32 } from "path";
|
|
14969
14969
|
|
|
14970
14970
|
class FileSystemRXAStore {
|
|
14971
14971
|
basePath;
|
|
@@ -15222,6 +15222,70 @@ class NodeProvider {
|
|
|
15222
15222
|
} catch {}
|
|
15223
15223
|
return {};
|
|
15224
15224
|
}
|
|
15225
|
+
configPath(config2) {
|
|
15226
|
+
const basePath = config2.path ?? DEFAULT_BASE_PATH;
|
|
15227
|
+
return join32(basePath, "config.json");
|
|
15228
|
+
}
|
|
15229
|
+
readConfig(config2) {
|
|
15230
|
+
const configPath = this.configPath(config2);
|
|
15231
|
+
try {
|
|
15232
|
+
if (existsSync(configPath)) {
|
|
15233
|
+
const raw = JSON.parse(readFileSync(configPath, "utf-8"));
|
|
15234
|
+
if (raw.registry && !raw.registries) {
|
|
15235
|
+
raw.registries = [{ name: "default", url: raw.registry, default: true }];
|
|
15236
|
+
delete raw.registry;
|
|
15237
|
+
}
|
|
15238
|
+
return raw;
|
|
15239
|
+
}
|
|
15240
|
+
} catch {}
|
|
15241
|
+
return {};
|
|
15242
|
+
}
|
|
15243
|
+
writeConfig(config2, data) {
|
|
15244
|
+
const configPath = this.configPath(config2);
|
|
15245
|
+
mkdirSync(dirname(configPath), { recursive: true });
|
|
15246
|
+
writeFileSync(configPath, JSON.stringify(data, null, 2));
|
|
15247
|
+
}
|
|
15248
|
+
getRegistries(config2) {
|
|
15249
|
+
return this.readConfig(config2).registries ?? [];
|
|
15250
|
+
}
|
|
15251
|
+
addRegistry(config2, name, url2, setDefault) {
|
|
15252
|
+
const data = this.readConfig(config2);
|
|
15253
|
+
const registries = data.registries ?? [];
|
|
15254
|
+
if (registries.some((r3) => r3.name === name)) {
|
|
15255
|
+
throw new Error(`Registry "${name}" already exists`);
|
|
15256
|
+
}
|
|
15257
|
+
const isDefault = setDefault || registries.length === 0;
|
|
15258
|
+
if (isDefault) {
|
|
15259
|
+
for (const r3 of registries)
|
|
15260
|
+
r3.default = false;
|
|
15261
|
+
}
|
|
15262
|
+
registries.push({ name, url: url2, default: isDefault });
|
|
15263
|
+
data.registries = registries;
|
|
15264
|
+
this.writeConfig(config2, data);
|
|
15265
|
+
}
|
|
15266
|
+
removeRegistry(config2, name) {
|
|
15267
|
+
const data = this.readConfig(config2);
|
|
15268
|
+
const registries = data.registries ?? [];
|
|
15269
|
+
const idx = registries.findIndex((r3) => r3.name === name);
|
|
15270
|
+
if (idx === -1) {
|
|
15271
|
+
throw new Error(`Registry "${name}" not found`);
|
|
15272
|
+
}
|
|
15273
|
+
registries.splice(idx, 1);
|
|
15274
|
+
data.registries = registries;
|
|
15275
|
+
this.writeConfig(config2, data);
|
|
15276
|
+
}
|
|
15277
|
+
setDefaultRegistry(config2, name) {
|
|
15278
|
+
const data = this.readConfig(config2);
|
|
15279
|
+
const registries = data.registries ?? [];
|
|
15280
|
+
const entry = registries.find((r3) => r3.name === name);
|
|
15281
|
+
if (!entry) {
|
|
15282
|
+
throw new Error(`Registry "${name}" not found`);
|
|
15283
|
+
}
|
|
15284
|
+
for (const r3 of registries)
|
|
15285
|
+
r3.default = r3.name === name;
|
|
15286
|
+
data.registries = registries;
|
|
15287
|
+
this.writeConfig(config2, data);
|
|
15288
|
+
}
|
|
15225
15289
|
}
|
|
15226
15290
|
var LOCAL_DIR = "_local", LATEST_FILE = ".latest", DEFAULT_BASE_PATH;
|
|
15227
15291
|
var init_dist2 = __esm(() => {
|
|
@@ -17899,4 +17963,4 @@ var main = defineCommand({
|
|
|
17899
17963
|
});
|
|
17900
17964
|
runMain(main);
|
|
17901
17965
|
|
|
17902
|
-
//# debugId=
|
|
17966
|
+
//# debugId=EFB446D3FE16011164756E2164756E21
|