@awsless/cli 0.0.46-local.1 → 0.0.46-local.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +321 -99
- package/dist/stack.json +1 -1
- package/dist/stack.stage.json +1 -1
- package/package.json +14 -14
package/dist/bin.js
CHANGED
|
@@ -102748,7 +102748,7 @@ var init_find_cache_dir = __esm(() => {
|
|
|
102748
102748
|
({ env: env3, cwd } = process4);
|
|
102749
102749
|
});
|
|
102750
102750
|
|
|
102751
|
-
// ../open-search/dist/chunk-
|
|
102751
|
+
// ../open-search/dist/chunk-M36HBITL.js
|
|
102752
102752
|
import { mkdir as mkdir6, rename as rename4, rm as rm7, stat as stat5 } from "fs/promises";
|
|
102753
102753
|
import { join as join27, resolve as resolve3 } from "path";
|
|
102754
102754
|
import { mkdir as mkdir22, readdir as readdir4, rename as rename22, rm as rm22, stat as stat22 } from "fs/promises";
|
|
@@ -102842,7 +102842,7 @@ var import_decompress, import_decompress2, getArchiveName = (version2) => {
|
|
|
102842
102842
|
}
|
|
102843
102843
|
return findJavaHome(dir);
|
|
102844
102844
|
}, VERSION_2_8_0;
|
|
102845
|
-
var
|
|
102845
|
+
var init_chunk_M36HBITL = __esm(() => {
|
|
102846
102846
|
init_find_cache_dir();
|
|
102847
102847
|
init_find_cache_dir();
|
|
102848
102848
|
import_decompress = __toESM(require_decompress(), 1);
|
|
@@ -102856,7 +102856,8 @@ var init_chunk_7I7EB23J = __esm(() => {
|
|
|
102856
102856
|
"http.port": port,
|
|
102857
102857
|
"path.data": `${cache3}/data`,
|
|
102858
102858
|
"path.logs": `${cache3}/logs`,
|
|
102859
|
-
"plugins.security.disabled": true
|
|
102859
|
+
"plugins.security.disabled": true,
|
|
102860
|
+
"cluster.routing.allocation.disk.threshold_enabled": false
|
|
102860
102861
|
})
|
|
102861
102862
|
};
|
|
102862
102863
|
});
|
|
@@ -103462,7 +103463,7 @@ var import_sleep_await, mock, searchClient = (options = {}, service = "es") => {
|
|
|
103462
103463
|
return new Schema2((input) => [...input].map((item) => struct.encode(item)), (encoded) => new Set(encoded.map((item) => struct.decode(item))), struct.mapping);
|
|
103463
103464
|
}, string2 = (props = {}) => new Schema2((value) => value, (value) => value, { type: "keyword", ...props }), uuid = (props = {}) => new Schema2((value) => value, (value) => value, { type: "keyword", ...props });
|
|
103464
103465
|
var init_dist2 = __esm(() => {
|
|
103465
|
-
|
|
103466
|
+
init_chunk_M36HBITL();
|
|
103466
103467
|
init_dist();
|
|
103467
103468
|
import_sleep_await = __toESM(require_dist3(), 1);
|
|
103468
103469
|
BulkError = class extends Error {
|
|
@@ -105671,7 +105672,7 @@ var require_readdirp = __commonJS((exports, module) => {
|
|
|
105671
105672
|
var sysPath = __require("path");
|
|
105672
105673
|
var { promisify: promisify2 } = __require("util");
|
|
105673
105674
|
var picomatch = require_picomatch3();
|
|
105674
|
-
var
|
|
105675
|
+
var readdir7 = promisify2(fs5.readdir);
|
|
105675
105676
|
var stat7 = promisify2(fs5.stat);
|
|
105676
105677
|
var lstat4 = promisify2(fs5.lstat);
|
|
105677
105678
|
var realpath2 = promisify2(fs5.realpath);
|
|
@@ -105804,7 +105805,7 @@ var require_readdirp = __commonJS((exports, module) => {
|
|
|
105804
105805
|
async _exploreDir(path6, depth) {
|
|
105805
105806
|
let files;
|
|
105806
105807
|
try {
|
|
105807
|
-
files = await
|
|
105808
|
+
files = await readdir7(path6, this._rdOptions);
|
|
105808
105809
|
} catch (error3) {
|
|
105809
105810
|
this._onError(error3);
|
|
105810
105811
|
}
|
|
@@ -151372,6 +151373,22 @@ var AppSchema = exports_external.object({
|
|
|
151372
151373
|
test: TestDefaultSchema
|
|
151373
151374
|
}).strict();
|
|
151374
151375
|
|
|
151376
|
+
// src/config/schema/local-entry.ts
|
|
151377
|
+
import { stat as stat4 } from "fs/promises";
|
|
151378
|
+
var LocalEntrySchema = exports_external.union([
|
|
151379
|
+
RelativePathSchema.refine(async (path2) => {
|
|
151380
|
+
try {
|
|
151381
|
+
const s2 = await stat4(path2);
|
|
151382
|
+
return s2.isFile() || s2.isDirectory();
|
|
151383
|
+
} catch (error3) {
|
|
151384
|
+
return false;
|
|
151385
|
+
}
|
|
151386
|
+
}, `File or directory doesn't exist`),
|
|
151387
|
+
exports_external.object({
|
|
151388
|
+
nocheck: RelativePathSchema.describe("Specifies a local file or directory without checking if the file or directory exists.")
|
|
151389
|
+
}).transform((v3) => v3.nocheck)
|
|
151390
|
+
]);
|
|
151391
|
+
|
|
151375
151392
|
// src/feature/cache/schema.ts
|
|
151376
151393
|
var StorageSchema = SizeSchema.refine(sizeMin(gibibytes(1)), "Minimum storage size is 1 GB").refine(sizeMax(gibibytes(5000)), "Maximum storage size is 5000 GB");
|
|
151377
151394
|
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.");
|
|
@@ -151453,22 +151470,6 @@ example: "5 minutes"`),
|
|
|
151453
151470
|
payload: exports_external.unknown().optional().describe("The JSON payload that will be passed to the consumer.")
|
|
151454
151471
|
})).optional().describe(`Define the cron jobs in your stack.`);
|
|
151455
151472
|
|
|
151456
|
-
// src/config/schema/local-entry.ts
|
|
151457
|
-
import { stat as stat4 } from "fs/promises";
|
|
151458
|
-
var LocalEntrySchema = exports_external.union([
|
|
151459
|
-
RelativePathSchema.refine(async (path2) => {
|
|
151460
|
-
try {
|
|
151461
|
-
const s2 = await stat4(path2);
|
|
151462
|
-
return s2.isFile() || s2.isDirectory();
|
|
151463
|
-
} catch (error3) {
|
|
151464
|
-
return false;
|
|
151465
|
-
}
|
|
151466
|
-
}, `File or directory doesn't exist`),
|
|
151467
|
-
exports_external.object({
|
|
151468
|
-
nocheck: RelativePathSchema.describe("Specifies a local file or directory without checking if the file or directory exists.")
|
|
151469
|
-
}).transform((v3) => v3.nocheck)
|
|
151470
|
-
]);
|
|
151471
|
-
|
|
151472
151473
|
// src/feature/site/schema.ts
|
|
151473
151474
|
var SitesSchema = exports_external.record(ResourceIdSchema, exports_external.object({
|
|
151474
151475
|
router: ResourceIdSchema.describe("The router id to link your site with."),
|
|
@@ -151710,6 +151711,7 @@ var StackSchema = exports_external.object({
|
|
|
151710
151711
|
pubsub: PubSubSchema,
|
|
151711
151712
|
searchs: SearchsSchema,
|
|
151712
151713
|
sites: SitesSchema,
|
|
151714
|
+
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."),
|
|
151713
151715
|
tests: TestsSchema,
|
|
151714
151716
|
images: ImagesSchema,
|
|
151715
151717
|
icons: IconsSchema,
|
|
@@ -154972,6 +154974,21 @@ var configFeature = defineFeature({
|
|
|
154972
154974
|
},
|
|
154973
154975
|
async onDev(ctx) {
|
|
154974
154976
|
const names = new Set(ctx.appConfig.configs ?? []);
|
|
154977
|
+
for (const stack of ctx.stackConfigs) {
|
|
154978
|
+
for (const props of Object.values(stack.functions ?? {})) {
|
|
154979
|
+
for (const name of props.sandbox?.configs ?? []) {
|
|
154980
|
+
names.add(name);
|
|
154981
|
+
}
|
|
154982
|
+
}
|
|
154983
|
+
for (const site of Object.values(stack.sites ?? {})) {
|
|
154984
|
+
for (const name of site.build?.configs ?? []) {
|
|
154985
|
+
names.add(name);
|
|
154986
|
+
}
|
|
154987
|
+
for (const name of site.ssr?.sandbox?.configs ?? []) {
|
|
154988
|
+
names.add(name);
|
|
154989
|
+
}
|
|
154990
|
+
}
|
|
154991
|
+
}
|
|
154975
154992
|
if (names.size === 0) {
|
|
154976
154993
|
return;
|
|
154977
154994
|
}
|
|
@@ -155945,7 +155962,7 @@ var functionFeature = defineFeature({
|
|
|
155945
155962
|
onStack(ctx) {
|
|
155946
155963
|
for (const [id, props] of Object.entries(ctx.stackConfig.functions ?? {})) {
|
|
155947
155964
|
const routeKey = formatRouteKey(ctx.stack.name, "function", id);
|
|
155948
|
-
if (!isStandaloneFunction(props)) {
|
|
155965
|
+
if (!isStandaloneFunction(props) || ctx.dev) {
|
|
155949
155966
|
registerBundleFunction(ctx, routeKey, props);
|
|
155950
155967
|
continue;
|
|
155951
155968
|
}
|
|
@@ -158705,7 +158722,7 @@ ${(errors3.trim() || output.trim()).slice(-2000)}`);
|
|
|
158705
158722
|
});
|
|
158706
158723
|
});
|
|
158707
158724
|
}
|
|
158708
|
-
if (props.ssr && isStandaloneFunction(props.ssr)) {
|
|
158725
|
+
if (props.ssr && isStandaloneFunction(props.ssr) && !ctx.dev) {
|
|
158709
158726
|
const fn = createLambdaFunction(ctx, `${id}-ssr`, props.ssr);
|
|
158710
158727
|
if (ctx.shared.has("router", "endpoint", props.router)) {
|
|
158711
158728
|
fn.setEnvironment(`ROUTER_${constantCase(props.router)}_ENDPOINT`, ctx.shared.entry("router", "endpoint", props.router));
|
|
@@ -158989,7 +159006,83 @@ import { toSeconds as toSeconds9 } from "@awsless/duration";
|
|
|
158989
159006
|
import { CreateTableCommand as CreateTableCommand2, DeleteTableCommand } from "@aws-sdk/client-dynamodb";
|
|
158990
159007
|
import { PutCommand } from "@aws-sdk/lib-dynamodb";
|
|
158991
159008
|
import { readFile as readFile15 } from "fs/promises";
|
|
159009
|
+
import { join as join37 } from "path";
|
|
159010
|
+
|
|
159011
|
+
// src/dev/reset.ts
|
|
159012
|
+
var import_ioredis4 = __toESM(require_built3(), 1);
|
|
159013
|
+
import { DeleteCommand, ScanCommand } from "@aws-sdk/lib-dynamodb";
|
|
159014
|
+
import { Client as Client6 } from "@opensearch-project/opensearch";
|
|
159015
|
+
import { readdir as readdir6, rm as rm9 } from "fs/promises";
|
|
158992
159016
|
import { join as join36 } from "path";
|
|
159017
|
+
var wiping = false;
|
|
159018
|
+
var isWiping = () => wiping;
|
|
159019
|
+
var createDataReset = (props) => {
|
|
159020
|
+
return async () => {
|
|
159021
|
+
wiping = true;
|
|
159022
|
+
try {
|
|
159023
|
+
const dynamo = props.pool.peek("dynamo");
|
|
159024
|
+
if (dynamo) {
|
|
159025
|
+
const client = dynamo.server.getDocumentClient();
|
|
159026
|
+
for (const [name, fingerprint] of dynamo.tableFingerprints) {
|
|
159027
|
+
const keys = JSON.parse(fingerprint).KeySchema.map((key) => key.AttributeName);
|
|
159028
|
+
let cursor;
|
|
159029
|
+
do {
|
|
159030
|
+
const result = await client.send(new ScanCommand({ TableName: name, ExclusiveStartKey: cursor }));
|
|
159031
|
+
for (const item of result.Items ?? []) {
|
|
159032
|
+
await client.send(new DeleteCommand({
|
|
159033
|
+
TableName: name,
|
|
159034
|
+
Key: Object.fromEntries(keys.map((key) => [key, item[key]]))
|
|
159035
|
+
}));
|
|
159036
|
+
}
|
|
159037
|
+
cursor = result.LastEvaluatedKey;
|
|
159038
|
+
} while (cursor);
|
|
159039
|
+
}
|
|
159040
|
+
}
|
|
159041
|
+
for (const stack of props.stackConfigs) {
|
|
159042
|
+
for (const id of Object.keys(stack.caches ?? {})) {
|
|
159043
|
+
const port = props.pool.peek(`cache:${stack.name}:${id}`);
|
|
159044
|
+
if (!port) {
|
|
159045
|
+
continue;
|
|
159046
|
+
}
|
|
159047
|
+
const redis = new import_ioredis4.Redis({ host: "127.0.0.1", port, lazyConnect: true });
|
|
159048
|
+
await redis.connect();
|
|
159049
|
+
await redis.flushall();
|
|
159050
|
+
redis.disconnect();
|
|
159051
|
+
}
|
|
159052
|
+
}
|
|
159053
|
+
const search2 = props.pool.peek("opensearch");
|
|
159054
|
+
if (search2) {
|
|
159055
|
+
const client = new Client6({ node: `http://localhost:${search2.port}` });
|
|
159056
|
+
for (const stack of props.stackConfigs) {
|
|
159057
|
+
for (const [id, searchProps] of Object.entries(stack.searchs ?? {})) {
|
|
159058
|
+
const index = formatSearchIndexName(stack.name, id);
|
|
159059
|
+
try {
|
|
159060
|
+
await client.indices.delete({ index });
|
|
159061
|
+
} catch (_3) {}
|
|
159062
|
+
await applySearchIndex(client, {
|
|
159063
|
+
index,
|
|
159064
|
+
mappings: resolveSearchMappings(searchProps),
|
|
159065
|
+
settings: searchProps.settings
|
|
159066
|
+
});
|
|
159067
|
+
}
|
|
159068
|
+
}
|
|
159069
|
+
}
|
|
159070
|
+
const storeRoot = join36(directories.output, "local", "store");
|
|
159071
|
+
try {
|
|
159072
|
+
for (const bucket of await readdir6(storeRoot)) {
|
|
159073
|
+
for (const entry of await readdir6(join36(storeRoot, bucket))) {
|
|
159074
|
+
if (entry === "image" || entry === "icon") {
|
|
159075
|
+
continue;
|
|
159076
|
+
}
|
|
159077
|
+
await rm9(join36(storeRoot, bucket, entry), { recursive: true, force: true });
|
|
159078
|
+
}
|
|
159079
|
+
}
|
|
159080
|
+
} catch (_3) {}
|
|
159081
|
+
} finally {
|
|
159082
|
+
wiping = false;
|
|
159083
|
+
}
|
|
159084
|
+
};
|
|
159085
|
+
};
|
|
158993
159086
|
|
|
158994
159087
|
// src/feature/table/util.ts
|
|
158995
159088
|
var formatTableKeys = (props) => {
|
|
@@ -159049,7 +159142,7 @@ var createTableInput = (name, props) => {
|
|
|
159049
159142
|
};
|
|
159050
159143
|
};
|
|
159051
159144
|
var loadSeed = async (stackName, id) => {
|
|
159052
|
-
const file2 =
|
|
159145
|
+
const file2 = join37(directories.output, "local", "seed", "table", stackName, `${id}.json`);
|
|
159053
159146
|
try {
|
|
159054
159147
|
const items = JSON.parse(await readFile15(file2, "utf8"));
|
|
159055
159148
|
return Array.isArray(items) ? items : [];
|
|
@@ -159123,6 +159216,9 @@ var tableOnDev = async (ctx) => {
|
|
|
159123
159216
|
const routeKey = formatRouteKey(stackName, "table", id);
|
|
159124
159217
|
const eventSourceARN = `arn:aws:dynamodb:${ctx.appConfig.region}:000000000000:table/${name}/stream/local`;
|
|
159125
159218
|
const unsubscribe = server.onStreamRecord(name, (record) => {
|
|
159219
|
+
if (isWiping()) {
|
|
159220
|
+
return;
|
|
159221
|
+
}
|
|
159126
159222
|
const event = { Records: [{ ...record, eventSourceARN }] };
|
|
159127
159223
|
dispatch(event).catch((error3) => {
|
|
159128
159224
|
reportFailure({
|
|
@@ -159959,12 +160055,12 @@ import { toDays as toDays9 } from "@awsless/duration";
|
|
|
159959
160055
|
import { formatRouteEnvName as formatRouteEnvName5 } from "awsless";
|
|
159960
160056
|
import { createHash as createHash18 } from "crypto";
|
|
159961
160057
|
import { readFile as readFile16 } from "fs/promises";
|
|
159962
|
-
import { dirname as dirname18, join as
|
|
160058
|
+
import { dirname as dirname18, join as join39 } from "path";
|
|
159963
160059
|
import { fileURLToPath as fileURLToPath13 } from "url";
|
|
159964
160060
|
|
|
159965
160061
|
// src/feature/image/dev.ts
|
|
159966
160062
|
import { cp } from "fs/promises";
|
|
159967
|
-
import { isAbsolute as isAbsolute2, join as
|
|
160063
|
+
import { isAbsolute as isAbsolute2, join as join38 } from "path";
|
|
159968
160064
|
var imageOnDev = async (ctx) => {
|
|
159969
160065
|
const images = ctx.stackConfigs.flatMap((stack) => Object.keys(stack.images ?? {}));
|
|
159970
160066
|
if (images.length === 0) {
|
|
@@ -160002,8 +160098,8 @@ var imageOnDev = async (ctx) => {
|
|
|
160002
160098
|
}
|
|
160003
160099
|
if (props.origin.static) {
|
|
160004
160100
|
ctx.addEnv(`${routeKey}:IMAGE_ORIGIN_S3`, "true");
|
|
160005
|
-
const source = isAbsolute2(props.origin.static) ? props.origin.static :
|
|
160006
|
-
await cp(source,
|
|
160101
|
+
const source = isAbsolute2(props.origin.static) ? props.origin.static : join38(directories.root, props.origin.static);
|
|
160102
|
+
await cp(source, join38(directories.output, "local", "store", bucket, folder, "origin"), {
|
|
160007
160103
|
recursive: true
|
|
160008
160104
|
});
|
|
160009
160105
|
}
|
|
@@ -160033,7 +160129,7 @@ var imageFeature = defineFeature({
|
|
|
160033
160129
|
throw new FileError("app.json", "The image feature requires an arm64 function bundle.");
|
|
160034
160130
|
}
|
|
160035
160131
|
const group4 = new Group(ctx.base, "image", "layer");
|
|
160036
|
-
const path6 =
|
|
160132
|
+
const path6 = join39(dirname18(fileURLToPath13(import.meta.url)), "/layers/sharp-arm.zip");
|
|
160037
160133
|
const layerId = formatGlobalResourceName({
|
|
160038
160134
|
appName: ctx.appConfig.name,
|
|
160039
160135
|
resourceType: "layer",
|
|
@@ -160113,7 +160209,7 @@ var imageFeature = defineFeature({
|
|
|
160113
160209
|
const serverRouteKey = formatRouteKey(ctx.stack.name, "image", id);
|
|
160114
160210
|
bundle.addHandler({
|
|
160115
160211
|
routeKey: serverRouteKey,
|
|
160116
|
-
file:
|
|
160212
|
+
file: join39(dirname18(fileURLToPath13(import.meta.url)), "/handlers/image.js"),
|
|
160117
160213
|
exportName: "default",
|
|
160118
160214
|
external: ["sharp"]
|
|
160119
160215
|
});
|
|
@@ -160151,8 +160247,8 @@ var imageFeature = defineFeature({
|
|
|
160151
160247
|
new aws2.s3.BucketObject(group4, `static-${file2}`, {
|
|
160152
160248
|
bucket: bucket.name,
|
|
160153
160249
|
key: `${folder}origin/${file2}`,
|
|
160154
|
-
source:
|
|
160155
|
-
sourceHash: $hash(
|
|
160250
|
+
source: join39(props.origin.static, file2),
|
|
160251
|
+
sourceHash: $hash(join39(props.origin.static, file2))
|
|
160156
160252
|
}, {
|
|
160157
160253
|
replaceOnChanges: ["bucket", "key"]
|
|
160158
160254
|
});
|
|
@@ -160168,12 +160264,12 @@ var imageFeature = defineFeature({
|
|
|
160168
160264
|
// src/feature/icon/index.ts
|
|
160169
160265
|
import { toDays as toDays10 } from "@awsless/duration";
|
|
160170
160266
|
import { formatRouteEnvName as formatRouteEnvName6 } from "awsless";
|
|
160171
|
-
import { dirname as dirname19, join as
|
|
160267
|
+
import { dirname as dirname19, join as join41 } from "path";
|
|
160172
160268
|
import { fileURLToPath as fileURLToPath14 } from "url";
|
|
160173
160269
|
|
|
160174
160270
|
// src/feature/icon/dev.ts
|
|
160175
160271
|
import { cp as cp2 } from "fs/promises";
|
|
160176
|
-
import { isAbsolute as isAbsolute3, join as
|
|
160272
|
+
import { isAbsolute as isAbsolute3, join as join40 } from "path";
|
|
160177
160273
|
var iconOnDev = async (ctx) => {
|
|
160178
160274
|
const icons = ctx.stackConfigs.flatMap((stack) => Object.keys(stack.icons ?? {}));
|
|
160179
160275
|
if (icons.length === 0) {
|
|
@@ -160211,8 +160307,8 @@ var iconOnDev = async (ctx) => {
|
|
|
160211
160307
|
}
|
|
160212
160308
|
if (props.origin.static) {
|
|
160213
160309
|
ctx.addEnv(`${routeKey}:ICON_ORIGIN_S3`, "true");
|
|
160214
|
-
const source = isAbsolute3(props.origin.static) ? props.origin.static :
|
|
160215
|
-
await cp2(source,
|
|
160310
|
+
const source = isAbsolute3(props.origin.static) ? props.origin.static : join40(directories.root, props.origin.static);
|
|
160311
|
+
await cp2(source, join40(directories.output, "local", "store", bucket, folder, "origin"), {
|
|
160216
160312
|
recursive: true
|
|
160217
160313
|
});
|
|
160218
160314
|
}
|
|
@@ -160259,7 +160355,7 @@ var iconFeature = defineFeature({
|
|
|
160259
160355
|
const serverRouteKey = formatRouteKey(ctx.stack.name, "icon", id);
|
|
160260
160356
|
bundle.addHandler({
|
|
160261
160357
|
routeKey: serverRouteKey,
|
|
160262
|
-
file:
|
|
160358
|
+
file: join41(dirname19(fileURLToPath14(import.meta.url)), "/handlers/icon.js"),
|
|
160263
160359
|
exportName: "default"
|
|
160264
160360
|
});
|
|
160265
160361
|
addRoutes({
|
|
@@ -160299,8 +160395,8 @@ var iconFeature = defineFeature({
|
|
|
160299
160395
|
new aws2.s3.BucketObject(group4, `static-${file2}`, {
|
|
160300
160396
|
bucket: bucket.name,
|
|
160301
160397
|
key: `${folder}origin/${file2}`,
|
|
160302
|
-
source:
|
|
160303
|
-
sourceHash: $hash(
|
|
160398
|
+
source: join41(props.origin.static, file2),
|
|
160399
|
+
sourceHash: $hash(join41(props.origin.static, file2))
|
|
160304
160400
|
}, {
|
|
160305
160401
|
replaceOnChanges: ["bucket", "key"]
|
|
160306
160402
|
});
|
|
@@ -160327,10 +160423,10 @@ var import_deepmerge4 = __toESM(require_cjs2(), 1);
|
|
|
160327
160423
|
// src/feature/job/build/executable.ts
|
|
160328
160424
|
import { createHash as createHash19 } from "crypto";
|
|
160329
160425
|
import { readFile as readFile17, writeFile as writeFile8 } from "fs/promises";
|
|
160330
|
-
import { join as
|
|
160426
|
+
import { join as join42, resolve as resolve4 } from "path";
|
|
160331
160427
|
var buildJobExecutable = async (input, outputPath, architecture) => {
|
|
160332
|
-
const filePath =
|
|
160333
|
-
const wrapperPath =
|
|
160428
|
+
const filePath = join42(outputPath, "program");
|
|
160429
|
+
const wrapperPath = join42(outputPath, "wrapper.ts");
|
|
160334
160430
|
const handlerPath = resolve4(input);
|
|
160335
160431
|
await writeFile8(wrapperPath, `import { parse } from '@awsless/json'
|
|
160336
160432
|
import { getObject } from '@awsless/s3'
|
|
@@ -160843,7 +160939,7 @@ import { stringify as stringify3 } from "@awsless/json";
|
|
|
160843
160939
|
import { generateFileHash as generateFileHash4 } from "@awsless/ts-file-cache";
|
|
160844
160940
|
var import_deepmerge6 = __toESM(require_cjs2(), 1);
|
|
160845
160941
|
import { createHash as createHash21 } from "crypto";
|
|
160846
|
-
import { join as
|
|
160942
|
+
import { join as join43 } from "path";
|
|
160847
160943
|
var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
160848
160944
|
const group4 = new Group(parentGroup, "instance", ns);
|
|
160849
160945
|
const name = formatLocalResourceName({
|
|
@@ -161048,7 +161144,7 @@ var createFargateTask = (parentGroup, ctx, ns, id, local) => {
|
|
|
161048
161144
|
healthCheck: props.healthCheck ? {
|
|
161049
161145
|
command: [
|
|
161050
161146
|
"CMD-SHELL",
|
|
161051
|
-
`curl -f http://${
|
|
161147
|
+
`curl -f http://${join43("localhost", props.healthCheck.path)} || exit 1`
|
|
161052
161148
|
],
|
|
161053
161149
|
interval: toSeconds11(props.healthCheck.interval),
|
|
161054
161150
|
retries: props.healthCheck.retries,
|
|
@@ -163191,6 +163287,7 @@ var createApp = (props) => {
|
|
|
163191
163287
|
feature.onBefore?.({
|
|
163192
163288
|
...props,
|
|
163193
163289
|
import: props.import ?? false,
|
|
163290
|
+
dev: props.dev ?? false,
|
|
163194
163291
|
app,
|
|
163195
163292
|
appId,
|
|
163196
163293
|
base,
|
|
@@ -163205,6 +163302,7 @@ var createApp = (props) => {
|
|
|
163205
163302
|
feature.onApp?.({
|
|
163206
163303
|
...props,
|
|
163207
163304
|
import: props.import ?? false,
|
|
163305
|
+
dev: props.dev ?? false,
|
|
163208
163306
|
app,
|
|
163209
163307
|
appId,
|
|
163210
163308
|
base,
|
|
@@ -163266,6 +163364,7 @@ var createApp = (props) => {
|
|
|
163266
163364
|
feature.onStack?.({
|
|
163267
163365
|
...props,
|
|
163268
163366
|
import: props.import ?? false,
|
|
163367
|
+
dev: props.dev ?? false,
|
|
163269
163368
|
stackConfig,
|
|
163270
163369
|
app,
|
|
163271
163370
|
appId,
|
|
@@ -163803,12 +163902,12 @@ import { DynamoDBClient as DynamoDBClient3 } from "@awsless/dynamodb";
|
|
|
163803
163902
|
// src/cli/ui/complex/run-tests.ts
|
|
163804
163903
|
var import_wildstring3 = __toESM(require_wildstring(), 1);
|
|
163805
163904
|
import { mkdir as mkdir7, readFile as readFile18, writeFile as writeFile9 } from "fs/promises";
|
|
163806
|
-
import { join as
|
|
163905
|
+
import { join as join45 } from "path";
|
|
163807
163906
|
import { parse as parse7, stringify as stringify4 } from "@awsless/json";
|
|
163808
163907
|
import { generateFolderHash, loadWorkspace as loadWorkspace2 } from "@awsless/ts-file-cache";
|
|
163809
163908
|
|
|
163810
163909
|
// src/test/start.ts
|
|
163811
|
-
import { dirname as dirname20, join as
|
|
163910
|
+
import { dirname as dirname20, join as join44 } from "path";
|
|
163812
163911
|
import { fileURLToPath as fileURLToPath15 } from "url";
|
|
163813
163912
|
import { configDefaults } from "vitest/config";
|
|
163814
163913
|
import { startVitest } from "vitest/node";
|
|
@@ -163876,7 +163975,7 @@ var startTest = async (props) => {
|
|
|
163876
163975
|
reporters: [new NullReporter],
|
|
163877
163976
|
env: props.env,
|
|
163878
163977
|
setupFiles: [
|
|
163879
|
-
|
|
163978
|
+
join44(__dirname4, "test-global-setup.js")
|
|
163880
163979
|
]
|
|
163881
163980
|
}, {
|
|
163882
163981
|
logLevel: "silent",
|
|
@@ -164032,7 +164131,7 @@ var logTestErrors = (event) => {
|
|
|
164032
164131
|
};
|
|
164033
164132
|
var runTest = async (stack, dir, filters, workspace, opts) => {
|
|
164034
164133
|
await mkdir7(directories.test, { recursive: true });
|
|
164035
|
-
const file2 =
|
|
164134
|
+
const file2 = join45(directories.test, `${stack}.json`);
|
|
164036
164135
|
const fingerprint = await generateFolderHash(workspace, dir);
|
|
164037
164136
|
if (!process.env.NO_CACHE) {
|
|
164038
164137
|
const exists5 = await fileExist(file2);
|
|
@@ -164905,12 +165004,12 @@ var auth = (program3) => {
|
|
|
164905
165004
|
|
|
164906
165005
|
// src/cli/command/bind.ts
|
|
164907
165006
|
import { readFile as readFile19 } from "fs/promises";
|
|
164908
|
-
import { join as
|
|
165007
|
+
import { join as join46 } from "path";
|
|
164909
165008
|
var bind = (program3) => {
|
|
164910
165009
|
program3.command("bind").argument("[command...]", "The command to execute").option("--config <string...>", "List of config values that will be accessable", (v3) => v3.split(",")).option("--local", "Bind against the running local dev environment instead of the deployed app").description(`Bind your site environment variables to a command`).action(async (commands5 = [], opts) => {
|
|
164911
165010
|
await layout("bind", async ({ appConfig, stackConfigs }) => {
|
|
164912
165011
|
if (opts.local) {
|
|
164913
|
-
const file2 =
|
|
165012
|
+
const file2 = join46(directories.output, "local", "env.json");
|
|
164914
165013
|
let env5;
|
|
164915
165014
|
try {
|
|
164916
165015
|
env5 = JSON.parse(await readFile19(file2, "utf8"));
|
|
@@ -165044,7 +165143,7 @@ var {
|
|
|
165044
165143
|
isIBMi
|
|
165045
165144
|
} = require_constants7();
|
|
165046
165145
|
var stat7 = promisify2(fs5.stat);
|
|
165047
|
-
var
|
|
165146
|
+
var readdir7 = promisify2(fs5.readdir);
|
|
165048
165147
|
var arrify = (value = []) => Array.isArray(value) ? value : [value];
|
|
165049
165148
|
var flatten = (list3, result = []) => {
|
|
165050
165149
|
list3.forEach((item) => {
|
|
@@ -165116,7 +165215,7 @@ class DirEntry {
|
|
|
165116
165215
|
return;
|
|
165117
165216
|
const dir = this.path;
|
|
165118
165217
|
try {
|
|
165119
|
-
await
|
|
165218
|
+
await readdir7(dir);
|
|
165120
165219
|
} catch (err) {
|
|
165121
165220
|
if (this._removeWatcher) {
|
|
165122
165221
|
this._removeWatcher(sysPath.dirname(dir), sysPath.basename(dir));
|
|
@@ -165703,18 +165802,18 @@ var watchConfig = async (options, resolve5, reject) => {
|
|
|
165703
165802
|
|
|
165704
165803
|
// src/dev/index.ts
|
|
165705
165804
|
import { loadWorkspace as loadWorkspace3 } from "@awsless/ts-file-cache";
|
|
165706
|
-
import { mkdir as mkdir10, rm as
|
|
165707
|
-
import { join as
|
|
165805
|
+
import { mkdir as mkdir10, rm as rm12, writeFile as writeFile13 } from "fs/promises";
|
|
165806
|
+
import { join as join53 } from "path";
|
|
165708
165807
|
|
|
165709
165808
|
// src/dev/context.ts
|
|
165710
165809
|
import { DynamoDBServer } from "@awsless/dynamodb-server";
|
|
165711
|
-
import { join as
|
|
165810
|
+
import { join as join48 } from "path";
|
|
165712
165811
|
|
|
165713
165812
|
// src/dev/servers/s3.ts
|
|
165714
165813
|
import { createHash as createHash22 } from "crypto";
|
|
165715
165814
|
import { createServer as createServer7 } from "http";
|
|
165716
|
-
import { mkdir as mkdir8, readdir as
|
|
165717
|
-
import { dirname as dirname21, join as
|
|
165815
|
+
import { mkdir as mkdir8, readdir as readdir8, readFile as readFile20, rm as rm10, stat as stat8, writeFile as writeFile10 } from "fs/promises";
|
|
165816
|
+
import { dirname as dirname21, join as join47, relative as relative9, sep as sep4 } from "path";
|
|
165718
165817
|
var readBody2 = (req) => {
|
|
165719
165818
|
return new Promise((resolve5, reject) => {
|
|
165720
165819
|
const chunks = [];
|
|
@@ -165784,8 +165883,8 @@ var createS3Server = (props) => {
|
|
|
165784
165883
|
res.end(xmlError("InvalidRequest", "Missing bucket name"));
|
|
165785
165884
|
return;
|
|
165786
165885
|
}
|
|
165787
|
-
const bucketDir =
|
|
165788
|
-
const file2 =
|
|
165886
|
+
const bucketDir = join47(props.root, bucket);
|
|
165887
|
+
const file2 = join47(bucketDir, ...keyParts);
|
|
165789
165888
|
if (relative9(bucketDir, file2).startsWith("..")) {
|
|
165790
165889
|
res.writeHead(400, { "content-type": "application/xml" });
|
|
165791
165890
|
res.end(xmlError("InvalidRequest", "Invalid object key"));
|
|
@@ -165797,12 +165896,12 @@ var createS3Server = (props) => {
|
|
|
165797
165896
|
const walk2 = async (dir) => {
|
|
165798
165897
|
let entries2;
|
|
165799
165898
|
try {
|
|
165800
|
-
entries2 = await
|
|
165899
|
+
entries2 = await readdir8(dir, { withFileTypes: true });
|
|
165801
165900
|
} catch (_4) {
|
|
165802
165901
|
return;
|
|
165803
165902
|
}
|
|
165804
165903
|
for (const entry of entries2) {
|
|
165805
|
-
const path6 =
|
|
165904
|
+
const path6 = join47(dir, entry.name);
|
|
165806
165905
|
if (entry.isDirectory()) {
|
|
165807
165906
|
await walk2(path6);
|
|
165808
165907
|
} else {
|
|
@@ -165853,7 +165952,7 @@ var createS3Server = (props) => {
|
|
|
165853
165952
|
return;
|
|
165854
165953
|
}
|
|
165855
165954
|
if (req.method === "DELETE") {
|
|
165856
|
-
await
|
|
165955
|
+
await rm10(file2, { force: true });
|
|
165857
165956
|
res.writeHead(204);
|
|
165858
165957
|
res.end();
|
|
165859
165958
|
notify("ObjectRemoved:Delete", bucket, key, 0, "");
|
|
@@ -165941,7 +166040,7 @@ var createDevContext = (props) => {
|
|
|
165941
166040
|
const value = await props.pool.keep("store", null, async () => {
|
|
165942
166041
|
const rules = [];
|
|
165943
166042
|
const server = createS3Server({
|
|
165944
|
-
root:
|
|
166043
|
+
root: join48(directories.output, "local", "store"),
|
|
165945
166044
|
region: props.appConfig.region,
|
|
165946
166045
|
rules
|
|
165947
166046
|
});
|
|
@@ -166010,19 +166109,67 @@ var createDevContext = (props) => {
|
|
|
166010
166109
|
};
|
|
166011
166110
|
};
|
|
166012
166111
|
|
|
166112
|
+
// src/dev/seed.ts
|
|
166113
|
+
import { spawn as spawn5 } from "child_process";
|
|
166114
|
+
import { isAbsolute as isAbsolute4, join as join49 } from "path";
|
|
166115
|
+
var createSeedRunner = (props) => {
|
|
166116
|
+
const seeds = props.stackConfigs.filter((stack) => stack.seed).map((stack) => ({
|
|
166117
|
+
name: stack.name,
|
|
166118
|
+
file: isAbsolute4(stack.seed) ? stack.seed : join49(directories.root, stack.seed)
|
|
166119
|
+
}));
|
|
166120
|
+
let running;
|
|
166121
|
+
const run = () => {
|
|
166122
|
+
running ??= (async () => {
|
|
166123
|
+
try {
|
|
166124
|
+
for (const entry of seeds) {
|
|
166125
|
+
debug(`Seeding the ${entry.name} stack`);
|
|
166126
|
+
await new Promise((resolve5, reject) => {
|
|
166127
|
+
const child = spawn5("bun", [entry.file], {
|
|
166128
|
+
cwd: directories.root,
|
|
166129
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
166130
|
+
env: { ...process.env, ...props.env }
|
|
166131
|
+
});
|
|
166132
|
+
const output = [];
|
|
166133
|
+
const capture = (chunk3) => output.push(chunk3.toString());
|
|
166134
|
+
child.stdout?.on("data", capture);
|
|
166135
|
+
child.stderr?.on("data", capture);
|
|
166136
|
+
child.on("error", reject);
|
|
166137
|
+
child.on("exit", (code) => {
|
|
166138
|
+
const logs = output.join("").trim();
|
|
166139
|
+
if (logs) {
|
|
166140
|
+
debug(logs);
|
|
166141
|
+
}
|
|
166142
|
+
if (code === 0) {
|
|
166143
|
+
resolve5();
|
|
166144
|
+
} else {
|
|
166145
|
+
reject(new Error(`The seed of the "${entry.name}" stack exited with code ${code}:
|
|
166146
|
+
${logs}`));
|
|
166147
|
+
}
|
|
166148
|
+
});
|
|
166149
|
+
});
|
|
166150
|
+
}
|
|
166151
|
+
} finally {
|
|
166152
|
+
running = undefined;
|
|
166153
|
+
}
|
|
166154
|
+
})();
|
|
166155
|
+
return running;
|
|
166156
|
+
};
|
|
166157
|
+
return { count: seeds.length, run };
|
|
166158
|
+
};
|
|
166159
|
+
|
|
166013
166160
|
// src/dev/dashboard/index.ts
|
|
166014
|
-
var
|
|
166161
|
+
var import_ioredis5 = __toESM(require_built3(), 1);
|
|
166015
166162
|
import { DynamoDBClient as DynamoDBClient4 } from "@aws-sdk/client-dynamodb";
|
|
166016
|
-
import { DynamoDBDocumentClient, ScanCommand } from "@aws-sdk/lib-dynamodb";
|
|
166163
|
+
import { DynamoDBDocumentClient, ScanCommand as ScanCommand2 } from "@aws-sdk/lib-dynamodb";
|
|
166017
166164
|
import { randomUUID as randomUUID5 } from "crypto";
|
|
166018
|
-
import { readdir as
|
|
166165
|
+
import { readdir as readdir9, readFile as readFile21, stat as stat9, writeFile as writeFile12 } from "fs/promises";
|
|
166019
166166
|
import { createServer as createServer8 } from "http";
|
|
166020
|
-
import { join as
|
|
166167
|
+
import { join as join51, relative as relative10, sep as sep5 } from "path";
|
|
166021
166168
|
|
|
166022
166169
|
// src/dev/worker.ts
|
|
166023
|
-
import { spawn as
|
|
166170
|
+
import { spawn as spawn6 } from "child_process";
|
|
166024
166171
|
import { writeFile as writeFile11 } from "fs/promises";
|
|
166025
|
-
import { join as
|
|
166172
|
+
import { join as join50 } from "path";
|
|
166026
166173
|
class WorkerError extends Error {
|
|
166027
166174
|
name;
|
|
166028
166175
|
constructor(name, message4, stack) {
|
|
@@ -166115,10 +166262,10 @@ var createBundleWorker = (props) => {
|
|
|
166115
166262
|
throw new Error("The bundle worker never became ready.");
|
|
166116
166263
|
};
|
|
166117
166264
|
const start = async () => {
|
|
166118
|
-
const entry =
|
|
166265
|
+
const entry = join50(props.buildDir, "worker.mjs");
|
|
166119
166266
|
await writeFile11(entry, WORKER_ENTRY);
|
|
166120
166267
|
port = await findFreePort();
|
|
166121
|
-
child =
|
|
166268
|
+
child = spawn6("node", ["--enable-source-maps", entry], {
|
|
166122
166269
|
cwd: props.buildDir,
|
|
166123
166270
|
stdio: ["ignore", "pipe", "pipe"],
|
|
166124
166271
|
env: {
|
|
@@ -166273,6 +166420,8 @@ var dashboardHtml = `<!doctype html>
|
|
|
166273
166420
|
cursor: pointer;
|
|
166274
166421
|
}
|
|
166275
166422
|
nav button .count { margin-left: auto; }
|
|
166423
|
+
nav button.reseed { margin-top: auto; color: var(--muted); }
|
|
166424
|
+
nav button.reseed:disabled { cursor: default; }
|
|
166276
166425
|
.icon {
|
|
166277
166426
|
width: 15px;
|
|
166278
166427
|
height: 15px;
|
|
@@ -166469,6 +166618,7 @@ const ICONS = {
|
|
|
166469
166618
|
config: svg('<line x1="4" y1="21" x2="4" y2="14"/><line x1="4" y1="10" x2="4" y2="3"/><line x1="12" y1="21" x2="12" y2="12"/><line x1="12" y1="8" x2="12" y2="3"/><line x1="20" y1="21" x2="20" y2="16"/><line x1="20" y1="12" x2="20" y2="3"/><line x1="1" y1="14" x2="7" y2="14"/><line x1="9" y1="8" x2="15" y2="8"/><line x1="17" y1="16" x2="23" y2="16"/>'),
|
|
166470
166619
|
route: svg('<circle cx="12" cy="12" r="10"/><line x1="2" y1="12" x2="22" y2="12"/><path d="M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"/>'),
|
|
166471
166620
|
site: svg('<rect x="2" y="3" width="20" height="14" rx="2"/><line x1="8" y1="21" x2="16" y2="21"/><line x1="12" y1="17" x2="12" y2="21"/>'),
|
|
166621
|
+
seed: svg('<path d="M12 22V8"/><path d="M12 8C12 5 9 2 5 2c0 4 3 6 7 6z"/><path d="M12 12c0-3 3-6 7-6 0 4-3 6-7 6z"/>'),
|
|
166472
166622
|
}
|
|
166473
166623
|
|
|
166474
166624
|
const icon = kind => {
|
|
@@ -167122,6 +167272,46 @@ const render = () => {
|
|
|
167122
167272
|
nav.append(button)
|
|
167123
167273
|
}
|
|
167124
167274
|
|
|
167275
|
+
if (state.seeds) {
|
|
167276
|
+
const reseed = $('button', { className: 'reseed' }, [icon('seed'), 'Reset & seed'])
|
|
167277
|
+
let armed = false
|
|
167278
|
+
let disarm
|
|
167279
|
+
|
|
167280
|
+
reseed.onclick = async () => {
|
|
167281
|
+
// The reset wipes all local data, so it asks for a second
|
|
167282
|
+
// click before running.
|
|
167283
|
+
if (!armed) {
|
|
167284
|
+
armed = true
|
|
167285
|
+
reseed.lastChild.textContent = 'Click to confirm'
|
|
167286
|
+
disarm = setTimeout(() => {
|
|
167287
|
+
armed = false
|
|
167288
|
+
reseed.lastChild.textContent = 'Reset & seed'
|
|
167289
|
+
}, 3000)
|
|
167290
|
+
return
|
|
167291
|
+
}
|
|
167292
|
+
|
|
167293
|
+
clearTimeout(disarm)
|
|
167294
|
+
armed = false
|
|
167295
|
+
reseed.disabled = true
|
|
167296
|
+
reseed.lastChild.textContent = 'Seeding...'
|
|
167297
|
+
|
|
167298
|
+
try {
|
|
167299
|
+
const res = await fetch('/api/seed', { method: 'POST' })
|
|
167300
|
+
const data = await res.json()
|
|
167301
|
+
reseed.lastChild.textContent = data.ok ? 'Done' : 'Failed'
|
|
167302
|
+
} catch {
|
|
167303
|
+
reseed.lastChild.textContent = 'Failed'
|
|
167304
|
+
}
|
|
167305
|
+
|
|
167306
|
+
setTimeout(() => {
|
|
167307
|
+
reseed.disabled = false
|
|
167308
|
+
reseed.lastChild.textContent = 'Reset & seed'
|
|
167309
|
+
}, 2000)
|
|
167310
|
+
}
|
|
167311
|
+
|
|
167312
|
+
nav.append(reseed)
|
|
167313
|
+
}
|
|
167314
|
+
|
|
167125
167315
|
const main = document.getElementById('main')
|
|
167126
167316
|
main.innerHTML = ''
|
|
167127
167317
|
|
|
@@ -167201,7 +167391,8 @@ var createDashboardServer = (props) => {
|
|
|
167201
167391
|
app: props.app,
|
|
167202
167392
|
routerPorts: props.routerPorts,
|
|
167203
167393
|
resources: props.resources,
|
|
167204
|
-
routes: props.routes
|
|
167394
|
+
routes: props.routes,
|
|
167395
|
+
seeds: Boolean(props.runSeeds)
|
|
167205
167396
|
}).replaceAll("<", "\\u003c");
|
|
167206
167397
|
return { status: 200, body: dashboardHtml.replace("__STATE__", state), type: "text/html" };
|
|
167207
167398
|
}
|
|
@@ -167244,7 +167435,7 @@ var createDashboardServer = (props) => {
|
|
|
167244
167435
|
if (url.pathname === "/api/table") {
|
|
167245
167436
|
const name = url.searchParams.get("name");
|
|
167246
167437
|
try {
|
|
167247
|
-
const result = await getDocumentClient().send(new
|
|
167438
|
+
const result = await getDocumentClient().send(new ScanCommand2({ TableName: name, Limit: 100 }));
|
|
167248
167439
|
return { status: 200, body: JSON.stringify({ items: result.Items ?? [], count: result.Count ?? 0 }) };
|
|
167249
167440
|
} catch (error3) {
|
|
167250
167441
|
throw new Error(`Scanning "${name}" via ${props.env.AWS_ENDPOINT_URL_DYNAMODB ?? "no dynamodb endpoint"} failed: ${error3 instanceof Error ? error3.message : String(error3)}`);
|
|
@@ -167252,7 +167443,7 @@ var createDashboardServer = (props) => {
|
|
|
167252
167443
|
}
|
|
167253
167444
|
if (url.pathname === "/api/cache") {
|
|
167254
167445
|
const [host, port] = (url.searchParams.get("target") ?? "").split(":");
|
|
167255
|
-
const redis = new
|
|
167446
|
+
const redis = new import_ioredis5.Redis({ host, port: Number(port), lazyConnect: true });
|
|
167256
167447
|
try {
|
|
167257
167448
|
await redis.connect();
|
|
167258
167449
|
const keyspace = await redis.info("keyspace");
|
|
@@ -167299,12 +167490,12 @@ var createDashboardServer = (props) => {
|
|
|
167299
167490
|
const walk2 = async (dir) => {
|
|
167300
167491
|
let entries2;
|
|
167301
167492
|
try {
|
|
167302
|
-
entries2 = await
|
|
167493
|
+
entries2 = await readdir9(dir, { withFileTypes: true });
|
|
167303
167494
|
} catch (_4) {
|
|
167304
167495
|
return;
|
|
167305
167496
|
}
|
|
167306
167497
|
for (const entry of entries2) {
|
|
167307
|
-
const path6 =
|
|
167498
|
+
const path6 = join51(dir, entry.name);
|
|
167308
167499
|
if (entry.isDirectory()) {
|
|
167309
167500
|
await walk2(path6);
|
|
167310
167501
|
} else {
|
|
@@ -167319,6 +167510,20 @@ var createDashboardServer = (props) => {
|
|
|
167319
167510
|
await walk2(props.storeRoot);
|
|
167320
167511
|
return { status: 200, body: JSON.stringify({ files }) };
|
|
167321
167512
|
}
|
|
167513
|
+
if (url.pathname === "/api/seed" && req.method === "POST") {
|
|
167514
|
+
if (!props.runSeeds) {
|
|
167515
|
+
return { status: 400, body: JSON.stringify({ error: "No seed files configured." }) };
|
|
167516
|
+
}
|
|
167517
|
+
try {
|
|
167518
|
+
await props.runSeeds();
|
|
167519
|
+
return { status: 200, body: JSON.stringify({ ok: true }) };
|
|
167520
|
+
} catch (error3) {
|
|
167521
|
+
return {
|
|
167522
|
+
status: 500,
|
|
167523
|
+
body: JSON.stringify({ error: error3 instanceof Error ? error3.message : String(error3) })
|
|
167524
|
+
};
|
|
167525
|
+
}
|
|
167526
|
+
}
|
|
167322
167527
|
if (url.pathname === "/api/config") {
|
|
167323
167528
|
if (req.method === "PUT") {
|
|
167324
167529
|
const values2 = JSON.parse((await readBody3(req)).toString() || "{}");
|
|
@@ -167552,22 +167757,22 @@ var createLambdaServer = (props) => {
|
|
|
167552
167757
|
};
|
|
167553
167758
|
|
|
167554
167759
|
// src/dev/sdk.ts
|
|
167555
|
-
import { readdir as
|
|
167760
|
+
import { readdir as readdir10, readFile as readFile22, mkdir as mkdir9, rm as rm11, symlink } from "fs/promises";
|
|
167556
167761
|
import { createRequire } from "module";
|
|
167557
|
-
import { dirname as dirname22, join as
|
|
167762
|
+
import { dirname as dirname22, join as join52 } from "path";
|
|
167558
167763
|
var linkSdkPackages = async (buildDir, onWarn) => {
|
|
167559
|
-
const filesDir =
|
|
167764
|
+
const filesDir = join52(buildDir, "files");
|
|
167560
167765
|
const packages = new Set;
|
|
167561
|
-
for (const file2 of await
|
|
167766
|
+
for (const file2 of await readdir10(filesDir)) {
|
|
167562
167767
|
if (!file2.endsWith(".mjs")) {
|
|
167563
167768
|
continue;
|
|
167564
167769
|
}
|
|
167565
|
-
const code = await readFile22(
|
|
167770
|
+
const code = await readFile22(join52(filesDir, file2), "utf8");
|
|
167566
167771
|
for (const match3 of code.matchAll(/(?:from\s*|import\()\s*["'](@aws-sdk\/[a-z0-9-]+|sharp)["']/g)) {
|
|
167567
167772
|
packages.add(match3[1]);
|
|
167568
167773
|
}
|
|
167569
167774
|
}
|
|
167570
|
-
const projectRequire = createRequire(
|
|
167775
|
+
const projectRequire = createRequire(join52(directories.root, "noop.js"));
|
|
167571
167776
|
const ownRequire = createRequire(import.meta.url);
|
|
167572
167777
|
for (const name of packages) {
|
|
167573
167778
|
try {
|
|
@@ -167581,9 +167786,9 @@ var linkSdkPackages = async (buildDir, onWarn) => {
|
|
|
167581
167786
|
onWarn?.(`The bundle imports "${name}", which is neither a project dependency nor shipped with the cli. Add it to your project dependencies.`);
|
|
167582
167787
|
continue;
|
|
167583
167788
|
}
|
|
167584
|
-
const target2 =
|
|
167789
|
+
const target2 = join52(buildDir, "node_modules", name);
|
|
167585
167790
|
await mkdir9(dirname22(target2), { recursive: true });
|
|
167586
|
-
await
|
|
167791
|
+
await rm11(target2, { recursive: true, force: true });
|
|
167587
167792
|
await symlink(source, target2, "dir");
|
|
167588
167793
|
}
|
|
167589
167794
|
};
|
|
@@ -167596,14 +167801,17 @@ var startDev = async (props) => {
|
|
|
167596
167801
|
const { builders, appId } = createApp({
|
|
167597
167802
|
appConfig,
|
|
167598
167803
|
stackConfigs,
|
|
167599
|
-
accountId: LOCAL_ACCOUNT_ID
|
|
167804
|
+
accountId: LOCAL_ACCOUNT_ID,
|
|
167805
|
+
dev: true
|
|
167600
167806
|
});
|
|
167601
|
-
await mkdir10(
|
|
167807
|
+
await mkdir10(join53(directories.output, "local"), { recursive: true });
|
|
167602
167808
|
const routerPorts = {};
|
|
167603
167809
|
Object.keys(appConfig.router ?? {}).forEach((id, index) => {
|
|
167604
167810
|
routerPorts[id] = props.port + 1 + index;
|
|
167605
167811
|
});
|
|
167812
|
+
const firstBoot = props.pool.peek("session") === undefined;
|
|
167606
167813
|
props.pool.begin();
|
|
167814
|
+
await props.pool.keep("session", null, async () => ({ value: true, stop: () => {} }));
|
|
167607
167815
|
const dev = createDevContext({ appConfig, stackConfigs, appId, routerPorts, log, pool: props.pool });
|
|
167608
167816
|
log("Preparing the local resources...");
|
|
167609
167817
|
for (const feature of features) {
|
|
@@ -167642,7 +167850,7 @@ var startDev = async (props) => {
|
|
|
167642
167850
|
for (const [id, port] of Object.entries(routerPorts)) {
|
|
167643
167851
|
env4[`ROUTER_${constantCase(id)}_ENDPOINT`] = `localhost:${port}`;
|
|
167644
167852
|
}
|
|
167645
|
-
await writeFile13(
|
|
167853
|
+
await writeFile13(join53(directories.output, "local", "env.json"), JSON.stringify(env4, null, "\t") + `
|
|
167646
167854
|
`);
|
|
167647
167855
|
const sorted = [...builders].sort((a4, b6) => Number(a4.type === "bundle") - Number(b6.type === "bundle"));
|
|
167648
167856
|
const workspace = await loadWorkspace3(directories.root);
|
|
@@ -167701,6 +167909,16 @@ var startDev = async (props) => {
|
|
|
167701
167909
|
log("Fix the error - the next invoke retries.");
|
|
167702
167910
|
dirty = true;
|
|
167703
167911
|
}
|
|
167912
|
+
const seeder = createSeedRunner({ stackConfigs, env: env4 });
|
|
167913
|
+
const resetData = createDataReset({ pool: props.pool, appConfig, stackConfigs });
|
|
167914
|
+
if (firstBoot && seeder.count > 0 && !dirty) {
|
|
167915
|
+
log("Seeding the local data...");
|
|
167916
|
+
try {
|
|
167917
|
+
await seeder.run();
|
|
167918
|
+
} catch (error3) {
|
|
167919
|
+
log(`Seeding failed: ${error3 instanceof Error ? error3.message : String(error3)}`);
|
|
167920
|
+
}
|
|
167921
|
+
}
|
|
167704
167922
|
const routers = [];
|
|
167705
167923
|
for (const [id, port] of Object.entries(routerPorts)) {
|
|
167706
167924
|
routers.push(await startDevRouter({
|
|
@@ -167711,14 +167929,18 @@ var startDev = async (props) => {
|
|
|
167711
167929
|
}
|
|
167712
167930
|
const dashboardPort = props.port;
|
|
167713
167931
|
const dashboard = createDashboardServer({
|
|
167932
|
+
runSeeds: seeder.count > 0 ? async () => {
|
|
167933
|
+
await resetData();
|
|
167934
|
+
await seeder.run();
|
|
167935
|
+
} : undefined,
|
|
167714
167936
|
app: appConfig.name,
|
|
167715
167937
|
region: appConfig.region,
|
|
167716
167938
|
routerPorts,
|
|
167717
167939
|
resources: dev.resources,
|
|
167718
167940
|
routes: dev.routes,
|
|
167719
167941
|
env: env4,
|
|
167720
|
-
storeRoot:
|
|
167721
|
-
configFile:
|
|
167942
|
+
storeRoot: join53(directories.output, "local", "store"),
|
|
167943
|
+
configFile: join53(directories.output, "local", "config.json"),
|
|
167722
167944
|
events: dev.events
|
|
167723
167945
|
});
|
|
167724
167946
|
dashboard.connect(dispatch);
|
|
@@ -167740,7 +167962,7 @@ var startDev = async (props) => {
|
|
|
167740
167962
|
dashboardPort,
|
|
167741
167963
|
routerPorts,
|
|
167742
167964
|
async stop() {
|
|
167743
|
-
await
|
|
167965
|
+
await rm12(join53(directories.output, "local", "env.json"), { force: true });
|
|
167744
167966
|
await watcher.close();
|
|
167745
167967
|
await restartWatcher?.close();
|
|
167746
167968
|
for (const router of routers) {
|
|
@@ -167804,7 +168026,7 @@ var createServerPool = () => {
|
|
|
167804
168026
|
|
|
167805
168027
|
// src/type-gen/generate.ts
|
|
167806
168028
|
import { mkdir as mkdir11, writeFile as writeFile14 } from "fs/promises";
|
|
167807
|
-
import { dirname as dirname23, join as
|
|
168029
|
+
import { dirname as dirname23, join as join54, relative as relative11 } from "path";
|
|
167808
168030
|
var generateTypes = async (props) => {
|
|
167809
168031
|
const files = [];
|
|
167810
168032
|
await Promise.all(features.map((feature) => {
|
|
@@ -167812,7 +168034,7 @@ var generateTypes = async (props) => {
|
|
|
167812
168034
|
...props,
|
|
167813
168035
|
async write(file2, data, include = false) {
|
|
167814
168036
|
const code = data?.toString("utf8");
|
|
167815
|
-
const path6 =
|
|
168037
|
+
const path6 = join54(directories.types, file2);
|
|
167816
168038
|
if (code) {
|
|
167817
168039
|
if (include) {
|
|
167818
168040
|
files.push(relative11(directories.root, path6));
|
|
@@ -167826,7 +168048,7 @@ var generateTypes = async (props) => {
|
|
|
167826
168048
|
if (files.length) {
|
|
167827
168049
|
const code = files.map((file2) => `/// <reference path='${file2}' />`).join(`
|
|
167828
168050
|
`);
|
|
167829
|
-
await writeFile14(
|
|
168051
|
+
await writeFile14(join54(directories.root, `awsless.d.ts`), code);
|
|
167830
168052
|
}
|
|
167831
168053
|
};
|
|
167832
168054
|
|
|
@@ -183447,12 +183669,12 @@ var state = (program3) => {
|
|
|
183447
183669
|
|
|
183448
183670
|
// src/cli/command/test.ts
|
|
183449
183671
|
import { mkdir as mkdir12, writeFile as writeFile15 } from "fs/promises";
|
|
183450
|
-
import { join as
|
|
183672
|
+
import { join as join56 } from "path";
|
|
183451
183673
|
|
|
183452
183674
|
// src/test/manifest.ts
|
|
183453
|
-
import { isAbsolute as
|
|
183675
|
+
import { isAbsolute as isAbsolute5, join as join55 } from "path";
|
|
183454
183676
|
var absolute = (file2) => {
|
|
183455
|
-
return
|
|
183677
|
+
return isAbsolute5(file2) ? file2 : join55(directories.root, file2);
|
|
183456
183678
|
};
|
|
183457
183679
|
var createTestManifest = (appConfig, stackConfigs) => {
|
|
183458
183680
|
const manifest = {
|
|
@@ -183548,7 +183770,7 @@ var test2 = (program3) => {
|
|
|
183548
183770
|
return "No tests found.";
|
|
183549
183771
|
}
|
|
183550
183772
|
const manifest = createTestManifest(props.appConfig, props.stackConfigs);
|
|
183551
|
-
const manifestFile =
|
|
183773
|
+
const manifestFile = join56(directories.output, "test", "manifest.json");
|
|
183552
183774
|
let redis;
|
|
183553
183775
|
let killSearch;
|
|
183554
183776
|
manifest.servers = {};
|
|
@@ -183575,7 +183797,7 @@ var test2 = (program3) => {
|
|
|
183575
183797
|
await redis.ping();
|
|
183576
183798
|
manifest.servers.redis = { host: "127.0.0.1", port: await redis.getPort() };
|
|
183577
183799
|
}
|
|
183578
|
-
await mkdir12(
|
|
183800
|
+
await mkdir12(join56(directories.output, "test"), { recursive: true });
|
|
183579
183801
|
await writeFile15(manifestFile, JSON.stringify(manifest));
|
|
183580
183802
|
process.env.AWSLESS_TEST_MANIFEST = manifestFile;
|
|
183581
183803
|
let passed = false;
|