alchemy 2.0.0-beta.16 → 2.0.0-beta.18

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 (99) hide show
  1. package/bin/alchemy.js +79 -6
  2. package/bin/alchemy.js.map +1 -1
  3. package/bin/cli.js +9 -7
  4. package/bin/commands/deploy.ts +11 -2
  5. package/bin/commands/profile.ts +21 -1
  6. package/bin/commands/state.ts +91 -1
  7. package/lib/AWS/CloudFront/CachePolicy.d.ts +106 -0
  8. package/lib/AWS/CloudFront/CachePolicy.d.ts.map +1 -0
  9. package/lib/AWS/CloudFront/CachePolicy.js +147 -0
  10. package/lib/AWS/CloudFront/CachePolicy.js.map +1 -0
  11. package/lib/AWS/CloudFront/KeyGroup.d.ts +72 -0
  12. package/lib/AWS/CloudFront/KeyGroup.d.ts.map +1 -0
  13. package/lib/AWS/CloudFront/KeyGroup.js +136 -0
  14. package/lib/AWS/CloudFront/KeyGroup.js.map +1 -0
  15. package/lib/AWS/CloudFront/OriginRequestPolicy.d.ts +84 -0
  16. package/lib/AWS/CloudFront/OriginRequestPolicy.d.ts.map +1 -0
  17. package/lib/AWS/CloudFront/OriginRequestPolicy.js +139 -0
  18. package/lib/AWS/CloudFront/OriginRequestPolicy.js.map +1 -0
  19. package/lib/AWS/CloudFront/PublicKey.d.ts +72 -0
  20. package/lib/AWS/CloudFront/PublicKey.d.ts.map +1 -0
  21. package/lib/AWS/CloudFront/PublicKey.js +137 -0
  22. package/lib/AWS/CloudFront/PublicKey.js.map +1 -0
  23. package/lib/AWS/CloudFront/ResponseHeadersPolicy.d.ts +114 -0
  24. package/lib/AWS/CloudFront/ResponseHeadersPolicy.d.ts.map +1 -0
  25. package/lib/AWS/CloudFront/ResponseHeadersPolicy.js +162 -0
  26. package/lib/AWS/CloudFront/ResponseHeadersPolicy.js.map +1 -0
  27. package/lib/AWS/CloudFront/index.d.ts +5 -0
  28. package/lib/AWS/CloudFront/index.d.ts.map +1 -1
  29. package/lib/AWS/CloudFront/index.js +5 -0
  30. package/lib/AWS/CloudFront/index.js.map +1 -1
  31. package/lib/AWS/ECS/CapacityProvider.d.ts +102 -0
  32. package/lib/AWS/ECS/CapacityProvider.d.ts.map +1 -0
  33. package/lib/AWS/ECS/CapacityProvider.js +217 -0
  34. package/lib/AWS/ECS/CapacityProvider.js.map +1 -0
  35. package/lib/AWS/ECS/index.d.ts +1 -0
  36. package/lib/AWS/ECS/index.d.ts.map +1 -1
  37. package/lib/AWS/ECS/index.js +1 -0
  38. package/lib/AWS/ECS/index.js.map +1 -1
  39. package/lib/AWS/Providers.d.ts.map +1 -1
  40. package/lib/AWS/Providers.js +7 -1
  41. package/lib/AWS/Providers.js.map +1 -1
  42. package/lib/Auth/Credentials.d.ts +6 -0
  43. package/lib/Auth/Credentials.d.ts.map +1 -1
  44. package/lib/Auth/Credentials.js +12 -1
  45. package/lib/Auth/Credentials.js.map +1 -1
  46. package/lib/Auth/Profile.d.ts +5 -0
  47. package/lib/Auth/Profile.d.ts.map +1 -1
  48. package/lib/Auth/Profile.js +11 -0
  49. package/lib/Auth/Profile.js.map +1 -1
  50. package/lib/Cloudflare/ApiToken/AccountApiToken.d.ts +2 -1
  51. package/lib/Cloudflare/ApiToken/AccountApiToken.d.ts.map +1 -1
  52. package/lib/Cloudflare/ApiToken/AccountApiToken.js +6 -5
  53. package/lib/Cloudflare/ApiToken/AccountApiToken.js.map +1 -1
  54. package/lib/Cloudflare/ApiToken/Common.d.ts +5 -11
  55. package/lib/Cloudflare/ApiToken/Common.d.ts.map +1 -1
  56. package/lib/Cloudflare/ApiToken/Common.js +4 -14
  57. package/lib/Cloudflare/ApiToken/Common.js.map +1 -1
  58. package/lib/Cloudflare/ApiToken/UserApiToken.js +4 -4
  59. package/lib/Cloudflare/ApiToken/UserApiToken.js.map +1 -1
  60. package/lib/GitHub/Comment.d.ts +2 -1
  61. package/lib/GitHub/Comment.d.ts.map +1 -1
  62. package/lib/GitHub/Comment.js +1 -0
  63. package/lib/GitHub/Comment.js.map +1 -1
  64. package/lib/GitHub/Providers.d.ts.map +1 -1
  65. package/lib/GitHub/Providers.js +2 -1
  66. package/lib/GitHub/Providers.js.map +1 -1
  67. package/lib/GitHub/Secret.d.ts +2 -2
  68. package/lib/GitHub/Secret.d.ts.map +1 -1
  69. package/lib/GitHub/Secrets.d.ts +45 -0
  70. package/lib/GitHub/Secrets.d.ts.map +1 -0
  71. package/lib/GitHub/Secrets.js +30 -0
  72. package/lib/GitHub/Secrets.js.map +1 -0
  73. package/lib/GitHub/Variable.d.ts +2 -2
  74. package/lib/GitHub/Variable.d.ts.map +1 -1
  75. package/lib/GitHub/index.d.ts +1 -0
  76. package/lib/GitHub/index.d.ts.map +1 -1
  77. package/lib/GitHub/index.js +1 -0
  78. package/lib/GitHub/index.js.map +1 -1
  79. package/package.json +1 -1
  80. package/src/AWS/CloudFront/CachePolicy.ts +271 -0
  81. package/src/AWS/CloudFront/KeyGroup.ts +233 -0
  82. package/src/AWS/CloudFront/OriginRequestPolicy.ts +256 -0
  83. package/src/AWS/CloudFront/PublicKey.ts +245 -0
  84. package/src/AWS/CloudFront/ResponseHeadersPolicy.ts +308 -0
  85. package/src/AWS/CloudFront/index.ts +11 -0
  86. package/src/AWS/ECS/CapacityProvider.ts +336 -0
  87. package/src/AWS/ECS/index.ts +4 -0
  88. package/src/AWS/Providers.ts +12 -0
  89. package/src/Auth/Credentials.ts +17 -1
  90. package/src/Auth/Profile.ts +15 -0
  91. package/src/Cloudflare/ApiToken/AccountApiToken.ts +6 -5
  92. package/src/Cloudflare/ApiToken/Common.ts +6 -18
  93. package/src/Cloudflare/ApiToken/UserApiToken.ts +4 -4
  94. package/src/GitHub/Comment.ts +4 -1
  95. package/src/GitHub/Providers.ts +8 -2
  96. package/src/GitHub/Secret.ts +2 -2
  97. package/src/GitHub/Secrets.ts +66 -0
  98. package/src/GitHub/Variable.ts +2 -2
  99. package/src/GitHub/index.ts +1 -0
