@awsless/awsless 0.0.291 → 0.0.293
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/README.MD +49 -0
- package/dist/bin.js +127 -101
- package/dist/build-json-schema.js +3 -3
- package/dist/{chunk-DVWXAVM2.js → chunk-S76KJGMT.js} +2 -2
- package/dist/server.js +1 -1
- package/dist/stack.json +1 -1
- package/package.json +8 -8
package/README.MD
CHANGED
|
@@ -14,12 +14,14 @@
|
|
|
14
14
|
|
|
15
15
|
- VPC
|
|
16
16
|
- Tests
|
|
17
|
+
- Commands
|
|
17
18
|
- Auth
|
|
18
19
|
- Config
|
|
19
20
|
- Domains
|
|
20
21
|
- Sites
|
|
21
22
|
- Functions
|
|
22
23
|
- Tasks
|
|
24
|
+
- Instances
|
|
23
25
|
- Database
|
|
24
26
|
- Tables
|
|
25
27
|
- Stores
|
|
@@ -78,6 +80,24 @@ Tasks are an lower cost alternative to queues.
|
|
|
78
80
|
}
|
|
79
81
|
```
|
|
80
82
|
|
|
83
|
+
## Instances
|
|
84
|
+
|
|
85
|
+
We use AWS EC2 Instances to provide low level server instances.
|
|
86
|
+
Tasks are an lower cost alternative to queues.
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"instances": {
|
|
91
|
+
"INSTANCE_NAME": {
|
|
92
|
+
"type": "t4g.nano",
|
|
93
|
+
"image": "ami-000000",
|
|
94
|
+
"code": "./src",
|
|
95
|
+
"command": "sh ./startup.sh",
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
81
101
|
## Tables
|
|
82
102
|
|
|
83
103
|
We use AWS DynamoDB to provide serverless tables.
|
|
@@ -239,3 +259,32 @@ We use AWS AppSync to provide a serverless GraphQL API.
|
|
|
239
259
|
}
|
|
240
260
|
}
|
|
241
261
|
```
|
|
262
|
+
|
|
263
|
+
## Auth
|
|
264
|
+
|
|
265
|
+
We use AWS Cognito to provide a serverless Authentication API.
|
|
266
|
+
|
|
267
|
+
```json
|
|
268
|
+
{
|
|
269
|
+
"auth": {
|
|
270
|
+
"AUTH_USER_POOL_NAME": {
|
|
271
|
+
"allowUserRegistration": false,
|
|
272
|
+
"password": {
|
|
273
|
+
"minLength": 24
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
## Commands
|
|
281
|
+
|
|
282
|
+
You can define custom cli commands that you can run from the awsless cli tool.
|
|
283
|
+
|
|
284
|
+
```json
|
|
285
|
+
{
|
|
286
|
+
"commands": {
|
|
287
|
+
"COMMAND_NAME": "./cli/your-command.ts"
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
```
|
package/dist/bin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
CommandOptions
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-S76KJGMT.js";
|
|
5
5
|
|
|
6
6
|
// src/cli/program.ts
|
|
7
7
|
import { Command as Command2 } from "commander";
|
|
@@ -71,9 +71,11 @@ import {
|
|
|
71
71
|
ScalarAttributeType
|
|
72
72
|
} from "@aws-sdk/client-dynamodb";
|
|
73
73
|
import { CreateBucketCommand, HeadBucketCommand, S3Client, S3ServiceException } from "@aws-sdk/client-s3";
|
|
74
|
-
import { confirm, log } from "@clack/prompts";
|
|
74
|
+
import { confirm, isCancel, log } from "@clack/prompts";
|
|
75
75
|
|
|
76
76
|
// src/error.ts
|
|
77
|
+
var ExpectedError = class extends Error {
|
|
78
|
+
};
|
|
77
79
|
var ConfigError = class extends Error {
|
|
78
80
|
constructor(file, error, data) {
|
|
79
81
|
super(error.message);
|
|
@@ -347,7 +349,7 @@ var bootstrapAwsless = async (props) => {
|
|
|
347
349
|
const confirmed = await confirm({
|
|
348
350
|
message: "Would you like to bootstrap now?"
|
|
349
351
|
});
|
|
350
|
-
if (!confirmed) {
|
|
352
|
+
if (!confirmed || isCancel(confirmed)) {
|
|
351
353
|
throw new Cancelled();
|
|
352
354
|
}
|
|
353
355
|
}
|
|
@@ -981,8 +983,8 @@ import { z as z19 } from "zod";
|
|
|
981
983
|
var CommandSchema2 = z19.union([
|
|
982
984
|
z19.object({
|
|
983
985
|
file: LocalFileSchema,
|
|
984
|
-
handler: z19.string().default("default"),
|
|
985
|
-
description: z19.string().optional()
|
|
986
|
+
handler: z19.string().default("default").describe("The name of the handler that needs to run"),
|
|
987
|
+
description: z19.string().optional().describe("A description of the command")
|
|
986
988
|
// options: z.record(ResourceIdSchema, OptionSchema).optional(),
|
|
987
989
|
// arguments: z.record(ResourceIdSchema, ArgumentSchema).optional(),
|
|
988
990
|
}),
|
|
@@ -992,7 +994,7 @@ var CommandSchema2 = z19.union([
|
|
|
992
994
|
description: void 0
|
|
993
995
|
}))
|
|
994
996
|
]);
|
|
995
|
-
var CommandsSchema = z19.record(ResourceIdSchema, CommandSchema2).optional().describe("Define the
|
|
997
|
+
var CommandsSchema = z19.record(ResourceIdSchema, CommandSchema2).optional().describe("Define the custom commands for your stack.");
|
|
996
998
|
|
|
997
999
|
// src/feature/config/schema.ts
|
|
998
1000
|
import { z as z20 } from "zod";
|
|
@@ -1568,8 +1570,81 @@ var logApp = (app) => {
|
|
|
1568
1570
|
};
|
|
1569
1571
|
|
|
1570
1572
|
// src/cli/ui/error/error.ts
|
|
1573
|
+
import { AppError as AppError2, StackError as StackError3 } from "@awsless/formation";
|
|
1571
1574
|
import { log as log6 } from "@clack/prompts";
|
|
1572
1575
|
|
|
1576
|
+
// src/cli/ui/error/app-error.ts
|
|
1577
|
+
import { StackError as StackError2 } from "@awsless/formation";
|
|
1578
|
+
import { log as log3 } from "@clack/prompts";
|
|
1579
|
+
|
|
1580
|
+
// src/cli/ui/error/stack-error.ts
|
|
1581
|
+
import { ResourceError } from "@awsless/formation";
|
|
1582
|
+
import { log as log2 } from "@clack/prompts";
|
|
1583
|
+
import { capitalCase as capitalCase2 } from "change-case";
|
|
1584
|
+
var formatOperation = (operation) => {
|
|
1585
|
+
const value = ` ${capitalCase2(operation)} `;
|
|
1586
|
+
switch (operation) {
|
|
1587
|
+
case "create":
|
|
1588
|
+
return color.success.bold.inverse(value);
|
|
1589
|
+
case "update":
|
|
1590
|
+
return color.warning.bold.inverse(value);
|
|
1591
|
+
case "delete":
|
|
1592
|
+
return color.error.bold.inverse(value);
|
|
1593
|
+
case "heal":
|
|
1594
|
+
return color.warning.bold.inverse(value);
|
|
1595
|
+
case "get":
|
|
1596
|
+
return color.info.bold.inverse(value);
|
|
1597
|
+
}
|
|
1598
|
+
};
|
|
1599
|
+
var logStackError = (error) => {
|
|
1600
|
+
log2.message(
|
|
1601
|
+
wrap([color.error(error.message), `Stack: ${error.stack}`].join("\n"), {
|
|
1602
|
+
hard: true
|
|
1603
|
+
}),
|
|
1604
|
+
{ symbol: color.error(icon.error) }
|
|
1605
|
+
);
|
|
1606
|
+
for (const issue of error.issues) {
|
|
1607
|
+
if (issue instanceof ResourceError) {
|
|
1608
|
+
log2.message(
|
|
1609
|
+
[
|
|
1610
|
+
formatOperation(issue.operation),
|
|
1611
|
+
"\n",
|
|
1612
|
+
wrap("URN: " + issue.urn, { hard: true }),
|
|
1613
|
+
"\n",
|
|
1614
|
+
wrap("ID: " + issue.id, { hard: true }),
|
|
1615
|
+
"\n\n",
|
|
1616
|
+
wrap(color.error(issue.message), { hard: true })
|
|
1617
|
+
// , '\n', color.error(issue.message)
|
|
1618
|
+
].join(""),
|
|
1619
|
+
{ symbol: color.error(icon.error) }
|
|
1620
|
+
);
|
|
1621
|
+
} else if (issue instanceof Error) {
|
|
1622
|
+
log2.message(wrap(color.error(issue.message), { hard: true }), {
|
|
1623
|
+
symbol: color.error(icon.error)
|
|
1624
|
+
});
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
};
|
|
1628
|
+
|
|
1629
|
+
// src/cli/ui/error/app-error.ts
|
|
1630
|
+
var logAppError = (error) => {
|
|
1631
|
+
log3.message(
|
|
1632
|
+
wrap([color.error(error.message), `App: ${error.app}`].join("\n"), {
|
|
1633
|
+
hard: true
|
|
1634
|
+
}),
|
|
1635
|
+
{ symbol: color.error(icon.error) }
|
|
1636
|
+
);
|
|
1637
|
+
for (const issue of error.issues) {
|
|
1638
|
+
if (issue instanceof StackError2) {
|
|
1639
|
+
logStackError(issue);
|
|
1640
|
+
} else if (issue instanceof Error) {
|
|
1641
|
+
log3.message(wrap(color.error(issue.message), { hard: true }), {
|
|
1642
|
+
symbol: color.error(icon.error)
|
|
1643
|
+
});
|
|
1644
|
+
}
|
|
1645
|
+
}
|
|
1646
|
+
};
|
|
1647
|
+
|
|
1573
1648
|
// src/cli/ui/error/config-error.ts
|
|
1574
1649
|
import * as p from "@clack/prompts";
|
|
1575
1650
|
var codeLine = (value, level = 0) => {
|
|
@@ -1653,88 +1728,15 @@ var logConfigError = (error) => {
|
|
|
1653
1728
|
}
|
|
1654
1729
|
};
|
|
1655
1730
|
|
|
1656
|
-
// src/cli/ui/error/error.ts
|
|
1657
|
-
import { AppError as AppError2, StackError as StackError3 } from "@awsless/formation";
|
|
1658
|
-
|
|
1659
|
-
// src/cli/ui/error/stack-error.ts
|
|
1660
|
-
import { ResourceError } from "@awsless/formation";
|
|
1661
|
-
import { log as log3 } from "@clack/prompts";
|
|
1662
|
-
import { capitalCase as capitalCase2 } from "change-case";
|
|
1663
|
-
var formatOperation = (operation) => {
|
|
1664
|
-
const value = ` ${capitalCase2(operation)} `;
|
|
1665
|
-
switch (operation) {
|
|
1666
|
-
case "create":
|
|
1667
|
-
return color.success.bold.inverse(value);
|
|
1668
|
-
case "update":
|
|
1669
|
-
return color.warning.bold.inverse(value);
|
|
1670
|
-
case "delete":
|
|
1671
|
-
return color.error.bold.inverse(value);
|
|
1672
|
-
case "heal":
|
|
1673
|
-
return color.warning.bold.inverse(value);
|
|
1674
|
-
case "get":
|
|
1675
|
-
return color.info.bold.inverse(value);
|
|
1676
|
-
}
|
|
1677
|
-
};
|
|
1678
|
-
var logStackError = (error) => {
|
|
1679
|
-
log3.message(
|
|
1680
|
-
wrap([color.error(error.message), `Stack: ${error.stack}`].join("\n"), {
|
|
1681
|
-
hard: true
|
|
1682
|
-
}),
|
|
1683
|
-
{ symbol: color.error(icon.error) }
|
|
1684
|
-
);
|
|
1685
|
-
for (const issue of error.issues) {
|
|
1686
|
-
if (issue instanceof ResourceError) {
|
|
1687
|
-
log3.message(
|
|
1688
|
-
[
|
|
1689
|
-
formatOperation(issue.operation),
|
|
1690
|
-
"\n",
|
|
1691
|
-
wrap("URN: " + issue.urn, { hard: true }),
|
|
1692
|
-
"\n",
|
|
1693
|
-
wrap("ID: " + issue.id, { hard: true }),
|
|
1694
|
-
"\n\n",
|
|
1695
|
-
wrap(color.error(issue.message), { hard: true })
|
|
1696
|
-
// , '\n', color.error(issue.message)
|
|
1697
|
-
].join(""),
|
|
1698
|
-
{ symbol: color.error(icon.error) }
|
|
1699
|
-
);
|
|
1700
|
-
} else if (issue instanceof Error) {
|
|
1701
|
-
log3.message(wrap(color.error(issue.message), { hard: true }), {
|
|
1702
|
-
symbol: color.error(icon.error)
|
|
1703
|
-
});
|
|
1704
|
-
}
|
|
1705
|
-
}
|
|
1706
|
-
};
|
|
1707
|
-
|
|
1708
1731
|
// src/cli/ui/error/file-error.ts
|
|
1709
|
-
import { log as log4 } from "@clack/prompts";
|
|
1710
|
-
var logFileError = (error) => {
|
|
1711
|
-
log4.message(
|
|
1712
|
-
wrap([color.error(error.message), color.dim(error.file)].join("\n"), {
|
|
1713
|
-
hard: true
|
|
1714
|
-
}),
|
|
1715
|
-
{ symbol: color.error(icon.error) }
|
|
1716
|
-
);
|
|
1717
|
-
};
|
|
1718
|
-
|
|
1719
|
-
// src/cli/ui/error/app-error.ts
|
|
1720
|
-
import { StackError as StackError2 } from "@awsless/formation";
|
|
1721
1732
|
import { log as log5 } from "@clack/prompts";
|
|
1722
|
-
var
|
|
1733
|
+
var logFileError = (error) => {
|
|
1723
1734
|
log5.message(
|
|
1724
|
-
wrap([color.error(error.message),
|
|
1735
|
+
wrap([color.error(error.message), color.dim(error.file)].join("\n"), {
|
|
1725
1736
|
hard: true
|
|
1726
1737
|
}),
|
|
1727
1738
|
{ symbol: color.error(icon.error) }
|
|
1728
1739
|
);
|
|
1729
|
-
for (const issue of error.issues) {
|
|
1730
|
-
if (issue instanceof StackError2) {
|
|
1731
|
-
logStackError(issue);
|
|
1732
|
-
} else if (issue instanceof Error) {
|
|
1733
|
-
log5.message(wrap(color.error(issue.message), { hard: true }), {
|
|
1734
|
-
symbol: color.error(icon.error)
|
|
1735
|
-
});
|
|
1736
|
-
}
|
|
1737
|
-
}
|
|
1738
1740
|
};
|
|
1739
1741
|
|
|
1740
1742
|
// src/cli/ui/error/error.ts
|
|
@@ -1745,6 +1747,10 @@ var logError = (error) => {
|
|
|
1745
1747
|
log6.message(color.error("Cancelled."), {
|
|
1746
1748
|
symbol: color.error(icon.error)
|
|
1747
1749
|
});
|
|
1750
|
+
} else if (error instanceof ExpectedError) {
|
|
1751
|
+
log6.message(error.message, {
|
|
1752
|
+
symbol: color.error(icon.error)
|
|
1753
|
+
});
|
|
1748
1754
|
} else if (error instanceof AppError2) {
|
|
1749
1755
|
logAppError(error);
|
|
1750
1756
|
} else if (error instanceof StackError3) {
|
|
@@ -2571,7 +2577,13 @@ var cacheFeature = defineFeature({
|
|
|
2571
2577
|
var commandFeature = defineFeature({
|
|
2572
2578
|
name: "command",
|
|
2573
2579
|
onStack(ctx) {
|
|
2580
|
+
const names = /* @__PURE__ */ new Set();
|
|
2574
2581
|
for (const [name, props] of Object.entries(ctx.stackConfig.commands ?? {})) {
|
|
2582
|
+
if (!names.has(name)) {
|
|
2583
|
+
names.add(name);
|
|
2584
|
+
} else {
|
|
2585
|
+
throw new FileError(ctx.stackConfig.file, `Duplicate command names aren't allowed: ${name}`);
|
|
2586
|
+
}
|
|
2575
2587
|
ctx.registerCommand({ name, ...props });
|
|
2576
2588
|
}
|
|
2577
2589
|
}
|
|
@@ -3478,7 +3490,7 @@ var httpFeature = defineFeature({
|
|
|
3478
3490
|
for (const [id, routes] of Object.entries(ctx.stackConfig.http ?? {})) {
|
|
3479
3491
|
const props = ctx.appConfig.defaults.http?.[id];
|
|
3480
3492
|
if (!props) {
|
|
3481
|
-
throw new
|
|
3493
|
+
throw new FileError(ctx.stackConfig.file, `Http definition is not defined on app level for "${id}"`);
|
|
3482
3494
|
}
|
|
3483
3495
|
const group = new Node8(ctx.stack, "http", id);
|
|
3484
3496
|
for (const [routeKey, routeProps] of Object.entries(routes)) {
|
|
@@ -4862,7 +4874,7 @@ var build2 = (program2) => {
|
|
|
4862
4874
|
};
|
|
4863
4875
|
|
|
4864
4876
|
// src/cli/command/config/set.ts
|
|
4865
|
-
import { spinner as spinner2, text } from "@clack/prompts";
|
|
4877
|
+
import { isCancel as isCancel2, spinner as spinner2, text } from "@clack/prompts";
|
|
4866
4878
|
var set = (program2) => {
|
|
4867
4879
|
program2.command("set <name>").description("Set a config value").action(async (name) => {
|
|
4868
4880
|
await layout("config set", async ({ appConfig }) => {
|
|
@@ -4882,9 +4894,12 @@ var set = (program2) => {
|
|
|
4882
4894
|
return;
|
|
4883
4895
|
}
|
|
4884
4896
|
});
|
|
4897
|
+
if (isCancel2(value)) {
|
|
4898
|
+
throw new Cancelled();
|
|
4899
|
+
}
|
|
4885
4900
|
const spin = spinner2();
|
|
4886
4901
|
spin.start("Saving remote config parameter");
|
|
4887
|
-
await params.set(name, value
|
|
4902
|
+
await params.set(name, value);
|
|
4888
4903
|
spin.stop(`Done saving remote config parameter.`);
|
|
4889
4904
|
});
|
|
4890
4905
|
});
|
|
@@ -4916,7 +4931,7 @@ var get = (program2) => {
|
|
|
4916
4931
|
};
|
|
4917
4932
|
|
|
4918
4933
|
// src/cli/command/config/delete.ts
|
|
4919
|
-
import { confirm as confirm2, spinner as spinner4 } from "@clack/prompts";
|
|
4934
|
+
import { confirm as confirm2, isCancel as isCancel3, spinner as spinner4 } from "@clack/prompts";
|
|
4920
4935
|
var del = (program2) => {
|
|
4921
4936
|
program2.command("delete <name>").description("Delete a config value").action(async (name) => {
|
|
4922
4937
|
await layout("config delete", async ({ appConfig }) => {
|
|
@@ -4929,7 +4944,7 @@ var del = (program2) => {
|
|
|
4929
4944
|
message: `Your deleting the ${color.info(name)} config parameter. Are you sure?`,
|
|
4930
4945
|
initialValue: false
|
|
4931
4946
|
});
|
|
4932
|
-
if (!ok) {
|
|
4947
|
+
if (!ok || isCancel3(ok)) {
|
|
4933
4948
|
throw new Cancelled();
|
|
4934
4949
|
}
|
|
4935
4950
|
const spin = spinner4();
|
|
@@ -5000,7 +5015,7 @@ var config = (program2) => {
|
|
|
5000
5015
|
};
|
|
5001
5016
|
|
|
5002
5017
|
// src/cli/command/delete.ts
|
|
5003
|
-
import { confirm as confirm3 } from "@clack/prompts";
|
|
5018
|
+
import { confirm as confirm3, isCancel as isCancel4 } from "@clack/prompts";
|
|
5004
5019
|
var del2 = (program2) => {
|
|
5005
5020
|
program2.command("delete").argument("[stacks...]", "Optionally filter stacks to delete").description("Delete your app from AWS").action(async (filters) => {
|
|
5006
5021
|
await layout("delete", async ({ appConfig, stackConfigs }) => {
|
|
@@ -5019,7 +5034,7 @@ var del2 = (program2) => {
|
|
|
5019
5034
|
"delete"
|
|
5020
5035
|
)} the [ ${formattedFilter} ] stacks?`
|
|
5021
5036
|
});
|
|
5022
|
-
if (!ok) {
|
|
5037
|
+
if (!ok || isCancel4(ok)) {
|
|
5023
5038
|
throw new Cancelled();
|
|
5024
5039
|
}
|
|
5025
5040
|
}
|
|
@@ -5039,7 +5054,7 @@ var del2 = (program2) => {
|
|
|
5039
5054
|
};
|
|
5040
5055
|
|
|
5041
5056
|
// src/cli/command/deploy.ts
|
|
5042
|
-
import { confirm as confirm4 } from "@clack/prompts";
|
|
5057
|
+
import { confirm as confirm4, isCancel as isCancel5 } from "@clack/prompts";
|
|
5043
5058
|
|
|
5044
5059
|
// src/cli/ui/complex/run-tests.ts
|
|
5045
5060
|
import { join as join11 } from "path";
|
|
@@ -5321,7 +5336,7 @@ var deploy = (program2) => {
|
|
|
5321
5336
|
const ok = await confirm4({
|
|
5322
5337
|
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?`
|
|
5323
5338
|
});
|
|
5324
|
-
if (!ok) {
|
|
5339
|
+
if (!ok || isCancel5(ok)) {
|
|
5325
5340
|
throw new Cancelled();
|
|
5326
5341
|
}
|
|
5327
5342
|
}
|
|
@@ -5352,7 +5367,7 @@ import {
|
|
|
5352
5367
|
CognitoIdentityProviderClient
|
|
5353
5368
|
} from "@aws-sdk/client-cognito-identity-provider";
|
|
5354
5369
|
import { unwrap as unwrap2 } from "@awsless/formation";
|
|
5355
|
-
import { password, select, text as text2 } from "@clack/prompts";
|
|
5370
|
+
import { isCancel as isCancel6, password, select, text as text2 } from "@clack/prompts";
|
|
5356
5371
|
var create = (program2) => {
|
|
5357
5372
|
program2.command("create").argument("[name]", "The name of the auth instance").description("Create an user for your userpool").action(async (name) => {
|
|
5358
5373
|
await layout("auth user create", async ({ appConfig, stackConfigs }) => {
|
|
@@ -5360,13 +5375,18 @@ var create = (program2) => {
|
|
|
5360
5375
|
const credentials = getCredentials(appConfig.profile);
|
|
5361
5376
|
const accountId = await getAccountId(credentials, region);
|
|
5362
5377
|
if (!name) {
|
|
5363
|
-
|
|
5378
|
+
const selectedName = await select({
|
|
5364
5379
|
message: "Select the auth userpool:",
|
|
5380
|
+
initialValue: Object.keys(appConfig.defaults.auth)[0],
|
|
5365
5381
|
options: Object.keys(appConfig.defaults.auth).map((name2) => ({
|
|
5366
5382
|
label: name2,
|
|
5367
5383
|
value: name2
|
|
5368
5384
|
}))
|
|
5369
5385
|
});
|
|
5386
|
+
if (isCancel6(selectedName)) {
|
|
5387
|
+
throw new Cancelled();
|
|
5388
|
+
}
|
|
5389
|
+
name = selectedName;
|
|
5370
5390
|
}
|
|
5371
5391
|
if (!(name in appConfig.defaults.auth)) {
|
|
5372
5392
|
throw new Error(`Provided auth name doesn't exist inside your app config.`);
|
|
@@ -5393,6 +5413,9 @@ var create = (program2) => {
|
|
|
5393
5413
|
return;
|
|
5394
5414
|
}
|
|
5395
5415
|
});
|
|
5416
|
+
if (isCancel6(user2)) {
|
|
5417
|
+
throw new Cancelled();
|
|
5418
|
+
}
|
|
5396
5419
|
const pass = await password({
|
|
5397
5420
|
message: "Password:",
|
|
5398
5421
|
mask: "*",
|
|
@@ -5403,6 +5426,9 @@ var create = (program2) => {
|
|
|
5403
5426
|
return;
|
|
5404
5427
|
}
|
|
5405
5428
|
});
|
|
5429
|
+
if (isCancel6(user2)) {
|
|
5430
|
+
throw new Cancelled();
|
|
5431
|
+
}
|
|
5406
5432
|
const client = new CognitoIdentityProviderClient({
|
|
5407
5433
|
region,
|
|
5408
5434
|
credentials
|
|
@@ -5613,11 +5639,11 @@ var resource = (program2) => {
|
|
|
5613
5639
|
};
|
|
5614
5640
|
|
|
5615
5641
|
// src/cli/command/run.ts
|
|
5616
|
-
import { isCancel, select as select2 } from "@clack/prompts";
|
|
5642
|
+
import { isCancel as isCancel7, select as select2 } from "@clack/prompts";
|
|
5617
5643
|
import { tsImport } from "tsx/esm/api";
|
|
5618
5644
|
var run = (program2) => {
|
|
5619
5645
|
program2.command("run").allowUnknownOption(true).argument("[command]", "The command you want to run").description("Run one of your defined commands.").action(async (selected) => {
|
|
5620
|
-
await layout(`run ${selected}`, async ({ appConfig, stackConfigs }) => {
|
|
5646
|
+
await layout(`run ${selected ?? ""}`, async ({ appConfig, stackConfigs }) => {
|
|
5621
5647
|
const region = appConfig.region;
|
|
5622
5648
|
const credentials = getCredentials(appConfig.profile);
|
|
5623
5649
|
const accountId = await getAccountId(credentials, region);
|
|
@@ -5637,13 +5663,13 @@ var run = (program2) => {
|
|
|
5637
5663
|
hint: cmd.description
|
|
5638
5664
|
}))
|
|
5639
5665
|
});
|
|
5640
|
-
if (
|
|
5666
|
+
if (isCancel7(selected2)) {
|
|
5641
5667
|
throw new Cancelled();
|
|
5642
5668
|
}
|
|
5643
5669
|
command = selected2;
|
|
5644
5670
|
}
|
|
5645
5671
|
if (!command) {
|
|
5646
|
-
throw new
|
|
5672
|
+
throw new ExpectedError(`The provided command doesn't exist.`);
|
|
5647
5673
|
}
|
|
5648
5674
|
process.env.APP = appConfig.name;
|
|
5649
5675
|
const module = await tsImport(command.file, {
|
|
@@ -5651,7 +5677,7 @@ var run = (program2) => {
|
|
|
5651
5677
|
});
|
|
5652
5678
|
const handler = module[command.handler];
|
|
5653
5679
|
if (!handler) {
|
|
5654
|
-
throw new
|
|
5680
|
+
throw new ExpectedError(`No "${command.handler}" handler found.`);
|
|
5655
5681
|
}
|
|
5656
5682
|
const result = await task("Running", (update) => {
|
|
5657
5683
|
const options = new CommandOptions(program2.args);
|
|
@@ -5683,7 +5709,7 @@ var pull = (program2) => {
|
|
|
5683
5709
|
};
|
|
5684
5710
|
|
|
5685
5711
|
// src/cli/command/state/push.ts
|
|
5686
|
-
import { confirm as confirm5 } from "@clack/prompts";
|
|
5712
|
+
import { confirm as confirm5, isCancel as isCancel8 } from "@clack/prompts";
|
|
5687
5713
|
var push = (program2) => {
|
|
5688
5714
|
program2.command("push").description("Push the local state to the remote server").action(async () => {
|
|
5689
5715
|
await layout("state pull", async ({ appConfig, stackConfigs }) => {
|
|
@@ -5696,7 +5722,7 @@ var push = (program2) => {
|
|
|
5696
5722
|
message: "Pushing up the local state might corrupt your remote state. Are you sure?",
|
|
5697
5723
|
initialValue: false
|
|
5698
5724
|
});
|
|
5699
|
-
if (!ok) {
|
|
5725
|
+
if (!ok || isCancel8(ok)) {
|
|
5700
5726
|
throw new Cancelled();
|
|
5701
5727
|
}
|
|
5702
5728
|
await pushRemoteState(app, stateProvider);
|
|
@@ -5706,7 +5732,7 @@ var push = (program2) => {
|
|
|
5706
5732
|
};
|
|
5707
5733
|
|
|
5708
5734
|
// src/cli/command/state/unlock.ts
|
|
5709
|
-
import { confirm as confirm6 } from "@clack/prompts";
|
|
5735
|
+
import { confirm as confirm6, isCancel as isCancel9 } from "@clack/prompts";
|
|
5710
5736
|
var unlock = (program2) => {
|
|
5711
5737
|
program2.command("unlock").description("Release the lock that ensures sequential deployments").action(async () => {
|
|
5712
5738
|
await layout("state unlock", async ({ appConfig, stackConfigs }) => {
|
|
@@ -5723,7 +5749,7 @@ var unlock = (program2) => {
|
|
|
5723
5749
|
message: "Releasing the lock that ensures sequential deployments might result in corrupt state if a deployment is still running. Are you sure?",
|
|
5724
5750
|
initialValue: false
|
|
5725
5751
|
});
|
|
5726
|
-
if (!ok) {
|
|
5752
|
+
if (!ok || isCancel9(ok)) {
|
|
5727
5753
|
throw new Cancelled();
|
|
5728
5754
|
}
|
|
5729
5755
|
await lockProvider.insecureReleaseLock(app.urn);
|
|
@@ -311,8 +311,8 @@ import { z as z9 } from "zod";
|
|
|
311
311
|
var CommandSchema = z9.union([
|
|
312
312
|
z9.object({
|
|
313
313
|
file: LocalFileSchema,
|
|
314
|
-
handler: z9.string().default("default"),
|
|
315
|
-
description: z9.string().optional()
|
|
314
|
+
handler: z9.string().default("default").describe("The name of the handler that needs to run"),
|
|
315
|
+
description: z9.string().optional().describe("A description of the command")
|
|
316
316
|
// options: z.record(ResourceIdSchema, OptionSchema).optional(),
|
|
317
317
|
// arguments: z.record(ResourceIdSchema, ArgumentSchema).optional(),
|
|
318
318
|
}),
|
|
@@ -322,7 +322,7 @@ var CommandSchema = z9.union([
|
|
|
322
322
|
description: void 0
|
|
323
323
|
}))
|
|
324
324
|
]);
|
|
325
|
-
var CommandsSchema = z9.record(ResourceIdSchema, CommandSchema).optional().describe("Define the
|
|
325
|
+
var CommandsSchema = z9.record(ResourceIdSchema, CommandSchema).optional().describe("Define the custom commands for your stack.");
|
|
326
326
|
|
|
327
327
|
// src/feature/config/schema.ts
|
|
328
328
|
import { z as z10 } from "zod";
|
|
@@ -9,14 +9,14 @@ var CommandOptions = class {
|
|
|
9
9
|
if (name in this.opts) {
|
|
10
10
|
return this.opts[name];
|
|
11
11
|
}
|
|
12
|
-
throw new Error(`
|
|
12
|
+
throw new Error(`CLI option "${name}" not found`);
|
|
13
13
|
}
|
|
14
14
|
getAssertType(name, type) {
|
|
15
15
|
const value = this.get(name);
|
|
16
16
|
if (typeof value === type) {
|
|
17
17
|
return value;
|
|
18
18
|
}
|
|
19
|
-
throw new Error(`
|
|
19
|
+
throw new Error(`CLI option "${name}" isn't a ${type} type`);
|
|
20
20
|
}
|
|
21
21
|
number(name) {
|
|
22
22
|
return this.getAssertType(name, "number");
|