@quadnix/octo-build 0.0.17 → 0.2.0

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 (195) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +117 -8
  3. package/dist/commands/apply/apply.command.d.ts +25 -0
  4. package/dist/commands/apply/apply.command.js +130 -0
  5. package/dist/commands/apply/apply.command.js.map +1 -0
  6. package/dist/commands/apply/index.d.ts +1 -0
  7. package/dist/commands/apply/index.js +2 -0
  8. package/dist/commands/apply/index.js.map +1 -0
  9. package/dist/commands/build/build.command.d.ts +1 -1
  10. package/dist/commands/build/build.command.js +4 -4
  11. package/dist/commands/build/build.command.js.map +1 -1
  12. package/dist/commands/build/main.d.ts +22 -0
  13. package/dist/commands/build/main.js +22 -0
  14. package/dist/commands/build/main.js.map +1 -1
  15. package/dist/commands/build/parsers/build-file.parser.d.ts +6 -0
  16. package/dist/commands/build/parsers/build-file.parser.js +6 -0
  17. package/dist/commands/build/parsers/build-file.parser.js.map +1 -1
  18. package/dist/commands/build/streams/stream-manager.d.ts +6 -0
  19. package/dist/commands/build/streams/stream-manager.js +7 -1
  20. package/dist/commands/build/streams/stream-manager.js.map +1 -1
  21. package/dist/commands/commit/commit.command.d.ts +23 -0
  22. package/dist/commands/commit/commit.command.js +81 -0
  23. package/dist/commands/commit/commit.command.js.map +1 -0
  24. package/dist/commands/commit/index.d.ts +1 -0
  25. package/dist/commands/commit/index.js +2 -0
  26. package/dist/commands/commit/index.js.map +1 -0
  27. package/dist/commands/create-anchor/create-anchor.command.js +1 -1
  28. package/dist/commands/create-anchor/create-anchor.command.js.map +1 -1
  29. package/dist/commands/create-anchor/generator-octo-anchor-template/generators/app/index.d.ts +18 -3
  30. package/dist/commands/create-anchor/generator-octo-anchor-template/generators/app/index.js +29 -11
  31. package/dist/commands/create-anchor/generator-octo-anchor-template/generators/app/index.js.map +1 -1
  32. package/dist/commands/create-anchor/generator-octo-anchor-template/generators/app/templates/anchors/anchor/anchor.schema.ts.ejs +9 -1
  33. package/dist/commands/create-app/create-app.command.d.ts +1 -1
  34. package/dist/commands/create-app/create-app.command.js +7 -3
  35. package/dist/commands/create-app/create-app.command.js.map +1 -1
  36. package/dist/commands/create-app/generator-octo-app-template/generators/app/index.d.ts +17 -1
  37. package/dist/commands/create-app/generator-octo-app-template/generators/app/index.js +72 -16
  38. package/dist/commands/create-app/generator-octo-app-template/generators/app/index.js.map +1 -1
  39. package/dist/commands/create-app/generator-octo-app-template/generators/app/templates/README.md.ejs +73 -14
  40. package/dist/commands/create-app/generator-octo-app-template/generators/app/templates/gitignore.ejs +14 -0
  41. package/dist/commands/create-app/generator-octo-app-template/generators/app/templates/index.ts.ejs +19 -0
  42. package/dist/commands/create-app/generator-octo-app-template/generators/app/templates/package.json.ejs +9 -1
  43. package/dist/commands/create-app/generator-octo-app-template/generators/app/templates/src/aws-dynamodb-service/octo.yaml.ejs +111 -0
  44. package/dist/commands/create-app/generator-octo-app-template/generators/app/templates/src/aws-ecs-server/octo.yaml.ejs +28 -16
  45. package/dist/commands/create-app/generator-octo-app-template/generators/app/templates/src/aws-s3-website/octo.yaml.ejs +25 -3
  46. package/dist/commands/create-app/generator-octo-app-template/generators/app/templates/tsconfig.json.ejs +0 -3
  47. package/dist/commands/{create-resource/create-resource.command.d.ts → create-external-resource/create-external-resource.command.d.ts} +1 -1
  48. package/dist/commands/create-external-resource/create-external-resource.command.js +64 -0
  49. package/dist/commands/create-external-resource/create-external-resource.command.js.map +1 -0
  50. package/dist/commands/{create-resource/generator-octo-resource-template → create-external-resource/generator-octo-external-resource-template}/generators/app/index.d.ts +17 -2
  51. package/dist/commands/{create-resource/generator-octo-resource-template → create-external-resource/generator-octo-external-resource-template}/generators/app/index.js +36 -35
  52. package/dist/commands/create-external-resource/generator-octo-external-resource-template/generators/app/index.js.map +1 -0
  53. package/dist/commands/{create-resource/generator-octo-resource-template → create-external-resource/generator-octo-external-resource-template}/generators/app/templates/resources/resource/actions/add.resource.action.ts.ejs +7 -16
  54. package/dist/commands/{create-resource/generator-octo-resource-template → create-external-resource/generator-octo-external-resource-template}/generators/app/templates/resources/resource/actions/delete.resource.action.ts.ejs +21 -3
  55. package/dist/commands/create-external-resource/generator-octo-external-resource-template/generators/app/templates/resources/resource/actions/update.resource.action.ts.ejs +63 -0
  56. package/dist/commands/{create-resource/generator-octo-resource-template → create-external-resource/generator-octo-external-resource-template}/generators/app/templates/resources/resource/index.ts.ejs +1 -2
  57. package/dist/commands/create-external-resource/generator-octo-external-resource-template/generators/app/templates/resources/resource/resource.ts.ejs +28 -0
  58. package/dist/commands/create-external-resource/index.d.ts +1 -0
  59. package/dist/commands/create-external-resource/index.js +2 -0
  60. package/dist/commands/create-external-resource/index.js.map +1 -0
  61. package/dist/commands/create-model/create-model.command.js +1 -1
  62. package/dist/commands/create-model/create-model.command.js.map +1 -1
  63. package/dist/commands/create-model/generator-octo-model-template/generators/app/index.d.ts +17 -2
  64. package/dist/commands/create-model/generator-octo-model-template/generators/app/index.js +26 -9
  65. package/dist/commands/create-model/generator-octo-model-template/generators/app/index.js.map +1 -1
  66. package/dist/commands/create-model/generator-octo-model-template/generators/app/templates/models/model/model.ts.ejs +41 -1
  67. package/dist/commands/create-model/generator-octo-model-template/generators/app/templates/models/model/schema.ts.ejs +6 -1
  68. package/dist/commands/create-module/create-module.command.js +1 -1
  69. package/dist/commands/create-module/create-module.command.js.map +1 -1
  70. package/dist/commands/create-module/generator-octo-module-template/generators/app/index.d.ts +17 -2
  71. package/dist/commands/create-module/generator-octo-module-template/generators/app/index.js +27 -10
  72. package/dist/commands/create-module/generator-octo-module-template/generators/app/index.js.map +1 -1
  73. package/dist/commands/create-overlay/create-overlay.command.js +4 -3
  74. package/dist/commands/create-overlay/create-overlay.command.js.map +1 -1
  75. package/dist/commands/create-overlay/generator-octo-overlay-template/generators/app/index.d.ts +17 -2
  76. package/dist/commands/create-overlay/generator-octo-overlay-template/generators/app/index.js +26 -9
  77. package/dist/commands/create-overlay/generator-octo-overlay-template/generators/app/index.js.map +1 -1
  78. package/dist/commands/{create-cdk/create-cdk.command.d.ts → create-terraform-resource/create-terraform-resource.command.d.ts} +3 -3
  79. package/dist/commands/{create-resource/create-resource.command.js → create-terraform-resource/create-terraform-resource.command.js} +17 -11
  80. package/dist/commands/create-terraform-resource/create-terraform-resource.command.js.map +1 -0
  81. package/dist/commands/create-terraform-resource/generator-octo-terraform-resource-template/generators/app/index.d.ts +25 -0
  82. package/dist/commands/create-terraform-resource/generator-octo-terraform-resource-template/generators/app/index.js +71 -0
  83. package/dist/commands/create-terraform-resource/generator-octo-terraform-resource-template/generators/app/index.js.map +1 -0
  84. package/dist/commands/create-terraform-resource/generator-octo-terraform-resource-template/generators/app/templates/resources/resource/index.schema.ts.ejs +43 -0
  85. package/dist/commands/create-terraform-resource/generator-octo-terraform-resource-template/generators/app/templates/resources/resource/index.ts.ejs +1 -0
  86. package/dist/commands/create-terraform-resource/generator-octo-terraform-resource-template/generators/app/templates/resources/resource/resource.ts.ejs +83 -0
  87. package/dist/commands/create-terraform-resource/index.d.ts +1 -0
  88. package/dist/commands/create-terraform-resource/index.js +2 -0
  89. package/dist/commands/create-terraform-resource/index.js.map +1 -0
  90. package/dist/commands/generate/generate.command.d.ts +16 -0
  91. package/dist/commands/generate/generate.command.js +35 -0
  92. package/dist/commands/generate/generate.command.js.map +1 -0
  93. package/dist/commands/generate/index.d.ts +1 -0
  94. package/dist/commands/generate/index.js +2 -0
  95. package/dist/commands/generate/index.js.map +1 -0
  96. package/dist/commands/get-response/get-response.command.d.ts +18 -0
  97. package/dist/commands/get-response/get-response.command.js +39 -0
  98. package/dist/commands/get-response/get-response.command.js.map +1 -0
  99. package/dist/commands/get-response/index.d.ts +1 -0
  100. package/dist/commands/get-response/index.js +2 -0
  101. package/dist/commands/get-response/index.js.map +1 -0
  102. package/dist/commands/lock/index.d.ts +1 -0
  103. package/dist/commands/lock/index.js +2 -0
  104. package/dist/commands/lock/index.js.map +1 -0
  105. package/dist/commands/lock/lock.command.d.ts +18 -0
  106. package/dist/commands/lock/lock.command.js +31 -0
  107. package/dist/commands/lock/lock.command.js.map +1 -0
  108. package/dist/commands/run-action/index.d.ts +1 -0
  109. package/dist/commands/run-action/index.js +2 -0
  110. package/dist/commands/run-action/index.js.map +1 -0
  111. package/dist/commands/run-action/run-action.command.d.ts +12 -0
  112. package/dist/commands/run-action/run-action.command.js +40 -0
  113. package/dist/commands/run-action/run-action.command.js.map +1 -0
  114. package/dist/commands/unlock/index.d.ts +1 -0
  115. package/dist/commands/unlock/index.js +2 -0
  116. package/dist/commands/unlock/index.js.map +1 -0
  117. package/dist/commands/unlock/unlock.command.d.ts +18 -0
  118. package/dist/commands/unlock/unlock.command.js +35 -0
  119. package/dist/commands/unlock/unlock.command.js.map +1 -0
  120. package/dist/commands/validate/index.d.ts +1 -0
  121. package/dist/commands/validate/index.js +2 -0
  122. package/dist/commands/validate/index.js.map +1 -0
  123. package/dist/commands/validate/validate.command.d.ts +17 -0
  124. package/dist/commands/validate/validate.command.js +62 -0
  125. package/dist/commands/validate/validate.command.js.map +1 -0
  126. package/dist/index.js +20 -8
  127. package/dist/index.js.map +1 -1
  128. package/dist/resources/octo-v1.schema.json +108 -27
  129. package/dist/utilities/definition/yaml/yaml-definition.utility.d.ts +103 -13
  130. package/dist/utilities/definition/yaml/yaml-definition.utility.js +215 -68
  131. package/dist/utilities/definition/yaml/yaml-definition.utility.js.map +1 -1
  132. package/dist/utilities/octo/octo.utility.d.ts +65 -0
  133. package/dist/utilities/octo/octo.utility.js +178 -0
  134. package/dist/utilities/octo/octo.utility.js.map +1 -0
  135. package/dist/utilities/process/process.utility.d.ts +8 -0
  136. package/dist/utilities/process/process.utility.js +8 -0
  137. package/dist/utilities/process/process.utility.js.map +1 -1
  138. package/dist/utilities/project-index/project-index.utility.d.ts +27 -0
  139. package/dist/utilities/project-index/project-index.utility.js +71 -0
  140. package/dist/utilities/project-index/project-index.utility.js.map +1 -0
  141. package/dist/utilities/string/string.utility.d.ts +22 -0
  142. package/dist/utilities/string/string.utility.js +27 -0
  143. package/dist/utilities/string/string.utility.js.map +1 -1
  144. package/package.json +11 -8
  145. package/dist/commands/create-cdk/create-cdk.command.js +0 -70
  146. package/dist/commands/create-cdk/create-cdk.command.js.map +0 -1
  147. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/index.d.ts +0 -10
  148. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/index.js +0 -107
  149. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/index.js.map +0 -1
  150. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/README.md.ejs +0 -23
  151. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/eslint.config.js.ejs +0 -337
  152. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/gitignore.ejs +0 -82
  153. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/gitkeep.ejs +0 -0
  154. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/package.json.ejs +0 -57
  155. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/prettierrc.ejs +0 -5
  156. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/anchors/app/app.anchor.schema.ts.ejs +0 -19
  157. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/anchors/app/app.anchor.ts.ejs +0 -17
  158. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/factories/dummy-credentials.factory.ts.ejs +0 -28
  159. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/modules/app/dummy-app/dummy-app.module.spec.ts.ejs +0 -90
  160. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/modules/app/dummy-app/dummy-app.module.ts.ejs +0 -16
  161. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/modules/app/dummy-app/index.schema.ts.ejs +0 -10
  162. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/modules/app/dummy-app/index.ts.ejs +0 -3
  163. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/modules/app/dummy-app/models/app/actions/add-dummy-app.model.action.ts.ejs +0 -59
  164. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/modules/app/dummy-app/models/app/index.ts.ejs +0 -1
  165. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/resources/http-fetch/actions/add-http-fetch.resource.action.ts.ejs +0 -55
  166. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/resources/http-fetch/http-fetch.resource.ts.ejs +0 -12
  167. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/resources/http-fetch/index.schema.ts.ejs +0 -35
  168. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/resources/http-fetch/index.ts.ejs +0 -3
  169. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/src/utilities/dummy/dummy.utility.ts.ejs +0 -11
  170. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/tsconfig.build.json.ejs +0 -11
  171. package/dist/commands/create-cdk/generator-octo-cdk-template/generators/app/templates/tsconfig.json.ejs +0 -39
  172. package/dist/commands/create-cdk/index.d.ts +0 -1
  173. package/dist/commands/create-cdk/index.js +0 -2
  174. package/dist/commands/create-cdk/index.js.map +0 -1
  175. package/dist/commands/create-resource/create-resource.command.js.map +0 -1
  176. package/dist/commands/create-resource/generator-octo-resource-template/generators/app/index.js.map +0 -1
  177. package/dist/commands/create-resource/generator-octo-resource-template/generators/app/templates/resources/resource/actions/update-tags.resource.action.ts.ejs +0 -86
  178. package/dist/commands/create-resource/generator-octo-resource-template/generators/app/templates/resources/resource/actions/validate.resource.action.ts.ejs +0 -40
  179. package/dist/commands/create-resource/generator-octo-resource-template/generators/app/templates/resources/resource/resource.ts.ejs +0 -12
  180. package/dist/commands/create-resource/index.d.ts +0 -1
  181. package/dist/commands/create-resource/index.js +0 -2
  182. package/dist/commands/create-resource/index.js.map +0 -1
  183. package/dist/commands/run/index.d.ts +0 -1
  184. package/dist/commands/run/index.js +0 -2
  185. package/dist/commands/run/index.js.map +0 -1
  186. package/dist/commands/run/run.command.d.ts +0 -11
  187. package/dist/commands/run/run.command.js +0 -96
  188. package/dist/commands/run/run.command.js.map +0 -1
  189. package/dist/commands/state/index.d.ts +0 -1
  190. package/dist/commands/state/index.js +0 -2
  191. package/dist/commands/state/index.js.map +0 -1
  192. package/dist/commands/state/state.command.d.ts +0 -14
  193. package/dist/commands/state/state.command.js +0 -79
  194. package/dist/commands/state/state.command.js.map +0 -1
  195. /package/dist/commands/{create-resource/generator-octo-resource-template → create-external-resource/generator-octo-external-resource-template}/generators/app/templates/resources/resource/index.schema.ts.ejs +0 -0
