@awsless/cli 0.0.46-local.49 → 0.0.46-local.51
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 +35 -22
- package/package.json +17 -17
package/dist/bin.js
CHANGED
|
@@ -166576,6 +166576,7 @@ import { join as join52, relative as relative10, sep as sep5 } from "path";
|
|
|
166576
166576
|
// src/dev/worker.ts
|
|
166577
166577
|
import { spawn as spawn6 } from "child_process";
|
|
166578
166578
|
import { writeFile as writeFile12 } from "fs/promises";
|
|
166579
|
+
import { availableParallelism } from "os";
|
|
166579
166580
|
import { join as join51 } from "path";
|
|
166580
166581
|
class WorkerError extends Error {
|
|
166581
166582
|
name;
|
|
@@ -166671,19 +166672,19 @@ const server = createServer((req, res) => {
|
|
|
166671
166672
|
server.listen(Number(process.env.AWSLESS_DEV_WORKER_PORT), '127.0.0.1')
|
|
166672
166673
|
`;
|
|
166673
166674
|
var createBundleWorker = (props) => {
|
|
166674
|
-
let
|
|
166675
|
-
|
|
166675
|
+
let workers = [];
|
|
166676
|
+
const concurrency = Math.max(1, props.concurrency ?? (Number(process.env.AWSLESS_DEV_WORKERS) || Math.min(4, Math.max(2, availableParallelism() - 2))));
|
|
166676
166677
|
const context = {
|
|
166677
166678
|
invokedFunctionArn: `arn:aws:lambda:${props.env.AWS_REGION}:${props.env.AWS_ACCOUNT_ID}:function:${props.functionName}:local`
|
|
166678
166679
|
};
|
|
166679
|
-
const waitForReady = async () => {
|
|
166680
|
+
const waitForReady = async (worker) => {
|
|
166680
166681
|
const deadline = Date.now() + 1e4;
|
|
166681
166682
|
while (Date.now() < deadline) {
|
|
166682
|
-
if (child
|
|
166683
|
-
throw new Error(`The bundle worker exited with code ${child.exitCode} during startup.`);
|
|
166683
|
+
if (worker.child.exitCode !== null) {
|
|
166684
|
+
throw new Error(`The bundle worker exited with code ${worker.child.exitCode} during startup.`);
|
|
166684
166685
|
}
|
|
166685
166686
|
try {
|
|
166686
|
-
const res = await fetch(`http://127.0.0.1:${port}`);
|
|
166687
|
+
const res = await fetch(`http://127.0.0.1:${worker.port}`);
|
|
166687
166688
|
if (res.ok) {
|
|
166688
166689
|
return;
|
|
166689
166690
|
}
|
|
@@ -166692,11 +166693,10 @@ var createBundleWorker = (props) => {
|
|
|
166692
166693
|
}
|
|
166693
166694
|
throw new Error("The bundle worker never became ready.");
|
|
166694
166695
|
};
|
|
166695
|
-
const
|
|
166696
|
+
const startWorker = async () => {
|
|
166696
166697
|
const entry = join51(props.buildDir, "worker.mjs");
|
|
166697
|
-
await
|
|
166698
|
-
|
|
166699
|
-
child = spawn6("node", ["--enable-source-maps", entry], {
|
|
166698
|
+
const port = await findFreePort();
|
|
166699
|
+
const child = spawn6("node", ["--enable-source-maps", entry], {
|
|
166700
166700
|
cwd: props.buildDir,
|
|
166701
166701
|
stdio: ["ignore", "pipe", "pipe"],
|
|
166702
166702
|
env: {
|
|
@@ -166743,11 +166743,18 @@ var createBundleWorker = (props) => {
|
|
|
166743
166743
|
debug(`Bundle worker exited with code ${code}`);
|
|
166744
166744
|
}
|
|
166745
166745
|
});
|
|
166746
|
-
|
|
166746
|
+
const worker = { child, port, inflight: 0 };
|
|
166747
|
+
await waitForReady(worker);
|
|
166748
|
+
return worker;
|
|
166749
|
+
};
|
|
166750
|
+
const start = async () => {
|
|
166751
|
+
await writeFile12(join51(props.buildDir, "worker.mjs"), WORKER_ENTRY);
|
|
166752
|
+
workers = await Promise.all(Array.from({ length: concurrency }, () => startWorker()));
|
|
166747
166753
|
};
|
|
166748
166754
|
const stop = async () => {
|
|
166749
|
-
|
|
166750
|
-
|
|
166755
|
+
const stopping = workers;
|
|
166756
|
+
workers = [];
|
|
166757
|
+
await Promise.all(stopping.map((worker) => stopChild(worker.child)));
|
|
166751
166758
|
};
|
|
166752
166759
|
return {
|
|
166753
166760
|
start,
|
|
@@ -166757,18 +166764,24 @@ var createBundleWorker = (props) => {
|
|
|
166757
166764
|
await start();
|
|
166758
166765
|
},
|
|
166759
166766
|
async dispatch(event) {
|
|
166760
|
-
if (
|
|
166767
|
+
if (workers.length === 0) {
|
|
166761
166768
|
throw new Error("The bundle worker is not running.");
|
|
166762
166769
|
}
|
|
166763
|
-
const
|
|
166764
|
-
|
|
166765
|
-
|
|
166766
|
-
|
|
166767
|
-
|
|
166768
|
-
|
|
166769
|
-
|
|
166770
|
+
const worker = workers.reduce((a4, b6) => b6.inflight < a4.inflight ? b6 : a4);
|
|
166771
|
+
worker.inflight++;
|
|
166772
|
+
try {
|
|
166773
|
+
const res = await fetch(`http://127.0.0.1:${worker.port}`, {
|
|
166774
|
+
method: "POST",
|
|
166775
|
+
body: JSON.stringify({ event, context })
|
|
166776
|
+
});
|
|
166777
|
+
const body = await res.json();
|
|
166778
|
+
if (body.error) {
|
|
166779
|
+
throw new WorkerError(body.error.name, body.error.message, body.error.stack);
|
|
166780
|
+
}
|
|
166781
|
+
return body.result;
|
|
166782
|
+
} finally {
|
|
166783
|
+
worker.inflight--;
|
|
166770
166784
|
}
|
|
166771
|
-
return body.result;
|
|
166772
166785
|
}
|
|
166773
166786
|
};
|
|
166774
166787
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/cli",
|
|
3
|
-
"version": "0.0.46-local.
|
|
3
|
+
"version": "0.0.46-local.51",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -38,19 +38,19 @@
|
|
|
38
38
|
"@opensearch-project/opensearch": "^2.13.0",
|
|
39
39
|
"rolldown": "1.2.1",
|
|
40
40
|
"vitest": "4.1.10",
|
|
41
|
-
"@awsless/
|
|
42
|
-
"@awsless/
|
|
41
|
+
"@awsless/dynamodb-server": "^0.1.8",
|
|
42
|
+
"@awsless/ts-file-cache": "^0.0.16"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"@awsless/big-float": "^0.1.7",
|
|
46
46
|
"@awsless/duration": "^0.0.4",
|
|
47
47
|
"@awsless/json": "^0.0.11",
|
|
48
|
-
"@awsless/s3": "^0.0.22",
|
|
49
48
|
"@awsless/dynamodb": "^0.3.22",
|
|
50
|
-
"@awsless/weak-cache": "^0.0.1",
|
|
51
49
|
"@awsless/lambda": "^0.0.47",
|
|
50
|
+
"@awsless/s3": "^0.0.22",
|
|
52
51
|
"@awsless/validate": "^0.1.8",
|
|
53
|
-
"awsless": "^0.0.
|
|
52
|
+
"@awsless/weak-cache": "^0.0.1",
|
|
53
|
+
"awsless": "^0.0.15-local.13"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@aws-sdk/client-cloudformation": "^3.369.0",
|
|
@@ -121,24 +121,24 @@
|
|
|
121
121
|
"zod": "^3.24.2",
|
|
122
122
|
"zod-to-json-schema": "^3.24.3",
|
|
123
123
|
"@awsless/big-float": "^0.1.7",
|
|
124
|
-
"@awsless/cloudwatch": "^0.0.1",
|
|
125
124
|
"@awsless/clui": "^0.0.9",
|
|
125
|
+
"@awsless/cloudwatch": "^0.0.1",
|
|
126
126
|
"@awsless/duration": "^0.0.4",
|
|
127
|
+
"@awsless/dynamodb": "^0.3.22",
|
|
128
|
+
"@awsless/iot": "^0.0.5",
|
|
127
129
|
"@awsless/json": "^0.0.11",
|
|
128
|
-
"@awsless/lambda": "^0.0.47",
|
|
129
130
|
"@awsless/open-search": "^0.0.26",
|
|
130
|
-
"@awsless/iot": "^0.0.5",
|
|
131
|
-
"@awsless/redis": "^0.1.13",
|
|
132
|
-
"@awsless/dynamodb": "^0.3.22",
|
|
133
|
-
"@awsless/s3": "^0.0.22",
|
|
134
|
-
"@awsless/sqs": "^0.0.24",
|
|
135
131
|
"@awsless/scheduler": "^0.0.5",
|
|
136
|
-
"@awsless/
|
|
132
|
+
"@awsless/s3": "^0.0.22",
|
|
133
|
+
"@awsless/lambda": "^0.0.47",
|
|
134
|
+
"@awsless/redis": "^0.1.13",
|
|
137
135
|
"@awsless/size": "^0.0.2",
|
|
138
|
-
"@awsless/
|
|
139
|
-
"@awsless/
|
|
136
|
+
"@awsless/ssm": "^0.0.8",
|
|
137
|
+
"@awsless/sqs": "^0.0.24",
|
|
140
138
|
"@awsless/sns": "^0.0.11",
|
|
141
|
-
"awsless": "^0.0.
|
|
139
|
+
"@awsless/weak-cache": "^0.0.1",
|
|
140
|
+
"awsless": "^0.0.15-local.13",
|
|
141
|
+
"@awsless/validate": "^0.1.8"
|
|
142
142
|
},
|
|
143
143
|
"scripts": {
|
|
144
144
|
"test": "bun cli/build-handlers.ts && pnpm vitest",
|