@awsless/awsless 0.0.189 → 0.0.191
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin.js +202 -64
- package/dist/build-json-schema.js +3 -0
- package/package.json +7 -7
package/dist/bin.js
CHANGED
|
@@ -165,6 +165,9 @@ var directories = {
|
|
|
165
165
|
get cache() {
|
|
166
166
|
return join(this.output, "cache");
|
|
167
167
|
},
|
|
168
|
+
get state() {
|
|
169
|
+
return join(this.output, "state");
|
|
170
|
+
},
|
|
168
171
|
get build() {
|
|
169
172
|
return join(this.output, "build");
|
|
170
173
|
},
|
|
@@ -1462,11 +1465,12 @@ import {
|
|
|
1462
1465
|
ScalarAttributeType
|
|
1463
1466
|
} from "@aws-sdk/client-dynamodb";
|
|
1464
1467
|
import { confirm, log as log6 } from "@clack/prompts";
|
|
1465
|
-
|
|
1468
|
+
import { CreateBucketCommand, HeadBucketCommand, S3Client, S3ServiceException } from "@aws-sdk/client-s3";
|
|
1469
|
+
var hasLockTable = async (client) => {
|
|
1466
1470
|
try {
|
|
1467
1471
|
const result = await client.send(
|
|
1468
1472
|
new DescribeTableCommand({
|
|
1469
|
-
TableName: "awsless-
|
|
1473
|
+
TableName: "awsless-locks"
|
|
1470
1474
|
})
|
|
1471
1475
|
);
|
|
1472
1476
|
return !!result.Table;
|
|
@@ -1477,10 +1481,26 @@ var hasStateTable = async (client) => {
|
|
|
1477
1481
|
throw error;
|
|
1478
1482
|
}
|
|
1479
1483
|
};
|
|
1480
|
-
var
|
|
1484
|
+
var hasStateBucket = async (client) => {
|
|
1485
|
+
try {
|
|
1486
|
+
const result = await client.send(
|
|
1487
|
+
new HeadBucketCommand({
|
|
1488
|
+
Bucket: "awsless-state"
|
|
1489
|
+
})
|
|
1490
|
+
);
|
|
1491
|
+
return !!result.BucketRegion;
|
|
1492
|
+
} catch (error) {
|
|
1493
|
+
console.log(error);
|
|
1494
|
+
if (error instanceof S3ServiceException) {
|
|
1495
|
+
return false;
|
|
1496
|
+
}
|
|
1497
|
+
throw error;
|
|
1498
|
+
}
|
|
1499
|
+
};
|
|
1500
|
+
var createLockTable = (client) => {
|
|
1481
1501
|
return client.send(
|
|
1482
1502
|
new CreateTableCommand({
|
|
1483
|
-
TableName: "awsless-
|
|
1503
|
+
TableName: "awsless-locks",
|
|
1484
1504
|
BillingMode: BillingMode.PAY_PER_REQUEST,
|
|
1485
1505
|
KeySchema: [
|
|
1486
1506
|
{
|
|
@@ -1497,10 +1517,22 @@ var createStateTable = (client) => {
|
|
|
1497
1517
|
})
|
|
1498
1518
|
);
|
|
1499
1519
|
};
|
|
1500
|
-
var
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1520
|
+
var createStateBucket = (client) => {
|
|
1521
|
+
return client.send(
|
|
1522
|
+
new CreateBucketCommand({
|
|
1523
|
+
Bucket: "awsless-state"
|
|
1524
|
+
})
|
|
1525
|
+
);
|
|
1526
|
+
};
|
|
1527
|
+
var bootstrapAwsless = async (props) => {
|
|
1528
|
+
const dynamo = new DynamoDB(props);
|
|
1529
|
+
const s3 = new S3Client(props);
|
|
1530
|
+
const [table2, bucket] = await Promise.all([
|
|
1531
|
+
//
|
|
1532
|
+
hasLockTable(dynamo),
|
|
1533
|
+
hasStateBucket(s3)
|
|
1534
|
+
]);
|
|
1535
|
+
if (!table2 || !bucket) {
|
|
1504
1536
|
log6.warn(`Your Awsless hasn't been bootstrapped yet.`);
|
|
1505
1537
|
if (!process.env.SKIP_PROMPT) {
|
|
1506
1538
|
const confirmed = await confirm({
|
|
@@ -1511,7 +1543,12 @@ var bootstrapAwsless = async (opts) => {
|
|
|
1511
1543
|
}
|
|
1512
1544
|
}
|
|
1513
1545
|
await task("Bootstrapping", async (update) => {
|
|
1514
|
-
|
|
1546
|
+
if (!table2) {
|
|
1547
|
+
await createLockTable(dynamo);
|
|
1548
|
+
}
|
|
1549
|
+
if (!bucket) {
|
|
1550
|
+
await createStateBucket(s3);
|
|
1551
|
+
}
|
|
1515
1552
|
update("Done deploying the bootstrap stack");
|
|
1516
1553
|
});
|
|
1517
1554
|
} else {
|
|
@@ -1991,14 +2028,14 @@ var build = (type, name, builder) => {
|
|
|
1991
2028
|
};
|
|
1992
2029
|
|
|
1993
2030
|
// src/feature/function/util.ts
|
|
1994
|
-
var createLambdaFunction = (group, ctx, ns, id,
|
|
2031
|
+
var createLambdaFunction = (group, ctx, ns, id, local2) => {
|
|
1995
2032
|
let name;
|
|
1996
2033
|
if ("stackConfig" in ctx) {
|
|
1997
2034
|
name = formatLocalResourceName(ctx.appConfig.name, ctx.stackConfig.name, ns, id);
|
|
1998
2035
|
} else {
|
|
1999
2036
|
name = formatGlobalResourceName(ctx.appConfig.name, ns, id);
|
|
2000
2037
|
}
|
|
2001
|
-
const props = deepmerge(ctx.appConfig.defaults.function,
|
|
2038
|
+
const props = deepmerge(ctx.appConfig.defaults.function, local2);
|
|
2002
2039
|
ctx.registerBuild("function", name, async (build3) => {
|
|
2003
2040
|
const version = await fingerprintFromFile(props.file);
|
|
2004
2041
|
return build3(version, async (write) => {
|
|
@@ -2073,8 +2110,8 @@ var createLambdaFunction = (group, ctx, ns, id, local) => {
|
|
|
2073
2110
|
if (ctx.appConfig.defaults.function.permissions) {
|
|
2074
2111
|
policy.addStatement(...ctx.appConfig.defaults.function.permissions);
|
|
2075
2112
|
}
|
|
2076
|
-
if ("permissions" in
|
|
2077
|
-
policy.addStatement(...
|
|
2113
|
+
if ("permissions" in local2 && local2.permissions) {
|
|
2114
|
+
policy.addStatement(...local2.permissions);
|
|
2078
2115
|
}
|
|
2079
2116
|
if (props.warm) {
|
|
2080
2117
|
const rule = new aws2.events.Rule(group, "warm", {
|
|
@@ -2378,9 +2415,12 @@ var configFeature = defineFeature({
|
|
|
2378
2415
|
await ctx.write("config.d.ts", gen, true);
|
|
2379
2416
|
},
|
|
2380
2417
|
onStack(ctx) {
|
|
2381
|
-
const configs = ctx.stackConfig.configs;
|
|
2418
|
+
const configs = ctx.stackConfig.configs ?? [];
|
|
2419
|
+
for (const name of configs) {
|
|
2420
|
+
ctx.registerConfig(name);
|
|
2421
|
+
}
|
|
2382
2422
|
ctx.onFunction(({ lambda, policy }) => {
|
|
2383
|
-
if (configs
|
|
2423
|
+
if (configs.length) {
|
|
2384
2424
|
lambda.addEnvironment("CONFIG", configs.join(","));
|
|
2385
2425
|
policy.addStatement({
|
|
2386
2426
|
actions: [
|
|
@@ -3037,8 +3077,8 @@ var queueFeature = defineFeature({
|
|
|
3037
3077
|
await ctx.write("queue.d.ts", gen, true);
|
|
3038
3078
|
},
|
|
3039
3079
|
onStack(ctx) {
|
|
3040
|
-
for (const [id,
|
|
3041
|
-
const props = deepmerge2(ctx.appConfig.defaults.queue,
|
|
3080
|
+
for (const [id, local2] of Object.entries(ctx.stackConfig.queues || {})) {
|
|
3081
|
+
const props = deepmerge2(ctx.appConfig.defaults.queue, local2);
|
|
3042
3082
|
const group = new Node9(ctx.stack, "queue", id);
|
|
3043
3083
|
const queue2 = new aws9.sqs.Queue(group, "queue", {
|
|
3044
3084
|
name: formatLocalResourceName(ctx.appConfig.name, ctx.stack.name, "queue", id),
|
|
@@ -3925,6 +3965,7 @@ var createApp = (props, filters = []) => {
|
|
|
3925
3965
|
const app = new App(props.appConfig.name);
|
|
3926
3966
|
const base = new Stack(app, "base");
|
|
3927
3967
|
const shared = new SharedData();
|
|
3968
|
+
const configs = /* @__PURE__ */ new Set();
|
|
3928
3969
|
const tests = [];
|
|
3929
3970
|
const builders = [];
|
|
3930
3971
|
const allFunctions = [];
|
|
@@ -3978,6 +4019,9 @@ var createApp = (props, filters = []) => {
|
|
|
3978
4019
|
},
|
|
3979
4020
|
registerBuild(type, name, builder) {
|
|
3980
4021
|
builders.push({ type, name, builder });
|
|
4022
|
+
},
|
|
4023
|
+
registerConfig(name) {
|
|
4024
|
+
configs.add(name);
|
|
3981
4025
|
}
|
|
3982
4026
|
});
|
|
3983
4027
|
}
|
|
@@ -3996,6 +4040,7 @@ var createApp = (props, filters = []) => {
|
|
|
3996
4040
|
app,
|
|
3997
4041
|
base,
|
|
3998
4042
|
tests,
|
|
4043
|
+
configs,
|
|
3999
4044
|
builders
|
|
4000
4045
|
// deploymentLine,
|
|
4001
4046
|
};
|
|
@@ -4086,7 +4131,7 @@ var get = (program2) => {
|
|
|
4086
4131
|
note2(
|
|
4087
4132
|
list({
|
|
4088
4133
|
Name: chalk4.magenta(name),
|
|
4089
|
-
Value: value ?? color.
|
|
4134
|
+
Value: value ?? color.warning("(empty)")
|
|
4090
4135
|
})
|
|
4091
4136
|
);
|
|
4092
4137
|
});
|
|
@@ -4123,8 +4168,11 @@ import { log as log7, spinner as spinner5 } from "@clack/prompts";
|
|
|
4123
4168
|
import chalk5 from "chalk";
|
|
4124
4169
|
var list2 = (program2) => {
|
|
4125
4170
|
program2.command("list").description(`List all config value's`).action(async () => {
|
|
4126
|
-
await layout("config list", async ({ appConfig }) => {
|
|
4171
|
+
await layout("config list", async ({ appConfig, stackConfigs }) => {
|
|
4172
|
+
const region = appConfig.region;
|
|
4127
4173
|
const credentials = getCredentials(appConfig.profile);
|
|
4174
|
+
const accountId = await getAccountId(credentials, region);
|
|
4175
|
+
const { configs } = createApp({ appConfig, stackConfigs, accountId });
|
|
4128
4176
|
const params = new SsmStore({
|
|
4129
4177
|
credentials,
|
|
4130
4178
|
appConfig
|
|
@@ -4133,11 +4181,25 @@ var list2 = (program2) => {
|
|
|
4133
4181
|
spin.start("Loading config parameters");
|
|
4134
4182
|
const values = await params.list();
|
|
4135
4183
|
spin.stop("Done loading config values.");
|
|
4136
|
-
|
|
4184
|
+
const requiredValues = [...configs].map((key) => {
|
|
4185
|
+
if (typeof values[key] !== "undefined") {
|
|
4186
|
+
return [chalk5.magenta(key), values[key]];
|
|
4187
|
+
} else {
|
|
4188
|
+
return [chalk5.magenta(key), color.warning("(empty)")];
|
|
4189
|
+
}
|
|
4190
|
+
});
|
|
4191
|
+
const unsusedValues = Object.entries(values).map(([key, value]) => {
|
|
4192
|
+
if (!configs.has(key)) {
|
|
4193
|
+
return [chalk5.magenta(key), `${value} ${color.error("(unused)")}`];
|
|
4194
|
+
}
|
|
4195
|
+
return void 0;
|
|
4196
|
+
}).filter(Boolean);
|
|
4197
|
+
const allValues = [...requiredValues, ...unsusedValues];
|
|
4198
|
+
if (requiredValues.length > 0) {
|
|
4137
4199
|
console.log(
|
|
4138
4200
|
table({
|
|
4139
4201
|
head: ["name", "value"],
|
|
4140
|
-
body:
|
|
4202
|
+
body: allValues
|
|
4141
4203
|
})
|
|
4142
4204
|
);
|
|
4143
4205
|
} else {
|
|
@@ -4162,8 +4224,54 @@ var config = (program2) => {
|
|
|
4162
4224
|
|
|
4163
4225
|
// src/cli/command/delete.ts
|
|
4164
4226
|
import { confirm as confirm3 } from "@clack/prompts";
|
|
4165
|
-
|
|
4227
|
+
|
|
4228
|
+
// src/util/workspace.ts
|
|
4229
|
+
import { WorkSpace, aws as aws18, local } from "@awsless/formation";
|
|
4166
4230
|
import { minutes as minutes4 } from "@awsless/duration";
|
|
4231
|
+
import { dirname as dirname8, join as join9 } from "path";
|
|
4232
|
+
import { mkdir as mkdir2, readFile as readFile6, rm, writeFile as writeFile2 } from "fs/promises";
|
|
4233
|
+
var createWorkSpace = (props) => {
|
|
4234
|
+
const lockProvider = new aws18.dynamodb.LockProvider({
|
|
4235
|
+
...props,
|
|
4236
|
+
tableName: "awsless-locks"
|
|
4237
|
+
});
|
|
4238
|
+
const stateProvider = new aws18.s3.StateProvider({
|
|
4239
|
+
...props,
|
|
4240
|
+
bucket: "awsless-state"
|
|
4241
|
+
});
|
|
4242
|
+
const cloudProviders = aws18.createCloudProviders({
|
|
4243
|
+
...props,
|
|
4244
|
+
timeout: minutes4(60)
|
|
4245
|
+
});
|
|
4246
|
+
const workspace = new WorkSpace({
|
|
4247
|
+
lockProvider,
|
|
4248
|
+
stateProvider,
|
|
4249
|
+
cloudProviders
|
|
4250
|
+
});
|
|
4251
|
+
return {
|
|
4252
|
+
workspace,
|
|
4253
|
+
lockProvider,
|
|
4254
|
+
stateProvider
|
|
4255
|
+
};
|
|
4256
|
+
};
|
|
4257
|
+
var pullRemoteState = async (app, stateProvider) => {
|
|
4258
|
+
const file = join9(directories.state, `${app.urn}.json`);
|
|
4259
|
+
const state2 = await stateProvider.get(app.urn);
|
|
4260
|
+
await mkdir2(dirname8(file), { recursive: true });
|
|
4261
|
+
if (typeof state2 === "undefined") {
|
|
4262
|
+
await rm(file);
|
|
4263
|
+
} else {
|
|
4264
|
+
await writeFile2(file, JSON.stringify(state2, void 0, 2));
|
|
4265
|
+
}
|
|
4266
|
+
};
|
|
4267
|
+
var pushRemoteState = async (app, stateProvider) => {
|
|
4268
|
+
const file = join9(directories.state, `${app.urn}.json`);
|
|
4269
|
+
const data = await readFile6(file, "utf8");
|
|
4270
|
+
const state2 = JSON.parse(data);
|
|
4271
|
+
await stateProvider.update(app.urn, state2);
|
|
4272
|
+
};
|
|
4273
|
+
|
|
4274
|
+
// src/cli/command/delete.ts
|
|
4167
4275
|
var del2 = (program2) => {
|
|
4168
4276
|
program2.command("delete").argument("[stacks...]", "Optionally filter stacks to delete").description("Delete your app from AWS").action(async (filters) => {
|
|
4169
4277
|
await layout("delete", async ({ appConfig, stackConfigs }) => {
|
|
@@ -4186,20 +4294,13 @@ var del2 = (program2) => {
|
|
|
4186
4294
|
throw new Cancelled();
|
|
4187
4295
|
}
|
|
4188
4296
|
}
|
|
4189
|
-
const workspace =
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
region,
|
|
4193
|
-
tableName: "awsless-state"
|
|
4194
|
-
}),
|
|
4195
|
-
cloudProviders: aws18.createCloudProviders({
|
|
4196
|
-
credentials,
|
|
4197
|
-
region: appConfig.region,
|
|
4198
|
-
timeout: minutes4(30)
|
|
4199
|
-
})
|
|
4297
|
+
const { workspace, stateProvider } = createWorkSpace({
|
|
4298
|
+
credentials,
|
|
4299
|
+
region
|
|
4200
4300
|
});
|
|
4201
4301
|
await task("Deleting the stacks to AWS", async (update) => {
|
|
4202
4302
|
await workspace.deleteApp(app);
|
|
4303
|
+
await pullRemoteState(app, stateProvider);
|
|
4203
4304
|
update("Done deleting the stacks to AWS.");
|
|
4204
4305
|
});
|
|
4205
4306
|
return "Your app has been deleted!";
|
|
@@ -4208,12 +4309,11 @@ var del2 = (program2) => {
|
|
|
4208
4309
|
};
|
|
4209
4310
|
|
|
4210
4311
|
// src/cli/command/deploy.ts
|
|
4211
|
-
import { WorkSpace as WorkSpace2, aws as aws19 } from "@awsless/formation";
|
|
4212
4312
|
import { confirm as confirm4 } from "@clack/prompts";
|
|
4213
4313
|
|
|
4214
4314
|
// src/cli/ui/complex/run-tests.ts
|
|
4215
|
-
import { join as
|
|
4216
|
-
import { mkdir as
|
|
4315
|
+
import { join as join10 } from "path";
|
|
4316
|
+
import { mkdir as mkdir3, readFile as readFile7, writeFile as writeFile3 } from "fs/promises";
|
|
4217
4317
|
|
|
4218
4318
|
// src/test/reporter.ts
|
|
4219
4319
|
import { getSuites, getTests } from "@vitest/runner/utils";
|
|
@@ -4397,12 +4497,12 @@ var logTestErrors = (event) => {
|
|
|
4397
4497
|
});
|
|
4398
4498
|
};
|
|
4399
4499
|
var runTest = async (stack, dir, filters) => {
|
|
4400
|
-
await
|
|
4500
|
+
await mkdir3(directories.test, { recursive: true });
|
|
4401
4501
|
const fingerprint = await fingerprintFromDirectory(dir);
|
|
4402
|
-
const file =
|
|
4502
|
+
const file = join10(directories.test, `${stack}.json`);
|
|
4403
4503
|
const exists = await fileExist(file);
|
|
4404
4504
|
if (exists && !process.env.NO_CACHE) {
|
|
4405
|
-
const raw = await
|
|
4505
|
+
const raw = await readFile7(file, { encoding: "utf8" });
|
|
4406
4506
|
const data = JSON.parse(raw);
|
|
4407
4507
|
if (data.fingerprint === fingerprint) {
|
|
4408
4508
|
log8.step(
|
|
@@ -4443,7 +4543,7 @@ var runTest = async (stack, dir, filters) => {
|
|
|
4443
4543
|
});
|
|
4444
4544
|
logTestLogs(result);
|
|
4445
4545
|
logTestErrors(result);
|
|
4446
|
-
await
|
|
4546
|
+
await writeFile3(
|
|
4447
4547
|
file,
|
|
4448
4548
|
JSON.stringify({
|
|
4449
4549
|
...result,
|
|
@@ -4465,7 +4565,6 @@ var runTests = async (tests, filters = []) => {
|
|
|
4465
4565
|
};
|
|
4466
4566
|
|
|
4467
4567
|
// src/cli/command/deploy.ts
|
|
4468
|
-
import { minutes as minutes5 } from "@awsless/duration";
|
|
4469
4568
|
var deploy = (program2) => {
|
|
4470
4569
|
program2.command("deploy").argument("[stacks...]", "Optionally filter stacks to deploy").description("Deploy your app to AWS").action(async (filters) => {
|
|
4471
4570
|
await layout("deploy", async ({ appConfig, stackConfigs }) => {
|
|
@@ -4492,20 +4591,13 @@ var deploy = (program2) => {
|
|
|
4492
4591
|
throw new Cancelled();
|
|
4493
4592
|
}
|
|
4494
4593
|
await buildAssets(builders);
|
|
4495
|
-
const workspace =
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
region,
|
|
4499
|
-
tableName: "awsless-state"
|
|
4500
|
-
}),
|
|
4501
|
-
cloudProviders: aws19.createCloudProviders({
|
|
4502
|
-
credentials,
|
|
4503
|
-
region: appConfig.region,
|
|
4504
|
-
timeout: minutes5(60)
|
|
4505
|
-
})
|
|
4594
|
+
const { workspace, stateProvider } = createWorkSpace({
|
|
4595
|
+
credentials,
|
|
4596
|
+
region
|
|
4506
4597
|
});
|
|
4507
4598
|
await task("Deploying the stacks to AWS", async (update) => {
|
|
4508
4599
|
await workspace.deployApp(app);
|
|
4600
|
+
await pullRemoteState(app, stateProvider);
|
|
4509
4601
|
update("Done deploying the stacks to AWS.");
|
|
4510
4602
|
});
|
|
4511
4603
|
return "Your app is ready!";
|
|
@@ -4514,7 +4606,7 @@ var deploy = (program2) => {
|
|
|
4514
4606
|
};
|
|
4515
4607
|
|
|
4516
4608
|
// src/cli/command/diff.ts
|
|
4517
|
-
import { WorkSpace as
|
|
4609
|
+
import { WorkSpace as WorkSpace2, aws as aws19 } from "@awsless/formation";
|
|
4518
4610
|
import chalk7 from "chalk";
|
|
4519
4611
|
var diff = (program2) => {
|
|
4520
4612
|
program2.command("diff").description("Diff your app with AWS").action(async (filters) => {
|
|
@@ -4525,13 +4617,13 @@ var diff = (program2) => {
|
|
|
4525
4617
|
await bootstrapAwsless({ credentials, region });
|
|
4526
4618
|
const { app, builders } = createApp({ appConfig, stackConfigs, accountId }, filters);
|
|
4527
4619
|
await buildAssets(builders);
|
|
4528
|
-
const workspace = new
|
|
4529
|
-
stateProvider: new
|
|
4620
|
+
const workspace = new WorkSpace2({
|
|
4621
|
+
stateProvider: new aws19.dynamodb.DynamoDBStateProvider({
|
|
4530
4622
|
credentials,
|
|
4531
4623
|
region,
|
|
4532
4624
|
tableName: "awsless-state"
|
|
4533
4625
|
}),
|
|
4534
|
-
cloudProviders:
|
|
4626
|
+
cloudProviders: aws19.createCloudProviders({
|
|
4535
4627
|
credentials,
|
|
4536
4628
|
region: appConfig.region
|
|
4537
4629
|
})
|
|
@@ -4586,8 +4678,8 @@ var diff = (program2) => {
|
|
|
4586
4678
|
import { log as log9 } from "@clack/prompts";
|
|
4587
4679
|
|
|
4588
4680
|
// src/type-gen/generate.ts
|
|
4589
|
-
import { mkdir as
|
|
4590
|
-
import { dirname as
|
|
4681
|
+
import { mkdir as mkdir4, writeFile as writeFile4 } from "fs/promises";
|
|
4682
|
+
import { dirname as dirname9, join as join11, relative as relative4 } from "path";
|
|
4591
4683
|
var generateTypes = async (props) => {
|
|
4592
4684
|
const files = [];
|
|
4593
4685
|
await Promise.all(
|
|
@@ -4596,13 +4688,13 @@ var generateTypes = async (props) => {
|
|
|
4596
4688
|
...props,
|
|
4597
4689
|
async write(file, data, include = false) {
|
|
4598
4690
|
const code = data?.toString("utf8");
|
|
4599
|
-
const path =
|
|
4691
|
+
const path = join11(directories.types, file);
|
|
4600
4692
|
if (code) {
|
|
4601
4693
|
if (include) {
|
|
4602
4694
|
files.push(relative4(directories.root, path));
|
|
4603
4695
|
}
|
|
4604
|
-
await
|
|
4605
|
-
await
|
|
4696
|
+
await mkdir4(dirname9(path), { recursive: true });
|
|
4697
|
+
await writeFile4(path, code);
|
|
4606
4698
|
}
|
|
4607
4699
|
}
|
|
4608
4700
|
});
|
|
@@ -4610,7 +4702,7 @@ var generateTypes = async (props) => {
|
|
|
4610
4702
|
);
|
|
4611
4703
|
if (files.length) {
|
|
4612
4704
|
const code = files.map((file) => `/// <reference path='${file}' />`).join("\n");
|
|
4613
|
-
await
|
|
4705
|
+
await writeFile4(join11(directories.root, `awsless.d.ts`), code);
|
|
4614
4706
|
}
|
|
4615
4707
|
};
|
|
4616
4708
|
|
|
@@ -4736,8 +4828,53 @@ var dev = (program2) => {
|
|
|
4736
4828
|
});
|
|
4737
4829
|
};
|
|
4738
4830
|
|
|
4831
|
+
// src/cli/command/state/pull.ts
|
|
4832
|
+
var pull = (program2) => {
|
|
4833
|
+
program2.command("pull").description("Pull the remote state and store it locally").action(async () => {
|
|
4834
|
+
await layout("state pull", async ({ appConfig, stackConfigs }) => {
|
|
4835
|
+
const region = appConfig.region;
|
|
4836
|
+
const credentials = getCredentials(appConfig.profile);
|
|
4837
|
+
const accountId = await getAccountId(credentials, region);
|
|
4838
|
+
const { app } = createApp({ appConfig, stackConfigs, accountId });
|
|
4839
|
+
const { stateProvider } = createWorkSpace({ credentials, region });
|
|
4840
|
+
await pullRemoteState(app, stateProvider);
|
|
4841
|
+
return "State pull was successful.";
|
|
4842
|
+
});
|
|
4843
|
+
});
|
|
4844
|
+
};
|
|
4845
|
+
|
|
4846
|
+
// src/cli/command/state/push.ts
|
|
4847
|
+
import { confirm as confirm5 } from "@clack/prompts";
|
|
4848
|
+
var push = (program2) => {
|
|
4849
|
+
program2.command("push").description("Push the local state to the remote server").action(async () => {
|
|
4850
|
+
await layout("state pull", async ({ appConfig, stackConfigs }) => {
|
|
4851
|
+
const region = appConfig.region;
|
|
4852
|
+
const credentials = getCredentials(appConfig.profile);
|
|
4853
|
+
const accountId = await getAccountId(credentials, region);
|
|
4854
|
+
const { app } = createApp({ appConfig, stackConfigs, accountId });
|
|
4855
|
+
const { stateProvider } = createWorkSpace({ credentials, region });
|
|
4856
|
+
const ok = await confirm5({
|
|
4857
|
+
message: "Pushing up the local state might corrupt your remote state. Are you sure?",
|
|
4858
|
+
initialValue: false
|
|
4859
|
+
});
|
|
4860
|
+
if (!ok) {
|
|
4861
|
+
throw new Cancelled();
|
|
4862
|
+
}
|
|
4863
|
+
await pushRemoteState(app, stateProvider);
|
|
4864
|
+
return "State push was successful.";
|
|
4865
|
+
});
|
|
4866
|
+
});
|
|
4867
|
+
};
|
|
4868
|
+
|
|
4869
|
+
// src/cli/command/state/index.ts
|
|
4870
|
+
var commands3 = [pull, push];
|
|
4871
|
+
var state = (program2) => {
|
|
4872
|
+
const command = program2.command("state").description(`Manage app state`);
|
|
4873
|
+
commands3.forEach((cb) => cb(command));
|
|
4874
|
+
};
|
|
4875
|
+
|
|
4739
4876
|
// src/cli/command/index.ts
|
|
4740
|
-
var
|
|
4877
|
+
var commands4 = [
|
|
4741
4878
|
bootstrap,
|
|
4742
4879
|
types,
|
|
4743
4880
|
build2,
|
|
@@ -4746,6 +4883,7 @@ var commands3 = [
|
|
|
4746
4883
|
del2,
|
|
4747
4884
|
dev,
|
|
4748
4885
|
// bind,
|
|
4886
|
+
state,
|
|
4749
4887
|
resource,
|
|
4750
4888
|
config,
|
|
4751
4889
|
test
|
|
@@ -4771,7 +4909,7 @@ program.on("option:skip-prompt", () => {
|
|
|
4771
4909
|
program.on("option:no-cache", () => {
|
|
4772
4910
|
process.env.NO_CACHE = program.opts().noCache ? "1" : void 0;
|
|
4773
4911
|
});
|
|
4774
|
-
|
|
4912
|
+
commands4.forEach((fn) => fn(program));
|
|
4775
4913
|
|
|
4776
4914
|
// src/bin.ts
|
|
4777
4915
|
program.parse(process.argv);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@awsless/awsless",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.191",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -29,12 +29,12 @@
|
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"@awsless/lambda": "^0.0.18",
|
|
32
|
-
"@awsless/redis": "^0.0.12",
|
|
33
32
|
"@awsless/s3": "^0.0.10",
|
|
33
|
+
"@awsless/redis": "^0.0.12",
|
|
34
|
+
"@awsless/sns": "^0.0.7",
|
|
34
35
|
"@awsless/sqs": "^0.0.7",
|
|
35
|
-
"@awsless/validate": "^0.0.13",
|
|
36
36
|
"@awsless/ssm": "^0.0.7",
|
|
37
|
-
"@awsless/
|
|
37
|
+
"@awsless/validate": "^0.0.13",
|
|
38
38
|
"@awsless/weak-cache": "^0.0.1"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
@@ -96,12 +96,12 @@
|
|
|
96
96
|
"wrap-ansi": "^8.1.0",
|
|
97
97
|
"zod": "^3.21.4",
|
|
98
98
|
"zod-to-json-schema": "^3.22.3",
|
|
99
|
-
"@awsless/code": "^0.0.10",
|
|
100
99
|
"@awsless/duration": "^0.0.1",
|
|
101
100
|
"@awsless/graphql": "^0.0.9",
|
|
102
|
-
"@awsless/formation": "^0.0.12",
|
|
103
101
|
"@awsless/size": "^0.0.1",
|
|
104
|
-
"@awsless/
|
|
102
|
+
"@awsless/formation": "^0.0.13",
|
|
103
|
+
"@awsless/validate": "^0.0.13",
|
|
104
|
+
"@awsless/code": "^0.0.10"
|
|
105
105
|
},
|
|
106
106
|
"scripts": {
|
|
107
107
|
"test": "pnpm code test",
|