@@ -0,0 +1,62 @@
1
+ import { resolve } from 'path';
2
+ import { Container, TerraformUtility } from '@quadnix/octo';
3
+ import { OctoUtility } from '../../utilities/octo/octo.utility.js';
4
+ /**
5
+ * Step 2 of the octo lifecycle. See `Octo.validate()`.
6
+ */
7
+ export const validateCommand = {
8
+ builder: (yargs) => {
9
+ return yargs
10
+ .option('terragruntDir', {
11
+ demandOption: true,
12
+ description: 'The generated Terragrunt directory to plan and validate.',
13
+ type: 'string',
14
+ })
15
+ .option('terraformBinary', {
16
+ demandOption: false,
17
+ description: 'Override the terraform/tofu binary terragrunt should invoke (sets TG_TF_PATH).',
18
+ type: 'string',
19
+ })
20
+ .option('terragruntBinary', {
21
+ demandOption: false,
22
+ description: 'Override the terragrunt binary/path to invoke.',
23
+ type: 'string',
24
+ })
25
+ .option('timeoutInMs', {
26
+ demandOption: false,
27
+ description: 'Override the per-command timeout, in milliseconds.',
28
+ type: 'number',
29
+ });
30
+ },
31
+ command: 'validate',
32
+ describe: "Step 2: validate the generated Terraform plans against Octo's resource diff.",
33
+ handler: async (argv) => {
34
+ const { terraformBinary, terragruntBinary, terragruntDir, timeoutInMs } = argv;
35
+ const resolvedDir = resolve(process.cwd(), terragruntDir);
36
+ await OctoUtility.runCommand('validate', async () => {
37
+ // A plan reads every `data "external"`, and each one shells back out to `octo get-response`.
38
+ OctoUtility.prepareCallbackEnvironment();
39
+ const { app, octo } = await OctoUtility.bootOcto();
40
+ const terraformUtility = await Container.getInstance().get(TerraformUtility, {
41
+ args: [{ terraformBinary, terragruntBinary, timeoutInMs }, true],
42
+ });
43
+ // A folder whose plan cannot be read is carried as an error rather than aborting the run. Octo
44
+ // reports the failure for a folder holding a module it tracks, and ignores one it does not know.
45
+ const planResult = await terraformUtility.plan(resolvedDir, { json: true });
46
+ // The report itself is rendered by whichever listeners the definition registers — none of
47
+ // them, and this command prints only its verdict. What survives here is the exit code, which
48
+ // is the CLI's own job and not a listener's.
49
+ const report = await octo.validate(app, planResult);
50
+ // Only being unable to read a folder is unsuccessful. Drift and unexplained changes are
51
+ // findings to act on, not exit codes.
52
+ //
53
+ // The verdict itself is not printed here - the listeners render the report, drift included,
54
+ // on stderr. What is left is the exit code, which is the CLI's own job, and the failure line on
55
+ // stderr.
56
+ if (report.failures.length > 0) {
57
+ throw new Error('Validation could not complete!');
58
+ }
59
+ });
60
+ },
61
+ };
62
+ //# sourceMappingURL=validate.command.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validate.command.js","sourceRoot":"","sources":["../../../src/commands/validate/validate.command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAE5D,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AASnE;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,CAAC,KAAW,EAAQ,EAAE;QAC7B,OAAO,KAAK;aACT,MAAM,CAAC,eAAe,EAAE;YACvB,YAAY,EAAE,IAAI;YAClB,WAAW,EAAE,0DAA0D;YACvE,IAAI,EAAE,QAAQ;S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AC7F,6CAA6C;YAC7C,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;YAEpD,wFAAwF;YACxF,sCAAsC;YACtC,EAAE;YACF,4FAA4F;YAC5F,gGAAgG;YAChG,UAAU;YACV,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC/B,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;YACpD,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;CACF,CAAC"}
package/dist/index.js CHANGED
@@ -2,16 +2,22 @@
2
2
  import * as process from 'process';
