@pmate/cli 0.50.2 → 0.50.4
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 +4 -0
- package/dist/index.js +25 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -442,3 +442,7 @@ 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.
|
|
447
|
+
|
|
448
|
+
Registry versions that omit `runtime.cwd` for ssh-pm2 can select the same isolated checkout using an absolute `runtime.ecosystemFile`, ending in `/<service dir>/ecosystem.config.cjs`. The CLI derives the repository root from this exact suffix. Read back the registered environment before deployment; never assume a submitted optional field was retained.
|
package/dist/index.js
CHANGED
|
@@ -21007,10 +21007,14 @@ var ServiceRuntimeRunner = class {
|
|
|
21007
21007
|
if (!appDir) {
|
|
21008
21008
|
throw new Error(`Missing network.dir for ${service.id}`);
|
|
21009
21009
|
}
|
|
21010
|
-
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);
|
|
21011
21015
|
const repoUrl = this.getRepoUrl(repository);
|
|
21012
21016
|
const gitUrl = this.withToken(repoUrl);
|
|
21013
|
-
const envSyncCommand = await this.buildNodeEnvSyncCommand(service.id, appDir, options.envName, server);
|
|
21017
|
+
const envSyncCommand = await this.buildNodeEnvSyncCommand(service.id, appDir, options.envName, server, !checkoutDir);
|
|
21014
21018
|
const envPrefix = envSyncCommand ? 'PMATE_SERVICE_ENV_FILE="$env_file" ' : "";
|
|
21015
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`;
|
|
21016
21020
|
const pm2Reload = port ? `${envPrefix}PORT=${port} pm2 reload "$eco" --only "${service.name}" --update-env` : `${envPrefix}pm2 reload "$eco" --only "${service.name}" --update-env`;
|
|
@@ -21020,12 +21024,21 @@ var ServiceRuntimeRunner = class {
|
|
|
21020
21024
|
].join("; ");
|
|
21021
21025
|
const command = [
|
|
21022
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; }`] : [],
|
|
21023
21028
|
`[ -d "${repoDir}/.git" ] || git clone "${gitUrl}" "${repoDir}"`,
|
|
21024
21029
|
`cd "${repoDir}"`,
|
|
21025
21030
|
`if [ -f ~/.profile ]; then . ~/.profile; fi`,
|
|
21026
21031
|
`if [ -f ~/.bashrc ]; then . ~/.bashrc; fi`,
|
|
21027
|
-
|
|
21028
|
-
|
|
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
|
+
],
|
|
21029
21042
|
`pnpm install`,
|
|
21030
21043
|
...envSyncCommand ? [envSyncCommand] : [],
|
|
21031
21044
|
`{ ${buildIfNeeded}; }`,
|
|
@@ -21035,7 +21048,7 @@ var ServiceRuntimeRunner = class {
|
|
|
21035
21048
|
].join(" && ");
|
|
21036
21049
|
await this.runRemoteCommand(server, command);
|
|
21037
21050
|
}
|
|
21038
|
-
async buildNodeEnvSyncCommand(serviceId, appDir, envName = "prod", hostTarget) {
|
|
21051
|
+
async buildNodeEnvSyncCommand(serviceId, appDir, envName = "prod", hostTarget, includeHost = true) {
|
|
21039
21052
|
if (!this.envProvider) {
|
|
21040
21053
|
return void 0;
|
|
21041
21054
|
}
|
|
@@ -21044,7 +21057,8 @@ var ServiceRuntimeRunner = class {
|
|
|
21044
21057
|
pulled = await this.envProvider(serviceId, {
|
|
21045
21058
|
stage: this.envNameToStage(envName),
|
|
21046
21059
|
format: "dotenv",
|
|
21047
|
-
...hostTarget ? { hostTarget } : {}
|
|
21060
|
+
...hostTarget ? { hostTarget } : {},
|
|
21061
|
+
...includeHost ? {} : { includeHost: false }
|
|
21048
21062
|
});
|
|
21049
21063
|
} catch (error) {
|
|
21050
21064
|
if (error instanceof ServiceEnvNotFoundError) {
|
|
@@ -22512,6 +22526,10 @@ var ServiceCommandHandler = class {
|
|
|
22512
22526
|
};
|
|
22513
22527
|
}
|
|
22514
22528
|
if (runtime.type === "ssh-pm2") {
|
|
22529
|
+
const ecosystem = runtime.ecosystemFile?.trim();
|
|
22530
|
+
const suffix = `/${dir}/ecosystem.config.cjs`;
|
|
22531
|
+
const checkoutDir = runtime.cwd?.trim() || (ecosystem?.startsWith("/") && ecosystem.endsWith(suffix) ? ecosystem.slice(0, -suffix.length) : void 0);
|
|
22532
|
+
if (ecosystem?.startsWith("/") && !checkoutDir) throw new Error("Absolute ecosystemFile must match the service dir and ecosystem.config.cjs");
|
|
22515
22533
|
return {
|
|
22516
22534
|
id: service.id,
|
|
22517
22535
|
namespace: service.namespace,
|
|
@@ -22522,6 +22540,7 @@ var ServiceCommandHandler = class {
|
|
|
22522
22540
|
exposeType: env.network?.type === "websocket" ? "websocket" : env.network?.type === "mixed" ? "mixed" : env.network ? "rest" : "internal",
|
|
22523
22541
|
repository,
|
|
22524
22542
|
dir,
|
|
22543
|
+
...checkoutDir ? { checkoutDir } : {},
|
|
22525
22544
|
server: requireString(runtime.server, `runtime.server for ${service.id} ${env.name}`),
|
|
22526
22545
|
...runtime.port !== void 0 ? { port: runtime.port } : {},
|
|
22527
22546
|
...splitPrimaryDomain(env.network?.domain)
|