@batijs/core 0.0.629 → 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 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
@@ -1,7 +1,7 @@
1
1
  import { BatiSet, CategoryLabels, Flags } from "@batijs/features";
2
2
  import * as _$attributes_parser0 from "attributes-parser";
3
3
  import * as _$yaml from "yaml";
4
- import { Document as YAMLDocument, DocumentOptions, ParseOptions, SchemaOptions } from "yaml";
4
+ import { Document as YAMLDocument, DocumentOptions, ParseOptions, SchemaOptions, YAMLMap, YAMLSeq } from "yaml";
5
5
  import { ProxifiedModule, builders, generateCode, loadFile, parseModule } from "magicast";
6
6
  import { addVitePlugin, deepMergeObject } from "magicast/helpers";
7
7
  import { Color } from "colorette";
@@ -11,6 +11,119 @@ export * from "colorette";
11
11
 
12
12
  //#region \0rolldown/runtime.js
13
13
  //#endregion
14
+ //#region src/dockerfile.d.ts
15
+ /**
16
+ * Chainable builder for the multi-stage Dockerfiles emitted by Bati boilerplates.
17
+ *
18
+ * `.from(img, { as })` widens the `Stages` type parameter, so `.copy(..., { from })`
19
+ * only autocompletes — and accepts — stage names that were actually declared.
20
+ */
21
+ interface BaseOptions {
22
+ /** Rendered as `# <comment>` line(s) immediately before the instruction. */
23
+ comment?: string;
24
+ }
25
+ interface FromOptions extends BaseOptions {
26
+ /** Stage alias: `AS <name>`. */
27
+ as: string;
28
+ }
29
+ interface CopyOptions<Stages extends string = string> extends BaseOptions {
30
+ /** Copy from a named build stage: `--from=<stage>`. */
31
+ from?: Stages;
32
+ }
33
+ type EnvRecord = Record<string, string>;
34
+ declare class DockerfileBuilder<Stages extends string = never> {
35
+ private readonly instructions;
36
+ from<S extends string>(image: string, options: FromOptions & {
37
+ as: S;
38
+ }): DockerfileBuilder<Stages | S>;
39
+ workdir(path: string, options?: BaseOptions): this;
40
+ run(command: string, options?: BaseOptions): this;
41
+ copy(sources: string[], dest: string, options?: CopyOptions<Stages | (string & {})>): this;
42
+ env(vars: EnvRecord, options?: BaseOptions): this;
43
+ expose(port: number, options?: BaseOptions): this;
44
+ cmd(command: string[], options?: BaseOptions): this;
45
+ /** Run `cb` against the builder only when `condition` holds. */
46
+ when(condition: boolean, cb: (builder: this) => void): this;
47
+ /** Apply a reusable group of steps. */
48
+ pipe(cb: (builder: this) => void): this;
49
+ build(): string;
50
+ }
51
+ declare function dockerfile(): DockerfileBuilder;
52
+ interface DockerPackageManager {
53
+ image: string;
54
+ /** pnpm and yarn ship through corepack; bun and npm don't. */
55
+ corepack: boolean;
56
+ install: string;
57
+ installProd: string;
58
+ /** Glob(s) to COPY so the install layer re-caches only on lockfile changes. */
59
+ lockfiles: string[];
60
+ }
61
+ declare function dockerPackageManager(name: string, {
62
+ frozenLockfile
63
+ }: {
64
+ frozenLockfile: boolean;
65
+ }): DockerPackageManager;
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
14
127
  //#region src/format.d.ts
15
128
  declare function formatCode(code: string, options: {
16
129
  filepath: string;
@@ -1078,30 +1191,6 @@ interface Yaml extends Literal {
1078
1191
  */
1079
1192
  interface YamlData extends Data {}
1080
1193
  //#endregion
1081
- //#region src/types.d.ts
1082
- type ContentGetter = () => string | Promise<string>;
1083
- interface VikeMeta {
1084
- BATI: BatiSet;
1085
- BATI_TEST?: boolean;
1086
- BATI_SKIP_GIT?: boolean;
1087
- BATI_IS_CI?: boolean;
1088
- }
1089
- type TransformerProps = {
1090
- readfile?: ContentGetter;
1091
- target: string;
1092
- source: string;
1093
- meta: VikeMeta;
1094
- packageJson: PackageJson;
1095
- };
1096
- type Transformer = (props: TransformerProps) => unknown;
1097
- interface PackageJson {
1098
- dependencies?: Record<string, string>;
1099
- devDependencies?: Record<string, string>;
1100
- }
1101
- interface StringTransformer {
1102
- finalize(): string;
1103
- }
1104
- //#endregion
1105
1194
  //#region src/markdown/utils.d.ts
1106
1195
  /**
1107
1196
  * Parse a comment marker.
@@ -1235,6 +1324,14 @@ declare function loadYaml({
1235
1324
  fallbackEmpty?: boolean;
1236
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>>;
1237
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
1238
1335
  //#region src/parse/linters/common.d.ts
1239
1336
  type AllowedContextFlags = "include-if-imported";
1240
1337
  interface FileContext {
@@ -1266,11 +1363,8 @@ declare function getVersion(): {
1266
1363
  version: string;
1267
1364
  semver: string[];
1268
1365
  };
1269
- //#endregion
1270
- //#region src/utils/env.d.ts
1271
- declare function appendToEnv(envContent: string | undefined | null, key: string, value: unknown, comment?: string): string;
1272
1366
  declare namespace index_d_exports {
1273
- export { ContentGetter, FileContext, MarkdownV2, PackageJson, PackageManagerInfo, StringTransformer, Transformer, TransformerProps, VikeMeta, YAMLDocument, addVitePlugin, appendToEnv, builders, deepMergeObject, formatCode, generateCode, getArgs, getVersion, loadAsJson, loadAsMagicast, loadFile, loadMarkdown, loadPackageJson, loadRelativeFileAsMagicast, loadYaml, packageManager, parseMarkdown, parseModule, randomBytes, transformAndFormat, which, withIcon };
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 };
1274
1368
  }
1275
1369
  //#endregion
1276
- export { ContentGetter, type FileContext, MarkdownV2, PackageJson, PackageManagerInfo, StringTransformer, Transformer, TransformerProps, VikeMeta, type YAMLDocument, addVitePlugin, appendToEnv, builders, deepMergeObject, formatCode, generateCode, getArgs, getVersion, loadAsJson, loadAsMagicast, loadFile, loadMarkdown, loadPackageJson, loadRelativeFileAsMagicast, loadYaml, packageManager, parseMarkdown, parseModule, randomBytes, transformAndFormat, which, withIcon };
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 };