@awsless/awsless 0.0.504 → 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 +369 -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 +12 -10
- 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;
|
|
@@ -7120,12 +7075,12 @@ var del2 = (program2) => {
|
|
|
7120
7075
|
if (!process.env.SKIP_PROMPT) {
|
|
7121
7076
|
const deployAll = filters.length === 0;
|
|
7122
7077
|
const deploySingle = filters.length === 1;
|
|
7123
|
-
const ok = await
|
|
7078
|
+
const ok = await prompt4.confirm({
|
|
7124
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(
|
|
7125
7080
|
"delete"
|
|
7126
7081
|
)} the [ ${formattedFilter} ] stacks?`
|
|
7127
7082
|
});
|
|
7128
|
-
if (!ok
|
|
7083
|
+
if (!ok) {
|
|
7129
7084
|
throw new Cancelled();
|
|
7130
7085
|
}
|
|
7131
7086
|
}
|
|
@@ -7149,12 +7104,12 @@ var del2 = (program2) => {
|
|
|
7149
7104
|
};
|
|
7150
7105
|
|
|
7151
7106
|
// src/cli/command/deploy.ts
|
|
7152
|
-
import {
|
|
7107
|
+
import { log as log16, prompt as prompt5 } from "@awsless/clui";
|
|
7153
7108
|
import wildstring4 from "wildstring";
|
|
7154
7109
|
|
|
7155
7110
|
// src/cli/ui/complex/run-tests.ts
|
|
7156
|
-
import { log as
|
|
7157
|
-
import
|
|
7111
|
+
import { log as log15 } from "@awsless/clui";
|
|
7112
|
+
import chalk4 from "chalk";
|
|
7158
7113
|
import { mkdir as mkdir4, readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
|
|
7159
7114
|
import { join as join15 } from "path";
|
|
7160
7115
|
import wildstring3 from "wildstring";
|
|
@@ -7276,8 +7231,8 @@ var CustomReporter = class {
|
|
|
7276
7231
|
this.cache = cache;
|
|
7277
7232
|
}
|
|
7278
7233
|
}
|
|
7279
|
-
onUserConsoleLog(
|
|
7280
|
-
this.logs.push(
|
|
7234
|
+
onUserConsoleLog(log23) {
|
|
7235
|
+
this.logs.push(log23.content.trimEnd());
|
|
7281
7236
|
}
|
|
7282
7237
|
runningTask(tasks) {
|
|
7283
7238
|
return tasks.find((t) => t.result?.state === "run");
|
|
@@ -7364,24 +7319,22 @@ var startTest = async (props) => {
|
|
|
7364
7319
|
|
|
7365
7320
|
// src/cli/ui/complex/run-tests.ts
|
|
7366
7321
|
var formatResult = (props) => {
|
|
7367
|
-
const
|
|
7322
|
+
const line = [`Test ${chalk4.magenta(props.stack)}`];
|
|
7368
7323
|
if (props.cached) {
|
|
7369
|
-
|
|
7324
|
+
line.push(color.warning(`(from cache)`));
|
|
7370
7325
|
}
|
|
7371
7326
|
if (props.event.passed > 0) {
|
|
7372
|
-
|
|
7327
|
+
line.push(color.success(`${props.event.passed} passed`));
|
|
7373
7328
|
}
|
|
7374
7329
|
if (props.event.failed > 0) {
|
|
7375
|
-
|
|
7330
|
+
line.push(color.error(`${props.event.failed} failed`));
|
|
7376
7331
|
}
|
|
7377
|
-
return
|
|
7332
|
+
return line.join(` `);
|
|
7378
7333
|
};
|
|
7379
7334
|
var logTestLogs = (event) => {
|
|
7380
7335
|
if (event.logs.length > 0) {
|
|
7381
|
-
|
|
7382
|
-
|
|
7383
|
-
});
|
|
7384
|
-
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"));
|
|
7385
7338
|
}
|
|
7386
7339
|
};
|
|
7387
7340
|
var logTestErrors = (event) => {
|
|
@@ -7392,7 +7345,7 @@ var logTestErrors = (event) => {
|
|
|
7392
7345
|
message,
|
|
7393
7346
|
comment.length > 0 ? color.dim(`//${comment}`) : ""
|
|
7394
7347
|
].join(" ");
|
|
7395
|
-
|
|
7348
|
+
log15.error(
|
|
7396
7349
|
[
|
|
7397
7350
|
//
|
|
7398
7351
|
color.error.inverse.bold(` FAIL `),
|
|
@@ -7401,18 +7354,11 @@ var logTestErrors = (event) => {
|
|
|
7401
7354
|
error.file,
|
|
7402
7355
|
color.dim(icon.arrow.right),
|
|
7403
7356
|
error.test,
|
|
7404
|
-
[
|
|
7405
|
-
`
|
|
7357
|
+
[`
|
|
7406
7358
|
|
|
7407
|
-
`,
|
|
7408
|
-
wrap(errorMessage, {
|
|
7409
|
-
hard: true
|
|
7410
|
-
}),
|
|
7411
|
-
...error.diff ? ["\n\n", error.diff] : []
|
|
7412
|
-
].join("")
|
|
7359
|
+
`, errorMessage, ...error.diff ? ["\n\n", error.diff] : []].join("")
|
|
7413
7360
|
// error.test,
|
|
7414
|
-
].join(" ")
|
|
7415
|
-
{ symbol: color.error(icon.error) }
|
|
7361
|
+
].join(" ")
|
|
7416
7362
|
);
|
|
7417
7363
|
});
|
|
7418
7364
|
};
|
|
@@ -7425,7 +7371,7 @@ var runTest = async (stack, dir, filters) => {
|
|
|
7425
7371
|
const raw = await readFile5(file, { encoding: "utf8" });
|
|
7426
7372
|
const data = JSON.parse(raw);
|
|
7427
7373
|
if (data.fingerprint === fingerprint) {
|
|
7428
|
-
|
|
7374
|
+
log15.step(
|
|
7429
7375
|
formatResult({
|
|
7430
7376
|
stack,
|
|
7431
7377
|
cached: true,
|
|
@@ -7517,10 +7463,10 @@ var deploy = (program2) => {
|
|
|
7517
7463
|
if (!process.env.SKIP_PROMPT) {
|
|
7518
7464
|
const deployAll = filters.length === 0;
|
|
7519
7465
|
const deploySingle = filters.length === 1;
|
|
7520
|
-
const ok = await
|
|
7466
|
+
const ok = await prompt5.confirm({
|
|
7521
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?`
|
|
7522
7468
|
});
|
|
7523
|
-
if (!ok
|
|
7469
|
+
if (!ok) {
|
|
7524
7470
|
throw new Cancelled();
|
|
7525
7471
|
}
|
|
7526
7472
|
}
|
|
@@ -7538,12 +7484,15 @@ var deploy = (program2) => {
|
|
|
7538
7484
|
profile,
|
|
7539
7485
|
region
|
|
7540
7486
|
});
|
|
7541
|
-
await task(
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
|
|
7546
|
-
|
|
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
|
+
}
|
|
7547
7496
|
});
|
|
7548
7497
|
playSuccessSound();
|
|
7549
7498
|
return "Your app is ready!";
|
|
@@ -7557,7 +7506,7 @@ import {
|
|
|
7557
7506
|
AdminSetUserPasswordCommand,
|
|
7558
7507
|
CognitoIdentityProviderClient
|
|
7559
7508
|
} from "@aws-sdk/client-cognito-identity-provider";
|
|
7560
|
-
import {
|
|
7509
|
+
import { prompt as prompt6 } from "@awsless/clui";
|
|
7561
7510
|
var create = (program2) => {
|
|
7562
7511
|
program2.command("create").argument("[name]", "The name of the auth instance").description("Create an user for your userpool").action(async (name) => {
|
|
7563
7512
|
await layout("auth user create", async ({ appConfig, stackConfigs }) => {
|
|
@@ -7565,22 +7514,21 @@ var create = (program2) => {
|
|
|
7565
7514
|
const profile = appConfig.profile;
|
|
7566
7515
|
const credentials = getCredentials(profile);
|
|
7567
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
|
+
}
|
|
7568
7520
|
if (!name) {
|
|
7569
|
-
|
|
7521
|
+
name = await prompt6.select({
|
|
7570
7522
|
message: "Select the auth userpool:",
|
|
7571
|
-
initialValue: Object.keys(appConfig.defaults.auth)
|
|
7523
|
+
initialValue: Object.keys(appConfig.defaults.auth).at(0),
|
|
7572
7524
|
options: Object.keys(appConfig.defaults.auth).map((name2) => ({
|
|
7573
7525
|
label: name2,
|
|
7574
7526
|
value: name2
|
|
7575
7527
|
}))
|
|
7576
7528
|
});
|
|
7577
|
-
if (isCancel6(selectedName)) {
|
|
7578
|
-
throw new Cancelled();
|
|
7579
|
-
}
|
|
7580
|
-
name = selectedName;
|
|
7581
7529
|
}
|
|
7582
7530
|
if (!(name in appConfig.defaults.auth)) {
|
|
7583
|
-
throw new
|
|
7531
|
+
throw new ExpectedError(`Provided auth name doesn't exist inside your app config.`);
|
|
7584
7532
|
}
|
|
7585
7533
|
const { shared, app } = createApp({ appConfig, stackConfigs, accountId });
|
|
7586
7534
|
const { workspace } = await createWorkSpace({
|
|
@@ -7594,9 +7542,9 @@ var create = (program2) => {
|
|
|
7594
7542
|
try {
|
|
7595
7543
|
userPoolId = await shared.entry("auth", `user-pool-id`, name);
|
|
7596
7544
|
} catch (_) {
|
|
7597
|
-
throw new
|
|
7545
|
+
throw new ExpectedError(`The auth userpool hasn't been deployed yet.`);
|
|
7598
7546
|
}
|
|
7599
|
-
const user2 = await
|
|
7547
|
+
const user2 = await prompt6.text({
|
|
7600
7548
|
message: "Username:",
|
|
7601
7549
|
validate(value) {
|
|
7602
7550
|
if (!value) {
|
|
@@ -7605,12 +7553,8 @@ var create = (program2) => {
|
|
|
7605
7553
|
return;
|
|
7606
7554
|
}
|
|
7607
7555
|
});
|
|
7608
|
-
|
|
7609
|
-
throw new Cancelled();
|
|
7610
|
-
}
|
|
7611
|
-
const pass = await password({
|
|
7556
|
+
const pass = await prompt6.password({
|
|
7612
7557
|
message: "Password:",
|
|
7613
|
-
mask: "*",
|
|
7614
7558
|
validate(value) {
|
|
7615
7559
|
if (!value) {
|
|
7616
7560
|
return "Required";
|
|
@@ -7618,9 +7562,6 @@ var create = (program2) => {
|
|
|
7618
7562
|
return;
|
|
7619
7563
|
}
|
|
7620
7564
|
});
|
|
7621
|
-
if (isCancel6(user2)) {
|
|
7622
|
-
throw new Cancelled();
|
|
7623
|
-
}
|
|
7624
7565
|
const client = new CognitoIdentityProviderClient({
|
|
7625
7566
|
region,
|
|
7626
7567
|
credentials
|
|
@@ -7660,7 +7601,7 @@ var auth = (program2) => {
|
|
|
7660
7601
|
};
|
|
7661
7602
|
|
|
7662
7603
|
// src/cli/command/bind.ts
|
|
7663
|
-
import { log as
|
|
7604
|
+
import { log as log17 } from "@awsless/clui";
|
|
7664
7605
|
import { constantCase as constantCase12 } from "change-case";
|
|
7665
7606
|
import { spawn } from "child_process";
|
|
7666
7607
|
var bind = (program2) => {
|
|
@@ -7683,9 +7624,9 @@ var bind = (program2) => {
|
|
|
7683
7624
|
env[name] = await value;
|
|
7684
7625
|
}
|
|
7685
7626
|
if (Object.keys(env).length > 0) {
|
|
7686
|
-
|
|
7627
|
+
log17.list("Bind Env", env);
|
|
7687
7628
|
} else {
|
|
7688
|
-
|
|
7629
|
+
log17.warning("No bindings available.");
|
|
7689
7630
|
}
|
|
7690
7631
|
const configList = opts.config ?? [];
|
|
7691
7632
|
const configs = {};
|
|
@@ -7693,7 +7634,7 @@ var bind = (program2) => {
|
|
|
7693
7634
|
configs[`CONFIG_${constantCase12(name)}`] = name;
|
|
7694
7635
|
}
|
|
7695
7636
|
if (configList.length ?? 0 > 0) {
|
|
7696
|
-
|
|
7637
|
+
log17.note("Bind Config", configList.map((v) => color.label(constantCase12(v))).join("\n"));
|
|
7697
7638
|
}
|
|
7698
7639
|
if (commands7.length === 0) {
|
|
7699
7640
|
return "No command to execute.";
|
|
@@ -7752,7 +7693,7 @@ var watchConfig = async (options, resolve, reject) => {
|
|
|
7752
7693
|
};
|
|
7753
7694
|
|
|
7754
7695
|
// src/cli/ui/complex/build-types.ts
|
|
7755
|
-
import { log as
|
|
7696
|
+
import { log as log18 } from "@awsless/clui";
|
|
7756
7697
|
|
|
7757
7698
|
// src/type-gen/generate.ts
|
|
7758
7699
|
import { mkdir as mkdir5, writeFile as writeFile4 } from "fs/promises";
|
|
@@ -7786,7 +7727,7 @@ var generateTypes = async (props) => {
|
|
|
7786
7727
|
// src/cli/ui/complex/build-types.ts
|
|
7787
7728
|
var buildTypes = async (props) => {
|
|
7788
7729
|
await generateTypes(props);
|
|
7789
|
-
|
|
7730
|
+
log18.step("Done generating type definition files.");
|
|
7790
7731
|
};
|
|
7791
7732
|
|
|
7792
7733
|
// src/cli/command/dev.ts
|
|
@@ -7810,8 +7751,8 @@ var dev = (program2) => {
|
|
|
7810
7751
|
};
|
|
7811
7752
|
|
|
7812
7753
|
// src/cli/command/resources.ts
|
|
7813
|
-
import { log as
|
|
7814
|
-
import
|
|
7754
|
+
import { log as log19 } from "@awsless/clui";
|
|
7755
|
+
import chalk5 from "chalk";
|
|
7815
7756
|
import wildstring5 from "wildstring";
|
|
7816
7757
|
var resources = (program2) => {
|
|
7817
7758
|
program2.command("resources").argument("[stacks...]", "Optionally filter stack resources to list").description(`List all defined resources in your app`).action(async (filters) => {
|
|
@@ -7832,24 +7773,21 @@ var resources = (program2) => {
|
|
|
7832
7773
|
continue;
|
|
7833
7774
|
}
|
|
7834
7775
|
}
|
|
7835
|
-
|
|
7836
|
-
|
|
7837
|
-
for (const resource of stack.resources) {
|
|
7838
|
-
line(formatResource(stack, resource.$.urn));
|
|
7839
|
-
}
|
|
7776
|
+
log19.step(chalk5.magenta(stack.name));
|
|
7777
|
+
log19.message(stack.resources.map((resource) => formatResource(stack, resource.$.urn)).join("\n"));
|
|
7840
7778
|
}
|
|
7841
7779
|
});
|
|
7842
7780
|
});
|
|
7843
7781
|
};
|
|
7844
7782
|
|
|
7845
7783
|
// src/cli/command/run.ts
|
|
7784
|
+
import { prompt as prompt7 } from "@awsless/clui";
|
|
7846
7785
|
import { DynamoDBClient, dynamoDBClient } from "@awsless/dynamodb";
|
|
7847
7786
|
import { iotClient, IoTDataPlaneClient } from "@awsless/iot";
|
|
7848
7787
|
import { LambdaClient as LambdaClient2, lambdaClient } from "@awsless/lambda";
|
|
7849
7788
|
import { S3Client as S3Client2, s3Client } from "@awsless/s3";
|
|
7850
7789
|
import { SNSClient, snsClient } from "@awsless/sns";
|
|
7851
7790
|
import { SQSClient, sqsClient } from "@awsless/sqs";
|
|
7852
|
-
import { isCancel as isCancel7, select as select2 } from "@clack/prompts";
|
|
7853
7791
|
import { tsImport } from "tsx/esm/api";
|
|
7854
7792
|
var run = (program2) => {
|
|
7855
7793
|
program2.command("run").allowUnknownOption(true).argument("[command]", "The command you want to run").description("Run one of your defined commands.").action(async (selected) => {
|
|
@@ -7864,7 +7802,7 @@ var run = (program2) => {
|
|
|
7864
7802
|
return cmd.name === selected;
|
|
7865
7803
|
});
|
|
7866
7804
|
} else {
|
|
7867
|
-
|
|
7805
|
+
command = await prompt7.select({
|
|
7868
7806
|
message: "Pick the command you want to run:",
|
|
7869
7807
|
initialValue: commands7[0],
|
|
7870
7808
|
options: commands7.map((cmd) => ({
|
|
@@ -7873,10 +7811,6 @@ var run = (program2) => {
|
|
|
7873
7811
|
hint: cmd.description
|
|
7874
7812
|
}))
|
|
7875
7813
|
});
|
|
7876
|
-
if (isCancel7(selected2)) {
|
|
7877
|
-
throw new Cancelled();
|
|
7878
|
-
}
|
|
7879
|
-
command = selected2;
|
|
7880
7814
|
}
|
|
7881
7815
|
if (!command) {
|
|
7882
7816
|
throw new ExpectedError(`The provided command doesn't exist.`);
|
|
@@ -7897,16 +7831,12 @@ var run = (program2) => {
|
|
|
7897
7831
|
iotClient.set(new IoTDataPlaneClient({ region, credentials }));
|
|
7898
7832
|
sqsClient.set(new SQSClient({ region, credentials }));
|
|
7899
7833
|
s3Client.set(new S3Client2({ region, credentials }));
|
|
7900
|
-
|
|
7901
|
-
|
|
7902
|
-
|
|
7903
|
-
|
|
7904
|
-
credentials,
|
|
7905
|
-
accountId,
|
|
7906
|
-
update
|
|
7907
|
-
});
|
|
7834
|
+
await handler({
|
|
7835
|
+
region,
|
|
7836
|
+
credentials,
|
|
7837
|
+
accountId
|
|
7908
7838
|
});
|
|
7909
|
-
return
|
|
7839
|
+
return;
|
|
7910
7840
|
});
|
|
7911
7841
|
});
|
|
7912
7842
|
};
|
|
@@ -7928,7 +7858,7 @@ var pull = (program2) => {
|
|
|
7928
7858
|
};
|
|
7929
7859
|
|
|
7930
7860
|
// src/cli/command/state/push.ts
|
|
7931
|
-
import {
|
|
7861
|
+
import { prompt as prompt8 } from "@awsless/clui";
|
|
7932
7862
|
var push = (program2) => {
|
|
7933
7863
|
program2.command("push").description("Push the local state to the remote server").action(async () => {
|
|
7934
7864
|
await layout("state pull", async ({ appConfig, stackConfigs }) => {
|
|
@@ -7938,11 +7868,11 @@ var push = (program2) => {
|
|
|
7938
7868
|
const accountId = await getAccountId(credentials, region);
|
|
7939
7869
|
const { app } = createApp({ appConfig, stackConfigs, accountId });
|
|
7940
7870
|
const { state: state2 } = await createWorkSpace({ credentials, region, accountId, profile });
|
|
7941
|
-
const ok = await
|
|
7871
|
+
const ok = await prompt8.confirm({
|
|
7942
7872
|
message: "Pushing up the local state might corrupt your remote state. Are you sure?",
|
|
7943
7873
|
initialValue: false
|
|
7944
7874
|
});
|
|
7945
|
-
if (!ok
|
|
7875
|
+
if (!ok) {
|
|
7946
7876
|
throw new Cancelled();
|
|
7947
7877
|
}
|
|
7948
7878
|
await pushRemoteState(app, state2);
|
|
@@ -7952,7 +7882,7 @@ var push = (program2) => {
|
|
|
7952
7882
|
};
|
|
7953
7883
|
|
|
7954
7884
|
// src/cli/command/state/unlock.ts
|
|
7955
|
-
import {
|
|
7885
|
+
import { prompt as prompt9 } from "@awsless/clui";
|
|
7956
7886
|
var unlock = (program2) => {
|
|
7957
7887
|
program2.command("unlock").description("Release the lock that ensures sequential deployments").action(async () => {
|
|
7958
7888
|
await layout("state unlock", async ({ appConfig, stackConfigs }) => {
|
|
@@ -7966,11 +7896,11 @@ var unlock = (program2) => {
|
|
|
7966
7896
|
if (!isLocked) {
|
|
7967
7897
|
return "No lock is exists.";
|
|
7968
7898
|
}
|
|
7969
|
-
const ok = await
|
|
7899
|
+
const ok = await prompt9.confirm({
|
|
7970
7900
|
message: "Releasing the lock that ensures sequential deployments might result in corrupt state if a deployment is still running. Are you sure?",
|
|
7971
7901
|
initialValue: false
|
|
7972
7902
|
});
|
|
7973
|
-
if (!ok
|
|
7903
|
+
if (!ok) {
|
|
7974
7904
|
throw new Cancelled();
|
|
7975
7905
|
}
|
|
7976
7906
|
await lock.insecureReleaseLock(app.urn);
|
|
@@ -8014,8 +7944,8 @@ var types = (program2) => {
|
|
|
8014
7944
|
};
|
|
8015
7945
|
|
|
8016
7946
|
// src/cli/command/domain/list.ts
|
|
8017
|
-
import { log as
|
|
8018
|
-
var
|
|
7947
|
+
import { log as log20 } from "@awsless/clui";
|
|
7948
|
+
var list2 = (program2) => {
|
|
8019
7949
|
program2.command("list").description("List all domains").action(async () => {
|
|
8020
7950
|
await layout("domain list", async ({ appConfig, stackConfigs }) => {
|
|
8021
7951
|
const region = appConfig.region;
|
|
@@ -8036,7 +7966,7 @@ var list3 = (program2) => {
|
|
|
8036
7966
|
});
|
|
8037
7967
|
await workspace.hydrate(app);
|
|
8038
7968
|
for (const zone of domainZones) {
|
|
8039
|
-
|
|
7969
|
+
log20.step(
|
|
8040
7970
|
[
|
|
8041
7971
|
//
|
|
8042
7972
|
color.label.green(await zone.name),
|
|
@@ -8044,14 +7974,14 @@ var list3 = (program2) => {
|
|
|
8044
7974
|
color.dim(await zone.id)
|
|
8045
7975
|
].join(" ")
|
|
8046
7976
|
);
|
|
8047
|
-
|
|
7977
|
+
log20.message((await zone.nameServers).join("\n"));
|
|
8048
7978
|
}
|
|
8049
7979
|
});
|
|
8050
7980
|
});
|
|
8051
7981
|
};
|
|
8052
7982
|
|
|
8053
7983
|
// src/cli/command/domain/deploy.ts
|
|
8054
|
-
import { log as
|
|
7984
|
+
import { log as log21 } from "@awsless/clui";
|
|
8055
7985
|
var deploy2 = (program2) => {
|
|
8056
7986
|
program2.command("deploy").description("Deploy the domain zones to AWS").action(async () => {
|
|
8057
7987
|
await layout("domain deploy", async ({ appConfig, stackConfigs }) => {
|
|
@@ -8071,12 +8001,16 @@ var deploy2 = (program2) => {
|
|
|
8071
8001
|
profile,
|
|
8072
8002
|
region
|
|
8073
8003
|
});
|
|
8074
|
-
await task(
|
|
8075
|
-
|
|
8076
|
-
|
|
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
|
+
}
|
|
8077
8011
|
});
|
|
8078
8012
|
for (const zone of domainZones) {
|
|
8079
|
-
|
|
8013
|
+
log21.step(
|
|
8080
8014
|
[
|
|
8081
8015
|
//
|
|
8082
8016
|
color.label.green(await zone.name),
|
|
@@ -8084,7 +8018,7 @@ var deploy2 = (program2) => {
|
|
|
8084
8018
|
color.dim(await zone.id)
|
|
8085
8019
|
].join(" ")
|
|
8086
8020
|
);
|
|
8087
|
-
|
|
8021
|
+
log21.message((await zone.nameServers).join("\n"));
|
|
8088
8022
|
}
|
|
8089
8023
|
});
|
|
8090
8024
|
});
|
|
@@ -8094,7 +8028,7 @@ var deploy2 = (program2) => {
|
|
|
8094
8028
|
var commands5 = [
|
|
8095
8029
|
//
|
|
8096
8030
|
deploy2,
|
|
8097
|
-
|
|
8031
|
+
list2
|
|
8098
8032
|
];
|
|
8099
8033
|
var domain = (program2) => {
|
|
8100
8034
|
const command = program2.command("domain").description(`Manage domains`);
|
|
@@ -8103,8 +8037,8 @@ var domain = (program2) => {
|
|
|
8103
8037
|
|
|
8104
8038
|
// src/cli/command/logs.ts
|
|
8105
8039
|
import { CloudWatchLogsClient, StartLiveTailCommand } from "@aws-sdk/client-cloudwatch-logs";
|
|
8106
|
-
import { log as
|
|
8107
|
-
import
|
|
8040
|
+
import { log as log22 } from "@awsless/clui";
|
|
8041
|
+
import chalk6 from "chalk";
|
|
8108
8042
|
import chunk2 from "chunk";
|
|
8109
8043
|
import { formatDate } from "date-fns";
|
|
8110
8044
|
import wildstring6 from "wildstring";
|
|
@@ -8145,25 +8079,29 @@ var logs = (program2) => {
|
|
|
8145
8079
|
process.once("SIGINT", () => {
|
|
8146
8080
|
abort.abort();
|
|
8147
8081
|
});
|
|
8148
|
-
const streams = await task(
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8162
|
-
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
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
|
+
}
|
|
8167
8105
|
});
|
|
8168
8106
|
await Promise.all(
|
|
8169
8107
|
streams.map(async (stream) => {
|
|
@@ -8189,16 +8127,16 @@ var plural = (count) => {
|
|
|
8189
8127
|
};
|
|
8190
8128
|
var formatLog = (level, date, group, message) => {
|
|
8191
8129
|
const levels = {
|
|
8192
|
-
INFO:
|
|
8193
|
-
DEBUG:
|
|
8194
|
-
TRACE:
|
|
8195
|
-
WARN:
|
|
8196
|
-
ERROR:
|
|
8197
|
-
FATAL:
|
|
8198
|
-
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
|
|
8199
8137
|
};
|
|
8200
|
-
const levelColor = levels[level] ??
|
|
8201
|
-
|
|
8138
|
+
const levelColor = levels[level] ?? chalk6.cyan;
|
|
8139
|
+
log22.message(
|
|
8202
8140
|
[
|
|
8203
8141
|
[
|
|
8204
8142
|
//
|
|
@@ -8206,11 +8144,9 @@ var formatLog = (level, date, group, message) => {
|
|
|
8206
8144
|
color.dim(formatDate(date, "HH:mm:ss")),
|
|
8207
8145
|
color.info(group)
|
|
8208
8146
|
].join(" "),
|
|
8209
|
-
|
|
8147
|
+
message
|
|
8210
8148
|
].join("\n"),
|
|
8211
|
-
|
|
8212
|
-
symbol: levelColor(icon.dot)
|
|
8213
|
-
}
|
|
8149
|
+
levelColor(icon.dot)
|
|
8214
8150
|
);
|
|
8215
8151
|
};
|
|
8216
8152
|
var parseJsonLog = (message) => {
|
|
@@ -8260,7 +8196,7 @@ var commands6 = [
|
|
|
8260
8196
|
];
|
|
8261
8197
|
|
|
8262
8198
|
// src/cli/program.ts
|
|
8263
|
-
var program = new
|
|
8199
|
+
var program = new Command();
|
|
8264
8200
|
program.name(logo());
|
|
8265
8201
|
program.option("--config-file <string>", "The app config file location");
|
|
8266
8202
|
program.option("--stage <string>", "The stage to use");
|