@awsless/awsless 0.0.503 → 0.0.505
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 +375 -433
- package/dist/prebuild/images/bundle.zip +0 -0
- package/dist/prebuild/rpc/bundle.zip +0 -0
- package/dist/server.js +0 -4
- package/package.json +16 -14
- package/dist/bin.d.ts +0 -1
- package/dist/chunk-QL4FTNZ7.js +0 -63
- package/dist/client.d.ts +0 -75
- package/dist/server.d.ts +0 -172
package/dist/bin.js
CHANGED
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
Cancelled,
|
|
4
|
-
CommandOptions,
|
|
5
|
-
ConfigError,
|
|
6
|
-
ExpectedError,
|
|
7
|
-
FileError
|
|
8
|
-
} from "./chunk-QL4FTNZ7.js";
|
|
9
2
|
|
|
10
3
|
// src/cli/program.ts
|
|
11
|
-
import { Command
|
|
4
|
+
import { Command } from "commander";
|
|
12
5
|
|
|
13
6
|
// src/util/aws.ts
|
|
14
7
|
import { GetCallerIdentityCommand, STSClient } from "@aws-sdk/client-sts";
|
|
@@ -40,7 +33,30 @@ import {
|
|
|
40
33
|
S3Client,
|
|
41
34
|
S3ServiceException
|
|
42
35
|
} from "@aws-sdk/client-s3";
|
|
43
|
-
import {
|
|
36
|
+
import { log, prompt } from "@awsless/clui";
|
|
37
|
+
|
|
38
|
+
// src/error.ts
|
|
39
|
+
var ExpectedError = class extends Error {
|
|
40
|
+
};
|
|
41
|
+
var ConfigError = class extends Error {
|
|
42
|
+
constructor(file, error, data) {
|
|
43
|
+
super(error.message);
|
|
44
|
+
this.file = file;
|
|
45
|
+
this.error = error;
|
|
46
|
+
this.data = data;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var FileError = class extends Error {
|
|
50
|
+
constructor(file, message) {
|
|
51
|
+
super(message);
|
|
52
|
+
this.file = file;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
var Cancelled = class extends Error {
|
|
56
|
+
constructor() {
|
|
57
|
+
super("Cancelled");
|
|
58
|
+
}
|
|
59
|
+
};
|
|
44
60
|
|
|
45
61
|
// src/util/workspace.ts
|
|
46
62
|
import {
|
|
@@ -403,120 +419,6 @@ var pushRemoteState = async (app, stateBackend) => {
|
|
|
403
419
|
await stateBackend.update(app.urn, state2);
|
|
404
420
|
};
|
|
405
421
|
|
|
406
|
-
// src/cli/ui/util.ts
|
|
407
|
-
import { spinner } from "@clack/prompts";
|
|
408
|
-
import { capitalCase } from "change-case";
|
|
409
|
-
import Table from "cli-table3";
|
|
410
|
-
import wrapAnsi from "wrap-ansi";
|
|
411
|
-
|
|
412
|
-
// src/cli/ui/style.ts
|
|
413
|
-
import chalk from "chalk";
|
|
414
|
-
var icon = {
|
|
415
|
-
// info: 'ℹ',
|
|
416
|
-
// success: '✓',
|
|
417
|
-
// warning: '⚠',
|
|
418
|
-
// question: '?',
|
|
419
|
-
error: "\xD7",
|
|
420
|
-
dot: "\xB7",
|
|
421
|
-
// line: '─',
|
|
422
|
-
// ellipsis: '…',
|
|
423
|
-
arrow: {
|
|
424
|
-
top: "^",
|
|
425
|
-
right: "\u203A"
|
|
426
|
-
}
|
|
427
|
-
// pointer: '❯',
|
|
428
|
-
};
|
|
429
|
-
var color = {
|
|
430
|
-
primary: chalk.bold.hex("#FF9000"),
|
|
431
|
-
// primary: chalk.bold.magentaBright,
|
|
432
|
-
// title: chalk.white,
|
|
433
|
-
// normal: chalk.white,
|
|
434
|
-
label: chalk.reset.white.bold,
|
|
435
|
-
dim: chalk.dim,
|
|
436
|
-
line: chalk.black,
|
|
437
|
-
// link: chalk.cyan,
|
|
438
|
-
info: chalk.blue,
|
|
439
|
-
success: chalk.green,
|
|
440
|
-
warning: chalk.yellow,
|
|
441
|
-
error: chalk.red,
|
|
442
|
-
attr: chalk.yellow
|
|
443
|
-
// cursor: chalk.bgWhite.blackBright,
|
|
444
|
-
};
|
|
445
|
-
var char = {
|
|
446
|
-
br: "\n"
|
|
447
|
-
};
|
|
448
|
-
|
|
449
|
-
// src/cli/ui/util.ts
|
|
450
|
-
var wrap = (lines, options) => {
|
|
451
|
-
return wrapAnsi(typeof lines === "string" ? lines : lines.join("\n"), process.stdout.columns - 8, options);
|
|
452
|
-
};
|
|
453
|
-
var padText = (texts) => {
|
|
454
|
-
const size = Math.max(...texts.map((text3) => text3.length));
|
|
455
|
-
return (text3, padding = 0, fill) => {
|
|
456
|
-
return text3.padEnd(size + padding, fill);
|
|
457
|
-
};
|
|
458
|
-
};
|
|
459
|
-
var task = async (message, cb) => {
|
|
460
|
-
let last = message;
|
|
461
|
-
const spin = spinner();
|
|
462
|
-
spin.start(last);
|
|
463
|
-
try {
|
|
464
|
-
const result = await cb((m) => {
|
|
465
|
-
spin.message(m.substring(0, process.stdout.columns - 8));
|
|
466
|
-
last = m;
|
|
467
|
-
});
|
|
468
|
-
spin.stop(last);
|
|
469
|
-
return result;
|
|
470
|
-
} catch (error) {
|
|
471
|
-
spin.stop("Failed.", 2);
|
|
472
|
-
throw error;
|
|
473
|
-
}
|
|
474
|
-
};
|
|
475
|
-
var list = (data) => {
|
|
476
|
-
const padName = padText(Object.keys(data));
|
|
477
|
-
return Object.entries(data).map(([name, value]) => [color.label(padName(name + ":", 2)), value].join("")).join(char.br);
|
|
478
|
-
};
|
|
479
|
-
var line = (message) => {
|
|
480
|
-
console.log(color.line("\u2502 "), message);
|
|
481
|
-
};
|
|
482
|
-
var table = (props) => {
|
|
483
|
-
console.log(color.line("\u2502"));
|
|
484
|
-
const table2 = new Table({
|
|
485
|
-
// wordWrap: true,
|
|
486
|
-
// wrapOnWordBoundary: false,
|
|
487
|
-
// truncate: '...',
|
|
488
|
-
// colWidths: props.colWidths,
|
|
489
|
-
// head: props.head.map(h => color.label(capitalCase(h))),
|
|
490
|
-
head: props.head.map((h) => "\n" + color.label(capitalCase(h))),
|
|
491
|
-
// colWidths: [100, 200],
|
|
492
|
-
style: {
|
|
493
|
-
"padding-left": 2,
|
|
494
|
-
"padding-right": 2
|
|
495
|
-
},
|
|
496
|
-
chars: {
|
|
497
|
-
"bottom-right": "\u256F",
|
|
498
|
-
"top-right": "\u256E",
|
|
499
|
-
"top-left": "\u251C",
|
|
500
|
-
"bottom-left": "\u251C"
|
|
501
|
-
// mid: '',
|
|
502
|
-
// 'mid-mid': '',
|
|
503
|
-
// 'left-mid': '',
|
|
504
|
-
// 'right-mid': '',
|
|
505
|
-
}
|
|
506
|
-
});
|
|
507
|
-
table2.push(
|
|
508
|
-
...props.body.map(
|
|
509
|
-
(row) => row.map((v) => {
|
|
510
|
-
if (typeof v === "boolean") {
|
|
511
|
-
return v ? color.success("yes") : color.error("no");
|
|
512
|
-
}
|
|
513
|
-
return v;
|
|
514
|
-
})
|
|
515
|
-
)
|
|
516
|
-
);
|
|
517
|
-
return table2.toString();
|
|
518
|
-
};
|
|
519
|
-
|
|
520
422
|
// src/cli/ui/complex/bootstrap-awsless.ts
|
|
521
423
|
var hasLockTable = async (client) => {
|
|
522
424
|
try {
|
|
@@ -605,29 +507,33 @@ var createStateBucket = async (client, region, accountId) => {
|
|
|
605
507
|
var bootstrapAwsless = async (props) => {
|
|
606
508
|
const dynamo = new DynamoDB(props);
|
|
607
509
|
const s3 = new S3Client(props);
|
|
608
|
-
const [
|
|
510
|
+
const [table, bucket] = await Promise.all([
|
|
609
511
|
//
|
|
610
512
|
hasLockTable(dynamo),
|
|
611
513
|
hasStateBucket(s3, props.region, props.accountId)
|
|
612
514
|
]);
|
|
613
|
-
if (!
|
|
614
|
-
log.
|
|
515
|
+
if (!table || !bucket) {
|
|
516
|
+
log.warning(`Awsless hasn't been bootstrapped yet.`);
|
|
615
517
|
if (!process.env.SKIP_PROMPT) {
|
|
616
|
-
const confirmed = await confirm({
|
|
518
|
+
const confirmed = await prompt.confirm({
|
|
617
519
|
message: "Would you like to bootstrap now?"
|
|
618
520
|
});
|
|
619
|
-
if (!confirmed
|
|
521
|
+
if (!confirmed) {
|
|
620
522
|
throw new Cancelled();
|
|
621
523
|
}
|
|
622
524
|
}
|
|
623
|
-
await task(
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
525
|
+
await log.task({
|
|
526
|
+
initialMessage: "Bootstrapping...",
|
|
527
|
+
successMessage: "Done deploying the bootstrap stack.",
|
|
528
|
+
errorMessage: "Failed to bootstrap Awsless.",
|
|
529
|
+
async task() {
|
|
530
|
+
if (!table) {
|
|
531
|
+
await createLockTable(dynamo);
|
|
532
|
+
}
|
|
533
|
+
if (!bucket) {
|
|
534
|
+
await createStateBucket(s3, props.region, props.accountId);
|
|
535
|
+
}
|
|
629
536
|
}
|
|
630
|
-
update("Done deploying the bootstrap stack.");
|
|
631
537
|
});
|
|
632
538
|
} else {
|
|
633
539
|
log.step("Awsless has already been bootstrapped.");
|
|
@@ -635,12 +541,46 @@ var bootstrapAwsless = async (props) => {
|
|
|
635
541
|
};
|
|
636
542
|
|
|
637
543
|
// src/cli/ui/complex/layout.ts
|
|
638
|
-
import {
|
|
544
|
+
import { log as log8 } from "@awsless/clui";
|
|
639
545
|
|
|
640
546
|
// src/config/load/load.ts
|
|
641
547
|
import { glob } from "glob";
|
|
642
548
|
import { basename as basename2, dirname as dirname3, join as join5 } from "path";
|
|
643
549
|
|
|
550
|
+
// src/cli/ui/style.ts
|
|
551
|
+
import chalk from "chalk";
|
|
552
|
+
var icon = {
|
|
553
|
+
// info: 'ℹ',
|
|
554
|
+
// success: '✓',
|
|
555
|
+
// warning: '⚠',
|
|
556
|
+
// question: '?',
|
|
557
|
+
error: "\xD7",
|
|
558
|
+
dot: "\xB7",
|
|
559
|
+
// line: '─',
|
|
560
|
+
// ellipsis: '…',
|
|
561
|
+
arrow: {
|
|
562
|
+
top: "^",
|
|
563
|
+
right: "\u203A"
|
|
564
|
+
}
|
|
565
|
+
// pointer: '❯',
|
|
566
|
+
};
|
|
567
|
+
var color = {
|
|
568
|
+
primary: chalk.bold.hex("#FF9000"),
|
|
569
|
+
// primary: chalk.bold.magentaBright,
|
|
570
|
+
// title: chalk.white,
|
|
571
|
+
// normal: chalk.white,
|
|
572
|
+
label: chalk.reset.white.bold,
|
|
573
|
+
dim: chalk.dim,
|
|
574
|
+
line: chalk.black,
|
|
575
|
+
// link: chalk.cyan,
|
|
576
|
+
info: chalk.blue,
|
|
577
|
+
success: chalk.green,
|
|
578
|
+
warning: chalk.yellow,
|
|
579
|
+
error: chalk.red,
|
|
580
|
+
attr: chalk.yellow
|
|
581
|
+
// cursor: chalk.bgWhite.blackBright,
|
|
582
|
+
};
|
|
583
|
+
|
|
644
584
|
// src/cli/debug.ts
|
|
645
585
|
var queue = [];
|
|
646
586
|
var debugError = (error) => {
|
|
@@ -972,11 +912,11 @@ var FunctionDefaultSchema = z14.object({
|
|
|
972
912
|
// container
|
|
973
913
|
warm: WarmSchema.default(0),
|
|
974
914
|
vpc: VPCSchema.default(false),
|
|
975
|
-
log: LogSchema.default(true).transform((
|
|
976
|
-
retention:
|
|
977
|
-
level: "level" in
|
|
978
|
-
system: "system" in
|
|
979
|
-
format: "format" in
|
|
915
|
+
log: LogSchema.default(true).transform((log23) => ({
|
|
916
|
+
retention: log23.retention ?? days(7),
|
|
917
|
+
level: "level" in log23 ? log23.level : "error",
|
|
918
|
+
system: "system" in log23 ? log23.system : "warn",
|
|
919
|
+
format: "format" in log23 ? log23.format : "json"
|
|
980
920
|
})),
|
|
981
921
|
timeout: TimeoutSchema.default("10 seconds"),
|
|
982
922
|
memorySize: MemorySizeSchema.default("128 MB"),
|
|
@@ -1672,9 +1612,9 @@ var SitesSchema = z32.record(
|
|
|
1672
1612
|
// src/feature/store/schema.ts
|
|
1673
1613
|
import { z as z33 } from "zod";
|
|
1674
1614
|
var StoresSchema = z33.union([
|
|
1675
|
-
z33.array(ResourceIdSchema).transform((
|
|
1615
|
+
z33.array(ResourceIdSchema).transform((list3) => {
|
|
1676
1616
|
const stores = {};
|
|
1677
|
-
for (const key of
|
|
1617
|
+
for (const key of list3) {
|
|
1678
1618
|
stores[key] = {};
|
|
1679
1619
|
}
|
|
1680
1620
|
return stores;
|
|
@@ -2469,12 +2409,12 @@ var cacheFeature = defineFeature({
|
|
|
2469
2409
|
ctx.addEnv(`${prefix}_HOST`, masterHost);
|
|
2470
2410
|
ctx.addEnv(
|
|
2471
2411
|
`${prefix}_PORT`,
|
|
2472
|
-
masterPort.pipe((
|
|
2412
|
+
masterPort.pipe((p) => p.toString())
|
|
2473
2413
|
);
|
|
2474
2414
|
ctx.addEnv(`${prefix}_SLAVE_HOST`, slaveHost);
|
|
2475
2415
|
ctx.addEnv(
|
|
2476
2416
|
`${prefix}_SLAVE_PORT`,
|
|
2477
|
-
slavePort.pipe((
|
|
2417
|
+
slavePort.pipe((p) => p.toString())
|
|
2478
2418
|
);
|
|
2479
2419
|
}
|
|
2480
2420
|
}
|
|
@@ -2880,9 +2820,9 @@ var createHashFromFile = (file) => {
|
|
|
2880
2820
|
stream.on("end", () => resolve(hash.digest("hex")));
|
|
2881
2821
|
});
|
|
2882
2822
|
};
|
|
2883
|
-
var listAllFiles = async (
|
|
2823
|
+
var listAllFiles = async (list3) => {
|
|
2884
2824
|
const files = [];
|
|
2885
|
-
for (const entry of
|
|
2825
|
+
for (const entry of list3) {
|
|
2886
2826
|
const stat5 = await lstat2(entry);
|
|
2887
2827
|
if (stat5.isDirectory()) {
|
|
2888
2828
|
const dirents = await readdir(entry, {
|
|
@@ -2941,11 +2881,11 @@ import { readdir as readdir3 } from "node:fs/promises";
|
|
|
2941
2881
|
import { join as join9, relative as relative2 } from "node:path";
|
|
2942
2882
|
var zipBundle = async ({ directory }) => {
|
|
2943
2883
|
const zip = new JSZip2();
|
|
2944
|
-
const
|
|
2884
|
+
const list3 = await readdir3(directory, {
|
|
2945
2885
|
recursive: true,
|
|
2946
2886
|
withFileTypes: true
|
|
2947
2887
|
});
|
|
2948
|
-
for (const file of
|
|
2888
|
+
for (const file of list3) {
|
|
2949
2889
|
if (file.isFile()) {
|
|
2950
2890
|
const path = join9(file.path, file.name);
|
|
2951
2891
|
const rel = relative2(directory, path);
|
|
@@ -3082,11 +3022,11 @@ var createLambdaFunction = (parentGroup, ctx, ns, id, local) => {
|
|
|
3082
3022
|
role: role.name,
|
|
3083
3023
|
name: "lambda-policy",
|
|
3084
3024
|
policy: new Future(async (resolve) => {
|
|
3085
|
-
const
|
|
3025
|
+
const list3 = await resolveInputs(statements);
|
|
3086
3026
|
resolve(
|
|
3087
3027
|
JSON.stringify({
|
|
3088
3028
|
Version: "2012-10-17",
|
|
3089
|
-
Statement:
|
|
3029
|
+
Statement: list3.map((statement) => ({
|
|
3090
3030
|
Effect: pascalCase(statement.effect ?? "allow"),
|
|
3091
3031
|
Action: statement.actions,
|
|
3092
3032
|
Resource: statement.resources
|
|
@@ -4201,11 +4141,11 @@ var createPrebuildLambdaFunction = (group, ctx, ns, id, props) => {
|
|
|
4201
4141
|
role: role.name,
|
|
4202
4142
|
name: "lambda-policy",
|
|
4203
4143
|
policy: new Future2(async (resolve) => {
|
|
4204
|
-
const
|
|
4144
|
+
const list3 = await resolveInputs2(statements);
|
|
4205
4145
|
resolve(
|
|
4206
4146
|
JSON.stringify({
|
|
4207
4147
|
Version: "2012-10-17",
|
|
4208
|
-
Statement:
|
|
4148
|
+
Statement: list3.map((statement) => ({
|
|
4209
4149
|
Effect: pascalCase2(statement.effect ?? "allow"),
|
|
4210
4150
|
Action: statement.actions,
|
|
4211
4151
|
Resource: statement.resources
|
|
@@ -4351,15 +4291,15 @@ var rpcFeature = defineFeature({
|
|
|
4351
4291
|
}
|
|
4352
4292
|
for (const stack of ctx.stackConfigs) {
|
|
4353
4293
|
for (const [id, queries] of Object.entries(stack.rpc ?? {})) {
|
|
4354
|
-
const
|
|
4355
|
-
if (!
|
|
4294
|
+
const list3 = names[id];
|
|
4295
|
+
if (!list3) {
|
|
4356
4296
|
throw new FileError(stack.file, `The RPC API for "${id}" isn't defined on app level.`);
|
|
4357
4297
|
}
|
|
4358
4298
|
for (const [name, props] of Object.entries(queries ?? {})) {
|
|
4359
|
-
if (
|
|
4299
|
+
if (list3.has(name)) {
|
|
4360
4300
|
throw new FileError(stack.file, `Duplicate RPC API function "${id}.${name}"`);
|
|
4361
4301
|
} else {
|
|
4362
|
-
|
|
4302
|
+
list3.add(name);
|
|
4363
4303
|
}
|
|
4364
4304
|
const timeout = toSeconds5(props.timeout ?? ctx.appConfig.defaults.function.timeout);
|
|
4365
4305
|
const maxTimeout = toSeconds5(ctx.appConfig.defaults.rpc[id].timeout) * 0.8;
|
|
@@ -4580,7 +4520,7 @@ var rpcFeature = defineFeature({
|
|
|
4580
4520
|
if (!defaultProps) {
|
|
4581
4521
|
throw new FileError(ctx.stackConfig.file, `RPC definition is not defined on app level for "${id}"`);
|
|
4582
4522
|
}
|
|
4583
|
-
const
|
|
4523
|
+
const table = ctx.shared.entry("rpc", "schema-table", id);
|
|
4584
4524
|
const group = new Group13(ctx.stack, "rpc", id);
|
|
4585
4525
|
for (const [name, props] of Object.entries(queries ?? {})) {
|
|
4586
4526
|
const queryGroup = new Group13(group, "query", name);
|
|
@@ -4590,9 +4530,9 @@ var rpcFeature = defineFeature({
|
|
|
4590
4530
|
description: `${id} ${name}`
|
|
4591
4531
|
});
|
|
4592
4532
|
new $13.aws.dynamodb.TableItem(queryGroup, "query", {
|
|
4593
|
-
tableName:
|
|
4594
|
-
hashKey:
|
|
4595
|
-
rangeKey:
|
|
4533
|
+
tableName: table.name,
|
|
4534
|
+
hashKey: table.hashKey,
|
|
4535
|
+
rangeKey: table.rangeKey,
|
|
4596
4536
|
item: JSON.stringify({
|
|
4597
4537
|
query: { S: name },
|
|
4598
4538
|
function: {
|
|
@@ -4629,11 +4569,11 @@ var searchFeature = defineFeature({
|
|
|
4629
4569
|
const gen = new TypeFile("@awsless/awsless");
|
|
4630
4570
|
const resources2 = new TypeObject(1);
|
|
4631
4571
|
for (const stack of ctx.stackConfigs) {
|
|
4632
|
-
const
|
|
4572
|
+
const list3 = new TypeObject(2);
|
|
4633
4573
|
for (const id of Object.keys(stack.searchs ?? {})) {
|
|
4634
|
-
|
|
4574
|
+
list3.addType(id, `Search`);
|
|
4635
4575
|
}
|
|
4636
|
-
resources2.addType(stack.name,
|
|
4576
|
+
resources2.addType(stack.name, list3);
|
|
4637
4577
|
}
|
|
4638
4578
|
gen.addCode(typeGenCode4);
|
|
4639
4579
|
gen.addInterface("SearchResources", resources2);
|
|
@@ -5230,7 +5170,7 @@ var storeFeature = defineFeature({
|
|
|
5230
5170
|
const gen = new TypeFile("@awsless/awsless");
|
|
5231
5171
|
const resources2 = new TypeObject(1);
|
|
5232
5172
|
for (const stack of ctx.stackConfigs) {
|
|
5233
|
-
const
|
|
5173
|
+
const list3 = new TypeObject(2);
|
|
5234
5174
|
for (const id of Object.keys(stack.stores ?? {})) {
|
|
5235
5175
|
const storeName = formatLocalResourceName({
|
|
5236
5176
|
appName: ctx.appConfig.name,
|
|
@@ -5238,9 +5178,9 @@ var storeFeature = defineFeature({
|
|
|
5238
5178
|
resourceType: "store",
|
|
5239
5179
|
resourceName: id
|
|
5240
5180
|
});
|
|
5241
|
-
|
|
5181
|
+
list3.addType(id, `Store<'${storeName}'>`);
|
|
5242
5182
|
}
|
|
5243
|
-
resources2.addType(stack.name,
|
|
5183
|
+
resources2.addType(stack.name, list3);
|
|
5244
5184
|
}
|
|
5245
5185
|
gen.addCode(typeGenCode5);
|
|
5246
5186
|
gen.addInterface("StoreResources", resources2);
|
|
@@ -5369,7 +5309,7 @@ var tableFeature = defineFeature({
|
|
|
5369
5309
|
const gen = new TypeFile("@awsless/awsless");
|
|
5370
5310
|
const resources2 = new TypeObject(1);
|
|
5371
5311
|
for (const stack of ctx.stackConfigs) {
|
|
5372
|
-
const
|
|
5312
|
+
const list3 = new TypeObject(2);
|
|
5373
5313
|
for (const name of Object.keys(stack.tables || {})) {
|
|
5374
5314
|
const tableName = formatLocalResourceName({
|
|
5375
5315
|
appName: ctx.appConfig.name,
|
|
@@ -5377,9 +5317,9 @@ var tableFeature = defineFeature({
|
|
|
5377
5317
|
resourceType: "table",
|
|
5378
5318
|
resourceName: name
|
|
5379
5319
|
});
|
|
5380
|
-
|
|
5320
|
+
list3.addType(name, `'${tableName}'`);
|
|
5381
5321
|
}
|
|
5382
|
-
resources2.addType(stack.name,
|
|
5322
|
+
resources2.addType(stack.name, list3);
|
|
5383
5323
|
}
|
|
5384
5324
|
gen.addInterface("TableResources", resources2);
|
|
5385
5325
|
await ctx.write("table.d.ts", gen, true);
|
|
@@ -5436,7 +5376,7 @@ var tableFeature = defineFeature({
|
|
|
5436
5376
|
type: types2[props.fields?.[name2] ?? "string"]
|
|
5437
5377
|
}));
|
|
5438
5378
|
};
|
|
5439
|
-
const
|
|
5379
|
+
const table = new $17.aws.dynamodb.Table(
|
|
5440
5380
|
group,
|
|
5441
5381
|
"table",
|
|
5442
5382
|
{
|
|
@@ -5477,7 +5417,7 @@ var tableFeature = defineFeature({
|
|
|
5477
5417
|
id,
|
|
5478
5418
|
{
|
|
5479
5419
|
functionName: result.lambda.functionName,
|
|
5480
|
-
eventSourceArn:
|
|
5420
|
+
eventSourceArn: table.streamArn,
|
|
5481
5421
|
// tumblingWindowInSeconds
|
|
5482
5422
|
// maximumRecordAgeInSeconds: props.stream.
|
|
5483
5423
|
// bisectBatchOnFunctionError: true,
|
|
@@ -5500,7 +5440,7 @@ var tableFeature = defineFeature({
|
|
|
5500
5440
|
"dynamodb:GetRecords",
|
|
5501
5441
|
"dynamodb:GetShardIterator"
|
|
5502
5442
|
],
|
|
5503
|
-
resources: [
|
|
5443
|
+
resources: [table.streamArn]
|
|
5504
5444
|
});
|
|
5505
5445
|
if (onFailure) {
|
|
5506
5446
|
result.addPermission({
|
|
@@ -5523,13 +5463,13 @@ var tableFeature = defineFeature({
|
|
|
5523
5463
|
"dynamodb:Query",
|
|
5524
5464
|
"dynamodb:Scan"
|
|
5525
5465
|
],
|
|
5526
|
-
resources: [
|
|
5466
|
+
resources: [table.arn]
|
|
5527
5467
|
});
|
|
5528
5468
|
const indexNames = Object.keys(props.indexes ?? {});
|
|
5529
5469
|
if (indexNames.length > 0) {
|
|
5530
5470
|
ctx.addStackPermission({
|
|
5531
5471
|
actions: ["dynamodb:Query"],
|
|
5532
|
-
resources: indexNames.map((indexName) =>
|
|
5472
|
+
resources: indexNames.map((indexName) => table.arn.pipe((arn) => `${arn}/index/${indexName}`))
|
|
5533
5473
|
});
|
|
5534
5474
|
}
|
|
5535
5475
|
}
|
|
@@ -5820,7 +5760,7 @@ var vpcFeature = defineFeature({
|
|
|
5820
5760
|
private: privateRouteTable,
|
|
5821
5761
|
public: publicRouteTable
|
|
5822
5762
|
};
|
|
5823
|
-
for (const [_type,
|
|
5763
|
+
for (const [_type, table] of Object.entries(tables)) {
|
|
5824
5764
|
const type = _type;
|
|
5825
5765
|
const subnetIds = [];
|
|
5826
5766
|
for (const i in zones) {
|
|
@@ -5836,7 +5776,7 @@ var vpcFeature = defineFeature({
|
|
|
5836
5776
|
availabilityZone: ctx.appConfig.region + zones[i]
|
|
5837
5777
|
});
|
|
5838
5778
|
new $19.aws.route.TableAssociation(group, id, {
|
|
5839
|
-
routeTableId:
|
|
5779
|
+
routeTableId: table.id,
|
|
5840
5780
|
subnetId: subnet.id
|
|
5841
5781
|
});
|
|
5842
5782
|
subnetIds.push(subnet.id);
|
|
@@ -6329,7 +6269,7 @@ var playErrorSound = () => {
|
|
|
6329
6269
|
};
|
|
6330
6270
|
|
|
6331
6271
|
// src/cli/ui/app.ts
|
|
6332
|
-
import {
|
|
6272
|
+
import { log as log2 } from "@awsless/clui";
|
|
6333
6273
|
var logApp = (app, opt) => {
|
|
6334
6274
|
const data = {
|
|
6335
6275
|
App: app.name,
|
|
@@ -6339,19 +6279,44 @@ var logApp = (app, opt) => {
|
|
|
6339
6279
|
if (opt.stage) {
|
|
6340
6280
|
data.Stage = color.warning(opt.stage);
|
|
6341
6281
|
}
|
|
6342
|
-
|
|
6282
|
+
log2.list("App Config", data);
|
|
6343
6283
|
};
|
|
6344
6284
|
|
|
6345
6285
|
// src/cli/ui/error/error.ts
|
|
6286
|
+
import { Cancelled as CancelledError, log as log7 } from "@awsless/clui";
|
|
6346
6287
|
import { AppError, ResourceError as ResourceError2 } from "@awsless/formation";
|
|
6347
|
-
|
|
6288
|
+
|
|
6289
|
+
// src/cli/ui/util.ts
|
|
6290
|
+
import { spinner } from "@clack/prompts";
|
|
6291
|
+
import { capitalCase } from "change-case";
|
|
6292
|
+
import Table from "cli-table3";
|
|
6293
|
+
import wrapAnsi from "wrap-ansi";
|
|
6294
|
+
var wrap = (lines, options) => {
|
|
6295
|
+
return wrapAnsi(typeof lines === "string" ? lines : lines.join("\n"), process.stdout.columns - 8, options);
|
|
6296
|
+
};
|
|
6297
|
+
var task = async (message, cb) => {
|
|
6298
|
+
let last = message;
|
|
6299
|
+
const spin = spinner();
|
|
6300
|
+
spin.start(last);
|
|
6301
|
+
try {
|
|
6302
|
+
const result = await cb((m) => {
|
|
6303
|
+
spin.message(m.substring(0, process.stdout.columns - 8));
|
|
6304
|
+
last = m;
|
|
6305
|
+
});
|
|
6306
|
+
spin.stop(last);
|
|
6307
|
+
return result;
|
|
6308
|
+
} catch (error) {
|
|
6309
|
+
spin.stop("Failed.", 2);
|
|
6310
|
+
throw error;
|
|
6311
|
+
}
|
|
6312
|
+
};
|
|
6348
6313
|
|
|
6349
6314
|
// src/cli/ui/error/app-error.ts
|
|
6350
|
-
import { log as
|
|
6315
|
+
import { log as log4 } from "@awsless/clui";
|
|
6351
6316
|
|
|
6352
6317
|
// src/cli/ui/error/stack-error.ts
|
|
6318
|
+
import { log as log3 } from "@awsless/clui";
|
|
6353
6319
|
import { ResourceError } from "@awsless/formation";
|
|
6354
|
-
import { log as log2 } from "@clack/prompts";
|
|
6355
6320
|
import { capitalCase as capitalCase2 } from "change-case";
|
|
6356
6321
|
var formatOperation = (operation) => {
|
|
6357
6322
|
const value = ` ${capitalCase2(operation)} `;
|
|
@@ -6372,7 +6337,7 @@ var formatOperation = (operation) => {
|
|
|
6372
6337
|
};
|
|
6373
6338
|
var logResourceError = (error) => {
|
|
6374
6339
|
if (error instanceof ResourceError) {
|
|
6375
|
-
|
|
6340
|
+
log3.error(
|
|
6376
6341
|
[
|
|
6377
6342
|
formatOperation(error.operation),
|
|
6378
6343
|
"\n",
|
|
@@ -6382,31 +6347,23 @@ var logResourceError = (error) => {
|
|
|
6382
6347
|
"\n\n",
|
|
6383
6348
|
wrap(color.error(error.message), { hard: true })
|
|
6384
6349
|
// , '\n', color.error(issue.message)
|
|
6385
|
-
].join("")
|
|
6386
|
-
{ symbol: color.error(icon.error) }
|
|
6350
|
+
].join("")
|
|
6387
6351
|
);
|
|
6388
6352
|
} else if (error instanceof Error) {
|
|
6389
|
-
|
|
6390
|
-
symbol: color.error(icon.error)
|
|
6391
|
-
});
|
|
6353
|
+
log3.error(wrap(color.error(error.message), { hard: true }));
|
|
6392
6354
|
}
|
|
6393
6355
|
};
|
|
6394
6356
|
|
|
6395
6357
|
// src/cli/ui/error/app-error.ts
|
|
6396
6358
|
var logAppError = (error) => {
|
|
6397
|
-
|
|
6398
|
-
wrap([color.error(error.message), `App: ${error.app}`].join("\n"), {
|
|
6399
|
-
hard: true
|
|
6400
|
-
}),
|
|
6401
|
-
{ symbol: color.error(icon.error) }
|
|
6402
|
-
);
|
|
6359
|
+
log4.error([color.error(error.message), `App: ${error.app}`].join("\n"));
|
|
6403
6360
|
for (const issue of error.issues) {
|
|
6404
6361
|
logResourceError(issue);
|
|
6405
6362
|
}
|
|
6406
6363
|
};
|
|
6407
6364
|
|
|
6408
6365
|
// src/cli/ui/error/config-error.ts
|
|
6409
|
-
import
|
|
6366
|
+
import { log as log5 } from "@awsless/clui";
|
|
6410
6367
|
var codeLine = (value, level = 0) => {
|
|
6411
6368
|
return [
|
|
6412
6369
|
//
|
|
@@ -6485,25 +6442,16 @@ var logConfigError = (error) => {
|
|
|
6485
6442
|
message.push(codeLine(color.error(error2), index));
|
|
6486
6443
|
}
|
|
6487
6444
|
});
|
|
6488
|
-
|
|
6489
|
-
wrap([...message, ...end], {
|
|
6490
|
-
trim: false
|
|
6491
|
-
}),
|
|
6492
|
-
{
|
|
6493
|
-
symbol: color.error`×`
|
|
6494
|
-
}
|
|
6495
|
-
);
|
|
6445
|
+
log5.error([...message, ...end].join("\n"));
|
|
6496
6446
|
}
|
|
6497
6447
|
};
|
|
6498
6448
|
|
|
6499
6449
|
// src/cli/ui/error/file-error.ts
|
|
6500
|
-
import { log as
|
|
6450
|
+
import { log as log6 } from "@awsless/clui";
|
|
6501
6451
|
var logFileError = (error) => {
|
|
6502
|
-
|
|
6503
|
-
|
|
6504
|
-
|
|
6505
|
-
}),
|
|
6506
|
-
{ symbol: color.error(icon.error) }
|
|
6452
|
+
log6.error(
|
|
6453
|
+
[color.error(error.message), color.dim(error.file)].join("\n")
|
|
6454
|
+
// { symbol: color.error(icon.error) }
|
|
6507
6455
|
);
|
|
6508
6456
|
};
|
|
6509
6457
|
|
|
@@ -6512,13 +6460,11 @@ var logError = (error) => {
|
|
|
6512
6460
|
if (error instanceof ConfigError) {
|
|
6513
6461
|
logConfigError(error);
|
|
6514
6462
|
} else if (error instanceof Cancelled) {
|
|
6515
|
-
|
|
6516
|
-
|
|
6517
|
-
|
|
6463
|
+
log7.error(color.error("Cancelled."));
|
|
6464
|
+
} else if (error instanceof CancelledError) {
|
|
6465
|
+
log7.error(color.error("Cancelled."));
|
|
6518
6466
|
} else if (error instanceof ExpectedError) {
|
|
6519
|
-
|
|
6520
|
-
symbol: color.error(icon.error)
|
|
6521
|
-
});
|
|
6467
|
+
log7.error(color.error(error.message));
|
|
6522
6468
|
} else if (error instanceof AppError) {
|
|
6523
6469
|
logAppError(error);
|
|
6524
6470
|
} else if (error instanceof ResourceError2) {
|
|
@@ -6528,20 +6474,16 @@ var logError = (error) => {
|
|
|
6528
6474
|
} else if (error instanceof Error) {
|
|
6529
6475
|
const message = `${error.name}: ${error.message}`;
|
|
6530
6476
|
const stack = error.stack ? color.dim(error.stack.replace(message, "")) : "";
|
|
6531
|
-
|
|
6477
|
+
log7.error(
|
|
6532
6478
|
wrap([color.error(message), stack], {
|
|
6533
6479
|
hard: true
|
|
6534
|
-
})
|
|
6535
|
-
{ symbol: color.error(icon.error) }
|
|
6480
|
+
})
|
|
6481
|
+
// { symbol: color.error(icon.error) }
|
|
6536
6482
|
);
|
|
6537
6483
|
} else if (typeof error === "string") {
|
|
6538
|
-
|
|
6539
|
-
symbol: color.error(icon.error)
|
|
6540
|
-
});
|
|
6484
|
+
log7.error(color.error(error));
|
|
6541
6485
|
} else {
|
|
6542
|
-
|
|
6543
|
-
symbol: color.error(icon.error)
|
|
6544
|
-
});
|
|
6486
|
+
log7.error(color.error("Unknown error!"));
|
|
6545
6487
|
}
|
|
6546
6488
|
};
|
|
6547
6489
|
|
|
@@ -6553,7 +6495,7 @@ var logo = () => {
|
|
|
6553
6495
|
// src/cli/ui/complex/layout.ts
|
|
6554
6496
|
var layout = async (command, cb) => {
|
|
6555
6497
|
console.log();
|
|
6556
|
-
intro(`${logo()} ${color.dim(command)}`);
|
|
6498
|
+
log8.intro(`${logo()} ${color.dim(command)}`);
|
|
6557
6499
|
try {
|
|
6558
6500
|
const options = program.optsWithGlobals();
|
|
6559
6501
|
const appConfig = await loadAppConfig(options);
|
|
@@ -6568,11 +6510,12 @@ var layout = async (command, cb) => {
|
|
|
6568
6510
|
appConfig,
|
|
6569
6511
|
stackConfigs
|
|
6570
6512
|
});
|
|
6571
|
-
outro(result ?? void 0);
|
|
6513
|
+
log8.outro(result ?? void 0);
|
|
6514
|
+
process.exit(0);
|
|
6572
6515
|
} catch (error) {
|
|
6573
6516
|
playErrorSound();
|
|
6574
6517
|
logError(error);
|
|
6575
|
-
outro();
|
|
6518
|
+
log8.outro();
|
|
6576
6519
|
process.exit(1);
|
|
6577
6520
|
}
|
|
6578
6521
|
};
|
|
@@ -6900,42 +6843,45 @@ var createApp = (props) => {
|
|
|
6900
6843
|
};
|
|
6901
6844
|
|
|
6902
6845
|
// src/cli/ui/complex/build-assets.ts
|
|
6846
|
+
import { color as color2, log as log9 } from "@awsless/clui";
|
|
6903
6847
|
import { loadWorkspace } from "@awsless/ts-file-cache";
|
|
6904
|
-
import
|
|
6848
|
+
import { capitalCase as capitalCase3 } from "change-case";
|
|
6905
6849
|
import wildstring from "wildstring";
|
|
6906
6850
|
var buildAssets = async (builders, stackFilters, showResult = false) => {
|
|
6907
6851
|
if (builders.length === 0) {
|
|
6908
6852
|
return;
|
|
6909
6853
|
}
|
|
6910
6854
|
const results = [];
|
|
6911
|
-
await task(
|
|
6912
|
-
|
|
6913
|
-
|
|
6914
|
-
|
|
6915
|
-
|
|
6916
|
-
|
|
6917
|
-
|
|
6855
|
+
await log9.task({
|
|
6856
|
+
initialMessage: "Building assets...",
|
|
6857
|
+
successMessage: "Done building assets.",
|
|
6858
|
+
errorMessage: "Failed building assets.",
|
|
6859
|
+
async task() {
|
|
6860
|
+
const workspace = await loadWorkspace(directories.root);
|
|
6861
|
+
for (const builder of builders) {
|
|
6862
|
+
if (stackFilters && stackFilters.length > 0) {
|
|
6863
|
+
const found = stackFilters.find((f) => wildstring.match(f, builder.stackName));
|
|
6864
|
+
if (!found) {
|
|
6865
|
+
continue;
|
|
6866
|
+
}
|
|
6867
|
+
}
|
|
6868
|
+
try {
|
|
6869
|
+
const result = await build(builder.type, builder.name, builder.builder, {
|
|
6870
|
+
workspace
|
|
6871
|
+
});
|
|
6872
|
+
results.push({ ...builder, result });
|
|
6873
|
+
} catch (error) {
|
|
6874
|
+
logError(new Error(`Build failed for: ${builder.type} ${builder.name}`));
|
|
6875
|
+
throw error;
|
|
6918
6876
|
}
|
|
6919
|
-
}
|
|
6920
|
-
try {
|
|
6921
|
-
const result = await build(builder.type, builder.name, builder.builder, {
|
|
6922
|
-
workspace
|
|
6923
|
-
});
|
|
6924
|
-
results.push({ ...builder, result });
|
|
6925
|
-
} catch (error) {
|
|
6926
|
-
logError(new Error(`Build failed for: ${builder.type} ${builder.name}`));
|
|
6927
|
-
throw error;
|
|
6928
6877
|
}
|
|
6929
6878
|
}
|
|
6930
|
-
update("Done building assets.");
|
|
6931
6879
|
});
|
|
6932
6880
|
if (showResult) {
|
|
6933
|
-
|
|
6934
|
-
|
|
6935
|
-
|
|
6936
|
-
|
|
6937
|
-
})
|
|
6938
|
-
);
|
|
6881
|
+
log9.table({
|
|
6882
|
+
head: ["Type", "Resource", ...Object.keys(results.at(0)?.result ?? {})].map((v) => capitalCase3(v)),
|
|
6883
|
+
body: results.map((r) => [color2.magenta(r.type), r.name, ...Object.values(r.result ?? {})])
|
|
6884
|
+
});
|
|
6939
6885
|
}
|
|
6940
6886
|
};
|
|
6941
6887
|
|
|
@@ -6953,7 +6899,7 @@ var build2 = (program2) => {
|
|
|
6953
6899
|
};
|
|
6954
6900
|
|
|
6955
6901
|
// src/cli/command/config/set.ts
|
|
6956
|
-
import {
|
|
6902
|
+
import { log as log10, prompt as prompt2 } from "@awsless/clui";
|
|
6957
6903
|
var set = (program2) => {
|
|
6958
6904
|
program2.command("set <name>").description("Set a config value").action(async (name) => {
|
|
6959
6905
|
await layout("config set", async ({ appConfig }) => {
|
|
@@ -6963,7 +6909,7 @@ var set = (program2) => {
|
|
|
6963
6909
|
appConfig
|
|
6964
6910
|
});
|
|
6965
6911
|
const initialValue = await params.get(name);
|
|
6966
|
-
const value = await text({
|
|
6912
|
+
const value = await prompt2.text({
|
|
6967
6913
|
message: "Enter the config value:",
|
|
6968
6914
|
initialValue,
|
|
6969
6915
|
validate(value2) {
|
|
@@ -6973,20 +6919,21 @@ var set = (program2) => {
|
|
|
6973
6919
|
return;
|
|
6974
6920
|
}
|
|
6975
6921
|
});
|
|
6976
|
-
|
|
6977
|
-
|
|
6978
|
-
|
|
6979
|
-
|
|
6980
|
-
|
|
6981
|
-
|
|
6982
|
-
|
|
6922
|
+
await log10.task({
|
|
6923
|
+
initialMessage: "Saving remote config parameter...",
|
|
6924
|
+
successMessage: "Done saving remote config parameter.",
|
|
6925
|
+
errorMessage: "Failed saving remote config parameter.",
|
|
6926
|
+
async task() {
|
|
6927
|
+
await params.set(name, value);
|
|
6928
|
+
}
|
|
6929
|
+
});
|
|
6983
6930
|
});
|
|
6984
6931
|
});
|
|
6985
6932
|
};
|
|
6986
6933
|
|
|
6987
6934
|
// src/cli/command/config/get.ts
|
|
6988
|
-
import {
|
|
6989
|
-
import
|
|
6935
|
+
import { log as log11 } from "@awsless/clui";
|
|
6936
|
+
import chalk2 from "chalk";
|
|
6990
6937
|
var get = (program2) => {
|
|
6991
6938
|
program2.command("get <name>").description("Get a config value").action(async (name) => {
|
|
6992
6939
|
await layout("config get", async ({ appConfig }) => {
|
|
@@ -6995,22 +6942,24 @@ var get = (program2) => {
|
|
|
6995
6942
|
credentials,
|
|
6996
6943
|
appConfig
|
|
6997
6944
|
});
|
|
6998
|
-
const
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
|
|
7005
|
-
|
|
7006
|
-
|
|
7007
|
-
|
|
6945
|
+
const value = await log11.task({
|
|
6946
|
+
initialMessage: "Getting remote config parameter...",
|
|
6947
|
+
successMessage: "Done getting remote config parameter.",
|
|
6948
|
+
errorMessage: "Failed getting remote config parameter.",
|
|
6949
|
+
task() {
|
|
6950
|
+
return params.get(name);
|
|
6951
|
+
}
|
|
6952
|
+
});
|
|
6953
|
+
log11.list("Config", {
|
|
6954
|
+
Name: chalk2.magenta(name),
|
|
6955
|
+
Value: value ?? color.warning("(empty)")
|
|
6956
|
+
});
|
|
7008
6957
|
});
|
|
7009
6958
|
});
|
|
7010
6959
|
};
|
|
7011
6960
|
|
|
7012
6961
|
// src/cli/command/config/delete.ts
|
|
7013
|
-
import {
|
|
6962
|
+
import { log as log12, prompt as prompt3 } from "@awsless/clui";
|
|
7014
6963
|
var del = (program2) => {
|
|
7015
6964
|
program2.command("delete <name>").description("Delete a config value").action(async (name) => {
|
|
7016
6965
|
await layout("config delete", async ({ appConfig }) => {
|
|
@@ -7019,25 +6968,29 @@ var del = (program2) => {
|
|
|
7019
6968
|
credentials,
|
|
7020
6969
|
appConfig
|
|
7021
6970
|
});
|
|
7022
|
-
const ok = await
|
|
6971
|
+
const ok = await prompt3.confirm({
|
|
7023
6972
|
message: `Your deleting the ${color.info(name)} config parameter. Are you sure?`,
|
|
7024
6973
|
initialValue: false
|
|
7025
6974
|
});
|
|
7026
|
-
if (!ok
|
|
6975
|
+
if (!ok) {
|
|
7027
6976
|
throw new Cancelled();
|
|
7028
6977
|
}
|
|
7029
|
-
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
6978
|
+
await log12.task({
|
|
6979
|
+
initialMessage: "Deleting remote config parameter...",
|
|
6980
|
+
successMessage: "Done deleting remote config parameter.",
|
|
6981
|
+
errorMessage: "Failed deleting remote config parameter.",
|
|
6982
|
+
async task() {
|
|
6983
|
+
await params.delete(name);
|
|
6984
|
+
}
|
|
6985
|
+
});
|
|
7033
6986
|
});
|
|
7034
6987
|
});
|
|
7035
6988
|
};
|
|
7036
6989
|
|
|
7037
6990
|
// src/cli/command/config/list.ts
|
|
7038
|
-
import { log as
|
|
7039
|
-
import
|
|
7040
|
-
var
|
|
6991
|
+
import { log as log13 } from "@awsless/clui";
|
|
6992
|
+
import chalk3 from "chalk";
|
|
6993
|
+
var list = (program2) => {
|
|
7041
6994
|
program2.command("list").description(`List all config value's`).action(async () => {
|
|
7042
6995
|
await layout("config list", async ({ appConfig, stackConfigs }) => {
|
|
7043
6996
|
const region = appConfig.region;
|
|
@@ -7048,33 +7001,35 @@ var list2 = (program2) => {
|
|
|
7048
7001
|
credentials,
|
|
7049
7002
|
appConfig
|
|
7050
7003
|
});
|
|
7051
|
-
const
|
|
7052
|
-
|
|
7053
|
-
|
|
7054
|
-
|
|
7004
|
+
const values = await log13.task({
|
|
7005
|
+
initialMessage: "Loading config parameters...",
|
|
7006
|
+
successMessage: "Done loading config values.",
|
|
7007
|
+
errorMessage: "Failed loading config values.",
|
|
7008
|
+
task() {
|
|
7009
|
+
return params.list();
|
|
7010
|
+
}
|
|
7011
|
+
});
|
|
7055
7012
|
const requiredValues = [...configs].map((key) => {
|
|
7056
7013
|
if (typeof values[key] !== "undefined") {
|
|
7057
|
-
return [
|
|
7014
|
+
return [chalk3.magenta(key), values[key]];
|
|
7058
7015
|
} else {
|
|
7059
|
-
return [
|
|
7016
|
+
return [chalk3.magenta(key), color.warning("(empty)")];
|
|
7060
7017
|
}
|
|
7061
7018
|
});
|
|
7062
7019
|
const unsusedValues = Object.entries(values).map(([key, value]) => {
|
|
7063
7020
|
if (!configs.has(key)) {
|
|
7064
|
-
return [
|
|
7021
|
+
return [chalk3.magenta(key), `${value} ${color.error("(unused)")}`];
|
|
7065
7022
|
}
|
|
7066
7023
|
return void 0;
|
|
7067
7024
|
}).filter(Boolean);
|
|
7068
7025
|
const allValues = [...requiredValues, ...unsusedValues];
|
|
7069
7026
|
if (requiredValues.length > 0) {
|
|
7070
|
-
|
|
7071
|
-
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
})
|
|
7075
|
-
);
|
|
7027
|
+
log13.table({
|
|
7028
|
+
head: ["Name", "Value"],
|
|
7029
|
+
body: allValues
|
|
7030
|
+
});
|
|
7076
7031
|
} else {
|
|
7077
|
-
|
|
7032
|
+
log13.warning("No config parameters found.");
|
|
7078
7033
|
}
|
|
7079
7034
|
});
|
|
7080
7035
|
});
|
|
@@ -7086,7 +7041,7 @@ var commands = [
|
|
|
7086
7041
|
set,
|
|
7087
7042
|
get,
|
|
7088
7043
|
del,
|
|
7089
|
-
|
|
7044
|
+
list
|
|
7090
7045
|
];
|
|
7091
7046
|
var config = (program2) => {
|
|
7092
7047
|
const command = program2.command("config").description(`Manage app config parameters`);
|
|
@@ -7094,13 +7049,13 @@ var config = (program2) => {
|
|
|
7094
7049
|
};
|
|
7095
7050
|
|
|
7096
7051
|
// src/cli/command/delete.ts
|
|
7097
|
-
import {
|
|
7052
|
+
import { log as log14, prompt as prompt4 } from "@awsless/clui";
|
|
7098
7053
|
import wildstring2 from "wildstring";
|
|
7099
7054
|
var del2 = (program2) => {
|
|
7100
7055
|
program2.command("delete").argument("[stacks...]", "Optionally filter stacks to delete").description("Delete your app from AWS").action(async (filters) => {
|
|
7101
7056
|
await layout("delete", async ({ appConfig, stackConfigs }) => {
|
|
7102
7057
|
if (appConfig.protect) {
|
|
7103
|
-
|
|
7058
|
+
log14.warning("Your app is protected against deletion.");
|
|
7104
7059
|
return "Disable the protect flag and try again.";
|
|
7105
7060
|
}
|
|
7106
7061
|
const region = appConfig.region;
|
|
@@ -7113,16 +7068,19 @@ var del2 = (program2) => {
|
|
|
7113
7068
|
return !!filters.find((f) => wildstring2.match(f, stack.name));
|
|
7114
7069
|
}).map((s) => s.name);
|
|
7115
7070
|
const formattedFilter = stackNames.map((i) => color.info(i)).join(color.dim(", "));
|
|
7071
|
+
if (filters.length > 0 && stackNames.length === 0) {
|
|
7072
|
+
throw new ExpectedError(`The stack filters provided didn't match.`);
|
|
7073
|
+
}
|
|
7116
7074
|
debug("Stacks to delete", formattedFilter);
|
|
7117
7075
|
if (!process.env.SKIP_PROMPT) {
|
|
7118
7076
|
const deployAll = filters.length === 0;
|
|
7119
7077
|
const deploySingle = filters.length === 1;
|
|
7120
|
-
const ok = await
|
|
7078
|
+
const ok = await prompt4.confirm({
|
|
7121
7079
|
message: deployAll ? `Are you sure you want to ${color.error("delete")} ${color.warning("all")} stacks?` : deploySingle ? `Are you sure you want to ${color.error("delete")} the ${formattedFilter} stack?` : `Are you sure you want to ${color.error(
|
|
7122
7080
|
"delete"
|
|
7123
7081
|
)} the [ ${formattedFilter} ] stacks?`
|
|
7124
7082
|
});
|
|
7125
|
-
if (!ok
|
|
7083
|
+
if (!ok) {
|
|
7126
7084
|
throw new Cancelled();
|
|
7127
7085
|
}
|
|
7128
7086
|
}
|
|
@@ -7146,12 +7104,12 @@ var del2 = (program2) => {
|
|
|
7146
7104
|
};
|
|
7147
7105
|
|
|
7148
7106
|
// src/cli/command/deploy.ts
|
|
7149
|
-
import {
|
|
7107
|
+
import { log as log16, prompt as prompt5 } from "@awsless/clui";
|
|
7150
7108
|
import wildstring4 from "wildstring";
|
|
7151
7109
|
|
|
7152
7110
|
// src/cli/ui/complex/run-tests.ts
|
|
7153
|
-
import { log as
|
|
7154
|
-
import
|
|
7111
|
+
import { log as log15 } from "@awsless/clui";
|
|
7112
|
+
import chalk4 from "chalk";
|
|
7155
7113
|
import { mkdir as mkdir4, readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
|
|
7156
7114
|
import { join as join15 } from "path";
|
|
7157
7115
|
import wildstring3 from "wildstring";
|
|
@@ -7273,8 +7231,8 @@ var CustomReporter = class {
|
|
|
7273
7231
|
this.cache = cache;
|
|
7274
7232
|
}
|
|
7275
7233
|
}
|
|
7276
|
-
onUserConsoleLog(
|
|
7277
|
-
this.logs.push(
|
|
7234
|
+
onUserConsoleLog(log23) {
|
|
7235
|
+
this.logs.push(log23.content.trimEnd());
|
|
7278
7236
|
}
|
|
7279
7237
|
runningTask(tasks) {
|
|
7280
7238
|
return tasks.find((t) => t.result?.state === "run");
|
|
@@ -7361,24 +7319,22 @@ var startTest = async (props) => {
|
|
|
7361
7319
|
|
|
7362
7320
|
// src/cli/ui/complex/run-tests.ts
|
|
7363
7321
|
var formatResult = (props) => {
|
|
7364
|
-
const
|
|
7322
|
+
const line = [`Test ${chalk4.magenta(props.stack)}`];
|
|
7365
7323
|
if (props.cached) {
|
|
7366
|
-
|
|
7324
|
+
line.push(color.warning(`(from cache)`));
|
|
7367
7325
|
}
|
|
7368
7326
|
if (props.event.passed > 0) {
|
|
7369
|
-
|
|
7327
|
+
line.push(color.success(`${props.event.passed} passed`));
|
|
7370
7328
|
}
|
|
7371
7329
|
if (props.event.failed > 0) {
|
|
7372
|
-
|
|
7330
|
+
line.push(color.error(`${props.event.failed} failed`));
|
|
7373
7331
|
}
|
|
7374
|
-
return
|
|
7332
|
+
return line.join(` `);
|
|
7375
7333
|
};
|
|
7376
7334
|
var logTestLogs = (event) => {
|
|
7377
7335
|
if (event.logs.length > 0) {
|
|
7378
|
-
|
|
7379
|
-
|
|
7380
|
-
});
|
|
7381
|
-
log9.message(event.logs.map((log16) => wrap(log16, { hard: true })).join("\n"));
|
|
7336
|
+
log15.message(color.info.bold.inverse(" LOGS "), color.dim(icon.dot));
|
|
7337
|
+
log15.message(event.logs.map((log23) => wrap(log23, { hard: true })).join("\n"));
|
|
7382
7338
|
}
|
|
7383
7339
|
};
|
|
7384
7340
|
var logTestErrors = (event) => {
|
|
@@ -7389,7 +7345,7 @@ var logTestErrors = (event) => {
|
|
|
7389
7345
|
message,
|
|
7390
7346
|
comment.length > 0 ? color.dim(`//${comment}`) : ""
|
|
7391
7347
|
].join(" ");
|
|
7392
|
-
|
|
7348
|
+
log15.error(
|
|
7393
7349
|
[
|
|
7394
7350
|
//
|
|
7395
7351
|
color.error.inverse.bold(` FAIL `),
|
|
@@ -7398,18 +7354,11 @@ var logTestErrors = (event) => {
|
|
|
7398
7354
|
error.file,
|
|
7399
7355
|
color.dim(icon.arrow.right),
|
|
7400
7356
|
error.test,
|
|
7401
|
-
[
|
|
7402
|
-
`
|
|
7357
|
+
[`
|
|
7403
7358
|
|
|
7404
|
-
`,
|
|
7405
|
-
wrap(errorMessage, {
|
|
7406
|
-
hard: true
|
|
7407
|
-
}),
|
|
7408
|
-
...error.diff ? ["\n\n", error.diff] : []
|
|
7409
|
-
].join("")
|
|
7359
|
+
`, errorMessage, ...error.diff ? ["\n\n", error.diff] : []].join("")
|
|
7410
7360
|
// error.test,
|
|
7411
|
-
].join(" ")
|
|
7412
|
-
{ symbol: color.error(icon.error) }
|
|
7361
|
+
].join(" ")
|
|
7413
7362
|
);
|
|
7414
7363
|
});
|
|
7415
7364
|
};
|
|
@@ -7422,7 +7371,7 @@ var runTest = async (stack, dir, filters) => {
|
|
|
7422
7371
|
const raw = await readFile5(file, { encoding: "utf8" });
|
|
7423
7372
|
const data = JSON.parse(raw);
|
|
7424
7373
|
if (data.fingerprint === fingerprint) {
|
|
7425
|
-
|
|
7374
|
+
log15.step(
|
|
7426
7375
|
formatResult({
|
|
7427
7376
|
stack,
|
|
7428
7377
|
cached: true,
|
|
@@ -7508,13 +7457,16 @@ var deploy = (program2) => {
|
|
|
7508
7457
|
}).map((s) => s.name);
|
|
7509
7458
|
const formattedFilter = stackNames.map((i) => color.info(i)).join(color.dim(", "));
|
|
7510
7459
|
debug("Stacks to deploy", formattedFilter);
|
|
7460
|
+
if (filters.length > 0 && stackNames.length === 0) {
|
|
7461
|
+
throw new ExpectedError(`The stack filters provided didn't match.`);
|
|
7462
|
+
}
|
|
7511
7463
|
if (!process.env.SKIP_PROMPT) {
|
|
7512
7464
|
const deployAll = filters.length === 0;
|
|
7513
7465
|
const deploySingle = filters.length === 1;
|
|
7514
|
-
const ok = await
|
|
7466
|
+
const ok = await prompt5.confirm({
|
|
7515
7467
|
message: deployAll ? `Are you sure you want to deploy ${color.warning("all")} stacks?` : deploySingle ? `Are you sure you want to deploy the ${formattedFilter} stack?` : `Are you sure you want to deploy the [ ${formattedFilter} ] stacks?`
|
|
7516
7468
|
});
|
|
7517
|
-
if (!ok
|
|
7469
|
+
if (!ok) {
|
|
7518
7470
|
throw new Cancelled();
|
|
7519
7471
|
}
|
|
7520
7472
|
}
|
|
@@ -7532,12 +7484,15 @@ var deploy = (program2) => {
|
|
|
7532
7484
|
profile,
|
|
7533
7485
|
region
|
|
7534
7486
|
});
|
|
7535
|
-
await task(
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
|
|
7540
|
-
|
|
7487
|
+
await log16.task({
|
|
7488
|
+
initialMessage: "Deploying the stacks to AWS",
|
|
7489
|
+
successMessage: "Done deploying the stacks to AWS.",
|
|
7490
|
+
async task() {
|
|
7491
|
+
await workspace.deploy(app, {
|
|
7492
|
+
filters: stackNames
|
|
7493
|
+
});
|
|
7494
|
+
await pullRemoteState(app, state2);
|
|
7495
|
+
}
|
|
7541
7496
|
});
|
|
7542
7497
|
playSuccessSound();
|
|
7543
7498
|
return "Your app is ready!";
|
|
@@ -7551,7 +7506,7 @@ import {
|
|
|
7551
7506
|
AdminSetUserPasswordCommand,
|
|
7552
7507
|
CognitoIdentityProviderClient
|
|
7553
7508
|
} from "@aws-sdk/client-cognito-identity-provider";
|
|
7554
|
-
import {
|
|
7509
|
+
import { prompt as prompt6 } from "@awsless/clui";
|
|
7555
7510
|
var create = (program2) => {
|
|
7556
7511
|
program2.command("create").argument("[name]", "The name of the auth instance").description("Create an user for your userpool").action(async (name) => {
|
|
7557
7512
|
await layout("auth user create", async ({ appConfig, stackConfigs }) => {
|
|
@@ -7559,22 +7514,21 @@ var create = (program2) => {
|
|
|
7559
7514
|
const profile = appConfig.profile;
|
|
7560
7515
|
const credentials = getCredentials(profile);
|
|
7561
7516
|
const accountId = await getAccountId(credentials, region);
|
|
7517
|
+
if (Object.keys(appConfig.defaults.auth ?? {}).length === 0) {
|
|
7518
|
+
throw new ExpectedError("No auth resources are defined.");
|
|
7519
|
+
}
|
|
7562
7520
|
if (!name) {
|
|
7563
|
-
|
|
7521
|
+
name = await prompt6.select({
|
|
7564
7522
|
message: "Select the auth userpool:",
|
|
7565
|
-
initialValue: Object.keys(appConfig.defaults.auth)
|
|
7523
|
+
initialValue: Object.keys(appConfig.defaults.auth).at(0),
|
|
7566
7524
|
options: Object.keys(appConfig.defaults.auth).map((name2) => ({
|
|
7567
7525
|
label: name2,
|
|
7568
7526
|
value: name2
|
|
7569
7527
|
}))
|
|
7570
7528
|
});
|
|
7571
|
-
if (isCancel6(selectedName)) {
|
|
7572
|
-
throw new Cancelled();
|
|
7573
|
-
}
|
|
7574
|
-
name = selectedName;
|
|
7575
7529
|
}
|
|
7576
7530
|
if (!(name in appConfig.defaults.auth)) {
|
|
7577
|
-
throw new
|
|
7531
|
+
throw new ExpectedError(`Provided auth name doesn't exist inside your app config.`);
|
|
7578
7532
|
}
|
|
7579
7533
|
const { shared, app } = createApp({ appConfig, stackConfigs, accountId });
|
|
7580
7534
|
const { workspace } = await createWorkSpace({
|
|
@@ -7588,9 +7542,9 @@ var create = (program2) => {
|
|
|
7588
7542
|
try {
|
|
7589
7543
|
userPoolId = await shared.entry("auth", `user-pool-id`, name);
|
|
7590
7544
|
} catch (_) {
|
|
7591
|
-
throw new
|
|
7545
|
+
throw new ExpectedError(`The auth userpool hasn't been deployed yet.`);
|
|
7592
7546
|
}
|
|
7593
|
-
const user2 = await
|
|
7547
|
+
const user2 = await prompt6.text({
|
|
7594
7548
|
message: "Username:",
|
|
7595
7549
|
validate(value) {
|
|
7596
7550
|
if (!value) {
|
|
@@ -7599,12 +7553,8 @@ var create = (program2) => {
|
|
|
7599
7553
|
return;
|
|
7600
7554
|
}
|
|
7601
7555
|
});
|
|
7602
|
-
|
|
7603
|
-
throw new Cancelled();
|
|
7604
|
-
}
|
|
7605
|
-
const pass = await password({
|
|
7556
|
+
const pass = await prompt6.password({
|
|
7606
7557
|
message: "Password:",
|
|
7607
|
-
mask: "*",
|
|
7608
7558
|
validate(value) {
|
|
7609
7559
|
if (!value) {
|
|
7610
7560
|
return "Required";
|
|
@@ -7612,9 +7562,6 @@ var create = (program2) => {
|
|
|
7612
7562
|
return;
|
|
7613
7563
|
}
|
|
7614
7564
|
});
|
|
7615
|
-
if (isCancel6(user2)) {
|
|
7616
|
-
throw new Cancelled();
|
|
7617
|
-
}
|
|
7618
7565
|
const client = new CognitoIdentityProviderClient({
|
|
7619
7566
|
region,
|
|
7620
7567
|
credentials
|
|
@@ -7654,7 +7601,7 @@ var auth = (program2) => {
|
|
|
7654
7601
|
};
|
|
7655
7602
|
|
|
7656
7603
|
// src/cli/command/bind.ts
|
|
7657
|
-
import { log as
|
|
7604
|
+
import { log as log17 } from "@awsless/clui";
|
|
7658
7605
|
import { constantCase as constantCase12 } from "change-case";
|
|
7659
7606
|
import { spawn } from "child_process";
|
|
7660
7607
|
var bind = (program2) => {
|
|
@@ -7677,9 +7624,9 @@ var bind = (program2) => {
|
|
|
7677
7624
|
env[name] = await value;
|
|
7678
7625
|
}
|
|
7679
7626
|
if (Object.keys(env).length > 0) {
|
|
7680
|
-
|
|
7627
|
+
log17.list("Bind Env", env);
|
|
7681
7628
|
} else {
|
|
7682
|
-
|
|
7629
|
+
log17.warning("No bindings available.");
|
|
7683
7630
|
}
|
|
7684
7631
|
const configList = opts.config ?? [];
|
|
7685
7632
|
const configs = {};
|
|
@@ -7687,7 +7634,7 @@ var bind = (program2) => {
|
|
|
7687
7634
|
configs[`CONFIG_${constantCase12(name)}`] = name;
|
|
7688
7635
|
}
|
|
7689
7636
|
if (configList.length ?? 0 > 0) {
|
|
7690
|
-
|
|
7637
|
+
log17.note("Bind Config", configList.map((v) => color.label(constantCase12(v))).join("\n"));
|
|
7691
7638
|
}
|
|
7692
7639
|
if (commands7.length === 0) {
|
|
7693
7640
|
return "No command to execute.";
|
|
@@ -7746,7 +7693,7 @@ var watchConfig = async (options, resolve, reject) => {
|
|
|
7746
7693
|
};
|
|
7747
7694
|
|
|
7748
7695
|
// src/cli/ui/complex/build-types.ts
|
|
7749
|
-
import { log as
|
|
7696
|
+
import { log as log18 } from "@awsless/clui";
|
|
7750
7697
|
|
|
7751
7698
|
// src/type-gen/generate.ts
|
|
7752
7699
|
import { mkdir as mkdir5, writeFile as writeFile4 } from "fs/promises";
|
|
@@ -7780,7 +7727,7 @@ var generateTypes = async (props) => {
|
|
|
7780
7727
|
// src/cli/ui/complex/build-types.ts
|
|
7781
7728
|
var buildTypes = async (props) => {
|
|
7782
7729
|
await generateTypes(props);
|
|
7783
|
-
|
|
7730
|
+
log18.step("Done generating type definition files.");
|
|
7784
7731
|
};
|
|
7785
7732
|
|
|
7786
7733
|
// src/cli/command/dev.ts
|
|
@@ -7804,8 +7751,8 @@ var dev = (program2) => {
|
|
|
7804
7751
|
};
|
|
7805
7752
|
|
|
7806
7753
|
// src/cli/command/resources.ts
|
|
7807
|
-
import { log as
|
|
7808
|
-
import
|
|
7754
|
+
import { log as log19 } from "@awsless/clui";
|
|
7755
|
+
import chalk5 from "chalk";
|
|
7809
7756
|
import wildstring5 from "wildstring";
|
|
7810
7757
|
var resources = (program2) => {
|
|
7811
7758
|
program2.command("resources").argument("[stacks...]", "Optionally filter stack resources to list").description(`List all defined resources in your app`).action(async (filters) => {
|
|
@@ -7826,24 +7773,21 @@ var resources = (program2) => {
|
|
|
7826
7773
|
continue;
|
|
7827
7774
|
}
|
|
7828
7775
|
}
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
for (const resource of stack.resources) {
|
|
7832
|
-
line(formatResource(stack, resource.$.urn));
|
|
7833
|
-
}
|
|
7776
|
+
log19.step(chalk5.magenta(stack.name));
|
|
7777
|
+
log19.message(stack.resources.map((resource) => formatResource(stack, resource.$.urn)).join("\n"));
|
|
7834
7778
|
}
|
|
7835
7779
|
});
|
|
7836
7780
|
});
|
|
7837
7781
|
};
|
|
7838
7782
|
|
|
7839
7783
|
// src/cli/command/run.ts
|
|
7784
|
+
import { prompt as prompt7 } from "@awsless/clui";
|
|
7840
7785
|
import { DynamoDBClient, dynamoDBClient } from "@awsless/dynamodb";
|
|
7841
7786
|
import { iotClient, IoTDataPlaneClient } from "@awsless/iot";
|
|
7842
7787
|
import { LambdaClient as LambdaClient2, lambdaClient } from "@awsless/lambda";
|
|
7843
7788
|
import { S3Client as S3Client2, s3Client } from "@awsless/s3";
|
|
7844
7789
|
import { SNSClient, snsClient } from "@awsless/sns";
|
|
7845
7790
|
import { SQSClient, sqsClient } from "@awsless/sqs";
|
|
7846
|
-
import { isCancel as isCancel7, select as select2 } from "@clack/prompts";
|
|
7847
7791
|
import { tsImport } from "tsx/esm/api";
|
|
7848
7792
|
var run = (program2) => {
|
|
7849
7793
|
program2.command("run").allowUnknownOption(true).argument("[command]", "The command you want to run").description("Run one of your defined commands.").action(async (selected) => {
|
|
@@ -7858,7 +7802,7 @@ var run = (program2) => {
|
|
|
7858
7802
|
return cmd.name === selected;
|
|
7859
7803
|
});
|
|
7860
7804
|
} else {
|
|
7861
|
-
|
|
7805
|
+
command = await prompt7.select({
|
|
7862
7806
|
message: "Pick the command you want to run:",
|
|
7863
7807
|
initialValue: commands7[0],
|
|
7864
7808
|
options: commands7.map((cmd) => ({
|
|
@@ -7867,10 +7811,6 @@ var run = (program2) => {
|
|
|
7867
7811
|
hint: cmd.description
|
|
7868
7812
|
}))
|
|
7869
7813
|
});
|
|
7870
|
-
if (isCancel7(selected2)) {
|
|
7871
|
-
throw new Cancelled();
|
|
7872
|
-
}
|
|
7873
|
-
command = selected2;
|
|
7874
7814
|
}
|
|
7875
7815
|
if (!command) {
|
|
7876
7816
|
throw new ExpectedError(`The provided command doesn't exist.`);
|
|
@@ -7891,16 +7831,12 @@ var run = (program2) => {
|
|
|
7891
7831
|
iotClient.set(new IoTDataPlaneClient({ region, credentials }));
|
|
7892
7832
|
sqsClient.set(new SQSClient({ region, credentials }));
|
|
7893
7833
|
s3Client.set(new S3Client2({ region, credentials }));
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
7897
|
-
|
|
7898
|
-
credentials,
|
|
7899
|
-
accountId,
|
|
7900
|
-
update
|
|
7901
|
-
});
|
|
7834
|
+
await handler({
|
|
7835
|
+
region,
|
|
7836
|
+
credentials,
|
|
7837
|
+
accountId
|
|
7902
7838
|
});
|
|
7903
|
-
return
|
|
7839
|
+
return;
|
|
7904
7840
|
});
|
|
7905
7841
|
});
|
|
7906
7842
|
};
|
|
@@ -7922,7 +7858,7 @@ var pull = (program2) => {
|
|
|
7922
7858
|
};
|
|
7923
7859
|
|
|
7924
7860
|
// src/cli/command/state/push.ts
|
|
7925
|
-
import {
|
|
7861
|
+
import { prompt as prompt8 } from "@awsless/clui";
|
|
7926
7862
|
var push = (program2) => {
|
|
7927
7863
|
program2.command("push").description("Push the local state to the remote server").action(async () => {
|
|
7928
7864
|
await layout("state pull", async ({ appConfig, stackConfigs }) => {
|
|
@@ -7932,11 +7868,11 @@ var push = (program2) => {
|
|
|
7932
7868
|
const accountId = await getAccountId(credentials, region);
|
|
7933
7869
|
const { app } = createApp({ appConfig, stackConfigs, accountId });
|
|
7934
7870
|
const { state: state2 } = await createWorkSpace({ credentials, region, accountId, profile });
|
|
7935
|
-
const ok = await
|
|
7871
|
+
const ok = await prompt8.confirm({
|
|
7936
7872
|
message: "Pushing up the local state might corrupt your remote state. Are you sure?",
|
|
7937
7873
|
initialValue: false
|
|
7938
7874
|
});
|
|
7939
|
-
if (!ok
|
|
7875
|
+
if (!ok) {
|
|
7940
7876
|
throw new Cancelled();
|
|
7941
7877
|
}
|
|
7942
7878
|
await pushRemoteState(app, state2);
|
|
@@ -7946,7 +7882,7 @@ var push = (program2) => {
|
|
|
7946
7882
|
};
|
|
7947
7883
|
|
|
7948
7884
|
// src/cli/command/state/unlock.ts
|
|
7949
|
-
import {
|
|
7885
|
+
import { prompt as prompt9 } from "@awsless/clui";
|
|
7950
7886
|
var unlock = (program2) => {
|
|
7951
7887
|
program2.command("unlock").description("Release the lock that ensures sequential deployments").action(async () => {
|
|
7952
7888
|
await layout("state unlock", async ({ appConfig, stackConfigs }) => {
|
|
@@ -7960,11 +7896,11 @@ var unlock = (program2) => {
|
|
|
7960
7896
|
if (!isLocked) {
|
|
7961
7897
|
return "No lock is exists.";
|
|
7962
7898
|
}
|
|
7963
|
-
const ok = await
|
|
7899
|
+
const ok = await prompt9.confirm({
|
|
7964
7900
|
message: "Releasing the lock that ensures sequential deployments might result in corrupt state if a deployment is still running. Are you sure?",
|
|
7965
7901
|
initialValue: false
|
|
7966
7902
|
});
|
|
7967
|
-
if (!ok
|
|
7903
|
+
if (!ok) {
|
|
7968
7904
|
throw new Cancelled();
|
|
7969
7905
|
}
|
|
7970
7906
|
await lock.insecureReleaseLock(app.urn);
|
|
@@ -8008,8 +7944,8 @@ var types = (program2) => {
|
|
|
8008
7944
|
};
|
|
8009
7945
|
|
|
8010
7946
|
// src/cli/command/domain/list.ts
|
|
8011
|
-
import { log as
|
|
8012
|
-
var
|
|
7947
|
+
import { log as log20 } from "@awsless/clui";
|
|
7948
|
+
var list2 = (program2) => {
|
|
8013
7949
|
program2.command("list").description("List all domains").action(async () => {
|
|
8014
7950
|
await layout("domain list", async ({ appConfig, stackConfigs }) => {
|
|
8015
7951
|
const region = appConfig.region;
|
|
@@ -8030,7 +7966,7 @@ var list3 = (program2) => {
|
|
|
8030
7966
|
});
|
|
8031
7967
|
await workspace.hydrate(app);
|
|
8032
7968
|
for (const zone of domainZones) {
|
|
8033
|
-
|
|
7969
|
+
log20.step(
|
|
8034
7970
|
[
|
|
8035
7971
|
//
|
|
8036
7972
|
color.label.green(await zone.name),
|
|
@@ -8038,14 +7974,14 @@ var list3 = (program2) => {
|
|
|
8038
7974
|
color.dim(await zone.id)
|
|
8039
7975
|
].join(" ")
|
|
8040
7976
|
);
|
|
8041
|
-
|
|
7977
|
+
log20.message((await zone.nameServers).join("\n"));
|
|
8042
7978
|
}
|
|
8043
7979
|
});
|
|
8044
7980
|
});
|
|
8045
7981
|
};
|
|
8046
7982
|
|
|
8047
7983
|
// src/cli/command/domain/deploy.ts
|
|
8048
|
-
import { log as
|
|
7984
|
+
import { log as log21 } from "@awsless/clui";
|
|
8049
7985
|
var deploy2 = (program2) => {
|
|
8050
7986
|
program2.command("deploy").description("Deploy the domain zones to AWS").action(async () => {
|
|
8051
7987
|
await layout("domain deploy", async ({ appConfig, stackConfigs }) => {
|
|
@@ -8065,12 +8001,16 @@ var deploy2 = (program2) => {
|
|
|
8065
8001
|
profile,
|
|
8066
8002
|
region
|
|
8067
8003
|
});
|
|
8068
|
-
await task(
|
|
8069
|
-
|
|
8070
|
-
|
|
8004
|
+
await log21.task({
|
|
8005
|
+
initialMessage: "Deploying the domain zones to AWS...",
|
|
8006
|
+
successMessage: "Done deploying the domain zones to AWS.",
|
|
8007
|
+
errorMessage: "Failed deploying the domain zones to AWS.",
|
|
8008
|
+
async task() {
|
|
8009
|
+
await workspace.deploy(app, { filters: ["zones"] });
|
|
8010
|
+
}
|
|
8071
8011
|
});
|
|
8072
8012
|
for (const zone of domainZones) {
|
|
8073
|
-
|
|
8013
|
+
log21.step(
|
|
8074
8014
|
[
|
|
8075
8015
|
//
|
|
8076
8016
|
color.label.green(await zone.name),
|
|
@@ -8078,7 +8018,7 @@ var deploy2 = (program2) => {
|
|
|
8078
8018
|
color.dim(await zone.id)
|
|
8079
8019
|
].join(" ")
|
|
8080
8020
|
);
|
|
8081
|
-
|
|
8021
|
+
log21.message((await zone.nameServers).join("\n"));
|
|
8082
8022
|
}
|
|
8083
8023
|
});
|
|
8084
8024
|
});
|
|
@@ -8088,7 +8028,7 @@ var deploy2 = (program2) => {
|
|
|
8088
8028
|
var commands5 = [
|
|
8089
8029
|
//
|
|
8090
8030
|
deploy2,
|
|
8091
|
-
|
|
8031
|
+
list2
|
|
8092
8032
|
];
|
|
8093
8033
|
var domain = (program2) => {
|
|
8094
8034
|
const command = program2.command("domain").description(`Manage domains`);
|
|
@@ -8097,8 +8037,8 @@ var domain = (program2) => {
|
|
|
8097
8037
|
|
|
8098
8038
|
// src/cli/command/logs.ts
|
|
8099
8039
|
import { CloudWatchLogsClient, StartLiveTailCommand } from "@aws-sdk/client-cloudwatch-logs";
|
|
8100
|
-
import { log as
|
|
8101
|
-
import
|
|
8040
|
+
import { log as log22 } from "@awsless/clui";
|
|
8041
|
+
import chalk6 from "chalk";
|
|
8102
8042
|
import chunk2 from "chunk";
|
|
8103
8043
|
import { formatDate } from "date-fns";
|
|
8104
8044
|
import wildstring6 from "wildstring";
|
|
@@ -8139,25 +8079,29 @@ var logs = (program2) => {
|
|
|
8139
8079
|
process.once("SIGINT", () => {
|
|
8140
8080
|
abort.abort();
|
|
8141
8081
|
});
|
|
8142
|
-
const streams = await task(
|
|
8143
|
-
|
|
8144
|
-
|
|
8145
|
-
|
|
8146
|
-
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8082
|
+
const streams = await log22.task({
|
|
8083
|
+
initialMessage: "Connecting to the log stream...",
|
|
8084
|
+
errorMessage: "Failed to connect to the log stream.",
|
|
8085
|
+
async task(update) {
|
|
8086
|
+
const result = await Promise.all(
|
|
8087
|
+
chunk2(logGroupArns, 10).map(async (arns) => {
|
|
8088
|
+
const command = new StartLiveTailCommand({
|
|
8089
|
+
logGroupIdentifiers: arns
|
|
8090
|
+
});
|
|
8091
|
+
const response = await client.send(command, {
|
|
8092
|
+
abortSignal: abort.signal
|
|
8093
|
+
});
|
|
8094
|
+
if (!response.responseStream) {
|
|
8095
|
+
throw new Error("Failed to connect to the log stream.");
|
|
8096
|
+
}
|
|
8097
|
+
return response.responseStream;
|
|
8098
|
+
})
|
|
8099
|
+
);
|
|
8100
|
+
update(
|
|
8101
|
+
`Connected to ${result.length} log stream${plural(result.length)} for ${logGroupArns.length} function${plural(logGroupArns.length)}.`
|
|
8102
|
+
);
|
|
8103
|
+
return result;
|
|
8104
|
+
}
|
|
8161
8105
|
});
|
|
8162
8106
|
await Promise.all(
|
|
8163
8107
|
streams.map(async (stream) => {
|
|
@@ -8183,16 +8127,16 @@ var plural = (count) => {
|
|
|
8183
8127
|
};
|
|
8184
8128
|
var formatLog = (level, date, group, message) => {
|
|
8185
8129
|
const levels = {
|
|
8186
|
-
INFO:
|
|
8187
|
-
DEBUG:
|
|
8188
|
-
TRACE:
|
|
8189
|
-
WARN:
|
|
8190
|
-
ERROR:
|
|
8191
|
-
FATAL:
|
|
8192
|
-
SYSTEM:
|
|
8130
|
+
INFO: chalk6.cyan,
|
|
8131
|
+
DEBUG: chalk6.cyan,
|
|
8132
|
+
TRACE: chalk6.cyan,
|
|
8133
|
+
WARN: chalk6.yellow,
|
|
8134
|
+
ERROR: chalk6.red,
|
|
8135
|
+
FATAL: chalk6.magenta,
|
|
8136
|
+
SYSTEM: chalk6.blue
|
|
8193
8137
|
};
|
|
8194
|
-
const levelColor = levels[level] ??
|
|
8195
|
-
|
|
8138
|
+
const levelColor = levels[level] ?? chalk6.cyan;
|
|
8139
|
+
log22.message(
|
|
8196
8140
|
[
|
|
8197
8141
|
[
|
|
8198
8142
|
//
|
|
@@ -8200,11 +8144,9 @@ var formatLog = (level, date, group, message) => {
|
|
|
8200
8144
|
color.dim(formatDate(date, "HH:mm:ss")),
|
|
8201
8145
|
color.info(group)
|
|
8202
8146
|
].join(" "),
|
|
8203
|
-
|
|
8147
|
+
message
|
|
8204
8148
|
].join("\n"),
|
|
8205
|
-
|
|
8206
|
-
symbol: levelColor(icon.dot)
|
|
8207
|
-
}
|
|
8149
|
+
levelColor(icon.dot)
|
|
8208
8150
|
);
|
|
8209
8151
|
};
|
|
8210
8152
|
var parseJsonLog = (message) => {
|
|
@@ -8254,7 +8196,7 @@ var commands6 = [
|
|
|
8254
8196
|
];
|
|
8255
8197
|
|
|
8256
8198
|
// src/cli/program.ts
|
|
8257
|
-
var program = new
|
|
8199
|
+
var program = new Command();
|
|
8258
8200
|
program.name(logo());
|
|
8259
8201
|
program.option("--config-file <string>", "The app config file location");
|
|
8260
8202
|
program.option("--stage <string>", "The stage to use");
|