@awsless/awsless 0.0.209 → 0.0.210

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 +123 -15
  2. package/package.json +6 -6
package/dist/bin.js CHANGED
@@ -1184,9 +1184,9 @@ var wrap = (lines, options) => {
1184
1184
  return wrapAnsi(typeof lines === "string" ? lines : lines.join("\n"), process.stdout.columns - 8, options);
1185
1185
  };
1186
1186
  var padText = (texts) => {
1187
- const size = Math.max(...texts.map((text2) => text2.length));
1188
- return (text2, padding = 0, fill) => {
1189
- return text2.padEnd(size + padding, fill);
1187
+ const size = Math.max(...texts.map((text3) => text3.length));
1188
+ return (text3, padding = 0, fill) => {
1189
+ return text3.padEnd(size + padding, fill);
1190
1190
  };
1191
1191
  };
1192
1192
  var task = async (message, cb) => {
@@ -1804,14 +1804,9 @@ var cacheFeature = defineFeature({
1804
1804
  ...props
1805
1805
  });
1806
1806
  ctx.onFunction(({ lambda }) => {
1807
- lambda.addEnvironment(
1808
- `CACHE_${constantCase2(ctx.stack.name)}_${constantCase2(id)}_HOST`,
1809
- cluster.address
1810
- );
1811
- lambda.addEnvironment(
1812
- `CACHE_${constantCase2(ctx.stack.name)}_${constantCase2(id)}_PORT`,
1813
- props.port.toString()
1814
- );
1807
+ const prefix = `CACHE_${constantCase2(ctx.stack.name)}_${constantCase2(id)}`;
1808
+ lambda.addEnvironment(`${prefix}_HOST`, cluster.address);
1809
+ lambda.addEnvironment(`${prefix}_PORT`, props.port.toString());
1815
1810
  });
1816
1811
  }
1817
1812
  }
@@ -2066,6 +2061,7 @@ var createLambdaFunction = (group, ctx, ns, id, local2) => {
2066
2061
  }
2067
2062
  const props = deepmerge(ctx.appConfig.defaults.function, local2);
