@resourcexjs/cli 2.6.0 → 2.7.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 +204 -7
- package/dist/index.js.map +7 -6
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -17087,11 +17087,22 @@ async function getConfig() {
|
|
|
17087
17087
|
fileConfig = await file2.json();
|
|
17088
17088
|
}
|
|
17089
17089
|
} catch {}
|
|
17090
|
+
if (fileConfig.registry && !fileConfig.registries) {
|
|
17091
|
+
fileConfig.registries = [{ name: "default", url: fileConfig.registry, default: true }];
|
|
17092
|
+
delete fileConfig.registry;
|
|
17093
|
+
}
|
|
17090
17094
|
const envRegistry = process.env.RX_REGISTRY;
|
|
17091
|
-
|
|
17095
|
+
let registry2;
|
|
17096
|
+
if (envRegistry !== undefined) {
|
|
17097
|
+
registry2 = envRegistry || undefined;
|
|
17098
|
+
} else {
|
|
17099
|
+
const defaultEntry = fileConfig.registries?.find((r3) => r3.default);
|
|
17100
|
+
registry2 = defaultEntry?.url;
|
|
17101
|
+
}
|
|
17092
17102
|
return {
|
|
17093
17103
|
path: process.env.RX_HOME || fileConfig.path || RX_HOME,
|
|
17094
|
-
registry: registry2
|
|
17104
|
+
registry: registry2,
|
|
17105
|
+
registries: fileConfig.registries ?? []
|
|
17095
17106
|
};
|
|
17096
17107
|
}
|
|
17097
17108
|
async function setConfig(key, value) {
|
|
@@ -17100,6 +17111,73 @@ async function setConfig(key, value) {
|
|
|
17100
17111
|
await Bun.$`mkdir -p ${RX_HOME}`.quiet();
|
|
17101
17112
|
await Bun.write(PATHS.config, JSON.stringify(config2, null, 2));
|
|
17102
17113
|
}
|
|
17114
|
+
async function readRawConfig() {
|
|
17115
|
+
try {
|
|
17116
|
+
const file2 = Bun.file(PATHS.config);
|
|
17117
|
+
if (await file2.exists()) {
|
|
17118
|
+
return await file2.json();
|
|
17119
|
+
}
|
|
17120
|
+
} catch {}
|
|
17121
|
+
return {};
|
|
17122
|
+
}
|
|
17123
|
+
async function writeConfig(config2) {
|
|
17124
|
+
await Bun.$`mkdir -p ${RX_HOME}`.quiet();
|
|
17125
|
+
const { registry: _3, ...toWrite } = config2;
|
|
17126
|
+
await Bun.write(PATHS.config, JSON.stringify(toWrite, null, 2));
|
|
17127
|
+
}
|
|
17128
|
+
function migrateConfig(config2) {
|
|
17129
|
+
if (config2.registry && !config2.registries) {
|
|
17130
|
+
config2.registries = [{ name: "default", url: config2.registry, default: true }];
|
|
17131
|
+
delete config2.registry;
|
|
17132
|
+
}
|
|
17133
|
+
return config2;
|
|
17134
|
+
}
|
|
17135
|
+
async function addRegistry(name, url2, setDefault) {
|
|
17136
|
+
const raw = migrateConfig(await readRawConfig());
|
|
17137
|
+
const registries = raw.registries ?? [];
|
|
17138
|
+
if (registries.some((r3) => r3.name === name)) {
|
|
17139
|
+
throw new Error(`Registry "${name}" already exists`);
|
|
17140
|
+
}
|
|
17141
|
+
const isDefault = setDefault || registries.length === 0;
|
|
17142
|
+
if (isDefault) {
|
|
17143
|
+
for (const r3 of registries)
|
|
17144
|
+
r3.default = false;
|
|
17145
|
+
}
|
|
17146
|
+
registries.push({ name, url: url2, default: isDefault });
|
|
17147
|
+
raw.registries = registries;
|
|
17148
|
+
await writeConfig(raw);
|
|
17149
|
+
}
|
|
17150
|
+
async function removeRegistry(name) {
|
|
17151
|
+
const raw = migrateConfig(await readRawConfig());
|
|
17152
|
+
const registries = raw.registries ?? [];
|
|
17153
|
+
const idx = registries.findIndex((r3) => r3.name === name);
|
|
17154
|
+
if (idx === -1) {
|
|
17155
|
+
throw new Error(`Registry "${name}" not found`);
|
|
17156
|
+
}
|
|
17157
|
+
registries.splice(idx, 1);
|
|
17158
|
+
raw.registries = registries;
|
|
17159
|
+
await writeConfig(raw);
|
|
17160
|
+
}
|
|
17161
|
+
async function setDefaultRegistry(name) {
|
|
17162
|
+
const raw = migrateConfig(await readRawConfig());
|
|
17163
|
+
const registries = raw.registries ?? [];
|
|
17164
|
+
const entry = registries.find((r3) => r3.name === name);
|
|
17165
|
+
if (!entry) {
|
|
17166
|
+
throw new Error(`Registry "${name}" not found`);
|
|
17167
|
+
}
|
|
17168
|
+
for (const r3 of registries)
|
|
17169
|
+
r3.default = r3.name === name;
|
|
17170
|
+
raw.registries = registries;
|
|
17171
|
+
await writeConfig(raw);
|
|
17172
|
+
}
|
|
17173
|
+
async function getRegistries() {
|
|
17174
|
+
const raw = migrateConfig(await readRawConfig());
|
|
17175
|
+
return raw.registries ?? [];
|
|
17176
|
+
}
|
|
17177
|
+
async function getRegistryByName(name) {
|
|
17178
|
+
const registries = await getRegistries();
|
|
17179
|
+
return registries.find((r3) => r3.name === name);
|
|
17180
|
+
}
|
|
17103
17181
|
|
|
17104
17182
|
// src/lib/client.ts
|
|
17105
17183
|
setProvider(new NodeProvider);
|
|
@@ -17305,15 +17383,21 @@ var push = defineCommand({
|
|
|
17305
17383
|
registry: {
|
|
17306
17384
|
type: "string",
|
|
17307
17385
|
alias: "r",
|
|
17308
|
-
description: "Registry URL (overrides
|
|
17386
|
+
description: "Registry name or URL (overrides default)"
|
|
17309
17387
|
}
|
|
17310
17388
|
},
|
|
17311
17389
|
async run({ args }) {
|
|
17312
17390
|
try {
|
|
17313
|
-
|
|
17314
|
-
|
|
17391
|
+
let registryUrl;
|
|
17392
|
+
if (args.registry) {
|
|
17393
|
+
const entry = await getRegistryByName(args.registry);
|
|
17394
|
+
registryUrl = entry ? entry.url : args.registry;
|
|
17395
|
+
} else {
|
|
17396
|
+
const config2 = await getConfig();
|
|
17397
|
+
registryUrl = config2.registry;
|
|
17398
|
+
}
|
|
17315
17399
|
if (!registryUrl) {
|
|
17316
|
-
consola.error("No registry configured. Use: rx
|
|
17400
|
+
consola.error("No registry configured. Use: rx registry add <name> <url> or --registry <name|url>");
|
|
17317
17401
|
process.exit(1);
|
|
17318
17402
|
}
|
|
17319
17403
|
const rx = await getClient({ registry: registryUrl });
|
|
@@ -17500,6 +17584,118 @@ var config2 = defineCommand({
|
|
|
17500
17584
|
}
|
|
17501
17585
|
});
|
|
17502
17586
|
|
|
17587
|
+
// src/commands/registry.ts
|
|
17588
|
+
var add2 = defineCommand({
|
|
17589
|
+
meta: {
|
|
17590
|
+
name: "add",
|
|
17591
|
+
description: "Add a registry"
|
|
17592
|
+
},
|
|
17593
|
+
args: {
|
|
17594
|
+
name: {
|
|
17595
|
+
type: "positional",
|
|
17596
|
+
description: "Registry name",
|
|
17597
|
+
required: true
|
|
17598
|
+
},
|
|
17599
|
+
url: {
|
|
17600
|
+
type: "positional",
|
|
17601
|
+
description: "Registry URL",
|
|
17602
|
+
required: true
|
|
17603
|
+
},
|
|
17604
|
+
default: {
|
|
17605
|
+
type: "boolean",
|
|
17606
|
+
description: "Set as default registry",
|
|
17607
|
+
default: false
|
|
17608
|
+
}
|
|
17609
|
+
},
|
|
17610
|
+
async run({ args }) {
|
|
17611
|
+
try {
|
|
17612
|
+
await addRegistry(args.name, args.url, args.default);
|
|
17613
|
+
const registries = await getRegistries();
|
|
17614
|
+
const entry = registries.find((r3) => r3.name === args.name);
|
|
17615
|
+
const marker = entry?.default ? " (default)" : "";
|
|
17616
|
+
consola.success(`Added registry: ${args.name} \u2192 ${args.url}${marker}`);
|
|
17617
|
+
} catch (error48) {
|
|
17618
|
+
consola.error(error48 instanceof Error ? error48.message : "Failed to add registry");
|
|
17619
|
+
process.exit(1);
|
|
17620
|
+
}
|
|
17621
|
+
}
|
|
17622
|
+
});
|
|
17623
|
+
var remove2 = defineCommand({
|
|
17624
|
+
meta: {
|
|
17625
|
+
name: "remove",
|
|
17626
|
+
description: "Remove a registry"
|
|
17627
|
+
},
|
|
17628
|
+
args: {
|
|
17629
|
+
name: {
|
|
17630
|
+
type: "positional",
|
|
17631
|
+
description: "Registry name",
|
|
17632
|
+
required: true
|
|
17633
|
+
}
|
|
17634
|
+
},
|
|
17635
|
+
async run({ args }) {
|
|
17636
|
+
try {
|
|
17637
|
+
await removeRegistry(args.name);
|
|
17638
|
+
consola.success(`Removed registry: ${args.name}`);
|
|
17639
|
+
} catch (error48) {
|
|
17640
|
+
consola.error(error48 instanceof Error ? error48.message : "Failed to remove registry");
|
|
17641
|
+
process.exit(1);
|
|
17642
|
+
}
|
|
17643
|
+
}
|
|
17644
|
+
});
|
|
17645
|
+
var listCmd = defineCommand({
|
|
17646
|
+
meta: {
|
|
17647
|
+
name: "list",
|
|
17648
|
+
description: "List all configured registries"
|
|
17649
|
+
},
|
|
17650
|
+
async run() {
|
|
17651
|
+
const registries = await getRegistries();
|
|
17652
|
+
if (registries.length === 0) {
|
|
17653
|
+
consola.info("No registries configured. Use: rx registry add <name> <url>");
|
|
17654
|
+
return;
|
|
17655
|
+
}
|
|
17656
|
+
consola.info(`Registries:
|
|
17657
|
+
`);
|
|
17658
|
+
for (const r3 of registries) {
|
|
17659
|
+
const marker = r3.default ? " (default)" : "";
|
|
17660
|
+
console.log(` ${r3.name} ${r3.url}${marker}`);
|
|
17661
|
+
}
|
|
17662
|
+
}
|
|
17663
|
+
});
|
|
17664
|
+
var defaultCmd = defineCommand({
|
|
17665
|
+
meta: {
|
|
17666
|
+
name: "default",
|
|
17667
|
+
description: "Set default registry"
|
|
17668
|
+
},
|
|
17669
|
+
args: {
|
|
17670
|
+
name: {
|
|
17671
|
+
type: "positional",
|
|
17672
|
+
description: "Registry name",
|
|
17673
|
+
required: true
|
|
17674
|
+
}
|
|
17675
|
+
},
|
|
17676
|
+
async run({ args }) {
|
|
17677
|
+
try {
|
|
17678
|
+
await setDefaultRegistry(args.name);
|
|
17679
|
+
consola.success(`Default registry set to: ${args.name}`);
|
|
17680
|
+
} catch (error48) {
|
|
17681
|
+
consola.error(error48 instanceof Error ? error48.message : "Failed to set default");
|
|
17682
|
+
process.exit(1);
|
|
17683
|
+
}
|
|
17684
|
+
}
|
|
17685
|
+
});
|
|
17686
|
+
var registry2 = defineCommand({
|
|
17687
|
+
meta: {
|
|
17688
|
+
name: "registry",
|
|
17689
|
+
description: "Manage registry configurations"
|
|
17690
|
+
},
|
|
17691
|
+
subCommands: {
|
|
17692
|
+
add: add2,
|
|
17693
|
+
remove: remove2,
|
|
17694
|
+
list: listCmd,
|
|
17695
|
+
default: defaultCmd
|
|
17696
|
+
}
|
|
17697
|
+
});
|
|
17698
|
+
|
|
17503
17699
|
// src/commands/server.ts
|
|
17504
17700
|
import { join as join6 } from "path";
|
|
17505
17701
|
var server = defineCommand({
|
|
@@ -17603,10 +17799,11 @@ var main = defineCommand({
|
|
|
17603
17799
|
search,
|
|
17604
17800
|
use,
|
|
17605
17801
|
config: config2,
|
|
17802
|
+
registry: registry2,
|
|
17606
17803
|
cache,
|
|
17607
17804
|
server
|
|
17608
17805
|
}
|
|
17609
17806
|
});
|
|
17610
17807
|
runMain(main);
|
|
17611
17808
|
|
|
17612
|
-
//# debugId=
|
|
17809
|
+
//# debugId=4412ACE67CCF020964756E2164756E21
|