@awsless/awsless 0.0.190 → 0.0.191

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/bin.js +37 -8
  2. package/package.json +5 -5
package/dist/bin.js CHANGED
@@ -2415,9 +2415,12 @@ var configFeature = defineFeature({
2415
2415
  await ctx.write("config.d.ts", gen, true);
2416
2416
  },
2417
2417
  onStack(ctx) {
2418
- const configs = ctx.stackConfig.configs;
2418
+ const configs = ctx.stackConfig.configs ?? [];
2419
+ for (const name of configs) {
2420
+ ctx.registerConfig(name);
2421
+ }
2419
2422
  ctx.onFunction(({ lambda, policy }) => {
2420
- if (configs && configs.length) {
2423
+ if (configs.length) {
2421
2424
  lambda.addEnvironment("CONFIG", configs.join(","));
2422
2425
  policy.addStatement({
2423
2426
  actions: [
@@ -3962,6 +3965,7 @@ var createApp = (props, filters = []) => {
3962
3965
  const app = new App(props.appConfig.name);
3963
3966
  const base = new Stack(app, "base");
3964
3967
  const shared = new SharedData();
3968
+ const configs = /* @__PURE__ */ new Set();
3965
3969
  const tests = [];
3966
3970
  const builders = [];
3967
3971
  const allFunctions = [];
@@ -4015,6 +4019,9 @@ var createApp = (props, filters = []) => {
4015
4019
  },
4016
4020
  registerBuild(type, name, builder) {
4017
4021
  builders.push({ type, name, builder });
4022
+ },
4023
+ registerConfig(name) {
4024
+ configs.add(name);
4018
4025
  }
4019
4026
  });
4020
4027
  }
@@ -4033,6 +4040,7 @@ var createApp = (props, filters = []) => {
4033
4040
  app,
4034
4041
  base,
4035
4042
  tests,
4043
+ configs,
4036
4044
  builders
4037
4045
  // deploymentLine,
4038
4046
  };
@@ -4123,7 +4131,7 @@ var get = (program2) => {
4123
4131
  note2(
4124
4132
  list({
4125
4133
  Name: chalk4.magenta(name),
4126
- Value: value ?? color.error("(empty)")
4134
+ Value: value ?? color.warning("(empty)")
4127
4135
  })
4128
4136
  );
4129
4137
  });
@@ -4160,8 +4168,11 @@ import { log as log7, spinner as spinner5 } from "@clack/prompts";
4160
4168
  import chalk5 from "chalk";
4161
4169
  var list2 = (program2) => {
4162
4170
  program2.command("list").description(`List all config value's`).action(async () => {
4163
- await layout("config list", async ({ appConfig }) => {
4171
+ await layout("config list", async ({ appConfig, stackConfigs }) => {
4172
+ const region = appConfig.region;
4164
4173
  const credentials = getCredentials(appConfig.profile);
4174
+ const accountId = await getAccountId(credentials, region);
4175
+ const { configs } = createApp({ appConfig, stackConfigs, accountId });
4165
4176
  const params = new SsmStore({
4166
4177
  credentials,
4167
4178
  appConfig
@@ -4170,11 +4181,25 @@ var list2 = (program2) => {
4170
4181
  spin.start("Loading config parameters");
4171
4182
  const values = await params.list();
4172
4183
  spin.stop("Done loading config values.");
4173
- if (Object.keys(values).length > 0) {
4184
+ const requiredValues = [...configs].map((key) => {
4185
+ if (typeof values[key] !== "undefined") {
4186
+ return [chalk5.magenta(key), values[key]];
4187
+ } else {
4188
+ return [chalk5.magenta(key), color.warning("(empty)")];
4189
+ }
4190
+ });
4191
+ const unsusedValues = Object.entries(values).map(([key, value]) => {
4192
+ if (!configs.has(key)) {
4193
+ return [chalk5.magenta(key), `${value} ${color.error("(unused)")}`];
4194
+ }
4195
+ return void 0;
4196
+ }).filter(Boolean);
4197
+ const allValues = [...requiredValues, ...unsusedValues];
4198
+ if (requiredValues.length > 0) {
4174
4199
  console.log(
4175
4200
  table({
4176
4201
  head: ["name", "value"],
4177
- body: Object.entries(values).map(([k, v]) => [chalk5.magenta(k), v])
4202
+ body: allValues
4178
4203
  })
4179
4204
  );
4180
4205
  } else {
@@ -4204,7 +4229,7 @@ import { confirm as confirm3 } from "@clack/prompts";
4204
4229
  import { WorkSpace, aws as aws18, local } from "@awsless/formation";
4205
4230
  import { minutes as minutes4 } from "@awsless/duration";
4206
4231
  import { dirname as dirname8, join as join9 } from "path";
4207
- import { mkdir as mkdir2, readFile as readFile6, writeFile as writeFile2 } from "fs/promises";
4232
+ import { mkdir as mkdir2, readFile as readFile6, rm, writeFile as writeFile2 } from "fs/promises";
4208
4233
  var createWorkSpace = (props) => {
4209
4234
  const lockProvider = new aws18.dynamodb.LockProvider({
4210
4235
  ...props,
@@ -4233,7 +4258,11 @@ var pullRemoteState = async (app, stateProvider) => {
4233
4258
  const file = join9(directories.state, `${app.urn}.json`);
4234
4259
  const state2 = await stateProvider.get(app.urn);
4235
4260
  await mkdir2(dirname8(file), { recursive: true });
4236
- await writeFile2(file, JSON.stringify(state2, void 0, 2));
4261
+ if (typeof state2 === "undefined") {
4262
+ await rm(file);
4263
+ } else {
4264
+ await writeFile2(file, JSON.stringify(state2, void 0, 2));
4265
+ }
4237
4266
  };
4238
4267
  var pushRemoteState = async (app, stateProvider) => {
4239
4268
  const file = join9(directories.state, `${app.urn}.json`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.190",
3
+ "version": "0.0.191",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -28,9 +28,9 @@
28
28
  }
29
29
  },
30
30
  "peerDependencies": {
31
- "@awsless/redis": "^0.0.12",
32
- "@awsless/s3": "^0.0.10",
33
31
  "@awsless/lambda": "^0.0.18",
32
+ "@awsless/s3": "^0.0.10",
33
+ "@awsless/redis": "^0.0.12",
34
34
  "@awsless/sns": "^0.0.7",
35
35
  "@awsless/sqs": "^0.0.7",
36
36
  "@awsless/ssm": "^0.0.7",
@@ -97,10 +97,10 @@
97
97
  "zod": "^3.21.4",
98
98
  "zod-to-json-schema": "^3.22.3",
99
99
  "@awsless/duration": "^0.0.1",
100
- "@awsless/formation": "^0.0.13",
100
+ "@awsless/graphql": "^0.0.9",
101
101
  "@awsless/size": "^0.0.1",
102
+ "@awsless/formation": "^0.0.13",
102
103
  "@awsless/validate": "^0.0.13",
103
- "@awsless/graphql": "^0.0.9",
104
104
  "@awsless/code": "^0.0.10"
105
105
  },
106
106
  "scripts": {