@verentis/cli 0.2.23 → 0.2.24
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 +3 -0
- package/dist/index.js +41 -14
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -252,6 +252,9 @@ verentis yank my-app 1.0.3
|
|
|
252
252
|
|
|
253
253
|
Published versions are `Submitted` for moderation; once approved the marketplace countersigns them and they become installable.
|
|
254
254
|
|
|
255
|
+
`verentis install` replaces an existing installation of the same package in the workspace branch in place, like the
|
|
256
|
+
marketplace install dialog. This upgrades or reinstalls an installed package and retries a `Failed` installation.
|
|
257
|
+
|
|
255
258
|
### Publisher publishing from GitHub Actions
|
|
256
259
|
|
|
257
260
|
Register a GitHub federated credential on your publisher in each target Verentis
|
package/dist/index.js
CHANGED
|
@@ -388,7 +388,6 @@ var SCOPES = {
|
|
|
388
388
|
packageCreate: "marketplace.package.create",
|
|
389
389
|
packagePublish: "marketplace.package.publish",
|
|
390
390
|
installCreate: "marketplace.install.create",
|
|
391
|
-
installDelete: "marketplace.install.delete",
|
|
392
391
|
resourceReadAll: "resources.resource.read-all",
|
|
393
392
|
resourceUpdate: "resources.resource.update"
|
|
394
393
|
};
|
|
@@ -447,7 +446,9 @@ var EXECUTION = {
|
|
|
447
446
|
run: "execution.execution.run"
|
|
448
447
|
};
|
|
449
448
|
var MARKETPLACE = {
|
|
449
|
+
installDelete: "marketplace.install.delete",
|
|
450
450
|
installRead: "marketplace.install.read",
|
|
451
|
+
installUpdate: "marketplace.install.update",
|
|
451
452
|
packageDelete: "marketplace.package.delete",
|
|
452
453
|
packageRead: "marketplace.package.read",
|
|
453
454
|
packageUpdate: "marketplace.package.update",
|
|
@@ -558,7 +559,9 @@ var marketplace = {
|
|
|
558
559
|
grantVisibility: e({ method: "POST", path: "/v1/packages/{packageId}/visibility-grants", scopes: [MARKETPLACE.packageVisibilityManage] }),
|
|
559
560
|
revokeVisibility: e({ method: "DELETE", path: "/v1/packages/{packageId}/visibility-grants/{grantId}", scopes: [MARKETPLACE.packageVisibilityManage] }),
|
|
560
561
|
getPackageStats: e({ method: "GET", path: "/v1/packages/{packageId}/stats", scopes: [MARKETPLACE.statsRead] }),
|
|
561
|
-
listInstallations: e({ method: "GET", path: "/v1/installations", scopes: [MARKETPLACE.installRead], paged: true })
|
|
562
|
+
listInstallations: e({ method: "GET", path: "/v1/installations", scopes: [MARKETPLACE.installRead], paged: true }),
|
|
563
|
+
uninstall: e({ method: "DELETE", path: "/v1/installations/{id}", scopes: [MARKETPLACE.installDelete, NODE.fileDelete, NODE.fileRead, NODE.nodeUpdate, NODE.journalCreate], workspaceBound: true })
|
|
564
|
+
};
|
|
562
565
|
|
|
563
566
|
// src/api/client.ts
|
|
564
567
|
function fillPath(template, params = {}) {
|
|
@@ -3548,20 +3551,37 @@ function registerRegistry(program2) {
|
|
|
3548
3551
|
console.log(`${pkg.publisherName}/${pkg.packageId}${version} \u2014 ${pkg.displayName} [${pkg.kind}, ${pkg.visibility.toLowerCase()}]`);
|
|
3549
3552
|
}
|
|
3550
3553
|
});
|
|
3551
|
-
program2.command("install <ref> [version]").description("Install a package into a workspace").option("--workspace <workspaceId>", "target workspace (default: configured default workspace)").option("--path <path>", "install path override (bundles)").option("--branch <branch>", "workspace branch", "main").option("--sealed", "install as a sealed tarball instead of extracting").action(async (ref, version, options) => {
|
|
3554
|
+
program2.command("install <ref> [version]").description("Install a package into a workspace (replaces an existing or failed installation of the same package in place)").option("--workspace <workspaceId>", "target workspace (default: configured default workspace)").option("--path <path>", "install path override (bundles)").option("--branch <branch>", "workspace branch", "main").option("--sealed", "install as a sealed tarball instead of extracting").action(async (ref, version, options) => {
|
|
3552
3555
|
const config = await loadConfig();
|
|
3553
3556
|
const workspaceId = options.workspace ?? config.defaultWorkspaceId;
|
|
3554
3557
|
if (!workspaceId) throw new Error("No workspace: pass --workspace <id> or set defaultWorkspaceId in ~/.verentis/config.json.");
|
|
3555
3558
|
const api = await createApiClient();
|
|
3556
3559
|
const { package: pkg } = await resolvePackageRef(api, ref);
|
|
3560
|
+
const consentScopes = pkg.kind === "Application" ? [SCOPES.resourceReadAll, SCOPES.resourceUpdate] : [];
|
|
3561
|
+
const existing = await findActiveInstallation(api, workspaceId, pkg.id, options.branch);
|
|
3562
|
+
if (existing) {
|
|
3563
|
+
if (options.path && existing.installPath && options.path !== existing.installPath) {
|
|
3564
|
+
throw new Error(`${ref} is already installed at '${existing.installPath}' (installation ${existing.id}). Uninstall it before installing at '${options.path}'.`);
|
|
3565
|
+
}
|
|
3566
|
+
const result = await api.request("PUT", `/v1/installations/${existing.id}`, {
|
|
3567
|
+
scopes: [MARKETPLACE.installUpdate, NODE.fileDelete, ...INSTALL_NODE_SCOPES, ...consentScopes],
|
|
3568
|
+
tokenWorkspaceId: workspaceId,
|
|
3569
|
+
body: {
|
|
3570
|
+
id: existing.id,
|
|
3571
|
+
workspaceId,
|
|
3572
|
+
packageVersion: version ?? void 0,
|
|
3573
|
+
installMode: options.sealed ? "Sealed" : existing.installMode ?? "Extracted"
|
|
3574
|
+
}
|
|
3575
|
+
});
|
|
3576
|
+
if (result && result.succeeded === false) {
|
|
3577
|
+
throw new Error(`Reinstall of ${ref} failed (installation ${existing.id}, status ${result.status}): ${result.error ?? "unknown error"}`);
|
|
3578
|
+
}
|
|
3579
|
+
const from = existing.status === "Failed" ? "failed installation" : "installation";
|
|
3580
|
+
console.log(`Replaced ${from} ${existing.id} with ${ref}${version ? `@${version}` : ""} in workspace ${workspaceId} (${result?.status ?? "Installed"}).`);
|
|
3581
|
+
return;
|
|
3582
|
+
}
|
|
3557
3583
|
const installationId = await api.request("POST", "/v1/installations", {
|
|
3558
|
-
|
|
3559
|
-
// and to Resource for the administrator's consent decision.
|
|
3560
|
-
scopes: [
|
|
3561
|
-
SCOPES.installCreate,
|
|
3562
|
-
"node.node.create",
|
|
3563
|
-
...pkg.kind === "Application" ? [SCOPES.resourceReadAll, SCOPES.resourceUpdate] : []
|
|
3564
|
-
],
|
|
3584
|
+
scopes: [SCOPES.installCreate, ...INSTALL_NODE_SCOPES, ...consentScopes],
|
|
3565
3585
|
tokenWorkspaceId: workspaceId,
|
|
3566
3586
|
body: {
|
|
3567
3587
|
workspaceId,
|
|
@@ -3576,14 +3596,21 @@ function registerRegistry(program2) {
|
|
|
3576
3596
|
});
|
|
3577
3597
|
program2.command("uninstall <installationId>").description("Uninstall a package from a workspace").requiredOption("--workspace <workspaceId>", "the workspace the installation belongs to").action(async (installationId, options) => {
|
|
3578
3598
|
const api = await createApiClient();
|
|
3579
|
-
await api.
|
|
3580
|
-
|
|
3581
|
-
|
|
3582
|
-
|
|
3599
|
+
await call(api, marketplace.uninstall, {
|
|
3600
|
+
params: { id: installationId },
|
|
3601
|
+
query: { workspaceId: options.workspace },
|
|
3602
|
+
workspaceId: options.workspace
|
|
3583
3603
|
});
|
|
3584
3604
|
console.log(`Uninstalled ${installationId}.`);
|
|
3585
3605
|
});
|
|
3586
3606
|
}
|
|
3607
|
+
var INSTALL_NODE_SCOPES = [NODE.nodeCreate, NODE.fileRead, NODE.nodeUpdate, NODE.journalCreate];
|
|
3608
|
+
async function findActiveInstallation(api, workspaceId, packageId, branch) {
|
|
3609
|
+
const page = await call(api, marketplace.listInstallations, {
|
|
3610
|
+
query: { workspaceId, packageId, branch, pageNo: 1, pageSize: 100, orderBy: "createdAt desc" }
|
|
3611
|
+
});
|
|
3612
|
+
return pageItems(page).find((installation) => installation.status !== "Uninstalled") ?? null;
|
|
3613
|
+
}
|
|
3587
3614
|
|
|
3588
3615
|
// src/commands/settings.ts
|
|
3589
3616
|
async function settingScope(flags) {
|