@awsless/awsless 0.0.20 → 0.0.22

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 (3) hide show
  1. package/dist/bin.cjs +77 -104
  2. package/dist/bin.js +77 -104
  3. package/package.json +1 -1
package/dist/bin.cjs CHANGED
@@ -522,7 +522,7 @@ var Stack = class {
522
522
  }
523
523
  }
524
524
  };
525
- for (const resource of this) {
525
+ for (const resource of this.resources) {
526
526
  const json2 = resource.toJSON();
527
527
  walk(json2);
528
528
  Object.assign(resources, json2);
@@ -604,9 +604,10 @@ var createDeploymentLine = (stacks) => {
604
604
  stack,
605
605
  depends: config?.depends?.map((dep) => dep.name) || []
606
606
  }));
607
+ const names = stacks.map(({ stack }) => stack.name);
607
608
  const line = [];
608
609
  const deps = [];
609
- let limit = 10;
610
+ let limit = 100;
610
611
  while (deps.length < list3.length) {
611
612
  const local = [];
612
613
  for (const { stack, depends } of list3) {
@@ -615,7 +616,8 @@ var createDeploymentLine = (stacks) => {
615
616
  }
616
617
  }
617
618
  if (limit-- <= 0) {
618
- throw new Error(`Circular stack dependencies arn't allowed.`);
619
+ const circularNames = names.filter((name) => deps.includes(name));
620
+ throw new Error(`Circular stack dependencies arn't allowed: ${circularNames}`);
619
621
  }
620
622
  deps.push(...local.map((stack) => stack.name));
621
623
  line.push(local);
@@ -4189,7 +4191,10 @@ var importFile = async (path) => {
4189
4191
  __dirname: (id) => `'${(0, import_path2.dirname)(id)}'`
4190
4192
  }),
4191
4193
  (0, import_rollup_plugin_swc32.swc)({
4192
- minify: false
4194
+ minify: false,
4195
+ jsc: {
4196
+ baseUrl: (0, import_path2.dirname)(path)
4197
+ }
4193
4198
  })
4194
4199
  ]
4195
4200
  });
@@ -5194,41 +5199,74 @@ var bootstrap = (program2) => {
5194
5199
  });
5195
5200
  };
5196
5201
 
