@pmate/cli 0.24.2 → 0.24.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.
Files changed (2) hide show
  1. package/dist/index.js +43 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -10178,7 +10178,7 @@ var AliyunService = class {
10178
10178
  const routeIndex = routes.findIndex((item) => item?.path === route.path);
10179
10179
  if (routeIndex >= 0) {
10180
10180
  const current = routes[routeIndex];
10181
- if (current?.functionName === route.functionName && (current?.qualifier || "LATEST") === route.qualifier) {
10181
+ if (current?.functionName === route.functionName && (current?.qualifier || "LATEST") === route.qualifier && !input.certConfig && (existing?.protocol || "HTTP") === (input.protocol ?? existing?.protocol ?? "HTTP")) {
10182
10182
  ui.success(`FC custom domain route already exists: ${input.domainName}${route.path}`);
10183
10183
  return;
10184
10184
  }
@@ -10191,6 +10191,9 @@ var AliyunService = class {
10191
10191
  new import_fc20230330.UpdateCustomDomainRequest({
10192
10192
  body: new import_fc20230330.UpdateCustomDomainInput({
10193
10193
  protocol: input.protocol ?? existing?.protocol ?? "HTTP",
10194
+ ...input.certConfig ? {
10195
+ certConfig: new import_fc20230330.CertConfig(input.certConfig)
10196
+ } : {},
10194
10197
  routeConfig: new import_fc20230330.RouteConfig({ routes })
10195
10198
  })
10196
10199
  })
@@ -10206,7 +10209,10 @@ var AliyunService = class {
10206
10209
  new import_fc20230330.CreateCustomDomainRequest({
10207
10210
  body: new import_fc20230330.CreateCustomDomainInput({
10208
10211
  domainName: input.domainName,
10209
- protocol: input.protocol ?? "HTTP",
10212
+ protocol: input.protocol ?? (input.certConfig ? "HTTP,HTTPS" : "HTTP"),
10213
+ ...input.certConfig ? {
10214
+ certConfig: new import_fc20230330.CertConfig(input.certConfig)
10215
+ } : {},
10210
10216
  authConfig: new import_fc20230330.AuthConfig({ authType: "anonymous", authInfo: "{}" }),
10211
10217
  routeConfig: new import_fc20230330.RouteConfig({ routes: [route] })
10212
10218
  })
@@ -18562,13 +18568,15 @@ var ServiceRuntimeRunner = class {
18562
18568
  });
18563
18569
  ui.success(`Added CNAME ${host} -> ${cnameTarget}`);
18564
18570
  }
18571
+ const certConfig = this.resolveFcCertConfig(host);
18565
18572
  await AliyunService.ensureFcCustomDomain({
18566
18573
  domainName: host,
18567
18574
  region: fc.region,
18568
18575
  functionName: fc.functionName,
18569
18576
  routePath: fc.routePath,
18570
- protocol: fc.protocol,
18571
- qualifier: fc.qualifier
18577
+ protocol: this.resolveFcProtocol(fc, certConfig),
18578
+ qualifier: fc.qualifier,
18579
+ certConfig
18572
18580
  });
18573
18581
  }
18574
18582
  ui.success(`Initialized FC service ${service.id}`, {
@@ -19322,6 +19330,37 @@ var ServiceRuntimeRunner = class {
19322
19330
  normalizeDnsValue(value) {
19323
19331
  return value.trim().replace(/\.$/, "").toLowerCase();
19324
19332
  }
19333
+ resolveFcCertConfig(host) {
19334
+ const config = loadPmateConfig();
19335
+ const certificatePath = config.ssl?.pub?.trim();
19336
+ const privateKeyPath = config.ssl?.prv?.trim();
19337
+ if (!certificatePath && !privateKeyPath) {
19338
+ return void 0;
19339
+ }
19340
+ if (!certificatePath) {
19341
+ throw new Error("Missing ssl.pub in ~/.pmate/config.yaml.");
19342
+ }
19343
+ if (!privateKeyPath) {
19344
+ throw new Error("Missing ssl.prv in ~/.pmate/config.yaml.");
19345
+ }
19346
+ if (!(0, import_node_fs17.existsSync)(certificatePath)) {
19347
+ throw new Error(`SSL certificate file not found: ${certificatePath}`);
19348
+ }
19349
+ if (!(0, import_node_fs17.existsSync)(privateKeyPath)) {
19350
+ throw new Error(`SSL private key file not found: ${privateKeyPath}`);
19351
+ }
19352
+ return {
19353
+ certName: host,
19354
+ certificate: (0, import_node_fs17.readFileSync)(certificatePath, "utf8"),
19355
+ privateKey: (0, import_node_fs17.readFileSync)(privateKeyPath, "utf8")
19356
+ };
19357
+ }
19358
+ resolveFcProtocol(fc, certConfig) {
19359
+ if (!certConfig) {
19360
+ return fc.protocol;
19361
+ }
19362
+ return fc.protocol === "HTTPS" ? "HTTPS" : "HTTP,HTTPS";
19363
+ }
19325
19364
  async resolveAliyunDeploymentEnv() {
19326
19365
  const config = loadPmateConfig();
19327
19366
  const accessKeyId = config.aliyun?.ak?.trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/cli",
3
- "version": "0.24.2",
3
+ "version": "0.24.3",
4
4
  "description": "CLI utilities for the pMate project",
5
5
  "license": "MIT",
6
6
  "bin": {