@powerlines/plugin-pulumi 0.3.1 → 0.4.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.
package/dist/index.cjs CHANGED
@@ -1,73 +1,3 @@
1
- Object.defineProperty(exports, '__esModule', { value: true });
2
- const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
3
- let __alloy_js_core_jsx_runtime = require("@alloy-js/core/jsx-runtime");
4
- let __powerlines_plugin_alloy_render = require("@powerlines/plugin-alloy/render");
5
- let __powerlines_plugin_alloy_yaml_components_yaml_file = require("@powerlines/plugin-alloy/yaml/components/yaml-file");
6
- let __pulumi_pulumi_automation = require("@pulumi/pulumi/automation");
7
- let __stryke_fs_package_fns = require("@stryke/fs/package-fns");
8
- let __stryke_helpers = require("@stryke/helpers");
9
- let __stryke_path_join = require("@stryke/path/join");
10
- let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
11
- let defu = require("defu");
12
- defu = require_rolldown_runtime.__toESM(defu);
13
- let powerlines_plugin_utils = require("powerlines/plugin-utils");
1
+ const require_plugin = require('./plugin.cjs');
14
2
 
15
- //#region src/index.tsx
16
- /**
17
- * A package containing a Powerlines plugin to configure infrastructure and deploy a project using Pulumi IaC.
18
- *
19
- * @see https://www.pulumi.com
20
- *
21
- * @param options - The Pulumi plugin user configuration options.
22
- * @returns A Powerlines plugin to configure infrastructure and deploy a project using Pulumi.
23
- */
24
- const plugin = (options = {}) => {
25
- return {
26
- name: "pulumi",
27
- async config() {
28
- return { deploy: { pulumi: (0, defu.default)(options, {
29
- projectName: this.config.name,
30
- settings: {}
31
- }) } };
32
- },
33
- async configResolved() {
34
- if (!options.stack) this.config.pulumi.stackName ??= (0, __pulumi_pulumi_automation.fullyQualifiedStackName)((0, __stryke_string_format_kebab_case.kebabCase)((0, powerlines_plugin_utils.getOrganizationName)(this) || "default"), `${(0, powerlines_plugin_utils.getWorkspaceName)(this) ? `${(0, __stryke_string_format_kebab_case.kebabCase)((0, powerlines_plugin_utils.getWorkspaceName)(this))}-` : ""}${(0, __stryke_string_format_kebab_case.kebabCase)(this.config.name)}`, this.config.mode);
35
- },
36
- async prepare() {
37
- const _self$ = this;
38
- await (0, __powerlines_plugin_alloy_render.render)(this, (0, __alloy_js_core_jsx_runtime.createComponent)(__powerlines_plugin_alloy_yaml_components_yaml_file.YamlFile, {
39
- get path() {
40
- return (0, __stryke_path_join.joinPaths)(_self$.infrastructurePath, "Pulumi.yaml");
41
- },
42
- get data() {
43
- return { runtime: {
44
- name: "nodejs",
45
- options: { packagemanager: (0, __stryke_fs_package_fns.getPackageManager)(_self$.workspaceConfig.workspaceRoot) }
46
- } };
47
- }
48
- }));
49
- },
50
- deploy: {
51
- order: "post",
52
- async handler() {
53
- this.info(`Deploying Pulumi stack: ${this.config.pulumi.stack?.name || this.config.pulumi.stackName}`);
54
- if (!options.stack && !options.program && !options.projectName || !options.workDir) throw new Error(`Pulumi plugin requires either an inline program or a working directory to be specified.`);
55
- let stack = options.stack;
56
- stack ??= await __pulumi_pulumi_automation.LocalWorkspace.createOrSelectStack({
57
- workDir: (0, __stryke_path_join.joinPaths)(this.infrastructurePath),
58
- ...(0, __stryke_helpers.omit)(this.config.pulumi, ["options", "settings"])
59
- });
60
- if (this.config.pulumi.settings && Object.keys(this.config.pulumi.settings).length > 0) await stack.workspace.saveStackSettings(stack.name, this.config.pulumi.settings);
61
- await stack.refresh({ onOutput: this.debug.bind(this) });
62
- if (this.config.pulumi.destroy) await stack.destroy({ onOutput: this.debug.bind(this) });
63
- const result = await stack.up({ onOutput: this.debug.bind(this) });
64
- this.info(`Successfully deployed ${stack.name} (v${result.summary.version}): ${result.summary.message}`);
65
- }
66
- }
67
- };
68
- };
69
- var src_default = plugin;
70
-
71
- //#endregion
72
- exports.default = src_default;
73
- exports.plugin = plugin;
3
+ exports.plugin = require_plugin.plugin;
package/dist/index.d.cts CHANGED
@@ -1,22 +1,18 @@
1
- import { PulumiPluginBaseOptions, PulumiPluginContext, PulumiPluginCreateStackInlineOptions, PulumiPluginCreateStackLocalOptions, PulumiPluginCreateStackOptions, PulumiPluginExistingStackOptions, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginResolvedOptions, PulumiPluginUserConfig, __ΩPulumiPluginBaseOptions, __ΩPulumiPluginContext, __ΩPulumiPluginCreateStackInlineOptions, __ΩPulumiPluginCreateStackLocalOptions, __ΩPulumiPluginCreateStackOptions, __ΩPulumiPluginExistingStackOptions, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginResolvedOptions, __ΩPulumiPluginUserConfig } from "./types/plugin.cjs";
1
+ import { PulumiPluginContext, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginUserConfig, __ΩPulumiPluginContext, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginUserConfig } from "./types/plugin.cjs";
2
+ import { plugin } from "./plugin.cjs";
2
3
  import "./types/index.cjs";
3
- import { Plugin } from "powerlines";
4
+ import { MaybePromise } from "@stryke/types";
5
+ import { PluginContext } from "powerlines";
4
6
 
5
7
  //#region src/index.d.ts
