@deltabox/toolchain 0.0.0-stage → 1.1.21
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/CHANGELOG.md +314 -0
- package/LICENSE +373 -0
- package/README.md +235 -2
- package/dist/_virtual/_rolldown/runtime.js +1 -0
- package/dist/biome.d.ts +4 -0
- package/dist/biome.js +1 -0
- package/dist/changelog.d.ts +17 -0
- package/dist/changelog.js +1 -0
- package/dist/cli/commands/index.js +1 -0
- package/dist/cli/commands/projects.js +1 -0
- package/dist/cli/commands/providers.js +1 -0
- package/dist/cli/commands/reset.js +1 -0
- package/dist/cli/commands/shared.js +1 -0
- package/dist/cli/commands/sync.js +1 -0
- package/dist/cli/commands/watch.js +1 -0
- package/dist/cli/context.js +1 -0
- package/dist/cli/index.d.ts +15 -0
- package/dist/cli/index.js +2 -0
- package/dist/cli/options.js +1 -0
- package/dist/cli/register.d.ts +14 -0
- package/dist/cli/register.js +1 -0
- package/dist/config.d.ts +18 -0
- package/dist/config.js +1 -0
- package/dist/core.d.ts +13 -0
- package/dist/core.js +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.js +1 -0
- package/dist/migrate.d.ts +15 -0
- package/dist/migrate.js +1 -0
- package/dist/package.js +1 -0
- package/dist/packages/biome/src/config.js +1 -0
- package/dist/packages/biome/src/index.d.ts +34 -0
- package/dist/packages/biome/src/index.js +1 -0
- package/dist/packages/biome/src/vscode-settings.js +1 -0
- package/dist/packages/changelog/src/cli/index.d.ts +8 -0
- package/dist/packages/changelog/src/cli/index.js +1 -0
- package/dist/packages/changelog/src/index.d.ts +19 -0
- package/dist/packages/changelog/src/index.js +1 -0
- package/dist/packages/changelog/src/run-workflows.d.ts +35 -0
- package/dist/packages/changelog/src/run-workflows.js +1 -0
- package/dist/packages/changelog/src/run.d.ts +14 -0
- package/dist/packages/changelog/src/run.js +1 -0
- package/dist/packages/changelog/src/sync.d.ts +18 -0
- package/dist/packages/changelog/src/sync.js +1 -0
- package/dist/packages/changelog/src/templates.d.ts +27 -0
- package/dist/packages/changelog/src/templates.js +27 -0
- package/dist/packages/changelog/src/utils/args.d.ts +7 -0
- package/dist/packages/changelog/src/utils/args.js +1 -0
- package/dist/packages/changelog/src/utils/format.d.ts +27 -0
- package/dist/packages/changelog/src/utils/format.js +5 -0
- package/dist/packages/changelog/src/utils/git.d.ts +9 -0
- package/dist/packages/changelog/src/utils/git.js +1 -0
- package/dist/packages/changelog/src/utils/packages.js +4 -0
- package/dist/packages/changelog/src/utils/reformat.d.ts +9 -0
- package/dist/packages/changelog/src/utils/reformat.js +6 -0
- package/dist/packages/changelog/src/utils/repo.js +1 -0
- package/dist/packages/changelog/src/utils/summary.d.ts +7 -0
- package/dist/packages/changelog/src/utils/summary.js +1 -0
- package/dist/packages/changelog/src/utils/types.d.ts +58 -0
- package/dist/packages/changelog/src/utils/version.d.ts +6 -0
- package/dist/packages/changelog/src/utils/version.js +14 -0
- package/dist/packages/changelog/src/utils/write.js +1 -0
- package/dist/packages/changelog/src/workflows.d.ts +53 -0
- package/dist/packages/changelog/src/workflows.js +5 -0
- package/dist/packages/config/src/cli/index.d.ts +28 -0
- package/dist/packages/config/src/cli/index.js +1 -0
- package/dist/packages/config/src/collect.d.ts +19 -0
- package/dist/packages/config/src/collect.js +1 -0
- package/dist/packages/config/src/config-json.d.ts +33 -0
- package/dist/packages/config/src/config-json.js +1 -0
- package/dist/packages/config/src/engine.d.ts +56 -0
- package/dist/packages/config/src/engine.js +1 -0
- package/dist/packages/config/src/env-file.d.ts +33 -0
- package/dist/packages/config/src/env-file.js +3 -0
- package/dist/packages/config/src/env.d.ts +31 -0
- package/dist/packages/config/src/env.js +1 -0
- package/dist/packages/config/src/generators/cli.d.ts +78 -0
- package/dist/packages/config/src/generators/cli.js +1 -0
- package/dist/packages/config/src/generators/env.d.ts +42 -0
- package/dist/packages/config/src/generators/env.js +23 -0
- package/dist/packages/config/src/generators/index.d.ts +8 -0
- package/dist/packages/config/src/generators/index.js +1 -0
- package/dist/packages/config/src/generators/json.d.ts +24 -0
- package/dist/packages/config/src/generators/json.js +1 -0
- package/dist/packages/config/src/generators/markdown.d.ts +77 -0
- package/dist/packages/config/src/generators/markdown.js +27 -0
- package/dist/packages/config/src/generators/types.d.ts +32 -0
- package/dist/packages/config/src/generators/types.js +1 -0
- package/dist/packages/config/src/index.d.ts +21 -0
- package/dist/packages/config/src/index.js +1 -0
- package/dist/packages/config/src/root.d.ts +11 -0
- package/dist/packages/config/src/root.js +1 -0
- package/dist/packages/config/src/schema.d.ts +34 -0
- package/dist/packages/config/src/schema.js +1 -0
- package/dist/packages/config/src/types.d.ts +75 -0
- package/dist/packages/config/src/types.js +1 -0
- package/dist/packages/core/src/graph.d.ts +55 -0
- package/dist/packages/core/src/graph.js +1 -0
- package/dist/packages/core/src/index.d.ts +16 -0
- package/dist/packages/core/src/index.js +1 -0
- package/dist/packages/core/src/loader.d.ts +27 -0
- package/dist/packages/core/src/loader.js +1 -0
- package/dist/packages/core/src/manifest.d.ts +17 -0
- package/dist/packages/core/src/manifest.js +1 -0
- package/dist/packages/core/src/project-type.d.ts +14 -0
- package/dist/packages/core/src/project-type.js +1 -0
- package/dist/packages/core/src/reset.d.ts +51 -0
- package/dist/packages/core/src/reset.js +1 -0
- package/dist/packages/core/src/select.d.ts +32 -0
- package/dist/packages/core/src/select.js +1 -0
- package/dist/packages/core/src/sync.d.ts +42 -0
- package/dist/packages/core/src/sync.js +1 -0
- package/dist/packages/core/src/vscode.d.ts +27 -0
- package/dist/packages/core/src/vscode.js +1 -0
- package/dist/packages/core/src/watch.d.ts +17 -0
- package/dist/packages/core/src/watch.js +1 -0
- package/dist/packages/migrate/src/biome.d.ts +18 -0
- package/dist/packages/migrate/src/biome.js +2 -0
- package/dist/packages/migrate/src/check.d.ts +14 -0
- package/dist/packages/migrate/src/check.js +1 -0
- package/dist/packages/migrate/src/cli/index.d.ts +12 -0
- package/dist/packages/migrate/src/cli/index.js +1 -0
- package/dist/packages/migrate/src/dprint.d.ts +18 -0
- package/dist/packages/migrate/src/dprint.js +1 -0
- package/dist/packages/migrate/src/eslint.d.ts +24 -0
- package/dist/packages/migrate/src/eslint.js +1 -0
- package/dist/packages/migrate/src/index.d.ts +14 -0
- package/dist/packages/migrate/src/index.js +1 -0
- package/dist/packages/migrate/src/oxfmt-map.d.ts +28 -0
- package/dist/packages/migrate/src/oxfmt-map.js +1 -0
- package/dist/packages/migrate/src/oxlint-map.d.ts +22 -0
- package/dist/packages/migrate/src/oxlint-map.js +1 -0
- package/dist/packages/migrate/src/prettier.d.ts +20 -0
- package/dist/packages/migrate/src/prettier.js +2 -0
- package/dist/packages/migrate/src/registry.d.ts +26 -0
- package/dist/packages/migrate/src/registry.js +1 -0
- package/dist/packages/migrate/src/types.d.ts +75 -0
- package/dist/packages/migrate/src/vite-target.d.ts +31 -0
- package/dist/packages/migrate/src/vite-target.js +5 -0
- package/dist/packages/project/src/cli/index.d.ts +8 -0
- package/dist/packages/project/src/cli/index.js +1 -0
- package/dist/packages/project/src/config.d.ts +55 -0
- package/dist/packages/project/src/config.js +1 -0
- package/dist/packages/project/src/index.d.ts +10 -0
- package/dist/packages/project/src/index.js +1 -0
- package/dist/packages/project/src/typescript.d.ts +66 -0
- package/dist/packages/project/src/typescript.js +22 -0
- package/dist/packages/shared/src/config-schema.d.ts +2039 -0
- package/dist/packages/shared/src/config-schema.js +1 -0
- package/dist/packages/shared/src/fs-utils.d.ts +18 -0
- package/dist/packages/shared/src/fs-utils.js +1 -0
- package/dist/packages/shared/src/index.d.ts +17 -0
- package/dist/packages/shared/src/index.js +1 -0
- package/dist/packages/shared/src/object-utils.d.ts +15 -0
- package/dist/packages/shared/src/object-utils.js +1 -0
- package/dist/packages/shared/src/provider.d.ts +66 -0
- package/dist/packages/shared/src/provider.js +1 -0
- package/dist/packages/shared/src/run.d.ts +26 -0
- package/dist/packages/shared/src/run.js +1 -0
- package/dist/packages/shared/src/string-utils.d.ts +52 -0
- package/dist/packages/shared/src/string-utils.js +3 -0
- package/dist/packages/shared/src/template.d.ts +53 -0
- package/dist/packages/shared/src/template.js +1 -0
- package/dist/packages/shared/src/toolchain.d.ts +159 -0
- package/dist/packages/shared/src/toolchain.js +1 -0
- package/dist/packages/shared/src/types.d.ts +100 -0
- package/dist/packages/shared/src/yaml.d.ts +17 -0
- package/dist/packages/shared/src/yaml.js +5 -0
- package/dist/packages/template/src/builtin.d.ts +10 -0
- package/dist/packages/template/src/builtin.js +1 -0
- package/dist/packages/template/src/cli/index.d.ts +8 -0
- package/dist/packages/template/src/cli/index.js +1 -0
- package/dist/packages/template/src/index.d.ts +10 -0
- package/dist/packages/template/src/index.js +1 -0
- package/dist/packages/template/src/local.d.ts +20 -0
- package/dist/packages/template/src/local.js +1 -0
- package/dist/packages/template/src/online.d.ts +17 -0
- package/dist/packages/template/src/online.js +1 -0
- package/dist/packages/template/src/registry.d.ts +48 -0
- package/dist/packages/template/src/registry.js +1 -0
- package/dist/packages/template/src/scaffold.d.ts +25 -0
- package/dist/packages/template/src/scaffold.js +1 -0
- package/dist/packages/template/src/types.d.ts +59 -0
- package/dist/packages/tsconfig/src/cli/generate/index.d.ts +35 -0
- package/dist/packages/tsconfig/src/cli/generate/index.js +1 -0
- package/dist/packages/tsconfig/src/cli/generate/utils.d.ts +43 -0
- package/dist/packages/tsconfig/src/cli/generate/utils.js +1 -0
- package/dist/packages/tsconfig/src/cli/index.d.ts +11 -0
- package/dist/packages/tsconfig/src/cli/index.js +1 -0
- package/dist/packages/tsconfig/src/index.d.ts +10 -0
- package/dist/packages/tsconfig/src/index.js +1 -0
- package/dist/packages/tsconfig/src/sync.d.ts +15 -0
- package/dist/packages/tsconfig/src/sync.js +1 -0
- package/dist/packages/tsconfig/src/templates/tsconfig.base.js +1 -0
- package/dist/packages/tsconfig/src/templates/tsconfig.build.js +1 -0
- package/dist/packages/tsconfig/src/templates/tsconfig.default.js +1 -0
- package/dist/packages/tsconfig/src/templates.d.ts +38 -0
- package/dist/packages/tsconfig/src/templates.js +1 -0
- package/dist/packages/tsdown/src/cleanup.d.ts +17 -0
- package/dist/packages/tsdown/src/cleanup.js +1 -0
- package/dist/packages/tsdown/src/cli/index.d.ts +11 -0
- package/dist/packages/tsdown/src/cli/index.js +1 -0
- package/dist/packages/tsdown/src/config/node.d.ts +37 -0
- package/dist/packages/tsdown/src/config/node.js +3 -0
- package/dist/packages/tsdown/src/index.d.ts +9 -0
- package/dist/packages/tsdown/src/index.js +1 -0
- package/dist/packages/vite/src/cli/index.d.ts +8 -0
- package/dist/packages/vite/src/cli/index.js +1 -0
- package/dist/packages/vite/src/commands.d.ts +29 -0
- package/dist/packages/vite/src/commands.js +1 -0
- package/dist/packages/vite/src/index.d.ts +9 -0
- package/dist/packages/vite/src/index.js +1 -0
- package/dist/packages/vite/src/plugin.d.ts +65 -0
- package/dist/packages/vite/src/plugin.js +1 -0
- package/dist/packages/vite/src/provider.d.ts +11 -0
- package/dist/packages/vite/src/provider.js +1 -0
- package/dist/packages/vite/src/sync.d.ts +25 -0
- package/dist/packages/vite/src/sync.js +2 -0
- package/dist/packages/vite/src/vp.d.ts +59 -0
- package/dist/packages/vite/src/vp.js +1 -0
- package/dist/project.d.ts +7 -0
- package/dist/project.js +1 -0
- package/dist/providers.d.ts +11 -0
- package/dist/providers.js +1 -0
- package/dist/shared.d.ts +14 -0
- package/dist/shared.js +1 -0
- package/dist/sync.d.ts +12 -0
- package/dist/sync.js +1 -0
- package/dist/template.d.ts +11 -0
- package/dist/template.js +1 -0
- package/dist/tsconfig.d.ts +8 -0
- package/dist/tsconfig.js +1 -0
- package/dist/tsdown.d.ts +7 -0
- package/dist/tsdown.js +1 -0
- package/dist/vite.d.ts +10 -0
- package/dist/vite.js +1 -0
- package/package.json +114 -3
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { CommitRecord } from "./types.js";
|
|
4
|
+
//#region packages/changelog/src/utils/summary.d.ts
|
|
5
|
+
/** Render the grouped changelog summary for a set of commits. */
|
|
6
|
+
export declare function buildSummary(records: CommitRecord[]): string;
|
|
7
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;import{recordIssues as e,renderAuthor as t,renderIssues as n,repoSlug as r,resolveAuthorInfo as i}from"./git.js";import{capitalize as a,formatBody as o,groupItems as s,parseCcSubject as c,renderGroups as l}from"./format.js";function u(u){let d=r(),f=s(u.map(r=>{let s=c(r.subject),l=r.hash.slice(0,7),u=t(i(r,d));return{parsed:s,text:`- ${a(s.rest)} ([#${l}](https://github.com/${d}/commit/${r.hash}) by ${u})${n(e(r,d))}`,bodyParagraphs:o(r.body)}}));return l(f)}export{u as buildSummary};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
//#region packages/changelog/src/utils/types.d.ts
|
|
4
|
+
/** Shared types for the changelog pipeline. */
|
|
5
|
+
export type BumpType = 'major' | 'minor' | 'patch';
|
|
6
|
+
export type ProcessingMethod = 'latest' | 'all' | string;
|
|
7
|
+
export interface CommitRecord {
|
|
8
|
+
hash: string;
|
|
9
|
+
subject: string;
|
|
10
|
+
body: string;
|
|
11
|
+
author: string;
|
|
12
|
+
authorEmail: string;
|
|
13
|
+
}
|
|
14
|
+
export interface AuthorInfo {
|
|
15
|
+
name: string;
|
|
16
|
+
url?: string;
|
|
17
|
+
}
|
|
18
|
+
export interface IssueInfo {
|
|
19
|
+
number: number;
|
|
20
|
+
title?: string;
|
|
21
|
+
url?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface CliOptions {
|
|
24
|
+
range: string;
|
|
25
|
+
dryRun: boolean;
|
|
26
|
+
version?: string;
|
|
27
|
+
baseVersion?: string;
|
|
28
|
+
processingMethod: ProcessingMethod;
|
|
29
|
+
formatOnly: boolean;
|
|
30
|
+
/** Include the `### Package changes` footer (disable with --no-package-changes-section). */
|
|
31
|
+
packageChanges: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** A Conventional-Commits subject parsed into its parts. */
|
|
34
|
+
export interface ParsedCommit {
|
|
35
|
+
type: string;
|
|
36
|
+
scope?: string;
|
|
37
|
+
breaking: boolean;
|
|
38
|
+
/** Everything after the `type(scope):` prefix (subject + link/author suffix). */
|
|
39
|
+
rest: string;
|
|
40
|
+
}
|
|
41
|
+
/** A list of parsed commits grouped by CC rule, then by scope. */
|
|
42
|
+
export interface GroupedRule {
|
|
43
|
+
title: string;
|
|
44
|
+
ungrouped: GroupedItem[];
|
|
45
|
+
scopes: Map<string, GroupedItem[]>;
|
|
46
|
+
}
|
|
47
|
+
export interface GroupedItem {
|
|
48
|
+
parsed: ParsedCommit;
|
|
49
|
+
text: string;
|
|
50
|
+
/** Description paragraphs; each becomes one nested bullet with wrapped continuations. */
|
|
51
|
+
bodyParagraphs: string[][];
|
|
52
|
+
}
|
|
53
|
+
/** A `## <version>` section parsed out of an existing changelog. */
|
|
54
|
+
export interface ExistingEntry {
|
|
55
|
+
version: string;
|
|
56
|
+
bullets: string[];
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
//#region packages/changelog/src/utils/version.d.ts
|
|
4
|
+
/** Render a `## <version> (Month Year)` heading + summary, optionally marked. */
|
|
5
|
+
export declare function renderChangelogEntry(version: string, summary: string, date?: Date, withMarkers?: boolean, packageChanges?: string): string;
|
|
6
|
+
//#endregion
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import{resolve as e}from"node:path";import"node:url";import.meta.url;import{discoverWorkspaceDirs as t,repoRoot as n}from"./repo.js";import{existsSync as r,readFileSync as i,writeFileSync as a}from"node:fs";function o(e){return`${e.toLocaleString(`en-US`,{month:`long`})} ${e.getFullYear()}`}function s(e,t){let n=/^(\d+)\.(\d+)\.(\d+)/.exec(e);if(!n)throw Error(`Cannot parse version "${e}"`);let r=Number(n[1]),i=Number(n[2]),a=Number(n[3]);return t===`major`?(r+=1,i=0,a=0):t===`minor`?(i+=1,a=0):a+=1,`${r}.${i}.${a}`}function c(e,t,n,r=!0,i=``){let a=n?` (${o(n)})`:``,s=i?`${t}\n\n${i}`:t;return r?`## ${e}${a}
|
|
2
|
+
|
|
3
|
+
<!-- release:start -->
|
|
4
|
+
|
|
5
|
+
${s}
|
|
6
|
+
|
|
7
|
+
<!-- release:end -->`:`## ${e}${a}\n\n${s}`}function l(e,t){let n=e.split(`
|
|
8
|
+
`).filter(e=>!e.includes(`<!-- release:start -->`)&&!e.includes(`<!-- release:end -->`)).join(`
|
|
9
|
+
`).trimEnd().replace(/\n{3,}/g,`
|
|
10
|
+
|
|
11
|
+
`),r=n.split(`
|
|
12
|
+
`),i=r[0],a;return a=i!==void 0&&i.startsWith(`# `)?[i,``,t.trimEnd(),``,...r.slice(1)].join(`
|
|
13
|
+
`):`${t.trimEnd()}\n\n${n}`,`${a.trimEnd()}\n`}function u(e,t){let n=r(e)?i(e,`utf8`):`# Changelog
|
|
14
|
+
`;a(e,l(n,t),`utf8`)}function d(o,s){let c=n(),l=[e(c,`CHANGELOG.md`),...t().map(t=>e(t,`CHANGELOG.md`))];for(let e of l){if(!r(e))continue;let t=i(e,`utf8`),n=t.replace(`## ${o}`,`## ${s}`);n!==t&&(a(e,n,`utf8`),console.log(` retagged ${e}`))}}export{s as bumpVersion,l as insertNewEntry,o as monthYear,u as prependChangelogEntry,c as renderChangelogEntry,d as retagChangelogs};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{relative as e,resolve as t}from"node:path";import"node:url";import.meta.url;import{readCommits as n,repoSlug as r}from"./git.js";import{discoverWorkspaceDirs as i,repoRoot as a}from"./repo.js";import{packageChangesForCurrent as o}from"./packages.js";import{formatChangelogFile as s}from"./format.js";import{prependChangelogEntry as c,renderChangelogEntry as l}from"./version.js";import{parseExistingChangelog as u,reformatRootChangelog as d}from"./reformat.js";import{buildSummary as f}from"./summary.js";import{existsSync as p,readFileSync as m,writeFileSync as h}from"node:fs";function g(g,_,v,y,b,x=!1){let S=a(),C=r(),w=t(S,`CHANGELOG.md`),T=``;if(x&&p(w)){let e=u(m(w,`utf8`))[0];e&&(T=o(e.version))}if(b){let e=d(x);e&&(h(w,e,`utf8`),console.log(` reformatted ${w}`))}let E=l(g,y,/* @__PURE__ */ new Date,!0,T);c(w,E),console.log(` updated ${w}`);for(let r of i()){if(t(r)===t(S))continue;let i=t(r,`CHANGELOG.md`);if(!p(i))continue;let a=e(S,r).replace(/\\/g,`/`),o=n(_,a);if(o.length===0){console.log(` skipped ${i} (no commits in ${a})`);continue}let s=f(o);c(i,l(g,s,/* @__PURE__ */ new Date)),console.log(` updated ${i}`)}for(let e of[t(S,`CHANGELOG.md`),...i().filter(e=>t(e)!==t(S)).map(e=>t(e,`CHANGELOG.md`)).filter(e=>p(e))])s(e,C)}export{g as writeChangelogs};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { Replacements } from "../../shared/src/template.js";
|
|
4
|
+
import { WorkflowConfig, WorkflowSetting, WorkflowStep } from "../../shared/src/config-schema.js";
|
|
5
|
+
import "../../shared/src/index.js";
|
|
6
|
+
//#region packages/changelog/src/workflows.d.ts
|
|
7
|
+
export interface WorkflowJob {
|
|
8
|
+
name?: string;
|
|
9
|
+
'runs-on': string;
|
|
10
|
+
if?: string;
|
|
11
|
+
needs?: string | string[];
|
|
12
|
+
/** A GitHub environment name (matched by the OIDC trusted publisher). */
|
|
13
|
+
environment?: string;
|
|
14
|
+
permissions?: Record<string, string>;
|
|
15
|
+
env?: Record<string, string>;
|
|
16
|
+
outputs?: Record<string, string>;
|
|
17
|
+
steps: WorkflowStep[];
|
|
18
|
+
}
|
|
19
|
+
export interface Workflow {
|
|
20
|
+
name: string;
|
|
21
|
+
on: Record<string, unknown>;
|
|
22
|
+
permissions?: Record<string, string>;
|
|
23
|
+
concurrency?: unknown;
|
|
24
|
+
env?: Record<string, string>;
|
|
25
|
+
jobs: Record<string, WorkflowJob>;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
/** The default replacement values for the workflow templates. */
|
|
29
|
+
export declare const DEFAULT_WORKFLOW_TOKENS: Replacements;
|
|
30
|
+
/** The workflow ids the builder knows about. */
|
|
31
|
+
export type WorkflowId = 'ci' | 'changelog' | 'release' | 'sync' | 'issues';
|
|
32
|
+
/** Default file name per workflow id. */
|
|
33
|
+
export declare const WORKFLOW_FILENAMES: Record<WorkflowId, string>;
|
|
34
|
+
/** Whether a workflow setting enables the workflow (default true). */
|
|
35
|
+
export declare function isEnabled(setting: WorkflowSetting | undefined): boolean;
|
|
36
|
+
/** Build all default workflows for a set of tokens. */
|
|
37
|
+
export declare function defaultWorkflows(tokens: Replacements): Record<WorkflowId, Workflow>;
|
|
38
|
+
/** Merge a consumer's {@link WorkflowConfig} over a default workflow. */
|
|
39
|
+
export declare function applyWorkflowConfig(workflow: Workflow, config?: WorkflowConfig): Workflow;
|
|
40
|
+
export interface RenderWorkflowOptions {
|
|
41
|
+
/** Base replacement tokens (merged with the workflow's own `tokens`). */
|
|
42
|
+
tokens: Replacements;
|
|
43
|
+
/** The consumer's per-workflow config. */
|
|
44
|
+
config?: WorkflowConfig;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Build one workflow as a YAML string, applying the consumer's config. Returns
|
|
48
|
+
* `undefined` when the workflow is disabled.
|
|
49
|
+
*/
|
|
50
|
+
export declare function renderWorkflow(id: WorkflowId, options: RenderWorkflowOptions): string | undefined;
|
|
51
|
+
/** Render every workflow, keyed by file name (disabled ones are omitted). */
|
|
52
|
+
export declare function renderWorkflows(tokens: Replacements, workflows?: Partial<Record<WorkflowId, WorkflowSetting>>): Record<string, string>;
|
|
53
|
+
//#endregion
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;import{applyReplacementsDeep as e}from"../../shared/src/template.js";import{toYaml as t}from"../../shared/src/yaml.js";import"../../shared/src/index.js";const n={nodeVersion:`22`,yarnVersion:`4.17.1`,packageManager:`yarn`,mainBranch:`main`,devBranch:`dev`,tooling:`dbx`},r={ci:`ci.yml`,changelog:`changelog.yml`,release:`release.yml`,sync:`sync.yml`,issues:`issues.yml`};function i(e){return e===void 0?!0:typeof e==`boolean`?e:e.enabled!==!1}function a(e){return`${e.packageManager} ${e.tooling}`}function o(e){return[{name:`Checkout`,uses:`actions/checkout@v4`,with:{"fetch-depth":0,token:"${{ secrets.GITHUB_TOKEN }}"}},{name:`Setup Node`,uses:`actions/setup-node@v4`,with:{"node-version":String(e.nodeVersion)}},{name:`Enable Corepack`,run:`corepack enable\ncorepack prepare ${e.packageManager}@${e.yarnVersion} --activate`},{name:`Install dependencies`,run:`${e.packageManager} install --immutable`}]}function s(e){let t=a(e),n=String(e.mainBranch),r=String(e.devBranch);return{ci:{name:`CI`,on:{push:{branches:[n]},pull_request:{branches:[`release/**`,`feat/**`,`feature/**`,`fix/**`,`chore/**`]}},jobs:{ci:{"runs-on":`ubuntu-latest`,steps:[...o(e),{name:`Commitlint (Conventional Commits)`,if:"${{ github.event_name == 'pull_request' || github.event.before != '0000000000000000000000000000000000000000' }}",run:`set -euo pipefail\nbase="\${{ github.event.pull_request.base.sha || github.event.before }}"\nhead="\${{ github.event.pull_request.head.sha || github.event.after }}"\n${e.packageManager} commitlint --from "$base" --to "$head"`},{name:`Verify generated files are in sync`,run:`${t} sync --check`},{name:`Build`,run:`${e.packageManager} build`}]}}},changelog:{name:`Changelog (dev)`,on:{push:{branches:[r]}},permissions:{contents:`write`},concurrency:{group:`changelog-dev`,"cancel-in-progress":!1},jobs:{"generate-changelog":{"runs-on":`ubuntu-latest`,if:`!startsWith(github.event.head_commit.message, 'chore: version packages ') && !startsWith(github.event.head_commit.message, 'release: ')`,env:{GITHUB_TOKEN:"${{ secrets.GITHUB_TOKEN }}"},steps:[...o(e),{name:`Generate changelog + bump versions`,env:{GITHUB_TOKEN:"${{ secrets.GITHUB_TOKEN }}"},run:[`set -euo pipefail`,'after="${{ github.event.after }}"; [ -n "$after" ] || after="HEAD"',`boundary="$(git log --format=%H --grep='^chore: version packages ' -1 || true)"`,`if [ -n "$boundary" ]; then range="$boundary..$after"; else range="$after"; fi`,`${t} changelog --range "$range"`].join(`
|
|
2
|
+
`)},{name:`Commit + push changelog updates`,env:{GITHUB_TOKEN:"${{ secrets.GITHUB_TOKEN }}"},run:[`set -euo pipefail`,`git diff --quiet && { echo "No changelog changes."; exit 0; }`,`git config user.name "github-actions[bot]"`,`git config user.email "41898282+github-actions[bot]@users.noreply.github.com"`,`git add -u -- "*package.json" "*CHANGELOG.md"`,`git commit -m "chore: version packages ($(node -p "require('./package.json').version"))"`,`git push origin ${r}`].join(`
|
|
3
|
+
`)}]}}},release:{name:`Release`,on:{push:{branches:[n]},workflow_dispatch:null},permissions:{contents:`write`,"pull-requests":`write`},concurrency:{group:`release`,"cancel-in-progress":!1},jobs:{"create-release-pr":{"runs-on":`ubuntu-latest`,if:`(github.event_name == 'push' || github.event_name == 'workflow_dispatch') && !startsWith(github.event.head_commit.message, 'chore: version packages ') && !startsWith(github.event.head_commit.message, 'release: ')`,env:{GITHUB_TOKEN:"${{ secrets.GITHUB_TOKEN }}"},steps:[...o(e),{name:`Open release PR`,env:{GITHUB_TOKEN:"${{ secrets.GITHUB_TOKEN }}"},run:[`set -euo pipefail`,`version="$(node -p "require('./package.json').version")"`,`branch="release/$version"`,`if git ls-remote --exit-code --heads origin "$branch" >/dev/null 2>&1; then`,` echo "Release PR already open for $version."; exit 0`,`fi`,`git config user.name "github-actions[bot]"`,`git config user.email "41898282+github-actions[bot]@users.noreply.github.com"`,`git checkout -b "$branch"`,`git add -A`,`git commit -m "chore: version packages ($version)" || true`,`git push origin "$branch"`,`notes="$(awk '/<!-- release:start -->/{f=1;next} /<!-- release:end -->/{exit} f{print}' CHANGELOG.md 2>/dev/null || true)"`,`[ -n "$notes" ] || notes="Release $version"`,`gh pr create --base ${n} --head "$branch" --title "release: $version" --body "$notes"`].join(`
|
|
4
|
+
`)}]}}},sync:{name:`Tooling sync`,on:{push:{branches:[n,r]},pull_request:null},jobs:{sync:{"runs-on":`ubuntu-latest`,steps:[...o(e),{name:`Verify generated files are in sync`,run:`${t} sync --check`}]}}},issues:{name:`Issues`,on:{issues:{types:[`opened`]}},permissions:{issues:`write`},jobs:{"enforce-title":{"runs-on":`ubuntu-latest`,steps:[{name:`Check and rename issue title`,env:{GH_TOKEN:"${{ github.token }}",ISSUE_NUMBER:"${{ github.event.issue.number }}"},run:[`set -euo pipefail`,`labels=$(gh issue view "$ISSUE_NUMBER" --json labels -q '.labels[].name' || true)`,`title=$(gh issue view "$ISSUE_NUMBER" --json title -q '.title')`,`type=""`,`for label in $labels; do case "$label" in *bug*) type="bug" ;; esac; done`,`if [ -z "$type" ]; then for label in $labels; do case "$label" in *enhancement*|*feature*|*feat*) type="feat" ;; esac; done; fi`,`if [ -z "$type" ]; then echo "No bug/enhancement label on issue #$ISSUE_NUMBER; skipping."; exit 0; fi`,`prefix="[bug]"; [ "$type" = "feat" ] && prefix="[feat]"`,`stripped=$(printf '%s' "$title" | sed -E 's/^\\[(bug|feat)\\] *//i')`,`new_title="$prefix $stripped"`,`if [ "$new_title" = "$title" ]; then echo "Issue #$ISSUE_NUMBER title already conforms."; exit 0; fi`,`gh issue edit "$ISSUE_NUMBER" --title "$new_title"`].join(`
|
|
5
|
+
`)}]}}}}}function c(e){return e.steps?Array.isArray(e.steps)?e.steps:[e.steps]:[]}function l(e,t={}){let n=structuredClone(e);if(t.pushBranches){let e=n.on.push??{};n.on.push={...e,branches:t.pushBranches}}if(t.pullRequestBranches){let e=n.on.pull_request??{};n.on.pull_request={...e,branches:t.pullRequestBranches}}t.triggers&&(n.on={...n.on,...t.triggers}),t.extra&&Object.assign(n,t.extra),t.jobs&&(n.jobs={...n.jobs,...t.jobs});let r=Object.keys(n.jobs)[0];for(let e of c(t)){let t=e.job??r;if(!t)continue;let i=n.jobs[t];i&&(i.steps=[...e.before??[],...i.steps,...e.after??[]])}return n}function u(r,i){let a=i.config??{};if(a.enabled===!1)return;let o={...n,...i.tokens,...a.tokens},c=s(o)[r],u=e(l(c,a),o);return t(u)}function d(e,t={}){let n={};for(let a of Object.keys(r)){let o=t[a];if(!i(o))continue;let s=u(a,{tokens:e,config:typeof o==`object`?o:{}});s&&(n[r[a]]=s)}return n}export{n as DEFAULT_WORKFLOW_TOKENS,r as WORKFLOW_FILENAMES,l as applyWorkflowConfig,s as defaultWorkflows,i as isEnabled,u as renderWorkflow,d as renderWorkflows};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { ToolingCommand } from "../../../shared/src/types.js";
|
|
4
|
+
import "../../../shared/src/index.js";
|
|
5
|
+
import { ConfigEngine } from "../engine.js";
|
|
6
|
+
//#region packages/config/src/cli/index.d.ts
|
|
7
|
+
/** Default output locations for the config commands. */
|
|
8
|
+
export interface ConfigCommandDefaults {
|
|
9
|
+
/** Where `.env.example[.dev]` are written (default: engine root). */
|
|
10
|
+
envDir?: string;
|
|
11
|
+
/** Where the config + env types are written. */
|
|
12
|
+
typesDir?: string;
|
|
13
|
+
/** Where the markdown reference is written. */
|
|
14
|
+
docsDir?: string;
|
|
15
|
+
/** The JSON Schema output path. */
|
|
16
|
+
schemaPath?: string;
|
|
17
|
+
/** The config metadata output path. */
|
|
18
|
+
configJsonPath?: string;
|
|
19
|
+
/** The CLI options output path. */
|
|
20
|
+
cliOptionsPath?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface ConfigCommandContext {
|
|
23
|
+
engine: ConfigEngine;
|
|
24
|
+
defaults?: ConfigCommandDefaults;
|
|
25
|
+
}
|
|
26
|
+
/** Build the config commands bound to a consumer's engine. */
|
|
27
|
+
export declare function configCommands(ctx: ConfigCommandContext): ToolingCommand[];
|
|
28
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as e}from"node:path";import"node:url";import.meta.url;import t from"node:fs";function n(t,n){return e.resolve(t??n)}function r(r){let{engine:i}=r,a=r.defaults??{};return[{name:`config:env`,description:`Generate .env.example from the config schemas.`,options:[{flags:`-o, --out <dir>`,description:`Output directory.`}],run:({out:t})=>{let r=e.join(n(t,a.envDir??i.root),`.env.example`);i.writeEnvFile({output:r}),console.log(`Generated ${e.relative(process.cwd(),r)}`)}},{name:`config:types`,description:`Generate the config and env types.`,options:[{flags:`-o, --out <dir>`,description:`Output directory.`},{flags:`--env`,description:`Also write the env type files.`}],run:({out:t,env:r})=>{let o=n(t,a.typesDir??i.root),s=i.writeConfigTypes({outputDir:o});r&&s.push(...i.writeEnvTypes({outputDir:o}));for(let t of s)console.log(`Generated ${e.relative(process.cwd(),t)}`)}},{name:`config:json`,description:`Generate the config metadata JSON.`,options:[{flags:`-o, --out <file>`,description:`Output file.`}],run:({out:r})=>{let o=n(r,a.configJsonPath??e.join(i.root,`config.json`)),s=i.buildConfigJson();t.mkdirSync(e.dirname(o),{recursive:!0}),t.writeFileSync(o,`${JSON.stringify(s,null,4)}\n`,`utf-8`),console.log(`Generated ${e.relative(process.cwd(),o)}`)}},{name:`config:schema`,description:`Generate the untyped JSON Schema.`,options:[{flags:`-o, --out <file>`,description:`Output file.`}],run:async({out:t})=>{let r=n(t,a.schemaPath??e.join(i.root,`config.schema.json`));await i.writeJsonSchema({output:r}),console.log(`Generated ${e.relative(process.cwd(),r)}`)}},{name:`config:markdown`,description:`Generate the markdown configuration reference.`,options:[{flags:`-o, --out <dir>`,description:`Output directory.`}],run:({out:t})=>{let r=n(t,a.docsDir??e.join(i.root,`docs/reference/configuration`)),o=i.writeMarkdown({outDir:r});for(let t of o)console.log(`Generated ${e.relative(process.cwd(),t)}`)}},{name:`config:cli`,description:`Generate the CLI options JSON.`,options:[{flags:`-o, --out <file>`,description:`Output file.`}],run:({out:t})=>{let r=n(t,a.cliOptionsPath??e.join(i.root,`cli-options.json`));i.generateCliOptions({output:r}),console.log(`Generated ${e.relative(process.cwd(),r)}`)}},{name:`config:all`,description:`Run every config generator.`,options:[{flags:`-o, --out <dir>`,description:`Base output directory.`}],run:async({out:t})=>{let r=n(t,i.root),a=[];a.push(i.writeEnvFile({output:e.join(r,`.env.example`)})),a.push(...i.writeConfigTypes({outputDir:e.join(r,`types`)}),...i.writeEnvTypes({outputDir:e.join(r,`types`)}),...i.writeMarkdown({outDir:e.join(r,`docs/reference/configuration`)})),a.push(await i.writeJsonSchema({output:e.join(r,`config.schema.json`)})),a.push(i.generateCliOptions({output:e.join(r,`cli-options.json`)}));for(let t of a.filter(e=>typeof e==`string`))console.log(`Generated ${e.relative(process.cwd(),t)}`)}}]}export{r as configCommands};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { ConfigScopes, EnvVarDef } from "./types.js";
|
|
4
|
+
//#region packages/config/src/collect.d.ts
|
|
5
|
+
/** The default env-var prefix used when none is configured. */
|
|
6
|
+
export declare const DEFAULT_ENV_PREFIX = "APP_";
|
|
7
|
+
/** Options for {@link collectEnvVars}. */
|
|
8
|
+
export interface CollectEnvVarsOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Custom env-name -> dotted-path derivation, used when a leaf does not set
|
|
11
|
+
* an explicit `path` (eg. to handle dual `PROXIFIED_`/`VITE_` prefixes).
|
|
12
|
+
*/
|
|
13
|
+
envPathOf?: (env: string) => string;
|
|
14
|
+
}
|
|
15
|
+
/** Collect every env-var-backed leaf from the scope schemas. */
|
|
16
|
+
export declare function collectEnvVars(scopes: ConfigScopes, envPrefix?: string, options?: CollectEnvVarsOptions): EnvVarDef[];
|
|
17
|
+
/** Collect the env var names marked `required` for a scope. */
|
|
18
|
+
export declare function collectRequiredEnvVars(scopes: ConfigScopes, scope: string, envPrefix?: string, options?: CollectEnvVarsOptions): string[];
|
|
19
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;import{envMetaOf as e}from"./schema.js";import{envPathOf as t}from"./types.js";const n=`APP_`;function r(e){let t=Array.isArray(e)?e:[e];if(t.includes(`array`))return`array`;if(t.includes(`object`))return`object`;if(t.includes(`boolean`))return`boolean`;if(t.includes(`number`))return`number`;if(t.includes(`string`))return`string`}function i(n,a,o,s){let c=e(n);if(c?.env){let e;try{e=n.toJSONSchema?.()}catch{}a.push({name:c.env,path:c.path??s.envPathOf?.(c.env)??t(c.env,o),...c.description?{description:c.description}:{},...e?.default===void 0?{}:{default:e.default},...c.required?{required:!0}:{},...c.secret?{secret:!0}:{},scope:c.scope??`default`,...c.public?{public:!0}:{},...r(e?.type)?{envType:r(e?.type)}:{}});return}let l=n.shape;if(l)for(let e of Object.values(l))i(e,a,o,s)}function a(e,t=n,r={}){let a=[];for(let[n,o]of Object.entries(e)){let e=a.length;i(o.zodSchema,a,t,r);for(let t=e;t<a.length;t++)(!a[t].scope||a[t].scope==="default")&&(a[t].scope=n)}return a}function o(e,t,r=n,i={}){return a(e,r,i).filter(e=>e.scope===t&&e.required).map(e=>e.name)}export{n as DEFAULT_ENV_PREFIX,a as collectEnvVars,o as collectRequiredEnvVars};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { ConfigScopes } from "./types.js";
|
|
4
|
+
import { CollectEnvVarsOptions } from "./collect.js";
|
|
5
|
+
//#region packages/config/src/config-json.d.ts
|
|
6
|
+
/** A serialized env var entry in `config.json`. */
|
|
7
|
+
export interface ConfigJsonEntry {
|
|
8
|
+
name: string;
|
|
9
|
+
path: string;
|
|
10
|
+
scope: string;
|
|
11
|
+
description?: string;
|
|
12
|
+
default?: unknown;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
secret?: boolean;
|
|
15
|
+
public?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** The generated config metadata document (`config.json`). */
|
|
18
|
+
export interface ConfigJsonDoc {
|
|
19
|
+
$comment: string;
|
|
20
|
+
version: number;
|
|
21
|
+
env: ConfigJsonEntry[];
|
|
22
|
+
}
|
|
23
|
+
export interface BuildConfigJsonOptions {
|
|
24
|
+
/** The env-var prefix (default `APP_`). */
|
|
25
|
+
envPrefix?: string;
|
|
26
|
+
/** Override the `$comment` banner. */
|
|
27
|
+
comment?: string;
|
|
28
|
+
/** Custom env-name -> dotted-path derivation. */
|
|
29
|
+
envPathOf?: CollectEnvVarsOptions['envPathOf'];
|
|
30
|
+
}
|
|
31
|
+
/** Build the config metadata JSON document. */
|
|
32
|
+
export declare function buildConfigJson(scopes: ConfigScopes, options?: BuildConfigJsonOptions): ConfigJsonDoc;
|
|
33
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;import{collectEnvVars as e}from"./collect.js";function t(t,n={}){let r=e(t,n.envPrefix,{envPathOf:n.envPathOf});return{$comment:n.comment??`Generated from the config engine — edit the config schemas instead.`,version:1,env:r.map(e=>({name:e.name,path:e.path,scope:e.scope,...e.description?{description:e.description}:{},...e.default===void 0?{}:{default:e.default},...e.required?{required:!0}:{},...e.secret?{secret:!0}:{},...e.public?{public:!0}:{}}))}}export{t as buildConfigJson};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { ConfigEngineOptions, ConfigScopes, EnvVarDef } from "./types.js";
|
|
4
|
+
import { BuildConfigJsonOptions, ConfigJsonDoc } from "./config-json.js";
|
|
5
|
+
import { EnvFileOptions } from "./env-file.js";
|
|
6
|
+
import { CliOptionDef, GenerateCliOptionsOptions } from "./generators/cli.js";
|
|
7
|
+
import { GenerateEnvTypesOptions } from "./generators/env.js";
|
|
8
|
+
import { GenerateJsonSchemaOptions } from "./generators/json.js";
|
|
9
|
+
import { GenerateMarkdownOptions } from "./generators/markdown.js";
|
|
10
|
+
import { GenerateTypesOptions } from "./generators/types.js";
|
|
11
|
+
//#region packages/config/src/engine.d.ts
|
|
12
|
+
/** The bound, reusable config engine. */
|
|
13
|
+
export interface ConfigEngine {
|
|
14
|
+
readonly scopes: ConfigScopes;
|
|
15
|
+
readonly envPrefix: string;
|
|
16
|
+
readonly baseGroup: string;
|
|
17
|
+
readonly root: string;
|
|
18
|
+
/** Every env-var-backed leaf across the registered scopes. */
|
|
19
|
+
collectEnvVars(): EnvVarDef[];
|
|
20
|
+
/** The names of the required env vars for a scope. */
|
|
21
|
+
requiredEnvVars(scope: string): string[];
|
|
22
|
+
/** Render `.env` content. */
|
|
23
|
+
renderEnvFile(options?: EnvFileOptions): string;
|
|
24
|
+
/** Write a `.env` file. Returns the path written. */
|
|
25
|
+
writeEnvFile(options: EnvFileOptions & {
|
|
26
|
+
output: string;
|
|
27
|
+
}): string;
|
|
28
|
+
/** Build the config metadata JSON document. */
|
|
29
|
+
buildConfigJson(options?: BuildConfigJsonOptions): ConfigJsonDoc;
|
|
30
|
+
/** Build (and optionally write) the untyped JSON Schema document. */
|
|
31
|
+
generateJsonSchema(options?: GenerateJsonSchemaOptions): Promise<Record<string, unknown>>;
|
|
32
|
+
/** Write the JSON Schema document. Returns the path written. */
|
|
33
|
+
writeJsonSchema(options: GenerateJsonSchemaOptions & {
|
|
34
|
+
output: string;
|
|
35
|
+
}): Promise<string>;
|
|
36
|
+
/** Render every config type file, keyed by scope name. */
|
|
37
|
+
renderConfigTypes(options?: GenerateTypesOptions): Record<string, string>;
|
|
38
|
+
/** Write the config type files into `outputDir`. */
|
|
39
|
+
writeConfigTypes(options: GenerateTypesOptions & {
|
|
40
|
+
outputDir: string;
|
|
41
|
+
}): string[];
|
|
42
|
+
/** Write the env type files into `outputDir`. */
|
|
43
|
+
writeEnvTypes(options: GenerateEnvTypesOptions & {
|
|
44
|
+
outputDir: string;
|
|
45
|
+
}): string[];
|
|
46
|
+
/** Write the markdown reference into `outDir`. */
|
|
47
|
+
writeMarkdown(options: GenerateMarkdownOptions & {
|
|
48
|
+
outDir: string;
|
|
49
|
+
}): string[];
|
|
50
|
+
/** Generate (and optionally write) the CLI option definitions. */
|
|
51
|
+
generateCliOptions(options?: GenerateCliOptionsOptions): CliOptionDef[];
|
|
52
|
+
}
|
|
53
|
+
/** Create a reusable config engine. */
|
|
54
|
+
export declare function createConfigEngine(options: ConfigEngineOptions): ConfigEngine;
|
|
55
|
+
//#endregion
|
|
56
|
+
export type { ConfigEngineOptions, ConfigScopes };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as e}from"node:path";import"node:url";import.meta.url;import{collectEnvVars as t,collectRequiredEnvVars as n}from"./collect.js";import{buildConfigJson as r}from"./config-json.js";import{generateEnvFile as i}from"./env-file.js";import{generateCliOptions as a}from"./generators/cli.js";import{generateEnvTypes as o}from"./generators/env.js";import{generateConfigJsonSchema as s,generateJsonSchemaFile as c}from"./generators/json.js";import{generateConfigMarkdown as l}from"./generators/markdown.js";import{generateConfigTypes as u,renderAllConfigTypes as d}from"./generators/types.js";import{findProjectRoot as f}from"./root.js";import p from"node:fs";function m(m){let h=m.scopes,g=m.envPrefix??`APP_`,_=m.baseGroup??`base`,v=m.root??f(),y=m.envPathOf;return{scopes:h,envPrefix:g,baseGroup:_,root:v,collectEnvVars:()=>t(h,g,{envPathOf:y}),requiredEnvVars:e=>n(h,e,g,{envPathOf:y}),renderEnvFile:(e={})=>i(h,{envPrefix:g,envPathOf:y,...e}),writeEnvFile:t=>{let n=i(h,{envPrefix:g,envPathOf:y,...t});return p.mkdirSync(e.dirname(t.output),{recursive:!0}),p.writeFileSync(t.output,n,`utf-8`),t.output},buildConfigJson:(e={})=>r(h,{envPrefix:g,envPathOf:y,...e}),generateJsonSchema:(e={})=>s(h,{baseGroup:_,...e}),writeJsonSchema:e=>c(h,{baseGroup:_,...e}),renderConfigTypes:(e={})=>d(h,{baseGroup:_,...e}),writeConfigTypes:e=>u(h,{baseGroup:_,...e}),writeEnvTypes:e=>o(h,{envPrefix:g,envPathOf:y,...e}),writeMarkdown:e=>l(h,{baseGroup:_,envPrefix:g,envPathOf:y,...e}),generateCliOptions:(e={})=>a(h,{envPrefix:g,envPathOf:y,...e})}}export{m as createConfigEngine};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { ConfigScopes } from "./types.js";
|
|
4
|
+
import { CollectEnvVarsOptions } from "./collect.js";
|
|
5
|
+
//#region packages/config/src/env-file.d.ts
|
|
6
|
+
export interface EnvFileOptions {
|
|
7
|
+
/** Env vars to include (defaults to all). */
|
|
8
|
+
include?: string[];
|
|
9
|
+
/** Env vars to exclude. */
|
|
10
|
+
exclude?: string[];
|
|
11
|
+
/** Default values to inject (overrides the schema defaults). */
|
|
12
|
+
values?: Record<string, string>;
|
|
13
|
+
/** Comment banner placed at the top of the file. */
|
|
14
|
+
header?: string;
|
|
15
|
+
/** Only emit these scopes (defaults to every registered scope). */
|
|
16
|
+
scopes?: string[];
|
|
17
|
+
/** The env-var prefix (default `APP_`). */
|
|
18
|
+
envPrefix?: string;
|
|
19
|
+
/** Omit descriptions (emit bare assignments). */
|
|
20
|
+
bare?: boolean;
|
|
21
|
+
/** Extra raw `NAME=value` lines appended after the schema vars. */
|
|
22
|
+
extra?: Record<string, string>;
|
|
23
|
+
/** The characters wrapping a scope's section header (default `----`). */
|
|
24
|
+
scopeSeparator?: string;
|
|
25
|
+
/** Custom env-name -> dotted-path derivation. */
|
|
26
|
+
envPathOf?: CollectEnvVarsOptions['envPathOf'];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Generate `.env` content from the config schemas. Secrets and required-without-
|
|
30
|
+
* default vars are emitted blank so operators fill them in.
|
|
31
|
+
*/
|
|
32
|
+
export declare function generateEnvFile(scopes: ConfigScopes, options?: EnvFileOptions): string;
|
|
33
|
+
//#endregion
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;import{collectEnvVars as e}from"./collect.js";function t(e){let t=e.default;return Array.isArray(t)?t.join(`,`):typeof t==`boolean`?t?`true`:`false`:typeof t==`number`?String(t):typeof t==`object`&&t?JSON.stringify(t):t===void 0?``:String(t)}function n(n,r={}){let i=r.envPrefix??`APP_`,a=r.scopeSeparator??`----`,o=e(n,i,{envPathOf:r.envPathOf}),s=r.scopes??Object.keys(n),c=o.filter(e=>s.includes(e.scope)&&(!r.include||r.include.includes(e.name))&&!r.exclude?.includes(e.name)),l=[];r.header&&l.push(r.header,``);let u;for(let e of c){if(e.scope!==u&&(u!==void 0&&l.push(``),l.push(`# ${a} ${e.scope.toUpperCase()} ${a}`),u=e.scope),!r.bare&&e.description)for(let t of e.description.split(`
|
|
2
|
+
`))l.push(`# ${t}`);let n=r.values?.[e.name];e.secret&&n===void 0?l.push(`# ${e.name}=`):l.push(`${e.name}=${n??t(e)}`)}if(r.extra){let e=Object.entries(r.extra).filter(([e])=>!c.some(t=>t.name===e)).map(([e,t])=>`${e}=${t}`);e.length&&l.push(``,`# ${a} EXTRA ${a}`,...e)}return`${l.join(`
|
|
3
|
+
`)}\n`}export{n as generateEnvFile};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
//#region packages/config/src/env.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Low-level configuration helpers: env-tree parsing, typed accessors and
|
|
6
|
+
* override merging. Free of Node builtins so browser consumers can import the
|
|
7
|
+
* frontend resolver without pulling `node:path` / `node:url` into a bundle.
|
|
8
|
+
*/
|
|
9
|
+
/** A flat env source (process.env, import.meta.env or a plain object). */
|
|
10
|
+
export type EnvSource = Record<string, string | undefined>;
|
|
11
|
+
/** A nested tree produced by folding `PREFIX_*` vars on `_`. */
|
|
12
|
+
export type EnvTree = Record<string, unknown>;
|
|
13
|
+
/** Parse a flat env source into the nested `PREFIX_*` tree. */
|
|
14
|
+
export declare function parseEnvTree(env?: EnvSource, prefix?: string): EnvTree;
|
|
15
|
+
/** Read a dotted path out of an env tree. */
|
|
16
|
+
export declare function readEnvPath(tree: EnvTree, path: string): unknown;
|
|
17
|
+
/** Read a string value, falling back when unset or empty. */
|
|
18
|
+
export declare function envString(tree: EnvTree, path: string, fallback?: string): string;
|
|
19
|
+
/** Read an integer value, falling back when unset or not a number. */
|
|
20
|
+
export declare function envInt(tree: EnvTree, path: string, fallback: number): number;
|
|
21
|
+
/** Read a boolean value. Accepts true/false/1/0/yes/no/on/off. */
|
|
22
|
+
export declare function envBool(tree: EnvTree, path: string, fallback: boolean): boolean;
|
|
23
|
+
/** Read a comma-separated list, filtering empty entries. */
|
|
24
|
+
export declare function envList(tree: EnvTree, path: string, fallback?: string[]): string[];
|
|
25
|
+
/** Read `Header=value,...` into a lowercase-keyed record. */
|
|
26
|
+
export declare function envMap(tree: EnvTree, path: string): Record<string, string>;
|
|
27
|
+
/** Recursively merge typed overrides over a base object (shallow per level). */
|
|
28
|
+
export declare function applyOverrides<T extends object>(base: T, overrides?: Partial<T>): T;
|
|
29
|
+
/** Trim trailing slashes from a URL-ish string. */
|
|
30
|
+
export declare function trimTrailingSlashes(value: string): string;
|
|
31
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;function e(e={},t=`APP_`){let n={};for(let[r,i]of Object.entries(e)){if(!r.startsWith(t)||i===void 0)continue;let e=r.slice(t.length).toLowerCase().split(`_`),a=n;for(let t=0;t<e.length-1;t+=1){let n=e[t]??``;(typeof a[n]!=`object`||a[n]===null)&&(a[n]={}),a=a[n]}a[e[e.length-1]??``]=i}return n}function t(e,t){let n=e;for(let e of t.split(`.`)){if(typeof n!=`object`||!n)return;n=n[e]}return n}function n(e,n,r=``){let i=t(e,n);return typeof i==`string`&&i.trim()!==``?i:r}function r(e,n,r){let i=t(e,n);if(typeof i!=`string`||i.trim()===``)return r;let a=Number.parseInt(i,10);return Number.isFinite(a)?a:r}function i(e,n,r){let i=t(e,n);if(typeof i!=`string`||i.trim()===``)return r;let a=i.trim().toLowerCase();return[`true`,`1`,`yes`,`on`].includes(a)?!0:![`false`,`0`,`no`,`off`].includes(a)&&r}function a(e,n,r=[]){let i=t(e,n);return typeof i!=`string`||i.trim()===``?r:i.split(`,`).map(e=>e.trim()).filter(Boolean)}function o(e,t){let n={};for(let r of a(e,t,[])){let e=r.indexOf(`=`);e!==-1&&(n[r.slice(0,e).trim().toLowerCase()]=r.slice(e+1).trim())}return n}function s(e,t){if(!t)return e;let n={...e};for(let[r,i]of Object.entries(t)){if(i===void 0)continue;let t=e[r];n[r]=t&&typeof t==`object`&&!Array.isArray(t)&&i&&typeof i==`object`&&!Array.isArray(i)?s(t,i):i}return n}function c(e){return e.replace(/\/+$/,``)}export{s as applyOverrides,i as envBool,r as envInt,a as envList,o as envMap,n as envString,e as parseEnvTree,t as readEnvPath,c as trimTrailingSlashes};
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { ConfigScopes } from "../types.js";
|
|
4
|
+
import { CollectEnvVarsOptions } from "../collect.js";
|
|
5
|
+
import { ParseArgsOptionsConfig } from "node:util";
|
|
6
|
+
//#region packages/config/src/generators/cli.d.ts
|
|
7
|
+
/** Flag-shaping options shared by every CLI helper. */
|
|
8
|
+
export interface CliFlagOptions {
|
|
9
|
+
/** The env-var prefix (default `APP_`). */
|
|
10
|
+
envPrefix?: string;
|
|
11
|
+
/** Shorthand flags keyed by env var name (eg. `{ APP_TOKEN: 't' }`). */
|
|
12
|
+
shortFlags?: Record<string, string>;
|
|
13
|
+
/** Custom env-name -> dotted-path derivation. */
|
|
14
|
+
envPathOf?: CollectEnvVarsOptions['envPathOf'];
|
|
15
|
+
}
|
|
16
|
+
/** A generated CLI option definition for one env var. */
|
|
17
|
+
export interface CliOptionDef {
|
|
18
|
+
/** CLI flag, e.g. `--base-url`. */
|
|
19
|
+
flag: string;
|
|
20
|
+
/** Shorthand flag, e.g. `-u`. */
|
|
21
|
+
short?: string;
|
|
22
|
+
/** The env var the flag reads, e.g. `APP_CLI_BASE_URL`. */
|
|
23
|
+
env: string;
|
|
24
|
+
/** The resolved value type (`string`, `number`, `boolean`, ...). */
|
|
25
|
+
type: string;
|
|
26
|
+
/** Human-readable description. */
|
|
27
|
+
description?: string;
|
|
28
|
+
/** Never echo a real value for this option (secrets). */
|
|
29
|
+
secret?: boolean;
|
|
30
|
+
/** The resolved default value, when one is configured. */
|
|
31
|
+
default?: string;
|
|
32
|
+
}
|
|
33
|
+
/** The long flag name (without dashes) for an env var. */
|
|
34
|
+
export declare function flagOf(env: string, options?: CliFlagOptions): string;
|
|
35
|
+
/** The long flag (e.g. `--base-url`) for an env var. */
|
|
36
|
+
export declare function cliFlagOf(env: string, options?: CliFlagOptions): string;
|
|
37
|
+
/** The shorthand flag (e.g. `-u`) for an env var, when configured. */
|
|
38
|
+
export declare function cliShortOf(env: string, options?: CliFlagOptions): string | undefined;
|
|
39
|
+
/** A flag label such as `-u, --base-url`. */
|
|
40
|
+
export declare function cliFlagLabel(env: string, options?: CliFlagOptions): string;
|
|
41
|
+
export interface GenerateCliOptionsOptions extends CliFlagOptions {
|
|
42
|
+
/** The scope whose env vars become flags (default `cli`). */
|
|
43
|
+
scope?: string;
|
|
44
|
+
/** Output file path to write the options as JSON. */
|
|
45
|
+
output?: string;
|
|
46
|
+
}
|
|
47
|
+
/** Generate the CLI option definitions for a scope's env vars. */
|
|
48
|
+
export declare function generateCliOptions(scopes: ConfigScopes, options?: GenerateCliOptionsOptions): CliOptionDef[];
|
|
49
|
+
/** The typed `values` of a parsed CLI args result. */
|
|
50
|
+
export type CliArgsValues = Record<string, string | undefined>;
|
|
51
|
+
/** A parsed CLI args result (node `parseArgs` output). */
|
|
52
|
+
export interface CliArgsResult {
|
|
53
|
+
values: CliArgsValues;
|
|
54
|
+
positionals: string[];
|
|
55
|
+
}
|
|
56
|
+
/** A generated `node:util` `parseArgs` option entry. */
|
|
57
|
+
export interface CliArgsOptionConfig {
|
|
58
|
+
type: 'string';
|
|
59
|
+
short?: string;
|
|
60
|
+
default?: string;
|
|
61
|
+
}
|
|
62
|
+
/** Build the `options` config for `node:util`'s `parseArgs`. */
|
|
63
|
+
export declare function generateCliArgsOptions(defs: CliOptionDef[]): Record<string, CliArgsOptionConfig>;
|
|
64
|
+
/** A generated CLI args parser bound to a set of option definitions. */
|
|
65
|
+
export interface CliArgsParser {
|
|
66
|
+
options: ParseArgsOptionsConfig;
|
|
67
|
+
parse: (args?: string[]) => CliArgsResult;
|
|
68
|
+
/** Map a parsed result into a `{ [flag]: value }` record of provided flags. */
|
|
69
|
+
toConfig: (result?: CliArgsResult) => CliArgsValues;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Create a CLI args parser from generated option definitions. The generated
|
|
73
|
+
* `parse` uses `node:util`'s `parseArgs` and returns a typed result.
|
|
74
|
+
*/
|
|
75
|
+
export declare function createCliArgsParser(defs: CliOptionDef[], parseOptions?: {
|
|
76
|
+
strict?: boolean;
|
|
77
|
+
}): CliArgsParser;
|
|
78
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;import{formatCliFlag as e}from"../../../shared/src/string-utils.js";import"../../../shared/src/index.js";import{collectEnvVars as t}from"../collect.js";import n from"node:fs";import{parseArgs as r}from"node:util";function i(t,n={}){return e(t,n.envPrefix??`APP_`)}function a(e,t={}){return`--${i(e,t)}`}function o(e,t={}){let n=t.shortFlags?.[e];return n?`-${n}`:void 0}function s(e,t={}){let n=a(e,t),r=o(e,t);return r?`${r}, ${n}`:n}function c(e,r={}){let i=r.scope??`cli`,s=[];for(let n of t(e,r.envPrefix,{envPathOf:r.envPathOf}).filter(e=>e.scope===i)){let e=o(n.name,r);s.push({flag:a(n.name,r),env:n.name,type:n.envType??`string`,...e?{short:e}:{},...n.description?{description:n.description}:{},...n.secret?{secret:!0}:{},...n.default!==void 0&&!n.secret?{default:String(n.default)}:{}})}return r.output&&n.writeFileSync(r.output,`${JSON.stringify(s,null,4)}\n`,`utf-8`),s}function l(e){return Object.fromEntries(e.map(e=>[e.flag.replace(/^--/,``),{type:`string`,...e.short?{short:e.short.replace(/^-/,``)}:{},...e.default?{default:e.default}:{}}]))}function u(e,t){let n=l(e);return{options:n,parse:(e=process.argv.slice(2))=>r({args:e,options:n,strict:t?.strict??!0}),toConfig:e=>{let t=e?.values??{},n={};for(let[e,r]of Object.entries(t))r!==void 0&&(n[e]=r);return n}}}export{s as cliFlagLabel,a as cliFlagOf,o as cliShortOf,u as createCliArgsParser,i as flagOf,l as generateCliArgsOptions,c as generateCliOptions};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { ConfigScopes } from "../types.js";
|
|
4
|
+
import { CollectEnvVarsOptions } from "../collect.js";
|
|
5
|
+
//#region packages/config/src/generators/env.d.ts
|
|
6
|
+
export interface GenerateEnvTypesOptions {
|
|
7
|
+
/** Output directory. When omitted, nothing is written. */
|
|
8
|
+
outputDir?: string;
|
|
9
|
+
/** The env-var prefix (default `APP_`). */
|
|
10
|
+
envPrefix?: string;
|
|
11
|
+
/** The `process.env` interface name (default `AppEnv`). */
|
|
12
|
+
envInterfaceName?: string;
|
|
13
|
+
/** The `import.meta.env` interface name (default `AppViteEnv`). */
|
|
14
|
+
viteEnvInterfaceName?: string;
|
|
15
|
+
/** The generated types file name (default `env.ts`). */
|
|
16
|
+
envFile?: string;
|
|
17
|
+
/** The generated ambient file name (default `env.d.ts`). */
|
|
18
|
+
dtsFile?: string;
|
|
19
|
+
/** The import specifier the `.d.ts` uses for the env types. */
|
|
20
|
+
importPath?: string;
|
|
21
|
+
/** A header comment prepended to both files. */
|
|
22
|
+
header?: string;
|
|
23
|
+
/** A raw (verbatim) header replacing the generated one in `env.ts`. */
|
|
24
|
+
envHeader?: string;
|
|
25
|
+
/** A raw (verbatim) header replacing the generated one in the `.d.ts`. */
|
|
26
|
+
dtsHeader?: string;
|
|
27
|
+
/** The doc comment above the `process.env` interface. */
|
|
28
|
+
envComment?: string;
|
|
29
|
+
/** Add a `declare module 'vite'` augmentation to the `.d.ts`. */
|
|
30
|
+
augmentVite?: boolean;
|
|
31
|
+
/** Custom env-name -> dotted-path derivation. */
|
|
32
|
+
envPathOf?: CollectEnvVarsOptions['envPathOf'];
|
|
33
|
+
}
|
|
34
|
+
/** Render the `env.ts` content (the env + vite-env interfaces). */
|
|
35
|
+
export declare function generateEnv(scopes: ConfigScopes, options?: GenerateEnvTypesOptions): string;
|
|
36
|
+
/** Render the ambient `.d.ts` content. */
|
|
37
|
+
export declare function generateEnvDts(options?: GenerateEnvTypesOptions): string;
|
|
38
|
+
/** Generate `env.ts` + the ambient `.d.ts` into `outputDir`. Returns the paths. */
|
|
39
|
+
export declare function generateEnvTypes(scopes: ConfigScopes, options: GenerateEnvTypesOptions & {
|
|
40
|
+
outputDir: string;
|
|
41
|
+
}): string[];
|
|
42
|
+
//#endregion
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import{default as e}from"node:path";import"node:url";import.meta.url;import{collectEnvVars as t}from"../collect.js";import n from"node:fs";function r(e){return e??`Generated env typing — DO NOT EDIT.`}function i(e,n={}){let i=n.envPrefix??`APP_`,a=n.envInterfaceName??`AppEnv`,o=n.viteEnvInterfaceName??`AppViteEnv`,s=t(e,i,{envPathOf:n.envPathOf}),c=s.filter(e=>e.scope!==`frontend`),l=s.filter(e=>e.public),u=n.envHeader?[n.envHeader,``]:[`/**`,` * ${r(n.header)}`,` */`,``];u.push(`/** ${n.envComment??"Environment variables typed on `process.env`."} */`,`export interface ${a} {`);for(let e of c)u.push(` /** ${(e.description??``).replace(/\n/g,` `)} */`),u.push(` ${e.name}?: string;`);u.push(`}`),u.push(``),u.push("/** Public frontend environment variables typed on `import.meta.env`. */"),u.push(`export interface ${o} {`);for(let e of l)u.push(` /** ${(e.description??``).replace(/\n/g,` `)} */`),u.push(` ${e.name}?: string;`);return u.push(`}`),`${u.join(`
|
|
2
|
+
`).trimEnd()}\n`}function a(e={}){let t=e.envInterfaceName??`AppEnv`,n=e.viteEnvInterfaceName??`AppViteEnv`,i=e.importPath??`./env.js`;return`${e.dtsHeader?`${e.dtsHeader}\n`:`/**
|
|
3
|
+
* ${r(e.header)}
|
|
4
|
+
*
|
|
5
|
+
* Re-exports the generated env types onto \`process.env\` and
|
|
6
|
+
* \`import.meta.env\` so environment variables type-check everywhere.
|
|
7
|
+
*/
|
|
8
|
+
`}import type { ${t}, ${n} } from '${i}';
|
|
9
|
+
|
|
10
|
+
declare global {
|
|
11
|
+
namespace NodeJS {
|
|
12
|
+
interface ProcessEnv extends ${t} {}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface ImportMetaEnv extends ${n} {}
|
|
16
|
+
}${e.augmentVite?`
|
|
17
|
+
|
|
18
|
+
declare module 'vite' {
|
|
19
|
+
interface ImportMetaEnv extends ${n} {}
|
|
20
|
+
}`:``}
|
|
21
|
+
|
|
22
|
+
export {};
|
|
23
|
+
`}function o(t,r){let o=e.join(r.outputDir,r.envFile??`env.ts`),s=e.join(r.outputDir,r.dtsFile??`env.d.ts`);return n.mkdirSync(r.outputDir,{recursive:!0}),n.writeFileSync(o,i(t,r),`utf-8`),n.writeFileSync(s,a(r),`utf-8`),[o,s]}export{i as generateEnv,a as generateEnvDts,o as generateEnvTypes};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { CliArgsOptionConfig, CliArgsParser, CliArgsResult, CliArgsValues, CliFlagOptions, CliOptionDef, GenerateCliOptionsOptions, cliFlagLabel, cliFlagOf, cliShortOf, createCliArgsParser, flagOf, generateCliArgsOptions, generateCliOptions } from "./cli.js";
|
|
4
|
+
import { GenerateEnvTypesOptions, generateEnv, generateEnvDts, generateEnvTypes } from "./env.js";
|
|
5
|
+
import { GenerateJsonSchemaOptions, generateConfigJsonSchema, generateJsonSchemaFile } from "./json.js";
|
|
6
|
+
import { ConfigFileSection, GenerateMarkdownOptions, RenderConfigFileOptions, RenderMarkdownOptions, generateConfigMarkdown, renderConfigFileMarkdown, renderConfigIndex, renderScopeMarkdown } from "./markdown.js";
|
|
7
|
+
import { GenerateTypesOptions, generateConfigTypes, renderAllConfigTypes, renderConfigTypes, resolveScopeSchema } from "./types.js";
|
|
8
|
+
export { CliArgsOptionConfig, CliArgsParser, CliArgsResult, CliArgsValues, CliFlagOptions, CliOptionDef, ConfigFileSection, GenerateCliOptionsOptions, GenerateEnvTypesOptions, GenerateJsonSchemaOptions, GenerateMarkdownOptions, GenerateTypesOptions, RenderConfigFileOptions, RenderMarkdownOptions, cliFlagLabel, cliFlagOf, cliShortOf, createCliArgsParser, flagOf, generateCliArgsOptions, generateCliOptions, generateConfigJsonSchema, generateConfigMarkdown, generateConfigTypes, generateEnv, generateEnvDts, generateEnvTypes, generateJsonSchemaFile, renderAllConfigTypes, renderConfigFileMarkdown, renderConfigIndex, renderConfigTypes, renderScopeMarkdown, resolveScopeSchema };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"node:path";import"node:url";import.meta.url;import{cliFlagLabel as e,cliFlagOf as t,cliShortOf as n,createCliArgsParser as r,flagOf as i,generateCliArgsOptions as a,generateCliOptions as o}from"./cli.js";import{generateEnv as s,generateEnvDts as c,generateEnvTypes as l}from"./env.js";import{generateConfigJsonSchema as u,generateJsonSchemaFile as d}from"./json.js";import{generateConfigMarkdown as f,renderConfigFileMarkdown as p,renderConfigIndex as m,renderScopeMarkdown as h}from"./markdown.js";import{generateConfigTypes as g,renderAllConfigTypes as _,renderConfigTypes as v,resolveScopeSchema as y}from"./types.js";export{e as cliFlagLabel,t as cliFlagOf,n as cliShortOf,r as createCliArgsParser,i as flagOf,a as generateCliArgsOptions,o as generateCliOptions,u as generateConfigJsonSchema,f as generateConfigMarkdown,g as generateConfigTypes,s as generateEnv,c as generateEnvDts,l as generateEnvTypes,d as generateJsonSchemaFile,_ as renderAllConfigTypes,p as renderConfigFileMarkdown,m as renderConfigIndex,v as renderConfigTypes,h as renderScopeMarkdown,y as resolveScopeSchema};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import __tsdown_shims_path from 'node:path';
|
|
2
|
+
import __tsdown_shims_url from 'node:url';
|
|
3
|
+
import { ConfigScopes } from "../types.js";
|
|
4
|
+
//#region packages/config/src/generators/json.d.ts
|
|
5
|
+
export interface GenerateJsonSchemaOptions {
|
|
6
|
+
/** Output file path. When omitted, nothing is written. */
|
|
7
|
+
output?: string;
|
|
8
|
+
/** The base group hoisted to the top level (default `base`). */
|
|
9
|
+
baseGroup?: string;
|
|
10
|
+
/** Document metadata overrides. */
|
|
11
|
+
id?: string;
|
|
12
|
+
title?: string;
|
|
13
|
+
description?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Build the combined untyped JSON Schema document covering every scope, using
|
|
17
|
+
* untyped's `resolveSchema` on the definitions lowered from the Zod schemas.
|
|
18
|
+
*/
|
|
19
|
+
export declare function generateConfigJsonSchema(scopes: ConfigScopes, options?: GenerateJsonSchemaOptions): Promise<Record<string, unknown>>;
|
|
20
|
+
/** Generate the JSON Schema document into `output`. Returns the path written. */
|
|
21
|
+
export declare function generateJsonSchemaFile(scopes: ConfigScopes, options: GenerateJsonSchemaOptions & {
|
|
22
|
+
output: string;
|
|
23
|
+
}): Promise<string>;
|
|
24
|
+
//#endregion
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{default as e}from"node:path";import"node:url";import.meta.url;import{flattenBaseSchema as t,zodToUntypedDefinition as n}from"../schema.js";import r from"node:fs";import{resolveSchema as i}from"untyped";async function a(a,o={}){let s={};for(let[e,r]of Object.entries(a))s[e]=t(await i(n(r.zodSchema)),o.baseGroup);let c={$schema:`https://json-schema.org/draft/2020-12/schema`,$id:o.id??`https://example.com/schemas/config.json`,title:o.title??`Configuration`,description:o.description??`Every env-var-backed configuration value across all scopes.`,type:`object`,properties:s,required:Object.keys(a)};return o.output&&(r.mkdirSync(e.dirname(o.output),{recursive:!0}),r.writeFileSync(o.output,`${JSON.stringify(c,null,4)}\n`,`utf-8`)),c}async function o(e,t){return await a(e,t),t.output}export{a as generateConfigJsonSchema,o as generateJsonSchemaFile};
|