sst 2.18.3 → 2.19.0
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/cdk/asset-publishing.d.ts +74 -0
- package/cdk/asset-publishing.js +147 -0
- package/cdk/deployments.d.ts +1 -1
- package/cdk/deployments.js +1 -3
- package/cdk-assets/private/asset-handler.d.ts +29 -0
- package/cdk-assets/private/asset-handler.js +1 -0
- package/cdk-assets/private/docker.d.ts +94 -0
- package/cdk-assets/private/docker.js +237 -0
- package/cdk-assets/private/handlers/container-images.d.ts +22 -0
- package/cdk-assets/private/handlers/container-images.js +231 -0
- package/cdk-assets/private/handlers/index.d.ts +3 -0
- package/cdk-assets/private/handlers/index.js +18 -0
- package/cdk-assets/publishing.d.ts +113 -0
- package/cdk-assets/publishing.js +194 -0
- package/cli/commands/dev.js +25 -1
- package/constructs/App.d.ts +1 -1
- package/constructs/App.js +1 -1
- package/constructs/Function.d.ts +5 -0
- package/constructs/Function.js +44 -11
- package/constructs/NextjsSite.js +3 -6
- package/constructs/SsrSite.d.ts +3 -2
- package/constructs/SsrSite.js +12 -8
- package/package.json +1 -1
- package/runtime/handlers/container.d.ts +1 -0
- package/runtime/handlers/container.js +124 -0
- package/runtime/handlers/node.js +1 -1
- package/runtime/handlers/python.js +1 -0
- package/runtime/handlers.d.ts +4 -0
- package/runtime/handlers.js +1 -0
- package/runtime/workers.js +1 -0
- package/sst.mjs +1220 -319
- package/stacks/synth.js +2 -0
- package/support/bridge/Dockerfile +3 -0
package/sst.mjs
CHANGED
|
@@ -292,10 +292,10 @@ async function load(input, shallow) {
|
|
|
292
292
|
plugins: [ts]
|
|
293
293
|
});
|
|
294
294
|
babel.traverse(ast, {
|
|
295
|
-
ObjectMethod(
|
|
296
|
-
const { key } =
|
|
295
|
+
ObjectMethod(path22) {
|
|
296
|
+
const { key } = path22.node;
|
|
297
297
|
if ("name" in key && key.name === "stacks") {
|
|
298
|
-
|
|
298
|
+
path22.remove();
|
|
299
299
|
}
|
|
300
300
|
}
|
|
301
301
|
});
|
|
@@ -471,7 +471,7 @@ async function promptPersonalStage(out, isRetry) {
|
|
|
471
471
|
input: process.stdin,
|
|
472
472
|
output: process.stdout
|
|
473
473
|
});
|
|
474
|
-
const stage = await new Promise((
|
|
474
|
+
const stage = await new Promise((resolve2) => {
|
|
475
475
|
const suggested = sanitizeStageName(os.userInfo().username) || "local";
|
|
476
476
|
const instruction = !isRetry ? `Please enter a name you\u2019d like to use for your personal stage.` : `Please enter a name that starts with a letter, followed by letters, numbers, or hyphens.`;
|
|
477
477
|
rl.question(
|
|
@@ -479,7 +479,7 @@ async function promptPersonalStage(out, isRetry) {
|
|
|
479
479
|
async (input) => {
|
|
480
480
|
rl.close();
|
|
481
481
|
const result = input === "" ? suggested : input;
|
|
482
|
-
|
|
482
|
+
resolve2(result);
|
|
483
483
|
}
|
|
484
484
|
);
|
|
485
485
|
});
|
|
@@ -541,7 +541,7 @@ var init_project = __esm({
|
|
|
541
541
|
// src/cli/telemetry/post-payload.ts
|
|
542
542
|
import https from "https";
|
|
543
543
|
function postPayload(endpoint, body) {
|
|
544
|
-
return new Promise((
|
|
544
|
+
return new Promise((resolve2, reject) => {
|
|
545
545
|
try {
|
|
546
546
|
const req = https.request(
|
|
547
547
|
endpoint,
|
|
@@ -555,7 +555,7 @@ function postPayload(endpoint, body) {
|
|
|
555
555
|
reject(new Error(`Unexpected status code: ${resp.statusCode}`));
|
|
556
556
|
return;
|
|
557
557
|
}
|
|
558
|
-
|
|
558
|
+
resolve2();
|
|
559
559
|
}
|
|
560
560
|
);
|
|
561
561
|
req.write(JSON.stringify(body));
|
|
@@ -981,11 +981,11 @@ function __metadata(metadataKey, metadataValue) {
|
|
|
981
981
|
}
|
|
982
982
|
function __awaiter(thisArg, _arguments, P, generator2) {
|
|
983
983
|
function adopt(value) {
|
|
984
|
-
return value instanceof P ? value : new P(function(
|
|
985
|
-
|
|
984
|
+
return value instanceof P ? value : new P(function(resolve2) {
|
|
985
|
+
resolve2(value);
|
|
986
986
|
});
|
|
987
987
|
}
|
|
988
|
-
return new (P || (P = Promise))(function(
|
|
988
|
+
return new (P || (P = Promise))(function(resolve2, reject) {
|
|
989
989
|
function fulfilled(value) {
|
|
990
990
|
try {
|
|
991
991
|
step(generator2.next(value));
|
|
@@ -1001,7 +1001,7 @@ function __awaiter(thisArg, _arguments, P, generator2) {
|
|
|
1001
1001
|
}
|
|
1002
1002
|
}
|
|
1003
1003
|
function step(result) {
|
|
1004
|
-
result.done ?
|
|
1004
|
+
result.done ? resolve2(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
1005
1005
|
}
|
|
1006
1006
|
step((generator2 = generator2.apply(thisArg, _arguments || [])).next());
|
|
1007
1007
|
});
|
|
@@ -1109,8 +1109,8 @@ function __read(o, n) {
|
|
|
1109
1109
|
try {
|
|
1110
1110
|
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
|
|
1111
1111
|
ar.push(r.value);
|
|
1112
|
-
} catch (
|
|
1113
|
-
e = { error:
|
|
1112
|
+
} catch (error3) {
|
|
1113
|
+
e = { error: error3 };
|
|
1114
1114
|
} finally {
|
|
1115
1115
|
try {
|
|
1116
1116
|
if (r && !r.done && (m = i["return"]))
|
|
@@ -1207,14 +1207,14 @@ function __asyncValues(o) {
|
|
|
1207
1207
|
}, i);
|
|
1208
1208
|
function verb(n) {
|
|
1209
1209
|
i[n] = o[n] && function(v) {
|
|
1210
|
-
return new Promise(function(
|
|
1211
|
-
v = o[n](v), settle(
|
|
1210
|
+
return new Promise(function(resolve2, reject) {
|
|
1211
|
+
v = o[n](v), settle(resolve2, reject, v.done, v.value);
|
|
1212
1212
|
});
|
|
1213
1213
|
};
|
|
1214
1214
|
}
|
|
1215
|
-
function settle(
|
|
1215
|
+
function settle(resolve2, reject, d, v) {
|
|
1216
1216
|
Promise.resolve(v).then(function(v2) {
|
|
1217
|
-
|
|
1217
|
+
resolve2({ value: v2, done: d });
|
|
1218
1218
|
}, reject);
|
|
1219
1219
|
}
|
|
1220
1220
|
}
|
|
@@ -1714,11 +1714,11 @@ var init_credentials = __esm({
|
|
|
1714
1714
|
input: process.stdin,
|
|
1715
1715
|
output: process.stdout
|
|
1716
1716
|
});
|
|
1717
|
-
return new Promise((
|
|
1717
|
+
return new Promise((resolve2) => {
|
|
1718
1718
|
Logger.debug(`Require MFA token for serial ARN ${serialArn}`);
|
|
1719
1719
|
const prompt = () => rl.question(`Enter MFA code for ${serialArn}: `, async (input) => {
|
|
1720
1720
|
if (input.trim() !== "") {
|
|
1721
|
-
|
|
1721
|
+
resolve2(input.trim());
|
|
1722
1722
|
rl.close();
|
|
1723
1723
|
} else {
|
|
1724
1724
|
prompt();
|
|
@@ -2084,7 +2084,7 @@ async function monitor(stack) {
|
|
|
2084
2084
|
}
|
|
2085
2085
|
throw ex;
|
|
2086
2086
|
}
|
|
2087
|
-
await new Promise((
|
|
2087
|
+
await new Promise((resolve2) => setTimeout(resolve2, 1e3));
|
|
2088
2088
|
}
|
|
2089
2089
|
}
|
|
2090
2090
|
function filterOutputs(input) {
|
|
@@ -2136,6 +2136,750 @@ var init_monitor = __esm({
|
|
|
2136
2136
|
}
|
|
2137
2137
|
});
|
|
2138
2138
|
|
|
2139
|
+
// src/cdk-assets/private/docker.ts
|
|
2140
|
+
import * as fs5 from "fs";
|
|
2141
|
+
import * as os3 from "os";
|
|
2142
|
+
import * as path5 from "path";
|
|
2143
|
+
import {
|
|
2144
|
+
cdkCredentialsConfig,
|
|
2145
|
+
obtainEcrCredentials
|
|
2146
|
+
} from "cdk-assets/lib/private/docker-credentials.js";
|
|
2147
|
+
import {
|
|
2148
|
+
shell
|
|
2149
|
+
} from "cdk-assets/lib/private/shell.js";
|
|
2150
|
+
import { createCriticalSection } from "cdk-assets/lib/private/util.js";
|
|
2151
|
+
function getDockerCmd() {
|
|
2152
|
+
return process.env.CDK_DOCKER ?? "docker";
|
|
2153
|
+
}
|
|
2154
|
+
function flatten(x) {
|
|
2155
|
+
return Array.prototype.concat([], ...x);
|
|
2156
|
+
}
|
|
2157
|
+
var Docker, DockerFactory;
|
|
2158
|
+
var init_docker = __esm({
|
|
2159
|
+
"src/cdk-assets/private/docker.ts"() {
|
|
2160
|
+
"use strict";
|
|
2161
|
+
Docker = class {
|
|
2162
|
+
constructor(logger) {
|
|
2163
|
+
this.logger = logger;
|
|
2164
|
+
}
|
|
2165
|
+
configDir = void 0;
|
|
2166
|
+
async exists(tag) {
|
|
2167
|
+
try {
|
|
2168
|
+
await this.execute(["inspect", tag], { quiet: true });
|
|
2169
|
+
return true;
|
|
2170
|
+
} catch (e) {
|
|
2171
|
+
const error3 = e;
|
|
2172
|
+
if (error3.code !== "PROCESS_FAILED") {
|
|
2173
|
+
throw error3;
|
|
2174
|
+
}
|
|
2175
|
+
switch (error3.exitCode) {
|
|
2176
|
+
case 1 /* Docker */:
|
|
2177
|
+
case 125 /* Podman */:
|
|
2178
|
+
return false;
|
|
2179
|
+
default:
|
|
2180
|
+
throw error3;
|
|
2181
|
+
}
|
|
2182
|
+
}
|
|
2183
|
+
}
|
|
2184
|
+
async build(options) {
|
|
2185
|
+
const buildCommand = [
|
|
2186
|
+
"build",
|
|
2187
|
+
...flatten(
|
|
2188
|
+
Object.entries(options.buildArgs || {}).map(([k, v]) => [
|
|
2189
|
+
"--build-arg",
|
|
2190
|
+
`${k}=${v}`
|
|
2191
|
+
])
|
|
2192
|
+
),
|
|
2193
|
+
...flatten(
|
|
2194
|
+
Object.entries(options.buildSecrets || {}).map(([k, v]) => [
|
|
2195
|
+
"--secret",
|
|
2196
|
+
`id=${k},${v}`
|
|
2197
|
+
])
|
|
2198
|
+
),
|
|
2199
|
+
"--tag",
|
|
2200
|
+
options.tag,
|
|
2201
|
+
...options.target ? ["--target", options.target] : [],
|
|
2202
|
+
...options.file ? ["--file", options.file] : [],
|
|
2203
|
+
...options.networkMode ? ["--network", options.networkMode] : [],
|
|
2204
|
+
...options.platform ? ["--platform", options.platform] : [],
|
|
2205
|
+
...options.outputs ? options.outputs.map((output) => [`--output=${output}`]) : [],
|
|
2206
|
+
...options.cacheFrom ? [
|
|
2207
|
+
...options.cacheFrom.map((cacheFrom) => [
|
|
2208
|
+
"--cache-from",
|
|
2209
|
+
this.cacheOptionToFlag(cacheFrom)
|
|
2210
|
+
]).flat()
|
|
2211
|
+
] : [],
|
|
2212
|
+
...options.cacheTo ? ["--cache-to", this.cacheOptionToFlag(options.cacheTo)] : [],
|
|
2213
|
+
"."
|
|
2214
|
+
];
|
|
2215
|
+
await this.execute(buildCommand, {
|
|
2216
|
+
cwd: options.directory,
|
|
2217
|
+
quiet: options.quiet
|
|
2218
|
+
});
|
|
2219
|
+
}
|
|
2220
|
+
async login(ecr) {
|
|
2221
|
+
const credentials = await obtainEcrCredentials(ecr);
|
|
2222
|
+
await this.execute(
|
|
2223
|
+
[
|
|
2224
|
+
"login",
|
|
2225
|
+
"--username",
|
|
2226
|
+
credentials.username,
|
|
2227
|
+
"--password-stdin",
|
|
2228
|
+
credentials.endpoint
|
|
2229
|
+
],
|
|
2230
|
+
{
|
|
2231
|
+
input: credentials.password,
|
|
2232
|
+
quiet: true
|
|
2233
|
+
}
|
|
2234
|
+
);
|
|
2235
|
+
}
|
|
2236
|
+
async tag(sourceTag, targetTag) {
|
|
2237
|
+
await this.execute(["tag", sourceTag, targetTag]);
|
|
2238
|
+
}
|
|
2239
|
+
async push(options) {
|
|
2240
|
+
await this.execute(["push", options.tag], { quiet: options.quiet });
|
|
2241
|
+
}
|
|
2242
|
+
configureCdkCredentials() {
|
|
2243
|
+
const config = cdkCredentialsConfig();
|
|
2244
|
+
if (!config) {
|
|
2245
|
+
return false;
|
|
2246
|
+
}
|
|
2247
|
+
this.configDir = fs5.mkdtempSync(path5.join(os3.tmpdir(), "cdkDockerConfig"));
|
|
2248
|
+
const domains = Object.keys(config.domainCredentials);
|
|
2249
|
+
const credHelpers = domains.reduce(
|
|
2250
|
+
(map3, domain) => {
|
|
2251
|
+
map3[domain] = "cdk-assets";
|
|
2252
|
+
return map3;
|
|
2253
|
+
},
|
|
2254
|
+
{}
|
|
2255
|
+
);
|
|
2256
|
+
fs5.writeFileSync(
|
|
2257
|
+
path5.join(this.configDir, "config.json"),
|
|
2258
|
+
JSON.stringify({ credHelpers }),
|
|
2259
|
+
{ encoding: "utf-8" }
|
|
2260
|
+
);
|
|
2261
|
+
return true;
|
|
2262
|
+
}
|
|
2263
|
+
resetAuthPlugins() {
|
|
2264
|
+
this.configDir = void 0;
|
|
2265
|
+
}
|
|
2266
|
+
async execute(args, options = {}) {
|
|
2267
|
+
const configArgs = this.configDir ? ["--config", this.configDir] : [];
|
|
2268
|
+
const pathToCdkAssets = "";
|
|
2269
|
+
try {
|
|
2270
|
+
await shell([getDockerCmd(), ...configArgs, ...args], {
|
|
2271
|
+
logger: this.logger,
|
|
2272
|
+
...options,
|
|
2273
|
+
env: {
|
|
2274
|
+
...process.env,
|
|
2275
|
+
...options.env,
|
|
2276
|
+
PATH: `${pathToCdkAssets}${path5.delimiter}${options.env?.PATH ?? process.env.PATH}`
|
|
2277
|
+
}
|
|
2278
|
+
});
|
|
2279
|
+
} catch (e) {
|
|
2280
|
+
if (e.code === "ENOENT") {
|
|
2281
|
+
throw new Error(
|
|
2282
|
+
"Unable to execute 'docker' in order to build a container asset. Please install 'docker' and try again."
|
|
2283
|
+
);
|
|
2284
|
+
}
|
|
2285
|
+
throw e;
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
cacheOptionToFlag(option) {
|
|
2289
|
+
let flag = `type=${option.type}`;
|
|
2290
|
+
if (option.params) {
|
|
2291
|
+
flag += "," + Object.entries(option.params).map(([k, v]) => `${k}=${v}`).join(",");
|
|
2292
|
+
}
|
|
2293
|
+
return flag;
|
|
2294
|
+
}
|
|
2295
|
+
};
|
|
2296
|
+
DockerFactory = class {
|
|
2297
|
+
enterLoggedInDestinationsCriticalSection = createCriticalSection();
|
|
2298
|
+
loggedInDestinations = /* @__PURE__ */ new Set();
|
|
2299
|
+
async forBuild(options) {
|
|
2300
|
+
const docker = new Docker(options.logger);
|
|
2301
|
+
let cdkDockerCredentialsConfigured = docker.configureCdkCredentials();
|
|
2302
|
+
if (!cdkDockerCredentialsConfigured) {
|
|
2303
|
+
await this.loginOncePerDestination(docker, options);
|
|
2304
|
+
}
|
|
2305
|
+
return docker;
|
|
2306
|
+
}
|
|
2307
|
+
async forEcrPush(options) {
|
|
2308
|
+
const docker = new Docker(options.logger);
|
|
2309
|
+
await this.loginOncePerDestination(docker, options);
|
|
2310
|
+
return docker;
|
|
2311
|
+
}
|
|
2312
|
+
async loginOncePerDestination(docker, options) {
|
|
2313
|
+
const repositoryDomain = options.repoUri.split("/")[0];
|
|
2314
|
+
await this.enterLoggedInDestinationsCriticalSection(async () => {
|
|
2315
|
+
if (this.loggedInDestinations.has(repositoryDomain)) {
|
|
2316
|
+
return;
|
|
2317
|
+
}
|
|
2318
|
+
await docker.login(options.ecr);
|
|
2319
|
+
this.loggedInDestinations.add(repositoryDomain);
|
|
2320
|
+
});
|
|
2321
|
+
}
|
|
2322
|
+
};
|
|
2323
|
+
}
|
|
2324
|
+
});
|
|
2325
|
+
|
|
2326
|
+
// src/cdk-assets/private/handlers/container-images.ts
|
|
2327
|
+
import * as path6 from "path";
|
|
2328
|
+
import { EventType } from "cdk-assets/lib/progress.js";
|
|
2329
|
+
import { replaceAwsPlaceholders } from "cdk-assets/lib/private/placeholders.js";
|
|
2330
|
+
import { shell as shell2 } from "cdk-assets/lib/private/shell.js";
|
|
2331
|
+
async function imageExists(ecr, repositoryName, imageTag) {
|
|
2332
|
+
try {
|
|
2333
|
+
await ecr.describeImages({ repositoryName, imageIds: [{ imageTag }] }).promise();
|
|
2334
|
+
return true;
|
|
2335
|
+
} catch (e) {
|
|
2336
|
+
if (e.code !== "ImageNotFoundException") {
|
|
2337
|
+
throw e;
|
|
2338
|
+
}
|
|
2339
|
+
return false;
|
|
2340
|
+
}
|
|
2341
|
+
}
|
|
2342
|
+
async function repositoryUri(ecr, repositoryName) {
|
|
2343
|
+
try {
|
|
2344
|
+
const response = await ecr.describeRepositories({ repositoryNames: [repositoryName] }).promise();
|
|
2345
|
+
return (response.repositories || [])[0]?.repositoryUri;
|
|
2346
|
+
} catch (e) {
|
|
2347
|
+
if (e.code !== "RepositoryNotFoundException") {
|
|
2348
|
+
throw e;
|
|
2349
|
+
}
|
|
2350
|
+
return void 0;
|
|
2351
|
+
}
|
|
2352
|
+
}
|
|
2353
|
+
var ContainerImageAssetHandler, ContainerImageBuilder;
|
|
2354
|
+
var init_container_images = __esm({
|
|
2355
|
+
"src/cdk-assets/private/handlers/container-images.ts"() {
|
|
2356
|
+
"use strict";
|
|
2357
|
+
ContainerImageAssetHandler = class {
|
|
2358
|
+
constructor(workDir, asset, host, options) {
|
|
2359
|
+
this.workDir = workDir;
|
|
2360
|
+
this.asset = asset;
|
|
2361
|
+
this.host = host;
|
|
2362
|
+
this.options = options;
|
|
2363
|
+
}
|
|
2364
|
+
init;
|
|
2365
|
+
async build() {
|
|
2366
|
+
const initOnce = await this.initOnce();
|
|
2367
|
+
if (initOnce.destinationAlreadyExists) {
|
|
2368
|
+
return;
|
|
2369
|
+
}
|
|
2370
|
+
if (this.host.aborted) {
|
|
2371
|
+
return;
|
|
2372
|
+
}
|
|
2373
|
+
const dockerForBuilding = await this.host.dockerFactory.forBuild({
|
|
2374
|
+
repoUri: initOnce.repoUri,
|
|
2375
|
+
logger: (m) => this.host.emitMessage(EventType.DEBUG, m),
|
|
2376
|
+
ecr: initOnce.ecr
|
|
2377
|
+
});
|
|
2378
|
+
const builder = new ContainerImageBuilder(
|
|
2379
|
+
dockerForBuilding,
|
|
2380
|
+
this.workDir,
|
|
2381
|
+
this.asset,
|
|
2382
|
+
this.host,
|
|
2383
|
+
{
|
|
2384
|
+
quiet: this.options.quiet
|
|
2385
|
+
}
|
|
2386
|
+
);
|
|
2387
|
+
const localTagName = await builder.build();
|
|
2388
|
+
if (localTagName === void 0 || this.host.aborted) {
|
|
2389
|
+
return;
|
|
2390
|
+
}
|
|
2391
|
+
if (this.host.aborted) {
|
|
2392
|
+
return;
|
|
2393
|
+
}
|
|
2394
|
+
await dockerForBuilding.tag(localTagName, initOnce.imageUri);
|
|
2395
|
+
}
|
|
2396
|
+
async isPublished() {
|
|
2397
|
+
try {
|
|
2398
|
+
const initOnce = await this.initOnce({ quiet: true });
|
|
2399
|
+
return initOnce.destinationAlreadyExists;
|
|
2400
|
+
} catch (e) {
|
|
2401
|
+
this.host.emitMessage(EventType.DEBUG, `${e.message}`);
|
|
2402
|
+
}
|
|
2403
|
+
return false;
|
|
2404
|
+
}
|
|
2405
|
+
async publish() {
|
|
2406
|
+
const initOnce = await this.initOnce();
|
|
2407
|
+
if (initOnce.destinationAlreadyExists) {
|
|
2408
|
+
return;
|
|
2409
|
+
}
|
|
2410
|
+
if (this.host.aborted) {
|
|
2411
|
+
return;
|
|
2412
|
+
}
|
|
2413
|
+
const dockerForPushing = await this.host.dockerFactory.forEcrPush({
|
|
2414
|
+
repoUri: initOnce.repoUri,
|
|
2415
|
+
logger: (m) => this.host.emitMessage(EventType.DEBUG, m),
|
|
2416
|
+
ecr: initOnce.ecr
|
|
2417
|
+
});
|
|
2418
|
+
if (this.host.aborted) {
|
|
2419
|
+
return;
|
|
2420
|
+
}
|
|
2421
|
+
this.host.emitMessage(EventType.UPLOAD, `Push ${initOnce.imageUri}`);
|
|
2422
|
+
await dockerForPushing.push({
|
|
2423
|
+
tag: initOnce.imageUri,
|
|
2424
|
+
quiet: this.options.quiet
|
|
2425
|
+
});
|
|
2426
|
+
}
|
|
2427
|
+
async initOnce(options = {}) {
|
|
2428
|
+
if (this.init) {
|
|
2429
|
+
return this.init;
|
|
2430
|
+
}
|
|
2431
|
+
const destination = await replaceAwsPlaceholders(
|
|
2432
|
+
this.asset.destination,
|
|
2433
|
+
this.host.aws
|
|
2434
|
+
);
|
|
2435
|
+
const ecr = await this.host.aws.ecrClient({
|
|
2436
|
+
...destination,
|
|
2437
|
+
quiet: options.quiet
|
|
2438
|
+
});
|
|
2439
|
+
const account = async () => (await this.host.aws.discoverCurrentAccount())?.accountId;
|
|
2440
|
+
const repoUri = await repositoryUri(ecr, destination.repositoryName);
|
|
2441
|
+
if (!repoUri) {
|
|
2442
|
+
throw new Error(
|
|
2443
|
+
`No ECR repository named '${destination.repositoryName}' in account ${await account()}. Is this account bootstrapped?`
|
|
2444
|
+
);
|
|
2445
|
+
}
|
|
2446
|
+
const imageUri = `${repoUri}:${destination.imageTag}`;
|
|
2447
|
+
this.init = {
|
|
2448
|
+
imageUri,
|
|
2449
|
+
ecr,
|
|
2450
|
+
repoUri,
|
|
2451
|
+
destinationAlreadyExists: await this.destinationAlreadyExists(
|
|
2452
|
+
ecr,
|
|
2453
|
+
destination,
|
|
2454
|
+
imageUri
|
|
2455
|
+
)
|
|
2456
|
+
};
|
|
2457
|
+
return this.init;
|
|
2458
|
+
}
|
|
2459
|
+
async destinationAlreadyExists(ecr, destination, imageUri) {
|
|
2460
|
+
this.host.emitMessage(EventType.CHECK, `Check ${imageUri}`);
|
|
2461
|
+
if (await imageExists(ecr, destination.repositoryName, destination.imageTag)) {
|
|
2462
|
+
this.host.emitMessage(EventType.FOUND, `Found ${imageUri}`);
|
|
2463
|
+
return true;
|
|
2464
|
+
}
|
|
2465
|
+
return false;
|
|
2466
|
+
}
|
|
2467
|
+
};
|
|
2468
|
+
ContainerImageBuilder = class {
|
|
2469
|
+
constructor(docker, workDir, asset, host, options) {
|
|
2470
|
+
this.docker = docker;
|
|
2471
|
+
this.workDir = workDir;
|
|
2472
|
+
this.asset = asset;
|
|
2473
|
+
this.host = host;
|
|
2474
|
+
this.options = options;
|
|
2475
|
+
}
|
|
2476
|
+
async build() {
|
|
2477
|
+
return this.asset.source.executable ? this.buildExternalAsset(this.asset.source.executable) : this.buildDirectoryAsset();
|
|
2478
|
+
}
|
|
2479
|
+
async buildDirectoryAsset() {
|
|
2480
|
+
const localTagName = `cdkasset-${this.asset.id.assetId.toLowerCase()}`;
|
|
2481
|
+
if (!await this.isImageCached(localTagName)) {
|
|
2482
|
+
if (this.host.aborted) {
|
|
2483
|
+
return void 0;
|
|
2484
|
+
}
|
|
2485
|
+
await this.buildImage(localTagName);
|
|
2486
|
+
}
|
|
2487
|
+
return localTagName;
|
|
2488
|
+
}
|
|
2489
|
+
async buildExternalAsset(executable, cwd) {
|
|
2490
|
+
const assetPath = cwd ?? this.workDir;
|
|
2491
|
+
this.host.emitMessage(
|
|
2492
|
+
EventType.BUILD,
|
|
2493
|
+
`Building Docker image using command '${executable}'`
|
|
2494
|
+
);
|
|
2495
|
+
if (this.host.aborted) {
|
|
2496
|
+
return void 0;
|
|
2497
|
+
}
|
|
2498
|
+
return (await shell2(executable, { cwd: assetPath, quiet: true })).trim();
|
|
2499
|
+
}
|
|
2500
|
+
async buildImage(localTagName) {
|
|
2501
|
+
const source = this.asset.source;
|
|
2502
|
+
if (!source.directory) {
|
|
2503
|
+
throw new Error(
|
|
2504
|
+
`'directory' is expected in the DockerImage asset source, got: ${JSON.stringify(
|
|
2505
|
+
source
|
|
2506
|
+
)}`
|
|
2507
|
+
);
|
|
2508
|
+
}
|
|
2509
|
+
const fullPath = path6.resolve(this.workDir, source.directory);
|
|
2510
|
+
this.host.emitMessage(
|
|
2511
|
+
EventType.BUILD,
|
|
2512
|
+
`Building Docker image at ${fullPath}`
|
|
2513
|
+
);
|
|
2514
|
+
await this.docker.build({
|
|
2515
|
+
directory: fullPath,
|
|
2516
|
+
tag: localTagName,
|
|
2517
|
+
buildArgs: source.dockerBuildArgs,
|
|
2518
|
+
buildSecrets: source.dockerBuildSecrets,
|
|
2519
|
+
target: source.dockerBuildTarget,
|
|
2520
|
+
file: source.dockerFile,
|
|
2521
|
+
networkMode: source.networkMode,
|
|
2522
|
+
platform: source.platform,
|
|
2523
|
+
outputs: source.dockerOutputs,
|
|
2524
|
+
cacheFrom: source.cacheFrom,
|
|
2525
|
+
cacheTo: source.cacheTo,
|
|
2526
|
+
quiet: this.options.quiet
|
|
2527
|
+
});
|
|
2528
|
+
}
|
|
2529
|
+
async isImageCached(localTagName) {
|
|
2530
|
+
if (await this.docker.exists(localTagName)) {
|
|
2531
|
+
this.host.emitMessage(EventType.CACHED, `Cached ${localTagName}`);
|
|
2532
|
+
return true;
|
|
2533
|
+
}
|
|
2534
|
+
return false;
|
|
2535
|
+
}
|
|
2536
|
+
};
|
|
2537
|
+
}
|
|
2538
|
+
});
|
|
2539
|
+
|
|
2540
|
+
// src/cdk-assets/private/handlers/index.ts
|
|
2541
|
+
import { FileAssetHandler } from "cdk-assets/lib/private/handlers/files.js";
|
|
2542
|
+
import {
|
|
2543
|
+
DockerImageManifestEntry,
|
|
2544
|
+
FileManifestEntry
|
|
2545
|
+
} from "cdk-assets/lib/asset-manifest.js";
|
|
2546
|
+
function makeAssetHandler(manifest, asset, host, options) {
|
|
2547
|
+
if (asset instanceof FileManifestEntry) {
|
|
2548
|
+
return new FileAssetHandler(manifest.directory, asset, host);
|
|
2549
|
+
}
|
|
2550
|
+
if (asset instanceof DockerImageManifestEntry) {
|
|
2551
|
+
return new ContainerImageAssetHandler(
|
|
2552
|
+
manifest.directory,
|
|
2553
|
+
asset,
|
|
2554
|
+
host,
|
|
2555
|
+
options
|
|
2556
|
+
);
|
|
2557
|
+
}
|
|
2558
|
+
throw new Error(`Unrecognized asset type: '${asset}'`);
|
|
2559
|
+
}
|
|
2560
|
+
var init_handlers = __esm({
|
|
2561
|
+
"src/cdk-assets/private/handlers/index.ts"() {
|
|
2562
|
+
"use strict";
|
|
2563
|
+
init_container_images();
|
|
2564
|
+
}
|
|
2565
|
+
});
|
|
2566
|
+
|
|
2567
|
+
// src/cdk-assets/publishing.ts
|
|
2568
|
+
import {
|
|
2569
|
+
EventType as EventType2
|
|
2570
|
+
} from "cdk-assets/lib/progress.js";
|
|
2571
|
+
var AssetPublishing;
|
|
2572
|
+
var init_publishing = __esm({
|
|
2573
|
+
"src/cdk-assets/publishing.ts"() {
|
|
2574
|
+
"use strict";
|
|
2575
|
+
init_docker();
|
|
2576
|
+
init_handlers();
|
|
2577
|
+
AssetPublishing = class {
|
|
2578
|
+
constructor(manifest, options) {
|
|
2579
|
+
this.manifest = manifest;
|
|
2580
|
+
this.options = options;
|
|
2581
|
+
this.assets = manifest.entries;
|
|
2582
|
+
this.totalOperations = this.assets.length;
|
|
2583
|
+
this.publishInParallel = options.publishInParallel ?? false;
|
|
2584
|
+
this.buildAssets = options.buildAssets ?? true;
|
|
2585
|
+
this.publishAssets = options.publishAssets ?? true;
|
|
2586
|
+
const self = this;
|
|
2587
|
+
this.handlerHost = {
|
|
2588
|
+
aws: this.options.aws,
|
|
2589
|
+
get aborted() {
|
|
2590
|
+
return self.aborted;
|
|
2591
|
+
},
|
|
2592
|
+
emitMessage(t, m) {
|
|
2593
|
+
self.progressEvent(t, m);
|
|
2594
|
+
},
|
|
2595
|
+
dockerFactory: new DockerFactory()
|
|
2596
|
+
};
|
|
2597
|
+
}
|
|
2598
|
+
message = "Starting";
|
|
2599
|
+
currentAsset;
|
|
2600
|
+
failures = new Array();
|
|
2601
|
+
assets;
|
|
2602
|
+
totalOperations;
|
|
2603
|
+
completedOperations = 0;
|
|
2604
|
+
aborted = false;
|
|
2605
|
+
handlerHost;
|
|
2606
|
+
publishInParallel;
|
|
2607
|
+
buildAssets;
|
|
2608
|
+
publishAssets;
|
|
2609
|
+
handlerCache = /* @__PURE__ */ new Map();
|
|
2610
|
+
async publish() {
|
|
2611
|
+
if (this.publishInParallel) {
|
|
2612
|
+
await Promise.all(
|
|
2613
|
+
this.assets.map(async (asset) => this.publishAsset(asset))
|
|
2614
|
+
);
|
|
2615
|
+
} else {
|
|
2616
|
+
for (const asset of this.assets) {
|
|
2617
|
+
if (!await this.publishAsset(asset)) {
|
|
2618
|
+
break;
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2621
|
+
}
|
|
2622
|
+
if ((this.options.throwOnError ?? true) && this.failures.length > 0) {
|
|
2623
|
+
throw new Error(
|
|
2624
|
+
`Error publishing: ${this.failures.map((e) => e.error.message)}`
|
|
2625
|
+
);
|
|
2626
|
+
}
|
|
2627
|
+
}
|
|
2628
|
+
async buildEntry(asset) {
|
|
2629
|
+
try {
|
|
2630
|
+
if (this.progressEvent(EventType2.START, `Building ${asset.id}`)) {
|
|
2631
|
+
return false;
|
|
2632
|
+
}
|
|
2633
|
+
const handler = this.assetHandler(asset);
|
|
2634
|
+
await handler.build();
|
|
2635
|
+
if (this.aborted) {
|
|
2636
|
+
throw new Error("Aborted");
|
|
2637
|
+
}
|
|
2638
|
+
this.completedOperations++;
|
|
2639
|
+
if (this.progressEvent(EventType2.SUCCESS, `Built ${asset.id}`)) {
|
|
2640
|
+
return false;
|
|
2641
|
+
}
|
|
2642
|
+
} catch (e) {
|
|
2643
|
+
this.failures.push({ asset, error: e });
|
|
2644
|
+
this.completedOperations++;
|
|
2645
|
+
if (this.progressEvent(EventType2.FAIL, e.message)) {
|
|
2646
|
+
return false;
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
return true;
|
|
2650
|
+
}
|
|
2651
|
+
async publishEntry(asset) {
|
|
2652
|
+
try {
|
|
2653
|
+
if (this.progressEvent(EventType2.START, `Publishing ${asset.id}`)) {
|
|
2654
|
+
return false;
|
|
2655
|
+
}
|
|
2656
|
+
const handler = this.assetHandler(asset);
|
|
2657
|
+
await handler.publish();
|
|
2658
|
+
if (this.aborted) {
|
|
2659
|
+
throw new Error("Aborted");
|
|
2660
|
+
}
|
|
2661
|
+
this.completedOperations++;
|
|
2662
|
+
if (this.progressEvent(EventType2.SUCCESS, `Published ${asset.id}`)) {
|
|
2663
|
+
return false;
|
|
2664
|
+
}
|
|
2665
|
+
} catch (e) {
|
|
2666
|
+
this.failures.push({ asset, error: e });
|
|
2667
|
+
this.completedOperations++;
|
|
2668
|
+
if (this.progressEvent(EventType2.FAIL, e.message)) {
|
|
2669
|
+
return false;
|
|
2670
|
+
}
|
|
2671
|
+
}
|
|
2672
|
+
return true;
|
|
2673
|
+
}
|
|
2674
|
+
isEntryPublished(asset) {
|
|
2675
|
+
const handler = this.assetHandler(asset);
|
|
2676
|
+
return handler.isPublished();
|
|
2677
|
+
}
|
|
2678
|
+
async publishAsset(asset) {
|
|
2679
|
+
try {
|
|
2680
|
+
if (this.progressEvent(EventType2.START, `Publishing ${asset.id}`)) {
|
|
2681
|
+
return false;
|
|
2682
|
+
}
|
|
2683
|
+
const handler = this.assetHandler(asset);
|
|
2684
|
+
if (this.buildAssets) {
|
|
2685
|
+
await handler.build();
|
|
2686
|
+
}
|
|
2687
|
+
if (this.publishAssets) {
|
|
2688
|
+
await handler.publish();
|
|
2689
|
+
}
|
|
2690
|
+
if (this.aborted) {
|
|
2691
|
+
throw new Error("Aborted");
|
|
2692
|
+
}
|
|
2693
|
+
this.completedOperations++;
|
|
2694
|
+
if (this.progressEvent(EventType2.SUCCESS, `Published ${asset.id}`)) {
|
|
2695
|
+
return false;
|
|
2696
|
+
}
|
|
2697
|
+
} catch (e) {
|
|
2698
|
+
this.failures.push({ asset, error: e });
|
|
2699
|
+
this.completedOperations++;
|
|
2700
|
+
if (this.progressEvent(EventType2.FAIL, e.message)) {
|
|
2701
|
+
return false;
|
|
2702
|
+
}
|
|
2703
|
+
}
|
|
2704
|
+
return true;
|
|
2705
|
+
}
|
|
2706
|
+
get percentComplete() {
|
|
2707
|
+
if (this.totalOperations === 0) {
|
|
2708
|
+
return 100;
|
|
2709
|
+
}
|
|
2710
|
+
return Math.floor(this.completedOperations / this.totalOperations * 100);
|
|
2711
|
+
}
|
|
2712
|
+
abort() {
|
|
2713
|
+
this.aborted = true;
|
|
2714
|
+
}
|
|
2715
|
+
get hasFailures() {
|
|
2716
|
+
return this.failures.length > 0;
|
|
2717
|
+
}
|
|
2718
|
+
progressEvent(event, message) {
|
|
2719
|
+
this.message = message;
|
|
2720
|
+
if (this.options.progressListener) {
|
|
2721
|
+
this.options.progressListener.onPublishEvent(event, this);
|
|
2722
|
+
}
|
|
2723
|
+
return this.aborted;
|
|
2724
|
+
}
|
|
2725
|
+
assetHandler(asset) {
|
|
2726
|
+
const existing = this.handlerCache.get(asset);
|
|
2727
|
+
if (existing) {
|
|
2728
|
+
return existing;
|
|
2729
|
+
}
|
|
2730
|
+
const ret = makeAssetHandler(this.manifest, asset, this.handlerHost, {
|
|
2731
|
+
quiet: this.options.quiet
|
|
2732
|
+
});
|
|
2733
|
+
this.handlerCache.set(asset, ret);
|
|
2734
|
+
return ret;
|
|
2735
|
+
}
|
|
2736
|
+
};
|
|
2737
|
+
}
|
|
2738
|
+
});
|
|
2739
|
+
|
|
2740
|
+
// src/cdk/asset-publishing.ts
|
|
2741
|
+
import * as cxapi from "@aws-cdk/cx-api";
|
|
2742
|
+
import * as cdk_assets from "cdk-assets";
|
|
2743
|
+
import { Mode } from "sst-aws-cdk/lib/api/aws-auth/credentials.js";
|
|
2744
|
+
import { debug, error, print } from "sst-aws-cdk/lib/logging.js";
|
|
2745
|
+
async function publishAssets(manifest, sdk, targetEnv, options = {}) {
|
|
2746
|
+
if (targetEnv.account === void 0 || targetEnv.account === cxapi.UNKNOWN_ACCOUNT || targetEnv.region === void 0 || targetEnv.account === cxapi.UNKNOWN_REGION) {
|
|
2747
|
+
throw new Error(
|
|
2748
|
+
`Asset publishing requires resolved account and region, got ${JSON.stringify(
|
|
2749
|
+
targetEnv
|
|
2750
|
+
)}`
|
|
2751
|
+
);
|
|
2752
|
+
}
|
|
2753
|
+
const publisher = new AssetPublishing(manifest, {
|
|
2754
|
+
aws: new PublishingAws(sdk, targetEnv),
|
|
2755
|
+
progressListener: new PublishingProgressListener(options.quiet ?? false),
|
|
2756
|
+
throwOnError: false,
|
|
2757
|
+
publishInParallel: options.parallel ?? true,
|
|
2758
|
+
buildAssets: options.buildAssets ?? true,
|
|
2759
|
+
publishAssets: true,
|
|
2760
|
+
quiet: options.quiet
|
|
2761
|
+
});
|
|
2762
|
+
await publisher.publish();
|
|
2763
|
+
if (publisher.hasFailures) {
|
|
2764
|
+
console.log(publisher.failures);
|
|
2765
|
+
throw new Error(
|
|
2766
|
+
"Failed to publish one or more assets. See the error messages above for more information."
|
|
2767
|
+
);
|
|
2768
|
+
}
|
|
2769
|
+
}
|
|
2770
|
+
async function buildAssets(manifest, sdk, targetEnv, options = {}) {
|
|
2771
|
+
if (targetEnv.account === void 0 || targetEnv.account === cxapi.UNKNOWN_ACCOUNT || targetEnv.region === void 0 || targetEnv.account === cxapi.UNKNOWN_REGION) {
|
|
2772
|
+
throw new Error(
|
|
2773
|
+
`Asset building requires resolved account and region, got ${JSON.stringify(
|
|
2774
|
+
targetEnv
|
|
2775
|
+
)}`
|
|
2776
|
+
);
|
|
2777
|
+
}
|
|
2778
|
+
const publisher = new cdk_assets.AssetPublishing(manifest, {
|
|
2779
|
+
aws: new PublishingAws(sdk, targetEnv),
|
|
2780
|
+
progressListener: new PublishingProgressListener(options.quiet ?? false),
|
|
2781
|
+
throwOnError: false,
|
|
2782
|
+
publishInParallel: options.parallel ?? true,
|
|
2783
|
+
buildAssets: true,
|
|
2784
|
+
publishAssets: false
|
|
2785
|
+
});
|
|
2786
|
+
await publisher.publish();
|
|
2787
|
+
if (publisher.hasFailures) {
|
|
2788
|
+
throw new Error(
|
|
2789
|
+
"Failed to build one or more assets. See the error messages above for more information."
|
|
2790
|
+
);
|
|
2791
|
+
}
|
|
2792
|
+
}
|
|
2793
|
+
var PublishingAws, EVENT_TO_LOGGER, PublishingProgressListener;
|
|
2794
|
+
var init_asset_publishing = __esm({
|
|
2795
|
+
"src/cdk/asset-publishing.ts"() {
|
|
2796
|
+
"use strict";
|
|
2797
|
+
init_publishing();
|
|
2798
|
+
PublishingAws = class {
|
|
2799
|
+
constructor(aws2, targetEnv) {
|
|
2800
|
+
this.aws = aws2;
|
|
2801
|
+
this.targetEnv = targetEnv;
|
|
2802
|
+
}
|
|
2803
|
+
sdkCache = /* @__PURE__ */ new Map();
|
|
2804
|
+
async discoverPartition() {
|
|
2805
|
+
return await this.aws.baseCredentialsPartition(
|
|
2806
|
+
this.targetEnv,
|
|
2807
|
+
Mode.ForWriting
|
|
2808
|
+
) ?? "aws";
|
|
2809
|
+
}
|
|
2810
|
+
async discoverDefaultRegion() {
|
|
2811
|
+
return this.targetEnv.region;
|
|
2812
|
+
}
|
|
2813
|
+
async discoverCurrentAccount() {
|
|
2814
|
+
const account = await this.aws.defaultAccount();
|
|
2815
|
+
return account ?? {
|
|
2816
|
+
accountId: "<unknown account>",
|
|
2817
|
+
partition: "aws"
|
|
2818
|
+
};
|
|
2819
|
+
}
|
|
2820
|
+
async discoverTargetAccount(options) {
|
|
2821
|
+
return (await this.sdk(options)).currentAccount();
|
|
2822
|
+
}
|
|
2823
|
+
async s3Client(options) {
|
|
2824
|
+
return (await this.sdk(options)).s3();
|
|
2825
|
+
}
|
|
2826
|
+
async ecrClient(options) {
|
|
2827
|
+
return (await this.sdk(options)).ecr();
|
|
2828
|
+
}
|
|
2829
|
+
async secretsManagerClient(options) {
|
|
2830
|
+
return (await this.sdk(options)).secretsManager();
|
|
2831
|
+
}
|
|
2832
|
+
async sdk(options) {
|
|
2833
|
+
const env = {
|
|
2834
|
+
...this.targetEnv,
|
|
2835
|
+
region: options.region ?? this.targetEnv.region
|
|
2836
|
+
};
|
|
2837
|
+
const cacheKey = JSON.stringify({
|
|
2838
|
+
env,
|
|
2839
|
+
assumeRuleArn: options.assumeRoleArn,
|
|
2840
|
+
assumeRoleExternalId: options.assumeRoleExternalId,
|
|
2841
|
+
quiet: options.quiet
|
|
2842
|
+
});
|
|
2843
|
+
const maybeSdk = this.sdkCache.get(cacheKey);
|
|
2844
|
+
if (maybeSdk) {
|
|
2845
|
+
return maybeSdk;
|
|
2846
|
+
}
|
|
2847
|
+
const sdk = (await this.aws.forEnvironment(
|
|
2848
|
+
env,
|
|
2849
|
+
Mode.ForWriting,
|
|
2850
|
+
{
|
|
2851
|
+
assumeRoleArn: options.assumeRoleArn,
|
|
2852
|
+
assumeRoleExternalId: options.assumeRoleExternalId
|
|
2853
|
+
},
|
|
2854
|
+
options.quiet
|
|
2855
|
+
)).sdk;
|
|
2856
|
+
this.sdkCache.set(cacheKey, sdk);
|
|
2857
|
+
return sdk;
|
|
2858
|
+
}
|
|
2859
|
+
};
|
|
2860
|
+
EVENT_TO_LOGGER = {
|
|
2861
|
+
build: debug,
|
|
2862
|
+
cached: debug,
|
|
2863
|
+
check: debug,
|
|
2864
|
+
debug,
|
|
2865
|
+
fail: error,
|
|
2866
|
+
found: debug,
|
|
2867
|
+
start: print,
|
|
2868
|
+
success: print,
|
|
2869
|
+
upload: debug
|
|
2870
|
+
};
|
|
2871
|
+
PublishingProgressListener = class {
|
|
2872
|
+
constructor(quiet) {
|
|
2873
|
+
this.quiet = quiet;
|
|
2874
|
+
}
|
|
2875
|
+
onPublishEvent(type, event) {
|
|
2876
|
+
const handler = this.quiet && type !== "fail" ? debug : EVENT_TO_LOGGER[type];
|
|
2877
|
+
handler(`[${event.percentComplete}%] ${type}: ${event.message}`);
|
|
2878
|
+
}
|
|
2879
|
+
};
|
|
2880
|
+
}
|
|
2881
|
+
});
|
|
2882
|
+
|
|
2139
2883
|
// src/cdk/util.ts
|
|
2140
2884
|
async function callWithRetry(cb) {
|
|
2141
2885
|
try {
|
|
@@ -2154,14 +2898,14 @@ var init_util = __esm({
|
|
|
2154
2898
|
});
|
|
2155
2899
|
|
|
2156
2900
|
// src/cdk/deploy-stack.ts
|
|
2157
|
-
import * as
|
|
2158
|
-
import
|
|
2901
|
+
import * as cxapi2 from "@aws-cdk/cx-api";
|
|
2902
|
+
import fs6 from "fs/promises";
|
|
2159
2903
|
import * as uuid from "uuid";
|
|
2160
2904
|
import { addMetadataAssetsToManifest } from "sst-aws-cdk/lib/assets.js";
|
|
2161
|
-
import { debug, error, print } from "sst-aws-cdk/lib/logging.js";
|
|
2905
|
+
import { debug as debug2, error as error2, print as print2 } from "sst-aws-cdk/lib/logging.js";
|
|
2162
2906
|
import { toYAML } from "sst-aws-cdk/lib/serialize.js";
|
|
2163
2907
|
import { AssetManifestBuilder } from "sst-aws-cdk/lib/util/asset-manifest-builder.js";
|
|
2164
|
-
import { publishAssets } from "sst-aws-cdk/lib/util/asset-publishing.js";
|
|
2908
|
+
import { publishAssets as publishAssets2 } from "sst-aws-cdk/lib/util/asset-publishing.js";
|
|
2165
2909
|
import { contentHash } from "sst-aws-cdk/lib/util/content-hash.js";
|
|
2166
2910
|
import { CfnEvaluationException } from "sst-aws-cdk/lib/api/evaluate-cloudformation-template.js";
|
|
2167
2911
|
import { HotswapMode } from "sst-aws-cdk/lib/api/hotswap/common.js";
|
|
@@ -2185,7 +2929,7 @@ async function deployStack(options) {
|
|
|
2185
2929
|
() => CloudFormationStack.lookup(cfn, deployName)
|
|
2186
2930
|
);
|
|
2187
2931
|
if (cloudFormationStack.stackStatus.isCreationFailure) {
|
|
2188
|
-
|
|
2932
|
+
debug2(
|
|
2189
2933
|
`Found existing stack ${deployName} that had previously failed creation. Deleting it before attempting to re-create it.`
|
|
2190
2934
|
);
|
|
2191
2935
|
await cfn.deleteStack({ StackName: deployName }).promise();
|
|
@@ -2217,7 +2961,7 @@ async function deployStack(options) {
|
|
|
2217
2961
|
cloudFormationStack,
|
|
2218
2962
|
stackParams.hasChanges(cloudFormationStack.parameters)
|
|
2219
2963
|
)) {
|
|
2220
|
-
|
|
2964
|
+
debug2(`${deployName}: skipping deployment (use --force to override)`);
|
|
2221
2965
|
if (options.hotswap) {
|
|
2222
2966
|
}
|
|
2223
2967
|
return {
|
|
@@ -2226,7 +2970,7 @@ async function deployStack(options) {
|
|
|
2226
2970
|
stackArn: cloudFormationStack.stackId
|
|
2227
2971
|
};
|
|
2228
2972
|
} else {
|
|
2229
|
-
|
|
2973
|
+
debug2(`${deployName}: deploying...`);
|
|
2230
2974
|
}
|
|
2231
2975
|
const bodyParameter = await makeBodyParameter(
|
|
2232
2976
|
stackArtifact,
|
|
@@ -2236,7 +2980,7 @@ async function deployStack(options) {
|
|
|
2236
2980
|
options.sdk,
|
|
2237
2981
|
options.overrideTemplate
|
|
2238
2982
|
);
|
|
2239
|
-
await
|
|
2983
|
+
await publishAssets2(
|
|
2240
2984
|
legacyAssets.toManifest(stackArtifact.assembly.directory),
|
|
2241
2985
|
options.sdkProvider,
|
|
2242
2986
|
stackEnv,
|
|
@@ -2257,7 +3001,7 @@ async function deployStack(options) {
|
|
|
2257
3001
|
if (hotswapDeploymentResult) {
|
|
2258
3002
|
return hotswapDeploymentResult;
|
|
2259
3003
|
}
|
|
2260
|
-
|
|
3004
|
+
print2(
|
|
2261
3005
|
"Could not perform a hotswap deployment, as the stack %s contains non-Asset changes",
|
|
2262
3006
|
stackArtifact.displayName
|
|
2263
3007
|
);
|
|
@@ -2265,13 +3009,13 @@ async function deployStack(options) {
|
|
|
2265
3009
|
if (!(e instanceof CfnEvaluationException)) {
|
|
2266
3010
|
throw e;
|
|
2267
3011
|
}
|
|
2268
|
-
|
|
3012
|
+
print2(
|
|
2269
3013
|
"Could not perform a hotswap deployment, because the CloudFormation template could not be resolved: %s",
|
|
2270
3014
|
e.message
|
|
2271
3015
|
);
|
|
2272
3016
|
}
|
|
2273
3017
|
if (hotswapMode === HotswapMode.FALL_BACK) {
|
|
2274
|
-
|
|
3018
|
+
print2("Falling back to doing a full deployment");
|
|
2275
3019
|
options.sdk.appendCustomUserAgent("cdk-hotswap/fallback");
|
|
2276
3020
|
} else {
|
|
2277
3021
|
return {
|
|
@@ -2305,7 +3049,7 @@ async function makeBodyParameter(stack, resolvedEnvironment, assetManifest, tool
|
|
|
2305
3049
|
return { TemplateBody: templateJson };
|
|
2306
3050
|
}
|
|
2307
3051
|
if (!toolkitInfo.found) {
|
|
2308
|
-
|
|
3052
|
+
error2(
|
|
2309
3053
|
`The template for stack "${stack.displayName}" is ${Math.round(
|
|
2310
3054
|
templateJson.length / 1024
|
|
2311
3055
|
)}KiB. Templates larger than ${LARGE_TEMPLATE_SIZE_KB}KiB must be uploaded to S3.
|
|
@@ -2324,7 +3068,7 @@ Run the following command in order to setup an S3 bucket in this environment, an
|
|
|
2324
3068
|
let templateFile = stack.templateFile;
|
|
2325
3069
|
if (overrideTemplate) {
|
|
2326
3070
|
templateFile = `${stack.templateFile}-${templateHash}.yaml`;
|
|
2327
|
-
await
|
|
3071
|
+
await fs6.writeFile(templateFile, templateJson, { encoding: "utf-8" });
|
|
2328
3072
|
}
|
|
2329
3073
|
assetManifest.addFileAsset(
|
|
2330
3074
|
templateHash,
|
|
@@ -2337,7 +3081,7 @@ Run the following command in order to setup an S3 bucket in this environment, an
|
|
|
2337
3081
|
}
|
|
2338
3082
|
);
|
|
2339
3083
|
const templateURL = `${toolkitInfo.bucketUrl}/${key}`;
|
|
2340
|
-
|
|
3084
|
+
debug2("Storing template in S3 at:", templateURL);
|
|
2341
3085
|
return { TemplateURL: templateURL };
|
|
2342
3086
|
}
|
|
2343
3087
|
async function makeBodyParameterAndUpload(stack, resolvedEnvironment, toolkitInfo, sdkProvider, sdk, overrideTemplate) {
|
|
@@ -2354,7 +3098,7 @@ async function makeBodyParameterAndUpload(stack, resolvedEnvironment, toolkitInf
|
|
|
2354
3098
|
overrideTemplate
|
|
2355
3099
|
);
|
|
2356
3100
|
const manifest = builder.toManifest(stack.assembly.directory);
|
|
2357
|
-
await
|
|
3101
|
+
await publishAssets2(manifest, sdkProvider, resolvedEnvironment, {
|
|
2358
3102
|
quiet: true
|
|
2359
3103
|
});
|
|
2360
3104
|
return bodyparam;
|
|
@@ -2381,47 +3125,47 @@ async function destroyStack(options) {
|
|
|
2381
3125
|
}
|
|
2382
3126
|
async function canSkipDeploy(deployStackOptions, cloudFormationStack, parameterChanges) {
|
|
2383
3127
|
const deployName = deployStackOptions.deployName || deployStackOptions.stack.stackName;
|
|
2384
|
-
|
|
3128
|
+
debug2(`${deployName}: checking if we can skip deploy`);
|
|
2385
3129
|
if (deployStackOptions.force) {
|
|
2386
|
-
|
|
3130
|
+
debug2(`${deployName}: forced deployment`);
|
|
2387
3131
|
return false;
|
|
2388
3132
|
}
|
|
2389
3133
|
if (deployStackOptions.deploymentMethod?.method === "change-set" && deployStackOptions.deploymentMethod.execute === false) {
|
|
2390
|
-
|
|
3134
|
+
debug2(`${deployName}: --no-execute, always creating change set`);
|
|
2391
3135
|
return false;
|
|
2392
3136
|
}
|
|
2393
3137
|
if (!cloudFormationStack.exists) {
|
|
2394
|
-
|
|
3138
|
+
debug2(`${deployName}: no existing stack`);
|
|
2395
3139
|
return false;
|
|
2396
3140
|
}
|
|
2397
3141
|
if (cloudFormationStack.stackStatus.isInProgress) {
|
|
2398
|
-
|
|
3142
|
+
debug2(`${deployName}: stack is busy`);
|
|
2399
3143
|
return false;
|
|
2400
3144
|
}
|
|
2401
3145
|
if (JSON.stringify(deployStackOptions.stack.template) !== JSON.stringify(await cloudFormationStack.template())) {
|
|
2402
|
-
|
|
3146
|
+
debug2(`${deployName}: template has changed`);
|
|
2403
3147
|
return false;
|
|
2404
3148
|
}
|
|
2405
3149
|
if (!compareTags(cloudFormationStack.tags, deployStackOptions.tags ?? [])) {
|
|
2406
|
-
|
|
3150
|
+
debug2(`${deployName}: tags have changed`);
|
|
2407
3151
|
return false;
|
|
2408
3152
|
}
|
|
2409
3153
|
if (!!deployStackOptions.stack.terminationProtection !== !!cloudFormationStack.terminationProtection) {
|
|
2410
|
-
|
|
3154
|
+
debug2(`${deployName}: termination protection has been updated`);
|
|
2411
3155
|
return false;
|
|
2412
3156
|
}
|
|
2413
3157
|
if (parameterChanges) {
|
|
2414
3158
|
if (parameterChanges === "ssm") {
|
|
2415
|
-
|
|
3159
|
+
debug2(
|
|
2416
3160
|
`${deployName}: some parameters come from SSM so we have to assume they may have changed`
|
|
2417
3161
|
);
|
|
2418
3162
|
} else {
|
|
2419
|
-
|
|
3163
|
+
debug2(`${deployName}: parameters have changed`);
|
|
2420
3164
|
}
|
|
2421
3165
|
return false;
|
|
2422
3166
|
}
|
|
2423
3167
|
if (cloudFormationStack.stackStatus.isFailure) {
|
|
2424
|
-
|
|
3168
|
+
debug2(`${deployName}: stack is in a failure state`);
|
|
2425
3169
|
return false;
|
|
2426
3170
|
}
|
|
2427
3171
|
return true;
|
|
@@ -2440,7 +3184,7 @@ function compareTags(a, b) {
|
|
|
2440
3184
|
}
|
|
2441
3185
|
function restUrlFromManifest(url10, environment, sdk) {
|
|
2442
3186
|
const doNotUseMarker = "**DONOTUSE**";
|
|
2443
|
-
url10 =
|
|
3187
|
+
url10 = cxapi2.EnvironmentPlaceholders.replace(url10, {
|
|
2444
3188
|
accountId: environment.account,
|
|
2445
3189
|
region: environment.region,
|
|
2446
3190
|
partition: doNotUseMarker
|
|
@@ -2509,9 +3253,9 @@ var init_deploy_stack = __esm({
|
|
|
2509
3253
|
);
|
|
2510
3254
|
await this.updateTerminationProtection();
|
|
2511
3255
|
if (changeSetHasNoChanges(changeSetDescription)) {
|
|
2512
|
-
|
|
3256
|
+
debug2("No changes are to be performed on %s.", this.stackName);
|
|
2513
3257
|
if (execute) {
|
|
2514
|
-
|
|
3258
|
+
debug2("Deleting empty change set %s", changeSetDescription.ChangeSetId);
|
|
2515
3259
|
await this.cfn.deleteChangeSet({
|
|
2516
3260
|
StackName: this.stackName,
|
|
2517
3261
|
ChangeSetName: changeSetName
|
|
@@ -2524,7 +3268,7 @@ var init_deploy_stack = __esm({
|
|
|
2524
3268
|
};
|
|
2525
3269
|
}
|
|
2526
3270
|
if (!execute) {
|
|
2527
|
-
|
|
3271
|
+
print2(
|
|
2528
3272
|
"Changeset %s created and waiting in review for manual execution (--no-execute)",
|
|
2529
3273
|
changeSetDescription.ChangeSetId
|
|
2530
3274
|
);
|
|
@@ -2538,7 +3282,7 @@ var init_deploy_stack = __esm({
|
|
|
2538
3282
|
}
|
|
2539
3283
|
async createChangeSet(changeSetName, willExecute) {
|
|
2540
3284
|
await this.cleanupOldChangeset(changeSetName);
|
|
2541
|
-
|
|
3285
|
+
debug2(
|
|
2542
3286
|
`Attempting to create ChangeSet with name ${changeSetName} to ${this.verb} stack ${this.stackName}`
|
|
2543
3287
|
);
|
|
2544
3288
|
const changeSet = await this.cfn.createChangeSet({
|
|
@@ -2550,7 +3294,7 @@ var init_deploy_stack = __esm({
|
|
|
2550
3294
|
ClientToken: `create${this.uuid}`,
|
|
2551
3295
|
...this.commonPrepareOptions()
|
|
2552
3296
|
}).promise();
|
|
2553
|
-
|
|
3297
|
+
debug2(
|
|
2554
3298
|
"Initiated creation of changeset: %s; waiting for it to finish creating...",
|
|
2555
3299
|
changeSet.Id
|
|
2556
3300
|
);
|
|
@@ -2559,7 +3303,7 @@ var init_deploy_stack = __esm({
|
|
|
2559
3303
|
});
|
|
2560
3304
|
}
|
|
2561
3305
|
async executeChangeSet(changeSet) {
|
|
2562
|
-
|
|
3306
|
+
debug2(
|
|
2563
3307
|
"Initiating execution of changeset %s on stack %s",
|
|
2564
3308
|
changeSet.ChangeSetId,
|
|
2565
3309
|
this.stackName
|
|
@@ -2570,7 +3314,7 @@ var init_deploy_stack = __esm({
|
|
|
2570
3314
|
ClientRequestToken: `exec${this.uuid}`,
|
|
2571
3315
|
...this.commonExecuteOptions()
|
|
2572
3316
|
}).promise();
|
|
2573
|
-
|
|
3317
|
+
debug2(
|
|
2574
3318
|
"Execution of changeset %s on stack %s has started; waiting for the update to complete...",
|
|
2575
3319
|
changeSet.ChangeSetId,
|
|
2576
3320
|
this.stackName
|
|
@@ -2580,7 +3324,7 @@ var init_deploy_stack = __esm({
|
|
|
2580
3324
|
}
|
|
2581
3325
|
async cleanupOldChangeset(changeSetName) {
|
|
2582
3326
|
if (this.cloudFormationStack.exists) {
|
|
2583
|
-
|
|
3327
|
+
debug2(
|
|
2584
3328
|
`Removing existing change set with name ${changeSetName} if it exists`
|
|
2585
3329
|
);
|
|
2586
3330
|
await this.cfn.deleteChangeSet({
|
|
@@ -2592,7 +3336,7 @@ var init_deploy_stack = __esm({
|
|
|
2592
3336
|
async updateTerminationProtection() {
|
|
2593
3337
|
const terminationProtection = this.stackArtifact.terminationProtection ?? false;
|
|
2594
3338
|
if (!!this.cloudFormationStack.terminationProtection !== terminationProtection) {
|
|
2595
|
-
|
|
3339
|
+
debug2(
|
|
2596
3340
|
"Updating termination protection from %s to %s for stack %s",
|
|
2597
3341
|
this.cloudFormationStack.terminationProtection,
|
|
2598
3342
|
terminationProtection,
|
|
@@ -2602,7 +3346,7 @@ var init_deploy_stack = __esm({
|
|
|
2602
3346
|
StackName: this.stackName,
|
|
2603
3347
|
EnableTerminationProtection: terminationProtection
|
|
2604
3348
|
}).promise();
|
|
2605
|
-
|
|
3349
|
+
debug2(
|
|
2606
3350
|
"Termination protection updated to %s for stack %s",
|
|
2607
3351
|
terminationProtection,
|
|
2608
3352
|
this.stackName
|
|
@@ -2651,7 +3395,7 @@ var init_deploy_stack = __esm({
|
|
|
2651
3395
|
throw new Error(suffixWithErrors(e.message));
|
|
2652
3396
|
} finally {
|
|
2653
3397
|
}
|
|
2654
|
-
|
|
3398
|
+
debug2("Stack %s has completed updating", this.stackName);
|
|
2655
3399
|
return {
|
|
2656
3400
|
noOp: false,
|
|
2657
3401
|
outputs: finalState.outputs,
|
|
@@ -2690,17 +3434,11 @@ __export(deployments_exports, {
|
|
|
2690
3434
|
CloudFormationDeployments: () => CloudFormationDeployments,
|
|
2691
3435
|
Deployments: () => Deployments
|
|
2692
3436
|
});
|
|
2693
|
-
import * as
|
|
2694
|
-
import * as
|
|
2695
|
-
import { AssetManifest } from "cdk-assets";
|
|
2696
|
-
import { debug as
|
|
2697
|
-
import {
|
|
2698
|
-
buildAssets,
|
|
2699
|
-
publishAssets as publishAssets2,
|
|
2700
|
-
PublishingAws,
|
|
2701
|
-
EVENT_TO_LOGGER
|
|
2702
|
-
} from "sst-aws-cdk/lib/util/asset-publishing.js";
|
|
2703
|
-
import { Mode } from "sst-aws-cdk/lib/api/aws-auth/credentials.js";
|
|
3437
|
+
import * as cxapi3 from "@aws-cdk/cx-api";
|
|
3438
|
+
import * as cdk_assets2 from "cdk-assets";
|
|
3439
|
+
import { AssetManifest as AssetManifest2 } from "cdk-assets";
|
|
3440
|
+
import { debug as debug3, warning } from "sst-aws-cdk/lib/logging.js";
|
|
3441
|
+
import { Mode as Mode2 } from "sst-aws-cdk/lib/api/aws-auth/credentials.js";
|
|
2704
3442
|
import {
|
|
2705
3443
|
loadCurrentTemplateWithNestedStacks,
|
|
2706
3444
|
loadCurrentTemplate
|
|
@@ -2714,6 +3452,7 @@ var Deployments, ParallelSafeAssetProgress, CloudFormationDeployments;
|
|
|
2714
3452
|
var init_deployments = __esm({
|
|
2715
3453
|
"src/cdk/deployments.ts"() {
|
|
2716
3454
|
"use strict";
|
|
3455
|
+
init_asset_publishing();
|
|
2717
3456
|
init_deploy_stack();
|
|
2718
3457
|
init_util();
|
|
2719
3458
|
Deployments = class {
|
|
@@ -2734,18 +3473,18 @@ var init_deployments = __esm({
|
|
|
2734
3473
|
)).deployedTemplate;
|
|
2735
3474
|
}
|
|
2736
3475
|
async readCurrentTemplate(stackArtifact) {
|
|
2737
|
-
|
|
3476
|
+
debug3(`Reading existing template for stack ${stackArtifact.displayName}.`);
|
|
2738
3477
|
const sdk = (await this.prepareSdkWithLookupOrDeployRole(stackArtifact)).stackSdk;
|
|
2739
3478
|
return loadCurrentTemplate(stackArtifact, sdk);
|
|
2740
3479
|
}
|
|
2741
3480
|
async resourceIdentifierSummaries(stackArtifact, toolkitStackName) {
|
|
2742
|
-
|
|
3481
|
+
debug3(
|
|
2743
3482
|
`Retrieving template summary for stack ${stackArtifact.displayName}.`
|
|
2744
3483
|
);
|
|
2745
3484
|
const { stackSdk, resolvedEnvironment } = await this.prepareSdkFor(
|
|
2746
3485
|
stackArtifact,
|
|
2747
3486
|
void 0,
|
|
2748
|
-
|
|
3487
|
+
Mode2.ForReading
|
|
2749
3488
|
);
|
|
2750
3489
|
const cfn = stackSdk.cloudFormation();
|
|
2751
3490
|
const toolkitInfo = await this.lookupToolkit(
|
|
@@ -2762,7 +3501,7 @@ var init_deployments = __esm({
|
|
|
2762
3501
|
);
|
|
2763
3502
|
const response = await cfn.getTemplateSummary(cfnParam).promise();
|
|
2764
3503
|
if (!response.ResourceIdentifierSummaries) {
|
|
2765
|
-
|
|
3504
|
+
debug3(
|
|
2766
3505
|
'GetTemplateSummary API call did not return "ResourceIdentifierSummaries"'
|
|
2767
3506
|
);
|
|
2768
3507
|
}
|
|
@@ -2782,7 +3521,7 @@ var init_deployments = __esm({
|
|
|
2782
3521
|
execute: options.execute
|
|
2783
3522
|
};
|
|
2784
3523
|
}
|
|
2785
|
-
const { stackSdk, resolvedEnvironment, cloudFormationRoleArn } = await this.prepareSdkFor(options.stack, options.roleArn,
|
|
3524
|
+
const { stackSdk, resolvedEnvironment, cloudFormationRoleArn } = await this.prepareSdkFor(options.stack, options.roleArn, Mode2.ForWriting);
|
|
2786
3525
|
const toolkitInfo = await callWithRetry(
|
|
2787
3526
|
() => this.lookupToolkit(
|
|
2788
3527
|
resolvedEnvironment,
|
|
@@ -2797,11 +3536,11 @@ var init_deployments = __esm({
|
|
|
2797
3536
|
toolkitInfo
|
|
2798
3537
|
);
|
|
2799
3538
|
const assetArtifacts = options.stack.dependencies.filter(
|
|
2800
|
-
|
|
3539
|
+
cxapi3.AssetManifestArtifact.isAssetManifestArtifact
|
|
2801
3540
|
);
|
|
2802
3541
|
for (const asset of assetArtifacts) {
|
|
2803
|
-
const manifest =
|
|
2804
|
-
await
|
|
3542
|
+
const manifest = AssetManifest2.fromFile(asset.file);
|
|
3543
|
+
await publishAssets(manifest, this.sdkProvider, resolvedEnvironment, {
|
|
2805
3544
|
buildAssets: true,
|
|
2806
3545
|
quiet: options.quiet,
|
|
2807
3546
|
parallel: options.assetParallelism
|
|
@@ -2835,7 +3574,7 @@ var init_deployments = __esm({
|
|
|
2835
3574
|
});
|
|
2836
3575
|
}
|
|
2837
3576
|
async destroyStack(options) {
|
|
2838
|
-
const { stackSdk, cloudFormationRoleArn: roleArn } = await this.prepareSdkFor(options.stack, options.roleArn,
|
|
3577
|
+
const { stackSdk, cloudFormationRoleArn: roleArn } = await this.prepareSdkFor(options.stack, options.roleArn, Mode2.ForWriting);
|
|
2839
3578
|
return destroyStack({
|
|
2840
3579
|
sdk: stackSdk,
|
|
2841
3580
|
roleArn,
|
|
@@ -2849,7 +3588,7 @@ var init_deployments = __esm({
|
|
|
2849
3588
|
const { stackSdk } = await this.prepareSdkFor(
|
|
2850
3589
|
options.stack,
|
|
2851
3590
|
void 0,
|
|
2852
|
-
|
|
3591
|
+
Mode2.ForReading
|
|
2853
3592
|
);
|
|
2854
3593
|
const stack = await CloudFormationStack2.lookup(
|
|
2855
3594
|
stackSdk.cloudFormation(),
|
|
@@ -2868,7 +3607,7 @@ var init_deployments = __esm({
|
|
|
2868
3607
|
}
|
|
2869
3608
|
} catch {
|
|
2870
3609
|
}
|
|
2871
|
-
return this.prepareSdkFor(stackArtifact, void 0,
|
|
3610
|
+
return this.prepareSdkFor(stackArtifact, void 0, Mode2.ForReading);
|
|
2872
3611
|
}
|
|
2873
3612
|
async prepareSdkFor(stack, roleArn, mode) {
|
|
2874
3613
|
if (!stack.environment) {
|
|
@@ -2917,7 +3656,7 @@ var init_deployments = __esm({
|
|
|
2917
3656
|
try {
|
|
2918
3657
|
const stackSdk = await this.cachedSdkForEnvironment(
|
|
2919
3658
|
resolvedEnvironment,
|
|
2920
|
-
|
|
3659
|
+
Mode2.ForReading,
|
|
2921
3660
|
{
|
|
2922
3661
|
assumeRoleArn: arns.lookupRoleArn,
|
|
2923
3662
|
assumeRoleExternalId: stack.lookupRole?.assumeRoleExternalId
|
|
@@ -2938,7 +3677,7 @@ var init_deployments = __esm({
|
|
|
2938
3677
|
}
|
|
2939
3678
|
return { ...stackSdk, resolvedEnvironment };
|
|
2940
3679
|
} catch (e) {
|
|
2941
|
-
|
|
3680
|
+
debug3(e);
|
|
2942
3681
|
if (stack.lookupRole && stack.lookupRole.requiresBootstrapStackVersion) {
|
|
2943
3682
|
warning(warningMessage);
|
|
2944
3683
|
warning(upgradeMessage);
|
|
@@ -2964,7 +3703,7 @@ var init_deployments = __esm({
|
|
|
2964
3703
|
const { stackSdk, resolvedEnvironment } = await this.prepareSdkFor(
|
|
2965
3704
|
options.stack,
|
|
2966
3705
|
options.roleArn,
|
|
2967
|
-
|
|
3706
|
+
Mode2.ForWriting
|
|
2968
3707
|
);
|
|
2969
3708
|
const toolkitInfo = await this.lookupToolkit(
|
|
2970
3709
|
resolvedEnvironment,
|
|
@@ -2980,7 +3719,7 @@ var init_deployments = __esm({
|
|
|
2980
3719
|
asset.bootstrapStackVersionSsmParameter,
|
|
2981
3720
|
toolkitInfo
|
|
2982
3721
|
);
|
|
2983
|
-
const manifest =
|
|
3722
|
+
const manifest = AssetManifest2.fromFile(asset.file);
|
|
2984
3723
|
return { manifest, stackEnv };
|
|
2985
3724
|
}
|
|
2986
3725
|
async buildAssets(asset, options) {
|
|
@@ -3000,7 +3739,7 @@ var init_deployments = __esm({
|
|
|
3000
3739
|
asset,
|
|
3001
3740
|
options
|
|
3002
3741
|
);
|
|
3003
|
-
await
|
|
3742
|
+
await publishAssets(
|
|
3004
3743
|
manifest,
|
|
3005
3744
|
this.sdkProvider,
|
|
3006
3745
|
stackEnv,
|
|
@@ -3008,7 +3747,7 @@ var init_deployments = __esm({
|
|
|
3008
3747
|
);
|
|
3009
3748
|
}
|
|
3010
3749
|
async buildSingleAsset(assetArtifact, assetManifest, asset, options) {
|
|
3011
|
-
const { stackSdk, resolvedEnvironment: stackEnv } = await this.prepareSdkFor(options.stack, options.roleArn,
|
|
3750
|
+
const { stackSdk, resolvedEnvironment: stackEnv } = await this.prepareSdkFor(options.stack, options.roleArn, Mode2.ForWriting);
|
|
3012
3751
|
const toolkitInfo = await this.lookupToolkit(
|
|
3013
3752
|
stackEnv,
|
|
3014
3753
|
stackSdk,
|
|
@@ -3031,7 +3770,7 @@ var init_deployments = __esm({
|
|
|
3031
3770
|
const { resolvedEnvironment: stackEnv } = await this.prepareSdkFor(
|
|
3032
3771
|
options.stack,
|
|
3033
3772
|
options.roleArn,
|
|
3034
|
-
|
|
3773
|
+
Mode2.ForWriting
|
|
3035
3774
|
);
|
|
3036
3775
|
const publisher = this.cachedPublisher(
|
|
3037
3776
|
assetManifest,
|
|
@@ -3044,7 +3783,7 @@ var init_deployments = __esm({
|
|
|
3044
3783
|
const { resolvedEnvironment: stackEnv } = await this.prepareSdkFor(
|
|
3045
3784
|
options.stack,
|
|
3046
3785
|
options.roleArn,
|
|
3047
|
-
|
|
3786
|
+
Mode2.ForWriting
|
|
3048
3787
|
);
|
|
3049
3788
|
const publisher = this.cachedPublisher(
|
|
3050
3789
|
assetManifest,
|
|
@@ -3092,7 +3831,7 @@ var init_deployments = __esm({
|
|
|
3092
3831
|
return existing;
|
|
3093
3832
|
}
|
|
3094
3833
|
const prefix = stackName ? `${stackName}: ` : "";
|
|
3095
|
-
const publisher = new
|
|
3834
|
+
const publisher = new cdk_assets2.AssetPublishing(assetManifest, {
|
|
3096
3835
|
aws: new PublishingAws(this.sdkProvider, env),
|
|
3097
3836
|
progressListener: new ParallelSafeAssetProgress(
|
|
3098
3837
|
prefix,
|
|
@@ -3109,7 +3848,7 @@ var init_deployments = __esm({
|
|
|
3109
3848
|
this.quiet = quiet;
|
|
3110
3849
|
}
|
|
3111
3850
|
onPublishEvent(type, event) {
|
|
3112
|
-
const handler = this.quiet && type !== "fail" ?
|
|
3851
|
+
const handler = this.quiet && type !== "fail" ? debug3 : EVENT_TO_LOGGER[type];
|
|
3113
3852
|
handler(`${this.prefix} ${type}: ${event.message}`);
|
|
3114
3853
|
}
|
|
3115
3854
|
};
|
|
@@ -3123,15 +3862,15 @@ var deployments_wrapper_exports = {};
|
|
|
3123
3862
|
__export(deployments_wrapper_exports, {
|
|
3124
3863
|
publishDeployAssets: () => publishDeployAssets
|
|
3125
3864
|
});
|
|
3126
|
-
import * as
|
|
3127
|
-
import { AssetManifest as
|
|
3128
|
-
import { debug as
|
|
3865
|
+
import * as cxapi4 from "@aws-cdk/cx-api";
|
|
3866
|
+
import { AssetManifest as AssetManifest3 } from "cdk-assets";
|
|
3867
|
+
import { debug as debug4 } from "sst-aws-cdk/lib/logging.js";
|
|
3129
3868
|
import {
|
|
3130
3869
|
CloudFormationStack as CloudFormationStack3,
|
|
3131
3870
|
TemplateParameters as TemplateParameters2,
|
|
3132
3871
|
waitForStackDelete as waitForStackDelete2
|
|
3133
3872
|
} from "sst-aws-cdk/lib/api/util/cloudformation.js";
|
|
3134
|
-
import { Mode as
|
|
3873
|
+
import { Mode as Mode3 } from "sst-aws-cdk/lib/api/aws-auth/credentials.js";
|
|
3135
3874
|
import { ToolkitInfo as ToolkitInfo2 } from "sst-aws-cdk/lib/api/toolkit-info.js";
|
|
3136
3875
|
import { addMetadataAssetsToManifest as addMetadataAssetsToManifest2 } from "sst-aws-cdk/lib/assets.js";
|
|
3137
3876
|
import { publishAssets as publishAssets3 } from "sst-aws-cdk/lib/util/asset-publishing.js";
|
|
@@ -3145,10 +3884,10 @@ async function publishDeployAssets(sdkProvider, options) {
|
|
|
3145
3884
|
cloudFormationRoleArn
|
|
3146
3885
|
} = await useDeployment().get(sdkProvider, options);
|
|
3147
3886
|
const assetArtifacts = options.stack.dependencies.filter(
|
|
3148
|
-
|
|
3887
|
+
cxapi4.AssetManifestArtifact.isAssetManifestArtifact
|
|
3149
3888
|
);
|
|
3150
3889
|
for (const asset of assetArtifacts) {
|
|
3151
|
-
const manifest =
|
|
3890
|
+
const manifest = AssetManifest3.fromFile(asset.file);
|
|
3152
3891
|
await publishAssets3(manifest, sdkProvider, resolvedEnvironment, {
|
|
3153
3892
|
buildAssets: true,
|
|
3154
3893
|
quiet: options.quiet,
|
|
@@ -3190,7 +3929,7 @@ async function deployStack2(options) {
|
|
|
3190
3929
|
const deployName = options.deployName || stackArtifact.stackName;
|
|
3191
3930
|
let cloudFormationStack = await CloudFormationStack3.lookup(cfn, deployName);
|
|
3192
3931
|
if (cloudFormationStack.stackStatus.isCreationFailure) {
|
|
3193
|
-
|
|
3932
|
+
debug4(
|
|
3194
3933
|
`Found existing stack ${deployName} that had previously failed creation. Deleting it before attempting to re-create it.`
|
|
3195
3934
|
);
|
|
3196
3935
|
await cfn.deleteStack({ StackName: deployName }).promise();
|
|
@@ -3266,7 +4005,7 @@ var init_deployments_wrapper = __esm({
|
|
|
3266
4005
|
const { stackSdk, resolvedEnvironment, cloudFormationRoleArn } = await deployment.prepareSdkFor(
|
|
3267
4006
|
options.stack,
|
|
3268
4007
|
options.roleArn,
|
|
3269
|
-
|
|
4008
|
+
Mode3.ForWriting
|
|
3270
4009
|
);
|
|
3271
4010
|
const toolkitInfo = await ToolkitInfo2.lookup(
|
|
3272
4011
|
resolvedEnvironment,
|
|
@@ -3326,7 +4065,7 @@ async function deployMany(stacks) {
|
|
|
3326
4065
|
const complete = /* @__PURE__ */ new Set();
|
|
3327
4066
|
const todo = new Set(stacks.map((s) => s.id));
|
|
3328
4067
|
const results = {};
|
|
3329
|
-
return new Promise((
|
|
4068
|
+
return new Promise((resolve2) => {
|
|
3330
4069
|
async function trigger() {
|
|
3331
4070
|
for (const stack of stacks) {
|
|
3332
4071
|
if (!todo.has(stack.id))
|
|
@@ -3355,7 +4094,7 @@ async function deployMany(stacks) {
|
|
|
3355
4094
|
}
|
|
3356
4095
|
});
|
|
3357
4096
|
if (complete.size === stacks.length) {
|
|
3358
|
-
|
|
4097
|
+
resolve2(results);
|
|
3359
4098
|
}
|
|
3360
4099
|
trigger();
|
|
3361
4100
|
});
|
|
@@ -3491,13 +4230,13 @@ async function listImports(exportName) {
|
|
|
3491
4230
|
}
|
|
3492
4231
|
}
|
|
3493
4232
|
async function getLocalTemplate(stack) {
|
|
3494
|
-
const
|
|
3495
|
-
const fileContent = await
|
|
4233
|
+
const fs19 = await import("fs/promises");
|
|
4234
|
+
const fileContent = await fs19.readFile(stack.templateFullPath);
|
|
3496
4235
|
return fileContent.toString();
|
|
3497
4236
|
}
|
|
3498
4237
|
async function saveLocalTemplate(stack, content) {
|
|
3499
|
-
const
|
|
3500
|
-
await
|
|
4238
|
+
const fs19 = await import("fs/promises");
|
|
4239
|
+
await fs19.writeFile(stack.templateFullPath, content);
|
|
3501
4240
|
}
|
|
3502
4241
|
var init_deploy = __esm({
|
|
3503
4242
|
"src/stacks/deploy.ts"() {
|
|
@@ -3566,8 +4305,8 @@ var init_diff = __esm({
|
|
|
3566
4305
|
});
|
|
3567
4306
|
|
|
3568
4307
|
// src/cache.ts
|
|
3569
|
-
import
|
|
3570
|
-
import
|
|
4308
|
+
import path7 from "path";
|
|
4309
|
+
import fs7 from "fs/promises";
|
|
3571
4310
|
var useCache;
|
|
3572
4311
|
var init_cache = __esm({
|
|
3573
4312
|
"src/cache.ts"() {
|
|
@@ -3577,19 +4316,19 @@ var init_cache = __esm({
|
|
|
3577
4316
|
init_context();
|
|
3578
4317
|
useCache = Context.memo(async () => {
|
|
3579
4318
|
const project = useProject();
|
|
3580
|
-
const cache =
|
|
3581
|
-
await
|
|
4319
|
+
const cache = path7.join(project.paths.out, "cache");
|
|
4320
|
+
await fs7.mkdir(cache, {
|
|
3582
4321
|
recursive: true
|
|
3583
4322
|
});
|
|
3584
4323
|
async function write(key, data2) {
|
|
3585
|
-
const full =
|
|
4324
|
+
const full = path7.join(cache, key);
|
|
3586
4325
|
Logger.debug("Writing cache", full, data2.length, "bytes");
|
|
3587
|
-
await
|
|
4326
|
+
await fs7.writeFile(full, data2);
|
|
3588
4327
|
}
|
|
3589
4328
|
async function read(key) {
|
|
3590
|
-
const full =
|
|
4329
|
+
const full = path7.join(cache, key);
|
|
3591
4330
|
try {
|
|
3592
|
-
const data2 = await
|
|
4331
|
+
const data2 = await fs7.readFile(full);
|
|
3593
4332
|
return data2.toString();
|
|
3594
4333
|
} catch {
|
|
3595
4334
|
return null;
|
|
@@ -3682,7 +4421,7 @@ var init_metadata = __esm({
|
|
|
3682
4421
|
bus.publish("stacks.metadata", data2);
|
|
3683
4422
|
return data2;
|
|
3684
4423
|
} catch {
|
|
3685
|
-
await new Promise((
|
|
4424
|
+
await new Promise((resolve2) => setTimeout(resolve2, 1e3));
|
|
3686
4425
|
}
|
|
3687
4426
|
}
|
|
3688
4427
|
});
|
|
@@ -3696,7 +4435,7 @@ __export(watcher_exports, {
|
|
|
3696
4435
|
useWatcher: () => useWatcher
|
|
3697
4436
|
});
|
|
3698
4437
|
import chokidar from "chokidar";
|
|
3699
|
-
import
|
|
4438
|
+
import path8 from "path";
|
|
3700
4439
|
var useWatcher;
|
|
3701
4440
|
var init_watcher = __esm({
|
|
3702
4441
|
"src/watcher.ts"() {
|
|
@@ -3727,7 +4466,7 @@ var init_watcher = __esm({
|
|
|
3727
4466
|
watcher.on("change", (file) => {
|
|
3728
4467
|
bus.publish("file.changed", {
|
|
3729
4468
|
file,
|
|
3730
|
-
relative:
|
|
4469
|
+
relative: path8.relative(project.paths.root, file)
|
|
3731
4470
|
});
|
|
3732
4471
|
});
|
|
3733
4472
|
return {
|
|
@@ -3738,11 +4477,11 @@ var init_watcher = __esm({
|
|
|
3738
4477
|
});
|
|
3739
4478
|
|
|
3740
4479
|
// src/runtime/handlers.ts
|
|
3741
|
-
import
|
|
3742
|
-
import
|
|
4480
|
+
import path9 from "path";
|
|
4481
|
+
import fs8 from "fs/promises";
|
|
3743
4482
|
import { useFunctions } from "../src/constructs/Function.js";
|
|
3744
4483
|
var useRuntimeHandlers, useFunctionBuilder;
|
|
3745
|
-
var
|
|
4484
|
+
var init_handlers2 = __esm({
|
|
3746
4485
|
"src/runtime/handlers.ts"() {
|
|
3747
4486
|
"use strict";
|
|
3748
4487
|
init_context();
|
|
@@ -3775,9 +4514,10 @@ var init_handlers = __esm({
|
|
|
3775
4514
|
errors: [`Function with ID "${functionID}" not found`]
|
|
3776
4515
|
};
|
|
3777
4516
|
const handler = result.for(func.runtime);
|
|
3778
|
-
const out =
|
|
3779
|
-
await
|
|
3780
|
-
await
|
|
4517
|
+
const out = path9.join(project.paths.artifacts, functionID);
|
|
4518
|
+
await fs8.rm(out, { recursive: true, force: true });
|
|
4519
|
+
await fs8.mkdir(out, { recursive: true });
|
|
4520
|
+
bus.publish("function.build.started", { functionID });
|
|
3781
4521
|
if (func.hooks?.beforeBuild)
|
|
3782
4522
|
await func.hooks.beforeBuild(func, out);
|
|
3783
4523
|
const built = await handler.build({
|
|
@@ -3796,22 +4536,22 @@ var init_handlers = __esm({
|
|
|
3796
4536
|
if (func.copyFiles) {
|
|
3797
4537
|
await Promise.all(
|
|
3798
4538
|
func.copyFiles.map(async (entry) => {
|
|
3799
|
-
const fromPath =
|
|
4539
|
+
const fromPath = path9.join(project.paths.root, entry.from);
|
|
3800
4540
|
const to = entry.to || entry.from;
|
|
3801
|
-
if (
|
|
4541
|
+
if (path9.isAbsolute(to))
|
|
3802
4542
|
throw new Error(
|
|
3803
4543
|
`Copy destination path "${to}" must be relative`
|
|
3804
4544
|
);
|
|
3805
|
-
const toPath =
|
|
4545
|
+
const toPath = path9.join(out, to);
|
|
3806
4546
|
if (mode === "deploy")
|
|
3807
|
-
await
|
|
4547
|
+
await fs8.cp(fromPath, toPath, {
|
|
3808
4548
|
recursive: true
|
|
3809
4549
|
});
|
|
3810
4550
|
if (mode === "start") {
|
|
3811
4551
|
try {
|
|
3812
|
-
const dir =
|
|
3813
|
-
await
|
|
3814
|
-
await
|
|
4552
|
+
const dir = path9.dirname(toPath);
|
|
4553
|
+
await fs8.mkdir(dir, { recursive: true });
|
|
4554
|
+
await fs8.symlink(fromPath, toPath);
|
|
3815
4555
|
} catch (ex) {
|
|
3816
4556
|
Logger.debug("Failed to symlink", fromPath, toPath, ex);
|
|
3817
4557
|
}
|
|
@@ -3921,8 +4661,8 @@ var init_server = __esm({
|
|
|
3921
4661
|
const value = queue?.shift();
|
|
3922
4662
|
if (value)
|
|
3923
4663
|
return value;
|
|
3924
|
-
return new Promise((
|
|
3925
|
-
workersWaiting.set(workerID,
|
|
4664
|
+
return new Promise((resolve2, reject) => {
|
|
4665
|
+
workersWaiting.set(workerID, resolve2);
|
|
3926
4666
|
});
|
|
3927
4667
|
}
|
|
3928
4668
|
workers.subscribe("worker.exited", async (evt) => {
|
|
@@ -4091,7 +4831,7 @@ var init_workers = __esm({
|
|
|
4091
4831
|
"use strict";
|
|
4092
4832
|
init_context();
|
|
4093
4833
|
init_bus();
|
|
4094
|
-
|
|
4834
|
+
init_handlers2();
|
|
4095
4835
|
init_server();
|
|
4096
4836
|
useRuntimeWorkers = Context.memo(async () => {
|
|
4097
4837
|
const workers = /* @__PURE__ */ new Map();
|
|
@@ -4133,6 +4873,7 @@ var init_workers = __esm({
|
|
|
4133
4873
|
await handler.startWorker({
|
|
4134
4874
|
...build2,
|
|
4135
4875
|
workerID: evt.properties.workerID,
|
|
4876
|
+
functionID: evt.properties.functionID,
|
|
4136
4877
|
environment: evt.properties.env,
|
|
4137
4878
|
url: `${server.url}/${evt.properties.workerID}/${server.API_VERSION}`,
|
|
4138
4879
|
runtime: props.runtime
|
|
@@ -4198,7 +4939,7 @@ var FRAMEWORK_MAP, BOOTSTRAP_MAP, useDotnetHandler;
|
|
|
4198
4939
|
var init_dotnet = __esm({
|
|
4199
4940
|
"src/runtime/handlers/dotnet.ts"() {
|
|
4200
4941
|
"use strict";
|
|
4201
|
-
|
|
4942
|
+
init_handlers2();
|
|
4202
4943
|
init_workers();
|
|
4203
4944
|
init_context();
|
|
4204
4945
|
init_server();
|
|
@@ -4326,8 +5067,8 @@ var node_exports = {};
|
|
|
4326
5067
|
__export(node_exports, {
|
|
4327
5068
|
useNodeHandler: () => useNodeHandler
|
|
4328
5069
|
});
|
|
4329
|
-
import
|
|
4330
|
-
import
|
|
5070
|
+
import path10 from "path";
|
|
5071
|
+
import fs9 from "fs/promises";
|
|
4331
5072
|
import { exec as exec2 } from "child_process";
|
|
4332
5073
|
import fsSync2 from "fs";
|
|
4333
5074
|
import esbuild2 from "esbuild";
|
|
@@ -4338,7 +5079,7 @@ var init_node = __esm({
|
|
|
4338
5079
|
"src/runtime/handlers/node.ts"() {
|
|
4339
5080
|
"use strict";
|
|
4340
5081
|
init_project();
|
|
4341
|
-
|
|
5082
|
+
init_handlers2();
|
|
4342
5083
|
init_workers();
|
|
4343
5084
|
init_context();
|
|
4344
5085
|
init_error();
|
|
@@ -4354,7 +5095,7 @@ var init_node = __esm({
|
|
|
4354
5095
|
const result = cache[input.functionID];
|
|
4355
5096
|
if (!result)
|
|
4356
5097
|
return false;
|
|
4357
|
-
const relative =
|
|
5098
|
+
const relative = path10.relative(project.paths.root, input.file).split(path10.sep).join(path10.posix.sep);
|
|
4358
5099
|
return Boolean(result.metafile?.inputs[relative]);
|
|
4359
5100
|
},
|
|
4360
5101
|
canHandle: (input) => input.startsWith("nodejs"),
|
|
@@ -4392,7 +5133,7 @@ var init_node = __esm({
|
|
|
4392
5133
|
},
|
|
4393
5134
|
build: async (input) => {
|
|
4394
5135
|
const exists = cache[input.functionID];
|
|
4395
|
-
const parsed =
|
|
5136
|
+
const parsed = path10.parse(input.props.handler);
|
|
4396
5137
|
const file = [
|
|
4397
5138
|
".ts",
|
|
4398
5139
|
".tsx",
|
|
@@ -4402,7 +5143,7 @@ var init_node = __esm({
|
|
|
4402
5143
|
".jsx",
|
|
4403
5144
|
".mjs",
|
|
4404
5145
|
".cjs"
|
|
4405
|
-
].map((ext) =>
|
|
5146
|
+
].map((ext) => path10.join(parsed.dir, parsed.name + ext)).find((file2) => {
|
|
4406
5147
|
return fsSync2.existsSync(file2);
|
|
4407
5148
|
});
|
|
4408
5149
|
if (!file)
|
|
@@ -4412,17 +5153,17 @@ var init_node = __esm({
|
|
|
4412
5153
|
};
|
|
4413
5154
|
const nodejs = input.props.nodejs || {};
|
|
4414
5155
|
const isESM = (nodejs.format || "esm") === "esm";
|
|
4415
|
-
const relative =
|
|
5156
|
+
const relative = path10.relative(
|
|
4416
5157
|
project.paths.root,
|
|
4417
|
-
|
|
5158
|
+
path10.resolve(parsed.dir)
|
|
4418
5159
|
);
|
|
4419
5160
|
const extension = isESM ? ".mjs" : ".cjs";
|
|
4420
|
-
const target =
|
|
5161
|
+
const target = path10.join(
|
|
4421
5162
|
input.out,
|
|
4422
|
-
!relative.startsWith("..") && !
|
|
5163
|
+
!relative.startsWith("..") && !path10.isAbsolute(input.props.handler) ? relative : "",
|
|
4423
5164
|
parsed.name + extension
|
|
4424
5165
|
);
|
|
4425
|
-
const handler =
|
|
5166
|
+
const handler = path10.relative(input.out, target.replace(extension, parsed.ext)).split(path10.sep).join(path10.posix.sep);
|
|
4426
5167
|
if (exists?.rebuild) {
|
|
4427
5168
|
const result = await exists.rebuild();
|
|
4428
5169
|
cache[input.functionID] = result;
|
|
@@ -4481,32 +5222,32 @@ var init_node = __esm({
|
|
|
4481
5222
|
...nodejs.install || [],
|
|
4482
5223
|
...forceExternal.filter((pkg) => pkg !== "aws-sdk").filter((pkg) => !external?.includes(pkg)).filter(
|
|
4483
5224
|
(pkg) => Object.values(result.metafile?.inputs || {}).some(
|
|
4484
|
-
({ imports }) => imports.some(({ path:
|
|
5225
|
+
({ imports }) => imports.some(({ path: path22 }) => path22 === pkg)
|
|
4485
5226
|
)
|
|
4486
5227
|
)
|
|
4487
5228
|
];
|
|
4488
5229
|
const warnings = [];
|
|
4489
5230
|
Object.entries(result.metafile?.inputs || {}).forEach(
|
|
4490
|
-
([inputPath, { imports }]) => imports.filter(({ path:
|
|
5231
|
+
([inputPath, { imports }]) => imports.filter(({ path: path22 }) => path22.includes("sst/constructs")).forEach(({ path: path22 }) => {
|
|
4491
5232
|
warnings.push(
|
|
4492
|
-
`You are importing from "${
|
|
5233
|
+
`You are importing from "${path22}" in "${inputPath}". Did you mean to import from "sst/node"?`
|
|
4493
5234
|
);
|
|
4494
5235
|
})
|
|
4495
5236
|
);
|
|
4496
5237
|
async function find2(dir, target2) {
|
|
4497
5238
|
if (dir === "/")
|
|
4498
5239
|
throw new VisibleError("Could not find a package.json file");
|
|
4499
|
-
if (await
|
|
5240
|
+
if (await fs9.access(path10.join(dir, target2)).then(() => true).catch(() => false))
|
|
4500
5241
|
return dir;
|
|
4501
|
-
return find2(
|
|
5242
|
+
return find2(path10.join(dir, ".."), target2);
|
|
4502
5243
|
}
|
|
4503
5244
|
if (input.mode === "deploy" && installPackages) {
|
|
4504
5245
|
const src = await find2(parsed.dir, "package.json");
|
|
4505
5246
|
const json = JSON.parse(
|
|
4506
|
-
await
|
|
5247
|
+
await fs9.readFile(path10.join(src, "package.json")).then((x) => x.toString())
|
|
4507
5248
|
);
|
|
4508
|
-
|
|
4509
|
-
|
|
5249
|
+
await fs9.writeFile(
|
|
5250
|
+
path10.join(input.out, "package.json"),
|
|
4510
5251
|
JSON.stringify({
|
|
4511
5252
|
dependencies: Object.fromEntries(
|
|
4512
5253
|
installPackages.map((x) => [x, json.dependencies?.[x] || "*"])
|
|
@@ -4520,24 +5261,24 @@ var init_node = __esm({
|
|
|
4520
5261
|
input.props.architecture === "arm_64" ? "--arch=arm64" : "--arch=x64"
|
|
4521
5262
|
);
|
|
4522
5263
|
}
|
|
4523
|
-
await new Promise((
|
|
4524
|
-
exec2(cmd.join(" "), { cwd: input.out }, (
|
|
4525
|
-
if (
|
|
4526
|
-
reject(
|
|
5264
|
+
await new Promise((resolve2, reject) => {
|
|
5265
|
+
exec2(cmd.join(" "), { cwd: input.out }, (error3) => {
|
|
5266
|
+
if (error3) {
|
|
5267
|
+
reject(error3);
|
|
4527
5268
|
}
|
|
4528
|
-
|
|
5269
|
+
resolve2();
|
|
4529
5270
|
});
|
|
4530
5271
|
});
|
|
4531
5272
|
}
|
|
4532
5273
|
if (input.mode === "start") {
|
|
4533
|
-
const dir =
|
|
5274
|
+
const dir = path10.join(
|
|
4534
5275
|
await find2(parsed.dir, "package.json"),
|
|
4535
5276
|
"node_modules"
|
|
4536
5277
|
);
|
|
4537
5278
|
try {
|
|
4538
|
-
await
|
|
4539
|
-
|
|
4540
|
-
|
|
5279
|
+
await fs9.symlink(
|
|
5280
|
+
path10.resolve(dir),
|
|
5281
|
+
path10.resolve(path10.join(input.out, "node_modules")),
|
|
4541
5282
|
"dir"
|
|
4542
5283
|
);
|
|
4543
5284
|
} catch {
|
|
@@ -4576,22 +5317,22 @@ var go_exports = {};
|
|
|
4576
5317
|
__export(go_exports, {
|
|
4577
5318
|
useGoHandler: () => useGoHandler
|
|
4578
5319
|
});
|
|
4579
|
-
import
|
|
4580
|
-
import
|
|
4581
|
-
import
|
|
5320
|
+
import path11 from "path";
|
|
5321
|
+
import fs10 from "fs/promises";
|
|
5322
|
+
import os4 from "os";
|
|
4582
5323
|
import { spawn as spawn2 } from "child_process";
|
|
4583
5324
|
async function find(dir, target) {
|
|
4584
5325
|
if (dir === "/")
|
|
4585
5326
|
throw new VisibleError(`Could not find a ${target} file`);
|
|
4586
|
-
if (await
|
|
5327
|
+
if (await fs10.access(path11.join(dir, target)).then(() => true).catch(() => false))
|
|
4587
5328
|
return dir;
|
|
4588
|
-
return find(
|
|
5329
|
+
return find(path11.join(dir, ".."), target);
|
|
4589
5330
|
}
|
|
4590
5331
|
var useGoHandler;
|
|
4591
5332
|
var init_go = __esm({
|
|
4592
5333
|
"src/runtime/handlers/go.ts"() {
|
|
4593
5334
|
"use strict";
|
|
4594
|
-
|
|
5335
|
+
init_handlers2();
|
|
4595
5336
|
init_workers();
|
|
4596
5337
|
init_context();
|
|
4597
5338
|
init_error();
|
|
@@ -4614,7 +5355,7 @@ var init_go = __esm({
|
|
|
4614
5355
|
},
|
|
4615
5356
|
canHandle: (input) => input.startsWith("go"),
|
|
4616
5357
|
startWorker: async (input) => {
|
|
4617
|
-
const proc = spawn2(
|
|
5358
|
+
const proc = spawn2(path11.join(input.out, handlerName), {
|
|
4618
5359
|
env: {
|
|
4619
5360
|
...process.env,
|
|
4620
5361
|
...input.environment,
|
|
@@ -4640,14 +5381,14 @@ var init_go = __esm({
|
|
|
4640
5381
|
}
|
|
4641
5382
|
},
|
|
4642
5383
|
build: async (input) => {
|
|
4643
|
-
const parsed =
|
|
5384
|
+
const parsed = path11.parse(input.props.handler);
|
|
4644
5385
|
const project = await find(parsed.dir, "go.mod");
|
|
4645
5386
|
sources.set(input.functionID, project);
|
|
4646
|
-
const src =
|
|
5387
|
+
const src = path11.relative(project, input.props.handler);
|
|
4647
5388
|
if (input.mode === "start") {
|
|
4648
5389
|
try {
|
|
4649
|
-
const target =
|
|
4650
|
-
const srcPath =
|
|
5390
|
+
const target = path11.join(input.out, handlerName);
|
|
5391
|
+
const srcPath = os4.platform() === "win32" ? src.replaceAll("\\", "\\\\") : src;
|
|
4651
5392
|
const result = await execAsync(
|
|
4652
5393
|
`go build -ldflags "-s -w" -o "${target}" ./${srcPath}`,
|
|
4653
5394
|
{
|
|
@@ -4666,8 +5407,8 @@ var init_go = __esm({
|
|
|
4666
5407
|
}
|
|
4667
5408
|
if (input.mode === "deploy") {
|
|
4668
5409
|
try {
|
|
4669
|
-
const target =
|
|
4670
|
-
const srcPath =
|
|
5410
|
+
const target = path11.join(input.out, "bootstrap");
|
|
5411
|
+
const srcPath = os4.platform() === "win32" ? src.replaceAll("\\", "\\\\") : src;
|
|
4671
5412
|
await execAsync(
|
|
4672
5413
|
`go build -ldflags "-s -w" -o "${target}" ./${srcPath}`,
|
|
4673
5414
|
{
|
|
@@ -4697,20 +5438,156 @@ var init_go = __esm({
|
|
|
4697
5438
|
}
|
|
4698
5439
|
});
|
|
4699
5440
|
|
|
5441
|
+
// src/runtime/handlers/container.ts
|
|
5442
|
+
var container_exports = {};
|
|
5443
|
+
__export(container_exports, {
|
|
5444
|
+
useContainerHandler: () => useContainerHandler
|
|
5445
|
+
});
|
|
5446
|
+
import { spawn as spawn3 } from "child_process";
|
|
5447
|
+
var useContainerHandler;
|
|
5448
|
+
var init_container = __esm({
|
|
5449
|
+
"src/runtime/handlers/container.ts"() {
|
|
5450
|
+
"use strict";
|
|
5451
|
+
init_handlers2();
|
|
5452
|
+
init_workers();
|
|
5453
|
+
init_context();
|
|
5454
|
+
init_error();
|
|
5455
|
+
init_server();
|
|
5456
|
+
init_fs();
|
|
5457
|
+
init_process();
|
|
5458
|
+
useContainerHandler = Context.memo(async () => {
|
|
5459
|
+
const workers = await useRuntimeWorkers();
|
|
5460
|
+
const server = await useRuntimeServerConfig();
|
|
5461
|
+
const handlers = useRuntimeHandlers();
|
|
5462
|
+
const containers = /* @__PURE__ */ new Map();
|
|
5463
|
+
const sources = /* @__PURE__ */ new Map();
|
|
5464
|
+
handlers.register({
|
|
5465
|
+
shouldBuild: (input) => {
|
|
5466
|
+
const parent = sources.get(input.functionID);
|
|
5467
|
+
if (!parent)
|
|
5468
|
+
return false;
|
|
5469
|
+
return isChild(parent, input.file);
|
|
5470
|
+
},
|
|
5471
|
+
canHandle: (input) => input.startsWith("container"),
|
|
5472
|
+
startWorker: async (input) => {
|
|
5473
|
+
const name = `sst-workerID-${input.workerID}-${Date.now()}`;
|
|
5474
|
+
const proc = spawn3(
|
|
5475
|
+
"docker",
|
|
5476
|
+
[
|
|
5477
|
+
"run",
|
|
5478
|
+
"--rm",
|
|
5479
|
+
"--network=host",
|
|
5480
|
+
`--name=${name}`,
|
|
5481
|
+
...Object.entries({
|
|
5482
|
+
...input.environment,
|
|
5483
|
+
IS_LOCAL: "true",
|
|
5484
|
+
AWS_LAMBDA_RUNTIME_API: `host.docker.internal:${server.port}/${input.workerID}`
|
|
5485
|
+
}).map(([key, value]) => ["-e", `${key}=${value}`]).flat(),
|
|
5486
|
+
`sst-dev:${input.functionID}`
|
|
5487
|
+
],
|
|
5488
|
+
{
|
|
5489
|
+
env: {
|
|
5490
|
+
...process.env
|
|
5491
|
+
},
|
|
5492
|
+
cwd: input.out
|
|
5493
|
+
}
|
|
5494
|
+
);
|
|
5495
|
+
proc.on("exit", () => {
|
|
5496
|
+
workers.exited(input.workerID);
|
|
5497
|
+
});
|
|
5498
|
+
proc.stdout.on("data", (data2) => {
|
|
5499
|
+
workers.stdout(input.workerID, data2.toString());
|
|
5500
|
+
});
|
|
5501
|
+
proc.stderr.on("data", (data2) => {
|
|
5502
|
+
workers.stdout(input.workerID, data2.toString());
|
|
5503
|
+
});
|
|
5504
|
+
containers.set(input.workerID, name);
|
|
5505
|
+
},
|
|
5506
|
+
stopWorker: async (workerID) => {
|
|
5507
|
+
const name = containers.get(workerID);
|
|
5508
|
+
if (name) {
|
|
5509
|
+
try {
|
|
5510
|
+
await execAsync(`docker kill ${name}`, {
|
|
5511
|
+
env: {
|
|
5512
|
+
...process.env
|
|
5513
|
+
}
|
|
5514
|
+
});
|
|
5515
|
+
} catch (ex) {
|
|
5516
|
+
console.error(ex);
|
|
5517
|
+
throw new VisibleError(`Could not stop docker container ${name}`);
|
|
5518
|
+
}
|
|
5519
|
+
containers.delete(workerID);
|
|
5520
|
+
}
|
|
5521
|
+
},
|
|
5522
|
+
build: async (input) => {
|
|
5523
|
+
const project = input.props.handler;
|
|
5524
|
+
sources.set(input.functionID, project);
|
|
5525
|
+
if (input.mode === "start") {
|
|
5526
|
+
try {
|
|
5527
|
+
const result = await execAsync(
|
|
5528
|
+
`docker build -t sst-dev:${input.functionID} .`,
|
|
5529
|
+
{
|
|
5530
|
+
cwd: project,
|
|
5531
|
+
env: {
|
|
5532
|
+
...process.env
|
|
5533
|
+
}
|
|
5534
|
+
}
|
|
5535
|
+
);
|
|
5536
|
+
} catch (ex) {
|
|
5537
|
+
return {
|
|
5538
|
+
type: "error",
|
|
5539
|
+
errors: [String(ex)]
|
|
5540
|
+
};
|
|
5541
|
+
}
|
|
5542
|
+
}
|
|
5543
|
+
if (input.mode === "deploy") {
|
|
5544
|
+
try {
|
|
5545
|
+
const platform = input.props.architecture === "arm_64" ? "linux/arm64" : "linux/amd64";
|
|
5546
|
+
await execAsync(
|
|
5547
|
+
[
|
|
5548
|
+
`docker build`,
|
|
5549
|
+
`-t sst-build:${input.functionID}`,
|
|
5550
|
+
`--platform ${platform}`,
|
|
5551
|
+
`.`
|
|
5552
|
+
].join(" "),
|
|
5553
|
+
{
|
|
5554
|
+
cwd: project,
|
|
5555
|
+
env: {
|
|
5556
|
+
...process.env
|
|
5557
|
+
}
|
|
5558
|
+
}
|
|
5559
|
+
);
|
|
5560
|
+
} catch (ex) {
|
|
5561
|
+
return {
|
|
5562
|
+
type: "error",
|
|
5563
|
+
errors: [String(ex)]
|
|
5564
|
+
};
|
|
5565
|
+
}
|
|
5566
|
+
}
|
|
5567
|
+
return {
|
|
5568
|
+
type: "success",
|
|
5569
|
+
handler: "not required for container"
|
|
5570
|
+
};
|
|
5571
|
+
}
|
|
5572
|
+
});
|
|
5573
|
+
});
|
|
5574
|
+
}
|
|
5575
|
+
});
|
|
5576
|
+
|
|
4700
5577
|
// src/runtime/handlers/rust.ts
|
|
4701
5578
|
var rust_exports = {};
|
|
4702
5579
|
__export(rust_exports, {
|
|
4703
5580
|
useRustHandler: () => useRustHandler
|
|
4704
5581
|
});
|
|
4705
|
-
import
|
|
4706
|
-
import
|
|
4707
|
-
import { exec as exec4, spawn as
|
|
5582
|
+
import path12 from "path";
|
|
5583
|
+
import fs11 from "fs/promises";
|
|
5584
|
+
import { exec as exec4, spawn as spawn4 } from "child_process";
|
|
4708
5585
|
import { promisify as promisify2 } from "util";
|
|
4709
5586
|
var execAsync2, useRustHandler;
|
|
4710
5587
|
var init_rust = __esm({
|
|
4711
5588
|
"src/runtime/handlers/rust.ts"() {
|
|
4712
5589
|
"use strict";
|
|
4713
|
-
|
|
5590
|
+
init_handlers2();
|
|
4714
5591
|
init_workers();
|
|
4715
5592
|
init_context();
|
|
4716
5593
|
init_error();
|
|
@@ -4736,7 +5613,7 @@ var init_rust = __esm({
|
|
|
4736
5613
|
},
|
|
4737
5614
|
canHandle: (input) => input.startsWith("rust"),
|
|
4738
5615
|
startWorker: async (input) => {
|
|
4739
|
-
const proc =
|
|
5616
|
+
const proc = spawn4(path12.join(input.out, handlerName), {
|
|
4740
5617
|
env: {
|
|
4741
5618
|
...process.env,
|
|
4742
5619
|
...input.environment,
|
|
@@ -4764,7 +5641,7 @@ var init_rust = __esm({
|
|
|
4764
5641
|
}
|
|
4765
5642
|
},
|
|
4766
5643
|
build: async (input) => {
|
|
4767
|
-
const parsed =
|
|
5644
|
+
const parsed = path12.parse(input.props.handler);
|
|
4768
5645
|
const project = await findAbove(parsed.dir, "Cargo.toml");
|
|
4769
5646
|
if (!project)
|
|
4770
5647
|
return {
|
|
@@ -4780,9 +5657,9 @@ var init_rust = __esm({
|
|
|
4780
5657
|
...process.env
|
|
4781
5658
|
}
|
|
4782
5659
|
});
|
|
4783
|
-
await
|
|
4784
|
-
|
|
4785
|
-
|
|
5660
|
+
await fs11.cp(
|
|
5661
|
+
path12.join(project, `target/debug`, parsed.name),
|
|
5662
|
+
path12.join(input.out, "handler")
|
|
4786
5663
|
);
|
|
4787
5664
|
} catch (ex) {
|
|
4788
5665
|
throw new VisibleError("Failed to build");
|
|
@@ -4796,9 +5673,9 @@ var init_rust = __esm({
|
|
|
4796
5673
|
...process.env
|
|
4797
5674
|
}
|
|
4798
5675
|
});
|
|
4799
|
-
await
|
|
4800
|
-
|
|
4801
|
-
|
|
5676
|
+
await fs11.cp(
|
|
5677
|
+
path12.join(project, `target/lambda/`, parsed.name, "bootstrap"),
|
|
5678
|
+
path12.join(input.out, "bootstrap")
|
|
4802
5679
|
);
|
|
4803
5680
|
} catch (ex) {
|
|
4804
5681
|
throw new VisibleError("Failed to build");
|
|
@@ -4815,9 +5692,9 @@ var init_rust = __esm({
|
|
|
4815
5692
|
});
|
|
4816
5693
|
|
|
4817
5694
|
// src/runtime/handlers/pythonBundling.ts
|
|
4818
|
-
import
|
|
5695
|
+
import fs12 from "fs";
|
|
4819
5696
|
import url5 from "url";
|
|
4820
|
-
import
|
|
5697
|
+
import path13 from "path";
|
|
4821
5698
|
import { DockerImage, FileSystem } from "aws-cdk-lib/core";
|
|
4822
5699
|
function bundle(options) {
|
|
4823
5700
|
const { entry, runtime, architecture, outputPathSuffix, installCommands } = options;
|
|
@@ -4828,9 +5705,9 @@ function bundle(options) {
|
|
|
4828
5705
|
stagedir
|
|
4829
5706
|
);
|
|
4830
5707
|
const dockerfile = hasInstallCommands ? "Dockerfile.custom" : hasDeps ? "Dockerfile.dependencies" : "Dockerfile";
|
|
4831
|
-
|
|
4832
|
-
|
|
4833
|
-
|
|
5708
|
+
fs12.copyFileSync(
|
|
5709
|
+
path13.join(__dirname, "../../support/python-runtime", dockerfile),
|
|
5710
|
+
path13.join(stagedir, dockerfile)
|
|
4834
5711
|
);
|
|
4835
5712
|
const image = DockerImage.fromBuild(stagedir, {
|
|
4836
5713
|
buildArgs: {
|
|
@@ -4838,21 +5715,21 @@ function bundle(options) {
|
|
|
4838
5715
|
},
|
|
4839
5716
|
file: dockerfile
|
|
4840
5717
|
});
|
|
4841
|
-
const outputPath =
|
|
5718
|
+
const outputPath = path13.join(options.out, outputPathSuffix);
|
|
4842
5719
|
if (hasDeps || hasInstallCommands) {
|
|
4843
5720
|
image.cp(`${BUNDLER_DEPENDENCIES_CACHE}/.`, outputPath);
|
|
4844
5721
|
}
|
|
4845
|
-
|
|
5722
|
+
fs12.cpSync(entry, outputPath, {
|
|
4846
5723
|
recursive: true
|
|
4847
5724
|
});
|
|
4848
5725
|
}
|
|
4849
5726
|
function stageDependencies(entry, stagedir) {
|
|
4850
5727
|
const prefixes = ["Pipfile", "pyproject", "poetry", "requirements.txt"];
|
|
4851
5728
|
let found = false;
|
|
4852
|
-
for (const file of
|
|
5729
|
+
for (const file of fs12.readdirSync(entry)) {
|
|
4853
5730
|
for (const prefix of prefixes) {
|
|
4854
5731
|
if (file.startsWith(prefix)) {
|
|
4855
|
-
|
|
5732
|
+
fs12.copyFileSync(path13.join(entry, file), path13.join(stagedir, file));
|
|
4856
5733
|
found = true;
|
|
4857
5734
|
}
|
|
4858
5735
|
}
|
|
@@ -4862,9 +5739,9 @@ function stageDependencies(entry, stagedir) {
|
|
|
4862
5739
|
function stageInstallCommands(installCommands, stagedir) {
|
|
4863
5740
|
let found = false;
|
|
4864
5741
|
if (installCommands.length > 0) {
|
|
4865
|
-
const filePath =
|
|
4866
|
-
|
|
4867
|
-
|
|
5742
|
+
const filePath = path13.join(stagedir, "sst-deps-install-command.sh");
|
|
5743
|
+
fs12.writeFileSync(filePath, installCommands.join(" && "));
|
|
5744
|
+
fs12.chmodSync(filePath, "755");
|
|
4868
5745
|
found = true;
|
|
4869
5746
|
}
|
|
4870
5747
|
return found;
|
|
@@ -4873,7 +5750,7 @@ var __dirname, BUNDLER_DEPENDENCIES_CACHE;
|
|
|
4873
5750
|
var init_pythonBundling = __esm({
|
|
4874
5751
|
"src/runtime/handlers/pythonBundling.ts"() {
|
|
4875
5752
|
"use strict";
|
|
4876
|
-
__dirname =
|
|
5753
|
+
__dirname = path13.dirname(url5.fileURLToPath(import.meta.url));
|
|
4877
5754
|
BUNDLER_DEPENDENCIES_CACHE = "/var/dependencies";
|
|
4878
5755
|
}
|
|
4879
5756
|
});
|
|
@@ -4883,17 +5760,17 @@ var python_exports = {};
|
|
|
4883
5760
|
__export(python_exports, {
|
|
4884
5761
|
usePythonHandler: () => usePythonHandler
|
|
4885
5762
|
});
|
|
4886
|
-
import
|
|
4887
|
-
import { exec as exec5, spawn as
|
|
5763
|
+
import path14 from "path";
|
|
5764
|
+
import { exec as exec5, spawn as spawn5 } from "child_process";
|
|
4888
5765
|
import { promisify as promisify3 } from "util";
|
|
4889
5766
|
import { Runtime } from "aws-cdk-lib/aws-lambda";
|
|
4890
|
-
import
|
|
5767
|
+
import os5 from "os";
|
|
4891
5768
|
import url6 from "url";
|
|
4892
5769
|
var execAsync3, RUNTIME_MAP, usePythonHandler;
|
|
4893
5770
|
var init_python = __esm({
|
|
4894
5771
|
"src/runtime/handlers/python.ts"() {
|
|
4895
5772
|
"use strict";
|
|
4896
|
-
|
|
5773
|
+
init_handlers2();
|
|
4897
5774
|
init_workers();
|
|
4898
5775
|
init_context();
|
|
4899
5776
|
init_server();
|
|
@@ -4905,7 +5782,8 @@ var init_python = __esm({
|
|
|
4905
5782
|
"python3.6": Runtime.PYTHON_3_6,
|
|
4906
5783
|
"python3.7": Runtime.PYTHON_3_7,
|
|
4907
5784
|
"python3.8": Runtime.PYTHON_3_8,
|
|
4908
|
-
"python3.9": Runtime.PYTHON_3_9
|
|
5785
|
+
"python3.9": Runtime.PYTHON_3_9,
|
|
5786
|
+
"python3.10": Runtime.PYTHON_3_10
|
|
4909
5787
|
};
|
|
4910
5788
|
usePythonHandler = Context.memo(async () => {
|
|
4911
5789
|
const workers = await useRuntimeWorkers();
|
|
@@ -4933,10 +5811,10 @@ var init_python = __esm({
|
|
|
4933
5811
|
const src = await findSrc(input.handler);
|
|
4934
5812
|
if (!src)
|
|
4935
5813
|
throw new Error(`Could not find src for ${input.handler}`);
|
|
4936
|
-
const parsed =
|
|
4937
|
-
const target = [...parsed.dir.split(
|
|
4938
|
-
const proc =
|
|
4939
|
-
|
|
5814
|
+
const parsed = path14.parse(path14.relative(src, input.handler));
|
|
5815
|
+
const target = [...parsed.dir.split(path14.sep), parsed.name].join(".");
|
|
5816
|
+
const proc = spawn5(
|
|
5817
|
+
os5.platform() === "win32" ? "python.exe" : "python3",
|
|
4940
5818
|
[
|
|
4941
5819
|
"-u",
|
|
4942
5820
|
url6.fileURLToPath(
|
|
@@ -4996,7 +5874,7 @@ var init_python = __esm({
|
|
|
4996
5874
|
});
|
|
4997
5875
|
return {
|
|
4998
5876
|
type: "success",
|
|
4999
|
-
handler:
|
|
5877
|
+
handler: path14.relative(src, path14.resolve(input.props.handler)).split(path14.sep).join(path14.posix.sep)
|
|
5000
5878
|
};
|
|
5001
5879
|
}
|
|
5002
5880
|
});
|
|
@@ -5009,21 +5887,21 @@ var java_exports = {};
|
|
|
5009
5887
|
__export(java_exports, {
|
|
5010
5888
|
useJavaHandler: () => useJavaHandler
|
|
5011
5889
|
});
|
|
5012
|
-
import
|
|
5013
|
-
import
|
|
5014
|
-
import
|
|
5015
|
-
import { spawn as
|
|
5890
|
+
import path15 from "path";
|
|
5891
|
+
import fs13 from "fs/promises";
|
|
5892
|
+
import os6 from "os";
|
|
5893
|
+
import { spawn as spawn6 } from "child_process";
|
|
5016
5894
|
import url7 from "url";
|
|
5017
5895
|
import AdmZip from "adm-zip";
|
|
5018
5896
|
async function getGradleBinary(srcPath) {
|
|
5019
|
-
const gradleWrapperPath =
|
|
5897
|
+
const gradleWrapperPath = path15.resolve(path15.join(srcPath, "gradlew"));
|
|
5020
5898
|
return await existsAsync(gradleWrapperPath) ? gradleWrapperPath : "gradle";
|
|
5021
5899
|
}
|
|
5022
5900
|
var useJavaHandler;
|
|
5023
5901
|
var init_java = __esm({
|
|
5024
5902
|
"src/runtime/handlers/java.ts"() {
|
|
5025
5903
|
"use strict";
|
|
5026
|
-
|
|
5904
|
+
init_handlers2();
|
|
5027
5905
|
init_workers();
|
|
5028
5906
|
init_context();
|
|
5029
5907
|
init_server();
|
|
@@ -5048,7 +5926,7 @@ var init_java = __esm({
|
|
|
5048
5926
|
},
|
|
5049
5927
|
canHandle: (input) => input.startsWith("java"),
|
|
5050
5928
|
startWorker: async (input) => {
|
|
5051
|
-
const proc =
|
|
5929
|
+
const proc = spawn6(
|
|
5052
5930
|
`java`,
|
|
5053
5931
|
[
|
|
5054
5932
|
`-cp`,
|
|
@@ -5056,7 +5934,7 @@ var init_java = __esm({
|
|
|
5056
5934
|
url7.fileURLToPath(
|
|
5057
5935
|
new URL("../../support/java-runtime/release/*", import.meta.url)
|
|
5058
5936
|
)
|
|
5059
|
-
].join(
|
|
5937
|
+
].join(os6.platform() === "win32" ? ";" : ":"),
|
|
5060
5938
|
"com.amazonaws.services.lambda.runtime.api.client.AWSLambda",
|
|
5061
5939
|
input.handler
|
|
5062
5940
|
],
|
|
@@ -5100,11 +5978,11 @@ var init_java = __esm({
|
|
|
5100
5978
|
cwd: srcPath
|
|
5101
5979
|
}
|
|
5102
5980
|
);
|
|
5103
|
-
const buildOutput =
|
|
5104
|
-
const zip = (await
|
|
5981
|
+
const buildOutput = path15.join(srcPath, "build", outputDir);
|
|
5982
|
+
const zip = (await fs13.readdir(buildOutput)).find(
|
|
5105
5983
|
(f) => f.endsWith(".zip")
|
|
5106
5984
|
);
|
|
5107
|
-
new AdmZip(
|
|
5985
|
+
new AdmZip(path15.join(buildOutput, zip)).extractAllTo(input.out);
|
|
5108
5986
|
return {
|
|
5109
5987
|
type: "success",
|
|
5110
5988
|
handler: input.props.handler
|
|
@@ -5123,17 +6001,19 @@ var init_java = __esm({
|
|
|
5123
6001
|
|
|
5124
6002
|
// src/stacks/synth.ts
|
|
5125
6003
|
import * as contextproviders from "sst-aws-cdk/lib/context-providers/index.js";
|
|
5126
|
-
import
|
|
6004
|
+
import path16 from "path";
|
|
5127
6005
|
async function synth(opts) {
|
|
5128
6006
|
Logger.debug("Synthesizing stacks...");
|
|
5129
6007
|
const { App: App2 } = await import("../src/constructs/App.js");
|
|
5130
6008
|
const { useNodeHandler: useNodeHandler2 } = await Promise.resolve().then(() => (init_node(), node_exports));
|
|
5131
6009
|
const { useGoHandler: useGoHandler2 } = await Promise.resolve().then(() => (init_go(), go_exports));
|
|
6010
|
+
const { useContainerHandler: useContainerHandler2 } = await Promise.resolve().then(() => (init_container(), container_exports));
|
|
5132
6011
|
const { useRustHandler: useRustHandler2 } = await Promise.resolve().then(() => (init_rust(), rust_exports));
|
|
5133
6012
|
const { usePythonHandler: usePythonHandler2 } = await Promise.resolve().then(() => (init_python(), python_exports));
|
|
5134
6013
|
const { useJavaHandler: useJavaHandler2 } = await Promise.resolve().then(() => (init_java(), java_exports));
|
|
5135
6014
|
useNodeHandler2();
|
|
5136
6015
|
useGoHandler2();
|
|
6016
|
+
useContainerHandler2();
|
|
5137
6017
|
usePythonHandler2();
|
|
5138
6018
|
useJavaHandler2();
|
|
5139
6019
|
useDotnetHandler();
|
|
@@ -5143,7 +6023,7 @@ async function synth(opts) {
|
|
|
5143
6023
|
const identity = await useSTSIdentity();
|
|
5144
6024
|
opts = {
|
|
5145
6025
|
...opts,
|
|
5146
|
-
buildDir: opts.buildDir ||
|
|
6026
|
+
buildDir: opts.buildDir || path16.join(project.paths.out, "dist")
|
|
5147
6027
|
};
|
|
5148
6028
|
const cfg = new Configuration();
|
|
5149
6029
|
await cfg.load();
|
|
@@ -5228,7 +6108,7 @@ async function removeMany(stacks) {
|
|
|
5228
6108
|
const complete = /* @__PURE__ */ new Set();
|
|
5229
6109
|
const todo = new Set(stacks.map((s) => s.id));
|
|
5230
6110
|
const results = {};
|
|
5231
|
-
return new Promise((
|
|
6111
|
+
return new Promise((resolve2) => {
|
|
5232
6112
|
async function trigger() {
|
|
5233
6113
|
for (const stack of stacks) {
|
|
5234
6114
|
if (!todo.has(stack.id))
|
|
@@ -5267,7 +6147,7 @@ async function removeMany(stacks) {
|
|
|
5267
6147
|
}
|
|
5268
6148
|
});
|
|
5269
6149
|
if (complete.size === stacks.length) {
|
|
5270
|
-
|
|
6150
|
+
resolve2(results);
|
|
5271
6151
|
}
|
|
5272
6152
|
trigger();
|
|
5273
6153
|
});
|
|
@@ -5356,9 +6236,9 @@ __export(bootstrap_exports, {
|
|
|
5356
6236
|
useBootstrap: () => useBootstrap
|
|
5357
6237
|
});
|
|
5358
6238
|
import url8 from "url";
|
|
5359
|
-
import
|
|
6239
|
+
import path17 from "path";
|
|
5360
6240
|
import { bold, dim } from "colorette";
|
|
5361
|
-
import { spawn as
|
|
6241
|
+
import { spawn as spawn7 } from "child_process";
|
|
5362
6242
|
import {
|
|
5363
6243
|
DescribeStacksCommand as DescribeStacksCommand2,
|
|
5364
6244
|
CloudFormationClient as CloudFormationClient3
|
|
@@ -5485,7 +6365,7 @@ async function bootstrapSST() {
|
|
|
5485
6365
|
});
|
|
5486
6366
|
const fn = new Function(stack, "MetadataHandler", {
|
|
5487
6367
|
code: Code.fromAsset(
|
|
5488
|
-
|
|
6368
|
+
path17.resolve(__dirname2, "support/bootstrap-metadata-function")
|
|
5489
6369
|
),
|
|
5490
6370
|
handler: "index.handler",
|
|
5491
6371
|
runtime: region?.startsWith("us-gov-") ? Runtime2.NODEJS_16_X : Runtime2.NODEJS_18_X,
|
|
@@ -5546,8 +6426,8 @@ async function bootstrapCDK() {
|
|
|
5546
6426
|
const identity = await useSTSIdentity();
|
|
5547
6427
|
const credentials = await useAWSCredentials();
|
|
5548
6428
|
const { region, profile, cdk } = useProject().config;
|
|
5549
|
-
await new Promise((
|
|
5550
|
-
const proc =
|
|
6429
|
+
await new Promise((resolve2, reject) => {
|
|
6430
|
+
const proc = spawn7(
|
|
5551
6431
|
[
|
|
5552
6432
|
"npx",
|
|
5553
6433
|
"cdk",
|
|
@@ -5584,7 +6464,7 @@ async function bootstrapCDK() {
|
|
|
5584
6464
|
proc.on("exit", (code) => {
|
|
5585
6465
|
Logger.debug("CDK bootstrap exited with code " + code);
|
|
5586
6466
|
if (code === 0) {
|
|
5587
|
-
|
|
6467
|
+
resolve2();
|
|
5588
6468
|
} else {
|
|
5589
6469
|
console.log(bold(dim(stderr)));
|
|
5590
6470
|
reject(new VisibleError(`Failed to bootstrap`));
|
|
@@ -5693,7 +6573,7 @@ __export(server_exports2, {
|
|
|
5693
6573
|
});
|
|
5694
6574
|
import { produceWithPatches, enablePatches } from "immer";
|
|
5695
6575
|
import express2 from "express";
|
|
5696
|
-
import
|
|
6576
|
+
import fs14 from "fs/promises";
|
|
5697
6577
|
import { WebSocketServer } from "ws";
|
|
5698
6578
|
import https3 from "https";
|
|
5699
6579
|
import http from "http";
|
|
@@ -5774,15 +6654,15 @@ async function useLocalServer(opts) {
|
|
|
5774
6654
|
const CERT_PATH = ".sst/localhost.pem";
|
|
5775
6655
|
if (result2.status === 0) {
|
|
5776
6656
|
try {
|
|
5777
|
-
await Promise.all([
|
|
6657
|
+
await Promise.all([fs14.access(KEY_PATH), fs14.access(CERT_PATH)]);
|
|
5778
6658
|
} catch (e) {
|
|
5779
6659
|
sync("mkcert", ["localhost"], {
|
|
5780
6660
|
cwd: ".sst"
|
|
5781
6661
|
});
|
|
5782
6662
|
}
|
|
5783
6663
|
const [key, cert] = await Promise.all([
|
|
5784
|
-
|
|
5785
|
-
|
|
6664
|
+
fs14.readFile(KEY_PATH),
|
|
6665
|
+
fs14.readFile(CERT_PATH)
|
|
5786
6666
|
]);
|
|
5787
6667
|
return https3.createServer(
|
|
5788
6668
|
{
|
|
@@ -6205,10 +7085,10 @@ function printDeploymentResults(assembly, results, remove4) {
|
|
|
6205
7085
|
Colors.line(
|
|
6206
7086
|
` ${Colors.dim(stackNameToId(stack))} ${Colors.dim(result.status)}`
|
|
6207
7087
|
);
|
|
6208
|
-
for (const [id,
|
|
7088
|
+
for (const [id, error3] of Object.entries(result.errors)) {
|
|
6209
7089
|
const readable = logicalIdToCdkPath(assembly, stack, id) || id;
|
|
6210
|
-
Colors.line(` ${Colors.danger.bold(readable + ":")} ${
|
|
6211
|
-
const helper = getHelper(
|
|
7090
|
+
Colors.line(` ${Colors.danger.bold(readable + ":")} ${error3}`);
|
|
7091
|
+
const helper = getHelper(error3);
|
|
6212
7092
|
if (helper) {
|
|
6213
7093
|
Colors.line(` ${Colors.warning.bold("\u2B91 Hint:")} ${helper}`);
|
|
6214
7094
|
}
|
|
@@ -6233,30 +7113,30 @@ function logicalIdToCdkPath(assembly, stack, logicalId) {
|
|
|
6233
7113
|
}
|
|
6234
7114
|
return found.split("/").filter(Boolean).slice(1, -1).join("/");
|
|
6235
7115
|
}
|
|
6236
|
-
function getHelper(
|
|
6237
|
-
return getCloudFrontBehaviorLimitHelper(
|
|
7116
|
+
function getHelper(error3) {
|
|
7117
|
+
return getCloudFrontBehaviorLimitHelper(error3) || getApiAccessLogPermissionsHelper(error3) || getAppSyncMultiResolverHelper(error3) || getApiLogRoleHelper(error3);
|
|
6238
7118
|
}
|
|
6239
|
-
function getCloudFrontBehaviorLimitHelper(
|
|
6240
|
-
if (
|
|
7119
|
+
function getCloudFrontBehaviorLimitHelper(error3) {
|
|
7120
|
+
if (error3.indexOf(
|
|
6241
7121
|
"Your request contains more CacheBehaviors than are allowed per distribution."
|
|
6242
7122
|
) > -1) {
|
|
6243
7123
|
return `This error often occurs when deploying a frontend with a large number of top-level files and folders in the assets directory. Check out this doc on how to resolve the issue - https://docs.sst.dev/known-issues#cloudfront-cachebehaviors-limit-exceeded`;
|
|
6244
7124
|
}
|
|
6245
7125
|
}
|
|
6246
|
-
function getApiAccessLogPermissionsHelper(
|
|
6247
|
-
if (
|
|
7126
|
+
function getApiAccessLogPermissionsHelper(error3) {
|
|
7127
|
+
if (error3.indexOf("Insufficient permissions to enable logging") > -1) {
|
|
6248
7128
|
return `This is a common deploy error. Check out this GitHub issue for more details - https://github.com/serverless-stack/sst/issues/125`;
|
|
6249
7129
|
}
|
|
6250
7130
|
}
|
|
6251
|
-
function getAppSyncMultiResolverHelper(
|
|
6252
|
-
if (
|
|
7131
|
+
function getAppSyncMultiResolverHelper(error3) {
|
|
7132
|
+
if (error3.indexOf(
|
|
6253
7133
|
"Only one resolver is allowed per field. (Service: AWSAppSync"
|
|
6254
7134
|
) > -1) {
|
|
6255
7135
|
return `This is a common error for deploying AppSync APIs. Check out this GitHub issue for more details - https://github.com/aws/aws-cdk/issues/13269`;
|
|
6256
7136
|
}
|
|
6257
7137
|
}
|
|
6258
|
-
function getApiLogRoleHelper(
|
|
6259
|
-
if (
|
|
7138
|
+
function getApiLogRoleHelper(error3) {
|
|
7139
|
+
if (error3.indexOf(
|
|
6260
7140
|
"CloudWatch Logs role ARN must be set in account settings to enable logging (Service: AmazonApiGatewayV2"
|
|
6261
7141
|
) > -1) {
|
|
6262
7142
|
return `This is a common error when configuring Access Log for WebSocket APIs. The AWS API Gateway service in your AWS account does not have permissions to the CloudWatch logs service. Follow this article to create an IAM role for logging to CloudWatch - https://aws.amazon.com/premiumsupport/knowledge-center/api-gateway-cloudwatch-logs/`;
|
|
@@ -6336,16 +7216,16 @@ __export(pothos_exports, {
|
|
|
6336
7216
|
import babel2 from "@babel/core";
|
|
6337
7217
|
import generator from "@babel/generator";
|
|
6338
7218
|
import esbuild3 from "esbuild";
|
|
6339
|
-
import
|
|
6340
|
-
import
|
|
7219
|
+
import fs15 from "fs/promises";
|
|
7220
|
+
import path18 from "path";
|
|
6341
7221
|
import url9 from "url";
|
|
6342
7222
|
async function generate2(opts) {
|
|
6343
7223
|
const { printSchema, lexicographicSortSchema } = await import("graphql");
|
|
6344
7224
|
const contents = await extractSchema(opts);
|
|
6345
|
-
const out =
|
|
6346
|
-
await
|
|
7225
|
+
const out = path18.join(path18.dirname(opts.schema), "out.mjs");
|
|
7226
|
+
await fs15.writeFile(out, contents, "utf8");
|
|
6347
7227
|
const { schema } = await import(url9.pathToFileURL(out).href + "?bust=" + Date.now());
|
|
6348
|
-
await
|
|
7228
|
+
await fs15.rm(out);
|
|
6349
7229
|
const schemaAsString = printSchema(lexicographicSortSchema(schema));
|
|
6350
7230
|
return schemaAsString;
|
|
6351
7231
|
}
|
|
@@ -6383,15 +7263,15 @@ async function extractSchema(opts) {
|
|
|
6383
7263
|
{
|
|
6384
7264
|
name: "pothos-extractor",
|
|
6385
7265
|
visitor: {
|
|
6386
|
-
Program(
|
|
6387
|
-
const dummyResolverId =
|
|
7266
|
+
Program(path22) {
|
|
7267
|
+
const dummyResolverId = path22.scope.generateUidIdentifier("DUMMY_RESOLVER");
|
|
6388
7268
|
const resolverNode = dummyResolver({
|
|
6389
7269
|
dummy_resolver: dummyResolverId
|
|
6390
7270
|
});
|
|
6391
|
-
|
|
6392
|
-
|
|
7271
|
+
path22.unshiftContainer("body", resolverNode);
|
|
7272
|
+
path22.scope.crawl();
|
|
6393
7273
|
let schemaBuilder = null;
|
|
6394
|
-
|
|
7274
|
+
path22.traverse({
|
|
6395
7275
|
ImportDeclaration(declarator) {
|
|
6396
7276
|
if (!declarator)
|
|
6397
7277
|
return;
|
|
@@ -6449,17 +7329,17 @@ async function extractSchema(opts) {
|
|
|
6449
7329
|
);
|
|
6450
7330
|
return contents.code;
|
|
6451
7331
|
}
|
|
6452
|
-
function getBindings(
|
|
7332
|
+
function getBindings(path22, globalPaths) {
|
|
6453
7333
|
const bindings = [];
|
|
6454
|
-
|
|
7334
|
+
path22.traverse({
|
|
6455
7335
|
Expression(expressionPath) {
|
|
6456
7336
|
if (!expressionPath.isIdentifier())
|
|
6457
7337
|
return;
|
|
6458
|
-
const binding =
|
|
7338
|
+
const binding = path22.scope.getBinding(expressionPath);
|
|
6459
7339
|
if (!binding || globalPaths.has(binding.path) || bindings.includes(binding.path))
|
|
6460
7340
|
return;
|
|
6461
7341
|
const rootBinding = findRootBinding(binding.path);
|
|
6462
|
-
if (
|
|
7342
|
+
if (path22 === rootBinding) {
|
|
6463
7343
|
bindings.push(binding.path);
|
|
6464
7344
|
return;
|
|
6465
7345
|
}
|
|
@@ -6472,8 +7352,8 @@ function getBindings(path20, globalPaths) {
|
|
|
6472
7352
|
}
|
|
6473
7353
|
return bindings;
|
|
6474
7354
|
}
|
|
6475
|
-
function findRootBinding(
|
|
6476
|
-
let rootPath =
|
|
7355
|
+
function findRootBinding(path22) {
|
|
7356
|
+
let rootPath = path22;
|
|
6477
7357
|
while (rootPath.parentPath?.node !== void 0 && !rootPath.parentPath?.isProgram()) {
|
|
6478
7358
|
rootPath = rootPath.parentPath;
|
|
6479
7359
|
}
|
|
@@ -6496,10 +7376,10 @@ var pothos_exports2 = {};
|
|
|
6496
7376
|
__export(pothos_exports2, {
|
|
6497
7377
|
usePothosBuilder: () => usePothosBuilder
|
|
6498
7378
|
});
|
|
6499
|
-
import
|
|
7379
|
+
import fs16 from "fs/promises";
|
|
6500
7380
|
import { exec as exec6 } from "child_process";
|
|
6501
7381
|
import { promisify as promisify4 } from "util";
|
|
6502
|
-
import
|
|
7382
|
+
import path19 from "path";
|
|
6503
7383
|
var execAsync4, usePothosBuilder;
|
|
6504
7384
|
var init_pothos2 = __esm({
|
|
6505
7385
|
"src/cli/commands/plugins/pothos.ts"() {
|
|
@@ -6518,7 +7398,7 @@ var init_pothos2 = __esm({
|
|
|
6518
7398
|
schema: route.schema,
|
|
6519
7399
|
internalPackages: route.internalPackages
|
|
6520
7400
|
});
|
|
6521
|
-
await
|
|
7401
|
+
await fs16.writeFile(route.output, schema);
|
|
6522
7402
|
if (Array.isArray(route.commands) && route.commands.length > 0) {
|
|
6523
7403
|
await Promise.all(route.commands.map((cmd) => execAsync4(cmd)));
|
|
6524
7404
|
}
|
|
@@ -6534,9 +7414,9 @@ var init_pothos2 = __esm({
|
|
|
6534
7414
|
if (evt.properties.file.endsWith("out.mjs"))
|
|
6535
7415
|
return;
|
|
6536
7416
|
for (const route of routes) {
|
|
6537
|
-
const dir =
|
|
6538
|
-
const relative =
|
|
6539
|
-
if (relative && !relative.startsWith("..") && !
|
|
7417
|
+
const dir = path19.dirname(route.schema);
|
|
7418
|
+
const relative = path19.relative(dir, evt.properties.file);
|
|
7419
|
+
if (relative && !relative.startsWith("..") && !path19.isAbsolute(relative))
|
|
6540
7420
|
build2(route);
|
|
6541
7421
|
}
|
|
6542
7422
|
});
|
|
@@ -6562,7 +7442,7 @@ __export(kysely_exports, {
|
|
|
6562
7442
|
import { Kysely } from "kysely";
|
|
6563
7443
|
import { DataApiDialect } from "kysely-data-api";
|
|
6564
7444
|
import { RDSData } from "@aws-sdk/client-rds-data";
|
|
6565
|
-
import * as
|
|
7445
|
+
import * as fs17 from "fs/promises";
|
|
6566
7446
|
import {
|
|
6567
7447
|
PostgresDialect,
|
|
6568
7448
|
MysqlDialect,
|
|
@@ -6620,7 +7500,7 @@ var init_kysely = __esm({
|
|
|
6620
7500
|
};
|
|
6621
7501
|
const serializer = new Serializer();
|
|
6622
7502
|
const data2 = serializer.serialize(nodes);
|
|
6623
|
-
await
|
|
7503
|
+
await fs17.writeFile(db.types.path, data2);
|
|
6624
7504
|
}
|
|
6625
7505
|
bus.subscribe("stacks.metadata", (evt) => {
|
|
6626
7506
|
const constructs = Object.values(evt.properties).flat();
|
|
@@ -6995,12 +7875,12 @@ var program = yargs(hideBin(process.argv)).scriptName("sst").option("stage", {
|
|
|
6995
7875
|
const { trackCli: trackCli2 } = await Promise.resolve().then(() => (init_telemetry(), telemetry_exports));
|
|
6996
7876
|
trackCli2(argv._[0]);
|
|
6997
7877
|
}
|
|
6998
|
-
}).version(false).epilogue(`Join the SST community on Discord https://sst.dev/discord`).recommendCommands().demandCommand().strict().fail((_,
|
|
6999
|
-
if (!
|
|
7878
|
+
}).version(false).epilogue(`Join the SST community on Discord https://sst.dev/discord`).recommendCommands().demandCommand().strict().fail((_, error3, yargs2) => {
|
|
7879
|
+
if (!error3) {
|
|
7000
7880
|
yargs2.showHelp();
|
|
7001
7881
|
process.exit(1);
|
|
7002
7882
|
}
|
|
7003
|
-
throw
|
|
7883
|
+
throw error3;
|
|
7004
7884
|
});
|
|
7005
7885
|
|
|
7006
7886
|
// src/cli/sst.ts
|
|
@@ -7033,14 +7913,14 @@ var dev = (program2) => program2.command(
|
|
|
7033
7913
|
const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
|
|
7034
7914
|
const { printHeader: printHeader2 } = await Promise.resolve().then(() => (init_header(), header_exports));
|
|
7035
7915
|
const { mapValues } = await import("remeda");
|
|
7036
|
-
const
|
|
7916
|
+
const path22 = await import("path");
|
|
7037
7917
|
const { useRuntimeWorkers: useRuntimeWorkers2 } = await Promise.resolve().then(() => (init_workers(), workers_exports));
|
|
7038
7918
|
const { useIOTBridge: useIOTBridge2 } = await Promise.resolve().then(() => (init_iot2(), iot_exports2));
|
|
7039
7919
|
const { useRuntimeServer: useRuntimeServer2 } = await Promise.resolve().then(() => (init_server(), server_exports));
|
|
7040
7920
|
const { useBus: useBus2 } = await Promise.resolve().then(() => (init_bus(), bus_exports));
|
|
7041
7921
|
const { useWatcher: useWatcher2 } = await Promise.resolve().then(() => (init_watcher(), watcher_exports));
|
|
7042
7922
|
const { useAppMetadata: useAppMetadata2, saveAppMetadata: saveAppMetadata2, Stacks } = await Promise.resolve().then(() => (init_stacks(), stacks_exports));
|
|
7043
|
-
const { Logger:
|
|
7923
|
+
const { Logger: Logger3 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
|
|
7044
7924
|
const { createSpinner: createSpinner2 } = await Promise.resolve().then(() => (init_spinner(), spinner_exports));
|
|
7045
7925
|
const { bold: bold2, dim: dim2, yellow } = await import("colorette");
|
|
7046
7926
|
const { render } = await import("ink");
|
|
@@ -7048,7 +7928,7 @@ var dev = (program2) => program2.command(
|
|
|
7048
7928
|
const { Context: Context2 } = await Promise.resolve().then(() => (init_context(), context_exports));
|
|
7049
7929
|
const { printDeploymentResults: printDeploymentResults2, DeploymentUI: DeploymentUI2 } = await Promise.resolve().then(() => (init_deploy2(), deploy_exports));
|
|
7050
7930
|
const { useLocalServer: useLocalServer2 } = await Promise.resolve().then(() => (init_server2(), server_exports2));
|
|
7051
|
-
const
|
|
7931
|
+
const fs19 = await import("fs/promises");
|
|
7052
7932
|
const crypto2 = await import("crypto");
|
|
7053
7933
|
const { useFunctions: useFunctions3 } = await import("../src/constructs/Function.js");
|
|
7054
7934
|
const { useSites } = await import("../src/constructs/SsrSite.js");
|
|
@@ -7100,9 +7980,16 @@ var dev = (program2) => program2.command(
|
|
|
7100
7980
|
);
|
|
7101
7981
|
});
|
|
7102
7982
|
bus.subscribe("worker.stdout", async (evt) => {
|
|
7983
|
+
const info = useFunctions3().fromID(evt.properties.functionID);
|
|
7103
7984
|
prefix(evt.properties.requestID);
|
|
7104
7985
|
const { started } = pending.get(evt.properties.requestID);
|
|
7105
7986
|
for (let line of evt.properties.message.split("\n")) {
|
|
7987
|
+
if (info?.runtime === "container") {
|
|
7988
|
+
const parts = line.split(" ");
|
|
7989
|
+
if (parts.length >= 4 && Date.parse(parts[0]) && parts[1].length === 36) {
|
|
7990
|
+
line = parts.slice(3).join(" ");
|
|
7991
|
+
}
|
|
7992
|
+
}
|
|
7106
7993
|
Colors2.line(
|
|
7107
7994
|
prefix(evt.properties.requestID),
|
|
7108
7995
|
Colors2.dim(("+" + (Date.now() - started) + "ms").padEnd(7)),
|
|
@@ -7110,13 +7997,27 @@ var dev = (program2) => program2.command(
|
|
|
7110
7997
|
);
|
|
7111
7998
|
}
|
|
7112
7999
|
});
|
|
8000
|
+
bus.subscribe("function.build.started", async (evt) => {
|
|
8001
|
+
const info = useFunctions3().fromID(evt.properties.functionID);
|
|
8002
|
+
if (!info)
|
|
8003
|
+
return;
|
|
8004
|
+
if (info.enableLiveDev === false)
|
|
8005
|
+
return;
|
|
8006
|
+
if (info.runtime !== "container")
|
|
8007
|
+
return;
|
|
8008
|
+
Colors2.line(
|
|
8009
|
+
Colors2.dim(Colors2.prefix, "Building", info.handler, "container")
|
|
8010
|
+
);
|
|
8011
|
+
});
|
|
7113
8012
|
bus.subscribe("function.build.success", async (evt) => {
|
|
7114
8013
|
const info = useFunctions3().fromID(evt.properties.functionID);
|
|
7115
8014
|
if (!info)
|
|
7116
8015
|
return;
|
|
7117
8016
|
if (info.enableLiveDev === false)
|
|
7118
8017
|
return;
|
|
7119
|
-
Colors2.line(
|
|
8018
|
+
Colors2.line(
|
|
8019
|
+
info.runtime === "container" ? Colors2.dim(Colors2.prefix, "Built", info.handler, "container") : Colors2.dim(Colors2.prefix, "Built", info.handler)
|
|
8020
|
+
);
|
|
7120
8021
|
});
|
|
7121
8022
|
bus.subscribe("function.build.failed", async (evt) => {
|
|
7122
8023
|
const info = useFunctions3().fromID(evt.properties.functionID);
|
|
@@ -7190,9 +8091,9 @@ var dev = (program2) => program2.command(
|
|
|
7190
8091
|
outDir: `.sst/cdk.out`,
|
|
7191
8092
|
mode: "dev"
|
|
7192
8093
|
});
|
|
7193
|
-
|
|
8094
|
+
Logger3.debug("Directory", assembly.directory);
|
|
7194
8095
|
const next = await checksum(assembly.directory);
|
|
7195
|
-
|
|
8096
|
+
Logger3.debug("Checksum", "next", next, "old", lastDeployed);
|
|
7196
8097
|
if (next === lastDeployed) {
|
|
7197
8098
|
spinner.succeed(Colors2.dim(" Built with no changes"));
|
|
7198
8099
|
isWorking = false;
|
|
@@ -7230,7 +8131,7 @@ var dev = (program2) => program2.command(
|
|
|
7230
8131
|
useSites().all.filter(({ props }) => props.dev?.deploy !== true).forEach(({ type, props }) => {
|
|
7231
8132
|
const framework = type === "AstroSite" ? "Astro" : type === "NextjsSite" ? "Next.js" : type === "RemixSite" ? "Remix" : type === "SolidStartSite" ? "SolidStart" : type === "SvelteKitSite" ? "SvelteKit" : void 0;
|
|
7232
8133
|
if (framework) {
|
|
7233
|
-
const cdCmd =
|
|
8134
|
+
const cdCmd = path22.resolve(props.path) === process.cwd() ? "" : `cd ${props.path} && `;
|
|
7234
8135
|
Colors2.line(
|
|
7235
8136
|
Colors2.primary(`\u279C `),
|
|
7236
8137
|
Colors2.bold(`Start ${framework}:`),
|
|
@@ -7241,8 +8142,8 @@ var dev = (program2) => program2.command(
|
|
|
7241
8142
|
});
|
|
7242
8143
|
}
|
|
7243
8144
|
lastDeployed = nextChecksum;
|
|
7244
|
-
|
|
7245
|
-
|
|
8145
|
+
fs19.writeFile(
|
|
8146
|
+
path22.join(project.paths.out, "outputs.json"),
|
|
7246
8147
|
JSON.stringify(
|
|
7247
8148
|
mapValues(results, (val) => val.outputs),
|
|
7248
8149
|
null,
|
|
@@ -7254,17 +8155,17 @@ var dev = (program2) => program2.command(
|
|
|
7254
8155
|
build2();
|
|
7255
8156
|
}
|
|
7256
8157
|
async function checksum(cdkOutPath) {
|
|
7257
|
-
const manifestPath =
|
|
8158
|
+
const manifestPath = path22.join(cdkOutPath, "manifest.json");
|
|
7258
8159
|
const cdkManifest = JSON.parse(
|
|
7259
|
-
await
|
|
8160
|
+
await fs19.readFile(manifestPath).then((x) => x.toString())
|
|
7260
8161
|
);
|
|
7261
8162
|
const checksumData = await Promise.all(
|
|
7262
8163
|
Object.keys(cdkManifest.artifacts).filter(
|
|
7263
8164
|
(key) => cdkManifest.artifacts[key].type === "aws:cloudformation:stack"
|
|
7264
8165
|
).map(async (key) => {
|
|
7265
8166
|
const { templateFile } = cdkManifest.artifacts[key].properties;
|
|
7266
|
-
const templatePath =
|
|
7267
|
-
const templateContent = await
|
|
8167
|
+
const templatePath = path22.join(cdkOutPath, templateFile);
|
|
8168
|
+
const templateContent = await fs19.readFile(templatePath);
|
|
7268
8169
|
return templateContent;
|
|
7269
8170
|
})
|
|
7270
8171
|
).then((x) => x.join("\n"));
|
|
@@ -7274,7 +8175,7 @@ var dev = (program2) => program2.command(
|
|
|
7274
8175
|
watcher.subscribe("file.changed", async (evt) => {
|
|
7275
8176
|
if (!project.metafile)
|
|
7276
8177
|
return;
|
|
7277
|
-
if (!project.metafile.inputs[evt.properties.relative.split(
|
|
8178
|
+
if (!project.metafile.inputs[evt.properties.relative.split(path22.sep).join(path22.posix.sep)])
|
|
7278
8179
|
return;
|
|
7279
8180
|
build2();
|
|
7280
8181
|
});
|
|
@@ -7319,7 +8220,7 @@ var dev = (program2) => program2.command(
|
|
|
7319
8220
|
input: process.stdin,
|
|
7320
8221
|
output: process.stdout
|
|
7321
8222
|
});
|
|
7322
|
-
return new Promise((
|
|
8223
|
+
return new Promise((resolve2) => {
|
|
7323
8224
|
console.log("");
|
|
7324
8225
|
rl.question(
|
|
7325
8226
|
`You have previously deployed the stage "${useProject2().config.stage}" in production. It is recommended that you use a different stage for development. Read more here \u2014 https://docs.sst.dev/live-lambda-development
|
|
@@ -7327,7 +8228,7 @@ var dev = (program2) => program2.command(
|
|
|
7327
8228
|
Are you sure you want to run this stage in dev mode? [y/N] `,
|
|
7328
8229
|
async (input) => {
|
|
7329
8230
|
rl.close();
|
|
7330
|
-
|
|
8231
|
+
resolve2(input.trim() === "y");
|
|
7331
8232
|
}
|
|
7332
8233
|
);
|
|
7333
8234
|
});
|
|
@@ -7356,7 +8257,7 @@ Are you sure you want to run this stage in dev mode? [y/N] `,
|
|
|
7356
8257
|
|
|
7357
8258
|
// src/cli/commands/bind.ts
|
|
7358
8259
|
init_error();
|
|
7359
|
-
import
|
|
8260
|
+
import path20 from "path";
|
|
7360
8261
|
var MetadataNotFoundError = class extends Error {
|
|
7361
8262
|
};
|
|
7362
8263
|
var MetadataOutdatedError = class extends Error {
|
|
@@ -7375,13 +8276,13 @@ var bind = (program2) => program2.command(
|
|
|
7375
8276
|
"Bind resources to your site before deployment"
|
|
7376
8277
|
),
|
|
7377
8278
|
async (args) => {
|
|
7378
|
-
const { spawn:
|
|
8279
|
+
const { spawn: spawn8 } = await import("child_process");
|
|
7379
8280
|
const kill = await import("tree-kill");
|
|
7380
8281
|
const { useProject: useProject2 } = await Promise.resolve().then(() => (init_project(), project_exports));
|
|
7381
8282
|
const { useBus: useBus2 } = await Promise.resolve().then(() => (init_bus(), bus_exports));
|
|
7382
8283
|
const { useIOT: useIOT2 } = await Promise.resolve().then(() => (init_iot(), iot_exports));
|
|
7383
8284
|
const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
|
|
7384
|
-
const { Logger:
|
|
8285
|
+
const { Logger: Logger3 } = await Promise.resolve().then(() => (init_logger(), logger_exports));
|
|
7385
8286
|
if (args._[0] === "env") {
|
|
7386
8287
|
Colors2.line(
|
|
7387
8288
|
Colors2.warning(
|
|
@@ -7406,7 +8307,7 @@ var bind = (program2) => program2.command(
|
|
|
7406
8307
|
);
|
|
7407
8308
|
}
|
|
7408
8309
|
if (args.script || !isSite && !args.site) {
|
|
7409
|
-
|
|
8310
|
+
Logger3.debug("Running in script mode.");
|
|
7410
8311
|
return await bindScript();
|
|
7411
8312
|
}
|
|
7412
8313
|
await bindSite("init");
|
|
@@ -7526,7 +8427,7 @@ var bind = (program2) => program2.command(
|
|
|
7526
8427
|
if (!c.data.path || isSsr && !c.data.server || !isSsr && !c.data.environment) {
|
|
7527
8428
|
throw new MetadataOutdatedError();
|
|
7528
8429
|
}
|
|
7529
|
-
return
|
|
8430
|
+
return path20.resolve(project.paths.root, c.data.path) === process.cwd();
|
|
7530
8431
|
});
|
|
7531
8432
|
if (!data2) {
|
|
7532
8433
|
throw new MetadataNotFoundError();
|
|
@@ -7585,16 +8486,16 @@ var bind = (program2) => program2.command(
|
|
|
7585
8486
|
Colors2.gap();
|
|
7586
8487
|
if (p) {
|
|
7587
8488
|
p.removeAllListeners("exit");
|
|
7588
|
-
await new Promise((
|
|
7589
|
-
kill.default(p?.pid, (
|
|
7590
|
-
if (
|
|
7591
|
-
return reject(
|
|
8489
|
+
await new Promise((resolve2, reject) => {
|
|
8490
|
+
kill.default(p?.pid, (error3) => {
|
|
8491
|
+
if (error3) {
|
|
8492
|
+
return reject(error3);
|
|
7592
8493
|
}
|
|
7593
|
-
|
|
8494
|
+
resolve2(true);
|
|
7594
8495
|
});
|
|
7595
8496
|
});
|
|
7596
8497
|
}
|
|
7597
|
-
p =
|
|
8498
|
+
p = spawn8(command, {
|
|
7598
8499
|
env: {
|
|
7599
8500
|
...process.env,
|
|
7600
8501
|
...envs,
|
|
@@ -7640,7 +8541,7 @@ var bind = (program2) => program2.command(
|
|
|
7640
8541
|
Colors2.line(
|
|
7641
8542
|
"Using local IAM credentials since `sst dev` is not running."
|
|
7642
8543
|
);
|
|
7643
|
-
|
|
8544
|
+
Logger3.debug(`Failed to assume ${roleArn}.`, err);
|
|
7644
8545
|
}
|
|
7645
8546
|
}
|
|
7646
8547
|
).strict(false);
|
|
@@ -7657,7 +8558,7 @@ var build = (program2) => program2.command(
|
|
|
7657
8558
|
const { useProject: useProject2 } = await Promise.resolve().then(() => (init_project(), project_exports));
|
|
7658
8559
|
const { Stacks } = await Promise.resolve().then(() => (init_stacks(), stacks_exports));
|
|
7659
8560
|
const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
|
|
7660
|
-
const
|
|
8561
|
+
const path22 = await import("path");
|
|
7661
8562
|
const project = useProject2();
|
|
7662
8563
|
const [_metafile, sstConfig] = await Stacks.load(project.paths.config);
|
|
7663
8564
|
const result = await Stacks.synth({
|
|
@@ -7669,7 +8570,7 @@ var build = (program2) => program2.command(
|
|
|
7669
8570
|
Colors2.line(
|
|
7670
8571
|
Colors2.success(`\u2714`),
|
|
7671
8572
|
Colors2.bold(" Built:"),
|
|
7672
|
-
`${result.stacks.length} stack${result.stacks.length > 1 ? "s" : ""} to ${
|
|
8573
|
+
`${result.stacks.length} stack${result.stacks.length > 1 ? "s" : ""} to ${path22.relative(process.cwd(), result.directory)}`
|
|
7673
8574
|
);
|
|
7674
8575
|
process.exit(0);
|
|
7675
8576
|
}
|
|
@@ -7678,8 +8579,8 @@ var build = (program2) => program2.command(
|
|
|
7678
8579
|
// src/cli/commands/deploy.tsx
|
|
7679
8580
|
init_credentials();
|
|
7680
8581
|
init_colors();
|
|
7681
|
-
import
|
|
7682
|
-
import
|
|
8582
|
+
import fs18 from "fs/promises";
|
|
8583
|
+
import path21 from "path";
|
|
7683
8584
|
var deploy2 = (program2) => program2.command(
|
|
7684
8585
|
"deploy [filter]",
|
|
7685
8586
|
"Deploy your app to AWS",
|
|
@@ -7712,7 +8613,7 @@ var deploy2 = (program2) => program2.command(
|
|
|
7712
8613
|
input: process.stdin,
|
|
7713
8614
|
output: process.stdout
|
|
7714
8615
|
});
|
|
7715
|
-
return new Promise((
|
|
8616
|
+
return new Promise((resolve2) => {
|
|
7716
8617
|
console.log("");
|
|
7717
8618
|
rl.question(
|
|
7718
8619
|
`You were previously running the stage "${project.config.stage}" in dev mode. It is recommended that you use a different stage for production. Read more here \u2014 https://docs.sst.dev/live-lambda-development
|
|
@@ -7720,7 +8621,7 @@ var deploy2 = (program2) => program2.command(
|
|
|
7720
8621
|
Are you sure you want to deploy to this stage? (y/N) `,
|
|
7721
8622
|
async (input) => {
|
|
7722
8623
|
rl.close();
|
|
7723
|
-
|
|
8624
|
+
resolve2(input.trim() === "y");
|
|
7724
8625
|
}
|
|
7725
8626
|
);
|
|
7726
8627
|
});
|
|
@@ -7769,8 +8670,8 @@ Are you sure you want to deploy to this stage? (y/N) `,
|
|
|
7769
8670
|
printDeploymentResults2(assembly, results);
|
|
7770
8671
|
if (Object.values(results).some((stack) => Stacks.isFailed(stack.status)))
|
|
7771
8672
|
process.exit(1);
|
|
7772
|
-
|
|
7773
|
-
|
|
8673
|
+
fs18.writeFile(
|
|
8674
|
+
path21.join(project.paths.out, "outputs.json"),
|
|
7774
8675
|
JSON.stringify(
|
|
7775
8676
|
mapValues(results, (val) => val.outputs),
|
|
7776
8677
|
null,
|
|
@@ -7987,8 +8888,8 @@ var load2 = (program2) => program2.command(
|
|
|
7987
8888
|
const { blue: blue4 } = await import("colorette");
|
|
7988
8889
|
const { createSpinner: createSpinner2 } = await Promise.resolve().then(() => (init_spinner(), spinner_exports));
|
|
7989
8890
|
const { parse: parse2 } = await import("dotenv");
|
|
7990
|
-
const
|
|
7991
|
-
const fileContent = await
|
|
8891
|
+
const fs19 = await import("fs/promises");
|
|
8892
|
+
const fileContent = await fs19.readFile(args.filename, "utf-8");
|
|
7992
8893
|
const envVars = parse2(fileContent);
|
|
7993
8894
|
const setting = createSpinner2(
|
|
7994
8895
|
` Setting secrets from "${args.filename}"`
|
|
@@ -8144,22 +9045,22 @@ var update = (program2) => program2.command(
|
|
|
8144
9045
|
}),
|
|
8145
9046
|
async (args) => {
|
|
8146
9047
|
const { green, yellow } = await import("colorette");
|
|
8147
|
-
const
|
|
8148
|
-
const
|
|
9048
|
+
const fs19 = await import("fs/promises");
|
|
9049
|
+
const path22 = await import("path");
|
|
8149
9050
|
const { fetch } = await import("undici");
|
|
8150
9051
|
const { useProject: useProject2 } = await Promise.resolve().then(() => (init_project(), project_exports));
|
|
8151
9052
|
const { Colors: Colors2 } = await Promise.resolve().then(() => (init_colors(), colors_exports));
|
|
8152
9053
|
async function find2(dir) {
|
|
8153
|
-
const children = await
|
|
9054
|
+
const children = await fs19.readdir(dir);
|
|
8154
9055
|
const tasks2 = children.map(async (item) => {
|
|
8155
9056
|
if (item === "node_modules")
|
|
8156
9057
|
return [];
|
|
8157
9058
|
if (/(^|\/)\.[^\/\.]/g.test(item))
|
|
8158
9059
|
return [];
|
|
8159
|
-
const full =
|
|
9060
|
+
const full = path22.join(dir, item);
|
|
8160
9061
|
if (item === "package.json")
|
|
8161
9062
|
return [full];
|
|
8162
|
-
const stat = await
|
|
9063
|
+
const stat = await fs19.stat(full);
|
|
8163
9064
|
if (stat.isDirectory())
|
|
8164
9065
|
return find2(full);
|
|
8165
9066
|
return [];
|
|
@@ -8173,7 +9074,7 @@ var update = (program2) => program2.command(
|
|
|
8173
9074
|
).then((resp) => resp.json());
|
|
8174
9075
|
const results = /* @__PURE__ */ new Map();
|
|
8175
9076
|
const tasks = files.map(async (file) => {
|
|
8176
|
-
const data2 = await
|
|
9077
|
+
const data2 = await fs19.readFile(file).then((x) => x.toString()).then(JSON.parse);
|
|
8177
9078
|
for (const field of FIELDS) {
|
|
8178
9079
|
const deps = data2[field];
|
|
8179
9080
|
if (!deps)
|
|
@@ -8207,7 +9108,7 @@ var update = (program2) => program2.command(
|
|
|
8207
9108
|
}
|
|
8208
9109
|
}
|
|
8209
9110
|
if (results.has(file)) {
|
|
8210
|
-
await
|
|
9111
|
+
await fs19.writeFile(file, JSON.stringify(data2, null, 2));
|
|
8211
9112
|
}
|
|
8212
9113
|
});
|
|
8213
9114
|
await Promise.all(tasks);
|
|
@@ -8218,7 +9119,7 @@ var update = (program2) => program2.command(
|
|
|
8218
9119
|
for (const [file, pkgs] of results.entries()) {
|
|
8219
9120
|
Colors2.line(
|
|
8220
9121
|
Colors2.success(`\u2714 `),
|
|
8221
|
-
Colors2.bold.dim(
|
|
9122
|
+
Colors2.bold.dim(path22.relative(project.paths.root, file))
|
|
8222
9123
|
);
|
|
8223
9124
|
for (const [pkg, version2] of pkgs) {
|
|
8224
9125
|
Colors2.line(Colors2.dim(` ${pkg}@${version2}`));
|