5197
- // src/cli/ui/complex/stack-tree.ts
5198
- var stackTree = (nodes, statuses) => {
5202
+ // src/cli/ui/complex/deployer.ts
5203
+ var stacksDeployer = (deploymentLine) => {
5204
+ const stackNames = deploymentLine.map((line) => line.map((stack) => stack.name)).flat();
5205
+ const stackNameSize = Math.max(...stackNames.map((name) => name.length));
5199
5206
  return (term) => {
5200
- const render = (nodes2, deep = 0, parents = []) => {
5201
- const size = nodes2.length - 1;
5202
- nodes2.forEach((node, i) => {
5203
- const name = node.stack.name;
5204
- const status2 = statuses[name];
5205
- const first = i === 0 && deep === 0;
5206
- const last = i === size;
5207
- const more = i < size;
5208
- const line = flexLine(term, [
5209
- ...parents.map((parent) => {
5210
- return style.label(
5211
- parent ? "\u2502".padEnd(3) : " ".repeat(3)
5212
- );
5213
- }),
5214
- style.label(
5215
- first && size === 0 ? " " : first ? "\u250C\u2500" : last ? "\u2514\u2500" : "\u251C\u2500"
5216
- ),
5207
+ const ui = {};
5208
+ term.out.gap();
5209
+ for (const i in deploymentLine) {
5210
+ const line = flexLine(
5211
+ term,
5212
+ [" "],
5213
+ [
5217
5214
  " ",
5218
- style.info(name),
5219
- " "
5220
- ], [
5215
+ style.placeholder(Number(i) + 1),
5216
+ style.placeholder(" \u2500\u2500")
5217
+ ]
5218
+ );
5219
+ term.out.write(line);
5220
+ term.out.write(br());
5221
+ for (const stack of deploymentLine[i]) {
5222
+ const icon = new Signal(" ");
5223
+ const name = new Signal(style.label.dim(stack.name));
5224
+ const status2 = new Signal(style.info.dim("waiting"));
5225
+ let stopSpinner;
5226
+ term.out.write([
5227
+ icon,
5228
+ " ",
5229
+ name,
5230
+ " ".repeat(stackNameSize - stack.name.length),
5231
+ " ",
5232
+ style.placeholder(symbol.pointerSmall),
5221
5233
  " ",
5222
5234
  status2,
5223
5235
  br()
5224
5236
  ]);
5225
- term.out.write(line);
5226
- render(node.children, deep + 1, [...parents, more]);
5227
- });
5228
- };
5229
- term.out.gap();
5230
- render(nodes);
5237
+ ui[stack.name] = {
5238
+ start: (value) => {
5239
+ const [spinner, stop] = createSpinner();
5240
+ name.set(style.label(stack.name));
5241
+ icon.set(spinner);
5242
+ status2.set(style.warning(value));
5243
+ stopSpinner = stop;
5244
+ },
5245
+ done(value) {
5246
+ stopSpinner();
5247
+ icon.set(style.success(symbol.success));
5248
+ status2.set(style.success(value));
5249
+ },
5250
+ fail(value) {
5251
+ stopSpinner();
5252
+ icon.set(style.error(symbol.error));
5253
+ status2.set(style.error(value));
5254
+ },
5255
+ warn(value) {
5256
+ stopSpinner();
5257
+ icon.set(style.warning(symbol.warning));
5258
+ status2.set(style.warning(value));
5259
+ }
5260
+ };
5261
+ }
5262
+ }
5263
+ term.out.write(flexLine(term, [" "], [
5264
+ " ",
5265
+ style.warning("\u26A1\uFE0F"),
5266
+ style.placeholder("\u2500\u2500")
5267
+ ]));
5231
5268
  term.out.gap();
5269
+ return ui;
5232
5270
  };
5233
5271
  };
5234
5272
 
@@ -5236,31 +5274,27 @@ var stackTree = (nodes, statuses) => {
5236
5274
  var status = (program2) => {
5237
5275
  program2.command("status").argument("[stacks...]", "Optionally filter stacks to lookup status").description("View the application status").action(async (filters) => {
5238
5276
  await layout(async (config, write) => {
5239
- const { app, dependencyTree } = await toApp(config, filters);
5277
+ const { app, deploymentLine } = await toApp(config, filters);
5240
5278
  await cleanUp();
5241
5279
  await write(assetBuilder(app));
5242
5280
  await write(templateBuilder(app));
5243
5281
  const doneLoading = write(loadingDialog("Loading stack information..."));
5244
5282
  const client = new StackClient(app, config.account, config.region, config.credentials);
5245
5283
  const statuses = [];
5246
- const stackStatuses = {};
5247
- for (const stack of app) {
5248
- stackStatuses[stack.name] = new Signal(style.info("Loading..."));
5249
- }
5250
- write(stackTree(dependencyTree, stackStatuses));
5284
+ const ui = write(stacksDeployer(deploymentLine));
5251
5285
  debug("Load metadata for all deployed stacks on AWS");
5252
5286
  await Promise.all(app.stacks.map(async (stack, i) => {
5287
+ const item = ui[stack.name];
5288
+ item.start("loading");
5253
5289
  const info = await client.get(stack.name, stack.region);
5254
- const signal = stackStatuses[stack.name];
5255
- await new Promise((resolve) => setTimeout(resolve, i * 1e3));
5256
5290
  if (!info) {
5257
- signal.set(style.error("non-existent"));
5291
+ item.fail("NON EXISTENT");
5258
5292
  statuses.push("non-existent");
5259
5293
  } else if (info.template !== stack.toString()) {
5260
- signal.set(style.warning("out-of-date"));
5294
+ item.warn("OUT OF DATE");
5261
5295
  statuses.push("out-of-date");
5262
5296
  } else {
5263
- signal.set(style.success("up-to-date"));
5297
+ item.done("UP TO DATE");
5264
5298
  statuses.push("up-to-date");
5265
5299
  }
5266
5300
  }));
@@ -5339,67 +5373,6 @@ var assetPublisher = (config, app) => {
5339
5373
  };
5340
5374
  };
5341
5375
 
5342
- // src/cli/ui/complex/deployer.ts
5343
- var stacksDeployer = (deploymentLine) => {
5344
- const stackNames = deploymentLine.map((line) => line.map((stack) => stack.name)).flat();
5345
- const stackNameSize = Math.max(...stackNames.map((name) => name.length));
5346
- return (term) => {
5347
- const ui = {};
5348
- term.out.gap();
5349
- for (const i in deploymentLine) {
5350
- const line = flexLine(
5351
- term,
5352
- [" "],
5353
- [
5354
- " ",
5355
- style.placeholder(Number(i) + 1),
5356
- style.placeholder(" \u2500\u2500")
5357
- ]
5358
- );
5359
- term.out.write(line);
5360
- term.out.write(br());
5361
- for (const stack of deploymentLine[i]) {
5362
- const icon = new Signal(" ");
5363
- const name = new Signal(style.label.dim(stack.name));
5364
- const status2 = new Signal(style.info.dim("waiting"));
5365
- let stopSpinner;
5366
- term.out.write([
5367
- icon,
5368
- " ",
5369
- name,
5370
- " ".repeat(stackNameSize - stack.name.length),
5371
- " ",
5372
- style.placeholder(symbol.pointerSmall),
5373
- " ",
5374
- status2,
5375
- br()
5376
- ]);
5377
- ui[stack.name] = {
5378
- start: (value) => {
5379
- const [spinner, stop] = createSpinner();
5380
- name.set(style.label(stack.name));
5381
- icon.set(spinner);
5382
- status2.set(style.warning(value));
5383
- stopSpinner = stop;
5384
- },
5385
- done(value) {
5386
- stopSpinner();
5387
- icon.set(style.success(symbol.success));
5388
- status2.set(style.success(value));
5389
- },
5390
- fail(value) {
5391
- stopSpinner();
5392
- icon.set(style.error(symbol.error));
5393
- status2.set(style.error(value));
5394
- }
5395
- };
5396
- }
5397
- }
5398
- term.out.gap();
5399
- return ui;
5400
- };
5401
- };
5402
-
5403
5376
  // src/cli/command/deploy.ts
5404
5377
  var deploy = (program2) => {
5405
5378
  program2.command("deploy").argument("[stacks...]", "Optionally filter stacks to deploy").description("Deploy your app to AWS").action(async (filters) => {
package/dist/bin.js CHANGED
@@ -502,7 +502,7 @@ var Stack = class {
502
502
  }
503
503
  }
504
504
  };
505
- for (const resource of this) {
505
+ for (const resource of this.resources) {
506
506
  const json2 = resource.toJSON();
507
507
  walk(json2);
508
508
  Object.assign(resources, json2);
@@ -584,9 +584,10 @@ var createDeploymentLine = (stacks) => {
584
584
  stack,
585
585
  depends: config?.depends?.map((dep) => dep.name) || []
586
586
  }));
587
+ const names = stacks.map(({ stack }) => stack.name);
587
588
  const line = [];
588
589
  const deps = [];
589
- let limit = 10;
590
+ let limit = 100;
590
591
  while (deps.length < list3.length) {
591
592
  const local = [];
592
593
  for (const { stack, depends } of list3) {
@@ -595,7 +596,8 @@ var createDeploymentLine = (stacks) => {
595
596
  }
596
597
  }
597
598
  if (limit-- <= 0) {
598
- throw new Error(`Circular stack dependencies arn't allowed.`);
599
+ const circularNames = names.filter((name) => deps.includes(name));
600
+ throw new Error(`Circular stack dependencies arn't allowed: ${circularNames}`);
599
601
  }
600
602
  deps.push(...local.map((stack) => stack.name));
601
603
  line.push(local);
@@ -4166,7 +4168,10 @@ var importFile = async (path) => {
4166
4168
  __dirname: (id) => `'${dirname(id)}'`
4167
4169
  }),
4168
4170
  swc2({
4169
- minify: false
4171
+ minify: false,
4172
+ jsc: {
4173
+ baseUrl: dirname(path)
4174
+ }
4170
4175
  })
4171
4176
  ]
4172
4177
  });
@@ -5171,41 +5176,74 @@ var bootstrap = (program2) => {
5171
5176
  });
5172
5177
  };
5173
5178
 
5174
- // src/cli/ui/complex/stack-tree.ts
5175
- var stackTree = (nodes, statuses) => {
5179
+ // src/cli/ui/complex/deployer.ts
5180
+ var stacksDeployer = (deploymentLine) => {
5181
+ const stackNames = deploymentLine.map((line) => line.map((stack) => stack.name)).flat();
5182
+ const stackNameSize = Math.max(...stackNames.map((name) => name.length));
5176
5183
  return (term) => {
5177
- const render = (nodes2, deep = 0, parents = []) => {
5178
- const size = nodes2.length - 1;
5179
- nodes2.forEach((node, i) => {
5180
- const name = node.stack.name;
5181
- const status2 = statuses[name];
5182
- const first = i === 0 && deep === 0;
5183
- const last = i === size;
5184
- const more = i < size;
5185
- const line = flexLine(term, [
5186
- ...parents.map((parent) => {
5187
- return style.label(
5188
- parent ? "\u2502".padEnd(3) : " ".repeat(3)
5189
- );
5190
- }),
5191
- style.label(
5192
- first && size === 0 ? " " : first ? "\u250C\u2500" : last ? "\u2514\u2500" : "\u251C\u2500"
5193
- ),
5184
+ const ui = {};
5185
+ term.out.gap();
5186
+ for (const i in deploymentLine) {
5187
+ const line = flexLine(
5188
+ term,
5189
+ [" "],
5190
+ [
5194
5191
  " ",
5195
- style.info(name),
5196
- " "
5197
- ], [
5192
+ style.placeholder(Number(i) + 1),
5193
+ style.placeholder(" \u2500\u2500")
5194
+ ]
5195
+ );
5196
+ term.out.write(line);
5197
+ term.out.write(br());
5198
+ for (const stack of deploymentLine[i]) {
5199
+ const icon = new Signal(" ");
5200
+ const name = new Signal(style.label.dim(stack.name));
5201
+ const status2 = new Signal(style.info.dim("waiting"));
5202
+ let stopSpinner;
5203
+ term.out.write([
5204
+ icon,
5205
+ " ",
5206
+ name,
5207
+ " ".repeat(stackNameSize - stack.name.length),
5208
+ " ",
5209
+ style.placeholder(symbol.pointerSmall),
5198
5210
  " ",
5199
5211
  status2,
5200
5212
  br()
5201
5213
  ]);
5202
- term.out.write(line);
5203
- render(node.children, deep + 1, [...parents, more]);
5204
- });
5205
- };
5206
- term.out.gap();
5207
- render(nodes);
5214
+ ui[stack.name] = {
5215
+ start: (value) => {
5216
+ const [spinner, stop] = createSpinner();
5217
+ name.set(style.label(stack.name));
5218
+ icon.set(spinner);
5219
+ status2.set(style.warning(value));
5220
+ stopSpinner = stop;
5221
+ },
5222
+ done(value) {
5223
+ stopSpinner();
5224
+ icon.set(style.success(symbol.success));
5225
+ status2.set(style.success(value));
5226
+ },
5227
+ fail(value) {
5228
+ stopSpinner();
5229
+ icon.set(style.error(symbol.error));
5230
+ status2.set(style.error(value));
5231
+ },
5232
+ warn(value) {
5233
+ stopSpinner();
5234
+ icon.set(style.warning(symbol.warning));
5235
+ status2.set(style.warning(value));
5236
+ }
5237
+ };
5238
+ }
5239
+ }
5240
+ term.out.write(flexLine(term, [" "], [
5241
+ " ",
5242
+ style.warning("\u26A1\uFE0F"),
5243
+ style.placeholder("\u2500\u2500")
5244
+ ]));
5208
5245
  term.out.gap();
5246
+ return ui;
5209
5247
  };
5210
5248
  };
5211
5249
 
@@ -5213,31 +5251,27 @@ var stackTree = (nodes, statuses) => {
5213
5251
  var status = (program2) => {
5214
5252
  program2.command("status").argument("[stacks...]", "Optionally filter stacks to lookup status").description("View the application status").action(async (filters) => {
5215
5253
  await layout(async (config, write) => {
5216
- const { app, dependencyTree } = await toApp(config, filters);
5254
+ const { app, deploymentLine } = await toApp(config, filters);
5217
5255
  await cleanUp();
5218
5256
  await write(assetBuilder(app));
5219
5257
  await write(templateBuilder(app));
5220
5258
  const doneLoading = write(loadingDialog("Loading stack information..."));
5221
5259
  const client = new StackClient(app, config.account, config.region, config.credentials);
5222
5260
  const statuses = [];
5223
- const stackStatuses = {};
5224
- for (const stack of app) {
5225
- stackStatuses[stack.name] = new Signal(style.info("Loading..."));
5226
- }
5227
- write(stackTree(dependencyTree, stackStatuses));
5261
+ const ui = write(stacksDeployer(deploymentLine));
5228
5262
  debug("Load metadata for all deployed stacks on AWS");
5229
5263
  await Promise.all(app.stacks.map(async (stack, i) => {
5264
+ const item = ui[stack.name];
5265
+ item.start("loading");
5230
5266
  const info = await client.get(stack.name, stack.region);
5231
- const signal = stackStatuses[stack.name];
5232
- await new Promise((resolve) => setTimeout(resolve, i * 1e3));
5233
5267
  if (!info) {
5234
- signal.set(style.error("non-existent"));
5268
+ item.fail("NON EXISTENT");
5235
5269
  statuses.push("non-existent");
5236
5270
  } else if (info.template !== stack.toString()) {
5237
- signal.set(style.warning("out-of-date"));
5271
+ item.warn("OUT OF DATE");
5238
5272
  statuses.push("out-of-date");
5239
5273
  } else {
5240
- signal.set(style.success("up-to-date"));
5274
+ item.done("UP TO DATE");
5241
5275
  statuses.push("up-to-date");
5242
5276
  }
5243
5277
  }));
@@ -5316,67 +5350,6 @@ var assetPublisher = (config, app) => {
5316
5350
  };
5317
5351
  };
5318
5352
 
5319
- // src/cli/ui/complex/deployer.ts
5320
- var stacksDeployer = (deploymentLine) => {
5321
- const stackNames = deploymentLine.map((line) => line.map((stack) => stack.name)).flat();
5322
- const stackNameSize = Math.max(...stackNames.map((name) => name.length));
5323
- return (term) => {
5324
- const ui = {};
5325
- term.out.gap();
5326
- for (const i in deploymentLine) {
5327
- const line = flexLine(
5328
- term,
5329
- [" "],
5330
- [
5331
- " ",
5332
- style.placeholder(Number(i) + 1),
5333
- style.placeholder(" \u2500\u2500")
5334
- ]
5335
- );
5336
- term.out.write(line);
5337
- term.out.write(br());
5338
- for (const stack of deploymentLine[i]) {
5339
- const icon = new Signal(" ");
5340
- const name = new Signal(style.label.dim(stack.name));
5341
- const status2 = new Signal(style.info.dim("waiting"));
5342
- let stopSpinner;
5343
- term.out.write([
5344
- icon,
5345
- " ",
5346
- name,
5347
- " ".repeat(stackNameSize - stack.name.length),
5348
- " ",
5349
- style.placeholder(symbol.pointerSmall),
5350
- " ",
5351
- status2,
5352
- br()
5353
- ]);
5354
- ui[stack.name] = {
5355
- start: (value) => {
5356
- const [spinner, stop] = createSpinner();
5357
- name.set(style.label(stack.name));
5358
- icon.set(spinner);
5359
- status2.set(style.warning(value));
5360
- stopSpinner = stop;
5361
- },
5362
- done(value) {
5363
- stopSpinner();
5364
- icon.set(style.success(symbol.success));
5365
- status2.set(style.success(value));
5366
- },
5367
- fail(value) {
5368
- stopSpinner();
5369
- icon.set(style.error(symbol.error));
5370
- status2.set(style.error(value));
5371
- }
5372
- };
5373
- }
5374
- }
5375
- term.out.gap();
5376
- return ui;
5377
- };
5378
- };
5379
-
5380
5353
  // src/cli/command/deploy.ts
5381
5354
  var deploy = (program2) => {
5382
5355
  program2.command("deploy").argument("[stacks...]", "Optionally filter stacks to deploy").description("Deploy your app to AWS").action(async (filters) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@awsless/awsless",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "repository": {