@adamhl8/configs 0.15.4 → 0.15.6
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.
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import process from "node:process";
|
|
4
|
+
const baseKnipPreprocessorPath = `${path.resolve(import.meta.dir, "../knip-preprocessor")}`;
|
|
5
|
+
const knipPreprocessorPathExt = await Bun.file(`${baseKnipPreprocessorPath}.ts`).exists() ? ".ts" : ".js";
|
|
6
|
+
const knipPreprocessorPath = `${baseKnipPreprocessorPath}${knipPreprocessorPathExt}`;
|
|
7
|
+
process.exitCode = Bun.spawnSync({
|
|
8
|
+
cmd: [
|
|
9
|
+
"bun",
|
|
10
|
+
"knip-bun",
|
|
11
|
+
"--preprocessor",
|
|
12
|
+
knipPreprocessorPath,
|
|
13
|
+
...process.argv.slice(2)
|
|
14
|
+
],
|
|
15
|
+
stdout: "inherit",
|
|
16
|
+
stderr: "inherit"
|
|
17
|
+
}).exitCode;
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["merge","baseConfig","baseConfig","baseConfig"],"sources":["../node_modules/es-toolkit/dist/_internal/isUnsafeProperty.mjs","../node_modules/es-toolkit/dist/compat/predicate/isObjectLike.mjs","../node_modules/es-toolkit/dist/object/mergeWith.mjs","../src/utils.ts","../src/knip.ts","../src/prettier.ts","../src/tsdown.ts"],"sourcesContent":["function isUnsafeProperty(key) {\n return key === '__proto__';\n}\n\nexport { isUnsafeProperty };\n","function isObjectLike(value) {\n return typeof value === 'object' && value !== null;\n}\n\nexport { isObjectLike };\n","import { isUnsafeProperty } from '../_internal/isUnsafeProperty.mjs';\nimport { isObjectLike } from '../compat/predicate/isObjectLike.mjs';\n\nfunction mergeWith(target, source, merge) {\n const sourceKeys = Object.keys(source);\n for (let i = 0; i < sourceKeys.length; i++) {\n const key = sourceKeys[i];\n if (isUnsafeProperty(key)) {\n continue;\n }\n const sourceValue = source[key];\n const targetValue = target[key];\n const merged = merge(targetValue, sourceValue, key, target, source);\n if (merged !== undefined) {\n target[key] = merged;\n }\n else if (Array.isArray(sourceValue)) {\n target[key] = mergeWith(targetValue ?? [], sourceValue, merge);\n }\n else if (isObjectLike(targetValue) && isObjectLike(sourceValue)) {\n target[key] = mergeWith(targetValue ?? {}, sourceValue, merge);\n }\n else if (targetValue === undefined || sourceValue !== undefined) {\n target[key] = sourceValue;\n }\n }\n return target;\n}\n\nexport { mergeWith };\n","import { mergeWith } from \"es-toolkit\"\nimport { isPlainObject } from \"remeda\"\nimport type { MergeDeep } from \"type-fest\"\n\ntype AnyObj = Record<PropertyKey, unknown>\n\n/**\n * A wrapper around es-toolkit's `mergeWith` with a custom merge function that concatenates arrays.\n */\
|
|
1
|
+
{"version":3,"file":"index.js","names":["merge","baseConfig","baseConfig","baseConfig"],"sources":["../node_modules/es-toolkit/dist/_internal/isUnsafeProperty.mjs","../node_modules/es-toolkit/dist/compat/predicate/isObjectLike.mjs","../node_modules/es-toolkit/dist/object/mergeWith.mjs","../src/utils.ts","../src/knip.ts","../src/prettier.ts","../src/tsdown.ts"],"sourcesContent":["function isUnsafeProperty(key) {\n return key === '__proto__';\n}\n\nexport { isUnsafeProperty };\n","function isObjectLike(value) {\n return typeof value === 'object' && value !== null;\n}\n\nexport { isObjectLike };\n","import { isUnsafeProperty } from '../_internal/isUnsafeProperty.mjs';\nimport { isObjectLike } from '../compat/predicate/isObjectLike.mjs';\n\nfunction mergeWith(target, source, merge) {\n const sourceKeys = Object.keys(source);\n for (let i = 0; i < sourceKeys.length; i++) {\n const key = sourceKeys[i];\n if (isUnsafeProperty(key)) {\n continue;\n }\n const sourceValue = source[key];\n const targetValue = target[key];\n const merged = merge(targetValue, sourceValue, key, target, source);\n if (merged !== undefined) {\n target[key] = merged;\n }\n else if (Array.isArray(sourceValue)) {\n target[key] = mergeWith(targetValue ?? [], sourceValue, merge);\n }\n else if (isObjectLike(targetValue) && isObjectLike(sourceValue)) {\n target[key] = mergeWith(targetValue ?? {}, sourceValue, merge);\n }\n else if (targetValue === undefined || sourceValue !== undefined) {\n target[key] = sourceValue;\n }\n }\n return target;\n}\n\nexport { mergeWith };\n","import { mergeWith } from \"es-toolkit\"\nimport { isPlainObject } from \"remeda\"\nimport type { MergeDeep } from \"type-fest\"\n\ntype AnyObj = Record<PropertyKey, unknown>\n\n/**\n * A wrapper around es-toolkit's `mergeWith` with a custom merge function that concatenates arrays.\n */\nfunction merge<T extends AnyObj, S extends AnyObj>(target: T, source: S): T & S {\n return mergeWith(target, source, (objValue: unknown, srcValue: unknown) =>\n Array.isArray(objValue) ? objValue.concat(srcValue) : undefined,\n )\n}\n\n/**\n * Creates a config merge function with proper type overloads for merging with a base config.\n */\nexport function createMergeConfigFn<UserConfigType, BaseConfig extends UserConfigType>(baseConfig: BaseConfig) {\n //\n\n // if `userConfig` is not provided, return the type of `baseConfig`\n function mergeConfig(): BaseConfig\n\n // if `userConfig` is provided, instead of returning `BaseConfig & UserConfig` (from `merge`), return a more friendly type using `MergeDeep`\n function mergeConfig<UserConfig extends UserConfigType>(\n userConfig: UserConfig,\n ): MergeDeep<BaseConfig, UserConfig, { arrayMergeMode: \"spread\" }>\n\n function mergeConfig<UserConfig extends UserConfigType>(userConfig?: UserConfig) {\n if (userConfig === undefined) return baseConfig\n\n if (!(isPlainObject(baseConfig) && isPlainObject(userConfig)))\n throw new Error(`target and/or source is not an object: target='${baseConfig}'\\nsource='${userConfig}'`)\n\n return merge(baseConfig, userConfig)\n }\n\n return mergeConfig\n}\n","import type { KnipConfig } from \"knip\"\n\n// biome-ignore lint/plugin: ignore\nimport { createMergeConfigFn } from \"./utils.ts\"\n\n// Normally, specifying the `./src/index.ts` entry would cause knip to complain about a redundant entry because it gets automatically included via the tsdown plugin.\n// However, in projects that _don't_ use tsdown, the `./src/index.ts` entry would be missing entirely.\n// To handle this, we specify it and disable the tsdown plugin. This makes knip work in both cases.\n\nconst baseConfig = {\n entry: [\"./src/index.ts\", \"**/*.test.ts\", \"./tsdown.config.ts\"],\n project: [\"**\"],\n tsdown: false,\n} as const satisfies KnipConfig\n\nexport const knipConfig = createMergeConfigFn<KnipConfig, typeof baseConfig>(baseConfig)\n","import type { Config } from \"prettier\"\n\n// biome-ignore lint/plugin: ignore\nimport { createMergeConfigFn } from \"./utils.ts\"\n\nconst baseConfig = {\n printWidth: 120,\n semi: false,\n plugins: [\n \"@prettier/plugin-xml\",\n \"prettier-plugin-sh\",\n \"prettier-plugin-toml\",\n \"prettier-plugin-astro\",\n \"prettier-plugin-tailwindcss\",\n ],\n tailwindStylesheet: \"./src/global.css\",\n overrides: [\n {\n // https://github.com/prettier/prettier/issues/15956\n files: \"*.jsonc\",\n options: {\n trailingComma: \"none\",\n },\n },\n {\n files: \"*.astro\",\n options: {\n parser: \"astro\",\n },\n },\n ],\n} as const satisfies Config\n\nexport const prettierConfig = createMergeConfigFn<Config, typeof baseConfig>(baseConfig)\n","import type { UserConfig } from \"tsdown\"\n\n// biome-ignore lint/plugin: ignore\nimport { createMergeConfigFn } from \"./utils.ts\"\n\nconst baseConfig = {\n entry: [\"./src/index.ts\"],\n unbundle: true,\n target: false,\n platform: \"neutral\",\n minify: \"dce-only\",\n sourcemap: true,\n dts: {\n newContext: true,\n sourcemap: true,\n },\n attw: {\n level: \"error\",\n profile: \"esmOnly\",\n },\n publint: true,\n failOnWarn: true,\n} as const satisfies UserConfig\n\nexport const tsdownConfig = createMergeConfigFn<UserConfig, typeof baseConfig>(baseConfig)\n"],"x_google_ignoreList":[0,1,2],"mappings":";AAAA,SAAS,iBAAiB,KAAK;AAC3B,QAAO,QAAQ;;ACDnB,SAAS,aAAa,OAAO;AACzB,QAAO,OAAO,UAAU,YAAY,UAAU;;ACElD,SAAS,UAAU,QAAQ,QAAQ,SAAO;CACtC,MAAM,aAAa,OAAO,KAAK,OAAO;AACtC,MAAK,IAAI,IAA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ACTxF,MAAa,eAAe,oBAnBT;CACjB,OAAO,CAAC,iBAAiB;CACzB,UAAU;CACV,QAAQ;CACR,UAAU;CACV,QAAQ;CACR,WAAW;CACX,KAAK;EACH,YAAY;EACZ,WAAW;EACZ;CACD,MAAM;EACJ,OAAO;EACP,SAAS;EACV;CACD,SAAS;CACT,YAAY;CACb,CAEyF"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { knipConfig } from "./index.ts";
|
|
2
|
+
const entries = knipConfig().entry;
|
|
3
|
+
const preprocess = (options) => {
|
|
4
|
+
const filteredConfigurationHints = [...options.configurationHints].filter((hint) => !(typeof hint.identifier === "string" && entries.includes(hint.identifier) && hint.type === "entry-empty"));
|
|
5
|
+
options.configurationHints = new Set(filteredConfigurationHints);
|
|
6
|
+
return options;
|
|
7
|
+
};
|
|
8
|
+
var knip_preprocessor_default = preprocess;
|
|
9
|
+
export { knip_preprocessor_default as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adamhl8/configs",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,17 +17,20 @@
|
|
|
17
17
|
},
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"exports": {
|
|
20
|
-
"./tsconfig": "./dist/tsconfig.json",
|
|
20
|
+
"./tsconfig": "./dist/tsconfig.base.json",
|
|
21
21
|
"./biome": "./dist/biome.base.json",
|
|
22
22
|
".": {
|
|
23
23
|
"types": "./dist/index.d.ts",
|
|
24
24
|
"import": "./dist/index.js"
|
|
25
25
|
}
|
|
26
26
|
},
|
|
27
|
+
"directories": {
|
|
28
|
+
"bin": "dist/bin/"
|
|
29
|
+
},
|
|
27
30
|
"files": ["dist/"],
|
|
28
31
|
"scripts": {
|
|
29
32
|
"bundle": "bun lint && bun tsdown",
|
|
30
|
-
"lint": "bun generate-biome-rules.ts && tsc --noEmit && biome check --write",
|
|
33
|
+
"lint": "bun generate-biome-rules.ts && tsc --noEmit && biome check --write && bun ./src/bin/adamhl8-knip.ts",
|
|
31
34
|
"postinstall": "mkdir -p ./node_modules/@adamhl8/configs/dist/ && cp -r ./src/biome-plugins/ ./node_modules/@adamhl8/configs/dist/",
|
|
32
35
|
"prepare": "find .githooks -type f -exec ln -srf {} .git/hooks/ \\; || true",
|
|
33
36
|
"prepublishOnly": "bun bundle"
|
|
@@ -43,7 +46,7 @@
|
|
|
43
46
|
"devDependencies": {
|
|
44
47
|
"@arethetypeswrong/core": "^0.18.2",
|
|
45
48
|
"@biomejs/biome": "^2.2.4",
|
|
46
|
-
"@types/bun": "^1.2.
|
|
49
|
+
"@types/bun": "^1.2.22",
|
|
47
50
|
"es-toolkit": "^1.39.10",
|
|
48
51
|
"knip": "^5.63.1",
|
|
49
52
|
"prettier": "^3.6.2",
|