@batijs/core 0.0.630 → 0.0.631
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/config.d.ts +31 -0
- package/dist/config.js +1 -1
- package/dist/index.d.ts +70 -29
- package/dist/index.js +413 -436
- package/package.json +1 -1
package/dist/config.d.ts
CHANGED
|
@@ -9,6 +9,35 @@ interface VikeMeta {
|
|
|
9
9
|
BATI_IS_CI?: boolean;
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
|
12
|
+
//#region src/env-registry.d.ts
|
|
13
|
+
/** Destinations a declared env var can be emitted to. */
|
|
14
|
+
type EnvSink = "dotenv" | "compose" | "dockerfile" | "wrangler";
|
|
15
|
+
/**
|
|
16
|
+
* What kind of value a var carries:
|
|
17
|
+
* - `secret`: no committed value; the host/CI supplies it at runtime.
|
|
18
|
+
* - `server-default`: a safe default committed to the repo.
|
|
19
|
+
* - `public`: a client/build-time var (e.g. `PUBLIC_ENV__*`), never part of the server runtime.
|
|
20
|
+
*/
|
|
21
|
+
type EnvScope = "secret" | "server-default" | "public";
|
|
22
|
+
interface EnvVarDef {
|
|
23
|
+
/** Variable name, e.g. `DATABASE_URL`. */
|
|
24
|
+
key: string;
|
|
25
|
+
scope: EnvScope;
|
|
26
|
+
/** `.env` help text (may be multi-line). */
|
|
27
|
+
comment?: string;
|
|
28
|
+
/** Default value for `server-default` / `public` scopes. */
|
|
29
|
+
default?: string;
|
|
30
|
+
/** Value overrides per destination, e.g. a container path vs. a local one. */
|
|
31
|
+
perSink?: Partial<Record<EnvSink, string>>;
|
|
32
|
+
/** `secret` only: env var to read a dev/test value from. */
|
|
33
|
+
devValueFrom?: string;
|
|
34
|
+
/** Groups + comments vars in the compose/Dockerfile output, e.g. `"auth0"`. */
|
|
35
|
+
group?: string;
|
|
36
|
+
}
|
|
37
|
+
type EnvRegistry = EnvVarDef[];
|
|
38
|
+
/** A feature's env-var producer; meta-gating (does the var apply?) lives here. */
|
|
39
|
+
type EnvRegistryFactory = (meta: VikeMeta) => EnvRegistry;
|
|
40
|
+
//#endregion
|
|
12
41
|
//#region src/config.d.ts
|
|
13
42
|
interface BatiConfigStep {
|
|
14
43
|
order?: number;
|
|
@@ -26,6 +55,8 @@ interface BatiConfig {
|
|
|
26
55
|
enforce?: "pre" | "post";
|
|
27
56
|
nextSteps?: (meta: VikeMeta, packageManager: string, utils: typeof Colorette) => BatiConfigStep[];
|
|
28
57
|
knip?: BatiKnipConfig;
|
|
58
|
+
/** Env vars this feature contributes, gated on `meta` (see {@link EnvRegistryFactory}). */
|
|
59
|
+
env?: EnvRegistryFactory;
|
|
29
60
|
}
|
|
30
61
|
declare function defineConfig<T extends BatiConfig>(config: T): T;
|
|
31
62
|
//#endregion
|
package/dist/config.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function e(e,t){if(!e)throw Error(t)}function t(t){return`enforce`in t&&e(t.enforce===`pre`||t.enforce===`post`,`'enforce' must be 'pre' or 'post', was ${t.enforce}`),`if`in t&&e(typeof t.if==`function`,`'if' must be a function`),`nextSteps`in t&&e(typeof t.nextSteps==`function`,`'nextSteps' must be a function`),`knip`in t&&(e(typeof t.knip==`object`&&t.knip!==null,`'knip' must be an object`),`entry`in t.knip&&e(Array.isArray(t.knip.entry),`'knip.entry' must be an array`),`ignoreDependencies`in t.knip&&e(Array.isArray(t.knip.ignoreDependencies),`'knip.ignoreDependencies' must be an array`),`ignore`in t.knip&&e(Array.isArray(t.knip.ignore),`'knip.ignore' must be an array`),`vite`in t.knip&&e(typeof t.knip.vite==`boolean`,`'knip.vite' must be a boolean`)),t}export{t as defineConfig};
|
|
1
|
+
function e(e,t){if(!e)throw Error(t)}function t(t){return`enforce`in t&&e(t.enforce===`pre`||t.enforce===`post`,`'enforce' must be 'pre' or 'post', was ${t.enforce}`),`if`in t&&e(typeof t.if==`function`,`'if' must be a function`),`nextSteps`in t&&e(typeof t.nextSteps==`function`,`'nextSteps' must be a function`),`knip`in t&&(e(typeof t.knip==`object`&&t.knip!==null,`'knip' must be an object`),`entry`in t.knip&&e(Array.isArray(t.knip.entry),`'knip.entry' must be an array`),`ignoreDependencies`in t.knip&&e(Array.isArray(t.knip.ignoreDependencies),`'knip.ignoreDependencies' must be an array`),`ignore`in t.knip&&e(Array.isArray(t.knip.ignore),`'knip.ignore' must be an array`),`vite`in t.knip&&e(typeof t.knip.vite==`boolean`,`'knip.vite' must be a boolean`)),`env`in t&&e(typeof t.env==`function`,`'env' must be a function of meta`),t}export{t as defineConfig};
|
package/dist/index.d.ts
CHANGED
|
@@ -64,6 +64,66 @@ declare function dockerPackageManager(name: string, {
|
|
|
64
64
|
frozenLockfile: boolean;
|
|
65
65
|
}): DockerPackageManager;
|
|
66
66
|
//#endregion
|
|
67
|
+
//#region src/types.d.ts
|
|
68
|
+
type ContentGetter = () => string | Promise<string>;
|
|
69
|
+
interface VikeMeta {
|
|
70
|
+
BATI: BatiSet;
|
|
71
|
+
BATI_TEST?: boolean;
|
|
72
|
+
BATI_SKIP_GIT?: boolean;
|
|
73
|
+
BATI_IS_CI?: boolean;
|
|
74
|
+
}
|
|
75
|
+
type TransformerProps = {
|
|
76
|
+
readfile?: ContentGetter;
|
|
77
|
+
target: string;
|
|
78
|
+
source: string;
|
|
79
|
+
meta: VikeMeta;
|
|
80
|
+
packageJson: PackageJson;
|
|
81
|
+
env: EnvRegistry;
|
|
82
|
+
};
|
|
83
|
+
type Transformer = (props: TransformerProps) => unknown;
|
|
84
|
+
interface PackageJson {
|
|
85
|
+
dependencies?: Record<string, string>;
|
|
86
|
+
devDependencies?: Record<string, string>;
|
|
87
|
+
}
|
|
88
|
+
interface StringTransformer {
|
|
89
|
+
finalize(): string;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
//#region src/env-registry.d.ts
|
|
93
|
+
/** Destinations a declared env var can be emitted to. */
|
|
94
|
+
type EnvSink = "dotenv" | "compose" | "dockerfile" | "wrangler";
|
|
95
|
+
/**
|
|
96
|
+
* What kind of value a var carries:
|
|
97
|
+
* - `secret`: no committed value; the host/CI supplies it at runtime.
|
|
98
|
+
* - `server-default`: a safe default committed to the repo.
|
|
99
|
+
* - `public`: a client/build-time var (e.g. `PUBLIC_ENV__*`), never part of the server runtime.
|
|
100
|
+
*/
|
|
101
|
+
type EnvScope = "secret" | "server-default" | "public";
|
|
102
|
+
interface EnvVarDef {
|
|
103
|
+
/** Variable name, e.g. `DATABASE_URL`. */
|
|
104
|
+
key: string;
|
|
105
|
+
scope: EnvScope;
|
|
106
|
+
/** `.env` help text (may be multi-line). */
|
|
107
|
+
comment?: string;
|
|
108
|
+
/** Default value for `server-default` / `public` scopes. */
|
|
109
|
+
default?: string;
|
|
110
|
+
/** Value overrides per destination, e.g. a container path vs. a local one. */
|
|
111
|
+
perSink?: Partial<Record<EnvSink, string>>;
|
|
112
|
+
/** `secret` only: env var to read a dev/test value from. */
|
|
113
|
+
devValueFrom?: string;
|
|
114
|
+
/** Groups + comments vars in the compose/Dockerfile output, e.g. `"auth0"`. */
|
|
115
|
+
group?: string;
|
|
116
|
+
}
|
|
117
|
+
type EnvRegistry = EnvVarDef[];
|
|
118
|
+
/** A feature's env-var producer; meta-gating (does the var apply?) lives here. */
|
|
119
|
+
type EnvRegistryFactory = (meta: VikeMeta) => EnvRegistry;
|
|
120
|
+
/** Server-runtime vars: everything but the client/build-time `public` ones. */
|
|
121
|
+
declare function isServerVar(def: EnvVarDef): boolean;
|
|
122
|
+
/** The committed value a non-secret var contributes to a sink. */
|
|
123
|
+
declare function committedValue(def: EnvVarDef, sink: EnvSink): string;
|
|
124
|
+
/** A secret's dev/test value, from its `devValueFrom` env var (empty if unset). */
|
|
125
|
+
declare function secretDevValue(def: EnvVarDef): string;
|
|
126
|
+
//#endregion
|
|
67
127
|
//#region src/format.d.ts
|
|
68
128
|
declare function formatCode(code: string, options: {
|
|
69
129
|
filepath: string;
|
|
@@ -1131,30 +1191,6 @@ interface Yaml extends Literal {
|
|
|
1131
1191
|
*/
|
|
1132
1192
|
interface YamlData extends Data {}
|
|
1133
1193
|
//#endregion
|
|
1134
|
-
//#region src/types.d.ts
|
|
1135
|
-
type ContentGetter = () => string | Promise<string>;
|
|
1136
|
-
interface VikeMeta {
|
|
1137
|
-
BATI: BatiSet;
|
|
1138
|
-
BATI_TEST?: boolean;
|
|
1139
|
-
BATI_SKIP_GIT?: boolean;
|
|
1140
|
-
BATI_IS_CI?: boolean;
|
|
1141
|
-
}
|
|
1142
|
-
type TransformerProps = {
|
|
1143
|
-
readfile?: ContentGetter;
|
|
1144
|
-
target: string;
|
|
1145
|
-
source: string;
|
|
1146
|
-
meta: VikeMeta;
|
|
1147
|
-
packageJson: PackageJson;
|
|
1148
|
-
};
|
|
1149
|
-
type Transformer = (props: TransformerProps) => unknown;
|
|
1150
|
-
interface PackageJson {
|
|
1151
|
-
dependencies?: Record<string, string>;
|
|
1152
|
-
devDependencies?: Record<string, string>;
|
|
1153
|
-
}
|
|
1154
|
-
interface StringTransformer {
|
|
1155
|
-
finalize(): string;
|
|
1156
|
-
}
|
|
1157
|
-
//#endregion
|
|
1158
1194
|
//#region src/markdown/utils.d.ts
|
|
1159
1195
|
/**
|
|
1160
1196
|
* Parse a comment marker.
|
|
@@ -1288,6 +1324,14 @@ declare function loadYaml({
|
|
|
1288
1324
|
fallbackEmpty?: boolean;
|
|
1289
1325
|
}): Promise<YAMLDocument.Parsed<_$yaml.Alias.Parsed, true> | YAMLDocument.Parsed<_$yaml.Scalar.Parsed, true> | YAMLDocument.Parsed<_$yaml.YAMLMap.Parsed<_$yaml.ParsedNode, _$yaml.ParsedNode | null>, true> | YAMLDocument.Parsed<_$yaml.YAMLSeq.Parsed<_$yaml.ParsedNode>, true>>;
|
|
1290
1326
|
//#endregion
|
|
1327
|
+
//#region src/parse/yaml.d.ts
|
|
1328
|
+
/**
|
|
1329
|
+
* Append `KEY=value` items to `services.<service>.environment` of a
|
|
1330
|
+
* docker-compose document. Used to inject the env-registry-derived env block
|
|
1331
|
+
* (see `composeEnvEntries`) without the compose boilerplate hardcoding vars.
|
|
1332
|
+
*/
|
|
1333
|
+
declare function setComposeEnvironment(code: string, entries: string[], service?: string): string;
|
|
1334
|
+
//#endregion
|
|
1291
1335
|
//#region src/parse/linters/common.d.ts
|
|
1292
1336
|
type AllowedContextFlags = "include-if-imported";
|
|
1293
1337
|
interface FileContext {
|
|
@@ -1319,11 +1363,8 @@ declare function getVersion(): {
|
|
|
1319
1363
|
version: string;
|
|
1320
1364
|
semver: string[];
|
|
1321
1365
|
};
|
|
1322
|
-
//#endregion
|
|
1323
|
-
//#region src/utils/env.d.ts
|
|
1324
|
-
declare function appendToEnv(envContent: string | undefined | null, key: string, value: unknown, comment?: string): string;
|
|
1325
1366
|
declare namespace index_d_exports {
|
|
1326
|
-
export { BaseOptions, ContentGetter, CopyOptions, DockerPackageManager, DockerfileBuilder, EnvRecord, FileContext, FromOptions, MarkdownV2, PackageJson, PackageManagerInfo, StringTransformer, Transformer, TransformerProps, VikeMeta, YAMLDocument, YAMLMap, YAMLSeq, addVitePlugin,
|
|
1367
|
+
export { BaseOptions, ContentGetter, CopyOptions, DockerPackageManager, DockerfileBuilder, EnvRecord, EnvRegistry, EnvRegistryFactory, EnvScope, EnvSink, EnvVarDef, FileContext, FromOptions, MarkdownV2, PackageJson, PackageManagerInfo, StringTransformer, Transformer, TransformerProps, VikeMeta, YAMLDocument, YAMLMap, YAMLSeq, addVitePlugin, builders, committedValue, deepMergeObject, dockerPackageManager, dockerfile, formatCode, generateCode, getArgs, getVersion, isServerVar, loadAsJson, loadAsMagicast, loadFile, loadMarkdown, loadPackageJson, loadRelativeFileAsMagicast, loadYaml, packageManager, parseMarkdown, parseModule, randomBytes, secretDevValue, setComposeEnvironment, transformAndFormat, which, withIcon };
|
|
1327
1368
|
}
|
|
1328
1369
|
//#endregion
|
|
1329
|
-
export { BaseOptions, ContentGetter, CopyOptions, DockerPackageManager, DockerfileBuilder, EnvRecord, type FileContext, FromOptions, MarkdownV2, PackageJson, PackageManagerInfo, StringTransformer, Transformer, TransformerProps, VikeMeta, type YAMLDocument, YAMLMap, YAMLSeq, addVitePlugin,
|
|
1370
|
+
export { BaseOptions, ContentGetter, CopyOptions, DockerPackageManager, DockerfileBuilder, EnvRecord, EnvRegistry, EnvRegistryFactory, EnvScope, EnvSink, EnvVarDef, type FileContext, FromOptions, MarkdownV2, PackageJson, PackageManagerInfo, StringTransformer, Transformer, TransformerProps, VikeMeta, type YAMLDocument, YAMLMap, YAMLSeq, addVitePlugin, builders, committedValue, deepMergeObject, dockerPackageManager, dockerfile, formatCode, generateCode, getArgs, getVersion, isServerVar, loadAsJson, loadAsMagicast, loadFile, loadMarkdown, loadPackageJson, loadRelativeFileAsMagicast, loadYaml, packageManager, parseMarkdown, parseModule, randomBytes, secretDevValue, setComposeEnvironment, transformAndFormat, which, withIcon };
|