6
- declare module "@powerlines/core" {
7
- interface BaseConfig {
8
+ declare module "powerlines" {
9
+ interface Config {
8
10
  pulumi?: PulumiPluginOptions;
9
11
  }
12
+ interface Hooks<TContext extends PluginContext> {
13
+ deployPulumi?: (this: TContext) => MaybePromise<void>;
14
+ }
10
15
  }
11
- /**
12
- * A package containing a Powerlines plugin to configure infrastructure and deploy a project using Pulumi IaC.
13
- *
14
- * @see https://www.pulumi.com
15
- *
16
- * @param options - The Pulumi plugin user configuration options.
17
- * @returns A Powerlines plugin to configure infrastructure and deploy a project using Pulumi.
18
- */
19
- declare const plugin: <TContext extends PulumiPluginContext = PulumiPluginContext>(options?: PulumiPluginOptions) => Plugin<TContext>;
20
16
  //#endregion
21
- export { PulumiPluginBaseOptions, PulumiPluginContext, PulumiPluginCreateStackInlineOptions, PulumiPluginCreateStackLocalOptions, PulumiPluginCreateStackOptions, PulumiPluginExistingStackOptions, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginResolvedOptions, PulumiPluginUserConfig, __ΩPulumiPluginBaseOptions, __ΩPulumiPluginContext, __ΩPulumiPluginCreateStackInlineOptions, __ΩPulumiPluginCreateStackLocalOptions, __ΩPulumiPluginCreateStackOptions, __ΩPulumiPluginExistingStackOptions, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginResolvedOptions, __ΩPulumiPluginUserConfig, plugin as default, plugin };
17
+ export { PulumiPluginContext, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginUserConfig, __ΩPulumiPluginContext, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginUserConfig, plugin };
22
18
  //# sourceMappingURL=index.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;IAwCwB,MAAA,CAAA,EAIX,mBAJW;EAAA;;;;AAgBxB;;;;;;AAIS,cAJI,MAIJ,EAAA,CAAA,iBAHU,mBAGV,GAHgC,mBAGhC,CAAA,CAAA,OAAA,CAAA,EADE,mBACF,EAAA,GAAN,MAAM,CAAC,QAAD,CAAA"}
1
+ {"version":3,"file":"index.d.cts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;aAwBa;;EAJwC,UAAA,KAAA,CAAA,iBAOlB,aAPkB,CAAA,CAAA;IAAA,YAAA,CAAA,EAAA,CAAA,IAAA,EAQ3B,QAR2B,EAAA,GAQd,YARc,CAAA,IAAA,CAAA;EAAA"}
package/dist/index.d.mts CHANGED
@@ -1,22 +1,18 @@
1
- import { PulumiPluginBaseOptions, PulumiPluginContext, PulumiPluginCreateStackInlineOptions, PulumiPluginCreateStackLocalOptions, PulumiPluginCreateStackOptions, PulumiPluginExistingStackOptions, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginResolvedOptions, PulumiPluginUserConfig, __ΩPulumiPluginBaseOptions, __ΩPulumiPluginContext, __ΩPulumiPluginCreateStackInlineOptions, __ΩPulumiPluginCreateStackLocalOptions, __ΩPulumiPluginCreateStackOptions, __ΩPulumiPluginExistingStackOptions, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginResolvedOptions, __ΩPulumiPluginUserConfig } from "./types/plugin.mjs";
1
+ import { PulumiPluginContext, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginUserConfig, __ΩPulumiPluginContext, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginUserConfig } from "./types/plugin.mjs";
2
+ import { plugin } from "./plugin.mjs";
2
3
  import "./types/index.mjs";
3
- import { Plugin } from "powerlines";
4
+ import { MaybePromise } from "@stryke/types";
5
+ import { PluginContext } from "powerlines";
4
6
 
5
7
  //#region src/index.d.ts
6
- declare module "@powerlines/core" {
7
- interface BaseConfig {
8
+ declare module "powerlines" {
9
+ interface Config {
8
10
  pulumi?: PulumiPluginOptions;
9
11
  }
12
+ interface Hooks<TContext extends PluginContext> {
13
+ deployPulumi?: (this: TContext) => MaybePromise<void>;
14
+ }
10
15
  }
11
- /**
12
- * A package containing a Powerlines plugin to configure infrastructure and deploy a project using Pulumi IaC.
13
- *
14
- * @see https://www.pulumi.com
15
- *
16
- * @param options - The Pulumi plugin user configuration options.
17
- * @returns A Powerlines plugin to configure infrastructure and deploy a project using Pulumi.
18
- */
19
- declare const plugin: <TContext extends PulumiPluginContext = PulumiPluginContext>(options?: PulumiPluginOptions) => Plugin<TContext>;
20
16
  //#endregion
21
- export { PulumiPluginBaseOptions, PulumiPluginContext, PulumiPluginCreateStackInlineOptions, PulumiPluginCreateStackLocalOptions, PulumiPluginCreateStackOptions, PulumiPluginExistingStackOptions, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginResolvedOptions, PulumiPluginUserConfig, __ΩPulumiPluginBaseOptions, __ΩPulumiPluginContext, __ΩPulumiPluginCreateStackInlineOptions, __ΩPulumiPluginCreateStackLocalOptions, __ΩPulumiPluginCreateStackOptions, __ΩPulumiPluginExistingStackOptions, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginResolvedOptions, __ΩPulumiPluginUserConfig, plugin as default, plugin };
17
+ export { PulumiPluginContext, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginUserConfig, __ΩPulumiPluginContext, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginUserConfig, plugin };
22
18
  //# sourceMappingURL=index.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.tsx"],"sourcesContent":[],"mappings":";;;;;;;IAwCwB,MAAA,CAAA,EAIX,mBAJW;EAAA;;;;AAgBxB;;;;;;AAIS,cAJI,MAIJ,EAAA,CAAA,iBAHU,mBAGV,GAHgC,mBAGhC,CAAA,CAAA,OAAA,CAAA,EADE,mBACF,EAAA,GAAN,MAAM,CAAC,QAAD,CAAA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;aAwBa;;EAJwC,UAAA,KAAA,CAAA,iBAOlB,aAPkB,CAAA,CAAA;IAAA,YAAA,CAAA,EAAA,CAAA,IAAA,EAQ3B,QAR2B,EAAA,GAQd,YARc,CAAA,IAAA,CAAA;EAAA"}
package/dist/index.mjs CHANGED
@@ -1,70 +1,3 @@
1
- import { createComponent } from "@alloy-js/core/jsx-runtime";
2
- import { render } from "@powerlines/plugin-alloy/render";
3
- import { YamlFile } from "@powerlines/plugin-alloy/yaml/components/yaml-file";
4
- import { LocalWorkspace, fullyQualifiedStackName } from "@pulumi/pulumi/automation";
5
- import { getPackageManager } from "@stryke/fs/package-fns";
6
- import { omit } from "@stryke/helpers";
7
- import { joinPaths } from "@stryke/path/join";
8
- import { kebabCase } from "@stryke/string-format/kebab-case";
9
- import defu from "defu";
10
- import { getOrganizationName, getWorkspaceName } from "powerlines/plugin-utils";
1
+ import { plugin } from "./plugin.mjs";
11
2
 
12
- //#region src/index.tsx
13
- /**
14
- * A package containing a Powerlines plugin to configure infrastructure and deploy a project using Pulumi IaC.
15
- *
16
- * @see https://www.pulumi.com
17
- *
18
- * @param options - The Pulumi plugin user configuration options.
19
- * @returns A Powerlines plugin to configure infrastructure and deploy a project using Pulumi.
20
- */
21
- const plugin = (options = {}) => {
22
- return {
23
- name: "pulumi",
24
- async config() {
25
- return { deploy: { pulumi: defu(options, {
26
- projectName: this.config.name,
27
- settings: {}
28
- }) } };
29
- },
30
- async configResolved() {
31
- if (!options.stack) this.config.pulumi.stackName ??= fullyQualifiedStackName(kebabCase(getOrganizationName(this) || "default"), `${getWorkspaceName(this) ? `${kebabCase(getWorkspaceName(this))}-` : ""}${kebabCase(this.config.name)}`, this.config.mode);
32
- },
33
- async prepare() {
34
- const _self$ = this;
35
- await render(this, createComponent(YamlFile, {
36
- get path() {
37
- return joinPaths(_self$.infrastructurePath, "Pulumi.yaml");
38
- },
39
- get data() {
40
- return { runtime: {
41
- name: "nodejs",
42
- options: { packagemanager: getPackageManager(_self$.workspaceConfig.workspaceRoot) }
43
- } };
44
- }
45
- }));
46
- },
47
- deploy: {
48
- order: "post",
49
- async handler() {
50
- this.info(`Deploying Pulumi stack: ${this.config.pulumi.stack?.name || this.config.pulumi.stackName}`);
51
- if (!options.stack && !options.program && !options.projectName || !options.workDir) throw new Error(`Pulumi plugin requires either an inline program or a working directory to be specified.`);
52
- let stack = options.stack;
53
- stack ??= await LocalWorkspace.createOrSelectStack({
54
- workDir: joinPaths(this.infrastructurePath),
55
- ...omit(this.config.pulumi, ["options", "settings"])
56
- });
57
- if (this.config.pulumi.settings && Object.keys(this.config.pulumi.settings).length > 0) await stack.workspace.saveStackSettings(stack.name, this.config.pulumi.settings);
58
- await stack.refresh({ onOutput: this.debug.bind(this) });
59
- if (this.config.pulumi.destroy) await stack.destroy({ onOutput: this.debug.bind(this) });
60
- const result = await stack.up({ onOutput: this.debug.bind(this) });
61
- this.info(`Successfully deployed ${stack.name} (v${result.summary.version}): ${result.summary.message}`);
62
- }
63
- }
64
- };
65
- };
66
- var src_default = plugin;
67
-
68
- //#endregion
69
- export { src_default as default, plugin };
70
- //# sourceMappingURL=index.mjs.map
3
+ export { plugin };
@@ -0,0 +1,54 @@
1
+ const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
2
+ let __pulumi_pulumi_automation = require("@pulumi/pulumi/automation");
3
+ let __stryke_string_format_kebab_case = require("@stryke/string-format/kebab-case");
4
+ let defu = require("defu");
5
+ defu = require_rolldown_runtime.__toESM(defu);
6
+ let powerlines_plugin_utils = require("powerlines/plugin-utils");
7
+
8
+ //#region src/plugin.ts
9
+ /**
10
+ * A package containing a Powerlines plugin to configure infrastructure and deploy a project using Pulumi IaC.
11
+ *
12
+ * @see https://www.pulumi.com
13
+ *
14
+ * @param options - The Pulumi plugin user configuration options.
15
+ * @returns A Powerlines plugin to configure infrastructure and deploy a project using Pulumi.
16
+ */
17
+ const plugin = (options = {}) => {
18
+ return [{
19
+ name: "pulumi",
20
+ async config() {
21
+ return { deploy: { pulumi: (0, defu.default)(options, {
22
+ projectName: this.config.name,
23
+ settings: {}
24
+ }) } };
25
+ },
26
+ async configResolved() {
27
+ const organizationName = (0, __stryke_string_format_kebab_case.kebabCase)((0, powerlines_plugin_utils.getOrganizationName)(this));
28
+ const workspaceName = (0, __stryke_string_format_kebab_case.kebabCase)((0, powerlines_plugin_utils.getWorkspaceName)(this));
29
+ const projectName = (0, __stryke_string_format_kebab_case.kebabCase)(this.config.name);
30
+ this.config.pulumi.stackName ??= (0, __pulumi_pulumi_automation.fullyQualifiedStackName)(organizationName || workspaceName || projectName, `${workspaceName && workspaceName !== organizationName && workspaceName !== projectName ? `${workspaceName}-` : ""}${projectName}`, this.config.mode);
31
+ },
32
+ async deploy() {
33
+ this.info(`Creating resources for Pulumi stack: ${this.config.pulumi.stackName}`);
34
+ this.pulumi ??= await __pulumi_pulumi_automation.LocalWorkspace.createOrSelectStack({
35
+ ...this.config.pulumi,
36
+ program: async () => {
37
+ this.debug("Executing Pulumi program to define infrastructure resources.");
38
+ await this.$$internal.callHook("deployPulumi", { sequential: true });
39
+ this.debug("Pulumi program execution completed. Resources have been defined.");
40
+ }
41
+ });
42
+ await this.pulumi.workspace.installPlugin("terraform-provider", "v1.0.2");
43
+ if (this.config.pulumi.settings && Object.keys(this.config.pulumi.settings).length > 0) await this.pulumi.workspace.saveStackSettings(this.pulumi.name, this.config.pulumi.settings);
44
+ this.info(`Deploying Pulumi stack: ${this.config.pulumi.stackName}`);
45
+ await this.pulumi.refresh({ onOutput: this.debug.bind(this) });
46
+ if (this.config.pulumi.destroy) await this.pulumi.destroy({ onOutput: this.debug.bind(this) });
47
+ const result = await this.pulumi.up({ onOutput: this.debug.bind(this) });
48
+ this.info(`Successfully deployed ${this.pulumi.name} (v${result.summary.version}): ${result.summary.message}`);
49
+ }
50
+ }];
51
+ };
52
+
53
+ //#endregion
54
+ exports.plugin = plugin;
@@ -0,0 +1,18 @@
1
+ import { PulumiPluginOptions } from "./types/plugin.cjs";
2
+ import { UNSAFE_PulumiPluginContext } from "./types/_internal.cjs";
3
+ import { Plugin } from "powerlines";
4
+
5
+ //#region src/plugin.d.ts
6
+
7
+ /**
8
+ * A package containing a Powerlines plugin to configure infrastructure and deploy a project using Pulumi IaC.
9
+ *
10
+ * @see https://www.pulumi.com
11
+ *
12
+ * @param options - The Pulumi plugin user configuration options.
13
+ * @returns A Powerlines plugin to configure infrastructure and deploy a project using Pulumi.
14
+ */
15
+ declare const plugin: <TContext extends UNSAFE_PulumiPluginContext = UNSAFE_PulumiPluginContext>(options?: PulumiPluginOptions) => Plugin<TContext>[];
16
+ //#endregion
17
+ export { plugin };
18
+ //# sourceMappingURL=plugin.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../src/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAqCA;;;;;;AAIS,cAJI,MAIJ,EAAA,CAAA,iBAHU,0BAGV,GAHuC,0BAGvC,CAAA,CAAA,OAAA,CAAA,EADE,mBACF,EAAA,GAAN,MAAM,CAAC,QAAD,CAAA,EAAA"}
@@ -0,0 +1,18 @@
1
+ import { PulumiPluginOptions } from "./types/plugin.mjs";
2
+ import { UNSAFE_PulumiPluginContext } from "./types/_internal.mjs";
3
+ import { Plugin } from "powerlines";
4
+
5
+ //#region src/plugin.d.ts
6
+
7
+ /**
8
+ * A package containing a Powerlines plugin to configure infrastructure and deploy a project using Pulumi IaC.
9
+ *
10
+ * @see https://www.pulumi.com
11
+ *
12
+ * @param options - The Pulumi plugin user configuration options.
13
+ * @returns A Powerlines plugin to configure infrastructure and deploy a project using Pulumi.
14
+ */
15
+ declare const plugin: <TContext extends UNSAFE_PulumiPluginContext = UNSAFE_PulumiPluginContext>(options?: PulumiPluginOptions) => Plugin<TContext>[];
16
+ //#endregion
17
+ export { plugin };
18
+ //# sourceMappingURL=plugin.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../src/plugin.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAqCA;;;;;;AAIS,cAJI,MAIJ,EAAA,CAAA,iBAHU,0BAGV,GAHuC,0BAGvC,CAAA,CAAA,OAAA,CAAA,EADE,mBACF,EAAA,GAAN,MAAM,CAAC,QAAD,CAAA,EAAA"}
@@ -0,0 +1,53 @@
1
+ import { LocalWorkspace, fullyQualifiedStackName } from "@pulumi/pulumi/automation";
2
+ import { kebabCase } from "@stryke/string-format/kebab-case";
3
+ import defu from "defu";
4
+ import { getOrganizationName, getWorkspaceName } from "powerlines/plugin-utils";
5
+
6
+ //#region src/plugin.ts
7
+ /**
8
+ * A package containing a Powerlines plugin to configure infrastructure and deploy a project using Pulumi IaC.
9
+ *
10
+ * @see https://www.pulumi.com
11
+ *
12
+ * @param options - The Pulumi plugin user configuration options.
13
+ * @returns A Powerlines plugin to configure infrastructure and deploy a project using Pulumi.
14
+ */
15
+ const plugin = (options = {}) => {
16
+ return [{
17
+ name: "pulumi",
18
+ async config() {
19
+ return { deploy: { pulumi: defu(options, {
20
+ projectName: this.config.name,
21
+ settings: {}
22
+ }) } };
23
+ },
24
+ async configResolved() {
25
+ const organizationName = kebabCase(getOrganizationName(this));
26
+ const workspaceName = kebabCase(getWorkspaceName(this));
27
+ const projectName = kebabCase(this.config.name);
28
+ this.config.pulumi.stackName ??= fullyQualifiedStackName(organizationName || workspaceName || projectName, `${workspaceName && workspaceName !== organizationName && workspaceName !== projectName ? `${workspaceName}-` : ""}${projectName}`, this.config.mode);
29
+ },
30
+ async deploy() {
31
+ this.info(`Creating resources for Pulumi stack: ${this.config.pulumi.stackName}`);
32
+ this.pulumi ??= await LocalWorkspace.createOrSelectStack({
33
+ ...this.config.pulumi,
34
+ program: async () => {
35
+ this.debug("Executing Pulumi program to define infrastructure resources.");
36
+ await this.$$internal.callHook("deployPulumi", { sequential: true });
37
+ this.debug("Pulumi program execution completed. Resources have been defined.");
38
+ }
39
+ });
40
+ await this.pulumi.workspace.installPlugin("terraform-provider", "v1.0.2");
41
+ if (this.config.pulumi.settings && Object.keys(this.config.pulumi.settings).length > 0) await this.pulumi.workspace.saveStackSettings(this.pulumi.name, this.config.pulumi.settings);
42
+ this.info(`Deploying Pulumi stack: ${this.config.pulumi.stackName}`);
43
+ await this.pulumi.refresh({ onOutput: this.debug.bind(this) });
44
+ if (this.config.pulumi.destroy) await this.pulumi.destroy({ onOutput: this.debug.bind(this) });
45
+ const result = await this.pulumi.up({ onOutput: this.debug.bind(this) });
46
+ this.info(`Successfully deployed ${this.pulumi.name} (v${result.summary.version}): ${result.summary.message}`);
47
+ }
48
+ }];
49
+ };
50
+
51
+ //#endregion
52
+ export { plugin };
53
+ //# sourceMappingURL=plugin.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.mjs","names":[],"sources":["../src/plugin.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport {\n fullyQualifiedStackName,\n LocalWorkspace\n} from \"@pulumi/pulumi/automation\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport { getOrganizationName, getWorkspaceName } from \"powerlines/plugin-utils\";\nimport { UNSAFE_PulumiPluginContext } from \"./types/_internal\";\nimport { PulumiPluginOptions } from \"./types/plugin\";\n\n/**\n * A package containing a Powerlines plugin to configure infrastructure and deploy a project using Pulumi IaC.\n *\n * @see https://www.pulumi.com\n *\n * @param options - The Pulumi plugin user configuration options.\n * @returns A Powerlines plugin to configure infrastructure and deploy a project using Pulumi.\n */\nexport const plugin = <\n TContext extends UNSAFE_PulumiPluginContext = UNSAFE_PulumiPluginContext\n>(\n options: PulumiPluginOptions = {}\n): Plugin<TContext>[] => {\n return [\n {\n name: \"pulumi\",\n async config() {\n return {\n deploy: {\n pulumi: defu(options, {\n projectName: this.config.name,\n settings: {}\n })\n }\n };\n },\n async configResolved() {\n const organizationName = kebabCase(getOrganizationName(this));\n const workspaceName = kebabCase(getWorkspaceName(this));\n const projectName = kebabCase(this.config.name);\n\n this.config.pulumi.stackName ??= fullyQualifiedStackName(\n organizationName || workspaceName || projectName,\n `${\n workspaceName &&\n workspaceName !== organizationName &&\n workspaceName !== projectName\n ? `${workspaceName}-`\n : \"\"\n }${projectName}`,\n this.config.mode\n );\n },\n async deploy() {\n this.info(\n `Creating resources for Pulumi stack: ${this.config.pulumi.stackName}`\n );\n\n this.pulumi ??= await LocalWorkspace.createOrSelectStack({\n ...(this.config.pulumi as Parameters<\n typeof LocalWorkspace.createOrSelectStack\n >[0]),\n program: async () => {\n this.debug(\n \"Executing Pulumi program to define infrastructure resources.\"\n );\n\n await this.$$internal.callHook(\"deployPulumi\", {\n sequential: true\n });\n\n this.debug(\n \"Pulumi program execution completed. Resources have been defined.\"\n );\n }\n });\n await this.pulumi.workspace.installPlugin(\n \"terraform-provider\",\n \"v1.0.2\"\n );\n\n if (\n this.config.pulumi.settings &&\n Object.keys(this.config.pulumi.settings).length > 0\n ) {\n await this.pulumi.workspace.saveStackSettings(\n this.pulumi.name,\n this.config.pulumi.settings\n );\n }\n\n this.info(`Deploying Pulumi stack: ${this.config.pulumi.stackName}`);\n\n await this.pulumi.refresh({ onOutput: this.debug.bind(this) });\n\n if (this.config.pulumi.destroy) {\n await this.pulumi.destroy({\n onOutput: this.debug.bind(this)\n });\n }\n\n const result = await this.pulumi.up({\n onOutput: this.debug.bind(this)\n });\n\n this.info(\n `Successfully deployed ${this.pulumi.name} (v${\n result.summary.version\n }): ${result.summary.message}`\n );\n }\n }\n ] as Plugin<TContext>[];\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;AAqCA,MAAa,UAGX,UAA+B,EAAE,KACV;AACvB,QAAO,CACL;EACE,MAAM;EACN,MAAM,SAAS;AACb,UAAO,EACL,QAAQ,EACN,QAAQ,KAAK,SAAS;IACpB,aAAa,KAAK,OAAO;IACzB,UAAU,EAAE;IACb,CAAC,EACH,EACF;;EAEH,MAAM,iBAAiB;GACrB,MAAM,mBAAmB,UAAU,oBAAoB,KAAK,CAAC;GAC7D,MAAM,gBAAgB,UAAU,iBAAiB,KAAK,CAAC;GACvD,MAAM,cAAc,UAAU,KAAK,OAAO,KAAK;AAE/C,QAAK,OAAO,OAAO,cAAc,wBAC/B,oBAAoB,iBAAiB,aACrC,GACE,iBACA,kBAAkB,oBAClB,kBAAkB,cACd,GAAG,cAAc,KACjB,KACH,eACH,KAAK,OAAO,KACb;;EAEH,MAAM,SAAS;AACb,QAAK,KACH,wCAAwC,KAAK,OAAO,OAAO,YAC5D;AAED,QAAK,WAAW,MAAM,eAAe,oBAAoB;IACvD,GAAI,KAAK,OAAO;IAGhB,SAAS,YAAY;AACnB,UAAK,MACH,+DACD;AAED,WAAM,KAAK,WAAW,SAAS,gBAAgB,EAC7C,YAAY,MACb,CAAC;AAEF,UAAK,MACH,mEACD;;IAEJ,CAAC;AACF,SAAM,KAAK,OAAO,UAAU,cAC1B,sBACA,SACD;AAED,OACE,KAAK,OAAO,OAAO,YACnB,OAAO,KAAK,KAAK,OAAO,OAAO,SAAS,CAAC,SAAS,EAElD,OAAM,KAAK,OAAO,UAAU,kBAC1B,KAAK,OAAO,MACZ,KAAK,OAAO,OAAO,SACpB;AAGH,QAAK,KAAK,2BAA2B,KAAK,OAAO,OAAO,YAAY;AAEpE,SAAM,KAAK,OAAO,QAAQ,EAAE,UAAU,KAAK,MAAM,KAAK,KAAK,EAAE,CAAC;AAE9D,OAAI,KAAK,OAAO,OAAO,QACrB,OAAM,KAAK,OAAO,QAAQ,EACxB,UAAU,KAAK,MAAM,KAAK,KAAK,EAChC,CAAC;GAGJ,MAAM,SAAS,MAAM,KAAK,OAAO,GAAG,EAClC,UAAU,KAAK,MAAM,KAAK,KAAK,EAChC,CAAC;AAEF,QAAK,KACH,yBAAyB,KAAK,OAAO,KAAK,KACxC,OAAO,QAAQ,QAChB,KAAK,OAAO,QAAQ,UACtB;;EAEJ,CACF"}
File without changes
@@ -0,0 +1,9 @@
1
+ import { PulumiPluginContext, PulumiPluginResolvedConfig } from "./plugin.cjs";
2
+ import { UNSAFE_PluginContext } from "@powerlines/core/types/_internal";
3
+
4
+ //#region src/types/_internal.d.ts
5
+ type UNSAFE_PulumiPluginContext<TResolvedConfig extends PulumiPluginResolvedConfig = PulumiPluginResolvedConfig> = PulumiPluginContext<TResolvedConfig> & UNSAFE_PluginContext<TResolvedConfig>;
6
+ declare type __ΩUNSAFE_PulumiPluginContext = any[];
7
+ //#endregion
8
+ export { UNSAFE_PulumiPluginContext, __ΩUNSAFE_PulumiPluginContext };
9
+ //# sourceMappingURL=_internal.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_internal.d.cts","names":[],"sources":["../../src/types/_internal.ts"],"sourcesContent":[],"mappings":";;;;KAqBY,mDACc,6BACtB,8BACA,oBAAoB,mBACtB,qBAAqB"}
@@ -0,0 +1,9 @@
1
+ import { PulumiPluginContext, PulumiPluginResolvedConfig } from "./plugin.mjs";
2
+ import { UNSAFE_PluginContext } from "@powerlines/core/types/_internal";
3
+
4
+ //#region src/types/_internal.d.ts
5
+ type UNSAFE_PulumiPluginContext<TResolvedConfig extends PulumiPluginResolvedConfig = PulumiPluginResolvedConfig> = PulumiPluginContext<TResolvedConfig> & UNSAFE_PluginContext<TResolvedConfig>;
6
+ declare type __ΩUNSAFE_PulumiPluginContext = any[];
7
+ //#endregion
8
+ export { UNSAFE_PulumiPluginContext, __ΩUNSAFE_PulumiPluginContext };
9
+ //# sourceMappingURL=_internal.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"_internal.d.mts","names":[],"sources":["../../src/types/_internal.ts"],"sourcesContent":[],"mappings":";;;;KAqBY,mDACc,6BACtB,8BACA,oBAAoB,mBACtB,qBAAqB"}
@@ -0,0 +1 @@
1
+ export { };
@@ -1,2 +1,2 @@
1
- import { PulumiPluginBaseOptions, PulumiPluginContext, PulumiPluginCreateStackInlineOptions, PulumiPluginCreateStackLocalOptions, PulumiPluginCreateStackOptions, PulumiPluginExistingStackOptions, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginResolvedOptions, PulumiPluginUserConfig, __ΩPulumiPluginBaseOptions, __ΩPulumiPluginContext, __ΩPulumiPluginCreateStackInlineOptions, __ΩPulumiPluginCreateStackLocalOptions, __ΩPulumiPluginCreateStackOptions, __ΩPulumiPluginExistingStackOptions, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginResolvedOptions, __ΩPulumiPluginUserConfig } from "./plugin.cjs";
2
- export { PulumiPluginBaseOptions, PulumiPluginContext, PulumiPluginCreateStackInlineOptions, PulumiPluginCreateStackLocalOptions, PulumiPluginCreateStackOptions, PulumiPluginExistingStackOptions, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginResolvedOptions, PulumiPluginUserConfig, __ΩPulumiPluginBaseOptions, __ΩPulumiPluginContext, __ΩPulumiPluginCreateStackInlineOptions, __ΩPulumiPluginCreateStackLocalOptions, __ΩPulumiPluginCreateStackOptions, __ΩPulumiPluginExistingStackOptions, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginResolvedOptions, __ΩPulumiPluginUserConfig };
1
+ import { PulumiPluginContext, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginUserConfig, __ΩPulumiPluginContext, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginUserConfig } from "./plugin.cjs";
2
+ export { PulumiPluginContext, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginUserConfig, __ΩPulumiPluginContext, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginUserConfig };
@@ -1,2 +1,2 @@
1
- import { PulumiPluginBaseOptions, PulumiPluginContext, PulumiPluginCreateStackInlineOptions, PulumiPluginCreateStackLocalOptions, PulumiPluginCreateStackOptions, PulumiPluginExistingStackOptions, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginResolvedOptions, PulumiPluginUserConfig, __ΩPulumiPluginBaseOptions, __ΩPulumiPluginContext, __ΩPulumiPluginCreateStackInlineOptions, __ΩPulumiPluginCreateStackLocalOptions, __ΩPulumiPluginCreateStackOptions, __ΩPulumiPluginExistingStackOptions, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginResolvedOptions, __ΩPulumiPluginUserConfig } from "./plugin.mjs";
2
- export { PulumiPluginBaseOptions, PulumiPluginContext, PulumiPluginCreateStackInlineOptions, PulumiPluginCreateStackLocalOptions, PulumiPluginCreateStackOptions, PulumiPluginExistingStackOptions, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginResolvedOptions, PulumiPluginUserConfig, __ΩPulumiPluginBaseOptions, __ΩPulumiPluginContext, __ΩPulumiPluginCreateStackInlineOptions, __ΩPulumiPluginCreateStackLocalOptions, __ΩPulumiPluginCreateStackOptions, __ΩPulumiPluginExistingStackOptions, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginResolvedOptions, __ΩPulumiPluginUserConfig };
1
+ import { PulumiPluginContext, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginUserConfig, __ΩPulumiPluginContext, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginUserConfig } from "./plugin.mjs";
2
+ export { PulumiPluginContext, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginUserConfig, __ΩPulumiPluginContext, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginUserConfig };
@@ -1,8 +1,12 @@
1
1
  import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
2
- import { LocalWorkspaceOptions, PulumiFn, Stack, StackSettings } from "@pulumi/pulumi/automation";
2
+ import { InlineProgramArgs, LocalWorkspaceOptions, Stack, StackSettings } from "@pulumi/pulumi/automation";
3
3
 
4
4
  //#region src/types/plugin.d.ts
5
- interface PulumiPluginBaseOptions {
5
+ interface PulumiPluginOptions extends Partial<InlineProgramArgs> {
6
+ /**
7
+ * Additional options for the Pulumi Workspace.
8
+ */
9
+ options?: LocalWorkspaceOptions;
6
10
  /**
7
11
  * Whether to destroy the stack during the `destroy` lifecycle phase.
8
12
  *
@@ -14,65 +18,19 @@ interface PulumiPluginBaseOptions {
14
18
  */
15
19
  settings?: StackSettings;
16
20
  }
17
- interface PulumiPluginExistingStackOptions extends PulumiPluginBaseOptions {
18
- /**
19
- * The Pulumi Stack instance to use for deployment operations.
20
- */
21
- stack?: Stack;
22
- }
23
- interface PulumiPluginCreateStackOptions extends PulumiPluginBaseOptions {
24
- /**
25
- * The associated stack name.
26
- */
27
- stackName?: string;
28
- /**
29
- * Additional options for the Pulumi Workspace.
30
- */
31
- options?: LocalWorkspaceOptions;
32
- }
33
- interface PulumiPluginExistingStackOptions {
34
- /**
35
- * The Pulumi Stack instance to use for deployment operations.
36
- */
37
- stack?: Stack;
38
- }
39
- interface PulumiPluginCreateStackInlineOptions extends PulumiPluginCreateStackOptions {
40
- /**
41
- * The associated project name.
42
- */
43
- projectName?: string;
44
- /**
45
- * The inline (in-process) Pulumi program to use with update and preview operations.
46
- */
47
- program?: PulumiFn;
48
- }
49
- interface PulumiPluginCreateStackLocalOptions extends PulumiPluginCreateStackOptions {
50
- /**
51
- * The working directory of the program.
52
- *
53
- * @defaultValue "\{artifactsPath\}/infrastructure"
54
- */
55
- workDir?: string;
56
- }
57
- type PulumiPluginOptions = PulumiPluginExistingStackOptions | PulumiPluginCreateStackInlineOptions | PulumiPluginCreateStackLocalOptions;
58
- type PulumiPluginResolvedOptions = (Omit<PulumiPluginExistingStackOptions, "stack"> & Required<Pick<PulumiPluginExistingStackOptions, "stack">>) | (Omit<PulumiPluginCreateStackInlineOptions, "stackName" | "projectName" | "program"> & Required<Pick<PulumiPluginCreateStackInlineOptions, "stackName" | "projectName" | "program">>) | (Omit<PulumiPluginCreateStackLocalOptions, "stackName" | "workDir"> & Required<Pick<PulumiPluginCreateStackLocalOptions, "stackName" | "workDir">>);
59
21
  interface PulumiPluginUserConfig extends UserConfig {
60
22
  pulumi?: PulumiPluginOptions;
61
23
  }
62
24
  interface PulumiPluginResolvedConfig extends ResolvedConfig {
63
25
  pulumi: PulumiPluginOptions;
64
26
  }
65
- type PulumiPluginContext<TResolvedConfig extends PulumiPluginResolvedConfig = PulumiPluginResolvedConfig> = PluginContext<TResolvedConfig>;
66
- declare type __ΩPulumiPluginBaseOptions = any[];
67
- declare type __ΩPulumiPluginExistingStackOptions = any[];
68
- declare type __ΩPulumiPluginCreateStackOptions = any[];
69
- declare type __ΩPulumiPluginCreateStackInlineOptions = any[];
70
- declare type __ΩPulumiPluginCreateStackLocalOptions = any[];
27
+ type PulumiPluginContext<TResolvedConfig extends PulumiPluginResolvedConfig = PulumiPluginResolvedConfig> = PluginContext<TResolvedConfig> & {
28
+ pulumi: Stack;
29
+ };
71
30
  declare type __ΩPulumiPluginOptions = any[];
72
- declare type __ΩPulumiPluginResolvedOptions = any[];
73
31
  declare type __ΩPulumiPluginUserConfig = any[];
74
32
  declare type __ΩPulumiPluginResolvedConfig = any[];
75
33
  declare type __ΩPulumiPluginContext = any[];
76
34
  //#endregion
77
- export { PulumiPluginBaseOptions, PulumiPluginContext, PulumiPluginCreateStackInlineOptions, PulumiPluginCreateStackLocalOptions, PulumiPluginCreateStackOptions, PulumiPluginExistingStackOptions, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginResolvedOptions, PulumiPluginUserConfig, __ΩPulumiPluginBaseOptions, __ΩPulumiPluginContext, __ΩPulumiPluginCreateStackInlineOptions, __ΩPulumiPluginCreateStackLocalOptions, __ΩPulumiPluginCreateStackOptions, __ΩPulumiPluginExistingStackOptions, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginResolvedOptions, __ΩPulumiPluginUserConfig };
35
+ export { PulumiPluginContext, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginUserConfig, __ΩPulumiPluginContext, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginUserConfig };
78
36
  //# sourceMappingURL=plugin.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;UA0BiB,uBAAA;;AAAjB;AAcA;AAOA;AAYA;EAOiB,OAAA,CAAA,EAAA,OAAA;EAYA;AASjB;;EAEI,QAAA,CAAA,EApDS,aAoDT;;AACmC,UAlDtB,gCAAA,SAAyC,uBAkDnB,CAAA;EAE3B;;;EAEQ,KAAA,CAAA,EAlDV,KAkDU;;AAAd,UA/CW,8BAAA,SAAuC,uBA+ClD,CAAA;EAEA;;;EAIE,SAAA,CAAA,EAAA,MAAA;EADF;;;EAQO,OAAA,CAAA,EAnDD,qBAmDC;;AADP,UA/CW,gCAAA,CA+CX;EAAQ;AAId;AAIA;EAIY,KAAA,CAAA,EAvDF,KAuDE;;AAER,UAtDa,oCAAA,SAA6C,8BAsD1D,CAAA;EACc;;;;;;;YA9CN;;UAGK,mCAAA,SAA4C;;;;;;;;KASjD,mBAAA,GACR,mCACA,uCACA;KAEQ,2BAAA,IACP,KAAK,6CACJ,SAAS,KAAK,gDACf,KACC,iFAGA,SACE,KACE,oFAIL,KAAK,gEACJ,SACE,KAAK;UAGI,sBAAA,SAA+B;WACrC;;UAGM,0BAAA,SAAmC;UAC1C;;KAGE,4CACc,6BACtB,8BACA,cAAc"}
1
+ {"version":3,"file":"plugin.d.cts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;UA0BiB,mBAAA,SAA4B,QAAQ;;AAArD;;EAIY,OAAA,CAAA,EAAA,qBAAA;EAYC;;;AAGb;AAIA;EAIY,OAAA,CAAA,EAAA,OAAA;EACc;;;EAEtB,QAAA,CAAA,EAdS,aAcT;;AACW,UAZE,sBAAA,SAA+B,UAYjC,CAAA;WAXJ;;UAGM,0BAAA,SAAmC;UAC1C;;KAGE,4CACc,6BACtB,8BACA,cAAc;UACR"}
@@ -1,8 +1,12 @@
1
- import { LocalWorkspaceOptions, PulumiFn, Stack, StackSettings } from "@pulumi/pulumi/automation";
1
+ import { InlineProgramArgs, LocalWorkspaceOptions, Stack, StackSettings } from "@pulumi/pulumi/automation";
2
2
  import { PluginContext, ResolvedConfig, UserConfig } from "powerlines";
3
3
 
4
4
  //#region src/types/plugin.d.ts
5
- interface PulumiPluginBaseOptions {
5
+ interface PulumiPluginOptions extends Partial<InlineProgramArgs> {
6
+ /**
7
+ * Additional options for the Pulumi Workspace.
8
+ */
9
+ options?: LocalWorkspaceOptions;
6
10
  /**
7
11
  * Whether to destroy the stack during the `destroy` lifecycle phase.
8
12
  *
@@ -14,65 +18,19 @@ interface PulumiPluginBaseOptions {
14
18
  */
15
19
  settings?: StackSettings;
16
20
  }
17
- interface PulumiPluginExistingStackOptions extends PulumiPluginBaseOptions {
18
- /**
19
- * The Pulumi Stack instance to use for deployment operations.
20
- */
21
- stack?: Stack;
22
- }
23
- interface PulumiPluginCreateStackOptions extends PulumiPluginBaseOptions {
24
- /**
25
- * The associated stack name.
26
- */
27
- stackName?: string;
28
- /**
29
- * Additional options for the Pulumi Workspace.
30
- */
31
- options?: LocalWorkspaceOptions;
32
- }
33
- interface PulumiPluginExistingStackOptions {
34
- /**
35
- * The Pulumi Stack instance to use for deployment operations.
36
- */
37
- stack?: Stack;
38
- }
39
- interface PulumiPluginCreateStackInlineOptions extends PulumiPluginCreateStackOptions {
40
- /**
41
- * The associated project name.
42
- */
43
- projectName?: string;
44
- /**
45
- * The inline (in-process) Pulumi program to use with update and preview operations.
46
- */
47
- program?: PulumiFn;
48
- }
49
- interface PulumiPluginCreateStackLocalOptions extends PulumiPluginCreateStackOptions {
50
- /**
51
- * The working directory of the program.
52
- *
53
- * @defaultValue "\{artifactsPath\}/infrastructure"
54
- */
55
- workDir?: string;
56
- }
57
- type PulumiPluginOptions = PulumiPluginExistingStackOptions | PulumiPluginCreateStackInlineOptions | PulumiPluginCreateStackLocalOptions;
58
- type PulumiPluginResolvedOptions = (Omit<PulumiPluginExistingStackOptions, "stack"> & Required<Pick<PulumiPluginExistingStackOptions, "stack">>) | (Omit<PulumiPluginCreateStackInlineOptions, "stackName" | "projectName" | "program"> & Required<Pick<PulumiPluginCreateStackInlineOptions, "stackName" | "projectName" | "program">>) | (Omit<PulumiPluginCreateStackLocalOptions, "stackName" | "workDir"> & Required<Pick<PulumiPluginCreateStackLocalOptions, "stackName" | "workDir">>);
59
21
  interface PulumiPluginUserConfig extends UserConfig {
60
22
  pulumi?: PulumiPluginOptions;
61
23
  }
62
24
  interface PulumiPluginResolvedConfig extends ResolvedConfig {
63
25
  pulumi: PulumiPluginOptions;
64
26
  }
65
- type PulumiPluginContext<TResolvedConfig extends PulumiPluginResolvedConfig = PulumiPluginResolvedConfig> = PluginContext<TResolvedConfig>;
66
- declare type __ΩPulumiPluginBaseOptions = any[];
67
- declare type __ΩPulumiPluginExistingStackOptions = any[];
68
- declare type __ΩPulumiPluginCreateStackOptions = any[];
69
- declare type __ΩPulumiPluginCreateStackInlineOptions = any[];
70
- declare type __ΩPulumiPluginCreateStackLocalOptions = any[];
27
+ type PulumiPluginContext<TResolvedConfig extends PulumiPluginResolvedConfig = PulumiPluginResolvedConfig> = PluginContext<TResolvedConfig> & {
28
+ pulumi: Stack;
29
+ };
71
30
  declare type __ΩPulumiPluginOptions = any[];
72
- declare type __ΩPulumiPluginResolvedOptions = any[];
73
31
  declare type __ΩPulumiPluginUserConfig = any[];
74
32
  declare type __ΩPulumiPluginResolvedConfig = any[];
75
33
  declare type __ΩPulumiPluginContext = any[];
76
34
  //#endregion
77
- export { PulumiPluginBaseOptions, PulumiPluginContext, PulumiPluginCreateStackInlineOptions, PulumiPluginCreateStackLocalOptions, PulumiPluginCreateStackOptions, PulumiPluginExistingStackOptions, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginResolvedOptions, PulumiPluginUserConfig, __ΩPulumiPluginBaseOptions, __ΩPulumiPluginContext, __ΩPulumiPluginCreateStackInlineOptions, __ΩPulumiPluginCreateStackLocalOptions, __ΩPulumiPluginCreateStackOptions, __ΩPulumiPluginExistingStackOptions, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginResolvedOptions, __ΩPulumiPluginUserConfig };
35
+ export { PulumiPluginContext, PulumiPluginOptions, PulumiPluginResolvedConfig, PulumiPluginUserConfig, __ΩPulumiPluginContext, __ΩPulumiPluginOptions, __ΩPulumiPluginResolvedConfig, __ΩPulumiPluginUserConfig };
78
36
  //# sourceMappingURL=plugin.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;UA0BiB,uBAAA;;AAAjB;AAcA;AAOA;AAYA;EAOiB,OAAA,CAAA,EAAA,OAAA;EAYA;AASjB;;EAEI,QAAA,CAAA,EApDS,aAoDT;;AACmC,UAlDtB,gCAAA,SAAyC,uBAkDnB,CAAA;EAE3B;;;EAEQ,KAAA,CAAA,EAlDV,KAkDU;;AAAd,UA/CW,8BAAA,SAAuC,uBA+ClD,CAAA;EAEA;;;EAIE,SAAA,CAAA,EAAA,MAAA;EADF;;;EAQO,OAAA,CAAA,EAnDD,qBAmDC;;AADP,UA/CW,gCAAA,CA+CX;EAAQ;AAId;AAIA;EAIY,KAAA,CAAA,EAvDF,KAuDE;;AAER,UAtDa,oCAAA,SAA6C,8BAsD1D,CAAA;EACc;;;;;;;YA9CN;;UAGK,mCAAA,SAA4C;;;;;;;;KASjD,mBAAA,GACR,mCACA,uCACA;KAEQ,2BAAA,IACP,KAAK,6CACJ,SAAS,KAAK,gDACf,KACC,iFAGA,SACE,KACE,oFAIL,KAAK,gEACJ,SACE,KAAK;UAGI,sBAAA,SAA+B;WACrC;;UAGM,0BAAA,SAAmC;UAC1C;;KAGE,4CACc,6BACtB,8BACA,cAAc"}
1
+ {"version":3,"file":"plugin.d.mts","names":[],"sources":["../../src/types/plugin.ts"],"sourcesContent":[],"mappings":";;;;UA0BiB,mBAAA,SAA4B,QAAQ;;AAArD;;EAIY,OAAA,CAAA,EAAA,qBAAA;EAYC;;;AAGb;AAIA;EAIY,OAAA,CAAA,EAAA,OAAA;EACc;;;EAEtB,QAAA,CAAA,EAdS,aAcT;;AACW,UAZE,sBAAA,SAA+B,UAYjC,CAAA;WAXJ;;UAGM,0BAAA,SAAmC;UAC1C;;KAGE,4CACc,6BACtB,8BACA,cAAc;UACR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerlines/plugin-pulumi",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "type": "module",
5
5
  "description": "A Powerlines plugin to transform source code to be platform agnostic using pulumi.",
6
6
  "repository": {
@@ -70,6 +70,20 @@
70
70
  "default": "./dist/types/index.mjs"
71
71
  }
72
72
  },
73
+ "./types/_internal": {
74
+ "require": {
75
+ "types": "./dist/types/_internal.d.cts",
76
+ "default": "./dist/types/_internal.cjs"
77
+ },
78
+ "import": {
79
+ "types": "./dist/types/_internal.d.mts",
80
+ "default": "./dist/types/_internal.mjs"
81
+ },
82
+ "default": {
83
+ "types": "./dist/types/_internal.d.mts",
84
+ "default": "./dist/types/_internal.mjs"
85
+ }
86
+ },
73
87
  "./types/plugin": {
74
88
  "require": {
75
89
  "types": "./dist/types/plugin.d.cts",
@@ -89,7 +103,6 @@
89
103
  "files": ["dist/**/*"],
90
104
  "keywords": ["pulumi", "powerlines", "storm-software", "powerlines-plugin"],
91
105
  "dependencies": {
92
- "@powerlines/plugin-alloy": "^0.25.1",
93
106
  "@pulumi/pulumi": "^3.225.1",
94
107
  "@stryke/fs": "^0.33.53",
95
108
  "@stryke/helpers": "^0.9.51",
@@ -98,14 +111,14 @@
98
111
  "@stryke/type-checks": "^0.5.34",
99
112
  "@stryke/types": "^0.10.48",
100
113
  "defu": "^6.1.4",
101
- "powerlines": "^0.40.4",
114
+ "powerlines": "^0.40.5",
102
115
  "typescript": "^5.9.3"
103
116
  },
104
117
  "devDependencies": {
105
- "@powerlines/plugin-plugin": "^0.12.268",
118
+ "@powerlines/plugin-plugin": "^0.12.269",
106
119
  "@types/node": "^25.3.5"
107
120
  },
108
121
  "publishConfig": { "access": "public" },
109
122
  "types": "./dist/index.d.cts",
110
- "gitHead": "81fe04ecdb367e905a2d89b30beebd28cfd8a470"
123
+ "gitHead": "842d89a4d59dd40606518bc727bfc31e3219b941"
111
124
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.mjs","names":["render","YamlFile","fullyQualifiedStackName","LocalWorkspace","getPackageManager","omit","joinPaths","kebabCase","defu","getOrganizationName","getWorkspaceName","plugin","options","name","config","deploy","pulumi","projectName","settings","configResolved","stack","stackName","mode","prepare","_self$","_$createComponent","path","infrastructurePath","data","runtime","packagemanager","workspaceConfig","workspaceRoot","order","handler","info","program","workDir","Error","createOrSelectStack","Object","keys","length","workspace","saveStackSettings","refresh","onOutput","debug","bind","destroy","result","up","summary","version","message"],"sources":["../src/index.tsx"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Powerlines\n\n This code was released as part of the Powerlines project. Powerlines\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/powerlines.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/powerlines\n Documentation: https://docs.stormsoftware.com/projects/powerlines\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { render } from \"@powerlines/plugin-alloy/render\";\nimport { YamlFile } from \"@powerlines/plugin-alloy/yaml/components/yaml-file\";\nimport {\n fullyQualifiedStackName,\n LocalWorkspace\n} from \"@pulumi/pulumi/automation\";\nimport { getPackageManager } from \"@stryke/fs/package-fns\";\nimport { omit } from \"@stryke/helpers\";\nimport { joinPaths } from \"@stryke/path/join\";\nimport { kebabCase } from \"@stryke/string-format/kebab-case\";\nimport defu from \"defu\";\nimport { Plugin } from \"powerlines\";\nimport { getOrganizationName, getWorkspaceName } from \"powerlines/plugin-utils\";\nimport {\n PulumiPluginContext,\n PulumiPluginCreateStackInlineOptions,\n PulumiPluginCreateStackLocalOptions,\n PulumiPluginCreateStackOptions,\n PulumiPluginExistingStackOptions,\n PulumiPluginOptions\n} from \"./types/plugin\";\n\nexport * from \"./types\";\n\ndeclare module \"@powerlines/core\" {\n interface BaseConfig {\n pulumi?: PulumiPluginOptions;\n }\n}\n\n/**\n * A package containing a Powerlines plugin to configure infrastructure and deploy a project using Pulumi IaC.\n *\n * @see https://www.pulumi.com\n *\n * @param options - The Pulumi plugin user configuration options.\n * @returns A Powerlines plugin to configure infrastructure and deploy a project using Pulumi.\n */\nexport const plugin = <\n TContext extends PulumiPluginContext = PulumiPluginContext\n>(\n options: PulumiPluginOptions = {}\n): Plugin<TContext> => {\n return {\n name: \"pulumi\",\n async config() {\n return {\n deploy: {\n pulumi: defu(options, {\n projectName: this.config.name,\n settings: {}\n })\n }\n };\n },\n async configResolved() {\n if (!(options as PulumiPluginExistingStackOptions).stack) {\n (this.config.pulumi as PulumiPluginCreateStackOptions).stackName ??=\n fullyQualifiedStackName(\n kebabCase(getOrganizationName(this) || \"default\"),\n `${\n getWorkspaceName(this)\n ? `${kebabCase(getWorkspaceName(this))}-`\n : \"\"\n }${kebabCase(this.config.name)}`,\n this.config.mode\n );\n }\n },\n async prepare() {\n await render(\n this,\n <YamlFile\n path={joinPaths(this.infrastructurePath, \"Pulumi.yaml\")}\n data={{\n runtime: {\n name: \"nodejs\",\n options: {\n packagemanager: getPackageManager(\n this.workspaceConfig.workspaceRoot\n )\n }\n }\n }}\n />\n );\n },\n deploy: {\n order: \"post\",\n async handler() {\n this.info(\n `Deploying Pulumi stack: ${\n (this.config.pulumi as PulumiPluginExistingStackOptions).stack\n ?.name ||\n (this.config.pulumi as PulumiPluginCreateStackOptions).stackName\n }`\n );\n\n if (\n (!(options as PulumiPluginExistingStackOptions).stack &&\n !(options as PulumiPluginCreateStackInlineOptions).program &&\n !(options as PulumiPluginCreateStackInlineOptions).projectName) ||\n !(options as PulumiPluginCreateStackLocalOptions).workDir\n ) {\n throw new Error(\n `Pulumi plugin requires either an inline program or a working directory to be specified.`\n );\n }\n\n let stack = (options as PulumiPluginExistingStackOptions).stack;\n stack ??= await LocalWorkspace.createOrSelectStack({\n workDir: joinPaths(this.infrastructurePath),\n ...(omit(this.config.pulumi as PulumiPluginCreateStackOptions, [\n \"options\",\n \"settings\"\n ]) as Parameters<typeof LocalWorkspace.createOrSelectStack>[0])\n });\n\n if (\n this.config.pulumi.settings &&\n Object.keys(this.config.pulumi.settings).length > 0\n ) {\n await stack.workspace.saveStackSettings(\n stack.name,\n this.config.pulumi.settings\n );\n }\n\n await stack.refresh({ onOutput: this.debug.bind(this) });\n\n if (this.config.pulumi.destroy) {\n await stack.destroy({ onOutput: this.debug.bind(this) });\n }\n\n const result = await stack.up({\n onOutput: this.debug.bind(this)\n });\n\n this.info(\n `Successfully deployed ${stack.name} (v${result.summary.version}): ${result.summary.message}`\n );\n }\n }\n } as Plugin<TContext>;\n};\n\nexport default plugin;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAwDA,MAAaW,UAGXC,UAA+B,EAAE,KACZ;AACrB,QAAO;EACLC,MAAM;EACN,MAAMC,SAAS;AACb,UAAO,EACLC,QAAQ,EACNC,QAAQR,KAAKI,SAAS;IACpBK,aAAa,KAAKH,OAAOD;IACzBK,UAAU,EAAC;IACZ,CAAA,EACH,EACD;;EAEH,MAAMC,iBAAiB;AACrB,OAAI,CAAEP,QAA6CQ,MAChD,MAAKN,OAAOE,OAA0CK,cACrDnB,wBACEK,UAAUE,oBAAoB,KAAK,IAAI,UAAU,EACjD,GACEC,iBAAiB,KAAK,GAClB,GAAGH,UAAUG,iBAAiB,KAAK,CAAC,CAAA,KACpC,KACHH,UAAU,KAAKO,OAAOD,KAAK,IAC9B,KAAKC,OAAOQ,KACb;;EAGP,MAAMC,UAAU;GAAA,MAAAC,SAAA;AACd,SAAMxB,OACJ,MAAIyB,gBACHxB,UAAQ;IAAA,IACPyB,OAAI;AAAA,YAAEpB,UAAUkB,OAAKG,oBAAoB,cAAc;;IAAA,IACvDC,OAAI;AAAA,YAAE,EACJC,SAAS;MACPhB,MAAM;MACND,SAAS,EACPkB,gBAAgB1B,kBACdoB,OAAKO,gBAAgBC,cACvB,EACF;MACF,EACD;;IAAA,CAEL,CAAC;;EAEHjB,QAAQ;GACNkB,OAAO;GACP,MAAMC,UAAU;AACd,SAAKC,KACH,2BACG,KAAKrB,OAAOE,OAA4CI,OACrDP,QACH,KAAKC,OAAOE,OAA0CK,YAE1D;AAED,QACG,CAAET,QAA6CQ,SAC9C,CAAER,QAAiDwB,WACnD,CAAExB,QAAiDK,eACrD,CAAEL,QAAgDyB,QAElD,OAAM,IAAIC,MACR,0FACD;IAGH,IAAIlB,QAASR,QAA6CQ;AAC1DA,cAAU,MAAMjB,eAAeoC,oBAAoB;KACjDF,SAAS/B,UAAU,KAAKqB,mBAAmB;KAC3C,GAAItB,KAAK,KAAKS,OAAOE,QAA0C,CAC7D,WACA,WACD,CAAA;KACF,CAAC;AAEF,QACE,KAAKF,OAAOE,OAAOE,YACnBsB,OAAOC,KAAK,KAAK3B,OAAOE,OAAOE,SAAS,CAACwB,SAAS,EAElD,OAAMtB,MAAMuB,UAAUC,kBACpBxB,MAAMP,MACN,KAAKC,OAAOE,OAAOE,SACpB;AAGH,UAAME,MAAMyB,QAAQ,EAAEC,UAAU,KAAKC,MAAMC,KAAK,KAAI,EAAG,CAAC;AAExD,QAAI,KAAKlC,OAAOE,OAAOiC,QACrB,OAAM7B,MAAM6B,QAAQ,EAAEH,UAAU,KAAKC,MAAMC,KAAK,KAAI,EAAG,CAAC;IAG1D,MAAME,SAAS,MAAM9B,MAAM+B,GAAG,EAC5BL,UAAU,KAAKC,MAAMC,KAAK,KAAI,EAC/B,CAAC;AAEF,SAAKb,KACH,yBAAyBf,MAAMP,KAAI,KAAMqC,OAAOE,QAAQC,QAAO,KAAMH,OAAOE,QAAQE,UACrF;;GAEL;EACD;;AAGH,kBAAe3C"}