3
3
  import chalk from 'chalk';
4
4
  import yargs from 'yargs/yargs';
5
+ import { applyCommand } from './commands/apply/index.js';
5
6
  import { buildCommand } from './commands/build/index.js';
7
+ import { commitCommand } from './commands/commit/index.js';
6
8
  import { createAnchorCommand } from './commands/create-anchor/index.js';
7
9
  import { createAppCommand } from './commands/create-app/index.js';
8
- import { createCdkCommand } from './commands/create-cdk/index.js';
10
+ import { createExternalResourceCommand } from './commands/create-external-resource/index.js';
9
11
  import { createModelCommand } from './commands/create-model/index.js';
10
12
  import { createModuleCommand } from './commands/create-module/index.js';
11
13
  import { createOverlayCommand } from './commands/create-overlay/index.js';
12
- import { createResourceCommand } from './commands/create-resource/index.js';
13
- import { runCommand } from './commands/run/index.js';
14
- import { stateCommand } from './commands/state/index.js';
14
+ import { createTerraformResourceCommand } from './commands/create-terraform-resource/index.js';
15
+ import { generateCommand } from './commands/generate/index.js';
16
+ import { getResponseCommand } from './commands/get-response/index.js';
17
+ import { lockCommand } from './commands/lock/index.js';
18
+ import { runActionCommand } from './commands/run-action/index.js';
19
+ import { unlockCommand } from './commands/unlock/index.js';
20
+ import { validateCommand } from './commands/validate/index.js';
15
21
  const PROGRAM_NAME = 'octo';
