@adamhl8/configs 0.24.12 → 0.25.0
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/configs/knip.base.d.ts +1 -1
- package/dist/configs/release-it.base.d.ts +1 -0
- package/dist/configs/release-it.base.d.ts.map +1 -1
- package/dist/configs/release-it.base.js +2 -1
- package/dist/configs/release-it.base.js.map +1 -1
- package/dist/env/index.d.ts +9 -0
- package/dist/env/index.d.ts.map +1 -0
- package/dist/env/index.js +17 -0
- package/dist/env/index.js.map +1 -0
- package/dist/env/utils.d.ts +14 -0
- package/dist/env/utils.d.ts.map +1 -0
- package/dist/env/utils.js +14 -0
- package/dist/env/utils.js.map +1 -0
- package/package.json +8 -1
|
@@ -6,7 +6,7 @@ declare const knipConfig: OptionalMergeConfigFn<KnipConfig, {
|
|
|
6
6
|
readonly project: ["**"];
|
|
7
7
|
readonly entry: ["./src/index.ts", "**/*.test.ts", "./tsdown.config.ts"];
|
|
8
8
|
readonly ignoreBinaries: ["lefthook", "gh"];
|
|
9
|
-
readonly ignoreDependencies: ("@adamhl8/eslint-plugin-clean-modules"
|
|
9
|
+
readonly ignoreDependencies: ("@commitlint/cli" | "@adamhl8/eslint-plugin-clean-modules")[];
|
|
10
10
|
readonly tsdown: false;
|
|
11
11
|
}>;
|
|
12
12
|
//#endregion
|
|
@@ -7,6 +7,7 @@ declare const releaseItConfig: OptionalMergeConfigFn<Config, {
|
|
|
7
7
|
readonly commitMessage: "release: ${version}";
|
|
8
8
|
readonly tagName: "${version}";
|
|
9
9
|
readonly tagAnnotation: "release ${version}";
|
|
10
|
+
readonly addUntrackedFiles: true;
|
|
10
11
|
};
|
|
11
12
|
readonly hooks: {
|
|
12
13
|
readonly "before:init": "nub run bundle";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"release-it.base.d.ts","names":[],"sources":["../../src/configs/release-it.base.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"release-it.base.d.ts","names":[],"sources":["../../src/configs/release-it.base.ts"],"mappings":";;;;cA6Ba,eAAA,EAAe,qBAAA,CAAA,MAAA;EAAA"}
|
|
@@ -3,7 +3,8 @@ const releaseItConfig = createMergeConfigFn({
|
|
|
3
3
|
git: {
|
|
4
4
|
commitMessage: "release: ${version}",
|
|
5
5
|
tagName: "${version}",
|
|
6
|
-
tagAnnotation: "release ${version}"
|
|
6
|
+
tagAnnotation: "release ${version}",
|
|
7
|
+
addUntrackedFiles: true
|
|
7
8
|
},
|
|
8
9
|
hooks: {
|
|
9
10
|
"before:init": "nub run bundle",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"release-it.base.js","names":[],"sources":["../../src/configs/release-it.base.ts"],"sourcesContent":["// oxlint-disable no-template-curly-in-string\nimport type { Config } from \"release-it\"\n\nimport { createMergeConfigFn } from \"#/utils.ts\"\n\nconst baseConfig = {\n git: {\n commitMessage: \"release: ${version}\",\n tagName: \"${version}\",\n tagAnnotation: \"release ${version}\",\n },\n hooks: {\n \"before:init\": \"nub run bundle\",\n \"after:bump\": [\"adamhl8-cliff --tag ${version} -o\", \"nubx oxfmt CHANGELOG.md\"],\n },\n github: {\n release: true,\n releaseName: \"${version}\",\n releaseNotes: \"adamhl8-cliff --unreleased --tag ${version}\",\n },\n npm: {\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion - release-it doesn't support nub directly yet\n publishPackageManager: \"nub\" as \"bun\",\n publishPath: \"\",\n publishArgs: [\"--no-git-checks\"],\n },\n} as const satisfies Config\n\nexport const releaseItConfig = createMergeConfigFn<Config, typeof baseConfig>(baseConfig)\n"],"mappings":";
|
|
1
|
+
{"version":3,"file":"release-it.base.js","names":[],"sources":["../../src/configs/release-it.base.ts"],"sourcesContent":["// oxlint-disable no-template-curly-in-string\nimport type { Config } from \"release-it\"\n\nimport { createMergeConfigFn } from \"#/utils.ts\"\n\nconst baseConfig = {\n git: {\n commitMessage: \"release: ${version}\",\n tagName: \"${version}\",\n tagAnnotation: \"release ${version}\",\n addUntrackedFiles: true,\n },\n hooks: {\n \"before:init\": \"nub run bundle\",\n \"after:bump\": [\"adamhl8-cliff --tag ${version} -o\", \"nubx oxfmt CHANGELOG.md\"],\n },\n github: {\n release: true,\n releaseName: \"${version}\",\n releaseNotes: \"adamhl8-cliff --unreleased --tag ${version}\",\n },\n npm: {\n // oxlint-disable-next-line typescript/no-unsafe-type-assertion - release-it doesn't support nub directly yet\n publishPackageManager: \"nub\" as \"bun\",\n publishPath: \"\",\n publishArgs: [\"--no-git-checks\"],\n },\n} as const satisfies Config\n\nexport const releaseItConfig = createMergeConfigFn<Config, typeof baseConfig>(baseConfig)\n"],"mappings":";AA6BA,MAAa,kBAAkB,oBAA+C;CAvB5E,KAAK;EACH,eAAe;EACf,SAAS;EACT,eAAe;EACf,mBAAmB;CACrB;CACA,OAAO;EACL,eAAe;EACf,cAAc,CAAC,qCAAqC,yBAAyB;CAC/E;CACA,QAAQ;EACN,SAAS;EACT,aAAa;EACb,cAAc;CAChB;CACA,KAAK;EAEH,uBAAuB;EACvB,aAAa;EACb,aAAa,CAAC,iBAAiB;CACjC;AAG4E,CAAU"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/env/index.ts"],"mappings":";;;;KAKK,MAAA,UAAgB,MAAM;AAAA,cAEd,QAAA,EAOP,MAAM"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { requireWhen } from "./utils.js";
|
|
2
|
+
import process from "node:process";
|
|
3
|
+
import arkenv from "arkenv";
|
|
4
|
+
import { attempt, isErr } from "ts-explicit-errors";
|
|
5
|
+
//#region src/env/index.ts
|
|
6
|
+
const parseEnv = ((...args) => {
|
|
7
|
+
const env = attempt(() => arkenv(...args));
|
|
8
|
+
if (isErr(env)) {
|
|
9
|
+
console.error(env.message);
|
|
10
|
+
process.exit(1);
|
|
11
|
+
}
|
|
12
|
+
return env;
|
|
13
|
+
});
|
|
14
|
+
//#endregion
|
|
15
|
+
export { parseEnv, requireWhen };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/env/index.ts"],"sourcesContent":["import process from \"node:process\"\n\nimport arkenv from \"arkenv\"\nimport { attempt, isErr } from \"ts-explicit-errors\"\n\ntype ArkEnv = typeof arkenv\n\nexport const parseEnv = ((...args: Parameters<ArkEnv>) => {\n const env = attempt(() => arkenv(...args))\n if (isErr(env)) {\n console.error(env.message)\n process.exit(1)\n }\n return env\n}) as ArkEnv\n\nexport { requireWhen } from \"#/env/utils.ts\"\n"],"mappings":";;;;;AAOA,MAAa,aAAa,GAAG,SAA6B;CACxD,MAAM,MAAM,cAAc,OAAO,GAAG,IAAI,CAAC;CACzC,IAAI,MAAM,GAAG,GAAG;EACd,QAAQ,MAAM,IAAI,OAAO;EACzB,QAAQ,KAAK,CAAC;CAChB;CACA,OAAO;AACT"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type } from "arktype";
|
|
2
|
+
|
|
3
|
+
//#region src/env/utils.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Makes an env var required while `when` is true, otherwise optional.
|
|
6
|
+
*
|
|
7
|
+
* A set value must always satisfy `def`. An unset var takes `fallback` (exempt from `def` validation), or the key is
|
|
8
|
+
* omitted entirely if no fallback is given.
|
|
9
|
+
*/
|
|
10
|
+
declare function requireWhen<const type$1>(when: boolean, type: type.validate<type$1>): ReturnType<type.instantiate<type$1>["optional"]>;
|
|
11
|
+
declare function requireWhen<const type$2>(when: boolean, type: type.validate<type$2>, fallback: type.infer<type$2>): type.instantiate<type$2>;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { requireWhen };
|
|
14
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","names":[],"sources":["../../src/env/utils.ts"],"mappings":";;;;;AASA;;;;iBAAgB,WAAA,eACd,IAAA,WACA,IAAA,EAAM,IAAA,CAAQ,QAAA,CAAS,MAAA,IACtB,UAAA,CAAW,IAAA,CAAQ,WAAA,CAAY,MAAA;AAAA,iBAClB,WAAA,eACd,IAAA,WACA,IAAA,EAAM,IAAA,CAAQ,QAAA,CAAS,MAAA,GACvB,QAAA,EAAU,IAAA,CAAQ,KAAA,CAAM,MAAA,IACvB,IAAA,CAAQ,WAAA,CAAY,MAAA"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type } from "arkenv";
|
|
2
|
+
//#region src/env/utils.ts
|
|
3
|
+
function requireWhen(when, type$1, ...rest) {
|
|
4
|
+
const t = type.raw(type$1);
|
|
5
|
+
if (when) return t;
|
|
6
|
+
if (rest.length === 0) return t.optional();
|
|
7
|
+
const [fallback] = rest;
|
|
8
|
+
const unset = Symbol("unset");
|
|
9
|
+
return t.or(type.unit(unset)).pipe((v) => v === unset ? fallback : v).default(unset);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { requireWhen };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","names":["arkenvType","type"],"sources":["../../src/env/utils.ts"],"sourcesContent":["import { type as arkenvType } from \"arkenv\"\nimport type { type as arktype } from \"arktype\"\n\n/**\n * Makes an env var required while `when` is true, otherwise optional.\n *\n * A set value must always satisfy `def`. An unset var takes `fallback` (exempt from `def` validation), or the key is\n * omitted entirely if no fallback is given.\n */\nexport function requireWhen<const type>(\n when: boolean,\n type: arktype.validate<type>,\n): ReturnType<arktype.instantiate<type>[\"optional\"]>\nexport function requireWhen<const type>(\n when: boolean,\n type: arktype.validate<type>,\n fallback: arktype.infer<type>,\n): arktype.instantiate<type>\n/* oxlint-disable typescript/no-unsafe-type-assertion */\nexport function requireWhen(when: boolean, type: unknown, ...rest: [unknown?]): never {\n const t = arkenvType.raw(type)\n if (when) return t as never\n if (rest.length === 0) return t.optional() as never\n const [fallback] = rest\n // defaulting to a sentinel keeps the fallback exempt from def validation without\n // letting an explicitly set value bypass it (env values can never be a symbol)\n const unset = Symbol(\"unset\")\n return t\n .or(arkenvType.unit(unset))\n .pipe((v: unknown) => (v === unset ? fallback : v))\n .default(unset as never) as never\n}\n"],"mappings":";;AAmBA,SAAgB,YAAY,MAAe,QAAe,GAAG,MAAyB;CACpF,MAAM,IAAIA,KAAW,IAAIC,MAAI;CAC7B,IAAI,MAAM,OAAO;CACjB,IAAI,KAAK,WAAW,GAAG,OAAO,EAAE,SAAS;CACzC,MAAM,CAAC,YAAY;CAGnB,MAAM,QAAQ,OAAO,OAAO;CAC5B,OAAO,EACJ,GAAGD,KAAW,KAAK,KAAK,CAAC,CAAC,CAC1B,MAAM,MAAgB,MAAM,QAAQ,WAAW,CAAE,CAAC,CAClD,QAAQ,KAAc;AAC3B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adamhl8/configs",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"homepage": "https://github.com/adamhl8/configs",
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/adamhl8/configs/issues"
|
|
@@ -31,6 +31,10 @@
|
|
|
31
31
|
".": {
|
|
32
32
|
"types": "./dist/index.d.ts",
|
|
33
33
|
"import": "./dist/index.js"
|
|
34
|
+
},
|
|
35
|
+
"./env": {
|
|
36
|
+
"types": "./dist/env/index.d.ts",
|
|
37
|
+
"import": "./dist/env/index.js"
|
|
34
38
|
}
|
|
35
39
|
},
|
|
36
40
|
"publishConfig": {
|
|
@@ -48,7 +52,10 @@
|
|
|
48
52
|
"@adamhl8/eslint-plugin-clean-modules": "^0.1.3",
|
|
49
53
|
"@commitlint/config-conventional": "^21.2.0",
|
|
50
54
|
"@commitlint/types": "^21.2.0",
|
|
55
|
+
"arkenv": "^0.12.2",
|
|
56
|
+
"arktype": "^2.2.2",
|
|
51
57
|
"es-toolkit": "^1.49.0",
|
|
58
|
+
"ts-explicit-errors": "^4.1.2",
|
|
52
59
|
"type-fest": "^5.7.0"
|
|
53
60
|
},
|
|
54
61
|
"devDependencies": {
|