@pmate/cli 0.48.0 → 0.48.2
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.d.ts +1 -0
- package/dist/index.js +50 -6
- package/dist/launcher.d.ts +1 -0
- package/dist/launcher.js +30164 -0
- package/dist/session-entry.d.ts +25 -0
- package/dist/session-entry.js +310 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -1163,6 +1163,7 @@ type LogsCommandArgs = {
|
|
|
1163
1163
|
type InstallCommandArgs = {
|
|
1164
1164
|
type: Command.Install;
|
|
1165
1165
|
package: string;
|
|
1166
|
+
staged?: boolean;
|
|
1166
1167
|
};
|
|
1167
1168
|
type CommandArgs = InstallCommandArgs | LogsCommandArgs | NoneCommandArgs | ListCommandArgs | LoginCommandArgs | AddDnsCommandArgs | StsCommandArgs | BucketCommandArgs | DeployCommandArgs | LogCommandArgs | InitCommandArgs | DeleteCommandArgs | DevCommandArgs | EnvCommandArgs | CommitCommandArgs | SummaryCommandArgs | QuizCommandArgs | ServiceCommandArgs | LinearCommandArgs | NotionCommandArgs | OssCommandArgs | QrcodeCommandArgs | RandomCommandArgs | CollectCommandArgs | ChatRoomCommandArgs | FunctionCommandArgs | WorkerCommandArgs | CallCommandArgs | NsCommandArgs | RoleCommandArgs | AccountCommandArgs | OrgCommandArgs | StoreCommandArgs | AppCommandArgs | VercelCommandArgs | HostCommandArgs;
|
|
1168
1169
|
|
package/dist/index.js
CHANGED
|
@@ -8989,7 +8989,7 @@ var PackageInstaller = class {
|
|
|
8989
8989
|
if (!response.ok || !body.success) throw Error(body.message ?? "Package registry unavailable");
|
|
8990
8990
|
return validateInstallMetadata(body.data, ref.id);
|
|
8991
8991
|
}
|
|
8992
|
-
async install(name) {
|
|
8992
|
+
async install(name, options = {}) {
|
|
8993
8993
|
const metadata = await this.metadata(name);
|
|
8994
8994
|
if (!metadata.platforms.includes(this.ports.platform ?? process.platform)) throw Error("Package is not supported on this platform");
|
|
8995
8995
|
(0, import_node_fs2.mkdirSync)(this.directory, { recursive: true, mode: 448 });
|
|
@@ -9002,11 +9002,54 @@ var PackageInstaller = class {
|
|
|
9002
9002
|
throw Error("Another package installation is running; inspect ~/.pmate/packages/install.lock");
|
|
9003
9003
|
}
|
|
9004
9004
|
try {
|
|
9005
|
-
|
|
9005
|
+
const old = this.records()[metadata.id];
|
|
9006
|
+
return options.staged || old?.root.startsWith(import_node_path2.default.join(this.directory, "releases") + import_node_path2.default.sep) ? await this.installStaged(metadata) : await this.installLocked(metadata);
|
|
9006
9007
|
} finally {
|
|
9007
9008
|
(0, import_node_fs2.rmSync)(lock, { recursive: true, force: true });
|
|
9008
9009
|
}
|
|
9009
9010
|
}
|
|
9011
|
+
/** Prepare a separate source tree, then switch command links. Never touch running processes. */
|
|
9012
|
+
async installStaged(metadata) {
|
|
9013
|
+
const records = this.records(), old = records[metadata.id];
|
|
9014
|
+
const root = import_node_path2.default.join(this.directory, "releases", ...metadata.repository.split("/"), metadata.name + "-" + metadata.version);
|
|
9015
|
+
(0, import_node_fs2.mkdirSync)(this.binDirectory, { recursive: true });
|
|
9016
|
+
for (const name of Object.keys(metadata.bins)) {
|
|
9017
|
+
const link = import_node_path2.default.join(this.binDirectory, name), stat = (0, import_node_fs2.lstatSync)(link, { throwIfNoEntry: false });
|
|
9018
|
+
if (stat && (!old?.bins[name] || !stat.isSymbolicLink() || (0, import_node_fs2.realpathSync)(link) !== (0, import_node_fs2.realpathSync)(old.bins[name]))) throw Error("Refusing to replace unmanaged command: " + name);
|
|
9019
|
+
}
|
|
9020
|
+
if (old?.version === metadata.version) {
|
|
9021
|
+
const manifest2 = JSON.parse((0, import_node_fs2.readFileSync)(this.local(old.root, import_node_path2.default.posix.join(metadata.directory, metadata.manifest)), "utf8"));
|
|
9022
|
+
if (manifest2.version !== old.version) throw Error("Installed manifest does not match the recorded version");
|
|
9023
|
+
for (const [name, file] of Object.entries(old.bins)) if (!(0, import_node_fs2.existsSync)(import_node_path2.default.join(this.binDirectory, name)) || (0, import_node_fs2.realpathSync)(import_node_path2.default.join(this.binDirectory, name)) !== (0, import_node_fs2.realpathSync)(file)) throw Error("Installed bin is missing or changed: " + name);
|
|
9024
|
+
return { ...old, changed: false };
|
|
9025
|
+
}
|
|
9026
|
+
if (old && old.version.split(".").map(BigInt).some((part, i, parts) => part > BigInt(metadata.version.split(".")[i]) && parts.slice(0, i).every((p, j) => p === BigInt(metadata.version.split(".")[j])))) throw Error("Published package version is older than the installed version");
|
|
9027
|
+
if ((0, import_node_fs2.existsSync)(root)) throw Error("Staged release directory already exists; inspect it before retrying");
|
|
9028
|
+
(0, import_node_fs2.mkdirSync)(import_node_path2.default.dirname(root), { recursive: true, mode: 448 });
|
|
9029
|
+
this.say("Preparing isolated release " + metadata.id + " " + metadata.version + "; running processes are unchanged");
|
|
9030
|
+
await this.execute("git", ["clone", "--branch", "main", "https://github.com/" + metadata.repository + ".git", root], import_node_path2.default.dirname(root));
|
|
9031
|
+
const manifest = JSON.parse((0, import_node_fs2.readFileSync)(this.local(root, import_node_path2.default.posix.join(metadata.directory, metadata.manifest)), "utf8"));
|
|
9032
|
+
if (manifest.version !== metadata.version) throw Error("Repository component version does not match the published package version");
|
|
9033
|
+
for (const step of metadata.prepare) await this.step(root, step);
|
|
9034
|
+
const bins = {};
|
|
9035
|
+
for (const [name, file] of Object.entries(metadata.bins)) {
|
|
9036
|
+
const target = this.local(root, file);
|
|
9037
|
+
if (!(0, import_node_fs2.lstatSync)(target).isFile()) throw Error("Package bin is not a regular file");
|
|
9038
|
+
(0, import_node_fs2.chmodSync)(target, 493);
|
|
9039
|
+
bins[name] = target;
|
|
9040
|
+
}
|
|
9041
|
+
const commit = await this.execute("git", ["rev-parse", "HEAD"], root);
|
|
9042
|
+
for (const [name, target] of Object.entries(bins)) {
|
|
9043
|
+
const link = import_node_path2.default.join(this.binDirectory, name), temporary = link + ".install-" + process.pid;
|
|
9044
|
+
(0, import_node_fs2.symlinkSync)(target, temporary);
|
|
9045
|
+
(0, import_node_fs2.renameSync)(temporary, link);
|
|
9046
|
+
}
|
|
9047
|
+
const record = { id: metadata.id, version: metadata.version, root, directory: metadata.directory, manifest: metadata.manifest, bins, metadataRevision: metadata.revision, commit, installedAt: (/* @__PURE__ */ new Date()).toISOString(), definition: metadata };
|
|
9048
|
+
records[metadata.id] = record;
|
|
9049
|
+
this.save(records);
|
|
9050
|
+
this.say("Installed " + metadata.id + " " + metadata.version + "; restart selected processes separately");
|
|
9051
|
+
return { ...record, changed: true };
|
|
9052
|
+
}
|
|
9010
9053
|
async installLocked(metadata) {
|
|
9011
9054
|
const records = this.records(), old = records[metadata.id], root = import_node_path2.default.join(this.directory, "repos", ...metadata.repository.split("/"));
|
|
9012
9055
|
(0, import_node_fs2.mkdirSync)(import_node_path2.default.dirname(root), { recursive: true, mode: 448 });
|
|
@@ -9118,8 +9161,9 @@ var PackageInstaller = class {
|
|
|
9118
9161
|
|
|
9119
9162
|
// src/installCommandParser.ts
|
|
9120
9163
|
function parseInstallArgs(args) {
|
|
9121
|
-
|
|
9122
|
-
|
|
9164
|
+
const staged = args.length === 2 && args[1] === "--staged";
|
|
9165
|
+
if (args.length !== 1 && !staged || !args[0] || args[0].startsWith("-")) throw Error("Usage: pmate install <package> [--staged]");
|
|
9166
|
+
return { type: "install" /* Install */, package: args[0], ...staged ? { staged: true } : {} };
|
|
9123
9167
|
}
|
|
9124
9168
|
|
|
9125
9169
|
// src/managedSession.ts
|
|
@@ -27559,7 +27603,7 @@ var HELP_TEXT = [
|
|
|
27559
27603
|
` ${import_chalk4.default.gray(" icon add <ns:objectId> <name> (--size <w>x<h>|--<w>x<h>) [--format <png|webp|svg|ico>] [--output <path>] [--force] [--base-url <url>] [--json]")}`,
|
|
27560
27604
|
` ${import_chalk4.default.gray(" delete <ns:objectId> [--base-url <url>] [--json]")}`,
|
|
27561
27605
|
` ${import_chalk4.default.gray(" default base URL: https://apps-api.pmate.chat")}`,
|
|
27562
|
-
` ${import_chalk4.default.cyan("install")} Install or update a managed source package: pmate install <package
|
|
27606
|
+
` ${import_chalk4.default.cyan("install")} Install or update a managed source package: pmate install <package> [--staged]`,
|
|
27563
27607
|
` ${import_chalk4.default.cyan("service")} Manage service registry entries via apps-api`,
|
|
27564
27608
|
" deploy <ns:service> [--env prod] [--cwd <repo>] [--dry-run] [--local] [--unsigned] [--platform mac|win] [--arch arm64|x64] [--config <file>] [--out-dir <dir>] [--scheme <name>] [--team <id>] [--variant release|debug] [--bump patch|minor|major]",
|
|
27565
27609
|
` ${import_chalk4.default.gray(" list [--namespace <ns>] [--repo <owner/name|https://github.com/owner/name>] [--server <name>] [--base-url <url>] [--json]")}`,
|
|
@@ -29339,7 +29383,7 @@ async function main() {
|
|
|
29339
29383
|
const commandArgs = parseCommandArgs(args);
|
|
29340
29384
|
switch (commandArgs.type) {
|
|
29341
29385
|
case "install" /* Install */: {
|
|
29342
|
-
await new PackageInstaller({ progress: (message) => ui.plain(message) }).install(commandArgs.package);
|
|
29386
|
+
await new PackageInstaller({ progress: (message) => ui.plain(message) }).install(commandArgs.package, { staged: commandArgs.staged });
|
|
29343
29387
|
return;
|
|
29344
29388
|
}
|
|
29345
29389
|
case "list" /* List */: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|