@storm-software/pulumi-tools 0.0.1

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 (38) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +7 -0
  3. package/executors/config/executor.js +4847 -0
  4. package/executors/import/executor.js +4846 -0
  5. package/executors/preview/executor.js +4843 -0
  6. package/executors/refresh/executor.js +4845 -0
  7. package/executors/up/executor.js +4848 -0
  8. package/executors.json +29 -0
  9. package/generators/init/generator.js +150 -0
  10. package/generators.json +9 -0
  11. package/index.js +5008 -0
  12. package/meta.json +3939 -0
  13. package/package.json +81 -0
  14. package/src/base/base-executor.d.ts +14 -0
  15. package/src/base/index.d.ts +2 -0
  16. package/src/base/providers.d.ts +6 -0
  17. package/src/executors/config/executor.d.ts +5 -0
  18. package/src/executors/config/schema.d.ts +9 -0
  19. package/src/executors/config/schema.json +38 -0
  20. package/src/executors/import/executor.d.ts +5 -0
  21. package/src/executors/import/schema.d.ts +6 -0
  22. package/src/executors/import/schema.json +40 -0
  23. package/src/executors/index.d.ts +5 -0
  24. package/src/executors/preview/executor.d.ts +5 -0
  25. package/src/executors/preview/schema.d.ts +5 -0
  26. package/src/executors/preview/schema.json +22 -0
  27. package/src/executors/refresh/executor.d.ts +5 -0
  28. package/src/executors/refresh/schema.d.ts +6 -0
  29. package/src/executors/refresh/schema.json +29 -0
  30. package/src/executors/up/executor.d.ts +5 -0
  31. package/src/executors/up/schema.d.ts +8 -0
  32. package/src/executors/up/schema.json +39 -0
  33. package/src/generators/index.d.ts +1 -0
  34. package/src/generators/init/files/src/index.ts.template +1 -0
  35. package/src/generators/init/generator.d.ts +6 -0
  36. package/src/generators/init/schema.d.ts +10 -0
  37. package/src/generators/init/schema.json +52 -0
  38. package/src/index.d.ts +2 -0
