@keychord/config 0.0.0 → 0.0.1
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/exports/default.d.mts +24 -0
- package/exports/default.mjs +30 -0
- package/package.json +5 -1
- package/tsconfig.json +0 -4
- package/vite.config.ts +0 -12
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
//#region src/default.d.ts
|
|
2
|
+
type Options = {
|
|
3
|
+
vendor?: string[];
|
|
4
|
+
dts?: boolean;
|
|
5
|
+
};
|
|
6
|
+
declare function config(options?: Options): {
|
|
7
|
+
plugins: any[];
|
|
8
|
+
pack: {
|
|
9
|
+
entry: Record<string, string>;
|
|
10
|
+
outDir: string;
|
|
11
|
+
deps: {
|
|
12
|
+
neverBundle: string[];
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
run: {
|
|
16
|
+
tasks: {
|
|
17
|
+
fix: {
|
|
18
|
+
command: string;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
//#endregion
|
|
24
|
+
export { Options, config };
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import fs from "fs";
|
|
3
|
+
import virtual from "vite-plugin-virtual";
|
|
4
|
+
import { fileURLToPath } from "url";
|
|
5
|
+
//#region src/default.ts
|
|
6
|
+
function config(options) {
|
|
7
|
+
const srcJsDirpath = path.join(process.cwd(), "src/js");
|
|
8
|
+
let entry = {};
|
|
9
|
+
if (fs.existsSync(srcJsDirpath) && fs.statSync(srcJsDirpath).isDirectory()) for (const filename of fs.readdirSync(srcJsDirpath).filter((file) => file.endsWith(".ts"))) entry[path.parse(filename).name] = path.join(srcJsDirpath, filename);
|
|
10
|
+
if (Object.keys(entry).length === 0) entry["noop"] = "virtual:empty";
|
|
11
|
+
const specifier = fileURLToPath(import.meta.resolve("@keychord/eslint-plugin-package-json"));
|
|
12
|
+
const eslintBinPath = path.join(fileURLToPath(import.meta.resolve("eslint/package.json")), "../bin/eslint.js");
|
|
13
|
+
return {
|
|
14
|
+
plugins: [virtual({ "virtual:empty": "" })],
|
|
15
|
+
pack: {
|
|
16
|
+
entry,
|
|
17
|
+
outDir: "js",
|
|
18
|
+
deps: { neverBundle: ["chord", ...options?.vendor ?? []] }
|
|
19
|
+
},
|
|
20
|
+
run: { tasks: { fix: { command: `
|
|
21
|
+
${eslintBinPath} **/package.json \
|
|
22
|
+
--no-config-lookup \
|
|
23
|
+
--fix \
|
|
24
|
+
--plugin ${specifier} \
|
|
25
|
+
--rule '@keychord/package-json/type: error'
|
|
26
|
+
` } } }
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
export { config };
|
package/package.json
CHANGED
package/tsconfig.json
DELETED