@powerlines/plugin-date 0.12.151 → 0.12.152
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/components/date-fns.cjs +3 -2
- package/dist/components/date-fns.mjs +1 -1
- package/dist/components/dayjs.cjs +3 -2
- package/dist/components/dayjs.mjs +1 -1
- package/dist/components/luxon.cjs +3 -2
- package/dist/components/luxon.mjs +1 -1
- package/dist/components/moment.cjs +3 -2
- package/dist/components/moment.mjs +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +3 -3
- package/dist/node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.cjs +43 -0
- package/dist/node_modules/.pnpm/defu@6.1.4/node_modules/defu/dist/defu.mjs +42 -0
- package/dist/packages/plugin-alloy/src/types/components.d.mts +2 -0
- package/dist/{plugin-env → packages/plugin-env}/src/types/plugin.d.mts +1 -1
- package/dist/{powerlines → packages/powerlines}/src/types/build.d.mts +6 -6
- package/dist/{powerlines → packages/powerlines}/src/types/config.d.mts +1 -2
- package/dist/{powerlines → packages/powerlines}/src/types/tsconfig.d.mts +1 -1
- package/dist/types/plugin.d.mts +1 -1
- package/package.json +5 -5
- package/dist/deepkit/schemas/reflection.cjs +0 -3998
- package/dist/deepkit/schemas/reflection.mjs +0 -3996
- package/dist/deepkit/schemas/reflection2.cjs +0 -4112
- package/dist/deepkit/schemas/reflection2.mjs +0 -4110
- package/dist/deepkit/src/capnp.cjs +0 -913
- package/dist/deepkit/src/capnp.mjs +0 -911
- package/dist/deepkit/src/esbuild-plugin.cjs +0 -47
- package/dist/deepkit/src/esbuild-plugin.mjs +0 -46
- package/dist/deepkit/src/reflect-type.cjs +0 -22
- package/dist/deepkit/src/reflect-type.mjs +0 -20
- package/dist/deepkit/src/resolve-reflections.cjs +0 -16
- package/dist/deepkit/src/resolve-reflections.mjs +0 -15
- package/dist/deepkit/src/transformer.cjs +0 -52
- package/dist/deepkit/src/transformer.mjs +0 -49
- package/dist/deepkit/src/transpile.cjs +0 -29
- package/dist/deepkit/src/transpile.mjs +0 -27
- package/dist/deepkit/src/utilities.cjs +0 -66
- package/dist/deepkit/src/utilities.mjs +0 -65
- package/dist/plugin-alloy/src/core/components/output.cjs +0 -38
- package/dist/plugin-alloy/src/core/components/output.mjs +0 -37
- package/dist/plugin-alloy/src/core/components/single-line-comment.cjs +0 -20
- package/dist/plugin-alloy/src/core/components/single-line-comment.mjs +0 -19
- package/dist/plugin-alloy/src/core/components/source-file.cjs +0 -60
- package/dist/plugin-alloy/src/core/components/source-file.mjs +0 -58
- package/dist/plugin-alloy/src/core/contexts/context.cjs +0 -60
- package/dist/plugin-alloy/src/core/contexts/context.mjs +0 -54
- package/dist/plugin-alloy/src/core/contexts/index.cjs +0 -2
- package/dist/plugin-alloy/src/core/contexts/index.mjs +0 -4
- package/dist/plugin-alloy/src/core/contexts/reflection.cjs +0 -46
- package/dist/plugin-alloy/src/core/contexts/reflection.mjs +0 -42
- package/dist/plugin-alloy/src/helpers/refkey.cjs +0 -16
- package/dist/plugin-alloy/src/helpers/refkey.mjs +0 -15
- package/dist/plugin-alloy/src/index.cjs +0 -103
- package/dist/plugin-alloy/src/index.mjs +0 -101
- package/dist/plugin-alloy/src/markdown/components/markdown-file.cjs +0 -7
- package/dist/plugin-alloy/src/markdown/components/markdown-file.mjs +0 -9
- package/dist/plugin-alloy/src/markdown/components/markdown-table.cjs +0 -5
- package/dist/plugin-alloy/src/markdown/components/markdown-table.mjs +0 -7
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.cjs +0 -17
- package/dist/plugin-alloy/src/markdown/contexts/markdown-table.mjs +0 -17
- package/dist/plugin-alloy/src/types/components.d.mts +0 -3
- package/dist/plugin-alloy/src/typescript/components/builtin-file.cjs +0 -47
- package/dist/plugin-alloy/src/typescript/components/builtin-file.mjs +0 -46
- package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.cjs +0 -75
- package/dist/plugin-alloy/src/typescript/components/tsdoc-reflection.mjs +0 -73
- package/dist/plugin-alloy/src/typescript/components/tsdoc.cjs +0 -359
- package/dist/plugin-alloy/src/typescript/components/tsdoc.mjs +0 -350
- package/dist/plugin-alloy/src/typescript/components/typescript-file.cjs +0 -153
- package/dist/plugin-alloy/src/typescript/components/typescript-file.mjs +0 -150
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.cjs +0 -53
- package/dist/plugin-alloy/src/typescript/components/typescript-interface.mjs +0 -52
- package/dist/plugin-alloy/src/typescript/components/typescript-object.cjs +0 -94
- package/dist/plugin-alloy/src/typescript/components/typescript-object.mjs +0 -93
- package/dist/plugin-automd/src/index.cjs +0 -101
- package/dist/plugin-automd/src/index.mjs +0 -98
- package/dist/plugin-babel/src/helpers/ast-utils.cjs +0 -10
- package/dist/plugin-babel/src/helpers/ast-utils.mjs +0 -9
- package/dist/plugin-babel/src/helpers/create-plugin.cjs +0 -41
- package/dist/plugin-babel/src/helpers/create-plugin.mjs +0 -39
- package/dist/plugin-babel/src/helpers/filters.cjs +0 -23
- package/dist/plugin-babel/src/helpers/filters.mjs +0 -21
- package/dist/plugin-babel/src/helpers/index.cjs +0 -5
- package/dist/plugin-babel/src/helpers/index.mjs +0 -7
- package/dist/plugin-babel/src/helpers/module-helpers.cjs +0 -38
- package/dist/plugin-babel/src/helpers/module-helpers.mjs +0 -35
- package/dist/plugin-babel/src/helpers/options.cjs +0 -50
- package/dist/plugin-babel/src/helpers/options.mjs +0 -47
- package/dist/plugin-babel/src/index.cjs +0 -91
- package/dist/plugin-babel/src/index.mjs +0 -89
- package/dist/plugin-env/src/babel/index.cjs +0 -1
- package/dist/plugin-env/src/babel/index.mjs +0 -3
- package/dist/plugin-env/src/babel/plugin.cjs +0 -121
- package/dist/plugin-env/src/babel/plugin.mjs +0 -119
- package/dist/plugin-env/src/components/docs.cjs +0 -9
- package/dist/plugin-env/src/components/docs.mjs +0 -11
- package/dist/plugin-env/src/components/env.cjs +0 -487
- package/dist/plugin-env/src/components/env.mjs +0 -484
- package/dist/plugin-env/src/components/index.cjs +0 -2
- package/dist/plugin-env/src/components/index.mjs +0 -4
- package/dist/plugin-env/src/helpers/automd-generator.cjs +0 -22
- package/dist/plugin-env/src/helpers/automd-generator.mjs +0 -21
- package/dist/plugin-env/src/helpers/create-reflection-resource.cjs +0 -55
- package/dist/plugin-env/src/helpers/create-reflection-resource.mjs +0 -54
- package/dist/plugin-env/src/helpers/index.cjs +0 -6
- package/dist/plugin-env/src/helpers/index.mjs +0 -8
- package/dist/plugin-env/src/helpers/load.cjs +0 -83
- package/dist/plugin-env/src/helpers/load.mjs +0 -80
- package/dist/plugin-env/src/helpers/persistence.cjs +0 -201
- package/dist/plugin-env/src/helpers/persistence.mjs +0 -190
- package/dist/plugin-env/src/helpers/reflect.cjs +0 -125
- package/dist/plugin-env/src/helpers/reflect.mjs +0 -117
- package/dist/plugin-env/src/helpers/source-file-env.cjs +0 -24
- package/dist/plugin-env/src/helpers/source-file-env.mjs +0 -23
- package/dist/plugin-env/src/helpers/template-helpers.cjs +0 -2
- package/dist/plugin-env/src/helpers/template-helpers.mjs +0 -4
- package/dist/plugin-env/src/index.cjs +0 -172
- package/dist/plugin-env/src/index.mjs +0 -170
- package/dist/powerlines/src/lib/build/esbuild.cjs +0 -102
- package/dist/powerlines/src/lib/build/esbuild.mjs +0 -100
- package/dist/powerlines/src/lib/entry.cjs +0 -12
- package/dist/powerlines/src/lib/entry.mjs +0 -14
- package/dist/powerlines/src/lib/logger.cjs +0 -41
- package/dist/powerlines/src/lib/logger.mjs +0 -39
- package/dist/powerlines/src/lib/utilities/bundle.cjs +0 -35
- package/dist/powerlines/src/lib/utilities/bundle.mjs +0 -34
- package/dist/powerlines/src/lib/utilities/file-header.cjs +0 -22
- package/dist/powerlines/src/lib/utilities/file-header.mjs +0 -21
- package/dist/powerlines/src/lib/utilities/resolve.cjs +0 -30
- package/dist/powerlines/src/lib/utilities/resolve.mjs +0 -29
- package/dist/powerlines/src/plugin-utils/paths.cjs +0 -1
- package/dist/powerlines/src/plugin-utils/paths.mjs +0 -3
- /package/dist/{deepkit → packages/deepkit}/schemas/reflection.d.mts +0 -0
- /package/dist/{deepkit → packages/deepkit}/src/types.d.mts +0 -0
- /package/dist/{plugin-alloy → packages/plugin-alloy}/src/types/index.d.mts +0 -0
- /package/dist/{plugin-alloy → packages/plugin-alloy}/src/types/plugin.d.mts +0 -0
- /package/dist/{plugin-automd → packages/plugin-automd}/src/types/plugin.d.mts +0 -0
- /package/dist/{plugin-automd → packages/plugin-automd}/src/types/toc.d.mts +0 -0
- /package/dist/{plugin-babel → packages/plugin-babel}/src/types/index.d.mts +0 -0
- /package/dist/{plugin-babel → packages/plugin-babel}/src/types/plugin.d.mts +0 -0
- /package/dist/{plugin-env → packages/plugin-env}/src/types/runtime.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/internal/helpers/hooks.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/api.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/babel.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/commands.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/context.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/fs.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/hooks.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/plugin.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/resolved.d.mts +0 -0
- /package/dist/{powerlines → packages/powerlines}/src/types/unplugin.d.mts +0 -0
|
@@ -1,484 +0,0 @@
|
|
|
1
|
-
import { usePowerlines } from "../../../plugin-alloy/src/core/contexts/context.mjs";
|
|
2
|
-
import { refkey as refkey$1 } from "../../../plugin-alloy/src/helpers/refkey.mjs";
|
|
3
|
-
import { TSDoc, TSDocExample, TSDocLink, TSDocParam, TSDocRemarks, TSDocReturns, TSDocThrows } from "../../../plugin-alloy/src/typescript/components/tsdoc.mjs";
|
|
4
|
-
import { BuiltinFile } from "../../../plugin-alloy/src/typescript/components/builtin-file.mjs";
|
|
5
|
-
import { TypeScriptInterface } from "../../../plugin-alloy/src/typescript/components/typescript-interface.mjs";
|
|
6
|
-
import { TypescriptObject } from "../../../plugin-alloy/src/typescript/components/typescript-object.mjs";
|
|
7
|
-
import { loadEnvFromContext } from "../helpers/load.mjs";
|
|
8
|
-
import { createReflectionResource } from "../helpers/create-reflection-resource.mjs";
|
|
9
|
-
import { ReflectionClass, ReflectionKind } from "@powerlines/deepkit/vendor/type";
|
|
10
|
-
import { For, Show, code, computed, splitProps } from "@alloy-js/core";
|
|
11
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
12
|
-
import defu from "defu";
|
|
13
|
-
import { titleCase } from "@stryke/string-format/title-case";
|
|
14
|
-
import { isNull } from "@stryke/type-checks/is-null";
|
|
15
|
-
import { ClassDeclaration, ClassMethod, ElseIfClause, FunctionDeclaration, IfStatement, NewExpression, TypeDeclaration, VarDeclaration } from "@alloy-js/typescript";
|
|
16
|
-
|
|
17
|
-
//#region ../plugin-env/src/components/env.tsx
|
|
18
|
-
/**
|
|
19
|
-
* Generates the environment configuration typescript definition for the Powerlines project.
|
|
20
|
-
*/
|
|
21
|
-
function EnvTypeDefinition(props) {
|
|
22
|
-
const [{ defaultValue, reflection }] = splitProps(props, ["defaultValue", "reflection"]);
|
|
23
|
-
const context = usePowerlines();
|
|
24
|
-
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
25
|
-
/* @__PURE__ */ jsx(TypeScriptInterface, {
|
|
26
|
-
name: " EnvBase",
|
|
27
|
-
extends: ["EnvInterface"],
|
|
28
|
-
defaultValue,
|
|
29
|
-
reflection,
|
|
30
|
-
export: true
|
|
31
|
-
}),
|
|
32
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
33
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
34
|
-
/* @__PURE__ */ jsx(TypeDeclaration, {
|
|
35
|
-
name: "Env",
|
|
36
|
-
export: true,
|
|
37
|
-
children: code` {
|
|
38
|
-
[Key in keyof EnvBase as Key ${context?.config.env.prefix.map((prefix) => `| \`${prefix.replace(/_$/g, "")}_\${Key}\``).join(" ")}]: EnvBase[Key];
|
|
39
|
-
}
|
|
40
|
-
`
|
|
41
|
-
})
|
|
42
|
-
] });
|
|
43
|
-
}
|
|
44
|
-
function ConfigPropertyConditional(props) {
|
|
45
|
-
const [{ context, name }] = splitProps(props, ["context", "name"]);
|
|
46
|
-
if (!context) return null;
|
|
47
|
-
return code`propertyName === "${name}" || propertyName.replace(/^(${context.config.env.prefix.sort((a, b) => a.startsWith(b) ? -1 : b.startsWith(a) ? 1 : a.localeCompare(b)).map((prefix) => `${prefix.replace(/_$/, "")}_`).join("|")})/g, "").toLowerCase().replace(/[\\s\\-_]+/g, "") === "${name.toLowerCase().replace(/[\s\-_]+/g, "")}"`;
|
|
48
|
-
}
|
|
49
|
-
function ConfigPropertyGet(props) {
|
|
50
|
-
const [{ context, property, index }] = splitProps(props, [
|
|
51
|
-
"context",
|
|
52
|
-
"property",
|
|
53
|
-
"index"
|
|
54
|
-
]);
|
|
55
|
-
if (!context) return null;
|
|
56
|
-
return /* @__PURE__ */ jsx(Fragment, { children: index === 0 ? /* @__PURE__ */ jsx(IfStatement, {
|
|
57
|
-
condition: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ConfigPropertyConditional, {
|
|
58
|
-
name: property.getNameAsString(),
|
|
59
|
-
context
|
|
60
|
-
}), /* @__PURE__ */ jsxs(Show, {
|
|
61
|
-
when: property.getAlias() && property.getAlias().length > 0,
|
|
62
|
-
children: [code` || `, /* @__PURE__ */ jsx(For, {
|
|
63
|
-
each: property.getAlias(),
|
|
64
|
-
joiner: code` || `,
|
|
65
|
-
children: (alias) => /* @__PURE__ */ jsx(ConfigPropertyConditional, {
|
|
66
|
-
name: alias,
|
|
67
|
-
context
|
|
68
|
-
})
|
|
69
|
-
})]
|
|
70
|
-
})] }),
|
|
71
|
-
children: code`return target["${property.getNameAsString()}"];`
|
|
72
|
-
}) : /* @__PURE__ */ jsx(ElseIfClause, {
|
|
73
|
-
condition: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ConfigPropertyConditional, {
|
|
74
|
-
name: property.getNameAsString(),
|
|
75
|
-
context
|
|
76
|
-
}), /* @__PURE__ */ jsxs(Show, {
|
|
77
|
-
when: property.getAlias() && property.getAlias().length > 0,
|
|
78
|
-
children: [code` || `, /* @__PURE__ */ jsx(For, {
|
|
79
|
-
each: property.getAlias(),
|
|
80
|
-
joiner: code` || `,
|
|
81
|
-
children: (alias) => /* @__PURE__ */ jsx(ConfigPropertyConditional, {
|
|
82
|
-
name: alias,
|
|
83
|
-
context
|
|
84
|
-
})
|
|
85
|
-
})]
|
|
86
|
-
})] }),
|
|
87
|
-
children: code`return target["${property.getNameAsString()}"];`
|
|
88
|
-
}) });
|
|
89
|
-
}
|
|
90
|
-
function ConfigPropertySet(props) {
|
|
91
|
-
const [{ context, property, index }] = splitProps(props, [
|
|
92
|
-
"context",
|
|
93
|
-
"property",
|
|
94
|
-
"index"
|
|
95
|
-
]);
|
|
96
|
-
if (!context) return null;
|
|
97
|
-
return /* @__PURE__ */ jsx(Fragment, { children: index === 0 ? /* @__PURE__ */ jsx(IfStatement, {
|
|
98
|
-
condition: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ConfigPropertyConditional, {
|
|
99
|
-
name: property.getNameAsString(),
|
|
100
|
-
context
|
|
101
|
-
}), /* @__PURE__ */ jsxs(Show, {
|
|
102
|
-
when: property.getAlias() && property.getAlias().length > 0,
|
|
103
|
-
children: [code` || `, /* @__PURE__ */ jsx(For, {
|
|
104
|
-
each: property.getAlias(),
|
|
105
|
-
joiner: code` || `,
|
|
106
|
-
children: (alias) => /* @__PURE__ */ jsx(ConfigPropertyConditional, {
|
|
107
|
-
name: alias,
|
|
108
|
-
context
|
|
109
|
-
})
|
|
110
|
-
})]
|
|
111
|
-
})] }),
|
|
112
|
-
children: code`
|
|
113
|
-
target["${property.getNameAsString()}"] = newValue;
|
|
114
|
-
return true;
|
|
115
|
-
`
|
|
116
|
-
}) : /* @__PURE__ */ jsx(ElseIfClause, {
|
|
117
|
-
condition: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(ConfigPropertyConditional, {
|
|
118
|
-
name: property.getNameAsString(),
|
|
119
|
-
context
|
|
120
|
-
}), /* @__PURE__ */ jsxs(Show, {
|
|
121
|
-
when: property.getAlias() && property.getAlias().length > 0,
|
|
122
|
-
children: [code` || `, /* @__PURE__ */ jsx(For, {
|
|
123
|
-
each: property.getAlias(),
|
|
124
|
-
joiner: code` || `,
|
|
125
|
-
children: (alias) => /* @__PURE__ */ jsx(ConfigPropertyConditional, {
|
|
126
|
-
name: alias,
|
|
127
|
-
context
|
|
128
|
-
})
|
|
129
|
-
})]
|
|
130
|
-
})] }),
|
|
131
|
-
children: code`
|
|
132
|
-
target["${property.getNameAsString()}"] = newValue;
|
|
133
|
-
return true;
|
|
134
|
-
`
|
|
135
|
-
}) });
|
|
136
|
-
}
|
|
137
|
-
const createEnvRefkey = refkey$1("createEnv");
|
|
138
|
-
const envRefkey = refkey$1("env");
|
|
139
|
-
const envSerializerRefkey = refkey$1("EnvSerializer");
|
|
140
|
-
/**
|
|
141
|
-
* Generates the environment configuration module for the Powerlines project.
|
|
142
|
-
*/
|
|
143
|
-
function EnvBuiltin(props) {
|
|
144
|
-
const [{ defaultConfig, children }, rest] = splitProps(props, ["defaultConfig", "children"]);
|
|
145
|
-
const context = usePowerlines();
|
|
146
|
-
const defaultValue = computed(() => context && loadEnvFromContext(context, process.env));
|
|
147
|
-
const reflection = createReflectionResource(context);
|
|
148
|
-
const envInstance = computed(() => {
|
|
149
|
-
return new ReflectionClass({
|
|
150
|
-
kind: ReflectionKind.objectLiteral,
|
|
151
|
-
description: `The initial environment configuration state for the ${titleCase(context?.config?.name)} project.`,
|
|
152
|
-
types: []
|
|
153
|
-
}, reflection.data ?? void 0);
|
|
154
|
-
});
|
|
155
|
-
const reflectionGetProperties = computed(() => reflection.data?.getProperties().filter((property) => !property.isIgnored()).sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())) ?? []);
|
|
156
|
-
const reflectionSetProperties = computed(() => reflection.data?.getProperties().filter((property) => !property.isIgnored() && !property.isReadonly()).sort((a, b) => a.getNameAsString().localeCompare(b.getNameAsString())) ?? []);
|
|
157
|
-
return /* @__PURE__ */ jsxs(BuiltinFile, {
|
|
158
|
-
id: "env",
|
|
159
|
-
description: "The Powerlines environment configuration module provides an interface to define environment configuration parameters.",
|
|
160
|
-
...rest,
|
|
161
|
-
imports: defu({
|
|
162
|
-
"@powerlines/deepkit/vendor/type": [
|
|
163
|
-
"Type",
|
|
164
|
-
"stringify",
|
|
165
|
-
"serializer",
|
|
166
|
-
"serializeFunction",
|
|
167
|
-
"deserializeFunction",
|
|
168
|
-
"ReflectionKind",
|
|
169
|
-
"TemplateState",
|
|
170
|
-
"Serializer",
|
|
171
|
-
"TypeProperty",
|
|
172
|
-
"TypePropertySignature"
|
|
173
|
-
],
|
|
174
|
-
"@powerlines/plugin-env/types/runtime": [{ name: "EnvInterface" }]
|
|
175
|
-
}, rest.imports ?? {}),
|
|
176
|
-
children: [
|
|
177
|
-
/* @__PURE__ */ jsxs(Show, {
|
|
178
|
-
when: !isNull(reflection.data),
|
|
179
|
-
children: [
|
|
180
|
-
/* @__PURE__ */ jsx(EnvTypeDefinition, {
|
|
181
|
-
defaultValue: defaultValue.value,
|
|
182
|
-
reflection: reflection.data
|
|
183
|
-
}),
|
|
184
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
185
|
-
/* @__PURE__ */ jsx("hbr", {})
|
|
186
|
-
]
|
|
187
|
-
}),
|
|
188
|
-
/* @__PURE__ */ jsx(TypescriptObject, {
|
|
189
|
-
name: "initialEnv",
|
|
190
|
-
type: "Partial<EnvBase>",
|
|
191
|
-
defaultValue,
|
|
192
|
-
reflection: envInstance,
|
|
193
|
-
export: true,
|
|
194
|
-
const: true
|
|
195
|
-
}),
|
|
196
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
197
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
198
|
-
/* @__PURE__ */ jsxs(TSDoc, {
|
|
199
|
-
heading: "The environment configuration serializer for the Powerlines application.",
|
|
200
|
-
children: [
|
|
201
|
-
/* @__PURE__ */ jsx(TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
|
|
202
|
-
/* @__PURE__ */ jsx(TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
|
|
203
|
-
/* @__PURE__ */ jsx(TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
|
|
204
|
-
]
|
|
205
|
-
}),
|
|
206
|
-
/* @__PURE__ */ jsx(ClassDeclaration, {
|
|
207
|
-
refkey: envSerializerRefkey,
|
|
208
|
-
name: "EnvSerializer",
|
|
209
|
-
extends: "Serializer",
|
|
210
|
-
export: true,
|
|
211
|
-
children: /* @__PURE__ */ jsx(ClassMethod, {
|
|
212
|
-
name: "constructor",
|
|
213
|
-
public: true,
|
|
214
|
-
children: code`
|
|
215
|
-
super("env");
|
|
216
|
-
|
|
217
|
-
this.deserializeRegistry.register(
|
|
218
|
-
ReflectionKind.boolean,
|
|
219
|
-
(type: Type, state: TemplateState) => {
|
|
220
|
-
state.addSetter(
|
|
221
|
-
\`typeof \${state.accessor.toString()} !== "boolean" ? \${state.accessor.toString()} === 1 || \${state.accessor.toString()} === "1" || \${state.accessor.toString()}.toLowerCase() === "t" || \${state.accessor.toString()}.toLowerCase() === "true" || \${state.accessor.toString()}.toLowerCase() === "y" || \${state.accessor.toString()}.toLowerCase() === "yes" : \${state.accessor.toString()}\`
|
|
222
|
-
);
|
|
223
|
-
}
|
|
224
|
-
);
|
|
225
|
-
`
|
|
226
|
-
})
|
|
227
|
-
}),
|
|
228
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
229
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
230
|
-
/* @__PURE__ */ jsxs(TSDoc, {
|
|
231
|
-
heading: "A {@link EnvSerializer | environment configuration serializer} instance for the Powerlines application.",
|
|
232
|
-
children: [
|
|
233
|
-
/* @__PURE__ */ jsx(TSDocLink, { children: `https://deepkit.io/docs/serialization/serializers` }),
|
|
234
|
-
/* @__PURE__ */ jsx(TSDocLink, { children: `https://github.com/marcj/untitled-code/blob/master/packages/type/src/serializer.ts#L1918` }),
|
|
235
|
-
/* @__PURE__ */ jsx(TSDocRemarks, { children: `This serializer is used to serialize and deserialize the Powerlines environment configuration.` })
|
|
236
|
-
]
|
|
237
|
-
}),
|
|
238
|
-
/* @__PURE__ */ jsx(VarDeclaration, {
|
|
239
|
-
name: "envSerializer",
|
|
240
|
-
export: false,
|
|
241
|
-
const: true,
|
|
242
|
-
initializer: /* @__PURE__ */ jsx(NewExpression, {
|
|
243
|
-
args: [],
|
|
244
|
-
target: "EnvSerializer"
|
|
245
|
-
})
|
|
246
|
-
}),
|
|
247
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
248
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
249
|
-
/* @__PURE__ */ jsxs(TSDoc, {
|
|
250
|
-
heading: "Serialize a environment configuration object to JSON data objects (not a JSON string).",
|
|
251
|
-
children: [
|
|
252
|
-
/* @__PURE__ */ jsx(TSDocRemarks, { children: `The resulting JSON object can be stringified using JSON.stringify().` }),
|
|
253
|
-
/* @__PURE__ */ jsx(TSDocExample, { children: `const json = serializeEnv(env);` }),
|
|
254
|
-
/* @__PURE__ */ jsx(TSDocThrows, { children: `ValidationError when serialization or validation fails.` })
|
|
255
|
-
]
|
|
256
|
-
}),
|
|
257
|
-
/* @__PURE__ */ jsx(VarDeclaration, {
|
|
258
|
-
name: "serializeEnv",
|
|
259
|
-
export: true,
|
|
260
|
-
const: true,
|
|
261
|
-
initializer: "serializeFunction<EnvBase>(envSerializer)"
|
|
262
|
-
}),
|
|
263
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
264
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
265
|
-
/* @__PURE__ */ jsxs(TSDoc, {
|
|
266
|
-
heading: "Deserialize a environment configuration object from JSON data objects to JavaScript objects, without running any validators.",
|
|
267
|
-
children: [
|
|
268
|
-
/* @__PURE__ */ jsx(TSDocRemarks, { children: `Types that are already correct will be used as-is.` }),
|
|
269
|
-
/* @__PURE__ */ jsx(TSDocExample, { children: `const env = deserializeEnv(json);` }),
|
|
270
|
-
/* @__PURE__ */ jsx(TSDocThrows, { children: `ValidationError when deserialization fails.` })
|
|
271
|
-
]
|
|
272
|
-
}),
|
|
273
|
-
/* @__PURE__ */ jsx(VarDeclaration, {
|
|
274
|
-
name: "deserializeEnv",
|
|
275
|
-
export: true,
|
|
276
|
-
const: true,
|
|
277
|
-
initializer: "deserializeFunction<EnvBase>(envSerializer)"
|
|
278
|
-
}),
|
|
279
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
280
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
281
|
-
/* @__PURE__ */ jsxs(TSDoc, {
|
|
282
|
-
heading: "Initializes the Powerlines environment configuration module.",
|
|
283
|
-
children: [
|
|
284
|
-
/* @__PURE__ */ jsx(TSDocRemarks, { children: `This function initializes the Powerlines environment configuration object.` }),
|
|
285
|
-
/* @__PURE__ */ jsx(TSDocParam, {
|
|
286
|
-
name: "environmentConfig",
|
|
287
|
-
children: `The dynamic/runtime configuration - this could include the current environment variables or any other environment-specific settings provided by the runtime.`
|
|
288
|
-
}),
|
|
289
|
-
/* @__PURE__ */ jsx(TSDocReturns, { children: `The initialized Powerlines configuration object.` })
|
|
290
|
-
]
|
|
291
|
-
}),
|
|
292
|
-
/* @__PURE__ */ jsx(Show, {
|
|
293
|
-
when: Boolean(context?.entryPath),
|
|
294
|
-
children: /* @__PURE__ */ jsxs(FunctionDeclaration, {
|
|
295
|
-
refkey: createEnvRefkey,
|
|
296
|
-
async: false,
|
|
297
|
-
export: true,
|
|
298
|
-
name: "createEnv",
|
|
299
|
-
parameters: [{
|
|
300
|
-
name: "environmentConfig",
|
|
301
|
-
type: `Partial<Env>`,
|
|
302
|
-
optional: false,
|
|
303
|
-
default: "{}"
|
|
304
|
-
}],
|
|
305
|
-
returnType: "Env",
|
|
306
|
-
children: [
|
|
307
|
-
code`
|
|
308
|
-
return new Proxy<Env>(
|
|
309
|
-
deserializeEnv({
|
|
310
|
-
...initialEnv,
|
|
311
|
-
...environmentConfig
|
|
312
|
-
}) as Env,
|
|
313
|
-
{
|
|
314
|
-
get: (target: EnvBase, propertyName: string) => { `,
|
|
315
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
316
|
-
/* @__PURE__ */ jsx(For, {
|
|
317
|
-
each: reflectionGetProperties,
|
|
318
|
-
children: (property, index) => /* @__PURE__ */ jsx(ConfigPropertyGet, {
|
|
319
|
-
index,
|
|
320
|
-
context,
|
|
321
|
-
property
|
|
322
|
-
})
|
|
323
|
-
}),
|
|
324
|
-
code`
|
|
325
|
-
return undefined;
|
|
326
|
-
}, `,
|
|
327
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
328
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
329
|
-
code` set: (target: EnvBase, propertyName: string, newValue: any) => { `,
|
|
330
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
331
|
-
/* @__PURE__ */ jsx(For, {
|
|
332
|
-
each: reflectionSetProperties,
|
|
333
|
-
ender: code` else `,
|
|
334
|
-
children: (property, index) => /* @__PURE__ */ jsx(ConfigPropertySet, {
|
|
335
|
-
index,
|
|
336
|
-
context,
|
|
337
|
-
property
|
|
338
|
-
})
|
|
339
|
-
}),
|
|
340
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
341
|
-
code`return false;
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
);
|
|
345
|
-
`
|
|
346
|
-
]
|
|
347
|
-
})
|
|
348
|
-
}),
|
|
349
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
350
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
351
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
352
|
-
/* @__PURE__ */ jsx(VarDeclaration, {
|
|
353
|
-
refkey: envRefkey,
|
|
354
|
-
name: "env",
|
|
355
|
-
type: "Env",
|
|
356
|
-
export: true,
|
|
357
|
-
const: true,
|
|
358
|
-
initializer: /* @__PURE__ */ jsx(Fragment, { children: code`createEnv(${defaultConfig || "{}"} as Partial<Env>);` })
|
|
359
|
-
}),
|
|
360
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
361
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
362
|
-
/* @__PURE__ */ jsx(VarDeclaration, {
|
|
363
|
-
export: true,
|
|
364
|
-
const: true,
|
|
365
|
-
name: "isCI",
|
|
366
|
-
doc: "Detect if the application is running in a CI environment.",
|
|
367
|
-
initializer: code`Boolean(
|
|
368
|
-
env.CI ||
|
|
369
|
-
env.RUN_ID ||
|
|
370
|
-
env.AGOLA_GIT_REF ||
|
|
371
|
-
env.AC_APPCIRCLE ||
|
|
372
|
-
env.APPVEYOR ||
|
|
373
|
-
env.CODEBUILD ||
|
|
374
|
-
env.TF_BUILD ||
|
|
375
|
-
env.bamboo_planKey ||
|
|
376
|
-
env.BITBUCKET_COMMIT ||
|
|
377
|
-
env.BITRISE_IO ||
|
|
378
|
-
env.BUDDY_WORKSPACE_ID ||
|
|
379
|
-
env.BUILDKITE ||
|
|
380
|
-
env.CIRCLECI ||
|
|
381
|
-
env.CIRRUS_CI ||
|
|
382
|
-
env.CF_BUILD_ID ||
|
|
383
|
-
env.CM_BUILD_ID ||
|
|
384
|
-
env.CI_NAME ||
|
|
385
|
-
env.DRONE ||
|
|
386
|
-
env.DSARI ||
|
|
387
|
-
env.EARTHLY_CI ||
|
|
388
|
-
env.EAS_BUILD ||
|
|
389
|
-
env.GERRIT_PROJECT ||
|
|
390
|
-
env.GITEA_ACTIONS ||
|
|
391
|
-
env.GITHUB_ACTIONS ||
|
|
392
|
-
env.GITLAB_CI ||
|
|
393
|
-
env.GOCD ||
|
|
394
|
-
env.BUILDER_OUTPUT ||
|
|
395
|
-
env.HARNESS_BUILD_ID ||
|
|
396
|
-
env.JENKINS_URL ||
|
|
397
|
-
env.LAYERCI ||
|
|
398
|
-
env.MAGNUM ||
|
|
399
|
-
env.NETLIFY ||
|
|
400
|
-
env.NEVERCODE ||
|
|
401
|
-
env.PROW_JOB_ID ||
|
|
402
|
-
env.RELEASE_BUILD_ID ||
|
|
403
|
-
env.RENDER ||
|
|
404
|
-
env.SAILCI ||
|
|
405
|
-
env.HUDSON ||
|
|
406
|
-
env.SCREWDRIVER ||
|
|
407
|
-
env.SEMAPHORE ||
|
|
408
|
-
env.SOURCEHUT ||
|
|
409
|
-
env.STRIDER ||
|
|
410
|
-
env.TASK_ID ||
|
|
411
|
-
env.RUN_ID ||
|
|
412
|
-
env.TEAMCITY_VERSION ||
|
|
413
|
-
env.TRAVIS ||
|
|
414
|
-
env.VELA ||
|
|
415
|
-
env.NOW_BUILDER ||
|
|
416
|
-
env.APPCENTER_BUILD_ID ||
|
|
417
|
-
env.CI_XCODE_PROJECT ||
|
|
418
|
-
env.XCS || false
|
|
419
|
-
);
|
|
420
|
-
`
|
|
421
|
-
}),
|
|
422
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
423
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
424
|
-
/* @__PURE__ */ jsx(TSDoc, {
|
|
425
|
-
heading: "Detect the \\`mode\\` of the current runtime environment.",
|
|
426
|
-
children: /* @__PURE__ */ jsx(TSDocRemarks, { children: code`The \`mode\` is determined by the \`MODE\` environment variable, or falls back to the \`NEXT_PUBLIC_VERCEL_ENV\`, \`NODE_ENV\`, or defaults to \`production\`. While the value can potentially be any string, Storm Software generally only allows a value in the following list:
|
|
427
|
-
- \`production\`
|
|
428
|
-
- \`test\`
|
|
429
|
-
- \`development\`` })
|
|
430
|
-
}),
|
|
431
|
-
/* @__PURE__ */ jsx(VarDeclaration, {
|
|
432
|
-
export: true,
|
|
433
|
-
const: true,
|
|
434
|
-
name: "mode",
|
|
435
|
-
initializer: code`String(env.MODE) || "production"; `
|
|
436
|
-
}),
|
|
437
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
438
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
439
|
-
/* @__PURE__ */ jsx(VarDeclaration, {
|
|
440
|
-
export: true,
|
|
441
|
-
const: true,
|
|
442
|
-
name: "isProduction",
|
|
443
|
-
doc: "Detect if the application is running in \\\"production\\\\\" mode",
|
|
444
|
-
initializer: code`["prd", "prod", "production"].includes(mode.toLowerCase()); `
|
|
445
|
-
}),
|
|
446
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
447
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
448
|
-
/* @__PURE__ */ jsx(VarDeclaration, {
|
|
449
|
-
export: true,
|
|
450
|
-
const: true,
|
|
451
|
-
name: "isTest",
|
|
452
|
-
doc: "Detect if the application is running in \"test\" mode",
|
|
453
|
-
initializer: code`["tst", "test", "testing", "stg", "stage", "staging"].includes(mode.toLowerCase()) || env.TEST; `
|
|
454
|
-
}),
|
|
455
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
456
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
457
|
-
/* @__PURE__ */ jsx(VarDeclaration, {
|
|
458
|
-
export: true,
|
|
459
|
-
const: true,
|
|
460
|
-
name: "isDevelopment",
|
|
461
|
-
doc: "Detect if the application is running in \"development\" mode",
|
|
462
|
-
initializer: code`["dev", "development"].includes(mode.toLowerCase()); `
|
|
463
|
-
}),
|
|
464
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
465
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
466
|
-
/* @__PURE__ */ jsx(VarDeclaration, {
|
|
467
|
-
export: true,
|
|
468
|
-
const: true,
|
|
469
|
-
name: "isDebug",
|
|
470
|
-
doc: "Detect if the application is running in \"debug\" mode",
|
|
471
|
-
initializer: code`Boolean(isDevelopment && env.DEBUG); `
|
|
472
|
-
}),
|
|
473
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
474
|
-
/* @__PURE__ */ jsx("hbr", {}),
|
|
475
|
-
/* @__PURE__ */ jsx(Show, {
|
|
476
|
-
when: Boolean(children),
|
|
477
|
-
children
|
|
478
|
-
})
|
|
479
|
-
]
|
|
480
|
-
});
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
//#endregion
|
|
484
|
-
export { EnvBuiltin, EnvTypeDefinition };
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
let __stryke_path_join_paths = require("@stryke/path/join-paths");
|
|
3
|
-
let automd = require("automd");
|
|
4
|
-
|
|
5
|
-
//#region ../plugin-env/src/helpers/automd-generator.ts
|
|
6
|
-
/**
|
|
7
|
-
* AutoMD generator to generate environment variable documentation
|
|
8
|
-
*
|
|
9
|
-
* @param context - The generator context.
|
|
10
|
-
* @returns The generated documentation content.
|
|
11
|
-
*/
|
|
12
|
-
const env = (context) => (0, automd.defineGenerator)({
|
|
13
|
-
name: "env",
|
|
14
|
-
async generate() {
|
|
15
|
-
const envDocFile = (0, __stryke_path_join_paths.joinPaths)(context.config.projectRoot, "docs", "generated", "env.md");
|
|
16
|
-
if (!context.fs.existsSync(envDocFile)) return { contents: "" };
|
|
17
|
-
return { contents: await context.fs.read(envDocFile) || "" };
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
//#endregion
|
|
22
|
-
exports.env = env;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { joinPaths } from "@stryke/path/join-paths";
|
|
2
|
-
import { defineGenerator } from "automd";
|
|
3
|
-
|
|
4
|
-
//#region ../plugin-env/src/helpers/automd-generator.ts
|
|
5
|
-
/**
|
|
6
|
-
* AutoMD generator to generate environment variable documentation
|
|
7
|
-
*
|
|
8
|
-
* @param context - The generator context.
|
|
9
|
-
* @returns The generated documentation content.
|
|
10
|
-
*/
|
|
11
|
-
const env = (context) => defineGenerator({
|
|
12
|
-
name: "env",
|
|
13
|
-
async generate() {
|
|
14
|
-
const envDocFile = joinPaths(context.config.projectRoot, "docs", "generated", "env.md");
|
|
15
|
-
if (!context.fs.existsSync(envDocFile)) return { contents: "" };
|
|
16
|
-
return { contents: await context.fs.read(envDocFile) || "" };
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
//#endregion
|
|
21
|
-
export { env };
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('../../../_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_persistence = require('./persistence.cjs');
|
|
3
|
-
const require_load = require('./load.cjs');
|
|
4
|
-
let __powerlines_deepkit_vendor_type = require("@powerlines/deepkit/vendor/type");
|
|
5
|
-
let __alloy_js_core = require("@alloy-js/core");
|
|
6
|
-
let __stryke_string_format_title_case = require("@stryke/string-format/title-case");
|
|
7
|
-
|
|
8
|
-
//#region ../plugin-env/src/helpers/create-reflection-resource.ts
|
|
9
|
-
/**
|
|
10
|
-
* Creates a reflection resource for the environment configuration.
|
|
11
|
-
*
|
|
12
|
-
* @param context - The environment plugin context.
|
|
13
|
-
* @returns A resource that provides the reflection of the environment configuration.
|
|
14
|
-
*/
|
|
15
|
-
function createReflectionResource(context) {
|
|
16
|
-
const defaultValue = (0, __alloy_js_core.computed)(() => context && require_load.loadEnvFromContext(context, process.env));
|
|
17
|
-
return (0, __alloy_js_core.createResource)(async () => {
|
|
18
|
-
if (!context) return new __powerlines_deepkit_vendor_type.ReflectionClass({
|
|
19
|
-
kind: __powerlines_deepkit_vendor_type.ReflectionKind.objectLiteral,
|
|
20
|
-
description: `The initial environment configuration state for the Powerlines project.`,
|
|
21
|
-
types: []
|
|
22
|
-
});
|
|
23
|
-
const result = await require_persistence.readEnvTypeReflection(context, "env");
|
|
24
|
-
result.getProperties().forEach((prop) => {
|
|
25
|
-
prop.getAlias().filter(Boolean).forEach((alias) => {
|
|
26
|
-
result.addProperty({
|
|
27
|
-
name: alias,
|
|
28
|
-
optional: prop.isOptional() ? true : void 0,
|
|
29
|
-
readonly: prop.isReadonly() ? true : void 0,
|
|
30
|
-
description: prop.getDescription(),
|
|
31
|
-
visibility: prop.getVisibility(),
|
|
32
|
-
type: prop.getType(),
|
|
33
|
-
default: prop.getDefaultValue(),
|
|
34
|
-
tags: {
|
|
35
|
-
hidden: prop.isHidden(),
|
|
36
|
-
ignore: prop.isIgnored(),
|
|
37
|
-
internal: prop.isInternal(),
|
|
38
|
-
alias: prop.getAlias().filter((a) => a !== alias).concat(prop.name),
|
|
39
|
-
title: prop.getTitle() || (0, __stryke_string_format_title_case.titleCase)(prop.name),
|
|
40
|
-
readonly: prop.isReadonly(),
|
|
41
|
-
permission: prop.getPermission(),
|
|
42
|
-
domain: prop.getDomain()
|
|
43
|
-
}
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
});
|
|
47
|
-
result.getProperties().forEach((prop) => {
|
|
48
|
-
prop.setDefaultValue(defaultValue.value?.[prop.getNameAsString()] ?? prop.getAlias().reduce((ret, alias) => ret ?? defaultValue.value?.[alias], void 0) ?? prop.getDefaultValue());
|
|
49
|
-
});
|
|
50
|
-
return result;
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
//#endregion
|
|
55
|
-
exports.createReflectionResource = createReflectionResource;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { readEnvTypeReflection } from "./persistence.mjs";
|
|
2
|
-
import { loadEnvFromContext } from "./load.mjs";
|
|
3
|
-
import { ReflectionClass, ReflectionKind } from "@powerlines/deepkit/vendor/type";
|
|
4
|
-
import { computed, createResource } from "@alloy-js/core";
|
|
5
|
-
import { titleCase } from "@stryke/string-format/title-case";
|
|
6
|
-
|
|
7
|
-
//#region ../plugin-env/src/helpers/create-reflection-resource.ts
|
|
8
|
-
/**
|
|
9
|
-
* Creates a reflection resource for the environment configuration.
|
|
10
|
-
*
|
|
11
|
-
* @param context - The environment plugin context.
|
|
12
|
-
* @returns A resource that provides the reflection of the environment configuration.
|
|
13
|
-
*/
|
|
14
|
-
function createReflectionResource(context) {
|
|
15
|
-
const defaultValue = computed(() => context && loadEnvFromContext(context, process.env));
|
|
16
|
-
return createResource(async () => {
|
|
17
|
-
if (!context) return new ReflectionClass({
|
|
18
|
-
kind: ReflectionKind.objectLiteral,
|
|
19
|
-
description: `The initial environment configuration state for the Powerlines project.`,
|
|
20
|
-
types: []
|
|
21
|
-
});
|
|
22
|
-
const result = await readEnvTypeReflection(context, "env");
|
|
23
|
-
result.getProperties().forEach((prop) => {
|
|
24
|
-
prop.getAlias().filter(Boolean).forEach((alias) => {
|
|
25
|
-
result.addProperty({
|
|
26
|
-
name: alias,
|
|
27
|
-
optional: prop.isOptional() ? true : void 0,
|
|
28
|
-
readonly: prop.isReadonly() ? true : void 0,
|
|
29
|
-
description: prop.getDescription(),
|
|
30
|
-
visibility: prop.getVisibility(),
|
|
31
|
-
type: prop.getType(),
|
|
32
|
-
default: prop.getDefaultValue(),
|
|
33
|
-
tags: {
|
|
34
|
-
hidden: prop.isHidden(),
|
|
35
|
-
ignore: prop.isIgnored(),
|
|
36
|
-
internal: prop.isInternal(),
|
|
37
|
-
alias: prop.getAlias().filter((a) => a !== alias).concat(prop.name),
|
|
38
|
-
title: prop.getTitle() || titleCase(prop.name),
|
|
39
|
-
readonly: prop.isReadonly(),
|
|
40
|
-
permission: prop.getPermission(),
|
|
41
|
-
domain: prop.getDomain()
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
result.getProperties().forEach((prop) => {
|
|
47
|
-
prop.setDefaultValue(defaultValue.value?.[prop.getNameAsString()] ?? prop.getAlias().reduce((ret, alias) => ret ?? defaultValue.value?.[alias], void 0) ?? prop.getDefaultValue());
|
|
48
|
-
});
|
|
49
|
-
return result;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
//#endregion
|
|
54
|
-
export { createReflectionResource };
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
const require_reflect = require('./reflect.cjs');
|
|
2
|
-
const require_persistence = require('./persistence.cjs');
|
|
3
|
-
const require_source_file_env = require('./source-file-env.cjs');
|
|
4
|
-
const require_load = require('./load.cjs');
|
|
5
|
-
const require_create_reflection_resource = require('./create-reflection-resource.cjs');
|
|
6
|
-
require('./template-helpers.cjs');
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { BaseEnv, BaseSecrets, createEnvReflection, createSecretsReflection, mergeEnvReflections, mergeSecretsReflections, reflectEnv, reflectSecrets } from "./reflect.mjs";
|
|
2
|
-
import { getEnvDefaultTypeDefinition, getEnvReflectionsPath, getEnvTypeReflectionsPath, getSecretsDefaultTypeDefinition, readEnvReflection, readEnvTypeReflection, readSecretsReflection, resolveRuntimeTypeFile, writeEnvReflection, writeEnvTypeReflection } from "./persistence.mjs";
|
|
3
|
-
import { removeEnvPrefix } from "./source-file-env.mjs";
|
|
4
|
-
import { loadEnv, loadEnvFromContext } from "./load.mjs";
|
|
5
|
-
import { createReflectionResource } from "./create-reflection-resource.mjs";
|
|
6
|
-
import "./template-helpers.mjs";
|
|
7
|
-
|
|
8
|
-
export { };
|