sst 2.26.4 → 2.26.6
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/cli/commands/dev.js
CHANGED
|
@@ -3,35 +3,20 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
3
3
|
type: "boolean",
|
|
4
4
|
description: "Increase function timeout",
|
|
5
5
|
}), async (args) => {
|
|
6
|
+
const { Logger } = await import("../../logger.js");
|
|
6
7
|
const { Colors } = await import("../colors.js");
|
|
7
8
|
const { printHeader } = await import("../ui/header.js");
|
|
8
9
|
const { mapValues } = await import("remeda");
|
|
9
10
|
const path = await import("path");
|
|
10
|
-
const { useRuntimeWorkers } = await import("../../runtime/workers.js");
|
|
11
|
-
const { useIOTBridge } = await import("../../runtime/iot.js");
|
|
12
|
-
const { useRuntimeServer } = await import("../../runtime/server.js");
|
|
13
11
|
const { useBus } = await import("../../bus.js");
|
|
14
12
|
const { useWatcher } = await import("../../watcher.js");
|
|
15
|
-
const { useAppMetadata, saveAppMetadata, Stacks } = await import("../../stacks/index.js");
|
|
16
13
|
const { exit, exitWithError, trackDevError, trackDevRunning } = await import("../program.js");
|
|
17
|
-
const { Logger } = await import("../../logger.js");
|
|
18
14
|
const { createSpinner } = await import("../spinner.js");
|
|
19
15
|
const { bold, dim, yellow } = await import("colorette");
|
|
20
|
-
const { render } = await import("ink");
|
|
21
|
-
const React = await import("react");
|
|
22
|
-
const { Context } = await import("../../context/context.js");
|
|
23
|
-
const { printDeploymentResults, DeploymentUI } = await import("../ui/deploy.js");
|
|
24
16
|
const { useLocalServer } = await import("../local/server.js");
|
|
25
17
|
const fs = await import("fs/promises");
|
|
26
18
|
const crypto = await import("crypto");
|
|
27
|
-
const { useFunctions } = await import("../../constructs/Function.js");
|
|
28
|
-
const { useSites } = await import("../../constructs/SsrSite.js");
|
|
29
|
-
const { usePothosBuilder } = await import("./plugins/pothos.js");
|
|
30
|
-
const { useKyselyTypeGenerator } = await import("./plugins/kysely.js");
|
|
31
|
-
const { useRDSWarmer } = await import("./plugins/warmer.js");
|
|
32
19
|
const { useProject } = await import("../../project.js");
|
|
33
|
-
const { useMetadataCache } = await import("../../stacks/metadata.js");
|
|
34
|
-
const { useIOT } = await import("../../iot.js");
|
|
35
20
|
const { clear } = await import("../terminal.js");
|
|
36
21
|
const { getCiInfo } = await import("../ci-info.js");
|
|
37
22
|
try {
|
|
@@ -40,6 +25,7 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
40
25
|
}
|
|
41
26
|
const project = useProject();
|
|
42
27
|
const useFunctionLogger = lazy(async () => {
|
|
28
|
+
const { useFunctions } = await import("../../constructs/Function.js");
|
|
43
29
|
const bus = useBus();
|
|
44
30
|
const colors = ["#01cdfe", "#ff71ce", "#05ffa1", "#b967ff"];
|
|
45
31
|
let index = 0;
|
|
@@ -141,11 +127,15 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
141
127
|
});
|
|
142
128
|
const useStackBuilder = lazy(async () => {
|
|
143
129
|
const watcher = useWatcher();
|
|
130
|
+
const { printDeploymentResults, DeploymentUI } = await import("../ui/deploy.js");
|
|
131
|
+
const { render } = await import("ink");
|
|
132
|
+
const React = await import("react");
|
|
144
133
|
const scriptVersion = Date.now().toString();
|
|
145
134
|
let lastDeployed;
|
|
146
135
|
let isWorking = false;
|
|
147
136
|
let isDirty = false;
|
|
148
137
|
async function build() {
|
|
138
|
+
const { Stacks } = await import("../../stacks/index.js");
|
|
149
139
|
if (isWorking) {
|
|
150
140
|
isDirty = true;
|
|
151
141
|
return;
|
|
@@ -205,15 +195,40 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
205
195
|
}
|
|
206
196
|
}
|
|
207
197
|
async function deploy(assembly) {
|
|
198
|
+
const metadata = await appMetadata();
|
|
199
|
+
if (!project.config.advanced?.disableAppModeCheck &&
|
|
200
|
+
!getCiInfo().isCI &&
|
|
201
|
+
metadata &&
|
|
202
|
+
metadata.mode !== "dev") {
|
|
203
|
+
async function promptChangeMode() {
|
|
204
|
+
const readline = await import("readline");
|
|
205
|
+
const rl = readline.createInterface({
|
|
206
|
+
input: process.stdin,
|
|
207
|
+
output: process.stdout,
|
|
208
|
+
});
|
|
209
|
+
return new Promise((resolve) => {
|
|
210
|
+
console.log("");
|
|
211
|
+
rl.question(`You have previously deployed the stage "${project.config.stage}" in production. It is recommended that you use a different stage for development. Read more here — https://docs.sst.dev/live-lambda-development\n\nAre you sure you want to run this stage in dev mode? [y/N] `, async (input) => {
|
|
212
|
+
rl.close();
|
|
213
|
+
resolve(input.trim() === "y");
|
|
214
|
+
});
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
if (!(await promptChangeMode())) {
|
|
218
|
+
await exit();
|
|
219
|
+
}
|
|
220
|
+
}
|
|
208
221
|
const nextChecksum = await checksum(assembly.directory);
|
|
222
|
+
const { useSites } = await import("../../constructs/SsrSite.js");
|
|
209
223
|
const component = render(React.createElement(DeploymentUI, { assembly: assembly }));
|
|
224
|
+
const { Stacks } = await import("../../stacks/index.js");
|
|
210
225
|
const results = await Stacks.deployMany(assembly.stacks);
|
|
211
226
|
component.clear();
|
|
212
227
|
component.unmount();
|
|
213
228
|
printDeploymentResults(assembly, results);
|
|
214
229
|
// Run after initial deploy
|
|
215
230
|
if (!lastDeployed) {
|
|
216
|
-
await saveAppMetadata({ mode: "dev" });
|
|
231
|
+
await import("../../stacks/app-metadata.js").then((mod) => mod.saveAppMetadata({ mode: "dev" }));
|
|
217
232
|
// Check failed stacks
|
|
218
233
|
const failed = Object.values(results).find((result) => Stacks.isFailed(result.status));
|
|
219
234
|
failed
|
|
@@ -280,7 +295,7 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
280
295
|
});
|
|
281
296
|
const useDisconnector = lazy(async () => {
|
|
282
297
|
const bus = useBus();
|
|
283
|
-
const iot = await useIOT();
|
|
298
|
+
const iot = await import("../../iot.js").then((mod) => mod.useIOT());
|
|
284
299
|
bus.subscribe("cli.dev", async (evt) => {
|
|
285
300
|
const topic = `${iot.prefix}/events`;
|
|
286
301
|
iot.publish(topic, "cli.dev", evt.properties);
|
|
@@ -299,49 +314,25 @@ export const dev = (program) => program.command(["dev", "start"], "Work on your
|
|
|
299
314
|
await exit();
|
|
300
315
|
});
|
|
301
316
|
});
|
|
302
|
-
|
|
303
|
-
|
|
317
|
+
console.log("wtf");
|
|
318
|
+
Logger.debug("dev is ready");
|
|
319
|
+
const appMetadata = lazy(() => import("../../stacks/app-metadata.js").then((mod) => mod.useAppMetadata()));
|
|
320
|
+
clear();
|
|
321
|
+
await printHeader({ console: true, hint: "ready!" });
|
|
322
|
+
await Promise.all([
|
|
323
|
+
useStackBuilder(),
|
|
324
|
+
useDisconnector(),
|
|
325
|
+
import("../../runtime/workers.js").then((mod) => mod.useRuntimeWorkers()),
|
|
326
|
+
import("../../runtime/iot.js").then((mod) => mod.useIOTBridge()),
|
|
327
|
+
import("../../runtime/server.js").then((mod) => mod.useRuntimeServer()),
|
|
304
328
|
useLocalServer({
|
|
305
329
|
key: "",
|
|
306
330
|
cert: "",
|
|
307
331
|
live: true,
|
|
308
332
|
}),
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
const rl = readline.createInterface({
|
|
313
|
-
input: process.stdin,
|
|
314
|
-
output: process.stdout,
|
|
315
|
-
});
|
|
316
|
-
return new Promise((resolve) => {
|
|
317
|
-
console.log("");
|
|
318
|
-
rl.question(`You have previously deployed the stage "${project.config.stage}" in production. It is recommended that you use a different stage for development. Read more here — https://docs.sst.dev/live-lambda-development\n\nAre you sure you want to run this stage in dev mode? [y/N] `, async (input) => {
|
|
319
|
-
rl.close();
|
|
320
|
-
resolve(input.trim() === "y");
|
|
321
|
-
});
|
|
322
|
-
});
|
|
323
|
-
}
|
|
324
|
-
// Check app mode changed
|
|
325
|
-
if (!project.config.advanced?.disableAppModeCheck &&
|
|
326
|
-
!getCiInfo().isCI &&
|
|
327
|
-
appMetadata &&
|
|
328
|
-
appMetadata.mode !== "dev") {
|
|
329
|
-
if (!(await promptChangeMode())) {
|
|
330
|
-
await exit();
|
|
331
|
-
}
|
|
332
|
-
}
|
|
333
|
-
clear();
|
|
334
|
-
await printHeader({ console: true, hint: "ready!" });
|
|
335
|
-
await useStackBuilder();
|
|
336
|
-
await Promise.all([
|
|
337
|
-
useDisconnector(),
|
|
338
|
-
useRuntimeWorkers(),
|
|
339
|
-
useIOTBridge(),
|
|
340
|
-
useRuntimeServer(),
|
|
341
|
-
usePothosBuilder(),
|
|
342
|
-
useMetadataCache(),
|
|
343
|
-
useKyselyTypeGenerator(),
|
|
344
|
-
useRDSWarmer(),
|
|
333
|
+
import("./plugins/pothos.js").then((mod) => mod.usePothosBuilder()),
|
|
334
|
+
import("./plugins/kysely.js").then((mod) => mod.useKyselyTypeGenerator()),
|
|
335
|
+
import("./plugins/warmer.js").then((mod) => mod.useRDSWarmer()),
|
|
345
336
|
useFunctionLogger(),
|
|
346
337
|
]);
|
|
347
338
|
}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
export const load = (program) => program.command("load <filename>", "Loads secrets from an .env file", (yargs) => yargs
|
|
1
|
+
export const load = (program) => program.command("load <filename>", "Loads secrets from an .env file", (yargs) => yargs
|
|
2
|
+
.positional("filename", {
|
|
2
3
|
type: "string",
|
|
3
4
|
demandOption: true,
|
|
5
|
+
})
|
|
6
|
+
.option("fallback", {
|
|
7
|
+
type: "boolean",
|
|
8
|
+
describe: "Load the fallback values",
|
|
4
9
|
}), async (args) => {
|
|
5
10
|
const { exit, exitWithError } = await import("../../program.js");
|
|
6
11
|
const { Config } = await import("../../../config.js");
|
|
@@ -16,7 +21,11 @@ export const load = (program) => program.command("load <filename>", "Loads secre
|
|
|
16
21
|
// Set secrets
|
|
17
22
|
const setting = createSpinner(` Setting secrets from "${args.filename}"`).start();
|
|
18
23
|
for (const [key, value] of Object.entries(envVars)) {
|
|
19
|
-
await Config.setSecret({
|
|
24
|
+
await Config.setSecret({
|
|
25
|
+
key: key,
|
|
26
|
+
value: value,
|
|
27
|
+
fallback: args.fallback === true,
|
|
28
|
+
});
|
|
20
29
|
}
|
|
21
30
|
setting.succeed();
|
|
22
31
|
// Restart functions & sites
|
package/cli/local/server.js
CHANGED
|
@@ -105,7 +105,11 @@ export async function useLocalServer(opts) {
|
|
|
105
105
|
const sockets = new Set();
|
|
106
106
|
let invocations = [];
|
|
107
107
|
function publish(invocation) {
|
|
108
|
-
invocations.
|
|
108
|
+
const index = invocations.findLastIndex((i) => i.id === invocation.id);
|
|
109
|
+
if (index < 0)
|
|
110
|
+
invocations.push(invocation);
|
|
111
|
+
else
|
|
112
|
+
invocations[index] = invocation;
|
|
109
113
|
const json = JSON.stringify({
|
|
110
114
|
type: "invocation",
|
|
111
115
|
properties: [invocation],
|
|
@@ -234,7 +238,7 @@ export async function useLocalServer(opts) {
|
|
|
234
238
|
});
|
|
235
239
|
});
|
|
236
240
|
bus.subscribe("worker.stdout", (evt) => {
|
|
237
|
-
const invocation = invocations.findLast((i) => i.
|
|
241
|
+
const invocation = invocations.findLast((i) => i.id === evt.properties.requestID);
|
|
238
242
|
if (invocation) {
|
|
239
243
|
invocation.logs.push({
|
|
240
244
|
id: Math.random().toString(),
|
|
@@ -254,7 +258,7 @@ export async function useLocalServer(opts) {
|
|
|
254
258
|
});
|
|
255
259
|
});
|
|
256
260
|
bus.subscribe("function.success", (evt) => {
|
|
257
|
-
const invocation = invocations.findLast((i) => i.
|
|
261
|
+
const invocation = invocations.findLast((i) => i.id === evt.properties.requestID);
|
|
258
262
|
if (invocation) {
|
|
259
263
|
invocation.end = Date.now();
|
|
260
264
|
invocation.report = {
|
|
@@ -278,7 +282,7 @@ export async function useLocalServer(opts) {
|
|
|
278
282
|
});
|
|
279
283
|
});
|
|
280
284
|
bus.subscribe("function.error", (evt) => {
|
|
281
|
-
const invocation = invocations.findLast((i) => i.
|
|
285
|
+
const invocation = invocations.findLast((i) => i.id === evt.properties.requestID);
|
|
282
286
|
if (invocation) {
|
|
283
287
|
invocation.errors.push({
|
|
284
288
|
id: invocation.id,
|
package/node/api/index.js
CHANGED