package/bin/alchemy.js CHANGED
@@ -82,7 +82,7 @@ var __require = /* @__PURE__ */ createRequire(import.meta.url);
82
82
 
83
83
  //#endregion
84
84
  //#region package.json
85
- var version = "2.0.0-beta.16";
85
+ var version = "2.0.0-beta.18";
86
86
 
87
87
  //#endregion
88
88
  //#region src/AlchemyContext.ts
@@ -45197,6 +45197,15 @@ const writeConfig = (config) => FileSystem.FileSystem.asEffect().pipe(Effect.tap
45197
45197
  const getProfile = (name) => readConfig.pipe(Effect.map((config) => config.profiles[name]));
45198
45198
  const setProfile = (name, profile$1) => readConfig.pipe(Effect.tap((config) => Effect.sync(() => config.profiles[name] = profile$1)), Effect.flatMap(writeConfig));
45199
45199
  /**
45200
+ * Remove `name` and all its provider credentials from the on-disk config.
45201
+ * Returns `true` if the profile existed and was removed, `false` otherwise.
45202
+ */
45203
+ const deleteProfile = (name) => readConfig.pipe(Effect.flatMap((config) => {
45204
+ if (!(name in config.profiles)) return Effect.succeed(false);
45205
+ delete config.profiles[name];
45206
+ return writeConfig(config).pipe(Effect.as(true));
45207
+ }));
45208
+ /**
45200
45209
  * Returns a `ConfigProvider` that overrides `ALCHEMY_PROFILE` with the
45201
45210
  * given `profile` (when explicitly passed via the CLI `--profile` flag),
45202
45211
  * falling through to `base` for everything else.
@@ -45559,11 +45568,12 @@ const execStack = Effect.fn(function* ({ main: main$1, stage: stage$1, envFile:
45559
45568
  } : stack, { force: force$1 });
45560
45569
  if (dryRun$1) yield* cli$1.displayPlan(updatePlan);
45561
45570
  else {
45562
- if (!yes$1) {
45571
+ const hasChanges = Object.keys(updatePlan.deletions).length > 0 || Object.values(updatePlan.resources).some((node) => node.action !== "noop" || node.bindings.some((b) => b.action !== "noop"));
45572
+ if (!yes$1 && hasChanges) {
45563
45573
  if (!(yield* cli$1.approvePlan(updatePlan))) return;
45564
45574
  }
45565
45575
  const outputs = yield* apply(updatePlan);
45566
- yield* Console.log(outputs);
45576
+ if (outputs !== void 0) yield* Console.log(outputs);
45567
45577
  }
45568
45578
  }).pipe(Effect.provide(stack.services));
45569
45579
  }).pipe(Effect.provide(services$1));
@@ -45709,7 +45719,8 @@ const logsCommand = Command.make("logs", {
45709
45719
  //#endregion
45710
45720
  //#region src/Auth/Credentials.ts
45711
45721
  const credentialsDirPath = posix.join(rootDir, "credentials");
45712
- const credentialsFilePath = (profile$1, provider) => posix.join(credentialsDirPath, profile$1, `${provider}.json`);
45722
+ const profileCredentialsDirPath = (profile$1) => posix.join(credentialsDirPath, profile$1);
45723
+ const credentialsFilePath = (profile$1, provider) => posix.join(profileCredentialsDirPath(profile$1), `${provider}.json`);
45713
45724
  const readCredentials = Effect.fnUntraced(function* (profile$1, provider) {
45714
45725
  const data = yield* (yield* FileSystem.FileSystem).readFileString(credentialsFilePath(profile$1, provider)).pipe(Effect.catch(() => Effect.succeed(void 0)));
45715
45726
  if (data === void 0) return void 0;
@@ -45728,6 +45739,13 @@ const writeCredentials = Effect.fnUntraced(function* (profile$1, provider, crede
45728
45739
  const deleteCredentials = Effect.fnUntraced(function* (profile$1, provider) {
45729
45740
  yield* (yield* FileSystem.FileSystem).remove(credentialsFilePath(profile$1, provider)).pipe(Effect.catch(() => Effect.void));
45730
45741
  });
45742
+ /**
45743
+ * Recursively remove the `~/.alchemy/credentials/{profile}` directory
45744
+ * containing all per-provider secrets for `profile`. No-op if it doesn't exist.
45745
+ */
45746
+ const deleteProfileCredentials = Effect.fnUntraced(function* (profile$1) {
45747
+ yield* (yield* FileSystem.FileSystem).remove(profileCredentialsDirPath(profile$1), { recursive: true }).pipe(Effect.catch(() => Effect.void));
45748
+ });
45731
45749
  function displayRedacted(r, visibleChars = 4) {
45732
45750
  const raw = Redacted.value(r);
45733
45751
  if (raw.length <= visibleChars) return "****";
@@ -46512,7 +46530,13 @@ const showCommand = Command.make("show", {
46512
46530
  }
46513
46531
  }).pipe(Effect.provide(services$1));
46514
46532
  }));
