edgeone 1.0.13 → 1.0.14-beta.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/edgeone-dist/cli.js +41 -24
- package/package.json +1 -1
package/edgeone-dist/cli.js
CHANGED
|
@@ -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.
|
|
102542
|
+
version: "1.0.14-beta.1",
|
|
102543
102543
|
description: "Command-line interface for TencentCloud Pages Functions",
|
|
102544
102544
|
bin: {
|
|
102545
102545
|
edgeone: "./edgeone-bin/edgeone.js"
|
|
@@ -113116,7 +113116,7 @@ var esbuild = require("esbuild");
|
|
|
113116
113116
|
var FUNCTIONPATH = "./functions";
|
|
113117
113117
|
var OUTPUTPATH = "./.edgeone/functions/index.js";
|
|
113118
113118
|
var OUTPUTMETA = "./.edgeone/meta.json";
|
|
113119
|
-
var regex1 = /^\/(?:[^/]+\/)*\[(.+?)\]
|
|
113119
|
+
var regex1 = /^\/(?:[^/]+\/)*\[(.+?)\]/;
|
|
113120
113120
|
var regex2 = /^\/(?:[^/]+\/)*\[\[(.+?)\]\]$/;
|
|
113121
113121
|
var methodList = [
|
|
113122
113122
|
// {
|
|
@@ -113231,13 +113231,21 @@ var BuildFunctionGenerator = class {
|
|
|
113231
113231
|
|
|
113232
113232
|
const params = {};
|
|
113233
113233
|
if (routeParams.id) {
|
|
113234
|
-
|
|
113235
|
-
|
|
113236
|
-
|
|
113237
|
-
|
|
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
|
-
|
|
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 (
|
|
113323
|
-
const match =
|
|
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:
|
|
113341
|
+
id: parameters,
|
|
113327
113342
|
mode: 1,
|
|
113328
|
-
left:
|
|
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(/^${
|
|
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(/^${
|
|
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)};
|
|
@@ -113418,7 +113429,7 @@ var BuildFunctionGenerator = class {
|
|
|
113418
113429
|
this.functionIndex = this.functionIndex + 1;
|
|
113419
113430
|
}
|
|
113420
113431
|
getMountPath(fullPath) {
|
|
113421
|
-
const p = fullPath.replace(/\/([^/]+)
|
|
113432
|
+
const p = fullPath.replace(/\/([^/]+)$/g, "");
|
|
113422
113433
|
if (!p) {
|
|
113423
113434
|
return "/";
|
|
113424
113435
|
}
|
|
@@ -113426,7 +113437,7 @@ var BuildFunctionGenerator = class {
|
|
|
113426
113437
|
}
|
|
113427
113438
|
recordFunc(obj, method) {
|
|
113428
113439
|
try {
|
|
113429
|
-
const key2 = obj.path.replace("functions/", "").replace(/\/\[\[(
|
|
113440
|
+
const key2 = obj.path.replace("functions/", "").replace(/\/\[\[([^/]+)\]\]$/, "/:$1*").replace(/\/\[([^/]+)\]/g, "/:$1");
|
|
113430
113441
|
this.functionList.push({
|
|
113431
113442
|
routePath: key2,
|
|
113432
113443
|
mountPath: this.getMountPath(key2),
|
|
@@ -113441,6 +113452,10 @@ var BuildFunctionGenerator = class {
|
|
|
113441
113452
|
}
|
|
113442
113453
|
}
|
|
113443
113454
|
bundleAndGetString(filePath) {
|
|
113455
|
+
const define2 = {};
|
|
113456
|
+
for (const k in this.env) {
|
|
113457
|
+
define2[`env.${k}`] = JSON.stringify(process.env[k]);
|
|
113458
|
+
}
|
|
113444
113459
|
const result = esbuild.buildSync({
|
|
113445
113460
|
entryPoints: [filePath],
|
|
113446
113461
|
bundle: true,
|
|
@@ -113449,7 +113464,9 @@ var BuildFunctionGenerator = class {
|
|
|
113449
113464
|
// outdir: './.tef_dist/assets',
|
|
113450
113465
|
write: false,
|
|
113451
113466
|
// 禁止写入文件
|
|
113452
|
-
outfile: "./.tef_dist/assets.js"
|
|
113467
|
+
outfile: "./.tef_dist/assets.js",
|
|
113468
|
+
// envs
|
|
113469
|
+
define: define2
|
|
113453
113470
|
});
|
|
113454
113471
|
const { outputFiles } = result;
|
|
113455
113472
|
let currentFileInfo;
|
|
@@ -113801,10 +113818,10 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
113801
113818
|
return 1;
|
|
113802
113819
|
}
|
|
113803
113820
|
if ("CI" in env2) {
|
|
113804
|
-
if (
|
|
113821
|
+
if ("GITHUB_ACTIONS" in env2 || "GITEA_ACTIONS" in env2) {
|
|
113805
113822
|
return 3;
|
|
113806
113823
|
}
|
|
113807
|
-
if (["TRAVIS", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env2) || env2.CI_NAME === "codeship") {
|
|
113824
|
+
if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env2) || env2.CI_NAME === "codeship") {
|
|
113808
113825
|
return 1;
|
|
113809
113826
|
}
|
|
113810
113827
|
return min;
|