@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
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
import { fetchContext as
|
|
2
|
-
import { load as
|
|
3
|
-
import { D as
|
|
1
|
+
import { fetchContext as Ne, FirewallEventContext as Ie, FetchEventContext as Be, AsyncHooksContext as de, StorageContext as De, EnvVarsContext as We, NetworkListContext as Me, fsContext as Le, streamContext as He, cryptoContext as Ve, promisesContext as ze, KVContext as Ge } from "@aziontech/builder/polyfills";
|
|
2
|
+
import { load as qe } from "@edge-runtime/primitives/dist/load.js";
|
|
3
|
+
import { D as C, p as Ke, u as Je, d as g, S as pe, B as F, r as Xe, a as Ye, b as _, m as Ze, e as Qe, c as et, w as tt, f as U, T as R, g as oe, h as te, i as Se, j as rt, k as $e } from "./utils-B43tliMf.js";
|
|
4
4
|
import * as O from "@aziontech/utils/node";
|
|
5
|
-
import { getPackageManager as
|
|
6
|
-
import
|
|
7
|
-
import { runPhaseWithTelemetry as x, TelemetryCollector as
|
|
8
|
-
import { validateConfig as re, processConfig as
|
|
9
|
-
import h, { rm as ie, mkdir as Pe, readFile as
|
|
10
|
-
import S, { resolve as ae,
|
|
5
|
+
import { getPackageManager as nt, feedback as p } from "@aziontech/utils/node";
|
|
6
|
+
import st from "chokidar";
|
|
7
|
+
import { runPhaseWithTelemetry as x, TelemetryCollector as ot, formatHeader as it, formatBuildConfig as at } from "@aziontech/bundler-telemetry";
|
|
8
|
+
import { validateConfig as re, processConfig as ct, convertJsonConfigToObject as lt } from "@aziontech/config";
|
|
9
|
+
import h, { rm as ie, mkdir as Pe, readFile as ft, stat as ut, writeFile as dt } from "fs/promises";
|
|
10
|
+
import S, { resolve as ae, join as k, relative as ne, basename as V, extname as I, dirname as xe } from "path";
|
|
11
11
|
import X from "os";
|
|
12
|
-
import { executeESBuildBuild as
|
|
13
|
-
import
|
|
12
|
+
import { executeESBuildBuild as pt, executeWebpackBuild as mt, createAzionWebpackConfig as ht, createAzionESBuildConfig as gt } from "@aziontech/builder";
|
|
13
|
+
import yt from "lodash";
|
|
14
|
+
import me, { existsSync as ke, readFileSync as wt, promises as z } from "fs";
|
|
14
15
|
import { runInContext as ce } from "vm";
|
|
15
|
-
import { pathToFileURL as
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import { runServer as
|
|
16
|
+
import { pathToFileURL as bt } from "url";
|
|
17
|
+
import D from "node:vm";
|
|
18
|
+
import Et from "net";
|
|
19
|
+
import { runServer as vt } from "edge-runtime";
|
|
19
20
|
import * as J from "@aziontech/presets";
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import
|
|
23
|
-
import { cosmiconfig as yt } from "cosmiconfig";
|
|
21
|
+
import { listFrameworks as Tt } from "@netlify/framework-info";
|
|
22
|
+
import * as Ce from "prettier";
|
|
23
|
+
import { cosmiconfig as St } from "cosmiconfig";
|
|
24
24
|
import { TypeScriptLoader as Y } from "cosmiconfig-typescript-loader";
|
|
25
|
-
class
|
|
25
|
+
class $t {
|
|
26
26
|
context;
|
|
27
27
|
constructor(t = {}) {
|
|
28
|
-
const r =
|
|
28
|
+
const r = D.createContext(
|
|
29
29
|
{},
|
|
30
30
|
{
|
|
31
31
|
name: "Edge Runtime",
|
|
@@ -42,17 +42,17 @@ class wt {
|
|
|
42
42
|
*/
|
|
43
43
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
44
|
evaluate(t) {
|
|
45
|
-
return
|
|
45
|
+
return D.runInContext(t, this.context, {
|
|
46
46
|
importModuleDynamically: async (r) => {
|
|
47
47
|
try {
|
|
48
|
-
return await import(
|
|
48
|
+
return await import(bt(ae(r)).href);
|
|
49
49
|
} catch {
|
|
50
50
|
process.env.DEBUG && console.warn(
|
|
51
51
|
">>> [edge-runtime] dynamic import failed, returning empty module:",
|
|
52
52
|
r
|
|
53
53
|
);
|
|
54
|
-
const n = new
|
|
55
|
-
return await n.link(() => new
|
|
54
|
+
const n = new D.SourceTextModule("export default {}", { context: this.context });
|
|
55
|
+
return await n.link(() => new D.SourceTextModule("export {}", { context: this.context })), await n.evaluate(), n;
|
|
56
56
|
}
|
|
57
57
|
}
|
|
58
58
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -60,14 +60,14 @@ class wt {
|
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
62
|
let G, q;
|
|
63
|
-
class
|
|
63
|
+
class Pt extends $t {
|
|
64
64
|
dispatchFetch;
|
|
65
65
|
constructor(t) {
|
|
66
66
|
super({
|
|
67
67
|
...t,
|
|
68
68
|
extend: (r) => t?.extend ? t.extend(he(r)) : he(r)
|
|
69
69
|
}), Object.defineProperty(this.context, "__onUnhandledRejectionHandlers", {
|
|
70
|
-
set:
|
|
70
|
+
set: kt,
|
|
71
71
|
configurable: !1,
|
|
72
72
|
enumerable: !1
|
|
73
73
|
}), Object.defineProperty(this, "__rejectionHandlers", {
|
|
@@ -75,20 +75,20 @@ class bt extends wt {
|
|
|
75
75
|
configurable: !1,
|
|
76
76
|
enumerable: !1
|
|
77
77
|
}), Object.defineProperty(this.context, "__onErrorHandlers", {
|
|
78
|
-
set:
|
|
78
|
+
set: Ct,
|
|
79
79
|
configurable: !1,
|
|
80
80
|
enumerable: !1
|
|
81
81
|
}), Object.defineProperty(this, "__errorHandlers", {
|
|
82
82
|
get: () => q,
|
|
83
83
|
configurable: !1,
|
|
84
84
|
enumerable: !1
|
|
85
|
-
}), this.evaluate(
|
|
86
|
-
for (const r of
|
|
87
|
-
|
|
85
|
+
}), this.evaluate(Ft()), this.dispatchFetch = this.evaluate(At());
|
|
86
|
+
for (const r of Fe)
|
|
87
|
+
xt(r, this.context);
|
|
88
88
|
t?.initialCode && this.evaluate(t.initialCode);
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
|
-
const
|
|
91
|
+
const Fe = [
|
|
92
92
|
"Object",
|
|
93
93
|
"Array",
|
|
94
94
|
"RegExp",
|
|
@@ -98,7 +98,7 @@ const Ce = [
|
|
|
98
98
|
"SyntaxError",
|
|
99
99
|
"TypeError"
|
|
100
100
|
];
|
|
101
|
-
function
|
|
101
|
+
function xt(e, t) {
|
|
102
102
|
const r = eval;
|
|
103
103
|
return t[/* @__PURE__ */ Symbol.for(`node:${e}`)] = r(e), ce(
|
|
104
104
|
`
|
|
@@ -122,17 +122,17 @@ function Et(e, t) {
|
|
|
122
122
|
t
|
|
123
123
|
);
|
|
124
124
|
}
|
|
125
|
-
function
|
|
125
|
+
function kt(e) {
|
|
126
126
|
G || process.on("unhandledRejection", function(r, n) {
|
|
127
127
|
G.forEach((o) => o({ reason: r, promise: n }));
|
|
128
128
|
}), G = e;
|
|
129
129
|
}
|
|
130
|
-
function
|
|
130
|
+
function Ct(e) {
|
|
131
131
|
q || process.on("uncaughtException", function(r) {
|
|
132
132
|
q.forEach((n) => n(r));
|
|
133
133
|
}), q = e;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function Ft() {
|
|
136
136
|
return `
|
|
137
137
|
Object.defineProperty(self, '__listeners', {
|
|
138
138
|
configurable: false,
|
|
@@ -175,7 +175,7 @@ function St() {
|
|
|
175
175
|
}
|
|
176
176
|
`;
|
|
177
177
|
}
|
|
178
|
-
function
|
|
178
|
+
function At() {
|
|
179
179
|
return `(async function dispatchFetch(input, init) {
|
|
180
180
|
const request = new Request(input, init);
|
|
181
181
|
const event = new FetchEvent(request);
|
|
@@ -216,9 +216,9 @@ function $t() {
|
|
|
216
216
|
}
|
|
217
217
|
function he(e) {
|
|
218
218
|
A(e, "self", { enumerable: !0, value: e }), A(e, "globalThis", { value: e }), A(e, "Symbol", { value: Symbol }), A(e, "clearInterval", { value: clearInterval }), A(e, "clearTimeout", { value: clearTimeout }), A(e, "queueMicrotask", { value: queueMicrotask }), A(e, "EdgeRuntime", { value: "edge-runtime" });
|
|
219
|
-
const t =
|
|
220
|
-
return
|
|
221
|
-
exports:
|
|
219
|
+
const t = _t(e);
|
|
220
|
+
return Ot(e, {
|
|
221
|
+
exports: qe({
|
|
222
222
|
...t,
|
|
223
223
|
WeakRef: ce("WeakRef", e)
|
|
224
224
|
}),
|
|
@@ -283,7 +283,7 @@ function A(e, t, r) {
|
|
|
283
283
|
writable: r.writable ?? !0
|
|
284
284
|
});
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function Ot(e, t) {
|
|
287
287
|
for (const r of t.enumerable ?? []) {
|
|
288
288
|
if (!t.exports[r])
|
|
289
289
|
throw new Error(`Attempt to export a nullable value for "${r}"`);
|
|
@@ -300,15 +300,23 @@ function Pt(e, t) {
|
|
|
300
300
|
});
|
|
301
301
|
}
|
|
302
302
|
}
|
|
303
|
-
function
|
|
304
|
-
const r = `({${
|
|
303
|
+
function _t(e) {
|
|
304
|
+
const r = `({${Fe.join(",")}})`;
|
|
305
305
|
return ce(r, e);
|
|
306
306
|
}
|
|
307
|
-
function
|
|
307
|
+
function jt() {
|
|
308
|
+
const e = k(process.cwd(), C.OUTPUT_ENV_VARS_PATH);
|
|
309
|
+
if (!ke(e)) return { ...process.env };
|
|
310
|
+
const t = wt(e, "utf-8");
|
|
311
|
+
return Object.fromEntries(
|
|
312
|
+
Ke(t).map(({ key: r, value: n }) => [r, Je(n)])
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
function Ae(e, t = !1) {
|
|
308
316
|
const r = /switch \((\w+)\) \{\n(\s+)case Object:/g;
|
|
309
317
|
e = e.replace(r, (s, i, c) => `if (${i} != null && ${i} !== Object && ${i}.name === "Object") ${i} = Object;
|
|
310
318
|
${c}` + s);
|
|
311
|
-
const n = (s) => (s.RESERVED_FETCH = s.fetch.bind(s), s.fetch = async (i, c) =>
|
|
319
|
+
const n = (s) => (s.RESERVED_FETCH = s.fetch.bind(s), s.fetch = async (i, c) => Ne(
|
|
312
320
|
s,
|
|
313
321
|
i,
|
|
314
322
|
c,
|
|
@@ -316,51 +324,51 @@ ${c}` + s);
|
|
|
316
324
|
globalThis?.AZION_BUCKET_NAME,
|
|
317
325
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
318
326
|
globalThis?.AZION_BUCKET_PREFIX
|
|
319
|
-
), s.FetchEvent = t ?
|
|
320
|
-
return new
|
|
327
|
+
), s.FetchEvent = t ? Ie : Be, s.Response = t ? Response : s.Response, s.eval = eval, s.process = { env: jt() }, s.File = void 0, s.WebSocket = void 0, s.ASYNC_LOCAL_STORAGE = de, s.AsyncLocalStorage = de.AsyncLocalStorage, s.STORAGE_CONTEXT = De, s.ENV_VARS_CONTEXT = We, s.NETWORK_LIST_CONTEXT = Me, s.FS_CONTEXT = Le, s.STREAM_CONTEXT = He, s.CRYPTO_CONTEXT = Ve, s.TextDecoderStream = TextDecoderStream, s.TextEncoderStream = TextEncoderStream, s.perfomance = { now: performance.now }, s.CompressionStream = CompressionStream, s.CountQueuingStrategy = CountQueuingStrategy, s.DecompressionStream = DecompressionStream, s.Promise = Promise, s.Promise.withResolvers = ze, s.KV_CONTEXT = Ge, s);
|
|
328
|
+
return new Pt({ extend: n, initialCode: e, codeGeneration: { strings: !0 } });
|
|
321
329
|
}
|
|
322
|
-
class
|
|
330
|
+
class Oe extends Error {
|
|
323
331
|
constructor(t, r) {
|
|
324
332
|
super(t), this.code = r, this.name = "PackageJsonError";
|
|
325
333
|
}
|
|
326
334
|
code;
|
|
327
335
|
}
|
|
328
|
-
class
|
|
336
|
+
class Ut extends Error {
|
|
329
337
|
constructor(t) {
|
|
330
338
|
super(`Please install dependencies using ${t}`), this.name = "DependenciesError";
|
|
331
339
|
}
|
|
332
340
|
}
|
|
333
|
-
const
|
|
341
|
+
const Rt = async () => {
|
|
334
342
|
const e = k(process.cwd(), "package.json");
|
|
335
343
|
try {
|
|
336
|
-
const t = await
|
|
344
|
+
const t = await ft(e, "utf8");
|
|
337
345
|
return JSON.parse(t);
|
|
338
346
|
} catch (t) {
|
|
339
|
-
throw new
|
|
347
|
+
throw new Oe("Failed to read package.json", t.code);
|
|
340
348
|
}
|
|
341
|
-
},
|
|
349
|
+
}, Nt = async () => {
|
|
342
350
|
const e = k(process.cwd(), "node_modules");
|
|
343
351
|
try {
|
|
344
|
-
return (await
|
|
352
|
+
return (await ut(e)).isDirectory();
|
|
345
353
|
} catch {
|
|
346
354
|
return !1;
|
|
347
355
|
}
|
|
348
|
-
},
|
|
356
|
+
}, It = async () => {
|
|
349
357
|
let e;
|
|
350
358
|
try {
|
|
351
|
-
e = await
|
|
359
|
+
e = await Rt();
|
|
352
360
|
} catch (t) {
|
|
353
|
-
if (t instanceof
|
|
361
|
+
if (t instanceof Oe && t.code === "ENOENT")
|
|
354
362
|
return;
|
|
355
363
|
throw t;
|
|
356
364
|
}
|
|
357
365
|
if (e && (e.dependencies || e.devDependencies)) {
|
|
358
|
-
const t = await
|
|
359
|
-
if (!await
|
|
360
|
-
throw new
|
|
366
|
+
const t = await nt();
|
|
367
|
+
if (!await Nt())
|
|
368
|
+
throw new Ut(t);
|
|
361
369
|
}
|
|
362
370
|
};
|
|
363
|
-
function
|
|
371
|
+
function W({
|
|
364
372
|
inputValue: e,
|
|
365
373
|
fileValue: t,
|
|
366
374
|
storeValue: r,
|
|
@@ -368,16 +376,16 @@ function D({
|
|
|
368
376
|
}) {
|
|
369
377
|
return ((i) => i === "true" ? !0 : i === "false" ? !1 : i)(e ?? t ?? r ?? n);
|
|
370
378
|
}
|
|
371
|
-
const
|
|
379
|
+
const Bt = (e, t) => {
|
|
372
380
|
const r = Object.keys(e).map((s) => {
|
|
373
381
|
const c = (s.endsWith(".js") ? s : `${s}.js`).replace(/\.dev\.js$/, ".js");
|
|
374
|
-
return `./${ne(
|
|
382
|
+
return `./${ne(C.OUTPUT_BASE_PATH, c)}`;
|
|
375
383
|
}), n = (t ?? []).map((s, i) => ({ func: s, index: i })).filter(({ func: s }) => s.path && !r.includes(s.path));
|
|
376
384
|
if (n.length === 0) return;
|
|
377
385
|
const o = n.map(({ func: s, index: i }) => {
|
|
378
386
|
const c = s.path, a = r[i];
|
|
379
387
|
if (a)
|
|
380
|
-
return ` - functions[${i}] ("${s.name}"): configured path "${c}" does not match generated output "${k(
|
|
388
|
+
return ` - functions[${i}] ("${s.name}"): configured path "${c}" does not match generated output "${k(C.OUTPUT_BASE_PATH, a)}". Update the path to "${a}" in azion.config`;
|
|
381
389
|
const l = r.map((f) => `"${f}"`).join(", ");
|
|
382
390
|
return ` - functions[${i}] ("${s.name}"): configured path "${c}" does not match any generated output. Update the path in azion.config to one of: ${l}`;
|
|
383
391
|
}).join(`
|
|
@@ -386,7 +394,7 @@ const Ot = (e, t) => {
|
|
|
386
394
|
`The "path" declared for the following function(s) in azion.config does not match the file(s) generated by the build:
|
|
387
395
|
${o}`
|
|
388
396
|
);
|
|
389
|
-
},
|
|
397
|
+
}, Dt = async (e) => {
|
|
390
398
|
try {
|
|
391
399
|
await Promise.all(
|
|
392
400
|
e.map(async (t) => {
|
|
@@ -402,7 +410,7 @@ ${o}`
|
|
|
402
410
|
} catch (t) {
|
|
403
411
|
throw new Error(`Failed to clean directories: ${t}`);
|
|
404
412
|
}
|
|
405
|
-
},
|
|
413
|
+
}, Wt = (e) => `//---
|
|
406
414
|
//storages:
|
|
407
415
|
// - name: assets
|
|
408
416
|
// bucket: ${e.bucket}
|
|
@@ -410,13 +418,13 @@ ${o}`
|
|
|
410
418
|
//---
|
|
411
419
|
/* this temporary binding is used to inject the storage name and prefix into the function file */
|
|
412
420
|
globalThis.AZION_BUCKET_NAME = '${e.bucket}';
|
|
413
|
-
globalThis.AZION_BUCKET_PREFIX = '${e.prefix}';`,
|
|
421
|
+
globalThis.AZION_BUCKET_PREFIX = '${e.prefix}';`, Mt = async (e) => {
|
|
414
422
|
try {
|
|
415
423
|
return await h.access(e), !0;
|
|
416
424
|
} catch {
|
|
417
425
|
return !1;
|
|
418
426
|
}
|
|
419
|
-
},
|
|
427
|
+
}, Lt = (e) => S.isAbsolute(e) ? e : S.resolve(process.cwd(), C.OUTPUT_BASE_PATH, e), Ht = (e, t) => t.find((r) => r.name === e), Vt = async (e, t, r) => {
|
|
420
428
|
if (!e.path) {
|
|
421
429
|
g.warn(`Function ${e.name} does not have a defined path`);
|
|
422
430
|
return;
|
|
@@ -426,10 +434,10 @@ globalThis.AZION_BUCKET_PREFIX = '${e.prefix}';`, Ut = async (e) => {
|
|
|
426
434
|
g.info(`Function ${e.name} does not have storage bindings`);
|
|
427
435
|
return;
|
|
428
436
|
}
|
|
429
|
-
const o =
|
|
437
|
+
const o = Lt(
|
|
430
438
|
e.path.replace(/\.js$/, r ? ".js" : ".dev.js")
|
|
431
439
|
);
|
|
432
|
-
if (!await
|
|
440
|
+
if (!await Mt(o)) {
|
|
433
441
|
p.bindings.warn(`Function file not found: ${o}.`), p.bindings.info(`Binding injection skipped for function ${e.name}`);
|
|
434
442
|
return;
|
|
435
443
|
}
|
|
@@ -439,7 +447,7 @@ globalThis.AZION_BUCKET_PREFIX = '${e.prefix}';`, Ut = async (e) => {
|
|
|
439
447
|
g.info(`Function ${e.name} already has injected bindings`);
|
|
440
448
|
return;
|
|
441
449
|
}
|
|
442
|
-
const i = String(n.bucket), c =
|
|
450
|
+
const i = String(n.bucket), c = Ht(i, t);
|
|
443
451
|
if (!c) {
|
|
444
452
|
g.warn(`Storage '${i}' not found for function ${e.name}`);
|
|
445
453
|
return;
|
|
@@ -448,7 +456,7 @@ globalThis.AZION_BUCKET_PREFIX = '${e.prefix}';`, Ut = async (e) => {
|
|
|
448
456
|
a || p.postbuild.info(
|
|
449
457
|
`No prefix provided for binding in function '${e.name}', using storage prefix: ${l}`
|
|
450
458
|
);
|
|
451
|
-
const f =
|
|
459
|
+
const f = Wt({
|
|
452
460
|
bucket: i,
|
|
453
461
|
prefix: l
|
|
454
462
|
});
|
|
@@ -459,7 +467,7 @@ ${s}`;
|
|
|
459
467
|
} catch (s) {
|
|
460
468
|
throw g.error(`Failed to process bindings for function ${e.name}:`, s), s;
|
|
461
469
|
}
|
|
462
|
-
},
|
|
470
|
+
}, zt = async ({
|
|
463
471
|
config: e,
|
|
464
472
|
storageSetup: t,
|
|
465
473
|
isProduction: r
|
|
@@ -471,48 +479,48 @@ ${s}`;
|
|
|
471
479
|
return;
|
|
472
480
|
}
|
|
473
481
|
g.info("Injecting bindings into functions..."), await Promise.all(
|
|
474
|
-
n.map((o) =>
|
|
482
|
+
n.map((o) => Vt(o, t, r))
|
|
475
483
|
);
|
|
476
484
|
} catch (n) {
|
|
477
485
|
return g.error("Failed to execute bindings setup:", n), Promise.reject(n);
|
|
478
486
|
}
|
|
479
|
-
},
|
|
487
|
+
}, Gt = () => (/* @__PURE__ */ new Date()).toISOString().slice(0, 10).replace(/-/g, ""), qt = async ({
|
|
480
488
|
entry: e,
|
|
481
489
|
ext: t = "js",
|
|
482
490
|
basePath: r = ".edge/functions",
|
|
483
491
|
production: n = !0,
|
|
484
492
|
bundler: o
|
|
485
493
|
}) => {
|
|
486
|
-
const s =
|
|
487
|
-
const l =
|
|
494
|
+
const s = Gt(), i = (c, a) => {
|
|
495
|
+
const l = V(c, I(c)), f = xe(c), u = `azion-${l}-${s}.temp.${t}`, m = ae(f, u), w = o === "webpack" ? ".js" : "", d = n ? "" : ".dev";
|
|
488
496
|
let y;
|
|
489
497
|
if (a) {
|
|
490
498
|
const T = a.replace(/\.[^/.]+$/, "");
|
|
491
|
-
y = k(r, `${T}${d}${
|
|
499
|
+
y = k(r, `${T}${d}${w}`);
|
|
492
500
|
} else
|
|
493
|
-
y = k(r, f, `${l}${d}${
|
|
501
|
+
y = k(r, f, `${l}${d}${w}`);
|
|
494
502
|
return { [y]: m };
|
|
495
503
|
};
|
|
496
504
|
if (typeof e == "string") {
|
|
497
|
-
const a = `${
|
|
505
|
+
const a = `${V(e, I(e))}${n ? "" : ".dev"}`;
|
|
498
506
|
return { ...i(e, a) };
|
|
499
507
|
}
|
|
500
508
|
return Array.isArray(e) ? e.reduce((c, a) => {
|
|
501
|
-
const f = `${
|
|
509
|
+
const f = `${V(a, I(a))}${n ? "" : ".dev"}`;
|
|
502
510
|
return { ...c, ...i(a, f) };
|
|
503
511
|
}, {}) : Object.entries(e).reduce(
|
|
504
512
|
(c, [a, l]) => ({ ...c, ...i(l, a) }),
|
|
505
513
|
{}
|
|
506
514
|
);
|
|
507
|
-
},
|
|
515
|
+
}, Kt = async (e, t, r) => {
|
|
508
516
|
let n = {};
|
|
509
|
-
const o = e.build?.entry, s = async (i) => await
|
|
517
|
+
const o = e.build?.entry, s = async (i) => await qt({
|
|
510
518
|
entry: i,
|
|
511
|
-
ext: t.metadata.ext ??
|
|
519
|
+
ext: t.metadata.ext ?? F.DEFAULT_OUTPUT_EXTENSION,
|
|
512
520
|
production: r,
|
|
513
521
|
bundler: e.build?.bundler ?? t.config.build?.bundler ?? pe.DEFAULT
|
|
514
522
|
});
|
|
515
|
-
if (o ? n = await s(o) : t.config.build?.entry ? n = await s(t.config.build.entry) : t.handler && (n = await s(
|
|
523
|
+
if (o ? n = await s(o) : t.config.build?.entry ? n = await s(t.config.build.entry) : t.handler && (n = await s(F.DEFAULT_HANDLER_FILENAME)), Object.keys(n).length === 0) {
|
|
516
524
|
const i = t.config.build?.entry ? `(default is "${t.config.build.entry}")` : "";
|
|
517
525
|
throw new Error(
|
|
518
526
|
`No entry point found ${i}. Please specify one using --entry or create a default entry file in your project.`
|
|
@@ -529,12 +537,12 @@ ${s}`;
|
|
|
529
537
|
},
|
|
530
538
|
polyfills: !!e.build?.polyfills
|
|
531
539
|
};
|
|
532
|
-
},
|
|
533
|
-
createAzionESBuildConfigWrapper:
|
|
534
|
-
createAzionWebpackConfigWrapper:
|
|
535
|
-
executeESBuildBuildWrapper:
|
|
536
|
-
executeWebpackBuildWrapper:
|
|
537
|
-
},
|
|
540
|
+
}, Jt = (e, t) => gt(e, t), Xt = (e, t) => ht(e, t), Yt = async (e) => pt(e), Zt = async (e) => mt(e), M = {
|
|
541
|
+
createAzionESBuildConfigWrapper: Jt,
|
|
542
|
+
createAzionWebpackConfigWrapper: Xt,
|
|
543
|
+
executeESBuildBuildWrapper: Yt,
|
|
544
|
+
executeWebpackBuildWrapper: Zt
|
|
545
|
+
}, Qt = (e) => {
|
|
538
546
|
const t = /import\s+.*?from\s*['"](.*?)['"];?/g, r = /(const\s+.*?=\s*require\(.*\).*);/g, n = (e.match(t) || []).map((i) => i.trim()), o = (e.match(r) || []).map((i) => i.trim());
|
|
539
547
|
let s = e.replace(t, "").replace(r, "").replace(/\n\s*\n\s*\n/g, `
|
|
540
548
|
|
|
@@ -543,15 +551,15 @@ ${s}`;
|
|
|
543
551
|
`)}
|
|
544
552
|
|
|
545
553
|
${s.trim()}`), s;
|
|
546
|
-
},
|
|
547
|
-
${e}` : e,
|
|
554
|
+
}, er = (e, t, r) => t.polyfills && r.production ? `import SRC_NODE_FS from "node:fs";
|
|
555
|
+
${e}` : e, L = async (e, t, r, n, o, s) => !e || !t ? s() : x(
|
|
548
556
|
e,
|
|
549
557
|
t,
|
|
550
558
|
r,
|
|
551
559
|
n,
|
|
552
560
|
o,
|
|
553
561
|
s
|
|
554
|
-
),
|
|
562
|
+
), tr = async ({
|
|
555
563
|
buildConfig: e,
|
|
556
564
|
prebuildResult: t,
|
|
557
565
|
ctx: r,
|
|
@@ -567,7 +575,7 @@ ${e}` : e, M = async (e, t, r, n, o, s) => !e || !t ? s() : x(
|
|
|
567
575
|
).then((l) => l.join(" "));
|
|
568
576
|
await Promise.all(
|
|
569
577
|
i.map(async (l) => {
|
|
570
|
-
const f = await h.readFile(l, "utf-8"), u = `${a} ${f}`, m =
|
|
578
|
+
const f = await h.readFile(l, "utf-8"), u = `${a} ${f}`, m = Qt(u);
|
|
571
579
|
return h.writeFile(l, m);
|
|
572
580
|
})
|
|
573
581
|
);
|
|
@@ -582,11 +590,11 @@ ${e}` : e, M = async (e, t, r, n, o, s) => !e || !t ? s() : x(
|
|
|
582
590
|
)
|
|
583
591
|
}
|
|
584
592
|
};
|
|
585
|
-
return await
|
|
593
|
+
return await rr(c, r, n, o, s), Promise.all(
|
|
586
594
|
Object.entries(c.entry).map(async ([a]) => {
|
|
587
595
|
const l = a.endsWith(".js") ? a : `${a}.js`, f = await h.readFile(l, "utf-8");
|
|
588
596
|
if (!r.production) return f;
|
|
589
|
-
const u =
|
|
597
|
+
const u = er(
|
|
590
598
|
f,
|
|
591
599
|
e,
|
|
592
600
|
r
|
|
@@ -597,29 +605,29 @@ ${e}` : e, M = async (e, t, r, n, o, s) => !e || !t ? s() : x(
|
|
|
597
605
|
} catch (i) {
|
|
598
606
|
return Promise.reject(i);
|
|
599
607
|
}
|
|
600
|
-
},
|
|
608
|
+
}, rr = async (e, t, r, n, o) => {
|
|
601
609
|
switch (e.bundler) {
|
|
602
610
|
case "esbuild": {
|
|
603
|
-
|
|
604
|
-
const s = await
|
|
611
|
+
F.IS_DEBUG && (p.build.info("=== System Info ==="), p.build.info("CPUs:", X.cpus().length), p.build.info("Total Memory:", X.totalmem() / 1024 / 1024, "MB"), p.build.info("Free Memory:", X.freemem() / 1024 / 1024, "MB"));
|
|
612
|
+
const s = await L(
|
|
605
613
|
r,
|
|
606
614
|
n,
|
|
607
615
|
o,
|
|
608
616
|
"esbuild-config-create",
|
|
609
617
|
"ESBuild Config Create",
|
|
610
|
-
async () =>
|
|
618
|
+
async () => M.createAzionESBuildConfigWrapper(e, t)
|
|
611
619
|
);
|
|
612
620
|
let i, c;
|
|
613
|
-
|
|
614
|
-
const a = await
|
|
621
|
+
F.IS_DEBUG && (p.build.info("=== Build Test ==="), i = Date.now(), c = process.memoryUsage());
|
|
622
|
+
const a = await L(
|
|
615
623
|
r,
|
|
616
624
|
n,
|
|
617
625
|
o,
|
|
618
626
|
"esbuild-execution",
|
|
619
627
|
"ESBuild Execution",
|
|
620
|
-
async () =>
|
|
628
|
+
async () => M.executeESBuildBuildWrapper(s)
|
|
621
629
|
);
|
|
622
|
-
if (
|
|
630
|
+
if (F.IS_DEBUG) {
|
|
623
631
|
const l = Date.now() - i, f = process.memoryUsage();
|
|
624
632
|
p.build.info("=== Results ==="), p.build.info("Duration:", l, "ms");
|
|
625
633
|
const u = {
|
|
@@ -631,40 +639,40 @@ ${e}` : e, M = async (e, t, r, n, o, s) => !e || !t ? s() : x(
|
|
|
631
639
|
return a;
|
|
632
640
|
}
|
|
633
641
|
case "webpack": {
|
|
634
|
-
const s = await
|
|
642
|
+
const s = await L(
|
|
635
643
|
r,
|
|
636
644
|
n,
|
|
637
645
|
o,
|
|
638
646
|
"webpack-config-create",
|
|
639
647
|
"Webpack Config Create",
|
|
640
|
-
async () =>
|
|
648
|
+
async () => M.createAzionWebpackConfigWrapper(e, t)
|
|
641
649
|
);
|
|
642
|
-
return
|
|
650
|
+
return L(
|
|
643
651
|
r,
|
|
644
652
|
n,
|
|
645
653
|
o,
|
|
646
654
|
"webpack-execution",
|
|
647
655
|
"Webpack Execution",
|
|
648
|
-
async () =>
|
|
656
|
+
async () => M.executeWebpackBuildWrapper(s)
|
|
649
657
|
);
|
|
650
658
|
}
|
|
651
659
|
default:
|
|
652
660
|
throw new Error(`Unsupported bundler: ${e.bundler}`);
|
|
653
661
|
}
|
|
654
|
-
},
|
|
662
|
+
}, nr = (e, t) => {
|
|
655
663
|
const r = (n, o) => {
|
|
656
664
|
if (n && !n.build || Array.isArray(n) && !Array.isArray(o))
|
|
657
665
|
return o;
|
|
658
666
|
};
|
|
659
|
-
return
|
|
660
|
-
},
|
|
667
|
+
return yt.mergeWith({}, e, t, r);
|
|
668
|
+
}, sr = { mergeConfigWithUserOverrides: nr }, ge = async ({
|
|
661
669
|
config: e,
|
|
662
670
|
preset: t
|
|
663
671
|
}) => {
|
|
664
672
|
try {
|
|
665
673
|
const { config: r } = t;
|
|
666
674
|
e.firewall && (delete r.applications, delete r.workloads, delete r.connectors, delete r.functions);
|
|
667
|
-
const n =
|
|
675
|
+
const n = sr.mergeConfigWithUserOverrides(
|
|
668
676
|
r,
|
|
669
677
|
e
|
|
670
678
|
);
|
|
@@ -678,7 +686,7 @@ ${e}` : e, M = async (e, t, r, n, o, s) => !e || !t ? s() : x(
|
|
|
678
686
|
} catch (r) {
|
|
679
687
|
throw new Error(`Failed to set environment: ${r.message}`);
|
|
680
688
|
}
|
|
681
|
-
}, ye = (e) => e ? typeof e == "string" ? [e] : Array.isArray(e) ? e : Object.values(e) : [],
|
|
689
|
+
}, ye = (e) => e ? typeof e == "string" ? [e] : Array.isArray(e) ? e : Object.values(e) : [], or = async ({
|
|
682
690
|
entrypoint: e,
|
|
683
691
|
preset: t
|
|
684
692
|
}) => {
|
|
@@ -734,10 +742,10 @@ If not specified, the entry defaults to index.ts or index.js" in the project roo
|
|
|
734
742
|
throw new Error(
|
|
735
743
|
"Cannot determine entry point. Please specify one using --entry or in your configuration."
|
|
736
744
|
);
|
|
737
|
-
},
|
|
745
|
+
}, ir = async ({ buildConfig: e, ctx: t }) => {
|
|
738
746
|
const { postbuild: r } = e.preset;
|
|
739
747
|
r && await r(e, { ...t });
|
|
740
|
-
},
|
|
748
|
+
}, ar = async ({
|
|
741
749
|
namespace: e,
|
|
742
750
|
property: t,
|
|
743
751
|
dirs: r
|
|
@@ -762,29 +770,37 @@ If not specified, the entry defaults to index.ts or index.js" in the project roo
|
|
|
762
770
|
);
|
|
763
771
|
};
|
|
764
772
|
return await o(r), `globalThis.${e}.${t}=${JSON.stringify(n)};`;
|
|
765
|
-
},
|
|
773
|
+
}, cr = async ({ dirs: e, prefix: t, outputPath: r }) => {
|
|
766
774
|
await Promise.all(
|
|
767
775
|
e.map(async (n) => {
|
|
768
776
|
const o = t ? n.replace(t, "") : n, s = k(r, o);
|
|
769
777
|
await h.access(s).then(() => !0).catch(() => !1) || await h.mkdir(s, { recursive: !0 }), await h.cp(n, s, { recursive: !0 });
|
|
770
778
|
})
|
|
771
779
|
);
|
|
772
|
-
},
|
|
780
|
+
}, lr = ({ namespace: e, property: t, vars: r }) => Object.entries(r).reduce(
|
|
773
781
|
(n, [o, s]) => {
|
|
774
782
|
const i = t ? `${e}.${t}` : e;
|
|
775
783
|
return `${n} globalThis.${i}.${o}=${s};`;
|
|
776
784
|
},
|
|
777
785
|
t ? `globalThis.${e}.${t}={};` : `globalThis.${e}={};`
|
|
778
|
-
),
|
|
786
|
+
), fr = async (e, t) => {
|
|
787
|
+
const r = Xe(t);
|
|
788
|
+
if (!r) return {};
|
|
789
|
+
const n = await Ye(e, !0);
|
|
790
|
+
return n.length === 0 ? {} : Object.fromEntries(
|
|
791
|
+
n.map(({ key: o }) => [`process.env.${o}`, `process.env.${r}${o}`])
|
|
792
|
+
);
|
|
793
|
+
}, ur = async ({
|
|
779
794
|
namespace: e,
|
|
780
795
|
property: t,
|
|
781
796
|
prefix: r
|
|
782
|
-
}) => `globalThis.${e} = { ...globalThis.${e}, ${t}: '${r && typeof r == "string" && r !== "" ? r : '""'}'};`,
|
|
783
|
-
injectWorkerMemoryFiles:
|
|
784
|
-
copyFilesToLocalEdgeStorage:
|
|
785
|
-
injectWorkerGlobals:
|
|
786
|
-
injectWorkerPathPrefix:
|
|
787
|
-
|
|
797
|
+
}) => `globalThis.${e} = { ...globalThis.${e}, ${t}: '${r && typeof r == "string" && r !== "" ? r : '""'}'};`, N = {
|
|
798
|
+
injectWorkerMemoryFiles: ar,
|
|
799
|
+
copyFilesToLocalEdgeStorage: cr,
|
|
800
|
+
injectWorkerGlobals: lr,
|
|
801
|
+
injectWorkerPathPrefix: ur,
|
|
802
|
+
buildEnvAliasDefineVars: fr
|
|
803
|
+
}, dr = {
|
|
788
804
|
filesToInject: [],
|
|
789
805
|
injection: {
|
|
790
806
|
globals: {}
|
|
@@ -793,53 +809,54 @@ If not specified, the entry defaults to index.ts or index.js" in the project roo
|
|
|
793
809
|
defineVars: {},
|
|
794
810
|
plugins: []
|
|
795
811
|
}
|
|
796
|
-
},
|
|
812
|
+
}, pr = async ({
|
|
797
813
|
buildConfig: e,
|
|
798
|
-
ctx: t
|
|
814
|
+
ctx: t,
|
|
815
|
+
applicationName: r
|
|
799
816
|
}) => {
|
|
800
|
-
const
|
|
801
|
-
namespace:
|
|
817
|
+
const n = await e.preset.prebuild?.(e, t) || dr, o = N.injectWorkerGlobals({
|
|
818
|
+
namespace: F.NAMESPACE,
|
|
802
819
|
// Transform globals object:
|
|
803
820
|
// 1. Convert object to entries
|
|
804
821
|
// 2. Remove any entries with undefined values
|
|
805
822
|
// 3. Ensure remaining values are typed as string
|
|
806
823
|
vars: Object.fromEntries(
|
|
807
|
-
Object.entries(
|
|
824
|
+
Object.entries(n.injection?.globals || {}).filter(([l, f]) => f !== void 0).map(([l, f]) => [l, f])
|
|
808
825
|
)
|
|
809
|
-
}),
|
|
810
|
-
namespace:
|
|
826
|
+
}), s = await N.injectWorkerMemoryFiles({
|
|
827
|
+
namespace: F.NAMESPACE,
|
|
811
828
|
property: "__FILES__",
|
|
812
829
|
dirs: e.memoryFS?.injectionDirs || []
|
|
813
830
|
});
|
|
814
|
-
e.memoryFS &&
|
|
831
|
+
e.memoryFS && N.copyFilesToLocalEdgeStorage({
|
|
815
832
|
dirs: e.memoryFS?.injectionDirs,
|
|
816
833
|
prefix: e.memoryFS?.removePathPrefix,
|
|
817
|
-
outputPath:
|
|
834
|
+
outputPath: C.OUTPUT_STORAGE_PATH
|
|
818
835
|
});
|
|
819
|
-
const
|
|
820
|
-
namespace:
|
|
836
|
+
const i = await N.injectWorkerPathPrefix({
|
|
837
|
+
namespace: F.NAMESPACE,
|
|
821
838
|
property: "FS_PATH_PREFIX_TO_REMOVE",
|
|
822
839
|
prefix: e.memoryFS?.removePathPrefix || ""
|
|
823
|
-
}),
|
|
824
|
-
${
|
|
840
|
+
}), c = `${o}${i}
|
|
841
|
+
${s}`, a = t.production ? await N.buildEnvAliasDefineVars(process.cwd(), r) : {};
|
|
825
842
|
return {
|
|
826
|
-
filesToInject:
|
|
843
|
+
filesToInject: n.filesToInject || [],
|
|
827
844
|
injection: {
|
|
828
|
-
globals:
|
|
845
|
+
globals: n.injection?.globals || {},
|
|
829
846
|
entry: "",
|
|
830
|
-
banner:
|
|
847
|
+
banner: c
|
|
831
848
|
},
|
|
832
849
|
bundler: {
|
|
833
|
-
defineVars:
|
|
834
|
-
plugins:
|
|
850
|
+
defineVars: { ...n.bundler?.defineVars, ...a },
|
|
851
|
+
plugins: n.bundler?.plugins || []
|
|
835
852
|
}
|
|
836
853
|
};
|
|
837
|
-
},
|
|
854
|
+
}, mr = ({ projectDir: e = process.cwd() }) => Tt({
|
|
838
855
|
projectDir: e
|
|
839
|
-
}),
|
|
840
|
-
async function
|
|
856
|
+
}), hr = { listFrameworks: mr };
|
|
857
|
+
async function gr() {
|
|
841
858
|
try {
|
|
842
|
-
const e = await
|
|
859
|
+
const e = await hr.listFrameworks({
|
|
843
860
|
projectDir: process.cwd()
|
|
844
861
|
});
|
|
845
862
|
if (e[0]?.id && Object.values(J).some(
|
|
@@ -847,32 +864,32 @@ async function cr() {
|
|
|
847
864
|
))
|
|
848
865
|
return e[0].id;
|
|
849
866
|
const t = k(process.cwd(), "tsconfig.json");
|
|
850
|
-
return me.existsSync(t) || me.readdirSync(process.cwd()).some((s) => [".ts", ".tsx"].includes(
|
|
867
|
+
return me.existsSync(t) || me.readdirSync(process.cwd()).some((s) => [".ts", ".tsx"].includes(I(s))) ? "typescript" : "javascript";
|
|
851
868
|
} catch {
|
|
852
869
|
return "javascript";
|
|
853
870
|
}
|
|
854
871
|
}
|
|
855
|
-
const
|
|
872
|
+
const yr = { inferPreset: gr }, wr = (e) => Object.values(J).find((t) => t.metadata?.name === e), br = async (e) => {
|
|
856
873
|
if (e) {
|
|
857
874
|
const t = typeof e == "string" ? e : e.metadata?.name;
|
|
858
875
|
O.feedback.build.info(`Using preset: ${t}`);
|
|
859
876
|
}
|
|
860
|
-
if (e || (O.feedback.build.info("No preset specified, using automatic detection..."), e = await
|
|
861
|
-
const t =
|
|
877
|
+
if (e || (O.feedback.build.info("No preset specified, using automatic detection..."), e = await yr.inferPreset(), O.feedback.build.info(`Detected preset: ${e}`)), typeof e == "string") {
|
|
878
|
+
const t = wr(e);
|
|
862
879
|
if (!t)
|
|
863
880
|
throw new Error(`Invalid build preset name: '${e}'`);
|
|
864
881
|
return t;
|
|
865
882
|
}
|
|
866
883
|
return e;
|
|
867
|
-
},
|
|
884
|
+
}, Er = () => `${Date.now()}`, vr = async (e) => {
|
|
868
885
|
try {
|
|
869
886
|
return await h.access(e), (await h.stat(e)).isDirectory();
|
|
870
887
|
} catch {
|
|
871
888
|
return !1;
|
|
872
889
|
}
|
|
873
|
-
},
|
|
890
|
+
}, Tr = async (e, t) => {
|
|
874
891
|
try {
|
|
875
|
-
const r =
|
|
892
|
+
const r = C.OUTPUT_STORAGE_METADATA_PATH;
|
|
876
893
|
let n = [];
|
|
877
894
|
try {
|
|
878
895
|
const s = await h.readFile(r, "utf-8");
|
|
@@ -888,7 +905,7 @@ const lr = { inferPreset: cr }, fr = (e) => Object.values(J).find((t) => t.metad
|
|
|
888
905
|
} catch (r) {
|
|
889
906
|
throw g.error(`Failed to save storage metadata for ${e}:`, r), r;
|
|
890
907
|
}
|
|
891
|
-
},
|
|
908
|
+
}, Sr = async (e, t, r, n) => {
|
|
892
909
|
const o = e.name;
|
|
893
910
|
try {
|
|
894
911
|
const s = S.join(r, o, n);
|
|
@@ -914,7 +931,7 @@ const lr = { inferPreset: cr }, fr = (e) => Object.values(J).find((t) => t.metad
|
|
|
914
931
|
i.isSymbolicLink() ? (await h.unlink(s), g.info(`Removed existing symlink: ${s}`)) : i.isDirectory() && (await h.rm(s, { recursive: !0, force: !0 }), g.info(`Removed existing directory: ${s}`));
|
|
915
932
|
} catch {
|
|
916
933
|
}
|
|
917
|
-
await h.symlink(t, s, "dir"), g.info(`Storage link created: ${o} -> ${t}`), await
|
|
934
|
+
await h.symlink(t, s, "dir"), g.info(`Storage link created: ${o} -> ${t}`), await Tr(o, {
|
|
918
935
|
name: o,
|
|
919
936
|
workloadsAccess: e.workloadsAccess || "read_only",
|
|
920
937
|
sourceDir: t,
|
|
@@ -924,25 +941,25 @@ const lr = { inferPreset: cr }, fr = (e) => Object.values(J).find((t) => t.metad
|
|
|
924
941
|
} catch (s) {
|
|
925
942
|
throw g.error(`Failed to create storage link for ${o}:`, s), s;
|
|
926
943
|
}
|
|
927
|
-
},
|
|
944
|
+
}, $r = (e) => !e.name || !e.dir ? (g.warn("Storage configuration is missing required fields (name or dir)"), !1) : !0, Pr = async ({ config: e }) => {
|
|
928
945
|
try {
|
|
929
946
|
const t = e.storage || [], r = [];
|
|
930
947
|
if (t.length === 0)
|
|
931
948
|
return g.info("No storages found to setup"), r;
|
|
932
|
-
await h.mkdir(
|
|
949
|
+
await h.mkdir(C.OUTPUT_STORAGE_PATH, { recursive: !0 });
|
|
933
950
|
for (const n of t) {
|
|
934
|
-
if (
|
|
951
|
+
if (!$r(n))
|
|
935
952
|
continue;
|
|
936
953
|
const o = S.resolve(process.cwd(), n.dir);
|
|
937
|
-
if (!await
|
|
954
|
+
if (!await vr(o))
|
|
938
955
|
throw new Error(
|
|
939
956
|
`Storage directory not found: ${o}.
|
|
940
957
|
- Please check the path provided in the azion.config file on storage[].dir`
|
|
941
958
|
);
|
|
942
|
-
const s = n.prefix, i = s ||
|
|
959
|
+
const s = n.prefix, i = s || Er();
|
|
943
960
|
s || p.storage.info(
|
|
944
961
|
`No prefix provided for storage '${n.name}', generating version prefix: ${i}`
|
|
945
|
-
), s && p.storage.info(`Using provided prefix for storage '${n.name}': ${i}`), await
|
|
962
|
+
), s && p.storage.info(`Using provided prefix for storage '${n.name}': ${i}`), await Sr(n, o, C.OUTPUT_STORAGE_PATH, i), r.push({
|
|
946
963
|
...n,
|
|
947
964
|
prefix: i
|
|
948
965
|
});
|
|
@@ -999,14 +1016,14 @@ if (fetchHandler) {
|
|
|
999
1016
|
} else {
|
|
1000
1017
|
throw new Error("No fetch handler found in default export object.");
|
|
1001
1018
|
}`
|
|
1002
|
-
},
|
|
1019
|
+
}, _e = (e) => {
|
|
1003
1020
|
const t = e.split(`
|
|
1004
1021
|
`), r = /addEventListener\s*\(\s*['"`](fetch|firewall)['"`]\s*,/;
|
|
1005
1022
|
return t.some((n) => {
|
|
1006
1023
|
const o = n.trim();
|
|
1007
1024
|
return o.startsWith("//") || o.startsWith("/*") ? !1 : r.test(n);
|
|
1008
1025
|
});
|
|
1009
|
-
},
|
|
1026
|
+
}, xr = async (e) => {
|
|
1010
1027
|
try {
|
|
1011
1028
|
const t = await import(e), r = t.default || t;
|
|
1012
1029
|
return {
|
|
@@ -1019,8 +1036,8 @@ if (fetchHandler) {
|
|
|
1019
1036
|
hasFetch: !0
|
|
1020
1037
|
};
|
|
1021
1038
|
}
|
|
1022
|
-
},
|
|
1023
|
-
const { hasFirewall: r, hasFetch: n } = await
|
|
1039
|
+
}, kr = async (e, t) => {
|
|
1040
|
+
const { hasFirewall: r, hasFetch: n } = await xr(e);
|
|
1024
1041
|
if (!r && !n)
|
|
1025
1042
|
return `// No fetch or firewall handlers found in: ${e}
|
|
1026
1043
|
// The original file will be used as-is in production mode.
|
|
@@ -1030,7 +1047,7 @@ console.warn('No Edge Function handlers found. File will run as-is.');`;
|
|
|
1030
1047
|
const o = [Q.baseImport(e)];
|
|
1031
1048
|
return r && o.push(Q.firewallHandler), n && o.push(Q.fetchHandler(t)), o.join(`
|
|
1032
1049
|
`);
|
|
1033
|
-
},
|
|
1050
|
+
}, Cr = (e) => `
|
|
1034
1051
|
import handler from '${e}';
|
|
1035
1052
|
|
|
1036
1053
|
// Legacy pattern wrapper: export default function → addEventListener
|
|
@@ -1039,36 +1056,36 @@ addEventListener('fetch', (event) => {
|
|
|
1039
1056
|
return await handler(event);
|
|
1040
1057
|
})());
|
|
1041
1058
|
});
|
|
1042
|
-
`, le = (e) => /export\s+default\s*\{[\s\S]*fetch[\s\S]*\}/.test(e),
|
|
1059
|
+
`, le = (e) => /export\s+default\s*\{[\s\S]*fetch[\s\S]*\}/.test(e), je = (e) => !(!/export\s+default\s+/.test(e) || le(e)), Fr = async (e) => {
|
|
1043
1060
|
try {
|
|
1044
1061
|
const t = await import(e);
|
|
1045
1062
|
return typeof t.default > "u" && !t.fetch && !t.firewall ? "serviceWorker" : t.default && typeof t.default == "object" && (t.default.fetch || t.default.firewall) ? "ESModules" : t.default ? "legacy" : "unsupported";
|
|
1046
1063
|
} catch {
|
|
1047
1064
|
const r = await (await import("fs/promises")).readFile(e, "utf-8");
|
|
1048
|
-
return
|
|
1065
|
+
return _e(r) ? "serviceWorker" : le(r) ? "ESModules" : je(r) ? "legacy" : "unsupported";
|
|
1049
1066
|
}
|
|
1050
|
-
},
|
|
1067
|
+
}, Ar = (e) => typeof e == "string" ? [e] : Array.isArray(e) ? e : Object.values(e), Or = (e) => _e(e) ? "serviceWorker" : le(e) ? "ESModules" : je(e) ? "legacy" : "unsupported", _r = async (e, t, r) => {
|
|
1051
1068
|
let n;
|
|
1052
1069
|
try {
|
|
1053
|
-
n = await
|
|
1070
|
+
n = await Fr(t);
|
|
1054
1071
|
} catch {
|
|
1055
|
-
n =
|
|
1072
|
+
n = Or(e);
|
|
1056
1073
|
}
|
|
1057
1074
|
switch (n) {
|
|
1058
1075
|
case "serviceWorker":
|
|
1059
1076
|
return e;
|
|
1060
1077
|
case "ESModules":
|
|
1061
|
-
return await
|
|
1078
|
+
return await kr(t, r);
|
|
1062
1079
|
case "legacy":
|
|
1063
|
-
return p.build.warn(Z.LEGACY_DEPRECATION),
|
|
1080
|
+
return p.build.warn(Z.LEGACY_DEPRECATION), Cr(t);
|
|
1064
1081
|
default:
|
|
1065
1082
|
return p.build.warn(Z.UNSUPPORTED_PATTERN_DETECTED), p.build.info(Z.UNSUPPORTED_PATTERN_SUGGESTIONS), e;
|
|
1066
1083
|
}
|
|
1067
|
-
},
|
|
1084
|
+
}, jr = async (e, t) => {
|
|
1068
1085
|
try {
|
|
1069
|
-
const r =
|
|
1086
|
+
const r = Ar(t.handler), n = e.entry || {}, o = await Promise.all(
|
|
1070
1087
|
r.map(async (s, i) => {
|
|
1071
|
-
const c = Object.values(n)[i], a = await h.readFile(s, "utf-8"), l = await
|
|
1088
|
+
const c = Object.values(n)[i], a = await h.readFile(s, "utf-8"), l = await _r(a, s, t.production);
|
|
1072
1089
|
return [c, l];
|
|
1073
1090
|
})
|
|
1074
1091
|
);
|
|
@@ -1078,29 +1095,29 @@ addEventListener('fetch', (event) => {
|
|
|
1078
1095
|
`Failed to setup worker code: ${r instanceof Error ? r.message : String(r)}`
|
|
1079
1096
|
);
|
|
1080
1097
|
}
|
|
1081
|
-
},
|
|
1098
|
+
}, Ur = (e) => e === !0 ? !0 : process.env[R.ENV_ENABLED] === "true", Rr = () => {
|
|
1082
1099
|
const e = process.env[R.ENV_FORMAT];
|
|
1083
1100
|
return e === "console" || e === "json" || e === "html" || e === "both" ? e : R.DEFAULT_FORMAT;
|
|
1084
|
-
},
|
|
1085
|
-
const { config: t, options: r } = e, n = !!r.production, o =
|
|
1101
|
+
}, Nr = () => process.env[R.ENV_OUTPUT] || R.DEFAULT_OUTPUT_PATH, Ir = () => R.DEFAULT_HTML_OUTPUT_PATH, Br = async (e) => {
|
|
1102
|
+
const { config: t, options: r } = e, n = !!r.production, o = Ur(r.telemetry), s = t.build?.bundler || "esbuild", i = {
|
|
1086
1103
|
enabled: o,
|
|
1087
|
-
outputFormat:
|
|
1088
|
-
outputPath:
|
|
1089
|
-
htmlOutputPath:
|
|
1104
|
+
outputFormat: Rr(),
|
|
1105
|
+
outputPath: Nr(),
|
|
1106
|
+
htmlOutputPath: Ir()
|
|
1090
1107
|
}, c = {
|
|
1091
|
-
bundlerVersion:
|
|
1108
|
+
bundlerVersion: F.VERSION,
|
|
1092
1109
|
preset: t.build?.preset?.toString() || "javascript",
|
|
1093
1110
|
bundler: s,
|
|
1094
1111
|
production: n,
|
|
1095
1112
|
entry: typeof t.build?.entry == "string" || Array.isArray(t.build?.entry) ? t.build.entry : t.build?.entry ? Object.values(t.build.entry) : ["./main.js"]
|
|
1096
|
-
}, a = new
|
|
1113
|
+
}, a = new ot(i, c);
|
|
1097
1114
|
try {
|
|
1098
1115
|
const l = a.startSpan("build", {
|
|
1099
1116
|
preset: c.preset,
|
|
1100
1117
|
bundler: c.bundler,
|
|
1101
1118
|
production: c.production
|
|
1102
1119
|
});
|
|
1103
|
-
o && i.outputFormat !== "json" && (console.log(
|
|
1120
|
+
o && i.outputFormat !== "json" && (console.log(it(F.VERSION)), console.log(at(c)), console.log(`
|
|
1104
1121
|
⚙️ Starting build pipeline...
|
|
1105
1122
|
`)), r.skipFrameworkBuild && p.build.warn("Skipping framework build"), await x(
|
|
1106
1123
|
a,
|
|
@@ -1108,7 +1125,7 @@ addEventListener('fetch', (event) => {
|
|
|
1108
1125
|
i.outputFormat,
|
|
1109
1126
|
"dependencies-check",
|
|
1110
1127
|
"Dependencies Check",
|
|
1111
|
-
async () =>
|
|
1128
|
+
async () => It()
|
|
1112
1129
|
);
|
|
1113
1130
|
const f = await x(
|
|
1114
1131
|
a,
|
|
@@ -1116,14 +1133,14 @@ addEventListener('fetch', (event) => {
|
|
|
1116
1133
|
i.outputFormat,
|
|
1117
1134
|
"preset-resolution",
|
|
1118
1135
|
"Preset Resolution",
|
|
1119
|
-
async () =>
|
|
1136
|
+
async () => br(t.build?.preset)
|
|
1120
1137
|
), u = await x(
|
|
1121
1138
|
a,
|
|
1122
1139
|
o,
|
|
1123
1140
|
i.outputFormat,
|
|
1124
1141
|
"build-config-setup",
|
|
1125
1142
|
"Build Config Setup",
|
|
1126
|
-
async () =>
|
|
1143
|
+
async () => Kt(t, f, n)
|
|
1127
1144
|
);
|
|
1128
1145
|
if (r.onlyGenerateConfig) {
|
|
1129
1146
|
const E = await ge({
|
|
@@ -1150,7 +1167,7 @@ addEventListener('fetch', (event) => {
|
|
|
1150
1167
|
skipFrameworkBuild: !!r.skipFrameworkBuild,
|
|
1151
1168
|
handler: ""
|
|
1152
1169
|
};
|
|
1153
|
-
const
|
|
1170
|
+
const w = await x(
|
|
1154
1171
|
a,
|
|
1155
1172
|
o,
|
|
1156
1173
|
i.outputFormat,
|
|
@@ -1172,9 +1189,10 @@ addEventListener('fetch', (event) => {
|
|
|
1172
1189
|
i.outputFormat,
|
|
1173
1190
|
"prebuild",
|
|
1174
1191
|
"Prebuild",
|
|
1175
|
-
async () =>
|
|
1192
|
+
async () => pr({
|
|
1176
1193
|
buildConfig: u,
|
|
1177
|
-
ctx: m
|
|
1194
|
+
ctx: m,
|
|
1195
|
+
applicationName: w.applications?.[0]?.name
|
|
1178
1196
|
})
|
|
1179
1197
|
);
|
|
1180
1198
|
p.prebuild.info("Pre-build completed successfully");
|
|
@@ -1184,7 +1202,7 @@ addEventListener('fetch', (event) => {
|
|
|
1184
1202
|
i.outputFormat,
|
|
1185
1203
|
"handler-resolution",
|
|
1186
1204
|
"Handler Resolution",
|
|
1187
|
-
async () =>
|
|
1205
|
+
async () => or({
|
|
1188
1206
|
entrypoint: t.build?.entry,
|
|
1189
1207
|
preset: f
|
|
1190
1208
|
})
|
|
@@ -1200,14 +1218,14 @@ addEventListener('fetch', (event) => {
|
|
|
1200
1218
|
"worker-setup",
|
|
1201
1219
|
"Worker Setup",
|
|
1202
1220
|
async () => {
|
|
1203
|
-
const E = await
|
|
1221
|
+
const E = await jr(u, m), b = [];
|
|
1204
1222
|
await Promise.all(
|
|
1205
1223
|
Object.entries(E).map(async ([v, j]) => {
|
|
1206
|
-
await Pe(xe(v), { recursive: !0 }), await
|
|
1224
|
+
await Pe(xe(v), { recursive: !0 }), await dt(v, j, "utf-8"), b.push(v);
|
|
1207
1225
|
})
|
|
1208
1226
|
);
|
|
1209
|
-
for (const v of
|
|
1210
|
-
await
|
|
1227
|
+
for (const v of b)
|
|
1228
|
+
await Ze(v);
|
|
1211
1229
|
return E;
|
|
1212
1230
|
}
|
|
1213
1231
|
), p.build.info("Starting build..."), await x(
|
|
@@ -1216,7 +1234,7 @@ addEventListener('fetch', (event) => {
|
|
|
1216
1234
|
i.outputFormat,
|
|
1217
1235
|
"core-build",
|
|
1218
1236
|
"Core Build",
|
|
1219
|
-
async () =>
|
|
1237
|
+
async () => tr({
|
|
1220
1238
|
buildConfig: u,
|
|
1221
1239
|
prebuildResult: d,
|
|
1222
1240
|
ctx: m,
|
|
@@ -1224,14 +1242,14 @@ addEventListener('fetch', (event) => {
|
|
|
1224
1242
|
telemetryEnabled: o,
|
|
1225
1243
|
telemetryOutputFormat: i.outputFormat
|
|
1226
1244
|
})
|
|
1227
|
-
), p.build.success("Build completed successfully"), await
|
|
1245
|
+
), p.build.success("Build completed successfully"), await Qe(), Bt(u.entry, w.functions), p.postbuild.info("Starting post-build..."), await x(
|
|
1228
1246
|
a,
|
|
1229
1247
|
o,
|
|
1230
1248
|
i.outputFormat,
|
|
1231
1249
|
"postbuild",
|
|
1232
1250
|
"Postbuild",
|
|
1233
1251
|
async () => {
|
|
1234
|
-
await
|
|
1252
|
+
await ir({ buildConfig: u, ctx: m });
|
|
1235
1253
|
}
|
|
1236
1254
|
), p.postbuild.success("Post-build completed successfully");
|
|
1237
1255
|
const T = await x(
|
|
@@ -1240,7 +1258,7 @@ addEventListener('fetch', (event) => {
|
|
|
1240
1258
|
i.outputFormat,
|
|
1241
1259
|
"storage-setup",
|
|
1242
1260
|
"Storage Setup",
|
|
1243
|
-
async () =>
|
|
1261
|
+
async () => Pr({ config: w })
|
|
1244
1262
|
);
|
|
1245
1263
|
return await x(
|
|
1246
1264
|
a,
|
|
@@ -1249,7 +1267,7 @@ addEventListener('fetch', (event) => {
|
|
|
1249
1267
|
"bindings-setup",
|
|
1250
1268
|
"Bindings Setup",
|
|
1251
1269
|
async () => {
|
|
1252
|
-
await
|
|
1270
|
+
await zt({ config: w, storageSetup: T, isProduction: n });
|
|
1253
1271
|
}
|
|
1254
1272
|
), await x(
|
|
1255
1273
|
a,
|
|
@@ -1258,10 +1276,10 @@ addEventListener('fetch', (event) => {
|
|
|
1258
1276
|
"env-vars-copy",
|
|
1259
1277
|
"Copy Env Vars",
|
|
1260
1278
|
async () => {
|
|
1261
|
-
await
|
|
1279
|
+
await et(m.production), await tt(w.applications?.[0]?.name, m.production);
|
|
1262
1280
|
}
|
|
1263
1281
|
), a.endSpan(l), o && (a.printToConsole(), await a.saveReport()), {
|
|
1264
|
-
config:
|
|
1282
|
+
config: w,
|
|
1265
1283
|
ctx: m,
|
|
1266
1284
|
setup: u
|
|
1267
1285
|
};
|
|
@@ -1271,24 +1289,24 @@ addEventListener('fetch', (event) => {
|
|
|
1271
1289
|
), a.markFailed(l instanceof Error ? l.message : String(l)), o && (a.printToConsole(), await a.saveReport()), process.exit(1);
|
|
1272
1290
|
}
|
|
1273
1291
|
};
|
|
1274
|
-
async function
|
|
1292
|
+
async function Dr(e) {
|
|
1275
1293
|
const t = await oe() || {}, { build: r } = t, n = {
|
|
1276
|
-
preset:
|
|
1294
|
+
preset: W({
|
|
1277
1295
|
inputValue: e.preset,
|
|
1278
1296
|
fileValue: r?.preset,
|
|
1279
1297
|
defaultValue: _.PRESET
|
|
1280
1298
|
}),
|
|
1281
|
-
entry:
|
|
1299
|
+
entry: W({
|
|
1282
1300
|
inputValue: e.entry,
|
|
1283
1301
|
fileValue: r?.entry,
|
|
1284
1302
|
defaultValue: _.ENTRY
|
|
1285
1303
|
}),
|
|
1286
|
-
bundler:
|
|
1304
|
+
bundler: W({
|
|
1287
1305
|
inputValue: void 0,
|
|
1288
1306
|
fileValue: r?.bundler,
|
|
1289
1307
|
defaultValue: _.BUNDLER
|
|
1290
1308
|
}),
|
|
1291
|
-
polyfills:
|
|
1309
|
+
polyfills: W({
|
|
1292
1310
|
inputValue: r?.polyfills,
|
|
1293
1311
|
fileValue: e.polyfills,
|
|
1294
1312
|
defaultValue: _.POLYFILLS
|
|
@@ -1301,7 +1319,7 @@ async function Or(e) {
|
|
|
1301
1319
|
extend: t?.build?.extend
|
|
1302
1320
|
}
|
|
1303
1321
|
};
|
|
1304
|
-
return e.production && await
|
|
1322
|
+
return e.production && await Dt([C.OUTPUT_BASE_PATH]), Br({
|
|
1305
1323
|
config: o,
|
|
1306
1324
|
options: {
|
|
1307
1325
|
production: e.production,
|
|
@@ -1312,14 +1330,14 @@ async function Or(e) {
|
|
|
1312
1330
|
});
|
|
1313
1331
|
}
|
|
1314
1332
|
let ee, K = !1;
|
|
1315
|
-
const
|
|
1333
|
+
const Wr = (e, t, r, n = !0) => {
|
|
1316
1334
|
let o = r;
|
|
1317
1335
|
const s = new RegExp(`addEventListener\\((['"]?)${e}\\1,`, "g"), i = /firewall:\s*\(event\)\s*=>\s*{/g, c = !!r.match(i), a = /eventType\s*=\s*['"]firewall['"];/g, l = !!r.match(s);
|
|
1318
1336
|
return (n && l || c) && (o = r.replace(s, `addEventListener("${t}",`), c && (o = o.replace(a, "eventType = 'fetch';"))), { matchEvent: l || c, codeChanged: o };
|
|
1319
1337
|
};
|
|
1320
|
-
function
|
|
1338
|
+
function Mr(e) {
|
|
1321
1339
|
return new Promise((t) => {
|
|
1322
|
-
const r = new
|
|
1340
|
+
const r = new Et.Socket();
|
|
1323
1341
|
r.setTimeout(1e3), r.on("connect", () => {
|
|
1324
1342
|
r.destroy(), t(!0);
|
|
1325
1343
|
}), r.on("timeout", () => {
|
|
@@ -1329,12 +1347,12 @@ function jr(e) {
|
|
|
1329
1347
|
}), r.connect(e, "127.0.0.1");
|
|
1330
1348
|
});
|
|
1331
1349
|
}
|
|
1332
|
-
async function
|
|
1350
|
+
async function Lr(e) {
|
|
1333
1351
|
try {
|
|
1334
1352
|
return await h.access(e), await h.readFile(e, "utf8");
|
|
1335
1353
|
} catch (t) {
|
|
1336
1354
|
if (t.message.includes("ENOENT")) {
|
|
1337
|
-
const r =
|
|
1355
|
+
const r = V(e);
|
|
1338
1356
|
throw new Error(
|
|
1339
1357
|
`Server entry file "${r}" not found. Please specify your entry point using "azion dev <path>" or create the default handler file.${U}`
|
|
1340
1358
|
);
|
|
@@ -1342,18 +1360,18 @@ async function Ur(e) {
|
|
|
1342
1360
|
throw new Error(`Error reading file ${e}: ${t.message}${U}`);
|
|
1343
1361
|
}
|
|
1344
1362
|
}
|
|
1345
|
-
async function
|
|
1363
|
+
async function Hr(e, t) {
|
|
1346
1364
|
const { matchEvent: r, codeChanged: n } = (
|
|
1347
1365
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1348
|
-
|
|
1349
|
-
), s =
|
|
1350
|
-
return
|
|
1366
|
+
Wr("firewall", "fetch", t)
|
|
1367
|
+
), s = Ae(r ? n : t, r);
|
|
1368
|
+
return vt({ port: e, host: "0.0.0.0", runtime: s });
|
|
1351
1369
|
}
|
|
1352
1370
|
function we(e, t) {
|
|
1353
1371
|
const r = e?.bindings?.storage?.bucket || t?.storage?.[0].name || "", n = e?.bindings?.storage?.prefix || t?.storage?.[0].prefix || "";
|
|
1354
1372
|
return { bucketName: r, prefix: n };
|
|
1355
1373
|
}
|
|
1356
|
-
function
|
|
1374
|
+
function Vr(e, t, r) {
|
|
1357
1375
|
const n = Object.keys(e).find((o) => {
|
|
1358
1376
|
const s = o.replace(/\.dev$/, "").replace(/\.edge\//, "");
|
|
1359
1377
|
return r.replace(/\.js$/, "").endsWith(s);
|
|
@@ -1365,14 +1383,14 @@ function Nr(e, t, r) {
|
|
|
1365
1383
|
function be(e) {
|
|
1366
1384
|
return e.endsWith(".js") ? e : `${e}.js`;
|
|
1367
1385
|
}
|
|
1368
|
-
function
|
|
1386
|
+
function zr(e, t, r) {
|
|
1369
1387
|
if (!e || Object.keys(e).length === 0)
|
|
1370
1388
|
throw new Error("No entries provided");
|
|
1371
1389
|
if (r) {
|
|
1372
1390
|
const i = t.functions?.find((l) => l.name === r);
|
|
1373
1391
|
if (!i)
|
|
1374
1392
|
throw new Error(`Function "${r}" not found in edge functions configuration`);
|
|
1375
|
-
const c =
|
|
1393
|
+
const c = Vr(e, r, i.path), a = we(i, t);
|
|
1376
1394
|
return {
|
|
1377
1395
|
name: i.name,
|
|
1378
1396
|
bucket: a.bucketName,
|
|
@@ -1394,20 +1412,20 @@ async function fe(e, t, r = !1, n) {
|
|
|
1394
1412
|
const {
|
|
1395
1413
|
setup: { entry: o },
|
|
1396
1414
|
config: { functions: s, storage: i }
|
|
1397
|
-
} = await
|
|
1415
|
+
} = await Dr({ production: !1, skipFrameworkBuild: r });
|
|
1398
1416
|
let c;
|
|
1399
1417
|
try {
|
|
1400
1418
|
const {
|
|
1401
1419
|
path: a,
|
|
1402
1420
|
bucket: l,
|
|
1403
1421
|
prefix: f
|
|
1404
|
-
} =
|
|
1405
|
-
globalThis.AZION_BUCKET_NAME = l, globalThis.AZION_BUCKET_PREFIX = f, c = await
|
|
1422
|
+
} = zr(o, { functions: s, storage: i }, n);
|
|
1423
|
+
globalThis.AZION_BUCKET_NAME = l, globalThis.AZION_BUCKET_PREFIX = f, c = await Lr(a);
|
|
1406
1424
|
} catch (a) {
|
|
1407
1425
|
p.server.error(a.message), g.error(`Error reading worker file: ${a}`), process.exit(1);
|
|
1408
1426
|
}
|
|
1409
1427
|
try {
|
|
1410
|
-
ee = await
|
|
1428
|
+
ee = await Hr(t, c), p.server.success(
|
|
1411
1429
|
`Function running on port 0.0.0.0:${t}, url: http://localhost:${t}`
|
|
1412
1430
|
);
|
|
1413
1431
|
} catch (a) {
|
|
@@ -1424,7 +1442,7 @@ async function fe(e, t, r = !1, n) {
|
|
|
1424
1442
|
K = !1;
|
|
1425
1443
|
}
|
|
1426
1444
|
}
|
|
1427
|
-
async function
|
|
1445
|
+
async function Gr(e, t, r) {
|
|
1428
1446
|
if (!K && !(e.startsWith(".azion-bundler") || e.startsWith("azion") && e.includes(".temp") || e.startsWith(".edge") || e.startsWith("node_modules") || e.startsWith(".vercel"))) {
|
|
1429
1447
|
K = !0;
|
|
1430
1448
|
try {
|
|
@@ -1436,9 +1454,9 @@ async function Br(e, t, r) {
|
|
|
1436
1454
|
}
|
|
1437
1455
|
}
|
|
1438
1456
|
}
|
|
1439
|
-
async function
|
|
1440
|
-
await
|
|
1441
|
-
const s =
|
|
1457
|
+
async function Ue(e, t, r = !1, n) {
|
|
1458
|
+
await Mr(t) && (p.server.error(`Port ${t} is in use. Please choose another port.`), process.exit(1)), await fe(e, t, r, n);
|
|
1459
|
+
const s = st.watch("./", {
|
|
1442
1460
|
persistent: !0,
|
|
1443
1461
|
ignoreInitial: !0,
|
|
1444
1462
|
// Ignore the initial add events
|
|
@@ -1446,31 +1464,31 @@ async function je(e, t, r = !1, n) {
|
|
|
1446
1464
|
ignored: [".git", ".vscode", ".idea", ".sublime-text", ".history"]
|
|
1447
1465
|
// Added common IDE-related folders
|
|
1448
1466
|
}), i = async (c) => {
|
|
1449
|
-
await
|
|
1467
|
+
await Gr(c, e, t);
|
|
1450
1468
|
};
|
|
1451
1469
|
s.on("add", i).on("change", i).on("unlink", i).on("addDir", i).on("unlinkDir", i).on("error", (c) => g.error(`Watcher error: ${c}`)).on("ready", () => p.server.info("Initial scan complete. Ready for changes."));
|
|
1452
1470
|
}
|
|
1453
1471
|
const Ee = {
|
|
1454
|
-
runtime:
|
|
1455
|
-
server:
|
|
1456
|
-
readStore:
|
|
1472
|
+
runtime: Ae,
|
|
1473
|
+
server: Ue,
|
|
1474
|
+
readStore: rt,
|
|
1457
1475
|
readAzionConfig: oe,
|
|
1458
1476
|
writeStore: Se,
|
|
1459
1477
|
writeUserConfig: te
|
|
1460
1478
|
};
|
|
1461
|
-
async function
|
|
1479
|
+
async function jn({
|
|
1462
1480
|
entry: e,
|
|
1463
1481
|
port: t,
|
|
1464
1482
|
skipFrameworkBuild: r = !1,
|
|
1465
1483
|
functionName: n
|
|
1466
1484
|
}) {
|
|
1467
1485
|
const o = parseInt(t, 10);
|
|
1468
|
-
|
|
1486
|
+
Ue(e || null, o, r, n);
|
|
1469
1487
|
}
|
|
1470
1488
|
function ve() {
|
|
1471
1489
|
return Object.values(J).filter((t) => t.metadata?.name).map((t) => t.metadata.name);
|
|
1472
1490
|
}
|
|
1473
|
-
function
|
|
1491
|
+
function qr(e) {
|
|
1474
1492
|
const t = J[e];
|
|
1475
1493
|
if (!t)
|
|
1476
1494
|
throw new Error(
|
|
@@ -1478,7 +1496,7 @@ function Dr(e) {
|
|
|
1478
1496
|
);
|
|
1479
1497
|
return t.config;
|
|
1480
1498
|
}
|
|
1481
|
-
async function
|
|
1499
|
+
async function Un(e, t = {}) {
|
|
1482
1500
|
const r = process.env.CLEAN_OUTPUT_MODE === "true";
|
|
1483
1501
|
switch (e) {
|
|
1484
1502
|
case "ls":
|
|
@@ -1490,7 +1508,7 @@ async function xn(e, t = {}) {
|
|
|
1490
1508
|
return;
|
|
1491
1509
|
}
|
|
1492
1510
|
try {
|
|
1493
|
-
const n =
|
|
1511
|
+
const n = qr(t.preset);
|
|
1494
1512
|
console.log(JSON.stringify(n, null, 2));
|
|
1495
1513
|
} catch (n) {
|
|
1496
1514
|
p.error(n instanceof Error ? n.message : "Unknown error occurred");
|
|
@@ -1501,14 +1519,14 @@ async function xn(e, t = {}) {
|
|
|
1501
1519
|
break;
|
|
1502
1520
|
}
|
|
1503
1521
|
}
|
|
1504
|
-
function
|
|
1505
|
-
return
|
|
1522
|
+
function Kr(e) {
|
|
1523
|
+
return ct(e);
|
|
1506
1524
|
}
|
|
1507
|
-
const
|
|
1525
|
+
const Jr = { processConfigWrapper: Kr }, Xr = ".edge/manifest.json", Yr = "azion.config", Zr = async (e, t = k(process.cwd(), ".edge")) => {
|
|
1508
1526
|
try {
|
|
1509
|
-
await
|
|
1527
|
+
await z.access(t);
|
|
1510
1528
|
} catch {
|
|
1511
|
-
await
|
|
1529
|
+
await z.mkdir(t, { recursive: !0 });
|
|
1512
1530
|
}
|
|
1513
1531
|
let r;
|
|
1514
1532
|
if (typeof e == "object")
|
|
@@ -1522,37 +1540,37 @@ const Mr = { processConfigWrapper: Wr }, Lr = ".edge/manifest.json", Hr = "azion
|
|
|
1522
1540
|
r = s;
|
|
1523
1541
|
}
|
|
1524
1542
|
re(r);
|
|
1525
|
-
const n =
|
|
1526
|
-
await
|
|
1527
|
-
},
|
|
1543
|
+
const n = Jr.processConfigWrapper(r), o = k(t, "manifest.json");
|
|
1544
|
+
await z.writeFile(o, JSON.stringify(n, null, 2)), O.feedback.manifest.success(`Manifest generated successfully at ${o}`);
|
|
1545
|
+
}, Qr = async (e, t = Yr) => {
|
|
1528
1546
|
const n = await (async (o) => {
|
|
1529
1547
|
const s = ae(process.cwd(), o);
|
|
1530
|
-
if (
|
|
1548
|
+
if (I(s) !== ".json")
|
|
1531
1549
|
throw new Error("Input file must be .json");
|
|
1532
|
-
const i = await
|
|
1533
|
-
return
|
|
1534
|
-
})(e ||
|
|
1550
|
+
const i = await z.readFile(s, "utf8");
|
|
1551
|
+
return lt(i);
|
|
1552
|
+
})(e || Xr);
|
|
1535
1553
|
await $e.writeUserConfig(n, t), O.feedback.manifest.success(`Config file generated successfully at ${t}`);
|
|
1536
1554
|
};
|
|
1537
|
-
async function
|
|
1555
|
+
async function Rn(e) {
|
|
1538
1556
|
try {
|
|
1539
1557
|
const t = e.action || "generate", n = {
|
|
1540
1558
|
generate: async () => {
|
|
1541
1559
|
const o = e.entry || e.config;
|
|
1542
|
-
await
|
|
1560
|
+
await Zr(o, e.output);
|
|
1543
1561
|
},
|
|
1544
1562
|
transform: async () => {
|
|
1545
|
-
await
|
|
1563
|
+
await Qr(e.entry, e.output);
|
|
1546
1564
|
}
|
|
1547
1565
|
}[t];
|
|
1548
1566
|
n && await n(), n || (p.manifest.error(
|
|
1549
1567
|
"Only transform and generate actions are supported"
|
|
1550
1568
|
), process.exit(1));
|
|
1551
1569
|
} catch (t) {
|
|
1552
|
-
g.error(t), p.error(`${t instanceof Error ? t.message : String(t)}${U}`), await ie(
|
|
1570
|
+
g.error(t), p.error(`${t instanceof Error ? t.message : String(t)}${U}`), await ie(C.OUTPUT_BASE_PATH, { recursive: !0, force: !0 }), process.exit(1);
|
|
1553
1571
|
}
|
|
1554
1572
|
}
|
|
1555
|
-
async function
|
|
1573
|
+
async function Nn({ command: e, options: t }) {
|
|
1556
1574
|
const r = JSON.parse(
|
|
1557
1575
|
typeof t.config == "string" ? t.config : "{}"
|
|
1558
1576
|
), n = t.scope || "global";
|
|
@@ -1585,8 +1603,8 @@ function se(e) {
|
|
|
1585
1603
|
return e;
|
|
1586
1604
|
}
|
|
1587
1605
|
}
|
|
1588
|
-
async function
|
|
1589
|
-
const t = await
|
|
1606
|
+
async function en() {
|
|
1607
|
+
const t = await St("azion", {
|
|
1590
1608
|
searchPlaces: [
|
|
1591
1609
|
"azion.config.ts",
|
|
1592
1610
|
"azion.config.mts",
|
|
@@ -1607,11 +1625,11 @@ async function Gr() {
|
|
|
1607
1625
|
const r = t.filepath, n = await h.readFile(r, "utf8");
|
|
1608
1626
|
return { configPath: r, fileContent: n };
|
|
1609
1627
|
}
|
|
1610
|
-
const
|
|
1611
|
-
findAndReadConfigFile:
|
|
1628
|
+
const Re = {
|
|
1629
|
+
findAndReadConfigFile: en,
|
|
1612
1630
|
tryParseJSON: se
|
|
1613
1631
|
};
|
|
1614
|
-
function
|
|
1632
|
+
function tn(e) {
|
|
1615
1633
|
const t = {}, r = e.key.split(".");
|
|
1616
1634
|
let n = t;
|
|
1617
1635
|
for (let o = 0; o < r.length; o++) {
|
|
@@ -1624,7 +1642,7 @@ function qr(e) {
|
|
|
1624
1642
|
}
|
|
1625
1643
|
return t;
|
|
1626
1644
|
}
|
|
1627
|
-
function
|
|
1645
|
+
function rn(e) {
|
|
1628
1646
|
if (!e.config)
|
|
1629
1647
|
throw new Error("Config is required for read");
|
|
1630
1648
|
const t = e.config, r = e.key.split(".").flatMap((o) => {
|
|
@@ -1655,7 +1673,7 @@ function Kr(e) {
|
|
|
1655
1673
|
}
|
|
1656
1674
|
return n;
|
|
1657
1675
|
}
|
|
1658
|
-
function
|
|
1676
|
+
function nn(e) {
|
|
1659
1677
|
if (!e.config)
|
|
1660
1678
|
throw new Error("Config is required for delete");
|
|
1661
1679
|
const t = { ...e.config }, r = e.key.split(".");
|
|
@@ -1694,7 +1712,7 @@ function Jr(e) {
|
|
|
1694
1712
|
}
|
|
1695
1713
|
return t;
|
|
1696
1714
|
}
|
|
1697
|
-
function
|
|
1715
|
+
function sn(e) {
|
|
1698
1716
|
const t = e.match(
|
|
1699
1717
|
/^\s*export\s+default\s+defineConfig\s*\(\s*/m
|
|
1700
1718
|
), r = e.match(
|
|
@@ -1706,19 +1724,19 @@ function Xr(e) {
|
|
|
1706
1724
|
else if (r)
|
|
1707
1725
|
s = r.index + r[0].length;
|
|
1708
1726
|
else if (n) {
|
|
1709
|
-
const
|
|
1710
|
-
let d =
|
|
1727
|
+
const w = n.index + n[0].length;
|
|
1728
|
+
let d = w;
|
|
1711
1729
|
for (; d < e.length && e[d].match(/\s/); )
|
|
1712
1730
|
d++;
|
|
1713
1731
|
const y = e.slice(d).match(/^defineConfig\s*\(\s*/);
|
|
1714
|
-
y ? s = d + y[0].length : s =
|
|
1732
|
+
y ? s = d + y[0].length : s = w;
|
|
1715
1733
|
} else if (o) {
|
|
1716
|
-
const
|
|
1717
|
-
let d =
|
|
1734
|
+
const w = o.index + o[0].length;
|
|
1735
|
+
let d = w;
|
|
1718
1736
|
for (; d < e.length && e[d].match(/\s/); )
|
|
1719
1737
|
d++;
|
|
1720
1738
|
const y = e.slice(d).match(/^defineConfig\s*\(\s*/);
|
|
1721
|
-
y ? s = d + y[0].length : s =
|
|
1739
|
+
y ? s = d + y[0].length : s = w;
|
|
1722
1740
|
}
|
|
1723
1741
|
if (s === -1)
|
|
1724
1742
|
throw new Error("Could not find module.exports or export default in config file");
|
|
@@ -1731,47 +1749,47 @@ function Xr(e) {
|
|
|
1731
1749
|
if (!a)
|
|
1732
1750
|
throw new Error("Config object must start with { or (");
|
|
1733
1751
|
let l = 1, f = !1, u = "", m = e.length;
|
|
1734
|
-
for (let
|
|
1735
|
-
const d = e[
|
|
1752
|
+
for (let w = i + 1; w < e.length; w++) {
|
|
1753
|
+
const d = e[w], y = w > 0 ? e[w - 1] : "";
|
|
1736
1754
|
if ((d === '"' || d === "'" || d === "`") && y !== "\\") {
|
|
1737
1755
|
f ? d === u && (f = !1, u = "") : (f = !0, u = d);
|
|
1738
1756
|
continue;
|
|
1739
1757
|
}
|
|
1740
1758
|
if (!f && (d === c ? l++ : d === a && l--, l === 0)) {
|
|
1741
|
-
m =
|
|
1759
|
+
m = w + 1;
|
|
1742
1760
|
break;
|
|
1743
1761
|
}
|
|
1744
1762
|
}
|
|
1745
1763
|
return { start: s, end: m };
|
|
1746
1764
|
}
|
|
1747
|
-
async function
|
|
1765
|
+
async function on(e, t) {
|
|
1748
1766
|
try {
|
|
1749
1767
|
const r = Array.isArray(e) ? e : [{ placeholder: e, value: t }];
|
|
1750
1768
|
for (const { placeholder: d, value: y } of r)
|
|
1751
1769
|
if (typeof d != "string" || typeof y != "string")
|
|
1752
1770
|
throw new Error("Placeholder and value must be strings");
|
|
1753
|
-
const { configPath: n, fileContent: o } = await
|
|
1771
|
+
const { configPath: n, fileContent: o } = await Re.findAndReadConfigFile(), { start: s, end: i } = sn(o), c = o.slice(0, s);
|
|
1754
1772
|
let a = o.slice(s, i);
|
|
1755
1773
|
const l = o.slice(i), f = /* @__PURE__ */ new Map();
|
|
1756
1774
|
for (const { placeholder: d, value: y } of r) {
|
|
1757
1775
|
let T = 0, E = 0;
|
|
1758
1776
|
for (; E < a.length; ) {
|
|
1759
|
-
const
|
|
1760
|
-
if (
|
|
1761
|
-
const v =
|
|
1762
|
-
let
|
|
1777
|
+
const b = a.indexOf(d, E);
|
|
1778
|
+
if (b === -1) break;
|
|
1779
|
+
const v = b > 0 ? a[b - 1] : "", j = b + d.length < a.length ? a[b + d.length] : "";
|
|
1780
|
+
let B = !0;
|
|
1763
1781
|
if (typeof d == "string" && d.match(/[A-Za-z0-9_$]/)) {
|
|
1764
1782
|
const P = v && v.match(/[A-Za-z0-9_$]/), $ = j && j.match(/[A-Za-z0-9_]/);
|
|
1765
|
-
(P || $) && (
|
|
1783
|
+
(P || $) && (B = !1);
|
|
1766
1784
|
}
|
|
1767
|
-
|
|
1785
|
+
B ? (a = a.slice(0, b) + y + a.slice(b + d.length), E = b + y.length, T++) : E = b + 1;
|
|
1768
1786
|
}
|
|
1769
1787
|
T > 0 && f.set(d, T);
|
|
1770
1788
|
}
|
|
1771
1789
|
const u = c + a + l;
|
|
1772
1790
|
let m;
|
|
1773
1791
|
try {
|
|
1774
|
-
m = await
|
|
1792
|
+
m = await Ce.format(u, {
|
|
1775
1793
|
parser: "babel",
|
|
1776
1794
|
semi: !1,
|
|
1777
1795
|
singleQuote: !0,
|
|
@@ -1781,8 +1799,8 @@ async function Yr(e, t) {
|
|
|
1781
1799
|
m = u;
|
|
1782
1800
|
}
|
|
1783
1801
|
await h.writeFile(n, m, "utf8");
|
|
1784
|
-
const
|
|
1785
|
-
if (
|
|
1802
|
+
const w = Array.from(f.values()).reduce((d, y) => d + y, 0);
|
|
1803
|
+
if (w === 0)
|
|
1786
1804
|
p.info(`No placeholders found to replace in ${S.basename(n)}`);
|
|
1787
1805
|
else if (f.size === 1) {
|
|
1788
1806
|
const [d, y] = Array.from(f.entries())[0], T = r.find((E) => E.placeholder === d);
|
|
@@ -1791,11 +1809,11 @@ async function Yr(e, t) {
|
|
|
1791
1809
|
);
|
|
1792
1810
|
} else {
|
|
1793
1811
|
const d = Array.from(f.entries()).map(([y, T]) => {
|
|
1794
|
-
const E = r.find((
|
|
1812
|
+
const E = r.find((b) => b.placeholder === y);
|
|
1795
1813
|
return `"${y}" -> "${E?.value}" (${T})`;
|
|
1796
1814
|
}).join(", ");
|
|
1797
1815
|
p.info(
|
|
1798
|
-
`Successfully replaced ${
|
|
1816
|
+
`Successfully replaced ${w} occurrences of ${f.size} placeholders (${d}) in ${S.basename(n)}`
|
|
1799
1817
|
);
|
|
1800
1818
|
}
|
|
1801
1819
|
} catch (r) {
|
|
@@ -1804,12 +1822,12 @@ async function Yr(e, t) {
|
|
|
1804
1822
|
);
|
|
1805
1823
|
}
|
|
1806
1824
|
}
|
|
1807
|
-
async function
|
|
1825
|
+
async function an(e, t) {
|
|
1808
1826
|
try {
|
|
1809
|
-
const { configPath: r, fileContent: n } = await
|
|
1827
|
+
const { configPath: r, fileContent: n } = await Re.findAndReadConfigFile(), o = cn(n, e, t);
|
|
1810
1828
|
let s;
|
|
1811
1829
|
try {
|
|
1812
|
-
s = await
|
|
1830
|
+
s = await Ce.format(o, {
|
|
1813
1831
|
parser: "babel",
|
|
1814
1832
|
semi: !1,
|
|
1815
1833
|
singleQuote: !0,
|
|
@@ -1827,11 +1845,11 @@ async function Zr(e, t) {
|
|
|
1827
1845
|
);
|
|
1828
1846
|
}
|
|
1829
1847
|
}
|
|
1830
|
-
function
|
|
1831
|
-
return
|
|
1848
|
+
function cn(e, t, r) {
|
|
1849
|
+
return ln(e, t, r);
|
|
1832
1850
|
}
|
|
1833
|
-
function
|
|
1834
|
-
const n =
|
|
1851
|
+
function ln(e, t, r) {
|
|
1852
|
+
const n = un(r), o = e.replace(/\n\s*/g, " ").replace(/\s+/g, " "), s = o.match(
|
|
1835
1853
|
/(.*(?:module\.exports\s*=(?:\s+\w+\()?|export default(?:\s+\w+\()?)\s*)\{/
|
|
1836
1854
|
);
|
|
1837
1855
|
if (!s)
|
|
@@ -1847,24 +1865,24 @@ function en(e, t, r) {
|
|
|
1847
1865
|
}
|
|
1848
1866
|
if (c !== 0)
|
|
1849
1867
|
return e;
|
|
1850
|
-
const u = o.substring(i, a), m =
|
|
1868
|
+
const u = o.substring(i, a), m = fn(t), w = ue(u, m, n), d = e.match(
|
|
1851
1869
|
/(.*(?:module\.exports\s*=(?:\s+\w+\()?|export default(?:\s+\w+\()?)\s*)\{/s
|
|
1852
1870
|
);
|
|
1853
1871
|
if (!d)
|
|
1854
1872
|
return e;
|
|
1855
1873
|
const y = d[1] + "{", T = d[0].length;
|
|
1856
|
-
let E = 1,
|
|
1874
|
+
let E = 1, b = T, v = !1, j = "";
|
|
1857
1875
|
for (let P = T; P < e.length && E > 0; P++) {
|
|
1858
1876
|
const $ = e[P];
|
|
1859
1877
|
if (v ? $ === j && e[P - 1] !== "\\" && (v = !1) : $ === '"' || $ === "'" ? (v = !0, j = $) : $ === "{" ? E++ : $ === "}" && E--, E === 0) {
|
|
1860
|
-
|
|
1878
|
+
b = P;
|
|
1861
1879
|
break;
|
|
1862
1880
|
}
|
|
1863
1881
|
}
|
|
1864
|
-
const
|
|
1865
|
-
return y +
|
|
1882
|
+
const B = "}" + e.substring(b + 1);
|
|
1883
|
+
return y + w + B;
|
|
1866
1884
|
}
|
|
1867
|
-
function
|
|
1885
|
+
function fn(e) {
|
|
1868
1886
|
const t = [];
|
|
1869
1887
|
let r = "", n = 0;
|
|
1870
1888
|
for (; n < e.length; ) {
|
|
@@ -1902,16 +1920,16 @@ function ue(e, t, r) {
|
|
|
1902
1920
|
if (a === -1)
|
|
1903
1921
|
return e;
|
|
1904
1922
|
let l = 0, f = !1, u = "", m = -1;
|
|
1905
|
-
for (let
|
|
1906
|
-
const v = e[
|
|
1923
|
+
for (let b = a; b < e.length; b++) {
|
|
1924
|
+
const v = e[b];
|
|
1907
1925
|
if (f)
|
|
1908
|
-
v === u && e[
|
|
1926
|
+
v === u && e[b - 1] !== "\\" && (f = !1);
|
|
1909
1927
|
else if (v === '"' || v === "'")
|
|
1910
1928
|
f = !0, u = v;
|
|
1911
1929
|
else if (v === "{")
|
|
1912
1930
|
l++;
|
|
1913
1931
|
else if (v === "}" && (l--, l === 0)) {
|
|
1914
|
-
m =
|
|
1932
|
+
m = b;
|
|
1915
1933
|
break;
|
|
1916
1934
|
}
|
|
1917
1935
|
}
|
|
@@ -1924,16 +1942,16 @@ function ue(e, t, r) {
|
|
|
1924
1942
|
if (a === -1)
|
|
1925
1943
|
return e;
|
|
1926
1944
|
let l = 0, f = !1, u = "", m = -1;
|
|
1927
|
-
for (let
|
|
1928
|
-
const v = e[
|
|
1945
|
+
for (let b = a; b < e.length; b++) {
|
|
1946
|
+
const v = e[b];
|
|
1929
1947
|
if (f)
|
|
1930
|
-
v === u && e[
|
|
1948
|
+
v === u && e[b - 1] !== "\\" && (f = !1);
|
|
1931
1949
|
else if (v === '"' || v === "'")
|
|
1932
1950
|
f = !0, u = v;
|
|
1933
1951
|
else if (v === "[")
|
|
1934
1952
|
l++;
|
|
1935
1953
|
else if (v === "]" && (l--, l === 0)) {
|
|
1936
|
-
m =
|
|
1954
|
+
m = b;
|
|
1937
1955
|
break;
|
|
1938
1956
|
}
|
|
1939
1957
|
}
|
|
@@ -2012,7 +2030,7 @@ function Te(e, t, r) {
|
|
|
2012
2030
|
}
|
|
2013
2031
|
return s.join(", ");
|
|
2014
2032
|
}
|
|
2015
|
-
function
|
|
2033
|
+
function un(e) {
|
|
2016
2034
|
if (typeof e == "string") {
|
|
2017
2035
|
if (e.startsWith('"') && e.endsWith('"') || e.startsWith("'") && e.endsWith("'"))
|
|
2018
2036
|
return e;
|
|
@@ -2021,7 +2039,7 @@ function rn(e) {
|
|
|
2021
2039
|
}
|
|
2022
2040
|
return String(e);
|
|
2023
2041
|
}
|
|
2024
|
-
async function
|
|
2042
|
+
async function In({ command: e, options: t }) {
|
|
2025
2043
|
try {
|
|
2026
2044
|
const r = await oe();
|
|
2027
2045
|
if (t.all) {
|
|
@@ -2046,7 +2064,7 @@ async function Fn({ command: e, options: t }) {
|
|
|
2046
2064
|
throw new Error("Configuration already exists. Use update command instead.");
|
|
2047
2065
|
if (i === void 0)
|
|
2048
2066
|
throw new Error("Value is required for create command");
|
|
2049
|
-
c =
|
|
2067
|
+
c = tn({
|
|
2050
2068
|
key: s,
|
|
2051
2069
|
value: i
|
|
2052
2070
|
});
|
|
@@ -2056,18 +2074,18 @@ async function Fn({ command: e, options: t }) {
|
|
|
2056
2074
|
throw new Error("No configuration found. Use create command first.");
|
|
2057
2075
|
if (i === void 0)
|
|
2058
2076
|
throw new Error("Value is required for update command");
|
|
2059
|
-
return await
|
|
2077
|
+
return await an(s, i), {};
|
|
2060
2078
|
case "read":
|
|
2061
2079
|
if (!r)
|
|
2062
2080
|
throw new Error("No configuration found");
|
|
2063
|
-
return a =
|
|
2081
|
+
return a = rn({
|
|
2064
2082
|
key: s,
|
|
2065
2083
|
config: r
|
|
2066
2084
|
}), a;
|
|
2067
2085
|
case "delete":
|
|
2068
2086
|
if (!r)
|
|
2069
2087
|
throw new Error("No configuration found");
|
|
2070
|
-
c =
|
|
2088
|
+
c = nn({
|
|
2071
2089
|
key: s,
|
|
2072
2090
|
config: r
|
|
2073
2091
|
});
|
|
@@ -2103,7 +2121,7 @@ async function Fn({ command: e, options: t }) {
|
|
|
2103
2121
|
throw new Error(
|
|
2104
2122
|
"Replacements are required for replace command. Use -k/-v pairs or --replacements JSON"
|
|
2105
2123
|
);
|
|
2106
|
-
return await
|
|
2124
|
+
return await on(l), {};
|
|
2107
2125
|
}
|
|
2108
2126
|
default:
|
|
2109
2127
|
throw new Error(`Unknown command: ${e}`);
|
|
@@ -2113,9 +2131,9 @@ async function Fn({ command: e, options: t }) {
|
|
|
2113
2131
|
g.error(r), p.error(`${r instanceof Error ? r.message : String(r)}`), process.exit(1);
|
|
2114
2132
|
}
|
|
2115
2133
|
}
|
|
2116
|
-
async function
|
|
2117
|
-
const t = e.path || k(
|
|
2118
|
-
|
|
2134
|
+
async function Bn(e = {}) {
|
|
2135
|
+
const t = e.path || k(C.OUTPUT_BASE_PATH, "telemetry-report.html");
|
|
2136
|
+
ke(t) || (p.error(
|
|
2119
2137
|
`Telemetry report not found at: ${t}
|
|
2120
2138
|
|
|
2121
2139
|
Make sure you have run a build with the --telemetry flag first.
|
|
@@ -2137,11 +2155,11 @@ Or: ef build --telemetry`
|
|
|
2137
2155
|
}
|
|
2138
2156
|
}
|
|
2139
2157
|
export {
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2158
|
+
Dr as buildCommand,
|
|
2159
|
+
In as configCommand,
|
|
2160
|
+
jn as devCommand,
|
|
2161
|
+
Rn as manifestCommand,
|
|
2162
|
+
Un as presetsCommand,
|
|
2163
|
+
Nn as storeCommand,
|
|
2164
|
+
Bn as telemetryCommand
|
|
2147
2165
|
};
|