@pmate/cli 0.45.0 → 0.45.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/README.md CHANGED
@@ -4,7 +4,7 @@ A TypeScript-powered command-line tool scaffold for future pMate automation.
4
4
 
5
5
  ## Deploy from an isolated checkout
6
6
 
7
- Vite deployments reject `--cwd`. They use the registered repository's conventional local checkout (`~/dev/pmate/<repository>`), refuse any uncommitted changes (including untracked files), fetch the latest GitHub `main`, switch to `main` and fast-forward to that exact revision. A missing remote `main`, failed switch/fetch, or local main with unpushed/divergent commits aborts before dependency installation, build or upload. No changes are stashed, reset or discarded. Dependencies are installed with `pnpm install --frozen-lockfile`; the deployed commit SHA is printed. Commit and push changes to `main` before deploying.
7
+ Vite deployments reject `--cwd`. They use a dedicated checkout at `~/.pmate/service-deploy/repos/<owner>/<repo>`, automatically cloning the registered repository on first deployment. This directory is independent of the current directory and development checkouts. They, refuse any uncommitted changes (including untracked files), fetch the latest GitHub `main`, switch to `main` and fast-forward to that exact revision. A missing remote `main`, failed switch/fetch, or local main with unpushed/divergent commits aborts before dependency installation, build or upload. No changes are stashed, reset or discarded. Dependencies are installed with `pnpm install --frozen-lockfile`; the deployed commit SHA is printed. Commit and push changes to `main` before deploying.
8
8
 
9
9
  Static and FC services can be released without modifying the conventional `~/dev/pmate` checkout. Use `pmate service deploy pmate:<service> --env prod --cwd /absolute/path/to/repo` for static or FC services. The registered service directory is resolved relative to that repository root; `--cwd` does not change the service's registered repository or environment.
10
10
 
package/dist/index.js CHANGED
@@ -132,11 +132,16 @@ function saveLoginSession(session, requestedApp = DEFAULT_APP_ID) {
132
132
  }
133
133
  function readRequiredSession(options) {
134
134
  const { sessionPath, store } = loadSessionStoreWithPath();
135
- const resolvedApp = resolveReadApp(store, options);
135
+ const boundApp = process.env.PMATE_SESSION_APP?.trim();
136
+ if (process.env.PMATE_EXPECTED_ACCOUNT_ID && !process.env.PMATE_SESSION_FILE?.trim()) throw new Error("Agent CLI requires a dedicated session file");
137
+ if (boundApp && options?.app && options.app !== boundApp) throw new Error("Agent CLI application differs from its bound session");
138
+ const resolvedApp = boundApp ? assertValidAppRef(boundApp) : resolveReadApp(store, options);
136
139
  const session = store.sessions[resolvedApp];
137
140
  if (!session) {
138
141
  throw new Error(buildMissingSessionMessage(sessionPath, resolvedApp));
139
142
  }
143
+ if (process.env.PMATE_EXPECTED_ACCOUNT_ID && session.accountId !== process.env.PMATE_EXPECTED_ACCOUNT_ID) throw new Error("Agent CLI Account mismatch");
144
+ if (process.env.PMATE_EXPECTED_PROFILE_ID && session.profileId !== process.env.PMATE_EXPECTED_PROFILE_ID) throw new Error("Agent CLI Profile mismatch");
140
145
  const token = session.token?.trim();
141
146
  if (!token) {
142
147
  throw new Error(
@@ -20165,7 +20170,7 @@ var ServiceRuntimeRunner = class {
20165
20170
  }
20166
20171
  async deployVite(service, options) {
20167
20172
  this.assertDeployableStaticSite(service);
20168
- const repoRoot = this.resolveRepoRoot(service);
20173
+ const repoRoot = this.resolveViteDeployRoot(service);
20169
20174
  await this.checkoutViteMain(service, repoRoot);
20170
20175
  const appDir = this.resolveLocalDir(service, repoRoot);
20171
20176
  const packageJsonPath = import_node_path31.default.join(appDir, "package.json");
@@ -20195,6 +20200,13 @@ var ServiceRuntimeRunner = class {
20195
20200
  }
20196
20201
  await AliyunService.uploadDirectory(distDir, bucketName);
20197
20202
  }
20203
+ resolveViteDeployRoot(service) {
20204
+ const repository = this.getRepoStaticSite(service).repository.trim().replace(/\.git$/i, "");
20205
+ if (!/^[a-zA-Z0-9_-][a-zA-Z0-9_.-]*\/[a-zA-Z0-9_-][a-zA-Z0-9_.-]*$/.test(repository)) {
20206
+ throw new Error(`Invalid repository: ${repository}; expected owner/name`);
20207
+ }
20208
+ return import_node_path31.default.join(import_node_os14.default.homedir(), ".pmate", "service-deploy", "repos", repository.toLowerCase());
20209
+ }
20198
20210
  async checkoutViteMain(service, repoRoot) {
20199
20211
  const repository = this.getRepoStaticSite(service).repository;
20200
20212
  const repoUrl = this.getRepoUrl(repository);
@@ -20205,6 +20217,11 @@ var ServiceRuntimeRunner = class {
20205
20217
  gitEnv.GIT_CONFIG_KEY_0 = "http.https://github.com/.extraheader";
20206
20218
  gitEnv.GIT_CONFIG_VALUE_0 = `Authorization: Basic ${Buffer.from(`x-access-token:${token}`).toString("base64")}`;
20207
20219
  }
20220
+ if (!(0, import_node_fs26.existsSync)(repoRoot)) {
20221
+ (0, import_node_fs26.mkdirSync)(import_node_path31.default.dirname(repoRoot), { recursive: true });
20222
+ await this.runCommandWithEnv("git", ["clone", "--branch", "main", "--single-branch", "--", repoUrl, repoRoot], import_node_path31.default.dirname(repoRoot), gitEnv);
20223
+ }
20224
+ ui.info(`Deployment checkout: ${repoRoot}`);
20208
20225
  ui.info(`Updating ${repository} to latest main for Vite deployment`);
20209
20226
  const script = [
20210
20227
  "set -eu",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/cli",
3
- "version": "0.45.0",
3
+ "version": "0.45.2",
4
4
  "description": "CLI utilities for the pMate project",
5
5
  "license": "MIT",
6
6
  "bin": {