@pmate/cli 0.24.33 → 0.24.35

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.
Files changed (2) hide show
  1. package/dist/index.js +30 -25
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -10591,9 +10591,13 @@ var AliyunService = class {
10591
10591
  const relativePath = import_node_path4.default.relative(localDir, filePath);
10592
10592
  const objectKey = this.toObjectKey(normalizedPrefix, relativePath);
10593
10593
  const contentType = this.getContentType(filePath);
10594
- const options = contentType ? { headers: { "Content-Type": contentType } } : void 0;
10594
+ const cacheControl = this.getStaticAssetCacheControl(relativePath);
10595
+ const headers = {};
10596
+ if (contentType) headers["Content-Type"] = contentType;
10597
+ if (cacheControl) headers["Cache-Control"] = cacheControl;
10598
+ const options = Object.keys(headers).length > 0 ? { headers } : void 0;
10595
10599
  const existing = existingMap.get(objectKey);
10596
- if (existing && typeof existing.size === "number") {
10600
+ if (existing && typeof existing.size === "number" && !cacheControl) {
10597
10601
  const stat = await import_node_fs3.promises.stat(filePath);
10598
10602
  if (stat.size === existing.size) {
10599
10603
  const etag = this.normalizeEtag(existing.etag);
@@ -10624,7 +10628,11 @@ var AliyunService = class {
10624
10628
  }
10625
10629
  const client = new import_ali_oss.default({ region, accessKeyId, accessKeySecret, bucket });
10626
10630
  const contentType = this.getContentType(localFile);
10627
- const options = contentType ? { headers: { "Content-Type": contentType } } : void 0;
10631
+ const cacheControl = this.getStaticAssetCacheControl(objectKey);
10632
+ const headers = {};
10633
+ if (contentType) headers["Content-Type"] = contentType;
10634
+ if (cacheControl) headers["Cache-Control"] = cacheControl;
10635
+ const options = Object.keys(headers).length > 0 ? { headers } : void 0;
10628
10636
  await client.put(objectKey, localFile, options);
10629
10637
  ui.success(`Uploaded ${objectKey}`);
10630
10638
  }
@@ -11061,6 +11069,17 @@ var AliyunService = class {
11061
11069
  return void 0;
11062
11070
  }
11063
11071
  }
11072
+ static getStaticAssetCacheControl(filePath) {
11073
+ const normalized = filePath.replace(/\\/g, "/");
11074
+ const base = import_node_path4.default.posix.basename(normalized).toLowerCase();
11075
+ if (base === "index.html" || base === "200.html" || base === "404.html") {
11076
+ return "no-cache, no-store, must-revalidate";
11077
+ }
11078
+ if (/[.-][a-z0-9_-]{8,}\./i.test(base)) {
11079
+ return "public, max-age=31536000, immutable";
11080
+ }
11081
+ return void 0;
11082
+ }
11064
11083
  static buildFcPathConfig(input) {
11065
11084
  return new import_fc20230330.PathConfig({
11066
11085
  path: input.routePath ?? "/*",
@@ -18558,10 +18577,7 @@ var ServiceRegistryClient = class {
18558
18577
  {
18559
18578
  stage: options.stage,
18560
18579
  ...options.branch ? { branch: options.branch } : {},
18561
- ...options.includeSecretValue ? { includeSecretValue: true } : {},
18562
- ...options.includeHost === false ? { includeHost: false } : {},
18563
- ...options.hostId ? { hostId: options.hostId } : {},
18564
- ...options.hostTarget ? { hostTarget: options.hostTarget } : {}
18580
+ ...options.includeSecretValue ? { includeSecretValue: true } : {}
18565
18581
  }
18566
18582
  );
18567
18583
  }
@@ -18601,9 +18617,6 @@ var ServiceRegistryClient = class {
18601
18617
  body: JSON.stringify({
18602
18618
  stage: options.stage,
18603
18619
  ...options.branch ? { branch: options.branch } : {},
18604
- ...options.includeHost === false ? { includeHost: false } : {},
18605
- ...options.hostId ? { hostId: options.hostId } : {},
18606
- ...options.hostTarget ? { hostTarget: options.hostTarget } : {},
18607
18620
  format: options.format
18608
18621
  })
18609
18622
  });
@@ -19124,7 +19137,7 @@ var ServiceRuntimeRunner = class {
19124
19137
  `pkg="${appDir}/package.json"`,
19125
19138
  `if [ -f "$pkg" ] && node -e 'const fs=require("node:fs"); const p=JSON.parse(fs.readFileSync(process.argv[1],"utf8")); process.exit(p?.scripts?.build ? 0 : 1);' "$pkg"; then (cd "${appDir}" && pnpm run build); fi`
19126
19139
  ].join("; ");
19127
- const envSyncCommand = await this.buildNodeEnvSyncCommand(service.id, appDir, options.envName, server);
19140
+ const envSyncCommand = await this.buildNodeEnvSyncCommand(service.id, appDir, options.envName);
19128
19141
  const command = [
19129
19142
  `cd "$HOME"`,
19130
19143
  `[ -d "${repoDir}/.git" ] || git clone "${gitUrl}" "${repoDir}"`,
@@ -19142,17 +19155,13 @@ var ServiceRuntimeRunner = class {
19142
19155
  ].join(" && ");
19143
19156
  await this.runRemoteCommand(server, command);
19144
19157
  }
19145
- async buildNodeEnvSyncCommand(serviceId, appDir, envName = "prod", hostTarget) {
19158
+ async buildNodeEnvSyncCommand(serviceId, appDir, envName = "prod") {
19146
19159
  if (!this.envProvider) {
19147
19160
  return void 0;
19148
19161
  }
19149
19162
  let pulled;
19150
19163
  try {
19151
- pulled = await this.envProvider(serviceId, {
19152
- stage: this.envNameToStage(envName),
19153
- format: "dotenv",
19154
- ...hostTarget ? { hostTarget } : {}
19155
- });
19164
+ pulled = await this.envProvider(serviceId, { stage: this.envNameToStage(envName), format: "dotenv" });
19156
19165
  } catch (error) {
19157
19166
  if (error instanceof ServiceEnvNotFoundError) {
19158
19167
  ui.warn(`No env found for ${serviceId}; skipping .env.local sync.`);
@@ -19193,7 +19202,7 @@ var ServiceRuntimeRunner = class {
19193
19202
  const gitUrl = this.withToken(repoUrl);
19194
19203
  const scriptPath = script.startsWith("/") || script.startsWith("./") ? script : `./${script}`;
19195
19204
  const envName = options.envName ?? "prod";
19196
- const envSyncCommand = await this.buildScriptEnvSyncCommand(service.id, envName, server);
19205
+ const envSyncCommand = await this.buildScriptEnvSyncCommand(service.id, envName);
19197
19206
  const command = [
19198
19207
  `cd "$HOME"`,
19199
19208
  `[ -d "${repoDir}/.git" ] || git clone "${gitUrl}" "${repoDir}"`,
@@ -19225,7 +19234,7 @@ var ServiceRuntimeRunner = class {
19225
19234
  const repoDir = this.getRepoDirName(repository);
19226
19235
  const scriptPath = script.startsWith("/") || script.startsWith("./") ? script : `./${script}`;
19227
19236
  const envName = options.envName ?? "prod";
19228
- const envSyncCommand = await this.buildScriptEnvSyncCommand(service.id, envName, server);
19237
+ const envSyncCommand = await this.buildScriptEnvSyncCommand(service.id, envName);
19229
19238
  const command = [
19230
19239
  `cd "$HOME"`,
19231
19240
  `cd "${repoDir}"`,
@@ -19236,17 +19245,13 @@ var ServiceRuntimeRunner = class {
19236
19245
  ].join(" && ");
19237
19246
  await this.runRemoteCommand(server, command);
19238
19247
  }
19239
- async buildScriptEnvSyncCommand(serviceId, envName, hostTarget) {
19248
+ async buildScriptEnvSyncCommand(serviceId, envName) {
19240
19249
  if (!this.envProvider) {
19241
19250
  return void 0;
19242
19251
  }
19243
19252
  let pulled;
19244
19253
  try {
19245
- pulled = await this.envProvider(serviceId, {
19246
- stage: this.envNameToStage(envName),
19247
- format: "dotenv",
19248
- ...hostTarget ? { hostTarget } : {}
19249
- });
19254
+ pulled = await this.envProvider(serviceId, { stage: this.envNameToStage(envName), format: "dotenv" });
19250
19255
  } catch (error) {
19251
19256
  if (error instanceof ServiceEnvNotFoundError) {
19252
19257
  ui.warn(`No env found for ${serviceId}; skipping PMate env file sync.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/cli",
3
- "version": "0.24.33",
3
+ "version": "0.24.35",
4
4
  "description": "CLI utilities for the pMate project",
5
5
  "license": "MIT",
6
6
  "bin": {