@calimero-network/registry-cli 1.7.0 → 1.9.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/README.md +1 -1
- package/dist/index.js +207 -52
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -184,7 +184,7 @@ calimero-registry apps create --file app-manifest.json
|
|
|
184
184
|
|
|
185
185
|
# Create with inline data
|
|
186
186
|
calimero-registry apps create \
|
|
187
|
-
--name "My
|
|
187
|
+
--name "My self-sovereign application" \
|
|
188
188
|
--description "A smart contract application" \
|
|
189
189
|
--version "1.0.0" \
|
|
190
190
|
--developer-id "developer-id"
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command } from 'commander';
|
|
3
3
|
import chalk6 from 'chalk';
|
|
4
|
+
import { createRequire } from 'module';
|
|
4
5
|
import ora6 from 'ora';
|
|
5
6
|
import { table } from 'table';
|
|
6
7
|
import axios from 'axios';
|
|
@@ -12,9 +13,9 @@ import fastify from 'fastify';
|
|
|
12
13
|
import cors from '@fastify/cors';
|
|
13
14
|
import * as tar from 'tar';
|
|
14
15
|
|
|
15
|
-
var
|
|
16
|
+
var CalimeroRegistryClient = class {
|
|
16
17
|
/**
|
|
17
|
-
* Creates a new
|
|
18
|
+
* Creates a new Calimero Registry client instance.
|
|
18
19
|
*
|
|
19
20
|
* @param config - Configuration options for the client
|
|
20
21
|
* @param config.baseURL - Base URL for the API (default: 'http://localhost:8082')
|
|
@@ -24,10 +25,10 @@ var SSAppRegistryClient = class {
|
|
|
24
25
|
* @example
|
|
25
26
|
* ```typescript
|
|
26
27
|
* // Basic configuration
|
|
27
|
-
* const client = new
|
|
28
|
+
* const client = new CalimeroRegistryClient();
|
|
28
29
|
*
|
|
29
30
|
* // Custom configuration
|
|
30
|
-
* const client = new
|
|
31
|
+
* const client = new CalimeroRegistryClient({
|
|
31
32
|
* baseURL: 'https://api.calimero.network',
|
|
32
33
|
* timeout: 30000,
|
|
33
34
|
* headers: {
|
|
@@ -656,12 +657,12 @@ var LocalDataStore = class {
|
|
|
656
657
|
);
|
|
657
658
|
}
|
|
658
659
|
// Manifest management (V2 / Bundles)
|
|
659
|
-
getBundleManifest(pkg,
|
|
660
|
-
const key = `${pkg}/${
|
|
660
|
+
getBundleManifest(pkg, version2) {
|
|
661
|
+
const key = `${pkg}/${version2}`;
|
|
661
662
|
return this.data.bundleManifests.get(key);
|
|
662
663
|
}
|
|
663
|
-
setBundleManifest(pkg,
|
|
664
|
-
const key = `${pkg}/${
|
|
664
|
+
setBundleManifest(pkg, version2, manifest) {
|
|
665
|
+
const key = `${pkg}/${version2}`;
|
|
665
666
|
this.data.bundleManifests.set(key, manifest);
|
|
666
667
|
this.saveData();
|
|
667
668
|
}
|
|
@@ -779,11 +780,11 @@ var LocalArtifactServer = class {
|
|
|
779
780
|
}
|
|
780
781
|
}
|
|
781
782
|
// Copy artifact to local storage
|
|
782
|
-
async copyArtifactToLocal(sourcePath, appId,
|
|
783
|
+
async copyArtifactToLocal(sourcePath, appId, version2, filename) {
|
|
783
784
|
if (!fs9.existsSync(sourcePath)) {
|
|
784
785
|
throw new Error(`Source file not found: ${sourcePath}`);
|
|
785
786
|
}
|
|
786
|
-
const appVersionDir = path7.join(this.artifactsDir, appId,
|
|
787
|
+
const appVersionDir = path7.join(this.artifactsDir, appId, version2);
|
|
787
788
|
if (!fs9.existsSync(appVersionDir)) {
|
|
788
789
|
fs9.mkdirSync(appVersionDir, { recursive: true });
|
|
789
790
|
}
|
|
@@ -794,8 +795,8 @@ var LocalArtifactServer = class {
|
|
|
794
795
|
return targetPath;
|
|
795
796
|
}
|
|
796
797
|
// Serve artifact by app ID, version, and filename
|
|
797
|
-
async serveArtifact(appId,
|
|
798
|
-
const artifactPath = path7.join(this.artifactsDir, appId,
|
|
798
|
+
async serveArtifact(appId, version2, filename) {
|
|
799
|
+
const artifactPath = path7.join(this.artifactsDir, appId, version2, filename);
|
|
799
800
|
if (!fs9.existsSync(artifactPath)) {
|
|
800
801
|
throw new Error(`Artifact not found: ${artifactPath}`);
|
|
801
802
|
}
|
|
@@ -828,9 +829,9 @@ var LocalArtifactServer = class {
|
|
|
828
829
|
return crypto.createHash("sha256").update(fileBuffer).digest("hex");
|
|
829
830
|
}
|
|
830
831
|
// Get artifact URL for local serving
|
|
831
|
-
getArtifactUrl(appId,
|
|
832
|
+
getArtifactUrl(appId, version2, filename) {
|
|
832
833
|
const baseUrl = `http://${this.config.getPublicHost()}:${this.config.getPort()}`;
|
|
833
|
-
return `${baseUrl}/artifacts/${appId}/${
|
|
834
|
+
return `${baseUrl}/artifacts/${appId}/${version2}/${filename}`;
|
|
834
835
|
}
|
|
835
836
|
// Get artifact URL by hash
|
|
836
837
|
getArtifactUrlByHash(hash) {
|
|
@@ -925,7 +926,7 @@ var LocalArtifactServer = class {
|
|
|
925
926
|
};
|
|
926
927
|
var RemoteRegistryClient = class {
|
|
927
928
|
constructor(baseURL, timeout) {
|
|
928
|
-
this.client = new
|
|
929
|
+
this.client = new CalimeroRegistryClient({
|
|
929
930
|
baseURL,
|
|
930
931
|
timeout
|
|
931
932
|
});
|
|
@@ -1029,7 +1030,7 @@ function createRegistryClient(useLocal, baseURL, timeout) {
|
|
|
1029
1030
|
);
|
|
1030
1031
|
}
|
|
1031
1032
|
}
|
|
1032
|
-
var appsCommand = new Command("apps").description("Manage
|
|
1033
|
+
var appsCommand = new Command("apps").description("Manage self-sovereign applications").addCommand(
|
|
1033
1034
|
new Command("list").description("List all applications").option("-n, --name <name>", "Filter by application name").action(async (options, command) => {
|
|
1034
1035
|
const globalOpts = command.parent?.parent?.opts();
|
|
1035
1036
|
const useLocal = globalOpts?.local || false;
|
|
@@ -1086,10 +1087,10 @@ var appsCommand = new Command("apps").description("Manage SSApp applications").a
|
|
|
1086
1087
|
}
|
|
1087
1088
|
const tableData = [
|
|
1088
1089
|
["Version", "CID", "Yanked"],
|
|
1089
|
-
...versions.map((
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1090
|
+
...versions.map((version2) => [
|
|
1091
|
+
version2.semver,
|
|
1092
|
+
version2.cid.substring(0, 12) + "...",
|
|
1093
|
+
version2.yanked ? chalk6.red("Yes") : chalk6.green("No")
|
|
1093
1094
|
])
|
|
1094
1095
|
];
|
|
1095
1096
|
console.log(table(tableData));
|
|
@@ -1102,7 +1103,7 @@ var appsCommand = new Command("apps").description("Manage SSApp applications").a
|
|
|
1102
1103
|
}
|
|
1103
1104
|
})
|
|
1104
1105
|
).addCommand(
|
|
1105
|
-
new Command("manifest").description("Get manifest for a specific application version").argument("<appId>", "Application ID").argument("<version>", "Application version").action(async (appId,
|
|
1106
|
+
new Command("manifest").description("Get manifest for a specific application version").argument("<appId>", "Application ID").argument("<version>", "Application version").action(async (appId, version2, options, command) => {
|
|
1106
1107
|
const globalOpts = command.parent?.parent?.opts();
|
|
1107
1108
|
const useLocal = globalOpts?.local || false;
|
|
1108
1109
|
const client = createRegistryClient(
|
|
@@ -1111,10 +1112,10 @@ var appsCommand = new Command("apps").description("Manage SSApp applications").a
|
|
|
1111
1112
|
parseInt(globalOpts?.timeout || "10000")
|
|
1112
1113
|
);
|
|
1113
1114
|
const spinner2 = ora6(
|
|
1114
|
-
`Fetching manifest for ${appId}@${
|
|
1115
|
+
`Fetching manifest for ${appId}@${version2}...`
|
|
1115
1116
|
).start();
|
|
1116
1117
|
try {
|
|
1117
|
-
const manifest = await client.getAppManifest(appId,
|
|
1118
|
+
const manifest = await client.getAppManifest(appId, version2);
|
|
1118
1119
|
spinner2.succeed("Manifest fetched successfully");
|
|
1119
1120
|
console.log(chalk6.blue("\nApplication Manifest:"));
|
|
1120
1121
|
console.log(JSON.stringify(manifest, null, 2));
|
|
@@ -1170,7 +1171,7 @@ var appsCommand = new Command("apps").description("Manage SSApp applications").a
|
|
|
1170
1171
|
var developersCommand = new Command("developers").description("Manage developer profiles").addCommand(
|
|
1171
1172
|
new Command("get").description("Get developer profile information").argument("<pubkey>", "Developer public key").action(async (pubkey, options, command) => {
|
|
1172
1173
|
const globalOpts = command.parent?.parent?.opts();
|
|
1173
|
-
const client = new
|
|
1174
|
+
const client = new CalimeroRegistryClient({
|
|
1174
1175
|
baseURL: globalOpts?.url || "http://localhost:8082",
|
|
1175
1176
|
timeout: parseInt(globalOpts?.timeout || "10000")
|
|
1176
1177
|
});
|
|
@@ -1208,7 +1209,7 @@ var developersCommand = new Command("developers").description("Manage developer
|
|
|
1208
1209
|
).addCommand(
|
|
1209
1210
|
new Command("create").description("Create a new developer profile").argument("<pubkey>", "Developer public key").argument("<display-name>", "Display name for the developer").option("-w, --website <url>", "Developer website URL").option("-p, --proofs <proofs>", "JSON string of proofs array").action(async (pubkey, displayName, options, command) => {
|
|
1210
1211
|
const globalOpts = command.parent?.parent?.opts();
|
|
1211
|
-
const client = new
|
|
1212
|
+
const client = new CalimeroRegistryClient({
|
|
1212
1213
|
baseURL: globalOpts?.url || "http://localhost:8082",
|
|
1213
1214
|
timeout: parseInt(globalOpts?.timeout || "10000")
|
|
1214
1215
|
});
|
|
@@ -1250,20 +1251,20 @@ var developersCommand = new Command("developers").description("Manage developer
|
|
|
1250
1251
|
})
|
|
1251
1252
|
);
|
|
1252
1253
|
var attestationsCommand = new Command("attestations").description("Manage application attestations").addCommand(
|
|
1253
|
-
new Command("get").description("Get attestation for a specific application version").argument("<pubkey>", "Developer public key").argument("<name>", "Application name").argument("<version>", "Application version").action(async (pubkey, name,
|
|
1254
|
+
new Command("get").description("Get attestation for a specific application version").argument("<pubkey>", "Developer public key").argument("<name>", "Application name").argument("<version>", "Application version").action(async (pubkey, name, version2, options, command) => {
|
|
1254
1255
|
const globalOpts = command.parent?.parent?.opts();
|
|
1255
|
-
const client = new
|
|
1256
|
+
const client = new CalimeroRegistryClient({
|
|
1256
1257
|
baseURL: globalOpts?.url || "http://localhost:8082",
|
|
1257
1258
|
timeout: parseInt(globalOpts?.timeout || "10000")
|
|
1258
1259
|
});
|
|
1259
1260
|
const spinner2 = ora6(
|
|
1260
|
-
`Fetching attestation for ${name}@${
|
|
1261
|
+
`Fetching attestation for ${name}@${version2}...`
|
|
1261
1262
|
).start();
|
|
1262
1263
|
try {
|
|
1263
1264
|
const attestation = await client.getAttestation(
|
|
1264
1265
|
pubkey,
|
|
1265
1266
|
name,
|
|
1266
|
-
|
|
1267
|
+
version2
|
|
1267
1268
|
);
|
|
1268
1269
|
spinner2.succeed("Attestation fetched successfully");
|
|
1269
1270
|
console.log(chalk6.blue("\nAttestation:"));
|
|
@@ -1281,7 +1282,7 @@ var attestationsCommand = new Command("attestations").description("Manage applic
|
|
|
1281
1282
|
}
|
|
1282
1283
|
})
|
|
1283
1284
|
);
|
|
1284
|
-
var healthCommand = new Command("health").description("Check the health of the
|
|
1285
|
+
var healthCommand = new Command("health").description("Check the health of the Calimero Registry API").action(async (options, command) => {
|
|
1285
1286
|
const globalOpts = command.parent?.opts();
|
|
1286
1287
|
const useLocal = globalOpts?.local || false;
|
|
1287
1288
|
const client = createRegistryClient(
|
|
@@ -1456,11 +1457,11 @@ var LocalRegistryServer = class {
|
|
|
1456
1457
|
this.server.get(
|
|
1457
1458
|
"/artifacts/:appId/:version/:filename",
|
|
1458
1459
|
async (request, reply) => {
|
|
1459
|
-
const { appId, version, filename } = request.params;
|
|
1460
|
+
const { appId, version: version2, filename } = request.params;
|
|
1460
1461
|
try {
|
|
1461
1462
|
const artifactData = await this.artifactServer.serveArtifact(
|
|
1462
1463
|
appId,
|
|
1463
|
-
|
|
1464
|
+
version2,
|
|
1464
1465
|
filename
|
|
1465
1466
|
);
|
|
1466
1467
|
reply.header("Content-Type", "application/octet-stream");
|
|
@@ -1515,13 +1516,13 @@ var LocalRegistryServer = class {
|
|
|
1515
1516
|
});
|
|
1516
1517
|
this.server.get("/api/v2/bundles", async (request, reply) => {
|
|
1517
1518
|
const query = request.query;
|
|
1518
|
-
const { package: pkg, version, developer } = query;
|
|
1519
|
-
if (pkg &&
|
|
1520
|
-
const manifest = this.dataStore.getBundleManifest(pkg,
|
|
1519
|
+
const { package: pkg, version: version2, developer } = query;
|
|
1520
|
+
if (pkg && version2) {
|
|
1521
|
+
const manifest = this.dataStore.getBundleManifest(pkg, version2);
|
|
1521
1522
|
if (!manifest) {
|
|
1522
1523
|
return reply.code(404).send({
|
|
1523
1524
|
error: "bundle_not_found",
|
|
1524
|
-
message: `Bundle ${pkg}@${
|
|
1525
|
+
message: `Bundle ${pkg}@${version2} not found`
|
|
1525
1526
|
});
|
|
1526
1527
|
}
|
|
1527
1528
|
return [manifest];
|
|
@@ -1562,12 +1563,12 @@ var LocalRegistryServer = class {
|
|
|
1562
1563
|
this.server.get(
|
|
1563
1564
|
"/api/v2/bundles/:package/:version",
|
|
1564
1565
|
async (request, reply) => {
|
|
1565
|
-
const { package: pkg, version } = request.params;
|
|
1566
|
-
const manifest = this.dataStore.getBundleManifest(pkg,
|
|
1566
|
+
const { package: pkg, version: version2 } = request.params;
|
|
1567
|
+
const manifest = this.dataStore.getBundleManifest(pkg, version2);
|
|
1567
1568
|
if (!manifest) {
|
|
1568
1569
|
return reply.code(404).send({
|
|
1569
1570
|
error: "manifest_not_found",
|
|
1570
|
-
message: `Manifest not found for ${pkg}@${
|
|
1571
|
+
message: `Manifest not found for ${pkg}@${version2}`
|
|
1571
1572
|
});
|
|
1572
1573
|
}
|
|
1573
1574
|
return manifest;
|
|
@@ -1888,7 +1889,7 @@ var RemoteConfig = class {
|
|
|
1888
1889
|
};
|
|
1889
1890
|
|
|
1890
1891
|
// src/commands/bundle.ts
|
|
1891
|
-
var bundleCommand = new Command("bundle").description("Manage application bundles (V2)").addCommand(createCreateCommand()).addCommand(createPushCommand()).addCommand(createGetCommand());
|
|
1892
|
+
var bundleCommand = new Command("bundle").description("Manage application bundles (V2)").addCommand(createCreateCommand()).addCommand(createPushCommand()).addCommand(createGetCommand()).addCommand(createEditCommand());
|
|
1892
1893
|
function createCreateCommand() {
|
|
1893
1894
|
return new Command("create").description("Create an MPK bundle from a WASM file").argument("<wasm-file>", "Path to the WASM file").argument("[package]", "Package name (e.g. com.calimero.myapp)").argument("[version]", "Version (e.g. 1.0.0)").option(
|
|
1894
1895
|
"-m, --manifest <path>",
|
|
@@ -1940,7 +1941,7 @@ Note:
|
|
|
1940
1941
|
- ABI can be provided via --abi flag or manifest.abi field (file path string)
|
|
1941
1942
|
- ABI file will be included in the bundle and referenced in the manifest
|
|
1942
1943
|
`
|
|
1943
|
-
).action(async (wasmFile, pkg,
|
|
1944
|
+
).action(async (wasmFile, pkg, version2, options) => {
|
|
1944
1945
|
try {
|
|
1945
1946
|
let manifestConfig = {};
|
|
1946
1947
|
if (options.manifest) {
|
|
@@ -1969,7 +1970,7 @@ Note:
|
|
|
1969
1970
|
}
|
|
1970
1971
|
}
|
|
1971
1972
|
const finalPackage = pkg || manifestConfig.package;
|
|
1972
|
-
const finalVersion =
|
|
1973
|
+
const finalVersion = version2 || manifestConfig.version;
|
|
1973
1974
|
const finalOutput = options.output || manifestConfig.output;
|
|
1974
1975
|
const finalName = options.name || manifestConfig.name;
|
|
1975
1976
|
const finalDescription = options.description || manifestConfig.description;
|
|
@@ -2276,16 +2277,16 @@ Note:
|
|
|
2276
2277
|
});
|
|
2277
2278
|
}
|
|
2278
2279
|
function createGetCommand() {
|
|
2279
|
-
return new Command("get").description("Get bundle manifest").argument("<package>", "Package name (e.g. com.calimero.kv)").argument("<version>", "Version (e.g. 1.0.0)").option("--local", "Use local registry", true).action(async (pkg,
|
|
2280
|
+
return new Command("get").description("Get bundle manifest").argument("<package>", "Package name (e.g. com.calimero.kv)").argument("<version>", "Version (e.g. 1.0.0)").option("--local", "Use local registry", true).action(async (pkg, version2, options) => {
|
|
2280
2281
|
try {
|
|
2281
2282
|
if (options.local) {
|
|
2282
2283
|
const config = new LocalConfig();
|
|
2283
2284
|
const store = new LocalDataStore(config);
|
|
2284
|
-
const manifest = store.getBundleManifest(pkg,
|
|
2285
|
+
const manifest = store.getBundleManifest(pkg, version2);
|
|
2285
2286
|
if (manifest) {
|
|
2286
2287
|
console.log(JSON.stringify(manifest, null, 2));
|
|
2287
2288
|
} else {
|
|
2288
|
-
console.error(`\u274C Manifest not found: ${pkg}@${
|
|
2289
|
+
console.error(`\u274C Manifest not found: ${pkg}@${version2}`);
|
|
2289
2290
|
process.exit(1);
|
|
2290
2291
|
}
|
|
2291
2292
|
} else {
|
|
@@ -2298,6 +2299,157 @@ function createGetCommand() {
|
|
|
2298
2299
|
}
|
|
2299
2300
|
});
|
|
2300
2301
|
}
|
|
2302
|
+
function createEditCommand() {
|
|
2303
|
+
return new Command("edit").description(
|
|
2304
|
+
"Edit package metadata (name, description, author, links). Use --remote to talk to the registry. Either supply --manifest (signed manifest file to PATCH) or use options to fetch, modify, and output a manifest for you to sign."
|
|
2305
|
+
).argument("<package>", "Package name (e.g. com.calimero.myapp)").argument("<version>", "Version (e.g. 1.0.0)").option("--remote", "Use remote registry (required for edit)").option("--url <registry-url>", "Registry URL (overrides config)").option("--api-key <key>", "API key for remote (overrides config and env)").option(
|
|
2306
|
+
"--manifest <path>",
|
|
2307
|
+
"Path to signed manifest to PATCH (if omitted, GET + apply options + write file + instructions)"
|
|
2308
|
+
).option(
|
|
2309
|
+
"-o, --output <path>",
|
|
2310
|
+
"Where to write modified manifest when not using --manifest (default: manifest.json)"
|
|
2311
|
+
).option("--name <name>", "Set metadata.name").option("--description <description>", "Set metadata.description").option("--author <author>", 'Set metadata.author (use "" to clear)').option("--frontend <url>", "Set links.frontend").option("--github <url>", "Set links.github").option("--docs <url>", "Set links.docs").addHelpText(
|
|
2312
|
+
"after",
|
|
2313
|
+
`
|
|
2314
|
+
Examples:
|
|
2315
|
+
# 1) Get current manifest, apply edits, write manifest.json and show sign instructions:
|
|
2316
|
+
$ calimero-registry bundle edit com.calimero.myapp 1.0.0 --remote --name "New Name" --description "New desc" -o manifest.json
|
|
2317
|
+
|
|
2318
|
+
# 2) After signing with mero-sign, PATCH the signed manifest:
|
|
2319
|
+
$ calimero-registry bundle edit com.calimero.myapp 1.0.0 --remote --manifest signed-manifest.json
|
|
2320
|
+
|
|
2321
|
+
# 3) With custom registry URL:
|
|
2322
|
+
$ calimero-registry bundle edit com.calimero.myapp 1.0.0 --remote --url https://apps.calimero.network --manifest signed-manifest.json
|
|
2323
|
+
`
|
|
2324
|
+
).action(async (pkg, version2, options) => {
|
|
2325
|
+
try {
|
|
2326
|
+
if (!options.remote) {
|
|
2327
|
+
console.error(
|
|
2328
|
+
"\u274C Edit requires --remote (editing is only supported against the remote registry)."
|
|
2329
|
+
);
|
|
2330
|
+
process.exit(1);
|
|
2331
|
+
}
|
|
2332
|
+
const remoteConfig = new RemoteConfig();
|
|
2333
|
+
const registryUrl = options.url || process.env.CALIMERO_REGISTRY_URL || remoteConfig.getRegistryUrl();
|
|
2334
|
+
const apiKey = options.apiKey || process.env.CALIMERO_API_KEY || remoteConfig.getApiKey();
|
|
2335
|
+
const baseUrl = registryUrl.replace(/\/$/, "");
|
|
2336
|
+
const bundleUrl = `${baseUrl}/api/v2/bundles/${encodeURIComponent(pkg)}/${encodeURIComponent(version2)}`;
|
|
2337
|
+
const headers = {
|
|
2338
|
+
"Content-Type": "application/json"
|
|
2339
|
+
};
|
|
2340
|
+
if (apiKey) headers["Authorization"] = `Bearer ${apiKey}`;
|
|
2341
|
+
if (options.manifest) {
|
|
2342
|
+
const manifestPath = path7.resolve(options.manifest);
|
|
2343
|
+
if (!fs9.existsSync(manifestPath)) {
|
|
2344
|
+
console.error(`\u274C Manifest file not found: ${options.manifest}`);
|
|
2345
|
+
process.exit(1);
|
|
2346
|
+
}
|
|
2347
|
+
const raw = fs9.readFileSync(manifestPath, "utf8");
|
|
2348
|
+
let manifest2;
|
|
2349
|
+
try {
|
|
2350
|
+
manifest2 = JSON.parse(raw);
|
|
2351
|
+
} catch {
|
|
2352
|
+
console.error(
|
|
2353
|
+
`\u274C Invalid JSON in manifest file: ${options.manifest}`
|
|
2354
|
+
);
|
|
2355
|
+
process.exit(1);
|
|
2356
|
+
}
|
|
2357
|
+
if (manifest2.package !== pkg || manifest2.appVersion !== version2) {
|
|
2358
|
+
console.error(
|
|
2359
|
+
`\u274C Manifest package/version (${manifest2.package}@${manifest2.appVersion}) does not match command args (${pkg}@${version2}).`
|
|
2360
|
+
);
|
|
2361
|
+
process.exit(1);
|
|
2362
|
+
}
|
|
2363
|
+
const res2 = await fetch(bundleUrl, {
|
|
2364
|
+
method: "PATCH",
|
|
2365
|
+
headers,
|
|
2366
|
+
body: JSON.stringify(manifest2)
|
|
2367
|
+
});
|
|
2368
|
+
const text = await res2.text();
|
|
2369
|
+
let body;
|
|
2370
|
+
try {
|
|
2371
|
+
body = JSON.parse(text);
|
|
2372
|
+
} catch {
|
|
2373
|
+
body = { message: text };
|
|
2374
|
+
}
|
|
2375
|
+
if (res2.ok) {
|
|
2376
|
+
console.log("\u2705 Bundle metadata updated.");
|
|
2377
|
+
console.log(` Package: ${body.package || pkg}`);
|
|
2378
|
+
console.log(` Version: ${body.version || version2}`);
|
|
2379
|
+
} else {
|
|
2380
|
+
console.error(
|
|
2381
|
+
`\u274C PATCH failed (${res2.status}): ${body.error ?? body.message ?? text}`
|
|
2382
|
+
);
|
|
2383
|
+
process.exit(1);
|
|
2384
|
+
}
|
|
2385
|
+
return;
|
|
2386
|
+
}
|
|
2387
|
+
const res = await fetch(bundleUrl, { method: "GET", headers });
|
|
2388
|
+
if (!res.ok) {
|
|
2389
|
+
const t2 = await res.text();
|
|
2390
|
+
let err;
|
|
2391
|
+
try {
|
|
2392
|
+
err = JSON.parse(t2);
|
|
2393
|
+
} catch {
|
|
2394
|
+
err = { message: t2 };
|
|
2395
|
+
}
|
|
2396
|
+
console.error(
|
|
2397
|
+
`\u274C GET failed (${res.status}): ${err.error ?? err.message ?? t2}`
|
|
2398
|
+
);
|
|
2399
|
+
process.exit(1);
|
|
2400
|
+
}
|
|
2401
|
+
const manifest = await res.json();
|
|
2402
|
+
if (manifest.package !== pkg || manifest.appVersion !== version2) {
|
|
2403
|
+
console.error(
|
|
2404
|
+
"\u274C Response manifest package/version does not match URL."
|
|
2405
|
+
);
|
|
2406
|
+
process.exit(1);
|
|
2407
|
+
}
|
|
2408
|
+
if (options.name !== void 0) {
|
|
2409
|
+
if (!manifest.metadata)
|
|
2410
|
+
manifest.metadata = { name: "", description: "", author: "" };
|
|
2411
|
+
manifest.metadata.name = options.name;
|
|
2412
|
+
}
|
|
2413
|
+
if (options.description !== void 0) {
|
|
2414
|
+
if (!manifest.metadata)
|
|
2415
|
+
manifest.metadata = { name: "", description: "", author: "" };
|
|
2416
|
+
manifest.metadata.description = options.description;
|
|
2417
|
+
}
|
|
2418
|
+
if (options.author !== void 0) {
|
|
2419
|
+
if (!manifest.metadata)
|
|
2420
|
+
manifest.metadata = { name: "", description: "", author: "" };
|
|
2421
|
+
manifest.metadata.author = options.author;
|
|
2422
|
+
}
|
|
2423
|
+
if (options.frontend !== void 0) {
|
|
2424
|
+
if (!manifest.links) manifest.links = {};
|
|
2425
|
+
manifest.links.frontend = options.frontend;
|
|
2426
|
+
}
|
|
2427
|
+
if (options.github !== void 0) {
|
|
2428
|
+
if (!manifest.links) manifest.links = {};
|
|
2429
|
+
manifest.links.github = options.github;
|
|
2430
|
+
}
|
|
2431
|
+
if (options.docs !== void 0) {
|
|
2432
|
+
if (!manifest.links) manifest.links = {};
|
|
2433
|
+
manifest.links.docs = options.docs;
|
|
2434
|
+
}
|
|
2435
|
+
const outputPath = path7.resolve(options.output || "manifest.json");
|
|
2436
|
+
fs9.writeFileSync(outputPath, JSON.stringify(manifest, null, 2));
|
|
2437
|
+
console.log(`\u2705 Wrote modified manifest to: ${outputPath}`);
|
|
2438
|
+
console.log("");
|
|
2439
|
+
console.log("Next steps:");
|
|
2440
|
+
console.log(" 1. Sign the manifest with mero-sign:");
|
|
2441
|
+
console.log(` mero-sign sign ${outputPath} --key your-key.json`);
|
|
2442
|
+
console.log(" 2. PATCH the signed manifest:");
|
|
2443
|
+
console.log(
|
|
2444
|
+
` calimero-registry bundle edit '${pkg}' '${version2}' --remote --manifest signed-manifest.json`
|
|
2445
|
+
);
|
|
2446
|
+
} catch (error) {
|
|
2447
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
2448
|
+
console.error("\u274C Edit failed:", message);
|
|
2449
|
+
process.exit(1);
|
|
2450
|
+
}
|
|
2451
|
+
});
|
|
2452
|
+
}
|
|
2301
2453
|
async function pushToRemote(bundlePath, manifest, registryUrl, apiKey) {
|
|
2302
2454
|
try {
|
|
2303
2455
|
console.log(`\u{1F4E4} Pushing to remote registry: ${registryUrl}`);
|
|
@@ -2322,12 +2474,10 @@ async function pushToRemote(bundlePath, manifest, registryUrl, apiKey) {
|
|
|
2322
2474
|
if (manifest.wasm) {
|
|
2323
2475
|
payload.wasm = manifest.wasm;
|
|
2324
2476
|
}
|
|
2325
|
-
if (manifest.abi) {
|
|
2477
|
+
if (manifest.abi !== void 0) {
|
|
2326
2478
|
payload.abi = manifest.abi;
|
|
2327
2479
|
}
|
|
2328
|
-
|
|
2329
|
-
payload.migrations = manifest.migrations;
|
|
2330
|
-
}
|
|
2480
|
+
payload.migrations = manifest.migrations ?? [];
|
|
2331
2481
|
if (manifest.links) {
|
|
2332
2482
|
payload.links = manifest.links;
|
|
2333
2483
|
}
|
|
@@ -2337,6 +2487,9 @@ async function pushToRemote(bundlePath, manifest, registryUrl, apiKey) {
|
|
|
2337
2487
|
if (manifest.minRuntimeVersion != null && String(manifest.minRuntimeVersion).trim()) {
|
|
2338
2488
|
payload.minRuntimeVersion = String(manifest.minRuntimeVersion).trim();
|
|
2339
2489
|
}
|
|
2490
|
+
if (manifest.signerId) {
|
|
2491
|
+
payload.signerId = manifest.signerId;
|
|
2492
|
+
}
|
|
2340
2493
|
const headers = {
|
|
2341
2494
|
"Content-Type": "application/json"
|
|
2342
2495
|
};
|
|
@@ -2392,10 +2545,10 @@ async function pushToRemote(bundlePath, manifest, registryUrl, apiKey) {
|
|
|
2392
2545
|
throw error;
|
|
2393
2546
|
}
|
|
2394
2547
|
}
|
|
2395
|
-
async function verifyRemotePush(registryUrl, packageName,
|
|
2548
|
+
async function verifyRemotePush(registryUrl, packageName, version2) {
|
|
2396
2549
|
try {
|
|
2397
2550
|
console.log("\u{1F50D} Verifying upload to remote registry...");
|
|
2398
|
-
const verifyUrl = `${registryUrl.replace(/\/$/, "")}/api/v2/bundles/${packageName}/${
|
|
2551
|
+
const verifyUrl = `${registryUrl.replace(/\/$/, "")}/api/v2/bundles/${packageName}/${version2}`;
|
|
2399
2552
|
const controller = new AbortController();
|
|
2400
2553
|
const timeoutId = setTimeout(() => controller.abort(), 1e4);
|
|
2401
2554
|
try {
|
|
@@ -2660,10 +2813,12 @@ function createConfigResetCommand() {
|
|
|
2660
2813
|
}
|
|
2661
2814
|
|
|
2662
2815
|
// src/index.ts
|
|
2816
|
+
var require2 = createRequire(import.meta.url);
|
|
2817
|
+
var { version } = require2("../package.json");
|
|
2663
2818
|
var program = new Command();
|
|
2664
2819
|
program.name("calimero-registry").description(
|
|
2665
2820
|
"Calimero Network App Registry CLI - Command-line interface for the App Registry"
|
|
2666
|
-
).version(
|
|
2821
|
+
).version(version);
|
|
2667
2822
|
program.addHelpText(
|
|
2668
2823
|
"after",
|
|
2669
2824
|
`
|