@powerlines/plugin-env 0.15.104 → 0.15.106
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/babel/plugin.cjs +36 -78
- package/dist/babel/plugin.mjs +36 -77
- package/dist/index.cjs +13 -0
- package/dist/index.mjs +13 -0
- package/package.json +9 -9
package/dist/babel/plugin.cjs
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
const require_rolldown_runtime = require('../_virtual/rolldown_runtime.cjs');
|
|
2
2
|
const require_types_plugin = require('../types/plugin.cjs');
|
|
3
|
-
const require_helpers_persistence = require('../helpers/persistence.cjs');
|
|
4
|
-
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
5
|
-
let __powerlines_deepkit_capnp = require("@powerlines/deepkit/capnp");
|
|
6
|
-
let __powerlines_deepkit_schemas_reflection = require("@powerlines/deepkit/schemas/reflection");
|
|
7
|
-
let __stryke_capnp = require("@stryke/capnp");
|
|
8
|
-
__stryke_capnp = require_rolldown_runtime.__toESM(__stryke_capnp);
|
|
9
|
-
let __stryke_fs_buffer = require("@stryke/fs/buffer");
|
|
10
|
-
let node_fs = require("node:fs");
|
|
11
3
|
let powerlines_types_babel = require("powerlines/types/babel");
|
|
12
4
|
let __babel_core = require("@babel/core");
|
|
13
5
|
let __powerlines_deepkit_utilities = require("@powerlines/deepkit/utilities");
|
|
@@ -51,7 +43,10 @@ const envBabelPlugin = (__powerlines_plugin_babel_helpers_create_plugin.createBa
|
|
|
51
43
|
"P\"2!\"/\""
|
|
52
44
|
]));
|
|
53
45
|
if (!envProperty || envProperty.isIgnored()) return;
|
|
54
|
-
if (!context.env.used.env.hasProperty(name))
|
|
46
|
+
if (!context.env.used.env.hasProperty(name)) {
|
|
47
|
+
log(__storm_software_config_tools_types.LogLevelLabel.DEBUG, `Adding "${name}" environment variables found in "${pass.filename || "unknown file"}" to used environment configuration reflection object.`);
|
|
48
|
+
context.env.used.env.addProperty(envProperty.property);
|
|
49
|
+
}
|
|
55
50
|
if (context.config.env.inject && isInjectable) {
|
|
56
51
|
let value = context.env.parsed?.[name];
|
|
57
52
|
if (value === void 0) {
|
|
@@ -102,77 +97,40 @@ const envBabelPlugin = (__powerlines_plugin_babel_helpers_create_plugin.createBa
|
|
|
102
97
|
"extractEnv",
|
|
103
98
|
"P!2!n\"2#\"2$\"/%"
|
|
104
99
|
];
|
|
105
|
-
return {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
imported: "env"
|
|
116
|
-
});
|
|
117
|
-
} else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isMetaProperty() && path.get("property")?.isIdentifier()) {
|
|
118
|
-
const identifier = path.get("property")?.node;
|
|
119
|
-
if (!identifier.name) return;
|
|
120
|
-
extractEnv(identifier, pass, false);
|
|
121
|
-
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
122
|
-
(0, __powerlines_plugin_babel_helpers_module_helpers.addImport)(path, {
|
|
123
|
-
module: `${context.config.framework || "powerlines"}:env`,
|
|
124
|
-
name: "env",
|
|
125
|
-
imported: "env"
|
|
126
|
-
});
|
|
127
|
-
} else if (path.get("object")?.isIdentifier({ name: "env" }) && path.get("property")?.isIdentifier()) {
|
|
128
|
-
const identifier = path.get("property")?.node;
|
|
129
|
-
if (!identifier.name) return;
|
|
130
|
-
extractEnv(identifier, pass, false);
|
|
131
|
-
}
|
|
132
|
-
}, [
|
|
133
|
-
() => __babel_core.NodePath,
|
|
134
|
-
"path",
|
|
135
|
-
() => powerlines_types_babel.__ΩBabelPluginPass,
|
|
136
|
-
"pass",
|
|
137
|
-
"MemberExpression",
|
|
138
|
-
"PP!7!2\"n#2$\"/%"
|
|
139
|
-
]) },
|
|
140
|
-
post() {
|
|
141
|
-
log(__storm_software_config_tools_types.LogLevelLabel.TRACE, `Adding environment variables from ${this.filename || "unknown file"} to env.json.`);
|
|
142
|
-
let persistedEnv = __powerlines_deepkit_vendor_type.ReflectionClass.from({
|
|
143
|
-
kind: __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
|
|
144
|
-
description: `An object containing the environment variables used by the application.`,
|
|
145
|
-
types: []
|
|
100
|
+
return { visitor: { MemberExpression: __assignType(function MemberExpression(path, pass) {
|
|
101
|
+
if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "process" }) && path.get("property")?.isIdentifier()) {
|
|
102
|
+
const identifier = path.get("property")?.node;
|
|
103
|
+
if (!identifier.name) return;
|
|
104
|
+
extractEnv(identifier, pass, false);
|
|
105
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
106
|
+
(0, __powerlines_plugin_babel_helpers_module_helpers.addImport)(path, {
|
|
107
|
+
module: `${context.config.framework || "powerlines"}:env`,
|
|
108
|
+
name: "env",
|
|
109
|
+
imported: "env"
|
|
146
110
|
});
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
"
|
|
155
|
-
""
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
description: property.getDescription() ?? `The ${property.getNameAsString()} variable.`,
|
|
162
|
-
default: property.getDefaultValue(),
|
|
163
|
-
optional: property.isOptional() ? true : void 0,
|
|
164
|
-
readonly: property.isReadonly() ? true : void 0,
|
|
165
|
-
visibility: property.getVisibility(),
|
|
166
|
-
type: property.getType(),
|
|
167
|
-
tags: property.getTags()
|
|
168
|
-
});
|
|
169
|
-
}, [
|
|
170
|
-
"property",
|
|
171
|
-
"",
|
|
172
|
-
"P\"2!\"/\""
|
|
173
|
-
]));
|
|
111
|
+
} else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isMetaProperty() && path.get("property")?.isIdentifier()) {
|
|
112
|
+
const identifier = path.get("property")?.node;
|
|
113
|
+
if (!identifier.name) return;
|
|
114
|
+
extractEnv(identifier, pass, false);
|
|
115
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
116
|
+
(0, __powerlines_plugin_babel_helpers_module_helpers.addImport)(path, {
|
|
117
|
+
module: `${context.config.framework || "powerlines"}:env`,
|
|
118
|
+
name: "env",
|
|
119
|
+
imported: "env"
|
|
120
|
+
});
|
|
121
|
+
} else if (path.get("object")?.isIdentifier({ name: "env" }) && path.get("property")?.isIdentifier()) {
|
|
122
|
+
const identifier = path.get("property")?.node;
|
|
123
|
+
if (!identifier.name) return;
|
|
124
|
+
extractEnv(identifier, pass, false);
|
|
174
125
|
}
|
|
175
|
-
}
|
|
126
|
+
}, [
|
|
127
|
+
() => __babel_core.NodePath,
|
|
128
|
+
"path",
|
|
129
|
+
() => powerlines_types_babel.__ΩBabelPluginPass,
|
|
130
|
+
"pass",
|
|
131
|
+
"MemberExpression",
|
|
132
|
+
"PP!7!2\"n#2$\"/%"
|
|
133
|
+
]) } };
|
|
176
134
|
}, [
|
|
177
135
|
"param0",
|
|
178
136
|
"",
|
package/dist/babel/plugin.mjs
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
1
|
import { __ΩEnvPluginContext } from "../types/plugin.mjs";
|
|
2
|
-
import { getEnvReflectionsPath } from "../helpers/persistence.mjs";
|
|
3
|
-
import { ReflectionClass, ReflectionKind, deserializeType, resolveClassType } from "@powerlines/deepkit/vendor/type";
|
|
4
|
-
import { convertFromCapnp } from "@powerlines/deepkit/capnp";
|
|
5
|
-
import { SerializedTypes } from "@powerlines/deepkit/schemas/reflection";
|
|
6
|
-
import * as capnp from "@stryke/capnp";
|
|
7
|
-
import { readFileBufferSync } from "@stryke/fs/buffer";
|
|
8
|
-
import { existsSync } from "node:fs";
|
|
9
2
|
import { __ΩBabelPluginPass } from "powerlines/types/babel";
|
|
10
3
|
import { NodePath } from "@babel/core";
|
|
11
4
|
import { stringifyDefaultValue } from "@powerlines/deepkit/utilities";
|
|
@@ -49,7 +42,10 @@ const envBabelPlugin = (createBabelPlugin.Ω = [[() => __ΩEnvPluginContext, "n!
|
|
|
49
42
|
"P\"2!\"/\""
|
|
50
43
|
]));
|
|
51
44
|
if (!envProperty || envProperty.isIgnored()) return;
|
|
52
|
-
if (!context.env.used.env.hasProperty(name))
|
|
45
|
+
if (!context.env.used.env.hasProperty(name)) {
|
|
46
|
+
log(LogLevelLabel.DEBUG, `Adding "${name}" environment variables found in "${pass.filename || "unknown file"}" to used environment configuration reflection object.`);
|
|
47
|
+
context.env.used.env.addProperty(envProperty.property);
|
|
48
|
+
}
|
|
53
49
|
if (context.config.env.inject && isInjectable) {
|
|
54
50
|
let value = context.env.parsed?.[name];
|
|
55
51
|
if (value === void 0) {
|
|
@@ -100,77 +96,40 @@ const envBabelPlugin = (createBabelPlugin.Ω = [[() => __ΩEnvPluginContext, "n!
|
|
|
100
96
|
"extractEnv",
|
|
101
97
|
"P!2!n\"2#\"2$\"/%"
|
|
102
98
|
];
|
|
103
|
-
return {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
imported: "env"
|
|
114
|
-
});
|
|
115
|
-
} else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isMetaProperty() && path.get("property")?.isIdentifier()) {
|
|
116
|
-
const identifier = path.get("property")?.node;
|
|
117
|
-
if (!identifier.name) return;
|
|
118
|
-
extractEnv(identifier, pass, false);
|
|
119
|
-
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
120
|
-
addImport(path, {
|
|
121
|
-
module: `${context.config.framework || "powerlines"}:env`,
|
|
122
|
-
name: "env",
|
|
123
|
-
imported: "env"
|
|
124
|
-
});
|
|
125
|
-
} else if (path.get("object")?.isIdentifier({ name: "env" }) && path.get("property")?.isIdentifier()) {
|
|
126
|
-
const identifier = path.get("property")?.node;
|
|
127
|
-
if (!identifier.name) return;
|
|
128
|
-
extractEnv(identifier, pass, false);
|
|
129
|
-
}
|
|
130
|
-
}, [
|
|
131
|
-
() => NodePath,
|
|
132
|
-
"path",
|
|
133
|
-
() => __ΩBabelPluginPass,
|
|
134
|
-
"pass",
|
|
135
|
-
"MemberExpression",
|
|
136
|
-
"PP!7!2\"n#2$\"/%"
|
|
137
|
-
]) },
|
|
138
|
-
post() {
|
|
139
|
-
log(LogLevelLabel.TRACE, `Adding environment variables from ${this.filename || "unknown file"} to env.json.`);
|
|
140
|
-
let persistedEnv = ReflectionClass.from({
|
|
141
|
-
kind: ReflectionKind.objectLiteral,
|
|
142
|
-
description: `An object containing the environment variables used by the application.`,
|
|
143
|
-
types: []
|
|
99
|
+
return { visitor: { MemberExpression: __assignType(function MemberExpression(path, pass) {
|
|
100
|
+
if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isIdentifier({ name: "process" }) && path.get("property")?.isIdentifier()) {
|
|
101
|
+
const identifier = path.get("property")?.node;
|
|
102
|
+
if (!identifier.name) return;
|
|
103
|
+
extractEnv(identifier, pass, false);
|
|
104
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
105
|
+
addImport(path, {
|
|
106
|
+
module: `${context.config.framework || "powerlines"}:env`,
|
|
107
|
+
name: "env",
|
|
108
|
+
imported: "env"
|
|
144
109
|
});
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
"
|
|
153
|
-
""
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
description: property.getDescription() ?? `The ${property.getNameAsString()} variable.`,
|
|
160
|
-
default: property.getDefaultValue(),
|
|
161
|
-
optional: property.isOptional() ? true : void 0,
|
|
162
|
-
readonly: property.isReadonly() ? true : void 0,
|
|
163
|
-
visibility: property.getVisibility(),
|
|
164
|
-
type: property.getType(),
|
|
165
|
-
tags: property.getTags()
|
|
166
|
-
});
|
|
167
|
-
}, [
|
|
168
|
-
"property",
|
|
169
|
-
"",
|
|
170
|
-
"P\"2!\"/\""
|
|
171
|
-
]));
|
|
110
|
+
} else if (path.get("object")?.get("property")?.isIdentifier({ name: "env" }) && path.get("object")?.get("object")?.isMetaProperty() && path.get("property")?.isIdentifier()) {
|
|
111
|
+
const identifier = path.get("property")?.node;
|
|
112
|
+
if (!identifier.name) return;
|
|
113
|
+
extractEnv(identifier, pass, false);
|
|
114
|
+
path.replaceWithSourceString(`env.${identifier.name}`);
|
|
115
|
+
addImport(path, {
|
|
116
|
+
module: `${context.config.framework || "powerlines"}:env`,
|
|
117
|
+
name: "env",
|
|
118
|
+
imported: "env"
|
|
119
|
+
});
|
|
120
|
+
} else if (path.get("object")?.isIdentifier({ name: "env" }) && path.get("property")?.isIdentifier()) {
|
|
121
|
+
const identifier = path.get("property")?.node;
|
|
122
|
+
if (!identifier.name) return;
|
|
123
|
+
extractEnv(identifier, pass, false);
|
|
172
124
|
}
|
|
173
|
-
}
|
|
125
|
+
}, [
|
|
126
|
+
() => NodePath,
|
|
127
|
+
"path",
|
|
128
|
+
() => __ΩBabelPluginPass,
|
|
129
|
+
"pass",
|
|
130
|
+
"MemberExpression",
|
|
131
|
+
"PP!7!2\"n#2$\"/%"
|
|
132
|
+
]) } };
|
|
174
133
|
}, [
|
|
175
134
|
"param0",
|
|
176
135
|
"",
|
package/dist/index.cjs
CHANGED
|
@@ -141,6 +141,19 @@ const plugin = (options = {}) => {
|
|
|
141
141
|
return _self$.config.env.defaultConfig;
|
|
142
142
|
} }));
|
|
143
143
|
},
|
|
144
|
+
transform: {
|
|
145
|
+
order: "post",
|
|
146
|
+
async handler() {
|
|
147
|
+
if (this.env.used.env.getProperties().length > 0) {
|
|
148
|
+
this.debug(`Persisting used environment configuration reflections to ${require_helpers_persistence.getEnvReflectionsPath(this, "env")}.`);
|
|
149
|
+
await require_helpers_persistence.writeEnvReflection(this, this.env.used.env, "env");
|
|
150
|
+
}
|
|
151
|
+
if (this.env.used.secrets.getProperties().length > 0) {
|
|
152
|
+
this.debug(`Persisting used secret configuration reflections to ${require_helpers_persistence.getEnvReflectionsPath(this, "secrets")}.`);
|
|
153
|
+
await require_helpers_persistence.writeEnvReflection(this, this.env.used.secrets, "secrets");
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
},
|
|
144
157
|
async docs() {
|
|
145
158
|
this.debug("Writing Environment documentation for the Powerlines project artifacts.");
|
|
146
159
|
const outputPath = require_join_paths.joinPaths(this.config.projectRoot, "docs", "generated");
|
package/dist/index.mjs
CHANGED
|
@@ -136,6 +136,19 @@ const plugin = (options = {}) => {
|
|
|
136
136
|
return _self$.config.env.defaultConfig;
|
|
137
137
|
} }));
|
|
138
138
|
},
|
|
139
|
+
transform: {
|
|
140
|
+
order: "post",
|
|
141
|
+
async handler() {
|
|
142
|
+
if (this.env.used.env.getProperties().length > 0) {
|
|
143
|
+
this.debug(`Persisting used environment configuration reflections to ${getEnvReflectionsPath(this, "env")}.`);
|
|
144
|
+
await writeEnvReflection(this, this.env.used.env, "env");
|
|
145
|
+
}
|
|
146
|
+
if (this.env.used.secrets.getProperties().length > 0) {
|
|
147
|
+
this.debug(`Persisting used secret configuration reflections to ${getEnvReflectionsPath(this, "secrets")}.`);
|
|
148
|
+
await writeEnvReflection(this, this.env.used.secrets, "secrets");
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
},
|
|
139
152
|
async docs() {
|
|
140
153
|
this.debug("Writing Environment documentation for the Powerlines project artifacts.");
|
|
141
154
|
const outputPath = joinPaths(this.config.projectRoot, "docs", "generated");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerlines/plugin-env",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.106",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "A package containing a Powerlines plugin for injecting static .env configuration values to the code so that they're accessible at runtime.",
|
|
6
6
|
"repository": {
|
|
@@ -193,10 +193,10 @@
|
|
|
193
193
|
"@alloy-js/typescript": "^0.22.0",
|
|
194
194
|
"@babel/core": "^7.28.6",
|
|
195
195
|
"@babel/types": "^7.28.6",
|
|
196
|
-
"@powerlines/plugin-alloy": "^0.18.
|
|
197
|
-
"@powerlines/plugin-automd": "^0.1.
|
|
198
|
-
"@powerlines/plugin-babel": "^0.12.
|
|
199
|
-
"@powerlines/plugin-plugin": "^0.12.
|
|
196
|
+
"@powerlines/plugin-alloy": "^0.18.99",
|
|
197
|
+
"@powerlines/plugin-automd": "^0.1.209",
|
|
198
|
+
"@powerlines/plugin-babel": "^0.12.218",
|
|
199
|
+
"@powerlines/plugin-plugin": "^0.12.160",
|
|
200
200
|
"@storm-software/config-tools": "^1.189.0",
|
|
201
201
|
"@stryke/capnp": "^0.12.61",
|
|
202
202
|
"@stryke/env": "^0.20.53",
|
|
@@ -206,14 +206,14 @@
|
|
|
206
206
|
"@stryke/type-checks": "^0.5.20",
|
|
207
207
|
"@stryke/types": "^0.10.34",
|
|
208
208
|
"automd": "^0.4.2",
|
|
209
|
-
"powerlines": "^0.37.
|
|
209
|
+
"powerlines": "^0.37.82"
|
|
210
210
|
},
|
|
211
211
|
"devDependencies": {
|
|
212
|
-
"@powerlines/deepkit": "^0.5.
|
|
213
|
-
"@powerlines/plugin-deepkit": "^0.11.
|
|
212
|
+
"@powerlines/deepkit": "^0.5.126",
|
|
213
|
+
"@powerlines/plugin-deepkit": "^0.11.88",
|
|
214
214
|
"@types/node": "^24.10.9",
|
|
215
215
|
"vite": "8.0.0-beta.2"
|
|
216
216
|
},
|
|
217
217
|
"publishConfig": { "access": "public" },
|
|
218
|
-
"gitHead": "
|
|
218
|
+
"gitHead": "e4d0cfc5040f75e4a14247997ffa396f58768c49"
|
|
219
219
|
}
|