@pmate/cli 0.50.1 → 0.50.3
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 +2 -0
- package/dist/index.js +31 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -442,3 +442,5 @@ Nickname lookup requires `--app`; duplicate nicknames return candidates for sele
|
|
|
442
442
|
The response remains a JSON array with `account`, `profiles`, and `nickNames`. Basic account fields are `id`, `createdAt`, `kind`, and optional `name`; profiles contain only `id`, `app`, `account`, `userName`, `nickName`, `avatar`. Even self/root lookups omit mobile by default. `--include private` adds mobile only for self or platform `account:read`; phone-number search always requires that permission before lookup, plus explicit private inclusion. Inaccessible and absent basic targets both return an empty array.
|
|
443
443
|
|
|
444
444
|
Migration: callers relying on the old aggregated `roles`, `session`, full profiles or implicit mobile must use the appropriate resource API or explicitly request private fields. Account list and app-users remain privileged administration commands and retain their existing contracts. Deploy the updated auth API before using these CLI options.
|
|
445
|
+
|
|
446
|
+
For `ssh-pm2` environments, optional `runtime.cwd` is the dedicated remote repository checkout root (the service `dir` remains relative to it). Use a separate path per service/environment, for example `/home/pmate/.pmate/service-deploy/deneb-api-preview`. It must be an absolute path without traversal. This opt-in flow refuses dirty checkouts and fast-forwards to published `origin/main`; it never resets or cleans local edits. Environments without `runtime.cwd` retain their existing deployment behavior.
|
package/dist/index.js
CHANGED
|
@@ -20239,6 +20239,13 @@ var import_dotenv = require("dotenv");
|
|
|
20239
20239
|
|
|
20240
20240
|
// src/services/ServiceRegistryClient.ts
|
|
20241
20241
|
init_sessionStore();
|
|
20242
|
+
var ServiceRegistryHttpError = class extends Error {
|
|
20243
|
+
constructor(status, message) {
|
|
20244
|
+
super(message);
|
|
20245
|
+
this.status = status;
|
|
20246
|
+
this.name = "ServiceRegistryHttpError";
|
|
20247
|
+
}
|
|
20248
|
+
};
|
|
20242
20249
|
var ServiceRegistryNotFoundError = class extends Error {
|
|
20243
20250
|
constructor(namespace, name) {
|
|
20244
20251
|
super(`Service not found: ${namespace}/${name}`);
|
|
@@ -20456,7 +20463,7 @@ var ServiceRegistryClient = class {
|
|
|
20456
20463
|
);
|
|
20457
20464
|
}
|
|
20458
20465
|
if (!response.ok || !payload?.success || payload.data === void 0) {
|
|
20459
|
-
throw new
|
|
20466
|
+
throw new ServiceRegistryHttpError(response.status, payload?.message || `Request failed with status ${response.status}`);
|
|
20460
20467
|
}
|
|
20461
20468
|
return payload.data;
|
|
20462
20469
|
}
|
|
@@ -20484,7 +20491,7 @@ var ServiceRegistryClient = class {
|
|
|
20484
20491
|
);
|
|
20485
20492
|
}
|
|
20486
20493
|
if (!response.ok || !payload?.success || payload.data === void 0) {
|
|
20487
|
-
throw new
|
|
20494
|
+
throw new ServiceRegistryHttpError(response.status, payload?.message || `Request failed with status ${response.status}`);
|
|
20488
20495
|
}
|
|
20489
20496
|
return payload.data;
|
|
20490
20497
|
}
|
|
@@ -21000,10 +21007,14 @@ var ServiceRuntimeRunner = class {
|
|
|
21000
21007
|
if (!appDir) {
|
|
21001
21008
|
throw new Error(`Missing network.dir for ${service.id}`);
|
|
21002
21009
|
}
|
|
21003
|
-
const
|
|
21010
|
+
const checkoutDir = network.checkoutDir;
|
|
21011
|
+
if (checkoutDir && (!/^\/[a-zA-Z0-9_./-]+$/.test(checkoutDir) || checkoutDir.split("/").some((part) => part === ".." || part === ".") || checkoutDir.split("/").filter(Boolean).length < 3)) {
|
|
21012
|
+
throw new Error("runtime.cwd for ssh-pm2 requires a dedicated absolute checkout directory");
|
|
21013
|
+
}
|
|
21014
|
+
const repoDir = checkoutDir || this.getRepoDirName(repository);
|
|
21004
21015
|
const repoUrl = this.getRepoUrl(repository);
|
|
21005
21016
|
const gitUrl = this.withToken(repoUrl);
|
|
21006
|
-
const envSyncCommand = await this.buildNodeEnvSyncCommand(service.id, appDir, options.envName, server);
|
|
21017
|
+
const envSyncCommand = await this.buildNodeEnvSyncCommand(service.id, appDir, options.envName, server, !checkoutDir);
|
|
21007
21018
|
const envPrefix = envSyncCommand ? 'PMATE_SERVICE_ENV_FILE="$env_file" ' : "";
|
|
21008
21019
|
const pm2Start = port ? `if ! pm2 describe "${service.name}" >/dev/null 2>&1; then ${envPrefix}PORT=${port} pm2 start "$eco" --only "${service.name}"; fi` : `if ! pm2 describe "${service.name}" >/dev/null 2>&1; then ${envPrefix}pm2 start "$eco" --only "${service.name}"; fi`;
|
|
21009
21020
|
const pm2Reload = port ? `${envPrefix}PORT=${port} pm2 reload "$eco" --only "${service.name}" --update-env` : `${envPrefix}pm2 reload "$eco" --only "${service.name}" --update-env`;
|
|
@@ -21013,12 +21024,21 @@ var ServiceRuntimeRunner = class {
|
|
|
21013
21024
|
].join("; ");
|
|
21014
21025
|
const command = [
|
|
21015
21026
|
`cd "$HOME"`,
|
|
21027
|
+
...checkoutDir ? [`mkdir -p ${shellQuote2(import_node_path33.default.posix.dirname(checkoutDir))}`, `test ! -L ${shellQuote2(checkoutDir)} || { echo 'Refusing symlink checkout' >&2; exit 1; }`] : [],
|
|
21016
21028
|
`[ -d "${repoDir}/.git" ] || git clone "${gitUrl}" "${repoDir}"`,
|
|
21017
21029
|
`cd "${repoDir}"`,
|
|
21018
21030
|
`if [ -f ~/.profile ]; then . ~/.profile; fi`,
|
|
21019
21031
|
`if [ -f ~/.bashrc ]; then . ~/.bashrc; fi`,
|
|
21020
|
-
|
|
21021
|
-
|
|
21032
|
+
...checkoutDir ? [
|
|
21033
|
+
`test -z "$(git status --porcelain)" || { echo 'Dedicated checkout has local changes; refusing to discard them' >&2; exit 1; }`,
|
|
21034
|
+
`git fetch origin main`,
|
|
21035
|
+
`git switch main`,
|
|
21036
|
+
`git merge --ff-only origin/main`,
|
|
21037
|
+
`test "$(git rev-parse HEAD)" = "$(git rev-parse origin/main)" || { echo 'Dedicated checkout has unpublished commits' >&2; exit 1; }`
|
|
21038
|
+
] : [
|
|
21039
|
+
`if [ -n "$(git status --porcelain)" ]; then git reset --hard HEAD; git clean -fd; fi`,
|
|
21040
|
+
`git pull --rebase`
|
|
21041
|
+
],
|
|
21022
21042
|
`pnpm install`,
|
|
21023
21043
|
...envSyncCommand ? [envSyncCommand] : [],
|
|
21024
21044
|
`{ ${buildIfNeeded}; }`,
|
|
@@ -21028,7 +21048,7 @@ var ServiceRuntimeRunner = class {
|
|
|
21028
21048
|
].join(" && ");
|
|
21029
21049
|
await this.runRemoteCommand(server, command);
|
|
21030
21050
|
}
|
|
21031
|
-
async buildNodeEnvSyncCommand(serviceId, appDir, envName = "prod", hostTarget) {
|
|
21051
|
+
async buildNodeEnvSyncCommand(serviceId, appDir, envName = "prod", hostTarget, includeHost = true) {
|
|
21032
21052
|
if (!this.envProvider) {
|
|
21033
21053
|
return void 0;
|
|
21034
21054
|
}
|
|
@@ -21037,7 +21057,8 @@ var ServiceRuntimeRunner = class {
|
|
|
21037
21057
|
pulled = await this.envProvider(serviceId, {
|
|
21038
21058
|
stage: this.envNameToStage(envName),
|
|
21039
21059
|
format: "dotenv",
|
|
21040
|
-
...hostTarget ? { hostTarget } : {}
|
|
21060
|
+
...hostTarget ? { hostTarget } : {},
|
|
21061
|
+
...includeHost ? {} : { includeHost: false }
|
|
21041
21062
|
});
|
|
21042
21063
|
} catch (error) {
|
|
21043
21064
|
if (error instanceof ServiceEnvNotFoundError) {
|
|
@@ -22515,6 +22536,7 @@ var ServiceCommandHandler = class {
|
|
|
22515
22536
|
exposeType: env.network?.type === "websocket" ? "websocket" : env.network?.type === "mixed" ? "mixed" : env.network ? "rest" : "internal",
|
|
22516
22537
|
repository,
|
|
22517
22538
|
dir,
|
|
22539
|
+
...runtime.cwd?.trim() ? { checkoutDir: runtime.cwd.trim() } : {},
|
|
22518
22540
|
server: requireString(runtime.server, `runtime.server for ${service.id} ${env.name}`),
|
|
22519
22541
|
...runtime.port !== void 0 ? { port: runtime.port } : {},
|
|
22520
22542
|
...splitPrimaryDomain(env.network?.domain)
|
|
@@ -23210,6 +23232,7 @@ function splitPrimaryDomain(host) {
|
|
|
23210
23232
|
};
|
|
23211
23233
|
}
|
|
23212
23234
|
function shouldRetryDeployHistoryAppend(error) {
|
|
23235
|
+
if (error instanceof ServiceRegistryHttpError) return [502, 503, 504].includes(error.status);
|
|
23213
23236
|
const message = error instanceof Error ? error.message : String(error);
|
|
23214
23237
|
return message.includes("status 502") || message.includes("status 503") || message.includes("status 504") || message.includes("fetch failed") || message.includes("ECONNRESET") || message.includes("ETIMEDOUT");
|
|
23215
23238
|
}
|