package/executors.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "executors": {
3
+ "config": {
4
+ "implementation": "./src/executors/config/executor",
5
+ "schema": "./src/executors/config/schema.json",
6
+ "description": "An executor to run the `config` pulumi CLI command"
7
+ },
8
+ "import": {
9
+ "implementation": "./src/executors/import/executor",
10
+ "schema": "./src/executors/import/schema.json",
11
+ "description": "An executor to run the `import` pulumi CLI command"
12
+ },
13
+ "preview": {
14
+ "implementation": "./src/executors/preview/executor",
15
+ "schema": "./src/executors/preview/schema.json",
16
+ "description": "An executor to run the `preview` pulumi CLI command"
17
+ },
18
+ "refresh": {
19
+ "implementation": "./src/executors/refresh/executor",
20
+ "schema": "./src/executors/refresh/schema.json",
21
+ "description": "An executor to run the `refresh` pulumi CLI command"
22
+ },
23
+ "up": {
24
+ "implementation": "./src/executors/up/executor",
25
+ "schema": "./src/executors/up/schema.json",
26
+ "description": "An executor to run the `up` pulumi CLI command"
27
+ }
28
+ }
29
+ }
@@ -0,0 +1,150 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __getOwnPropNames = Object.getOwnPropertyNames;
4
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
5
+ var __export = (target, all) => {
6
+ for (var name in all)
7
+ __defProp(target, name, { get: all[name], enumerable: true });
8
+ };
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
+
19
+ // packages/pulumi-tools/src/generators/init/generator.ts
20
+ var generator_exports = {};
21
+ __export(generator_exports, {
22
+ default: () => generator_default,
23
+ initGeneratorFn: () => initGeneratorFn
24
+ });
25
+ module.exports = __toCommonJS(generator_exports);
26
+ var import_devkit = require("@nx/devkit");
27
+ var import_config_tools = require("@storm-software/config-tools");
28
+ var import_workspace_tools = require("@storm-software/workspace-tools");
29
+ var import_node_fs = require("node:fs");
30
+ var import_node_path = require("node:path");
31
+
32
+ // packages/pulumi-tools/src/base/providers.ts
33
+ function getCloudTemplateName(cloudProvider) {
34
+ return `${cloudProvider}-typescript`;
35
+ }
36
+
37
+ // packages/pulumi-tools/src/generators/init/generator.ts
38
+ async function initGeneratorFn(tree, options, config) {
39
+ const task = (0, import_workspace_tools.initGenerator)(tree, options);
40
+ (0, import_devkit.addProjectConfiguration)(tree, options.name || "deployment", {
41
+ root: options.directory || "./deployment",
42
+ projectType: "application",
43
+ sourceRoot: options.directory || "./deployment",
44
+ targets: {
45
+ up: {
46
+ executor: "@nx-extend/pulumi:up",
47
+ options: {}
48
+ },
49
+ preview: {
50
+ executor: "@nx-extend/pulumi:preview",
51
+ options: {}
52
+ },
53
+ refresh: {
54
+ executor: "@nx-extend/pulumi:refresh",
55
+ options: {}
56
+ },
57
+ import: {
58
+ executor: "@nx-extend/pulumi:import",
59
+ options: {}
60
+ }
61
+ },
62
+ tags: ["infra:pulumi"]
63
+ });
64
+ await (0, import_devkit.runTasksInSerial)(
65
+ generateNewPulumiProject(tree, options, config),
66
+ loginToPulumi(tree, options, config),
67
+ addPulumiDeps(tree, options),
68
+ cleanupProject(tree, options)
69
+ )();
70
+ if (!options.skipFormat) {
71
+ await (0, import_devkit.formatFiles)(tree);
72
+ }
73
+ return task;
74
+ }
75
+ var generator_default = (0, import_workspace_tools.withRunGenerator)(
76
+ "Initialize Storm Pulumi workspace",
77
+ initGeneratorFn
78
+ );
79
+ function generateNewPulumiProject(tree, options, config) {
80
+ return () => {
81
+ const template = getCloudTemplateName(options.provider);
82
+ (0, import_config_tools.run)(
83
+ config,
84
+ [
85
+ `pulumi new ${template}`,
86
+ `--name=${options.name || "deployment"}`,
87
+ `--dir=${options.directory || "./deployment"}`,
88
+ options.secretsProvider && `--secrets-provider=${options.secretsProvider}`,
89
+ "--generate-only",
90
+ "--yes",
91
+ "--force"
92
+ ].filter(Boolean).join(" "),
93
+ (0, import_node_path.join)(config.workspaceRoot, options.directory || "./deployment"),
94
+ "inherit"
95
+ );
96
+ };
97
+ }
98
+ function loginToPulumi(tree, options, config) {
99
+ return () => {
100
+ if (!options.login) {
101
+ return;
102
+ }
103
+ if (options.login.startsWith("file://")) {
104
+ options.login = `file://${tree.root}/${options.directory || "./deployment"}/${options.login.replace("file://", "")}`;
105
+ }
106
+ (0, import_config_tools.run)(
107
+ config,
108
+ ["pulumi login", options.login].filter(Boolean).join(" "),
109
+ (0, import_node_path.join)(config.workspaceRoot, options.directory || "./deployment"),
110
+ "inherit",
111
+ {
112
+ ...process.env,
113
+ PULUMI_EXPERIMENTAL: "true"
114
+ }
115
+ );
116
+ };
117
+ }
118
+ function addPulumiDeps(tree, options) {
119
+ return () => {
120
+ const packageJson = (0, import_devkit.readJsonFile)(`${options.directory}/package.json`);
121
+ if (packageJson) {
122
+ (0, import_devkit.addDependenciesToPackageJson)(tree, {}, packageJson.dependencies || {})();
123
+ }
124
+ };
125
+ }
126
+ function cleanupProject(tree, options) {
127
+ return () => {
128
+ const indexTsLocation = (0, import_node_path.join)(
129
+ tree.root,
130
+ `${options.directory || "./deployment"}/index.ts`
131
+ );
132
+ tree.write(
133
+ `${options.directory}/pulumi.ts`,
134
+ (0, import_node_fs.readFileSync)(indexTsLocation).toString()
135
+ );
136
+ (0, import_node_fs.unlinkSync)(
137
+ (0, import_node_path.join)(tree.root, `${options.directory || "./deployment"}/.gitignore`)
138
+ );
139
+ (0, import_node_fs.unlinkSync)(
140
+ (0, import_node_path.join)(tree.root, `${options.directory || "./deployment"}/package.json`)
141
+ );
142
+ (0, import_node_fs.unlinkSync)(
143
+ (0, import_node_path.join)(tree.root, `${options.directory || "./deployment"}/tsconfig.json`)
144
+ );
145
+ };
146
+ }
147
+ // Annotate the CommonJS export names for ESM import in node:
148
+ 0 && (module.exports = {
149
+ initGeneratorFn
150
+ });
@@ -0,0 +1,9 @@
1
+ {
2
+ "generators": {
3
+ "init": {
4
+ "factory": "./src/generators/init/generator",
5
+ "schema": "./src/generators/init/schema.json",
6
+ "description": "Initialize the workspace"
7
+ }
8
+ }
9
+ }