16
22
  const parser = yargs(process.argv.slice(2))
17
23
  .scriptName(PROGRAM_NAME)
@@ -23,13 +29,19 @@ const parser = yargs(process.argv.slice(2))
23
29
  .alias('v', 'version');
24
30
  parser.command(createAnchorCommand);
25
31
  parser.command(createAppCommand);
26
- parser.command(createCdkCommand);
32
+ parser.command(createExternalResourceCommand);
27
33
  parser.command(createModelCommand);
28
34
  parser.command(createModuleCommand);
29
35
  parser.command(createOverlayCommand);
30
- parser.command(createResourceCommand);
36
+ parser.command(createTerraformResourceCommand);
37
+ parser.command(applyCommand);
31
38
  parser.command(buildCommand);
32
- parser.command(runCommand);
33
- parser.command(stateCommand);
39
+ parser.command(commitCommand);
40
+ parser.command(generateCommand);
41
+ parser.command(getResponseCommand);
42
+ parser.command(lockCommand);
43
+ parser.command(runActionCommand);
44
+ parser.command(unlockCommand);
45
+ parser.command(validateCommand);
34
46
  await parser.argv;
35
47
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,KAAK,MAAM,aAAa,CAAC;AAChC,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAClE,OAAO,EAAE,kBAAkB,EAAE,MAAM,kCAAkC,CAAC;AACtE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B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,OAAO,CAAC,6BAA6B,CAAC,CAAC;AAC9C,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;AACnC,MAAM,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;AACpC,MAAM,CAAC,OAAO,CAAC,oBAAoB,CAAC,CAAC;AACrC,MAAM,CAAC,OAAO,CAAC,8BAA8B,CAAC,CAAC;AAC/C,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AAC7B,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;AAC7B,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AAC9B,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;AAChC,MAAM,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;AACnC,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;AAC5B,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC,CAAC;AACjC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;AAC9B,MAAM,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;AAEhC,MAAM,MAAM,CAAC,IAAI,CAAC"}
@@ -82,7 +82,7 @@
82
82
  "additionalProperties": false,
