@aziontech/bundler 1.1.3 → 1.1.4
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/README.md +48 -68
- package/dist/{index-dMuB6SYF.js → index-CgialJ1S.js} +342 -324
- package/dist/index.js +33 -28
- package/dist/utils-B43tliMf.js +377 -0
- package/package.json +3 -4
- package/dist/utils-DkUMNTN3.js +0 -329
package/dist/index.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
import { Command as
|
|
3
|
-
import { satisfies as
|
|
4
|
-
import { B as r, d as
|
|
2
|
+
import { Command as b } from "commander";
|
|
3
|
+
import { satisfies as g } from "semver";
|
|
4
|
+
import { B as r, d as y, E as v, e as a } from "./utils-B43tliMf.js";
|
|
5
5
|
import { feedback as p } from "@aziontech/utils/node";
|
|
6
|
-
import { createHash as
|
|
6
|
+
import { createHash as x } from "crypto";
|
|
7
7
|
import { mkdir as h } from "fs/promises";
|
|
8
|
-
const n = new
|
|
9
|
-
function
|
|
8
|
+
const n = new b();
|
|
9
|
+
function E() {
|
|
10
10
|
const e = process.cwd();
|
|
11
|
-
return
|
|
11
|
+
return x("md5").update(e).digest("hex");
|
|
12
12
|
}
|
|
13
|
-
async function
|
|
14
|
-
const e =
|
|
13
|
+
async function w() {
|
|
14
|
+
const e = E(), o = r.TEMP_DIR(e);
|
|
15
15
|
return await h(o, { recursive: !0 }), o;
|
|
16
16
|
}
|
|
17
17
|
function c() {
|
|
18
|
-
return
|
|
18
|
+
return g(process.version, `>= ${r.MIN_NODE_VERSION}`);
|
|
19
19
|
}
|
|
20
|
-
async function
|
|
20
|
+
async function k() {
|
|
21
21
|
return {
|
|
22
22
|
root: r.ROOT_PATH,
|
|
23
23
|
package: r.PACKAGE_JSON,
|
|
24
24
|
debug: r.IS_DEBUG,
|
|
25
25
|
version: r.VERSION,
|
|
26
|
-
tempPath: await
|
|
26
|
+
tempPath: await w(),
|
|
27
27
|
argsPath: r.ARGS_PATH,
|
|
28
28
|
experimental: r.EXPERIMENTAL
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
function
|
|
31
|
+
function z() {
|
|
32
32
|
process.on("exit", a), process.on("SIGINT", () => {
|
|
33
33
|
a(), process.exit(0);
|
|
34
34
|
}), process.on("SIGTERM", () => {
|
|
@@ -43,9 +43,9 @@ function E() {
|
|
|
43
43
|
console.error("Unhandled Promise Rejection:", e), a(), process.exit(1);
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
-
function
|
|
46
|
+
function j() {
|
|
47
47
|
n.version(globalThis.bundler.version), n.command("store <command>").description("Manage store configuration").option("-c, --config <json>", `Configuration in JSON format (e.g., '{"key": "value"}')`).option("-s, --scope <scope>", "Scope of the store (default: global)").action(async (e, o) => {
|
|
48
|
-
const { storeCommand: t } = await import("./index-
|
|
48
|
+
const { storeCommand: t } = await import("./index-CgialJ1S.js");
|
|
49
49
|
await t({
|
|
50
50
|
command: e,
|
|
51
51
|
options: o
|
|
@@ -59,6 +59,10 @@ function k() {
|
|
|
59
59
|
).option("-d, --dev", "Build in development mode", !1).option("-x, --experimental [boolean]", "Enable experimental features", !1).option("--skip-framework-build", "Skip framework build step", !1).option("--only-generate-config", "Build only generate azion.config", !1).option(
|
|
60
60
|
"--telemetry [format]",
|
|
61
61
|
"Enable telemetry output (console, json, html or both). Defaults to both if flag is present without value."
|
|
62
|
+
).option(
|
|
63
|
+
"--alias-env",
|
|
64
|
+
"Temporary: rewrite env var names to a per-project prefix to avoid cross-project naming collisions",
|
|
65
|
+
!1
|
|
62
66
|
).addHelpText(
|
|
63
67
|
"after",
|
|
64
68
|
`
|
|
@@ -71,21 +75,22 @@ Examples:
|
|
|
71
75
|
$ azbundler build --telemetry json
|
|
72
76
|
`
|
|
73
77
|
).action(async (e) => {
|
|
74
|
-
const { buildCommand: o, manifestCommand: t } = await import("./index-
|
|
78
|
+
const { buildCommand: o, manifestCommand: t } = await import("./index-CgialJ1S.js"), { dev: i, experimental: l, telemetry: s, aliasEnv: d, ...m } = e;
|
|
75
79
|
if (l && (globalThis.bundler.experimental = !0), s !== void 0) {
|
|
76
|
-
const
|
|
77
|
-
process.env.AZ_BUNDLER_TELEMETRY = "true", process.env.AZ_BUNDLER_TELEMETRY_FORMAT =
|
|
80
|
+
const f = typeof s == "string" ? s : "both";
|
|
81
|
+
process.env.AZ_BUNDLER_TELEMETRY = "true", process.env.AZ_BUNDLER_TELEMETRY_FORMAT = f;
|
|
78
82
|
}
|
|
79
|
-
|
|
80
|
-
|
|
83
|
+
d && (process.env[v.ENABLE_VAR] = "true");
|
|
84
|
+
const { config: u } = await o({
|
|
85
|
+
...m,
|
|
81
86
|
production: !i
|
|
82
87
|
});
|
|
83
|
-
await t({ action: "generate", config:
|
|
88
|
+
await t({ action: "generate", config: u });
|
|
84
89
|
}), n.command("dev").description("Start local development environment").argument("[entry]", "Specify the entry file (default: .edge/worker.dev.js)").option("-p, --port <port>", "Specify the port", "3333").option("-x, --experimental [boolean]", "Enable experimental features", !1).option("--skip-framework-build", "Skip framework build step", !1).option("--function-name <name>", "Specify the function name").action(async (e, o) => {
|
|
85
|
-
const { devCommand: t } = await import("./index-
|
|
90
|
+
const { devCommand: t } = await import("./index-CgialJ1S.js"), { experimental: i } = o;
|
|
86
91
|
i && (globalThis.bundler.experimental = !0), await t({ entry: e, ...o });
|
|
87
92
|
}), n.command("presets <command>").description("Manage presets for Azion projects").argument("[preset]", "Preset name (required for config command)").action(async (e, o) => {
|
|
88
|
-
const { presetsCommand: t } = await import("./index-
|
|
93
|
+
const { presetsCommand: t } = await import("./index-CgialJ1S.js");
|
|
89
94
|
await t(e, { preset: o });
|
|
90
95
|
}), n.command("manifest [action]").description("Manage manifest files for Azion").argument(
|
|
91
96
|
"[action]",
|
|
@@ -99,7 +104,7 @@ Examples:
|
|
|
99
104
|
$ azbundler manifest -e azion.config.js -o .edge
|
|
100
105
|
`
|
|
101
106
|
).action(async (e, o, t) => {
|
|
102
|
-
const { manifestCommand: i } = await import("./index-
|
|
107
|
+
const { manifestCommand: i } = await import("./index-CgialJ1S.js");
|
|
103
108
|
await i({
|
|
104
109
|
...o || t,
|
|
105
110
|
action: e
|
|
@@ -117,7 +122,7 @@ Examples:
|
|
|
117
122
|
$ azbundler config replace -k '$EDGE_FUNCTION_NAME' -v "my-func"
|
|
118
123
|
`
|
|
119
124
|
).action(async (e, o) => {
|
|
120
|
-
const { configCommand: t } = await import("./index-
|
|
125
|
+
const { configCommand: t } = await import("./index-CgialJ1S.js");
|
|
121
126
|
await t({
|
|
122
127
|
command: e,
|
|
123
128
|
options: o
|
|
@@ -130,14 +135,14 @@ Examples:
|
|
|
130
135
|
$ azbundler telemetry --path ./custom-report.html
|
|
131
136
|
`
|
|
132
137
|
).action(async (e) => {
|
|
133
|
-
const { telemetryCommand: o } = await import("./index-
|
|
138
|
+
const { telemetryCommand: o } = await import("./index-CgialJ1S.js");
|
|
134
139
|
await o(e);
|
|
135
140
|
}), n.parse(process.argv);
|
|
136
141
|
}
|
|
137
142
|
try {
|
|
138
|
-
c() && (globalThis.bundler = await
|
|
143
|
+
c() && (globalThis.bundler = await k(), j(), z()), c() || (p.error(
|
|
139
144
|
`Invalid Node version. Node version must be greater than ${r.MIN_NODE_VERSION}.`
|
|
140
145
|
), process.exit(1));
|
|
141
146
|
} catch (e) {
|
|
142
|
-
p.error("An unknown error occurred."),
|
|
147
|
+
p.error("An unknown error occurred."), y.error(e), process.exit(1);
|
|
143
148
|
}
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import w, { readFileSync as I, unlinkSync as x } from "fs";
|
|
2
|
+
import m, { writeFile as R } from "fs/promises";
|
|
3
|
+
import { getAbsoluteDirPath as V, feedback as E } from "@aziontech/utils/node";
|
|
4
|
+
import { tmpdir as k } from "os";
|
|
5
|
+
import f, { join as u, resolve as B } from "path";
|
|
6
|
+
import "@aziontech/builder/polyfills";
|
|
7
|
+
import "@edge-runtime/primitives/dist/load.js";
|
|
8
|
+
import "chokidar";
|
|
9
|
+
import "@aziontech/bundler-telemetry";
|
|
10
|
+
import { convertJsonConfigToObject as M } from "@aziontech/config";
|
|
11
|
+
import "@aziontech/builder";
|
|
12
|
+
import "lodash";
|
|
13
|
+
import "@aziontech/presets";
|
|
14
|
+
import "@netlify/framework-info";
|
|
15
|
+
import "edge-runtime";
|
|
16
|
+
import j from "prettier";
|
|
17
|
+
import { cosmiconfig as H } from "cosmiconfig";
|
|
18
|
+
import { TypeScriptLoader as S } from "cosmiconfig-typescript-loader";
|
|
19
|
+
const $ = {
|
|
20
|
+
OUTPUT_BASE_PATH: ".edge",
|
|
21
|
+
OUTPUT_FUNCTIONS_PATH: u(".edge", "functions"),
|
|
22
|
+
OUTPUT_STORAGE_PATH: u(".edge", "storage"),
|
|
23
|
+
OUTPUT_MANIFEST_PATH: u(".edge", "manifest.json"),
|
|
24
|
+
OUTPUT_ENV_VARS_PATH: u(".edge", ".env"),
|
|
25
|
+
/**
|
|
26
|
+
* Temporary workaround for Azion's global environment variables
|
|
27
|
+
*/
|
|
28
|
+
OUTPUT_ENV_VARS_LOCAL_PATH: u(".edge", ".env.azion"),
|
|
29
|
+
OUTPUT_STORAGE_METADATA_PATH: u(".edge", "storage", "metadata.json"),
|
|
30
|
+
OUTPUT_KV_PATH: u(".edge", "kv")
|
|
31
|
+
}, _e = {
|
|
32
|
+
POLYFILLS: !0,
|
|
33
|
+
WORKER: !1,
|
|
34
|
+
PRODUCTION: !0,
|
|
35
|
+
EXTENSION: "js",
|
|
36
|
+
PRESET: void 0,
|
|
37
|
+
ENTRY: void 0,
|
|
38
|
+
BUNDLER: void 0
|
|
39
|
+
}, Te = {
|
|
40
|
+
DEFAULT: "esbuild"
|
|
41
|
+
}, U = {
|
|
42
|
+
NAMESPACE: "bundler",
|
|
43
|
+
EXPERIMENTAL: !1,
|
|
44
|
+
MIN_NODE_VERSION: "18.0.0",
|
|
45
|
+
CONFIG_FILENAME: "azion.config",
|
|
46
|
+
DEFAULT_HANDLER_FILENAME: "handler",
|
|
47
|
+
DEFAULT_DEV_WORKER_FILENAME: "handler.dev",
|
|
48
|
+
DEFAULT_OUTPUT_EXTENSION: "js",
|
|
49
|
+
LIB_DIR: V(import.meta.url, "bundler"),
|
|
50
|
+
ARGS_PATH: "@aziontech/args.json",
|
|
51
|
+
IS_DEBUG: process.env.DEBUG === "true",
|
|
52
|
+
TEMP_DIR: (n) => u(k(), ".azion", n),
|
|
53
|
+
get ROOT_PATH() {
|
|
54
|
+
return B(U.LIB_DIR, ".");
|
|
55
|
+
},
|
|
56
|
+
get PACKAGE_JSON() {
|
|
57
|
+
return JSON.parse(I(`${U.ROOT_PATH}/package.json`, "utf8"));
|
|
58
|
+
},
|
|
59
|
+
get VERSION() {
|
|
60
|
+
return U.PACKAGE_JSON.version;
|
|
61
|
+
}
|
|
62
|
+
}, g = `
|
|
63
|
+
|
|
64
|
+
📚 Need help? Check out our documentation:
|
|
65
|
+
- Azion CLI Documentation: https://www.azion.com/en/documentation/devtools/cli/build/
|
|
66
|
+
- Azion Library on Github: https://github.com/aziontech/lib/tree/main/packages/config/
|
|
67
|
+
- Azion Bundler on GitHub: https://github.com/aziontech/bundler
|
|
68
|
+
`, P = {
|
|
69
|
+
ENV_PREFIX_VAR: "AZ_BUNDLER_ENV_ALIAS_PREFIX",
|
|
70
|
+
ENABLE_VAR: "AZ_BUNDLER_ENV_ALIAS_ENABLED"
|
|
71
|
+
}, Ae = {
|
|
72
|
+
ENV_ENABLED: "AZ_BUNDLER_TELEMETRY",
|
|
73
|
+
ENV_FORMAT: "AZ_BUNDLER_TELEMETRY_FORMAT",
|
|
74
|
+
ENV_OUTPUT: "AZ_BUNDLER_TELEMETRY_OUTPUT",
|
|
75
|
+
DEFAULT_FORMAT: "both",
|
|
76
|
+
DEFAULT_OUTPUT_PATH: ".edge/telemetry-report.json",
|
|
77
|
+
DEFAULT_HTML_OUTPUT_PATH: ".edge/telemetry-report.html"
|
|
78
|
+
}, J = (n) => n.split(`
|
|
79
|
+
`).map((e) => e.match(/^\s*([A-Za-z_][A-Za-z0-9_]*)\s*=\s*(.*)$/)).filter((e) => !!e).map((e) => ({ key: e[1], value: e[2] })), he = (n) => {
|
|
80
|
+
const e = n.trim().replace(/\r$/, "");
|
|
81
|
+
return e.length >= 2 && (e.startsWith('"') && e.endsWith('"') || e.startsWith("'") && e.endsWith("'")) ? e.slice(1, -1) : e;
|
|
82
|
+
}, G = (n) => n ? [".env.production.local", ".env.local", ".env.production", ".env"] : [".env.development.local", ".env.local", ".env.development", ".env"];
|
|
83
|
+
async function L(n, e) {
|
|
84
|
+
const t = /* @__PURE__ */ new Map();
|
|
85
|
+
for (const r of [...G(e)].reverse()) {
|
|
86
|
+
const i = u(n, r);
|
|
87
|
+
if (!await m.access(i, w.constants.F_OK).then(() => !0).catch(() => !1)) continue;
|
|
88
|
+
const c = await m.readFile(i, "utf-8");
|
|
89
|
+
J(c).forEach(({ key: T, value: A }) => t.set(T, A));
|
|
90
|
+
}
|
|
91
|
+
return Array.from(t, ([r, i]) => ({ key: r, value: i }));
|
|
92
|
+
}
|
|
93
|
+
const Z = (n) => {
|
|
94
|
+
const e = n.toUpperCase().replace(/[^A-Z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
95
|
+
return e ? `${e}_` : "";
|
|
96
|
+
}, Y = (n) => process.env[P.ENABLE_VAR] !== "true" ? "" : process.env[P.ENV_PREFIX_VAR] || Z(n || "");
|
|
97
|
+
async function O(n, e = "global") {
|
|
98
|
+
let t;
|
|
99
|
+
switch (e) {
|
|
100
|
+
case "global":
|
|
101
|
+
t = globalThis.bundler.tempPath;
|
|
102
|
+
break;
|
|
103
|
+
case "local":
|
|
104
|
+
t = f.join(process.cwd());
|
|
105
|
+
break;
|
|
106
|
+
default:
|
|
107
|
+
t = e;
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
const r = f.join(t, ".azion-bundler.json");
|
|
111
|
+
try {
|
|
112
|
+
await m.mkdir(t, { recursive: !0 });
|
|
113
|
+
} catch (i) {
|
|
114
|
+
throw a.error(i), E.build.error(
|
|
115
|
+
`An error occurred while creating the ${r} folder.${g}`
|
|
116
|
+
), i;
|
|
117
|
+
}
|
|
118
|
+
try {
|
|
119
|
+
await m.writeFile(r, JSON.stringify(n, null, 2));
|
|
120
|
+
} catch (i) {
|
|
121
|
+
throw a.error(i), E.build.error(
|
|
122
|
+
`An error occurred while writing the ${r} file.${g}`
|
|
123
|
+
), i;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async function N(n = "global") {
|
|
127
|
+
let e;
|
|
128
|
+
switch (n) {
|
|
129
|
+
case "global":
|
|
130
|
+
e = globalThis.bundler.tempPath;
|
|
131
|
+
break;
|
|
132
|
+
case "local":
|
|
133
|
+
e = f.join(process.cwd());
|
|
134
|
+
break;
|
|
135
|
+
default:
|
|
136
|
+
e = n;
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
if (!e) return {};
|
|
140
|
+
const t = f.join(e, ".azion-bundler.json");
|
|
141
|
+
try {
|
|
142
|
+
await m.access(t);
|
|
143
|
+
const r = await m.readFile(t, "utf8");
|
|
144
|
+
return JSON.parse(r);
|
|
145
|
+
} catch {
|
|
146
|
+
return {};
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
function K(n, e) {
|
|
150
|
+
if (n.message.includes("ERR_MODULE_NOT_FOUND")) {
|
|
151
|
+
const t = n.message.match(/'([^']+)'/)?.[1];
|
|
152
|
+
t ? E.build.error(
|
|
153
|
+
`Missing dependency: ${t}. Please install it using 'npm install ${t}' or 'yarn add ${t}'.${g}`
|
|
154
|
+
) : E.build.error(
|
|
155
|
+
`A required dependency is missing. Please ensure all dependencies are installed.${g}`
|
|
156
|
+
), a.error(`Failed to load configuration from ${e}. ${n.message}`);
|
|
157
|
+
} else
|
|
158
|
+
throw n;
|
|
159
|
+
}
|
|
160
|
+
async function W(n) {
|
|
161
|
+
const e = H("azion", {
|
|
162
|
+
searchPlaces: [
|
|
163
|
+
"azion.config.ts",
|
|
164
|
+
"azion.config.mts",
|
|
165
|
+
"azion.config.cts",
|
|
166
|
+
"azion.config.js",
|
|
167
|
+
"azion.config.mjs",
|
|
168
|
+
"azion.config.cjs",
|
|
169
|
+
"azion.config.json"
|
|
170
|
+
],
|
|
171
|
+
loaders: {
|
|
172
|
+
".ts": S(),
|
|
173
|
+
".mts": S(),
|
|
174
|
+
".cts": S()
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
try {
|
|
178
|
+
const t = n ? await e.load(n) : await e.search();
|
|
179
|
+
if (!t) return null;
|
|
180
|
+
const r = t.config, i = t.filepath;
|
|
181
|
+
return f.extname(i) === ".json" ? M(JSON.stringify(r)) : r;
|
|
182
|
+
} catch (t) {
|
|
183
|
+
if (t.message.includes("ERR_MODULE_NOT_FOUND"))
|
|
184
|
+
return K(t, n || "azion.config"), null;
|
|
185
|
+
if (t.message.includes("TypeScriptLoader failed to compile")) {
|
|
186
|
+
const r = t.message.split(`TypeScriptLoader failed to compile TypeScript:
|
|
187
|
+
`)[1]?.trim();
|
|
188
|
+
E.build.error(`${r || t.message}${g}`), process.exit(1);
|
|
189
|
+
}
|
|
190
|
+
t.message.includes("ERR_REQUIRE_CYCLE_MODULE") && (E.build.error(
|
|
191
|
+
`Circular dependency detected while loading configuration file. This usually happens when using ES modules. Please ensure your configuration file doesn't have circular imports.${g}`
|
|
192
|
+
), process.exit(1)), a.error(t), E.build.error(
|
|
193
|
+
`Failed to load configuration file. For detailed debugging information, run with DEBUG=true environment variable.${g}`
|
|
194
|
+
), process.exit(1);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
function X() {
|
|
198
|
+
const n = f.join(process.cwd(), "package.json");
|
|
199
|
+
return w.existsSync(n) ? JSON.parse(w.readFileSync(n, "utf8")).type !== "module" : !0;
|
|
200
|
+
}
|
|
201
|
+
async function Q(n, e) {
|
|
202
|
+
const r = X() ? ".cjs" : ".mjs", i = n.build?.preset === "typescript";
|
|
203
|
+
let s = i ? ".ts" : r, c;
|
|
204
|
+
if (e) {
|
|
205
|
+
const o = f.parse(e);
|
|
206
|
+
if ([".js", ".mjs", ".cjs", ".ts"].includes(o.ext))
|
|
207
|
+
c = f.resolve(e), s = o.ext;
|
|
208
|
+
else {
|
|
209
|
+
const l = f.resolve(e);
|
|
210
|
+
try {
|
|
211
|
+
(await m.stat(l)).isFile() ? c = `${l}${s}` : c = f.join(l, `azion.config${s}`);
|
|
212
|
+
} catch {
|
|
213
|
+
e.includes("/") || e.includes("\\") ? c = f.join(l, `azion.config${s}`) : c = `${l}${s}`;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
} else
|
|
217
|
+
c = f.join(process.cwd(), `azion.config${s}`);
|
|
218
|
+
const T = i ? "export default" : s === ".cjs" ? "module.exports =" : "export default", A = `/**
|
|
219
|
+
* This file was automatically generated based on your preset configuration.
|
|
220
|
+
*
|
|
221
|
+
* For better type checking and IntelliSense:
|
|
222
|
+
* 1. Install azion config as dev dependency:
|
|
223
|
+
* npm install -D @aziontech/config
|
|
224
|
+
*
|
|
225
|
+
* 2. Use defineConfig:
|
|
226
|
+
* import { defineConfig } from '@aziontech/config'
|
|
227
|
+
*
|
|
228
|
+
* 3. Replace the configuration with defineConfig:
|
|
229
|
+
* export default defineConfig({
|
|
230
|
+
* // Your configuration here
|
|
231
|
+
* })
|
|
232
|
+
*
|
|
233
|
+
* For more configuration options, visit:
|
|
234
|
+
* https://github.com/aziontech/lib/tree/main/packages/config
|
|
235
|
+
*/
|
|
236
|
+
|
|
237
|
+
`;
|
|
238
|
+
function v(o) {
|
|
239
|
+
if (o == null)
|
|
240
|
+
return o;
|
|
241
|
+
if (Array.isArray(o))
|
|
242
|
+
return o.map(v).filter((d) => d !== void 0);
|
|
243
|
+
if (typeof o == "object") {
|
|
244
|
+
const d = {};
|
|
245
|
+
for (const [p, l] of Object.entries(o))
|
|
246
|
+
if (l !== void 0) {
|
|
247
|
+
const _ = v(l);
|
|
248
|
+
_ !== void 0 && (d[p] = _);
|
|
249
|
+
}
|
|
250
|
+
return d;
|
|
251
|
+
}
|
|
252
|
+
return o;
|
|
253
|
+
}
|
|
254
|
+
function y(o, d = 0) {
|
|
255
|
+
const p = " ".repeat(d);
|
|
256
|
+
if (typeof o == "function")
|
|
257
|
+
return o.toString();
|
|
258
|
+
if (typeof o == "string")
|
|
259
|
+
return `'${o.replaceAll("'", "\\'")}'`;
|
|
260
|
+
if (typeof o == "number" || typeof o == "boolean" || o == null)
|
|
261
|
+
return String(o);
|
|
262
|
+
if (Array.isArray(o)) {
|
|
263
|
+
if (o.length === 0) return "[]";
|
|
264
|
+
const l = o.map((_) => y(_, d + 1));
|
|
265
|
+
return `[
|
|
266
|
+
${p} ${l.join(`,
|
|
267
|
+
${p} `)}
|
|
268
|
+
${p}]`;
|
|
269
|
+
}
|
|
270
|
+
if (typeof o == "object") {
|
|
271
|
+
const l = Object.entries(o).filter(([, h]) => h !== void 0);
|
|
272
|
+
return l.length === 0 ? "{}" : `{
|
|
273
|
+
${l.map(([h, C]) => {
|
|
274
|
+
const z = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(h) ? h : `'${h}'`;
|
|
275
|
+
return `${p} ${z}: ${y(C, d + 1)}`;
|
|
276
|
+
}).join(`,
|
|
277
|
+
`)}
|
|
278
|
+
${p}}`;
|
|
279
|
+
}
|
|
280
|
+
return String(o);
|
|
281
|
+
}
|
|
282
|
+
const F = v(n), b = y(F), D = await j.format(
|
|
283
|
+
A + `${T} ${b};`,
|
|
284
|
+
{
|
|
285
|
+
parser: "babel",
|
|
286
|
+
semi: !1,
|
|
287
|
+
singleQuote: !0,
|
|
288
|
+
trailingComma: "none"
|
|
289
|
+
}
|
|
290
|
+
);
|
|
291
|
+
await m.writeFile(c, D);
|
|
292
|
+
}
|
|
293
|
+
const ve = {
|
|
294
|
+
writeStore: O,
|
|
295
|
+
readStore: N,
|
|
296
|
+
readAzionConfig: W,
|
|
297
|
+
writeUserConfig: Q
|
|
298
|
+
};
|
|
299
|
+
async function ye(n) {
|
|
300
|
+
try {
|
|
301
|
+
const e = await N("global"), t = e.tempFiles || [];
|
|
302
|
+
t.includes(n) || (t.push(n), await O({ ...e, tempFiles: t }, "global"));
|
|
303
|
+
} catch {
|
|
304
|
+
a.warn("Failed to register temp file:", n);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
async function Se() {
|
|
308
|
+
try {
|
|
309
|
+
const n = await N("global"), e = n.tempFiles || [], t = [];
|
|
310
|
+
e.forEach((r) => {
|
|
311
|
+
try {
|
|
312
|
+
x(r), a.info("Successfully removed temp file:", r);
|
|
313
|
+
} catch {
|
|
314
|
+
a.warn("Failed to remove temp file:", r), t.push(r);
|
|
315
|
+
}
|
|
316
|
+
}), await O({ ...n, tempFiles: t }, "global"), t.length > 0 && a.warn(`${t.length} temp files could not be removed and will be retried later`);
|
|
317
|
+
} catch (n) {
|
|
318
|
+
a.warn("Failed to clean temp files from store:", n);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
const a = {};
|
|
322
|
+
Object.keys(console).forEach((n) => {
|
|
323
|
+
typeof console[n] == "function" && (a[n] = (...e) => {
|
|
324
|
+
process.env.DEBUG === "true" && console[n](...e);
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
async function Ue(n = !0) {
|
|
328
|
+
const e = process.cwd(), t = $.OUTPUT_ENV_VARS_PATH;
|
|
329
|
+
try {
|
|
330
|
+
const r = await L(e, n);
|
|
331
|
+
if (r.length === 0) return;
|
|
332
|
+
const i = r.map(({ key: s, value: c }) => `${s}=${c}`).join(`
|
|
333
|
+
`);
|
|
334
|
+
await R(t, `${i}
|
|
335
|
+
`, "utf-8"), a.info(`Environment file copied to ${t}`);
|
|
336
|
+
} catch {
|
|
337
|
+
a.warn("No .env file found or error copying environment file");
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
async function we(n, e = !0) {
|
|
341
|
+
const t = Y(n);
|
|
342
|
+
if (!t) return;
|
|
343
|
+
const r = process.cwd(), i = $.OUTPUT_ENV_VARS_LOCAL_PATH;
|
|
344
|
+
try {
|
|
345
|
+
const s = await L(r, e);
|
|
346
|
+
if (s.length === 0) return;
|
|
347
|
+
const c = s.map(({ key: T, value: A }) => `${t}${T}=${A}`).join(`
|
|
348
|
+
`);
|
|
349
|
+
await R(i, `${c}
|
|
350
|
+
`, "utf-8"), a.info(`Prefixed environment file written to ${i}`);
|
|
351
|
+
} catch {
|
|
352
|
+
a.warn("No .env file found or error writing prefixed environment file");
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
export {
|
|
356
|
+
U as B,
|
|
357
|
+
$ as D,
|
|
358
|
+
P as E,
|
|
359
|
+
Te as S,
|
|
360
|
+
Ae as T,
|
|
361
|
+
L as a,
|
|
362
|
+
_e as b,
|
|
363
|
+
Ue as c,
|
|
364
|
+
a as d,
|
|
365
|
+
Se as e,
|
|
366
|
+
g as f,
|
|
367
|
+
W as g,
|
|
368
|
+
Q as h,
|
|
369
|
+
O as i,
|
|
370
|
+
N as j,
|
|
371
|
+
ve as k,
|
|
372
|
+
ye as m,
|
|
373
|
+
J as p,
|
|
374
|
+
Y as r,
|
|
375
|
+
he as u,
|
|
376
|
+
we as w
|
|
377
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aziontech/bundler",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
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
|
"index": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -43,7 +43,6 @@
|
|
|
43
43
|
"@types/tmp": "^0.2.6",
|
|
44
44
|
"globals": "^16.0.0",
|
|
45
45
|
"jest": "^30.4.2",
|
|
46
|
-
"markdown-table": "^3.0.3",
|
|
47
46
|
"mock-fs": "^5.2.0",
|
|
48
47
|
"puppeteer": "^25.3.0",
|
|
49
48
|
"supertest": "^7.2.2",
|
|
@@ -80,8 +79,8 @@
|
|
|
80
79
|
"e2e:start": "pnpm submodule:update && tests/scripts/start-e2e-env.sh",
|
|
81
80
|
"e2e:stop": "tests/scripts/stop-e2e-env.sh",
|
|
82
81
|
"e2e:destroy": "tests/scripts/destroy-e2e-env.sh",
|
|
83
|
-
"test:e2e": "pnpm e2e:start && NODE_OPTIONS='--experimental-vm-modules' jest --detectOpenHandles --forceExit --runInBand --config=./jest-e2e.config.js tests/e2e/ --json --outputFile e2e_results.json
|
|
84
|
-
"test:nodejs-apis": "pnpm e2e:start && NODE_OPTIONS='--experimental-vm-modules' jest --forceExit --runInBand --config=./jest-e2e.config.js tests/nodejs-apis/ --json --outputFile nodejs_apis_results.json
|
|
82
|
+
"test:e2e": "pnpm e2e:start && NODE_OPTIONS='--experimental-vm-modules' jest --detectOpenHandles --forceExit --runInBand --config=./jest-e2e.config.js tests/e2e/ --json --outputFile e2e_results.json; TEST_EXIT_CODE=$?; pnpm e2e:stop; pnpm task:reports; exit $TEST_EXIT_CODE",
|
|
83
|
+
"test:nodejs-apis": "pnpm e2e:start && NODE_OPTIONS='--experimental-vm-modules' jest --forceExit --runInBand --config=./jest-e2e.config.js tests/nodejs-apis/ --json --outputFile nodejs_apis_results.json; TEST_EXIT_CODE=$?; pnpm e2e:stop; pnpm task:reports-nodejs-apis; exit $TEST_EXIT_CODE",
|
|
85
84
|
"submodule:update": "git submodule update --init --recursive && git submodule foreach git pull origin main"
|
|
86
85
|
}
|
|
87
86
|
}
|