46515
- const profileCommand = Command.make("profile", {}).pipe(Command.withSubcommands([showCommand]));
46533
+ const clearCommand$1 = Command.make("clear", { profile }, Effect.fnUntraced(function* ({ profile: profile$1 }) {
46534
+ const removed = yield* deleteProfile(profile$1);
46535
+ yield* deleteProfileCredentials(profile$1);
46536
+ if (removed) yield* Console.log(`Cleared profile '${profile$1}' and all its credentials.`);
46537
+ else yield* Console.log(`Profile '${profile$1}' not found in profiles.json; removed any stray credentials directory.`);
46538
+ }));
46539
+ const profileCommand = Command.make("profile", {}).pipe(Command.withSubcommands([showCommand, clearCommand$1]));
46516
46540
 
46517
46541
  //#endregion
46518
46542
  //#region bin/commands/state.ts
@@ -46655,12 +46679,61 @@ const treeCommand = Command.make("tree", {
46655
46679
  }
46656
46680
  }));
46657
46681
  }));
46682
+ const clearStackArg = Argument.string("stack").pipe(Argument.withDescription("Stack name to clear. Omit to clear ALL stacks in the store."), Argument.optional);
46683
+ const clearStageArg = Argument.string("stage").pipe(Argument.withDescription("Stage to clear within the stack. Omit to clear all stages in the stack."), Argument.optional);
46684
+ /**
46685
+ * Destructive: removes resource state from the store. The actual cloud
46686
+ * resources are NOT touched — this only affects what alchemy thinks
46687
+ * exists. Always confirms before deleting unless `--yes` is passed.
46688
+ */
46689
+ const clearCommand = Command.make("clear", {
46690
+ stack: clearStackArg,
46691
+ stageName: clearStageArg,
46692
+ main,
46693
+ envFile,
46694
+ stage,
46695
+ profile,
46696
+ local: localFlag,
46697
+ yes
46698
+ }, Effect.fnUntraced(function* ({ stack: stackOpt, stageName: stageOpt, yes: yesFlag,...rest }) {
46699
+ const stackName = Option.getOrUndefined(stackOpt);
46700
+ const stageName = Option.getOrUndefined(stageOpt);
46701
+ if (stageName !== void 0 && stackName === void 0) {
46702
+ yield* Console.log("Error: cannot specify <stage> without <stack>. Pass the stack name as the first argument.");
46703
+ return yield* Effect.fail(/* @__PURE__ */ new Error("missing stack"));
46704
+ }
46705
+ yield* withStateService(rest, (state) => Effect.gen(function* () {
46706
+ const targets = stackName === void 0 ? [...yield* state.listStacks()].sort().map((s) => ({ stack: s })) : stageName === void 0 ? [{ stack: stackName }] : [{
46707
+ stack: stackName,
46708
+ stage: stageName
46709
+ }];
46710
+ if (targets.length === 0) {
46711
+ yield* Console.log("(nothing to clear)");
46712
+ return;
46713
+ }
46714
+ const scope = stackName === void 0 ? `ALL stacks (${targets.length}): ${targets.map((t) => t.stack).join(", ")}` : stageName === void 0 ? `stack '${stackName}' (all stages)` : `stage '${stageName}' in stack '${stackName}'`;
46715
+ if (!yesFlag) {
46716
+ if (!(yield* confirm({
46717
+ message: `About to delete ${scope} from the state store. This cannot be undone. Continue?`,
46718
+ initialValue: false
46719
+ }))) {
46720
+ yield* Console.log("Cancelled.");
46721
+ return;
46722
+ }
46723
+ }
46724
+ for (const target of targets) {
46725
+ yield* state.deleteStack(target);
46726
+ yield* Console.log(`cleared ${target.stack}${target.stage ? `/${target.stage}` : ""}`);
46727
+ }
46728
+ }));
46729
+ }));
46658
46730
  const stateCommand = Command.make("state", {}).pipe(Command.withSubcommands([
46659
46731
  stacksCommand,
46660
46732
  stagesCommand,
46661
46733
  resourcesCommand,
46662
46734
  getCommand,
46663
- treeCommand
46735
+ treeCommand,
46736
+ clearCommand
46664
46737
  ]));
46665
46738
 
46666
46739
  //#endregion