83
83
  "properties": {
84
84
  "type": {
85
- "const": "HtmlReportEventListener",
85
+ "const": "JournalEventListener",
86
86
  "type": "string"
87
87
  }
88
88
  },
@@ -92,6 +92,13 @@
92
92
  {
93
93
  "additionalProperties": false,
94
94
  "properties": {
95
+ "colorize": {
96
+ "type": "boolean"
97
+ },
98
+ "level": {
99
+ "enum": ["debug", "error", "fatal", "info", "silent", "trace", "warn"],
100
+ "type": "string"
101
+ },
95
102
  "type": {
96
103
  "const": "LoggingEventListener",
97
104
  "type": "string"
@@ -109,32 +116,49 @@
109
116
  {
110
117
  "additionalProperties": false,
111
118
  "properties": {
112
- "encryptionKey": {
113
- "type": "string"
114
- },
115
119
  "statePath": {
116
120
  "type": "string"
117
121
  },
118
122
  "type": {
119
- "const": "LocalEncryptionStateProvider",
123
+ "const": "LocalStateProvider",
120
124
  "type": "string"
121
125
  }
122
126
  },
123
- "required": ["encryptionKey", "type", "statePath"],
127
+ "required": ["type", "statePath"],
124
128
  "type": "object"
125
129
  },
126
130
  {
127
131
  "additionalProperties": false,
128
132
  "properties": {
133
+ "appId": {
134
+ "type": "string"
135
+ },
136
+ "checkInIntervalInSeconds": {
137
+ "maximum": 60,
138
+ "minimum": 5,
139
+ "type": "integer"
140
+ },
141
+ "lockContext": {
142
+ "type": "string"
143
+ },
144
+ "organizationId": {
145
+ "type": "string"
146
+ },
147
+ "sessionId": {
148
+ "type": "string"
149
+ },
150
+ "stateManagementServiceUrl": {
151
+ "type": "string"
152
+ },
129
153
  "statePath": {
130
154
  "type": "string"
131
155
  },
132
156
  "type": {
133
- "const": "LocalStateProvider",
157
+ "const": "RemoteStateProvider",
134
158
  "type": "string"
135
159
  }
136
160
  },
137
- "required": ["type", "statePath"],
161
+ "required": ["appId", "organizationId", "sessionId", "stateManagementServiceUrl", "statePath", "type"],
138
162
  "type": "object"
139
163
  },
140
164
  {
@@ -149,31 +173,88 @@
149
173
  "type": "object"
150
174
  }
151
175
  ]
152
- },
153
- "transactionOptions": {
154
- "additionalProperties": false,
155
- "properties": {
156
- "yieldModelDiffs": {
157
- "default": false,
158
- "type": "boolean"
176
+ }
177
+ },
178
+ "required": ["stateProvider"],
179
+ "type": "object"
180
+ },
181
+ "tags": {
182
+ "items": {
183
+ "additionalProperties": false,
184
+ "properties": {
185
+ "scope": {
186
+ "additionalProperties": false,
187
+ "properties": {
188
+ "moduleId": {
189
+ "type": "string"
190
+ }
191
+ },
192
+ "type": "object"
193
+ },
194
+ "tags": {
195
+ "additionalProperties": {
196
+ "type": "string"
159
197
  },
160
- "yieldModelTransaction": {
161
- "default": false,
162
- "type": "boolean"
198
+ "type": "object"
199
+ }
200
+ },
201
+ "required": ["tags"],
202
+ "type": "object"
203
+ },
204
+ "type": "array"
205
+ },
206
+ "terraform": {
207
+ "additionalProperties": false,
208
+ "properties": {
209
+ "providers": {
210
+ "items": {
211
+ "additionalProperties": false,
212
+ "properties": {
213
+ "accountId": {
214
+ "type": "string"
215
+ },
216
+ "accountName": {
217
+ "type": "string"
218
+ },
219
+ "providerType": {
220
+ "type": "string"
221
+ },
222
+ "regionId": {
223
+ "type": "string"
224
+ },
225
+ "setRegionAttribute": {
226
+ "type": "boolean"
227
+ },
228
+ "spec": {
229
+ "type": "object"
230
+ }
163
231
  },
164
- "yieldResourceDiffs": {
165
- "default": false,
166
- "type": "boolean"
232
+ "required": ["accountId", "providerType", "regionId"],
233
+ "type": "object"
234
+ },
235
+ "type": "array"
236
+ },
237
+ "requiredProviders": {
238
+ "additionalProperties": {
239
+ "additionalProperties": false,
240
+ "properties": {
241
+ "minVersion": {
242
+ "type": "string"
243
+ },
244
+ "source": {
245
+ "type": "string"
246
+ }
167
247
  },
168
- "yieldResourceTransaction": {
169
- "default": false,
170
- "type": "boolean"
171
- }
248
+ "required": ["source"],
249
+ "type": "object"
172
250
  },
173
251
  "type": "object"
252
+ },
253
+ "requiredVersion": {
254
+ "type": "string"
174
255
  }
175
256
  },
176
- "required": ["stateProvider"],
257
+ "required": ["providers", "requiredProviders", "requiredVersion"],
177
258
  "type": "object"
178
259
  },
179
260
  "version": {
@@ -181,7 +262,7 @@
181
262
  "type": "number"
182
263
  }
183
264
  },
184
- "required": ["imports", "modules", "settings", "version"],
265
+ "required": ["imports", "modules", "settings", "terraform", "version"],
185
266
  "title": "Octo V1 Definition Schema",
186
267
  "type": "object"
187
268
  }
@@ -1,10 +1,34 @@
1
- import { type Constructable, LocalEncryptionStateProvider, LocalStateProvider, TestStateProvider } from '@quadnix/octo';
2
- import type { HtmlReportEventListener } from '@quadnix/octo-event-listeners/html-report';
1
+ import { type Constructable, LocalStateProvider, type Octo, RemoteStateProvider, TestStateProvider } from '@quadnix/octo';
2
+ import type { JournalEventListener } from '@quadnix/octo-event-listeners/journal';
3
3
  import type { LoggingEventListener } from '@quadnix/octo-event-listeners/logging';
4
+ /**
5
+ * Reads `octo.yml` and turns each section into the values {@link Octo} is booted with.
6
+ */
4
7
  export declare class YamlDefinitionUtility {
5
8
  private readonly definition;
9
+ /**
10
+ * The directory holding the definition file. Everything the definition names by relative path is
11
+ * resolved against this, not against `process.cwd()`: `octo run-action` is invoked by terraform
12
+ * from inside a terragrunt cache directory, so the cwd there is neither the project nor stable.
13
+ */
14
+ private readonly definitionDir;
15
+ /**
16
+ * @param definitionFilePath Path to the definition file.
17
+ * @throws If the file is unreadable, or fails schema validation.
18
+ */
6
19
  constructor(definitionFilePath: string);
20
+ /**
21
+ * Substitutes `${env.KEY}` references in a value with what the definition's `env` block declares.
22
+ *
23
+ * Arrays and objects are walked, because a module input is as nested as its schema: a reference
24
+ * can sit inside a list of images, or a key of an object, as readily as at the top level.
25
+ *
26
+ * @throws If a value holds one of its own ancestors, which no substitution over it terminates on.
27
+ */
7
28
  resolveEnvironmentValue<T>(value: unknown): T;
29
+ /**
30
+ * Imports the hook callbacks the definition names, in the shape {@link Octo.registerHooks} takes.
31
+ */
8
32
  resolveHooks(): Promise<{
9
33
  postCommitHooks?: {
10
34
  handle: any;
@@ -29,34 +53,100 @@ export declare class YamlDefinitionUtility {
29
53
  handle: any;
30
54
  }[];
31
55
  }>;
56
+ /**
57
+ * Imports every module class the definition's `imports` block names.
58
+ */
32
59
  resolveImports(): Promise<{
33
60
  className: Constructable<any>;
34
61
  }[]>;
62
+ /**
63
+ * The listeners the definition lists. The logging listener writes to stderr, so stdout carries only
64
+ * a command's own output.
65
+ */
35
66
  resolveListeners(): Promise<{
36
67
  args?: unknown[];
37
68
  metadata?: Record<string, string>;
38
- type: Constructable<HtmlReportEventListener | LoggingEventListener>;
69
+ type: Constructable<JournalEventListener | LoggingEventListener>;
39
70
  }[]>;
71
+ /**
72
+ * Pairs each `modules` entry with its imported class, and resolves its inputs.
73
+ */
40
74
  resolveModules(imports: Awaited<ReturnType<YamlDefinitionUtility['resolveImports']>>): {
41
75
  moduleClass: Constructable<any>;
42
76
  moduleId: string;
43
77
  moduleInputs: Record<string, unknown>;
44
78
  }[];
79
+ /**
80
+ * How often terraform state is checked into the state provider while a terraform command runs, or
81
+ * `undefined` for the default. Only `RemoteStateProvider` sets it.
82
+ */
83
+ resolveStateCheckInIntervalInMs(): number | undefined;
84
+ /**
85
+ * Builds the `IStateProvider` the definition asks for.
86
+ */
45
87
  resolveStateProvider(): {
46
- type: LocalEncryptionStateProvider;
47
- } | {
48
88
  type: LocalStateProvider;
89
+ } | {
90
+ type: RemoteStateProvider;
49
91
  } | {
50
92
  type: TestStateProvider;
51
93
  };
52
- resolveTransactionOptions(): {
53
- appLockId: string | undefined;
54
- enableResourceCapture: boolean;
55
- enableResourceValidation: boolean;
56
- yieldModelDiffs: boolean;
57
- yieldModelTransaction: boolean;
58
- yieldResourceDiffs: boolean;
59
- yieldResourceTransaction: boolean;
94
+ /**
95
+ * The tag registrations the definition declares, in the shape `Octo.registerTags()` takes.
96
+ *
97
+ * A `scope` naming a `moduleId` reaches that module's resources; an absent or empty one reaches
98
+ * every resource of the run.
99
+ */
100
+ resolveTags(): Parameters<Octo['registerTags']>[0];
101
+ /**
102
+ * The terraform version, required providers, and provider blocks the definition declares.
103
+ */
104
+ resolveTerraformOptions(): {
105
+ providers: {
106
+ accountId: string;
107
+ accountName: string | undefined;
108
+ providerType: string;
109
+ regionId: string;
110
+ setRegionAttribute: boolean | undefined;
111
+ spec: Record<string, unknown>;
112
+ }[];
113
+ requiredProviders: Record<string, {
114
+ minVersion?: string;
115
+ source: string;
116
+ }>;
117
+ requiredVersion: string;
60
118
  };
119
+ /**
120
+ * Substitutes one `${env.KEY}` reference with what the definition's `env` block declares for that
121
+ * key, read in the kind the block gives it. Anything holding no reference is returned as it came.
122
+ */
123
+ private resolveEnvironmentReference;
124
+ /**
125
+ * Resolves a definition-file import specifier to something `import()` can load.
126
+ *
127
+ * A relative path resolves against the **definition file's own directory**. It cannot resolve
128
+ * against the current working directory: terraform invokes `octo run-action` from inside a
129
+ * terragrunt cache directory, so a definition saying `./dist/index.js` - which is what every
130
+ * generated app says - would be looked for under the cache and never found.
131
+ *
132
+ * A bare specifier resolves against the **user's project root**, not octo-build's own install
133
+ * directory - node would otherwise resolve it from wherever octo-build happens to live. A flat
134
+ * `node_modules` hides that; a linked store does not, and there the user's own dependencies are
135
+ * invisible.
136
+ */
137
+ private resolveImportPath;
138
+ /**
139
+ * Walks a value, substituting every `${env.KEY}` reference it holds at any depth.
140
+ *
141
+ * `ancestors` is the chain currently being walked rather than everything already seen. A YAML
142
+ * anchor used in two places points one node at two parents, which resolves twice and is no cycle;
143
+ * a node reappearing beneath itself is one, and walking it never ends.
144
+ *
145
+ * @throws If a value holds one of its own ancestors.
146
+ */
147
+ private resolveNestedEnvironmentValue;
148
+ /**
149
+ * Checks the definition against `octo-v1.schema.json`.
150
+ */
61
151
  private validateDefinition;
62
152
  }