@awsless/awsless 0.0.619 → 0.0.621

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 CHANGED
@@ -1120,11 +1120,11 @@ var FunctionDefaultSchema = z15.object({
1120
1120
  // container
1121
1121
  warm: WarmSchema.default(0),
1122
1122
  vpc: VPCSchema.default(false),
1123
- log: LogSchema.default(true).transform((log30) => ({
1124
- retention: log30.retention ?? days(7),
1125
- level: "level" in log30 ? log30.level : "error",
1126
- system: "system" in log30 ? log30.system : "warn",
1127
- format: "format" in log30 ? log30.format : "json"
1123
+ log: LogSchema.default(true).transform((log31) => ({
1124
+ retention: log31.retention ?? days(7),
1125
+ level: "level" in log31 ? log31.level : "error",
1126
+ system: "system" in log31 ? log31.system : "warn",
1127
+ format: "format" in log31 ? log31.format : "json"
1128
1128
  })),
1129
1129
  timeout: TimeoutSchema.default("10 seconds"),
1130
1130
  memorySize: MemorySizeSchema.default("128 MB"),
@@ -1652,8 +1652,8 @@ var InstanceDefaultSchema = z25.object({
1652
1652
  permissions: PermissionsSchema2.optional(),
1653
1653
  healthCheck: HealthCheckSchema.optional(),
1654
1654
  // restartPolicy: RestartPolicySchema.default({ enabled: true }),
1655
- log: LogSchema2.default(true).transform((log30) => ({
1656
- retention: log30.retention ?? days4(7)
1655
+ log: LogSchema2.default(true).transform((log31) => ({
1656
+ retention: log31.retention ?? days4(7)
1657
1657
  }))
1658
1658
  }).default({});
1659
1659
 
@@ -6574,7 +6574,7 @@ var buildExecutable = async (input, outputPath, architecture) => {
6574
6574
  }
6575
6575
  if (!result.success) {
6576
6576
  throw new ExpectedError(`Executable build failed:
6577
- ${result.logs?.map((log30) => log30.message).join("\n")}`);
6577
+ ${result.logs?.map((log31) => log31.message).join("\n")}`);
6578
6578
  }
6579
6579
  const file = await readFile4(filePath);
6580
6580
  return {
@@ -8074,7 +8074,7 @@ var createApp = (props) => {
8074
8074
  region: props.appConfig.region,
8075
8075
  appName: props.appConfig.name
8076
8076
  });
8077
- const commands9 = [];
8077
+ const commands10 = [];
8078
8078
  const configs = /* @__PURE__ */ new Set();
8079
8079
  const functionsByConfig = {};
8080
8080
  const tests = [];
@@ -8142,7 +8142,7 @@ var createApp = (props) => {
8142
8142
  });
8143
8143
  },
8144
8144
  registerCommand(command) {
8145
- commands9.push(command);
8145
+ commands10.push(command);
8146
8146
  },
8147
8147
  registerDomainZone(zone) {
8148
8148
  domainZones.push(zone);
@@ -8243,7 +8243,7 @@ var createApp = (props) => {
8243
8243
  configs.add(name);
8244
8244
  },
8245
8245
  registerCommand(command) {
8246
- commands9.push(command);
8246
+ commands10.push(command);
8247
8247
  },
8248
8248
  registerDomainZone(zone) {
8249
8249
  domainZones.push(zone);
@@ -8339,7 +8339,7 @@ var createApp = (props) => {
8339
8339
  functionsByConfig,
8340
8340
  warnings,
8341
8341
  builders,
8342
- commands: commands9
8342
+ commands: commands10
8343
8343
  // deploymentLine,
8344
8344
  };
8345
8345
  };
@@ -8801,10 +8801,10 @@ var startTest = async (props) => {
8801
8801
  tests.push(entry);
8802
8802
  if ("task" in test2) {
8803
8803
  const task2 = test2.task;
8804
- for (const log30 of task2.logs ?? []) {
8804
+ for (const log31 of task2.logs ?? []) {
8805
8805
  entry.logs.push({
8806
- time: log30.time,
8807
- text: log30.content
8806
+ time: log31.time,
8807
+ text: log31.content
8808
8808
  });
8809
8809
  }
8810
8810
  }
@@ -8872,7 +8872,7 @@ var logTestLogs = (event) => {
8872
8872
  ].join(" "),
8873
8873
  color.line(icon.dot)
8874
8874
  );
8875
- log16.message(test2.logs.map((log30) => log30.text).join("\n"));
8875
+ log16.message(test2.logs.map((log31) => log31.text).join("\n"));
8876
8876
  }
8877
8877
  }
8878
8878
  };
@@ -9513,7 +9513,7 @@ import { log as log22 } from "@awsless/clui";
9513
9513
  import chalk4 from "chalk";
9514
9514
  import { constantCase as constantCase15 } from "change-case";
9515
9515
  var bind = (program2) => {
9516
- program2.command("bind").argument("[command...]", "The command to execute").option("--config <string...>", "List of config values that will be accessable", (v) => v.split(",")).description(`Bind your site environment variables to a command`).action(async (commands9 = [], opts) => {
9516
+ program2.command("bind").argument("[command...]", "The command to execute").option("--config <string...>", "List of config values that will be accessable", (v) => v.split(",")).description(`Bind your site environment variables to a command`).action(async (commands10 = [], opts) => {
9517
9517
  await layout("bind", async ({ appConfig, stackConfigs }) => {
9518
9518
  const region = appConfig.region;
9519
9519
  const profile = appConfig.profile;
@@ -9543,14 +9543,14 @@ var bind = (program2) => {
9543
9543
  if (configList.length ?? 0 > 0) {
9544
9544
  log22.note("Bind Config", configList.map((v) => color.label(constantCase15(v))).join("\n"));
9545
9545
  }
9546
- if (commands9.length === 0) {
9546
+ if (commands10.length === 0) {
9547
9547
  return "No command to execute.";
9548
9548
  }
9549
9549
  const freshCred = await credentials();
9550
9550
  console.log(chalk4.black(`\u2502`));
9551
- console.log(chalk4.black(`\u2514 ${chalk4.yellow(commands9.join(" "))}`));
9551
+ console.log(chalk4.black(`\u2514 ${chalk4.yellow(commands10.join(" "))}`));
9552
9552
  console.log("");
9553
- const instance = Bun.spawn(commands9, {
9553
+ const instance = Bun.spawn(commands10, {
9554
9554
  // cwd: process.cwd(),
9555
9555
  env: {
9556
9556
  // Pass the process env vars
@@ -9740,17 +9740,17 @@ var run = (program2) => {
9740
9740
  const region = appConfig.region;
9741
9741
  const credentials = await getCredentials(appConfig.profile);
9742
9742
  const accountId = await getAccountId(credentials, region);
9743
- const { commands: commands9, appId } = createApp({ appConfig, stackConfigs, accountId });
9743
+ const { commands: commands10, appId } = createApp({ appConfig, stackConfigs, accountId });
9744
9744
  let command;
9745
9745
  if (selected) {
9746
- command = commands9.find((cmd) => {
9746
+ command = commands10.find((cmd) => {
9747
9747
  return cmd.name === selected;
9748
9748
  });
9749
9749
  } else {
9750
9750
  command = await prompt11.select({
9751
9751
  message: "Pick the command you want to run:",
9752
- initialValue: commands9[0],
9753
- options: commands9.map((cmd) => ({
9752
+ initialValue: commands10[0],
9753
+ options: commands10.map((cmd) => ({
9754
9754
  value: cmd,
9755
9755
  label: cmd.name,
9756
9756
  hint: cmd.description
@@ -10359,8 +10359,89 @@ var icon2 = (program2) => {
10359
10359
  commands7.forEach((cb) => cb(command));
10360
10360
  };
10361
10361
 
10362
- // src/cli/command/index.ts
10362
+ // src/cli/command/cron/invoke.ts
10363
+ import { log as log30, prompt as prompt16 } from "@awsless/clui";
10364
+ import { invoke as invokeLambda, LambdaClient as LambdaClient4 } from "@awsless/lambda";
10365
+ var invoke = (program2) => {
10366
+ program2.command("invoke").description("Invoke a cronjob").argument("[stack]", "The stack name of the cronjob").argument("[name]", "The name of the cronjob").action(async (stack, name) => {
10367
+ await layout("cron invoke", async ({ appConfig, stackConfigs }) => {
10368
+ const region = appConfig.region;
10369
+ const profile = appConfig.profile;
10370
+ const credentials = await getCredentials(profile);
10371
+ if (!stack) {
10372
+ const cronStacks = stackConfigs.filter((stack2) => {
10373
+ if (Object.keys(stack2.crons ?? {}).length > 0) {
10374
+ return stack2;
10375
+ }
10376
+ return;
10377
+ });
10378
+ if (cronStacks.length === 0) {
10379
+ throw new ExpectedError("There are no crons defined inside your app.");
10380
+ }
10381
+ stack = await prompt16.select({
10382
+ message: "Select the stack:",
10383
+ options: cronStacks.map((stack2) => ({
10384
+ label: stack2.name,
10385
+ value: stack2.name
10386
+ }))
10387
+ });
10388
+ }
10389
+ const stackConfig = stackConfigs.find((s) => s.name === stack);
10390
+ if (!stackConfig) {
10391
+ throw new ExpectedError(`The stack "${stack}" doesn't exist.`);
10392
+ }
10393
+ const names = Object.keys(stackConfig.crons ?? {});
10394
+ if (!name) {
10395
+ name = await prompt16.select({
10396
+ message: "Select the cron:",
10397
+ options: names.map((name2) => ({
10398
+ label: name2,
10399
+ value: name2
10400
+ }))
10401
+ });
10402
+ }
10403
+ if (!names) {
10404
+ throw new ExpectedError(`No image resources are defined in stack "${stack}".`);
10405
+ }
10406
+ const functionName = formatLocalResourceName({
10407
+ appName: appConfig.name,
10408
+ stackName: stackConfig.name,
10409
+ resourceType: "cron",
10410
+ resourceName: name
10411
+ });
10412
+ const payload = stackConfig.crons?.[name]?.payload ?? {};
10413
+ const response = await log30.task({
10414
+ initialMessage: "Invoking cron...",
10415
+ successMessage: "Done invoking cron.",
10416
+ errorMessage: "Failed invoking cron.",
10417
+ task() {
10418
+ return invokeLambda({
10419
+ name: functionName,
10420
+ payload,
10421
+ client: new LambdaClient4({
10422
+ credentials,
10423
+ region
10424
+ })
10425
+ });
10426
+ }
10427
+ });
10428
+ log30.note("Response", JSON.stringify(response, void 0, 4));
10429
+ });
10430
+ });
10431
+ };
10432
+
10433
+ // src/cli/command/cron/index.ts
10363
10434
  var commands8 = [
10435
+ //
10436
+ invoke
10437
+ ];
10438
+ var cron = (program2) => {
10439
+ const command = program2.command("cron").description(`Manage crons`);
10440
+ commands8.forEach((cb) => cb(command));
10441
+ };
10442
+
10443
+ // src/cli/command/index.ts
10444
+ var commands9 = [
10364
10445
  bootstrap,
10365
10446
  types,
10366
10447
  build2,
@@ -10377,6 +10458,7 @@ var commands8 = [
10377
10458
  resources,
10378
10459
  config,
10379
10460
  test,
10461
+ cron,
10380
10462
  image,
10381
10463
  icon2
10382
10464
  ];
@@ -10401,7 +10483,7 @@ program.on("option:skip-prompt", () => {
10401
10483
  program.on("option:no-cache", () => {
10402
10484
  process.env.NO_CACHE = program.opts().cache === false ? "1" : void 0;
10403
10485
  });
10404
- commands8.forEach((fn) => fn(program));
10486
+ commands9.forEach((fn) => fn(program));
10405
10487
 
10406
10488
  // src/bin.ts
10407
10489
  program.parse(process.argv);
Binary file
Binary file
@@ -1 +1 @@
1
- 29e42274e3589b52fe72c8c4bdca163acdcb3a97
1
+ 22970c85ad535a245bb6bcd4fb0fd5b611fdff91
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.619",
3
+ "version": "0.0.621",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -33,22 +33,22 @@
33
33
  ]
34
34
  },
35
35
  "peerDependencies": {
36
- "@awsless/clui": "^0.0.8",
37
36
  "@awsless/big-float": "^0.1.5",
38
- "@awsless/dynamodb": "^0.3.11",
39
- "@awsless/iot": "^0.0.3",
37
+ "@awsless/cloudwatch": "^0.0.1",
38
+ "@awsless/clui": "^0.0.8",
40
39
  "@awsless/duration": "^0.0.4",
41
40
  "@awsless/json": "^0.0.10",
42
41
  "@awsless/lambda": "^0.0.35",
43
- "@awsless/open-search": "^0.0.21",
42
+ "@awsless/dynamodb": "^0.3.11",
44
43
  "@awsless/mqtt": "^0.0.2",
45
44
  "@awsless/s3": "^0.0.21",
46
- "@awsless/cloudwatch": "^0.0.1",
47
- "@awsless/sqs": "^0.0.16",
48
- "@awsless/ssm": "^0.0.7",
49
- "@awsless/redis": "^0.0.14",
45
+ "@awsless/open-search": "^0.0.21",
50
46
  "@awsless/sns": "^0.0.10",
51
47
  "@awsless/validate": "^0.1.3",
48
+ "@awsless/redis": "^0.0.14",
49
+ "@awsless/iot": "^0.0.3",
50
+ "@awsless/sqs": "^0.0.16",
51
+ "@awsless/ssm": "^0.0.7",
52
52
  "@awsless/weak-cache": "^0.0.1"
53
53
  },
54
54
  "dependencies": {
@@ -140,15 +140,15 @@
140
140
  "zod": "^3.24.2",
141
141
  "zod-to-json-schema": "^3.24.3",
142
142
  "@awsless/big-float": "^0.1.5",
143
+ "@awsless/cloudwatch": "^0.0.1",
143
144
  "@awsless/duration": "^0.0.4",
144
145
  "@awsless/json": "^0.0.10",
145
146
  "@awsless/graphql": "^0.0.9",
146
- "@awsless/scheduler": "^0.0.4",
147
147
  "@awsless/size": "^0.0.2",
148
+ "@awsless/scheduler": "^0.0.4",
148
149
  "@awsless/validate": "^0.1.3",
149
- "@awsless/cloudwatch": "^0.0.1",
150
- "@awsless/clui": "^0.0.8",
151
- "@awsless/ts-file-cache": "^0.0.12"
150
+ "@awsless/ts-file-cache": "^0.0.12",
151
+ "@awsless/clui": "^0.0.8"
152
152
  },
153
153
  "devDependencies": {
154
154
  "@hono/node-server": "1.19.9",