2068
2063
  ctx.registerBuild("function", name, async (build3) => {
2064
+ props.file;
2069
2065
  const version = await fingerprintFromFile(props.file);
2070
2066
  return build3(version, async (write) => {
2071
2067
  const bundle = await bundleTypeScript({ file: props.file });
@@ -3975,7 +3971,7 @@ var restFeature = defineFeature({
3975
3971
  },
3976
3972
  onStack(ctx) {
3977
3973
  for (const [id, routes] of Object.entries(ctx.stackConfig.rest ?? {})) {
3978
- const restGroup = new Node18(ctx.base, "rest", id);
3974
+ const restGroup = new Node18(ctx.stack, "rest", id);
3979
3975
  for (const [routeKey, props] of Object.entries(routes)) {
3980
3976
  const group = new Node18(restGroup, "route", routeKey);
3981
3977
  const apiId = ctx.shared.get(`rest-${id}-id`);
@@ -4076,6 +4072,8 @@ var createApp = (props, filters = []) => {
4076
4072
  const builders = [];
4077
4073
  const allFunctions = [];
4078
4074
  const globalListeners = [];
4075
+ const allLocalListeners = {};
4076
+ const allLocalFunctions = {};
4079
4077
  for (const feature of features) {
4080
4078
  feature.onApp?.({
4081
4079
  ...props,
@@ -4105,6 +4103,8 @@ var createApp = (props, filters = []) => {
4105
4103
  const localListeners = [];
4106
4104
  const localFunctions = [];
4107
4105
  const stack = new Stack(app, stackConfig.name);
4106
+ allLocalListeners[stack.name] = localListeners;
4107
+ allLocalFunctions[stack.name] = localFunctions;
4108
4108
  for (const feature of features) {
4109
4109
  feature.onStack?.({
4110
4110
  ...props,
@@ -4142,10 +4142,22 @@ var createApp = (props, filters = []) => {
4142
4142
  listener(fn);
4143
4143
  }
4144
4144
  }
4145
+ for (const stackConfig of filterdStacks) {
4146
+ const functions = allLocalFunctions[stackConfig.name];
4147
+ for (const dependency of stackConfig.depends ?? []) {
4148
+ const listeners = allLocalListeners[dependency];
4149
+ for (const fn of functions) {
4150
+ for (const listener of listeners) {
4151
+ listener(fn);
4152
+ }
4153
+ }
4154
+ }
4155
+ }
4145
4156
  return {
4146
4157
  app,
4147
4158
  base,
4148
4159
  tests,
4160
+ shared,
4149
4161
  configs,
4150
4162
  builders
4151
4163
  // deploymentLine,
@@ -4324,7 +4336,7 @@ var commands = [
4324
4336
  list2
4325
4337
  ];
4326
4338
  var config = (program2) => {
4327
- const command = program2.command("config").description(`Manage app config's`);
4339
+ const command = program2.command("config").description(`Manage app config parameters`);
4328
4340
  commands.forEach((cb) => cb(command));
4329
4341
  };
4330
4342
 
@@ -4988,8 +5000,103 @@ var state = (program2) => {
4988
5000
  commands3.forEach((cb) => cb(command));
4989
5001
  };
4990
5002
 
5003
+ // src/cli/command/auth/user/create.ts
5004
+ import { unwrap } from "@awsless/formation";
5005
+ import {
5006
+ AdminCreateUserCommand,
5007
+ AdminSetUserPasswordCommand,
5008
+ CognitoIdentityProviderClient
5009
+ } from "@aws-sdk/client-cognito-identity-provider";
5010
+ import { password, select, text as text2 } from "@clack/prompts";
5011
+ var create = (program2) => {
5012
+ program2.command("create").argument("[name]", "The name of the auth instance").description("Create an user for your userpool").action(async (name) => {
5013
+ await layout("auth user create", async ({ appConfig, stackConfigs }) => {
5014
+ const region = appConfig.region;
5015
+ const credentials = getCredentials(appConfig.profile);
5016
+ const accountId = await getAccountId(credentials, region);
5017
+ if (!name) {
5018
+ name = await select({
5019
+ message: "Select the auth userpool:",
5020
+ options: Object.keys(appConfig.defaults.auth).map((name2) => ({
5021
+ label: name2,
5022
+ value: name2
5023
+ }))
5024
+ });
5025
+ }
5026
+ if (!(name in appConfig.defaults.auth)) {
5027
+ throw new Error(`Provided auth name doesn't exist inside your app config.`);
5028
+ }
5029
+ const { shared, app } = createApp({ appConfig, stackConfigs, accountId });
5030
+ const { workspace } = createWorkSpace({
5031
+ credentials,
5032
+ region
5033
+ });
5034
+ await workspace.hydrate(app);
5035
+ let userPoolId;
5036
+ try {
5037
+ userPoolId = unwrap(shared.get(`auth-${name}-user-pool-id`));
5038
+ } catch (_) {
5039
+ throw new Error(`The auth userpool hasn't been deployed yet.`);
5040
+ }
5041
+ const user2 = await text2({
5042
+ message: "Username:",
5043
+ validate(value) {
5044
+ if (!value) {
5045
+ return "Required";
5046
+ }
5047
+ return;
5048
+ }
5049
+ });
5050
+ const pass = await password({
5051
+ message: "Password:",
5052
+ mask: "*",
5053
+ validate(value) {
5054
+ if (!value) {
5055
+ return "Required";
5056
+ }
5057
+ return;
5058
+ }
5059
+ });
5060
+ const client = new CognitoIdentityProviderClient({
5061
+ region,
5062
+ credentials
5063
+ });
5064
+ await client.send(
5065
+ new AdminCreateUserCommand({
5066
+ UserPoolId: userPoolId,
5067
+ Username: user2.toString(),
5068
+ TemporaryPassword: pass.toString()
5069
+ })
5070
+ );
5071
+ await client.send(
5072
+ new AdminSetUserPasswordCommand({
5073
+ UserPoolId: userPoolId,
5074
+ Username: user2.toString(),
5075
+ Password: pass.toString(),
5076
+ Permanent: true
5077
+ })
5078
+ );
5079
+ return "User created.";
5080
+ });
5081
+ });
5082
+ };
5083
+
5084
+ // src/cli/command/auth/user/index.ts
5085
+ var commands4 = [create];
5086
+ var user = (program2) => {
5087
+ const command = program2.command("user").description(`Manage auth users`);
5088
+ commands4.forEach((cb) => cb(command));
5089
+ };
5090
+
5091
+ // src/cli/command/auth/index.ts
5092
+ var commands5 = [user];
5093
+ var auth = (program2) => {
5094
+ const command = program2.command("auth").description(`Manage auth`);
5095
+ commands5.forEach((cb) => cb(command));
5096
+ };
5097
+
4991
5098
  // src/cli/command/index.ts
4992
- var commands4 = [
5099
+ var commands6 = [
4993
5100
  bootstrap,
4994
5101
  types,
4995
5102
  build2,
@@ -4998,6 +5105,7 @@ var commands4 = [
4998
5105
  del2,
4999
5106
  dev,
5000
5107
  // bind,
5108
+ auth,
5001
5109
  state,
5002
5110
  resource,
5003
5111
  config,
@@ -5024,7 +5132,7 @@ program.on("option:skip-prompt", () => {
5024
5132
  program.on("option:no-cache", () => {
5025
5133
  process.env.NO_CACHE = program.opts().noCache ? "1" : void 0;
5026
5134
  });
5027
- commands4.forEach((fn) => fn(program));
5135
+ commands6.forEach((fn) => fn(program));
5028
5136
 
5029
5137
  // src/bin.ts
5030
5138
  program.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.209",
3
+ "version": "0.0.210",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -31,12 +31,12 @@
31
31
  "@awsless/lambda": "^0.0.18",
32
32
  "@awsless/open-search": "^0.0.12",
33
33
  "@awsless/redis": "^0.0.12",
34
- "@awsless/s3": "^0.0.10",
35
34
  "@awsless/sns": "^0.0.7",
36
35
  "@awsless/sqs": "^0.0.7",
36
+ "@awsless/s3": "^0.0.10",
37
+ "@awsless/validate": "^0.0.13",
37
38
  "@awsless/ssm": "^0.0.7",
38
- "@awsless/weak-cache": "^0.0.1",
39
- "@awsless/validate": "^0.0.13"
39
+ "@awsless/weak-cache": "^0.0.1"
40
40
  },
41
41
  "dependencies": {
42
42
  "@aws-appsync/utils": "^1.5.0",
@@ -97,11 +97,11 @@
97
97
  "wrap-ansi": "^8.1.0",
98
98
  "zod": "^3.21.4",
99
99
  "zod-to-json-schema": "^3.22.3",
100
+ "@awsless/formation": "^0.0.20",
100
101
  "@awsless/duration": "^0.0.1",
102
+ "@awsless/size": "^0.0.1",
101
103
  "@awsless/graphql": "^0.0.9",
102
- "@awsless/formation": "^0.0.19",
103
104
  "@awsless/validate": "^0.0.13",
104
- "@awsless/size": "^0.0.1",
105
105
  "@awsless/code": "^0.0.10"
106
106
  },
107
107
  "scripts": {