@awsless/cli 0.0.46-local.47 → 0.0.46-local.49
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/dist/app.json +1 -1
- package/dist/app.stage.json +1 -1
- package/dist/bin.js +196 -129
- package/dist/handlers/bundle.js +2 -0
- package/dist/stack.json +1 -1
- package/dist/stack.stage.json +1 -1
- package/package.json +16 -16
package/dist/bin.js
CHANGED
|
@@ -150186,6 +150186,38 @@ var bootstrapAwsless = async (props) => {
|
|
|
150186
150186
|
// src/config/load/load.ts
|
|
150187
150187
|
import { basename as basename2, dirname as dirname5, join as join13 } from "path";
|
|
150188
150188
|
|
|
150189
|
+
// src/config/schema/local-entry.ts
|
|
150190
|
+
import { stat as stat2 } from "fs/promises";
|
|
150191
|
+
|
|
150192
|
+
// src/config/schema/relative-path.ts
|
|
150193
|
+
import { join as join11 } from "path";
|
|
150194
|
+
var basePath;
|
|
150195
|
+
var setLocalBasePath = (path2) => {
|
|
150196
|
+
basePath = path2;
|
|
150197
|
+
};
|
|
150198
|
+
var resolvePath = (path2) => {
|
|
150199
|
+
if (path2.startsWith(".") && basePath) {
|
|
150200
|
+
return join11(basePath, path2);
|
|
150201
|
+
}
|
|
150202
|
+
return path2;
|
|
150203
|
+
};
|
|
150204
|
+
var RelativePathSchema = exports_external.string().transform((path2) => resolvePath(path2));
|
|
150205
|
+
|
|
150206
|
+
// src/config/schema/local-entry.ts
|
|
150207
|
+
var LocalEntrySchema = exports_external.union([
|
|
150208
|
+
RelativePathSchema.refine(async (path2) => {
|
|
150209
|
+
try {
|
|
150210
|
+
const s2 = await stat2(path2);
|
|
150211
|
+
return s2.isFile() || s2.isDirectory();
|
|
150212
|
+
} catch (error3) {
|
|
150213
|
+
return false;
|
|
150214
|
+
}
|
|
150215
|
+
}, `File or directory doesn't exist`),
|
|
150216
|
+
exports_external.object({
|
|
150217
|
+
nocheck: RelativePathSchema.describe("Specifies a local file or directory without checking if the file or directory exists.")
|
|
150218
|
+
}).transform((v3) => v3.nocheck)
|
|
150219
|
+
]);
|
|
150220
|
+
|
|
150189
150221
|
// src/config/schema/config-ref.ts
|
|
150190
150222
|
var ConfigRefSchema = exports_external.string().regex(/^config:[a-z0-9-]+$/, "Invalid config reference");
|
|
150191
150223
|
var isConfigRef = (value) => {
|
|
@@ -150352,27 +150384,11 @@ var parse3 = (value) => {
|
|
|
150352
150384
|
};
|
|
150353
150385
|
|
|
150354
150386
|
// src/config/schema/local-file.ts
|
|
150355
|
-
import { stat as
|
|
150356
|
-
|
|
150357
|
-
// src/config/schema/relative-path.ts
|
|
150358
|
-
import { join as join11 } from "path";
|
|
150359
|
-
var basePath;
|
|
150360
|
-
var setLocalBasePath = (path2) => {
|
|
150361
|
-
basePath = path2;
|
|
150362
|
-
};
|
|
150363
|
-
var resolvePath = (path2) => {
|
|
150364
|
-
if (path2.startsWith(".") && basePath) {
|
|
150365
|
-
return join11(basePath, path2);
|
|
150366
|
-
}
|
|
150367
|
-
return path2;
|
|
150368
|
-
};
|
|
150369
|
-
var RelativePathSchema = exports_external.string().transform((path2) => resolvePath(path2));
|
|
150370
|
-
|
|
150371
|
-
// src/config/schema/local-file.ts
|
|
150387
|
+
import { stat as stat3 } from "fs/promises";
|
|
150372
150388
|
var LocalFileSchema = exports_external.union([
|
|
150373
150389
|
RelativePathSchema.refine(async (path2) => {
|
|
150374
150390
|
try {
|
|
150375
|
-
const s2 = await
|
|
150391
|
+
const s2 = await stat3(path2);
|
|
150376
150392
|
return s2.isFile();
|
|
150377
150393
|
} catch (error3) {
|
|
150378
150394
|
return false;
|
|
@@ -151222,11 +151238,11 @@ var IndexSchema = exports_external.object({
|
|
|
151222
151238
|
var SearchsSchema = exports_external.record(IndexNameSchema, IndexSchema).optional().describe("Define the search indexes in your stack, backed by the one shared OpenSearch domain of your app. The physical index name is prefixed with the stack name.");
|
|
151223
151239
|
|
|
151224
151240
|
// src/config/schema/local-directory.ts
|
|
151225
|
-
import { stat as
|
|
151241
|
+
import { stat as stat4 } from "fs/promises";
|
|
151226
151242
|
var LocalDirectorySchema = exports_external.union([
|
|
151227
151243
|
RelativePathSchema.refine(async (path2) => {
|
|
151228
151244
|
try {
|
|
151229
|
-
const s2 = await
|
|
151245
|
+
const s2 = await stat4(path2);
|
|
151230
151246
|
return s2.isDirectory();
|
|
151231
151247
|
} catch (error3) {
|
|
151232
151248
|
return false;
|
|
@@ -151304,6 +151320,7 @@ var AppSchema = exports_external.object({
|
|
|
151304
151320
|
profile: exports_external.string().describe("The AWS profile to deploy to."),
|
|
151305
151321
|
protect: exports_external.boolean().default(false).describe("Protect your app & stacks from being deleted."),
|
|
151306
151322
|
configs: ConfigsSchema,
|
|
151323
|
+
seed: LocalEntrySchema.optional().describe("The file that seeds your local dev environment with data. It runs with the full local environment on the first dev boot & through the dashboard reseed button. One app wide file, so the seeding order is explicit."),
|
|
151307
151324
|
removal: exports_external.enum(["remove", "retain"]).default("remove").describe([
|
|
151308
151325
|
"Configure how your resources are handled when they have to be removed.",
|
|
151309
151326
|
"",
|
|
@@ -151330,22 +151347,6 @@ var AppSchema = exports_external.object({
|
|
|
151330
151347
|
test: TestDefaultSchema
|
|
151331
151348
|
}).strict();
|
|
151332
151349
|
|
|
151333
|
-
// src/config/schema/local-entry.ts
|
|
151334
|
-
import { stat as stat4 } from "fs/promises";
|
|
151335
|
-
var LocalEntrySchema = exports_external.union([
|
|
151336
|
-
RelativePathSchema.refine(async (path2) => {
|
|
151337
|
-
try {
|
|
151338
|
-
const s2 = await stat4(path2);
|
|
151339
|
-
return s2.isFile() || s2.isDirectory();
|
|
151340
|
-
} catch (error3) {
|
|
151341
|
-
return false;
|
|
151342
|
-
}
|
|
151343
|
-
}, `File or directory doesn't exist`),
|
|
151344
|
-
exports_external.object({
|
|
151345
|
-
nocheck: RelativePathSchema.describe("Specifies a local file or directory without checking if the file or directory exists.")
|
|
151346
|
-
}).transform((v3) => v3.nocheck)
|
|
151347
|
-
]);
|
|
151348
|
-
|
|
151349
151350
|
// src/feature/cache/schema.ts
|
|
151350
151351
|
var StorageSchema = SizeSchema.refine(sizeMin(gibibytes(1)), "Minimum storage size is 1 GB").refine(sizeMax(gibibytes(5000)), "Maximum storage size is 5000 GB");
|
|
151351
151352
|
var MinimumStorageSchema = StorageSchema.describe("The lower limit for data storage the cache is set to use. You can specify a size value from 1 GB to 5000 GB.");
|
|
@@ -151668,7 +151669,6 @@ var StackSchema = exports_external.object({
|
|
|
151668
151669
|
pubsub: PubSubSchema,
|
|
151669
151670
|
searchs: SearchsSchema,
|
|
151670
151671
|
sites: SitesSchema,
|
|
151671
|
-
seed: LocalEntrySchema.optional().describe("The file that seeds your local dev environment with data. It runs with the full local environment on the first dev boot & through the dashboard reseed button."),
|
|
151672
151672
|
tests: TestsSchema,
|
|
151673
151673
|
images: ImagesSchema,
|
|
151674
151674
|
icons: IconsSchema,
|
|
@@ -153541,9 +153541,14 @@ for (const name in env) {
|
|
|
153541
153541
|
process.env[name] ??= env[name]
|
|
153542
153542
|
}
|
|
153543
153543
|
|
|
153544
|
-
const
|
|
153544
|
+
const runtime = await import(${JSON.stringify(runtime)})
|
|
153545
153545
|
|
|
153546
|
-
|
|
153546
|
+
// The local dev worker tags console output with the active route. A
|
|
153547
|
+
// lazy accessor instead of a re-export, since a static re-export would
|
|
153548
|
+
// hoist the runtime import above the env application.
|
|
153549
|
+
export const getCurrentRoute = () => runtime.getCurrentRoute?.()
|
|
153550
|
+
|
|
153551
|
+
export default runtime.createBundle({
|
|
153547
153552
|
${entries2.join(`
|
|
153548
153553
|
`)}
|
|
153549
153554
|
})
|
|
@@ -166204,7 +166209,7 @@ var watchConfig = async (options, resolve5, reject) => {
|
|
|
166204
166209
|
|
|
166205
166210
|
// src/dev/index.ts
|
|
166206
166211
|
import { loadWorkspace as loadWorkspace3 } from "@awsless/ts-file-cache";
|
|
166207
|
-
import { mkdir as
|
|
166212
|
+
import { mkdir as mkdir10, rm as rm12, writeFile as writeFile14 } from "fs/promises";
|
|
166208
166213
|
import { join as join54 } from "path";
|
|
166209
166214
|
|
|
166210
166215
|
// src/dev/context.ts
|
|
@@ -166513,88 +166518,50 @@ var createDevContext = (props) => {
|
|
|
166513
166518
|
|
|
166514
166519
|
// src/dev/seed.ts
|
|
166515
166520
|
import { spawn as spawn5 } from "child_process";
|
|
166516
|
-
import { mkdir as mkdir9, writeFile as writeFile12 } from "fs/promises";
|
|
166517
166521
|
import { isAbsolute as isAbsolute4, join as join50 } from "path";
|
|
166518
|
-
import { pathToFileURL } from "url";
|
|
166519
|
-
var MARKER = "__awsless_seed__:";
|
|
166520
166522
|
var createSeedRunner = (props) => {
|
|
166521
|
-
const
|
|
166522
|
-
name: stack.name,
|
|
166523
|
-
file: isAbsolute4(stack.seed) ? stack.seed : join50(directories.root, stack.seed)
|
|
166524
|
-
}));
|
|
166523
|
+
const file2 = props.seed && (isAbsolute4(props.seed) ? props.seed : join50(directories.root, props.seed));
|
|
166525
166524
|
let running;
|
|
166526
166525
|
const run = () => {
|
|
166527
166526
|
running ??= (async () => {
|
|
166528
166527
|
try {
|
|
166529
|
-
|
|
166530
|
-
return
|
|
166531
|
-
|
|
166532
|
-
|
|
166533
|
-
}).join("");
|
|
166534
|
-
const runnerDir = join50(directories.output, "local");
|
|
166535
|
-
const runnerFile = join50(runnerDir, "seed-runner.mjs");
|
|
166536
|
-
await mkdir9(runnerDir, { recursive: true });
|
|
166537
|
-
await writeFile12(runnerFile, runner);
|
|
166538
|
-
const timings = [];
|
|
166528
|
+
if (!file2) {
|
|
166529
|
+
return;
|
|
166530
|
+
}
|
|
166531
|
+
debug(`Seeding from ${props.seed}`);
|
|
166539
166532
|
await new Promise((resolve5, reject) => {
|
|
166540
|
-
const child = spawn5("bun", [
|
|
166533
|
+
const child = spawn5("bun", [file2], {
|
|
166541
166534
|
cwd: directories.root,
|
|
166542
166535
|
stdio: ["ignore", "pipe", "pipe"],
|
|
166543
166536
|
env: { ...process.env, ...props.env }
|
|
166544
166537
|
});
|
|
166545
|
-
let current;
|
|
166546
|
-
let started = Date.now();
|
|
166547
166538
|
const output = [];
|
|
166548
|
-
let buffered = "";
|
|
166549
166539
|
const capture = (chunk3) => {
|
|
166550
|
-
|
|
166551
|
-
let index;
|
|
166552
|
-
while ((index = buffered.indexOf(`
|
|
166553
|
-
`)) >= 0) {
|
|
166554
|
-
const line = buffered.slice(0, index);
|
|
166555
|
-
buffered = buffered.slice(index + 1);
|
|
166556
|
-
if (line.startsWith(MARKER)) {
|
|
166557
|
-
if (current) {
|
|
166558
|
-
timings.push([current, Date.now() - started]);
|
|
166559
|
-
}
|
|
166560
|
-
current = line.slice(MARKER.length);
|
|
166561
|
-
started = Date.now();
|
|
166562
|
-
debug(`Seeding the ${current} stack`);
|
|
166563
|
-
} else {
|
|
166564
|
-
output.push(line);
|
|
166565
|
-
}
|
|
166566
|
-
}
|
|
166540
|
+
output.push(chunk3.toString());
|
|
166567
166541
|
};
|
|
166568
166542
|
child.stdout?.on("data", capture);
|
|
166569
166543
|
child.stderr?.on("data", capture);
|
|
166570
166544
|
child.on("error", reject);
|
|
166571
166545
|
child.on("exit", (code) => {
|
|
166572
|
-
|
|
166573
|
-
`));
|
|
166574
|
-
const logs = output.join(`
|
|
166575
|
-
`).trim();
|
|
166546
|
+
const logs = output.join("").trim();
|
|
166576
166547
|
if (logs) {
|
|
166577
166548
|
debug(logs);
|
|
166578
166549
|
}
|
|
166579
166550
|
if (code === 0) {
|
|
166580
|
-
if (current) {
|
|
166581
|
-
timings.push([current, Date.now() - started]);
|
|
166582
|
-
}
|
|
166583
166551
|
resolve5();
|
|
166584
166552
|
} else {
|
|
166585
|
-
reject(new Error(`The seed
|
|
166553
|
+
reject(new Error(`The seed exited with code ${code}:
|
|
166586
166554
|
${logs}`));
|
|
166587
166555
|
}
|
|
166588
166556
|
});
|
|
166589
166557
|
});
|
|
166590
|
-
return timings;
|
|
166591
166558
|
} finally {
|
|
166592
166559
|
running = undefined;
|
|
166593
166560
|
}
|
|
166594
166561
|
})();
|
|
166595
166562
|
return running;
|
|
166596
166563
|
};
|
|
166597
|
-
return { count:
|
|
166564
|
+
return { count: file2 ? 1 : 0, run };
|
|
166598
166565
|
};
|
|
166599
166566
|
|
|
166600
166567
|
// src/dev/dashboard/index.ts
|
|
@@ -166602,13 +166569,13 @@ var import_ioredis5 = __toESM(require_built3(), 1);
|
|
|
166602
166569
|
import { DynamoDBClient as DynamoDBClient5 } from "@aws-sdk/client-dynamodb";
|
|
166603
166570
|
import { DynamoDBDocumentClient, ScanCommand as ScanCommand2 } from "@aws-sdk/lib-dynamodb";
|
|
166604
166571
|
import { randomUUID as randomUUID6 } from "crypto";
|
|
166605
|
-
import { readdir as readdir9, readFile as readFile22, stat as stat8, writeFile as
|
|
166572
|
+
import { readdir as readdir9, readFile as readFile22, stat as stat8, writeFile as writeFile13 } from "fs/promises";
|
|
166606
166573
|
import { createServer as createServer9 } from "http";
|
|
166607
166574
|
import { join as join52, relative as relative10, sep as sep5 } from "path";
|
|
166608
166575
|
|
|
166609
166576
|
// src/dev/worker.ts
|
|
166610
166577
|
import { spawn as spawn6 } from "child_process";
|
|
166611
|
-
import { writeFile as
|
|
166578
|
+
import { writeFile as writeFile12 } from "fs/promises";
|
|
166612
166579
|
import { join as join51 } from "path";
|
|
166613
166580
|
class WorkerError extends Error {
|
|
166614
166581
|
name;
|
|
@@ -166621,11 +166588,35 @@ class WorkerError extends Error {
|
|
|
166621
166588
|
}
|
|
166622
166589
|
}
|
|
166623
166590
|
var WORKER_ENTRY = `import { createServer } from 'node:http'
|
|
166591
|
+
import { format } from 'node:util'
|
|
166624
166592
|
|
|
166625
166593
|
let handler
|
|
166594
|
+
let getCurrentRoute = () => undefined
|
|
166595
|
+
|
|
166596
|
+
// Every console call writes ONE framed record: an invisible \\x1f
|
|
166597
|
+
// marker with the active bundle route & the json-encoded text, so
|
|
166598
|
+
// multi-line output stays a single log entry downstream. The route
|
|
166599
|
+
// comes from the bundle's async context, accurate even under
|
|
166600
|
+
// concurrent requests.
|
|
166601
|
+
const patchConsole = (method, stream) => {
|
|
166602
|
+
console[method] = (...args) => {
|
|
166603
|
+
const route = getCurrentRoute() ?? ''
|
|
166604
|
+
|
|
166605
|
+
stream.write('\\x1f' + route + '\\x1f' + JSON.stringify(format(...args)) + '\\n')
|
|
166606
|
+
}
|
|
166607
|
+
}
|
|
166608
|
+
|
|
166609
|
+
patchConsole('log', process.stdout)
|
|
166610
|
+
patchConsole('info', process.stdout)
|
|
166611
|
+
patchConsole('debug', process.stdout)
|
|
166612
|
+
patchConsole('warn', process.stderr)
|
|
166613
|
+
patchConsole('error', process.stderr)
|
|
166626
166614
|
|
|
166627
166615
|
try {
|
|
166628
|
-
|
|
166616
|
+
const bundle = await import('./files/index.mjs')
|
|
166617
|
+
|
|
166618
|
+
handler = bundle.default
|
|
166619
|
+
getCurrentRoute = bundle.getCurrentRoute ?? getCurrentRoute
|
|
166629
166620
|
} catch (error) {
|
|
166630
166621
|
// Keep module load failures readable, instead of node dumping the
|
|
166631
166622
|
// whole minified line that threw.
|
|
@@ -166703,7 +166694,7 @@ var createBundleWorker = (props) => {
|
|
|
166703
166694
|
};
|
|
166704
166695
|
const start = async () => {
|
|
166705
166696
|
const entry = join51(props.buildDir, "worker.mjs");
|
|
166706
|
-
await
|
|
166697
|
+
await writeFile12(entry, WORKER_ENTRY);
|
|
166707
166698
|
port = await findFreePort();
|
|
166708
166699
|
child = spawn6("node", ["--enable-source-maps", entry], {
|
|
166709
166700
|
cwd: props.buildDir,
|
|
@@ -166714,13 +166705,34 @@ var createBundleWorker = (props) => {
|
|
|
166714
166705
|
AWSLESS_DEV_WORKER_PORT: String(port)
|
|
166715
166706
|
}
|
|
166716
166707
|
});
|
|
166708
|
+
const buffers = { stdout: "", stderr: "" };
|
|
166717
166709
|
const capture = (stream2) => (chunk3) => {
|
|
166718
|
-
|
|
166719
|
-
|
|
166720
|
-
`)
|
|
166721
|
-
|
|
166722
|
-
|
|
166723
|
-
|
|
166710
|
+
buffers[stream2] += chunk3.toString();
|
|
166711
|
+
const parts = buffers[stream2].split(`
|
|
166712
|
+
`);
|
|
166713
|
+
buffers[stream2] = parts.pop() ?? "";
|
|
166714
|
+
for (const raw of parts) {
|
|
166715
|
+
if (raw === "") {
|
|
166716
|
+
continue;
|
|
166717
|
+
}
|
|
166718
|
+
let text2 = raw;
|
|
166719
|
+
let route;
|
|
166720
|
+
if (raw.startsWith("\x1F")) {
|
|
166721
|
+
const end = raw.indexOf("\x1F", 1);
|
|
166722
|
+
if (end > 0) {
|
|
166723
|
+
route = raw.slice(1, end) || undefined;
|
|
166724
|
+
try {
|
|
166725
|
+
text2 = JSON.parse(raw.slice(end + 1));
|
|
166726
|
+
} catch (_4) {
|
|
166727
|
+
text2 = raw.slice(end + 1);
|
|
166728
|
+
}
|
|
166729
|
+
}
|
|
166730
|
+
}
|
|
166731
|
+
process[stream2].write((route ? `[${route}] ` : "") + text2 + `
|
|
166732
|
+
`);
|
|
166733
|
+
const clean = stripAnsi2(text2);
|
|
166734
|
+
if (clean.trim() !== "") {
|
|
166735
|
+
props.onOutput?.(clean, stream2, route);
|
|
166724
166736
|
}
|
|
166725
166737
|
}
|
|
166726
166738
|
};
|
|
@@ -166831,8 +166843,12 @@ var dashboardHtml = `<!doctype html>
|
|
|
166831
166843
|
}
|
|
166832
166844
|
.logs .line { display: flex; gap: 8px; padding: 1px 0; }
|
|
166833
166845
|
.logs .time { color: var(--muted); flex-shrink: 0; }
|
|
166846
|
+
.logs .route { color: var(--accent); word-break: break-all; }
|
|
166834
166847
|
.logs .text { white-space: pre-wrap; word-break: break-word; }
|
|
166835
|
-
.logs .line.error .text { color: var(--bad); }
|
|
166848
|
+
.logs .line.error .text, .logs .entry.error .text { color: var(--bad); }
|
|
166849
|
+
.logs .entry { padding: 4px 0; }
|
|
166850
|
+
.logs .entry + .entry, .logs .line + .entry, .logs .entry + .line { border-top: 1px solid var(--border); }
|
|
166851
|
+
.logs .entry .meta { display: flex; gap: 8px; margin-bottom: 2px; }
|
|
166836
166852
|
.config-form { display: flex; flex-direction: column; gap: 8px; max-width: 520px; }
|
|
166837
166853
|
.config-form .field { display: grid; grid-template-columns: 180px 1fr; gap: 12px; align-items: center; }
|
|
166838
166854
|
.config-form .name { color: var(--muted); overflow-wrap: anywhere; }
|
|
@@ -166998,6 +167014,15 @@ var dashboardHtml = `<!doctype html>
|
|
|
166998
167014
|
cursor: pointer;
|
|
166999
167015
|
}
|
|
167000
167016
|
button.primary:disabled { opacity: 0.5; cursor: wait; }
|
|
167017
|
+
button.secondary {
|
|
167018
|
+
background: var(--panel);
|
|
167019
|
+
color: var(--text);
|
|
167020
|
+
border: 1px solid var(--border);
|
|
167021
|
+
border-radius: 6px;
|
|
167022
|
+
padding: 6px 16px;
|
|
167023
|
+
font: inherit;
|
|
167024
|
+
cursor: pointer;
|
|
167025
|
+
}
|
|
167001
167026
|
pre.result {
|
|
167002
167027
|
background: var(--panel);
|
|
167003
167028
|
border: 1px solid var(--border);
|
|
@@ -167066,7 +167091,7 @@ const GROUPS = [
|
|
|
167066
167091
|
['config', 'Config'],
|
|
167067
167092
|
['auth', 'Auth'],
|
|
167068
167093
|
['email', 'Emails'],
|
|
167069
|
-
['worker', '
|
|
167094
|
+
['worker', 'Logs'],
|
|
167070
167095
|
['route', 'Routes'],
|
|
167071
167096
|
]
|
|
167072
167097
|
|
|
@@ -167184,11 +167209,23 @@ window.addEventListener('popstate', applyLocation)
|
|
|
167184
167209
|
// Detail panels
|
|
167185
167210
|
|
|
167186
167211
|
const invokePanel = (main, r) => {
|
|
167212
|
+
// The last payload survives reloads & panel switches, so a hand
|
|
167213
|
+
// crafted event never gets lost. The envelope only prefills the
|
|
167214
|
+
// first visit.
|
|
167215
|
+
const storageKey = 'invoke-payload:' + r.kind + ':' + (r.stack ?? '-') + ':' + r.id
|
|
167187
167216
|
const placeholder = JSON.stringify(r.envelope ?? {}, null, 2)
|
|
167188
|
-
const input = $('textarea', { value: placeholder, spellcheck: false })
|
|
167217
|
+
const input = $('textarea', { value: localStorage.getItem(storageKey) ?? placeholder, spellcheck: false })
|
|
167189
167218
|
const status = $('span', { className: 'status' })
|
|
167190
167219
|
const result = $('pre', { className: 'result', hidden: true })
|
|
167191
167220
|
const run = $('button', { className: 'primary', textContent: r.kind === 'topic' ? 'Publish' : 'Invoke' })
|
|
167221
|
+
const reset = $('button', { className: 'secondary', textContent: 'Reset' })
|
|
167222
|
+
|
|
167223
|
+
input.oninput = () => localStorage.setItem(storageKey, input.value)
|
|
167224
|
+
|
|
167225
|
+
reset.onclick = () => {
|
|
167226
|
+
localStorage.removeItem(storageKey)
|
|
167227
|
+
input.value = placeholder
|
|
167228
|
+
}
|
|
167192
167229
|
|
|
167193
167230
|
run.onclick = async () => {
|
|
167194
167231
|
run.disabled = true
|
|
@@ -167214,9 +167251,14 @@ const invokePanel = (main, r) => {
|
|
|
167214
167251
|
|
|
167215
167252
|
main.append(
|
|
167216
167253
|
input,
|
|
167217
|
-
$('div', { className: 'actions' }, [run, status]),
|
|
167254
|
+
$('div', { className: 'actions' }, [run, reset, status]),
|
|
167218
167255
|
result,
|
|
167219
167256
|
)
|
|
167257
|
+
|
|
167258
|
+
// The resource's own console output, filtered from the worker feed.
|
|
167259
|
+
if (r.routeKey) {
|
|
167260
|
+
cleanupPanel = attachLogFeed(main, 'worker', r.routeKey)
|
|
167261
|
+
}
|
|
167220
167262
|
}
|
|
167221
167263
|
|
|
167222
167264
|
const pubsubPanel = (main, r) => {
|
|
@@ -167340,8 +167382,10 @@ const rpcPanel = (main, r) => {
|
|
|
167340
167382
|
// A terminal-style view streaming a resource's live event channel,
|
|
167341
167383
|
// like the dev server output of a site. The bus replays the recent
|
|
167342
167384
|
// lines, so the boot output shows even when the panel opens later.
|
|
167343
|
-
const attachLogFeed = (main, channel) => {
|
|
167344
|
-
|
|
167385
|
+
const attachLogFeed = (main, channel, route, title = 'Logs') => {
|
|
167386
|
+
if (title) {
|
|
167387
|
+
main.append($('h3', {}, title))
|
|
167388
|
+
}
|
|
167345
167389
|
|
|
167346
167390
|
const feed = $('div', { className: 'logs' }, $('p', { className: 'empty' }, 'Waiting for output...'))
|
|
167347
167391
|
main.append(feed)
|
|
@@ -167351,11 +167395,34 @@ const attachLogFeed = (main, channel) => {
|
|
|
167351
167395
|
source.onmessage = message => {
|
|
167352
167396
|
const data = JSON.parse(message.data)
|
|
167353
167397
|
|
|
167398
|
+
// A route filter shows only the lines of one resource, like the
|
|
167399
|
+
// function panel showing its own console output.
|
|
167400
|
+
if (route && data.route !== route) {
|
|
167401
|
+
return
|
|
167402
|
+
}
|
|
167403
|
+
|
|
167354
167404
|
feed.querySelector('.empty')?.remove()
|
|
167355
|
-
|
|
167356
|
-
|
|
167357
|
-
|
|
167358
|
-
|
|
167405
|
+
|
|
167406
|
+
const error = data.error ? ' error' : ''
|
|
167407
|
+
const showRoute = !route && data.route
|
|
167408
|
+
|
|
167409
|
+
// Tagged or multi-line records render as a block with the
|
|
167410
|
+
// metadata on its own header line, so long route names never
|
|
167411
|
+
// squeeze the text. Plain lines keep the compact row.
|
|
167412
|
+
if (showRoute || data.line.includes('\\n')) {
|
|
167413
|
+
feed.append($('div', { className: 'entry' + error }, [
|
|
167414
|
+
$('div', { className: 'meta' }, [
|
|
167415
|
+
$('span', { className: 'time' }, new Date(data.date).toLocaleTimeString()),
|
|
167416
|
+
showRoute ? $('span', { className: 'route' }, data.route) : '',
|
|
167417
|
+
]),
|
|
167418
|
+
$('div', { className: 'text' }, data.line),
|
|
167419
|
+
]))
|
|
167420
|
+
} else {
|
|
167421
|
+
feed.append($('div', { className: 'line' + error }, [
|
|
167422
|
+
$('span', { className: 'time' }, new Date(data.date).toLocaleTimeString()),
|
|
167423
|
+
$('span', { className: 'text' }, data.line),
|
|
167424
|
+
]))
|
|
167425
|
+
}
|
|
167359
167426
|
|
|
167360
167427
|
// Only the last 200 lines stay around, pinned to the bottom.
|
|
167361
167428
|
while (feed.children.length > 200) {
|
|
@@ -167878,7 +167945,7 @@ const renderList = main => {
|
|
|
167878
167945
|
// The worker page streams the bundle worker output directly,
|
|
167879
167946
|
// instead of listing its single resource.
|
|
167880
167947
|
if (view.kind === 'worker') {
|
|
167881
|
-
cleanupPanel = attachLogFeed(main, 'worker')
|
|
167948
|
+
cleanupPanel = attachLogFeed(main, 'worker', undefined, null)
|
|
167882
167949
|
return
|
|
167883
167950
|
}
|
|
167884
167951
|
|
|
@@ -168263,7 +168330,7 @@ var createDashboardServer = (props) => {
|
|
|
168263
168330
|
if (url.pathname === "/api/config") {
|
|
168264
168331
|
if (req.method === "PUT") {
|
|
168265
168332
|
const values2 = JSON.parse((await readBody3(req)).toString() || "{}");
|
|
168266
|
-
await
|
|
168333
|
+
await writeFile13(props.configFile, JSON.stringify(values2, null, "\t") + `
|
|
168267
168334
|
`);
|
|
168268
168335
|
return { status: 200, body: JSON.stringify({ ok: true }) };
|
|
168269
168336
|
}
|
|
@@ -168499,7 +168566,7 @@ var createLambdaServer = (props) => {
|
|
|
168499
168566
|
};
|
|
168500
168567
|
|
|
168501
168568
|
// src/dev/sdk.ts
|
|
168502
|
-
import { readdir as readdir10, readFile as readFile23, mkdir as
|
|
168569
|
+
import { readdir as readdir10, readFile as readFile23, mkdir as mkdir9, rm as rm11, symlink } from "fs/promises";
|
|
168503
168570
|
import { createRequire } from "module";
|
|
168504
168571
|
import { dirname as dirname22, join as join53 } from "path";
|
|
168505
168572
|
var linkSdkPackages = async (buildDir, onWarn) => {
|
|
@@ -168542,7 +168609,7 @@ var linkSdkPackages = async (buildDir, onWarn) => {
|
|
|
168542
168609
|
}
|
|
168543
168610
|
}
|
|
168544
168611
|
const target2 = join53(buildDir, "node_modules", name);
|
|
168545
|
-
await
|
|
168612
|
+
await mkdir9(dirname22(target2), { recursive: true });
|
|
168546
168613
|
await rm11(target2, { recursive: true, force: true });
|
|
168547
168614
|
await symlink(source, target2, "dir");
|
|
168548
168615
|
}
|
|
@@ -168565,7 +168632,7 @@ var startDev = async (props) => {
|
|
|
168565
168632
|
dev: true
|
|
168566
168633
|
});
|
|
168567
168634
|
ready2();
|
|
168568
|
-
await
|
|
168635
|
+
await mkdir10(join54(directories.output, "local"), { recursive: true });
|
|
168569
168636
|
const routerPorts = {};
|
|
168570
168637
|
Object.keys(appConfig.router ?? {}).forEach((id, index) => {
|
|
168571
168638
|
routerPorts[id] = props.port + 1 + index;
|
|
@@ -168620,7 +168687,7 @@ var startDev = async (props) => {
|
|
|
168620
168687
|
for (const [id, port] of Object.entries(routerPorts)) {
|
|
168621
168688
|
env5[`ROUTER_${constantCase(id)}_ENDPOINT`] = `localhost:${port}`;
|
|
168622
168689
|
}
|
|
168623
|
-
await
|
|
168690
|
+
await writeFile14(join54(directories.output, "local", "env.json"), JSON.stringify(env5, null, "\t") + `
|
|
168624
168691
|
`);
|
|
168625
168692
|
return { env: env5, lambda: lambda2 };
|
|
168626
168693
|
});
|
|
@@ -168635,7 +168702,7 @@ var startDev = async (props) => {
|
|
|
168635
168702
|
}
|
|
168636
168703
|
debug(`Build ${builder.type}:${builder.name}`, meta?.cached ? "cached" : String(meta?.buildTime));
|
|
168637
168704
|
}
|
|
168638
|
-
await
|
|
168705
|
+
await writeFile14(getBuildPath("bundle", bundleName, "files/awsless-env.mjs"), `export default {}
|
|
168639
168706
|
`);
|
|
168640
168707
|
await linkSdkPackages(buildDir, log);
|
|
168641
168708
|
return changed;
|
|
@@ -168644,14 +168711,14 @@ var startDev = async (props) => {
|
|
|
168644
168711
|
workspace = await loadWorkspace3(directories.root);
|
|
168645
168712
|
await buildAll();
|
|
168646
168713
|
});
|
|
168647
|
-
const emitWorkerLine = (line, error3 = false) => {
|
|
168648
|
-
dev.events.emit("worker", { date: Date.now(), line, error: error3 });
|
|
168714
|
+
const emitWorkerLine = (line, error3 = false, route) => {
|
|
168715
|
+
dev.events.emit("worker", { date: Date.now(), line, error: error3, route });
|
|
168649
168716
|
};
|
|
168650
168717
|
const worker = createBundleWorker({
|
|
168651
168718
|
buildDir,
|
|
168652
168719
|
env: env4,
|
|
168653
168720
|
functionName: bundleName,
|
|
168654
|
-
onOutput: (line, stream2) => emitWorkerLine(line, stream2 === "stderr")
|
|
168721
|
+
onOutput: (line, stream2, route) => emitWorkerLine(line, stream2 === "stderr", route)
|
|
168655
168722
|
});
|
|
168656
168723
|
dev.resources.push({
|
|
168657
168724
|
kind: "worker",
|
|
@@ -168718,12 +168785,12 @@ var startDev = async (props) => {
|
|
|
168718
168785
|
restartNeeded = true;
|
|
168719
168786
|
}
|
|
168720
168787
|
});
|
|
168721
|
-
const seeder = createSeedRunner({
|
|
168788
|
+
const seeder = createSeedRunner({ seed: appConfig.seed, env: env4 });
|
|
168722
168789
|
const resetData = createDataReset({ pool: props.pool, appConfig, stackConfigs });
|
|
168723
168790
|
if (firstBoot && seeder.count > 0 && !dirty) {
|
|
168724
168791
|
try {
|
|
168725
|
-
await phase({ start: "Seeding the local data...", done: "Seeded the local data" }, async (
|
|
168726
|
-
|
|
168792
|
+
await phase({ start: "Seeding the local data...", done: "Seeded the local data" }, async () => {
|
|
168793
|
+
await seeder.run();
|
|
168727
168794
|
});
|
|
168728
168795
|
} catch (error3) {
|
|
168729
168796
|
log(`Seeding failed: ${error3 instanceof Error ? error3.message : String(error3)}`);
|
|
@@ -168739,7 +168806,7 @@ var startDev = async (props) => {
|
|
|
168739
168806
|
const detail = error3 instanceof Error ? error3.stack ?? error3.message : String(error3);
|
|
168740
168807
|
process.stderr.write(`Route ${routeKey} failed: ${detail}
|
|
168741
168808
|
`);
|
|
168742
|
-
emitWorkerLine(`Route ${routeKey} failed: ${detail}`, true);
|
|
168809
|
+
emitWorkerLine(`Route ${routeKey} failed: ${detail}`, true, routeKey);
|
|
168743
168810
|
}
|
|
168744
168811
|
}));
|
|
168745
168812
|
}
|
|
@@ -168855,7 +168922,7 @@ var createServerPool = () => {
|
|
|
168855
168922
|
};
|
|
168856
168923
|
|
|
168857
168924
|
// src/type-gen/generate.ts
|
|
168858
|
-
import { mkdir as
|
|
168925
|
+
import { mkdir as mkdir11, writeFile as writeFile15 } from "fs/promises";
|
|
168859
168926
|
import { dirname as dirname23, join as join55, relative as relative11 } from "path";
|
|
168860
168927
|
var generateTypes = async (props) => {
|
|
168861
168928
|
const files = [];
|
|
@@ -168869,8 +168936,8 @@ var generateTypes = async (props) => {
|
|
|
168869
168936
|
if (include) {
|
|
168870
168937
|
files.push(relative11(directories.root, path6));
|
|
168871
168938
|
}
|
|
168872
|
-
await
|
|
168873
|
-
await
|
|
168939
|
+
await mkdir11(dirname23(path6), { recursive: true });
|
|
168940
|
+
await writeFile15(path6, code);
|
|
168874
168941
|
}
|
|
168875
168942
|
}
|
|
168876
168943
|
});
|
|
@@ -168878,7 +168945,7 @@ var generateTypes = async (props) => {
|
|
|
168878
168945
|
if (files.length) {
|
|
168879
168946
|
const code = files.map((file2) => `/// <reference path='${file2}' />`).join(`
|
|
168880
168947
|
`);
|
|
168881
|
-
await
|
|
168948
|
+
await writeFile15(join55(directories.root, `awsless.d.ts`), code);
|
|
168882
168949
|
}
|
|
168883
168950
|
};
|
|
168884
168951
|
|
|
@@ -184507,7 +184574,7 @@ var state = (program3) => {
|
|
|
184507
184574
|
};
|
|
184508
184575
|
|
|
184509
184576
|
// src/cli/command/test.ts
|
|
184510
|
-
import { mkdir as
|
|
184577
|
+
import { mkdir as mkdir12, writeFile as writeFile16 } from "fs/promises";
|
|
184511
184578
|
import { join as join57 } from "path";
|
|
184512
184579
|
|
|
184513
184580
|
// src/test/manifest.ts
|
|
@@ -184633,8 +184700,8 @@ var test2 = (program3) => {
|
|
|
184633
184700
|
await redis.ping();
|
|
184634
184701
|
manifest.servers.redis = { host: "127.0.0.1", port: await redis.getPort() };
|
|
184635
184702
|
}
|
|
184636
|
-
await
|
|
184637
|
-
await
|
|
184703
|
+
await mkdir12(join57(directories.output, "test"), { recursive: true });
|
|
184704
|
+
await writeFile16(manifestFile, JSON.stringify(manifest));
|
|
184638
184705
|
process.env.AWSLESS_TEST_MANIFEST = manifestFile;
|
|
184639
184706
|
let passed = false;
|
|
184640
184707
|
try {
|
package/dist/handlers/bundle.js
CHANGED
|
@@ -406,6 +406,7 @@ var topicHandler = (event, routes) => {
|
|
|
406
406
|
};
|
|
407
407
|
|
|
408
408
|
// src/feature/bundle/server/handle.ts
|
|
409
|
+
import { getCurrentRoute as getCurrentRoute2 } from "awsless";
|
|
409
410
|
var createBundle = (handlers) => {
|
|
410
411
|
const routes = Object.keys(handlers);
|
|
411
412
|
setBundleRoutes(routes);
|
|
@@ -504,5 +505,6 @@ var createBundle = (handlers) => {
|
|
|
504
505
|
};
|
|
505
506
|
};
|
|
506
507
|
export {
|
|
508
|
+
getCurrentRoute2 as getCurrentRoute,
|
|
507
509
|
createBundle
|
|
508
510
|
};
|