edgeone 1.0.13 → 1.0.14-beta.1

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/edgeone-dist/cli.js +34 -28
  2. package/package.json +1 -1
@@ -102539,7 +102539,7 @@ var yargs_default = Yargs;
102539
102539
  // package.json
102540
102540
  var package_default = {
102541
102541
  name: "edgeone",
102542
- version: "1.0.13",
102542
+ version: "1.0.14",
102543
102543
  description: "Command-line interface for TencentCloud Pages Functions",
102544
102544
  bin: {
102545
102545
  edgeone: "./edgeone-bin/edgeone.js"
@@ -113231,13 +113231,21 @@ var BuildFunctionGenerator = class {
113231
113231
 
113232
113232
  const params = {};
113233
113233
  if (routeParams.id) {
113234
- const value = urlInfo.pathname.replace(routeParams.left, '');
113235
- const splitedValue = value.split('/');
113236
- if (splitedValue.length === 1) {
113237
- params[routeParams.id] = splitedValue[0];
113234
+ if (routeParams.mode === 1) {
113235
+ const value = urlInfo.pathname.match(routeParams.left);
113236
+ for (let i = 1; i < value.length; i++) {
113237
+ params[routeParams.id[i - 1]] = value[i];
113238
+ }
113238
113239
  } else {
113239
- params[routeParams.id] = splitedValue;
113240
+ const value = urlInfo.pathname.replace(routeParams.left, '');
113241
+ const splitedValue = value.split('/');
113242
+ if (splitedValue.length === 1) {
113243
+ params[routeParams.id] = splitedValue[0];
113244
+ } else {
113245
+ params[routeParams.id] = splitedValue;
113246
+ }
113240
113247
  }
113248
+
113241
113249
  }
113242
113250
  if(!matchedFunc){
113243
113251
  pagesFunctionResponse = function() {
@@ -113308,7 +113316,6 @@ var BuildFunctionGenerator = class {
113308
113316
  return false;
113309
113317
  }
113310
113318
  matchPath(path9) {
113311
- const regex12 = /^\/(?:[^/]+\/)*\[(.+?)\]$/;
113312
113319
  const regex22 = /^\/(?:[^/]+\/)*\[\[(.+?)\]\]$/;
113313
113320
  if (regex22.test(path9) && path9.indexOf("[[") > -1) {
113314
113321
  const match = regex22.exec(path9);
@@ -113319,13 +113326,21 @@ var BuildFunctionGenerator = class {
113319
113326
  left: path9.replace(`[[${match[1]}]]`, "")
113320
113327
  };
113321
113328
  }
113322
- } else if (regex12.test(path9)) {
113323
- const match = regex12.exec(path9);
113329
+ } else if (regex1.test(path9)) {
113330
+ const match = regex1.exec(path9);
113331
+ const regex = /\[(.*?)\]/g;
113332
+ const matches = path9.match(regex);
113333
+ const parameters = matches.map((match2) => match2.slice(1, -1));
113334
+ let leftPart = JSON.parse(JSON.stringify(path9));
113335
+ parameters == null ? void 0 : parameters.forEach((item) => {
113336
+ leftPart = leftPart.replace(`[${item}]`, `([^/]*)`);
113337
+ });
113338
+ leftPart = leftPart.replace(/\//g, "\\/");
113324
113339
  if (match[1]) {
113325
113340
  return {
113326
- id: match[1],
113341
+ id: parameters,
113327
113342
  mode: 1,
113328
- left: path9.replace(`[${match[1]}]`, "")
113343
+ left: leftPart
113329
113344
  };
113330
113345
  }
113331
113346
  } else {
@@ -113353,10 +113368,8 @@ var BuildFunctionGenerator = class {
113353
113368
  `;
113354
113369
  this.recordFunc(stringMap, "onRequest");
113355
113370
  } else if (routeParams.mode === 1) {
113356
- const match = regex1.exec(`${stringMap.path}`);
113357
- const leftPart = `${stringMap.path}`.replace(`[${match[1]}]`, "").replace(/\//g, "\\/");
113358
113371
  this.logicText += `
113359
- if(/^${leftPart}([^/]+)$/.test(urlInfo.pathname)) {
113372
+ if(/^${routeParams.left}$/.test(urlInfo.pathname)) {
113360
113373
  routeParams = ${JSON.stringify(routeParams)};
113361
113374
  matchedFunc = true;
113362
113375
  ${tempResult}
@@ -113391,10 +113404,8 @@ var BuildFunctionGenerator = class {
113391
113404
  `;
113392
113405
  this.recordFunc(stringMap, item.funcName);
113393
113406
  } else if (routeParams.mode === 1) {
113394
- const match = regex1.exec(`${stringMap.path}`);
113395
- const leftPart = `${stringMap.path}`.replace(`[${match[1]}]`, "").replace(/\//g, "\\/");
113396
113407
  this.logicText += `
113397
- if(/^${leftPart}([^/]+)$/.test(urlInfo.pathname) && request.method === '${item.method}') {
113408
+ if(/^${routeParams.left}$/.test(urlInfo.pathname)) {
113398
113409
  routeParams = ${JSON.stringify(routeParams)};
113399
113410
  matchedFunc = true;
113400
113411
  ${tempResult}
@@ -113403,7 +113414,7 @@ var BuildFunctionGenerator = class {
113403
113414
  this.recordFunc(stringMap, item.funcName);
113404
113415
  } else if (routeParams.mode === 2) {
113405
113416
  const match = regex2.exec(`${stringMap.path}`);
113406
- const leftPart = `${stringMap.path}`.replace(`[${match[1]}]`, "").replace(/\//g, "\\/");
113417
+ const leftPart = `${stringMap.path}`.replace(`[[${match[1]}]]`, "").replace(/\//g, "\\/");
113407
113418
  this.logicText += `
113408
113419
  if(/^${leftPart}(.+?)$/.test(urlInfo.pathname) && request.method === '${item.method}') {
113409
113420
  routeParams = ${JSON.stringify(routeParams)};
@@ -113492,13 +113503,7 @@ async function PagesCI(_) {
113492
113503
  // src/pages/common/env.tsx
113493
113504
  var pullEnvVars = async (projectId) => {
113494
113505
  const envDestination = getCwdFullPath("./.env");
113495
- let localEnv = {};
113496
- try {
113497
- localEnv = readEnvFileSync(envDestination);
113498
- } catch (error3) {
113499
- writeFileSync(envDestination, "");
113500
- normalLog("Created new .env file");
113501
- }
113506
+ const localEnv = readEnvFileSync(envDestination);
113502
113507
  const localEnvVars = [];
113503
113508
  Object.keys(localEnv).forEach((key2) => {
113504
113509
  if (key2.endsWith("DEV")) {
@@ -113801,10 +113806,10 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
113801
113806
  return 1;
113802
113807
  }
113803
113808
  if ("CI" in env2) {
113804
- if (["GITHUB_ACTIONS", "GITEA_ACTIONS", "CIRCLECI"].some((key2) => key2 in env2)) {
113809
+ if ("GITHUB_ACTIONS" in env2 || "GITEA_ACTIONS" in env2) {
113805
113810
  return 3;
113806
113811
  }
113807
- if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env2) || env2.CI_NAME === "codeship") {
113812
+ if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env2) || env2.CI_NAME === "codeship") {
113808
113813
  return 1;
113809
113814
  }
113810
113815
  return min;
@@ -114183,7 +114188,8 @@ async function handleLog(url2) {
114183
114188
  okLog("Function log connected.");
114184
114189
  });
114185
114190
  ws.on("close", function close() {
114186
- normalLog("Function log server disconnected");
114191
+ normalLog("Function log server disconnected, exiting...Please restart the dev server.");
114192
+ process.exit(0);
114187
114193
  });
114188
114194
  ws.on("message", function message(data) {
114189
114195
  const { logs, event_info, exceptions } = JSON.parse(data.toString());
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "edgeone",
3
- "version": "1.0.13",
3
+ "version": "1.0.14-beta.1",
4
4
  "description": "Command-line interface for TencentCloud Pages Functions",
5
5
  "bin": {
6
6
  "edgeone": "./edgeone-bin/edgeone.js"