edge-functions 5.0.2 → 5.0.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.
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
debug,
|
|
3
|
-
generateTimestamp
|
|
4
|
-
|
|
3
|
+
generateTimestamp,
|
|
4
|
+
removeAzionTempFiles
|
|
5
|
+
} from "./chunk-TFXEYXNB.js";
|
|
5
6
|
|
|
6
7
|
// lib/env/runtime.ts
|
|
7
8
|
import { EdgeRuntime } from "edge-runtime";
|
|
@@ -940,6 +941,7 @@ var build = async ({
|
|
|
940
941
|
preset: resolvedPreset,
|
|
941
942
|
ctx
|
|
942
943
|
});
|
|
944
|
+
removeAzionTempFiles();
|
|
943
945
|
return {
|
|
944
946
|
config: mergedConfig,
|
|
945
947
|
ctx
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
// lib/utils
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
// lib/utils/generateTimestamp/generateTimestamp.ts
|
|
1
|
+
// lib/utils.ts
|
|
2
|
+
import { readdirSync, unlinkSync } from "fs";
|
|
3
|
+
import { join } from "path";
|
|
4
|
+
function removeAzionTempFiles() {
|
|
5
|
+
const directory = process.cwd();
|
|
6
|
+
const tempFiles = readdirSync(directory).filter(
|
|
7
|
+
(file) => file.startsWith("azion-") && (file.endsWith(".temp.js") || file.endsWith(".temp.ts"))
|
|
8
|
+
);
|
|
9
|
+
tempFiles.forEach((file) => {
|
|
10
|
+
const filePath = join(directory, file);
|
|
11
|
+
unlinkSync(filePath);
|
|
12
|
+
});
|
|
13
|
+
}
|
|
15
14
|
function generateTimestamp() {
|
|
16
15
|
const now = /* @__PURE__ */ new Date();
|
|
17
16
|
const year = now.getFullYear();
|
|
@@ -22,8 +21,19 @@ function generateTimestamp() {
|
|
|
22
21
|
const seconds = String(now.getSeconds()).padStart(2, "0");
|
|
23
22
|
return `${year}${month}${day}${hours}${minutes}${seconds}`;
|
|
24
23
|
}
|
|
24
|
+
var debug = {};
|
|
25
|
+
Object.keys(console).forEach((method) => {
|
|
26
|
+
if (typeof console[method] === "function") {
|
|
27
|
+
debug[method] = (...args) => {
|
|
28
|
+
if (process.env.DEBUG === "true") {
|
|
29
|
+
console[method](...args);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
});
|
|
25
34
|
|
|
26
35
|
export {
|
|
27
|
-
|
|
28
|
-
generateTimestamp
|
|
36
|
+
removeAzionTempFiles,
|
|
37
|
+
generateTimestamp,
|
|
38
|
+
debug
|
|
29
39
|
};
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
buildCommand,
|
|
3
3
|
bundler_default,
|
|
4
4
|
writeStore
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-TFQQQ3K2.js";
|
|
6
6
|
import {
|
|
7
7
|
debug
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-TFXEYXNB.js";
|
|
9
9
|
|
|
10
10
|
// lib/commands/dev/command.ts
|
|
11
11
|
import { join } from "path";
|
|
@@ -14,7 +14,7 @@ async function devCommand({
|
|
|
14
14
|
port
|
|
15
15
|
}) {
|
|
16
16
|
const parsedPort = parseInt(port, 10);
|
|
17
|
-
const { server } = await import("./env-
|
|
17
|
+
const { server } = await import("./env-6C2DFUNG.js");
|
|
18
18
|
const edgeDir = join(process.cwd(), ".edge");
|
|
19
19
|
const devWorkerPath = join(edgeDir, "worker.dev.js");
|
|
20
20
|
const entryPoint = entry || devWorkerPath;
|
package/dist/main.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
import {
|
|
3
|
-
debug
|
|
4
|
-
|
|
3
|
+
debug,
|
|
4
|
+
removeAzionTempFiles
|
|
5
|
+
} from "./chunk-TFXEYXNB.js";
|
|
5
6
|
|
|
6
7
|
// lib/main.ts
|
|
7
8
|
import { resolve, join } from "path";
|
|
8
|
-
import { readFileSync,
|
|
9
|
+
import { readFileSync, mkdirSync } from "fs";
|
|
9
10
|
import { Command } from "commander";
|
|
10
11
|
import { satisfies } from "semver";
|
|
11
12
|
import os from "os";
|
|
@@ -48,49 +49,39 @@ function setBundlerEnvironment() {
|
|
|
48
49
|
};
|
|
49
50
|
globalThis.bundler = bundlerContext;
|
|
50
51
|
}
|
|
51
|
-
function cleanUpTempFiles() {
|
|
52
|
-
const directory = process.cwd();
|
|
53
|
-
const tempFiles = readdirSync(directory).filter(
|
|
54
|
-
(file) => file.startsWith("azion-") && (file.endsWith(".temp.js") || file.endsWith(".temp.ts"))
|
|
55
|
-
);
|
|
56
|
-
tempFiles.forEach((file) => {
|
|
57
|
-
const filePath = join(directory, file);
|
|
58
|
-
unlinkSync(filePath);
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
52
|
function setupBundlerProcessHandlers() {
|
|
62
|
-
process.on("exit",
|
|
53
|
+
process.on("exit", removeAzionTempFiles);
|
|
63
54
|
process.on("SIGINT", () => {
|
|
64
|
-
|
|
55
|
+
removeAzionTempFiles();
|
|
65
56
|
process.exit(0);
|
|
66
57
|
});
|
|
67
58
|
process.on("SIGTERM", () => {
|
|
68
|
-
|
|
59
|
+
removeAzionTempFiles();
|
|
69
60
|
process.exit(0);
|
|
70
61
|
});
|
|
71
62
|
process.on("SIGHUP", () => {
|
|
72
|
-
|
|
63
|
+
removeAzionTempFiles();
|
|
73
64
|
process.exit(0);
|
|
74
65
|
});
|
|
75
66
|
process.on("SIGBREAK", () => {
|
|
76
|
-
|
|
67
|
+
removeAzionTempFiles();
|
|
77
68
|
process.exit(0);
|
|
78
69
|
});
|
|
79
70
|
process.on("uncaughtException", (error) => {
|
|
80
71
|
console.error("Uncaught Exception:", error);
|
|
81
|
-
|
|
72
|
+
removeAzionTempFiles();
|
|
82
73
|
process.exit(1);
|
|
83
74
|
});
|
|
84
75
|
process.on("unhandledRejection", (reason) => {
|
|
85
76
|
console.error("Unhandled Promise Rejection:", reason);
|
|
86
|
-
|
|
77
|
+
removeAzionTempFiles();
|
|
87
78
|
process.exit(1);
|
|
88
79
|
});
|
|
89
80
|
}
|
|
90
81
|
function startBundler() {
|
|
91
82
|
AzionBundler.version(BUNDLER_CURRENT_VERSION);
|
|
92
83
|
AzionBundler.command("store <command>").description("Manage store configuration (init/destroy)").option("--scope <scope>", "Project scope", "global").option("--preset <string>", "Preset name").option("--entry <string>", "Code entrypoint").option("--bundler <type>", "Bundler type (webpack/esbuild)").option("--polyfills [boolean]", "Use node polyfills in build").option("--worker [boolean]", "Indicates worker expression").action(async (command, options) => {
|
|
93
|
-
const { storeCommand } = await import("./commands-
|
|
84
|
+
const { storeCommand } = await import("./commands-WQPLDY5F.js");
|
|
94
85
|
await storeCommand({ command, options });
|
|
95
86
|
});
|
|
96
87
|
AzionBundler.command("build").description("Build a project for edge deployment").option(
|
|
@@ -106,7 +97,7 @@ function startBundler() {
|
|
|
106
97
|
"--worker [boolean]",
|
|
107
98
|
"Indicates that the constructed code inserts its own worker expression. Use --worker or --worker=true to enable, --worker=false to disable"
|
|
108
99
|
).option("--development", "Build in development mode", false).action(async (options) => {
|
|
109
|
-
const { buildCommand, manifestCommand } = await import("./commands-
|
|
100
|
+
const { buildCommand, manifestCommand } = await import("./commands-WQPLDY5F.js");
|
|
110
101
|
const { config } = await buildCommand({
|
|
111
102
|
...options,
|
|
112
103
|
production: !options.development
|
|
@@ -117,11 +108,11 @@ function startBundler() {
|
|
|
117
108
|
"[entry]",
|
|
118
109
|
"Specify the entry file (default: .edge/worker.dev.js)"
|
|
119
110
|
).option("-p, --port <port>", "Specify the port", "3333").action(async (entry, options) => {
|
|
120
|
-
const { devCommand } = await import("./commands-
|
|
111
|
+
const { devCommand } = await import("./commands-WQPLDY5F.js");
|
|
121
112
|
await devCommand({ entry, ...options });
|
|
122
113
|
});
|
|
123
114
|
AzionBundler.command("presets <command>").description("List <ls> defined project presets for Azion").action(async (command) => {
|
|
124
|
-
const { presetsCommand } = await import("./commands-
|
|
115
|
+
const { presetsCommand } = await import("./commands-WQPLDY5F.js");
|
|
125
116
|
await presetsCommand(command);
|
|
126
117
|
});
|
|
127
118
|
AzionBundler.command("manifest [action]").description(
|
|
@@ -139,7 +130,7 @@ Examples:
|
|
|
139
130
|
$ az manifest --entry=azion.config.js --output=.edge
|
|
140
131
|
`
|
|
141
132
|
).action(async (action, options) => {
|
|
142
|
-
const { manifestCommand } = await import("./commands-
|
|
133
|
+
const { manifestCommand } = await import("./commands-WQPLDY5F.js");
|
|
143
134
|
await manifestCommand({
|
|
144
135
|
...options,
|
|
145
136
|
action
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "edge-functions",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.3",
|
|
4
4
|
"description": "Tool to launch and build JavaScript/Frameworks. This tool automates polyfills for Edge Computing and assists in creating Workers, notably for the Azion platform.",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"module": "dist/main.ts",
|