@zayne-labs/prettier-config 0.11.29 → 0.11.31
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/constants/defaults.js +1 -36
- package/dist/defaults-DSLyxKBp.js +36 -0
- package/dist/defaults-DSLyxKBp.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -8
- package/dist/index.js.map +1 -1
- package/dist/plugins/safe-sort-imports.js +2 -3
- package/dist/plugins/safe-sort-imports.js.map +1 -1
- package/dist/{types-D6q0MZ28.d.ts → types-DYlPXXa_.d.ts} +1 -1
- package/dist/utils-4qxCZ86b.js +58 -0
- package/dist/utils-4qxCZ86b.js.map +1 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +1 -58
- package/package.json +7 -7
- package/dist/constants/defaults.js.map +0 -1
- package/dist/utils.js.map +0 -1
|
@@ -1,37 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
//#region src/constants/defaults.ts
|
|
4
|
-
const getDefaultTailwindSettings = () => {
|
|
5
|
-
return defineEnumDeep({
|
|
6
|
-
tailwindAttributes: [
|
|
7
|
-
"className",
|
|
8
|
-
"classNames",
|
|
9
|
-
"classes"
|
|
10
|
-
],
|
|
11
|
-
tailwindFunctions: [
|
|
12
|
-
"cnMerge",
|
|
13
|
-
"cnJoin",
|
|
14
|
-
"cn",
|
|
15
|
-
"tv",
|
|
16
|
-
"tw"
|
|
17
|
-
],
|
|
18
|
-
tailwindStylesheet: "./tailwind.css"
|
|
19
|
-
});
|
|
20
|
-
};
|
|
21
|
-
const getDefaultImportSortingOrder = () => {
|
|
22
|
-
return defineEnumDeep({
|
|
23
|
-
css: ".css$",
|
|
24
|
-
main: [
|
|
25
|
-
"^https?://",
|
|
26
|
-
"<BUILTIN_MODULES>",
|
|
27
|
-
"^(bun|jsr|npm):",
|
|
28
|
-
"<THIRD_PARTY_MODULES>",
|
|
29
|
-
"^(@@?/|[#$%~])",
|
|
30
|
-
"^(?!.*[.]css$)[./].*$"
|
|
31
|
-
]
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
//#endregion
|
|
1
|
+
import { n as getDefaultTailwindSettings, t as getDefaultImportSortingOrder } from "../defaults-DSLyxKBp.js";
|
|
36
2
|
export { getDefaultImportSortingOrder, getDefaultTailwindSettings };
|
|
37
|
-
//# sourceMappingURL=defaults.js.map
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { defineEnumDeep } from "@zayne-labs/toolkit-type-helpers";
|
|
2
|
+
//#region src/constants/defaults.ts
|
|
3
|
+
const getDefaultTailwindSettings = () => {
|
|
4
|
+
return defineEnumDeep({
|
|
5
|
+
tailwindAttributes: [
|
|
6
|
+
"className",
|
|
7
|
+
"classNames",
|
|
8
|
+
"classes"
|
|
9
|
+
],
|
|
10
|
+
tailwindFunctions: [
|
|
11
|
+
"cnMerge",
|
|
12
|
+
"cnJoin",
|
|
13
|
+
"cn",
|
|
14
|
+
"tv",
|
|
15
|
+
"tw"
|
|
16
|
+
],
|
|
17
|
+
tailwindStylesheet: "./tailwind.css"
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const getDefaultImportSortingOrder = () => {
|
|
21
|
+
return defineEnumDeep({
|
|
22
|
+
css: ".css$",
|
|
23
|
+
main: [
|
|
24
|
+
"^https?://",
|
|
25
|
+
"<BUILTIN_MODULES>",
|
|
26
|
+
"^(bun|jsr|npm):",
|
|
27
|
+
"<THIRD_PARTY_MODULES>",
|
|
28
|
+
"^(@@?/|[#$%~])",
|
|
29
|
+
"^(?!.*[.]css$)[./].*$"
|
|
30
|
+
]
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { getDefaultTailwindSettings as n, getDefaultImportSortingOrder as t };
|
|
35
|
+
|
|
36
|
+
//# sourceMappingURL=defaults-DSLyxKBp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults-DSLyxKBp.js","names":[],"sources":["../src/constants/defaults.ts"],"sourcesContent":["import { defineEnumDeep } from \"@zayne-labs/toolkit-type-helpers\";\n\nexport const getDefaultTailwindSettings = () => {\n\treturn defineEnumDeep({\n\t\ttailwindAttributes: [\"className\", \"classNames\", \"classes\"],\n\t\ttailwindFunctions: [\"cnMerge\", \"cnJoin\", \"cn\", \"tv\", \"tw\"],\n\t\ttailwindStylesheet: \"./tailwind.css\",\n\t});\n};\n\nexport const getDefaultImportSortingOrder = () => {\n\treturn defineEnumDeep({\n\t\t// CSS files (always last)\n\t\tcss: \".css$\",\n\n\t\tmain: [\n\t\t\t// URLs (e.g., https://example.org)\n\t\t\t\"^https?://\",\n\t\t\t// Protocol imports (node:, bun:, jsr:, npm:, etc.)\n\t\t\t\"<BUILTIN_MODULES>\",\n\t\t\t\"^(bun|jsr|npm):\",\n\t\t\t// Third-party packages\n\t\t\t\"<THIRD_PARTY_MODULES>\",\n\t\t\t// Aliases (@/, @@/, #, ~, $, %)\n\t\t\t\"^(@@?/|[#$%~])\",\n\t\t\t// Relative and absolute paths (excluding CSS)\n\t\t\t\"^(?!.*[.]css$)[./].*$\",\n\t\t],\n\t});\n};\n"],"mappings":";;AAEA,MAAa,mCAAmC;AAC/C,QAAO,eAAe;EACrB,oBAAoB;GAAC;GAAa;GAAc;GAAU;EAC1D,mBAAmB;GAAC;GAAW;GAAU;GAAM;GAAM;GAAK;EAC1D,oBAAoB;EACpB,CAAC;;AAGH,MAAa,qCAAqC;AACjD,QAAO,eAAe;EAErB,KAAK;EAEL,MAAM;GAEL;GAEA;GACA;GAEA;GAEA;GAEA;GACA;EACD,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as OptionsTailwindCss, i as OptionsSortImports, n as OptionsAstro, o as ResolvedPrettierConfig, r as OptionsPrettierConfig, t as ExtractOptions } from "./types-
|
|
1
|
+
import { a as OptionsTailwindCss, i as OptionsSortImports, n as OptionsAstro, o as ResolvedPrettierConfig, r as OptionsPrettierConfig, t as ExtractOptions } from "./types-DYlPXXa_.js";
|
|
2
2
|
|
|
3
3
|
//#region src/configs/astro.d.ts
|
|
4
4
|
declare const astro: (options: ExtractOptions<OptionsPrettierConfig["astro"]>) => Promise<typeof options>;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { n as ensurePackages, o as resolveOptions, t as combineConfigs } from "./utils-4qxCZ86b.js";
|
|
2
|
+
import { n as getDefaultTailwindSettings, t as getDefaultImportSortingOrder } from "./defaults-DSLyxKBp.js";
|
|
4
3
|
//#region src/configs/astro.ts
|
|
5
4
|
const astro = async (options) => {
|
|
6
5
|
await ensurePackages(["prettier-plugin-astro"]);
|
|
@@ -13,7 +12,6 @@ const astro = async (options) => {
|
|
|
13
12
|
plugins: ["prettier-plugin-astro", ...options.plugins ?? []]
|
|
14
13
|
};
|
|
15
14
|
};
|
|
16
|
-
|
|
17
15
|
//#endregion
|
|
18
16
|
//#region src/configs/base.ts
|
|
19
17
|
const base = (options) => {
|
|
@@ -29,7 +27,6 @@ const base = (options) => {
|
|
|
29
27
|
...options
|
|
30
28
|
};
|
|
31
29
|
};
|
|
32
|
-
|
|
33
30
|
//#endregion
|
|
34
31
|
//#region src/configs/tailwindcss.ts
|
|
35
32
|
const tailwindcss = async (options) => {
|
|
@@ -54,7 +51,6 @@ const tailwindcss = async (options) => {
|
|
|
54
51
|
tailwindFunctions: [...tailwindSettings.tailwindFunctions, ...options.tailwindFunctions ?? []]
|
|
55
52
|
};
|
|
56
53
|
};
|
|
57
|
-
|
|
58
54
|
//#endregion
|
|
59
55
|
//#region src/configs/sort.ts
|
|
60
56
|
const sortImports = async (options) => {
|
|
@@ -72,7 +68,6 @@ const sortImports = async (options) => {
|
|
|
72
68
|
plugins: ["@zayne-labs/prettier-config/plugins/safe-sort-imports", ...options.plugins ?? []]
|
|
73
69
|
};
|
|
74
70
|
};
|
|
75
|
-
|
|
76
71
|
//#endregion
|
|
77
72
|
//#region src/factory.ts
|
|
78
73
|
/**
|
|
@@ -108,7 +103,7 @@ const zayne = async (options = {}, ...extraConfigs) => {
|
|
|
108
103
|
enabledTailwindcss ? tailwindcss(resolveOptions(enabledTailwindcss)) : void 0
|
|
109
104
|
]);
|
|
110
105
|
};
|
|
111
|
-
|
|
112
106
|
//#endregion
|
|
113
107
|
export { astro, base, sortImports, tailwindcss, zayne };
|
|
108
|
+
|
|
114
109
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../src/configs/astro.ts","../src/configs/base.ts","../src/configs/tailwindcss.ts","../src/configs/sort.ts","../src/factory.ts"],"sourcesContent":["import type { ExtractOptions, OptionsPrettierConfig } from \"@/types\";\nimport { ensurePackages } from \"@/utils\";\n\nexport const astro = async (\n\toptions: ExtractOptions<OptionsPrettierConfig[\"astro\"]>\n): Promise<typeof options> => {\n\tawait ensurePackages([\"prettier-plugin-astro\"]);\n\n\treturn {\n\t\t...options,\n\n\t\toverrides: [\n\t\t\t{\n\t\t\t\tfiles: \"*.astro\",\n\t\t\t\toptions: { parser: \"astro\" },\n\t\t\t},\n\t\t\t...(options.overrides ?? []),\n\t\t],\n\n\t\tplugins: [\"prettier-plugin-astro\", ...(options.plugins ?? [])],\n\t};\n};\n","import type { ExtractOptions, OptionsPrettierConfig } from \"@/types\";\n\nexport const base = (options: ExtractOptions<OptionsPrettierConfig[\"base\"]>): typeof options => {\n\treturn {\n\t\texperimentalOperatorPosition: \"start\",\n\t\texperimentalTernaries: true,\n\t\tjsxSingleQuote: false,\n\t\tprintWidth: 107,\n\t\tsingleQuote: false,\n\t\ttabWidth: 3,\n\t\ttrailingComma: \"es5\",\n\t\tuseTabs: true,\n\n\t\t...options,\n\t};\n};\n","import { getDefaultTailwindSettings } from \"@/constants/defaults\";\nimport type { ExtractOptions, OptionsPrettierConfig } from \"@/types\";\nimport { ensurePackages } from \"@/utils\";\n\nexport const tailwindcss = async (\n\toptions: ExtractOptions<OptionsPrettierConfig[\"tailwindcss\"]>\n): Promise<typeof options> => {\n\tawait ensurePackages([\n\t\t\"prettier-plugin-tailwindcss\",\n\t\t\"prettier-plugin-classnames\",\n\t\t\"prettier-plugin-merge\",\n\t]);\n\n\tconst tailwindSettings = getDefaultTailwindSettings();\n\n\treturn {\n\t\ttailwindStylesheet: tailwindSettings.tailwindStylesheet,\n\n\t\t...options,\n\n\t\tcustomAttributes: [...tailwindSettings.tailwindAttributes, ...(options.customAttributes ?? [])],\n\t\tcustomFunctions: [...tailwindSettings.tailwindFunctions, ...(options.customFunctions ?? [])],\n\n\t\tplugins: [\n\t\t\t\"prettier-plugin-tailwindcss\",\n\t\t\t\"prettier-plugin-classnames\",\n\n\t\t\t...(options.plugins ?? []),\n\n\t\t\t/**\n\t\t\t * The 'merge' plugin must always come last\n\t\t\t * @see https://github.com/ony3000/prettier-plugin-merge#why-prettier-plugin-merge\n\t\t\t */\n\t\t\t\"prettier-plugin-merge\",\n\t\t],\n\n\t\ttailwindAttributes: [...tailwindSettings.tailwindAttributes, ...(options.tailwindAttributes ?? [])],\n\t\ttailwindFunctions: [...tailwindSettings.tailwindFunctions, ...(options.tailwindFunctions ?? [])],\n\t};\n};\n","import { getDefaultImportSortingOrder } from \"@/constants/defaults\";\nimport type { ExtractOptions, OptionsPrettierConfig } from \"@/types\";\nimport { ensurePackages } from \"@/utils\";\n\nexport const sortImports = async (\n\toptions: ExtractOptions<OptionsPrettierConfig[\"sortImports\"]>\n): Promise<typeof options> => {\n\tawait ensurePackages([\"@ianvs/prettier-plugin-sort-imports\"]);\n\n\tconst sortingOrder = getDefaultImportSortingOrder();\n\n\treturn {\n\t\t...options,\n\n\t\timportOrder: [...sortingOrder.main, ...(options.importOrder ?? []), sortingOrder.css],\n\t\timportOrderSafeSideEffects: [sortingOrder.css, ...(options.importOrderSafeSideEffects ?? [])],\n\t\timportOrderTypeScriptVersion: \"5.9.3\",\n\n\t\tplugins: [\"@zayne-labs/prettier-config/plugins/safe-sort-imports\", ...(options.plugins ?? [])],\n\t};\n};\n","import type { Awaitable } from \"@zayne-labs/toolkit-type-helpers\";\nimport { astro, base, sortImports, tailwindcss } from \"./configs\";\nimport type { OptionsPrettierConfig, ResolvedPrettierConfig } from \"./types\";\nimport { combineConfigs, resolveOptions } from \"./utils\";\n\n/**\n * @description Factory function for creating a customized Prettier configuration.\n * Combines base, Astro, and Tailwind CSS configurations based on the provided options.\n * Any Array values (like `plugins` and `overrides`) are merged, while other values are overwritten.\n *\n * @example\n * ```ts\n * // prettier.config.ts\n * import { zayne } from \"@zayne-labs/prettier-config\";\n *\n * export default zayne(\n * {\n * base: true,\n * tailwindcss: { tailwindStylesheet: \"./src/styles.css\" },\n * astro: true,\n * },\n * // Extra config to merge (optional)\n * {\n * useTabs: false,\n * }\n * );\n * ```\n */\nexport const zayne = async (\n\toptions: OptionsPrettierConfig = {},\n\t...extraConfigs: ResolvedPrettierConfig[]\n) => {\n\tconst {\n\t\tastro: enabledAstro = false,\n\t\tbase: enabledBase = true,\n\t\tsortImports: enabledSortImports = true,\n\t\ttailwindcss: enabledTailwindcss = false,\n\t} = options;\n\n\tconst configArray: Array<Awaitable<ResolvedPrettierConfig | undefined>> = [\n\t\tenabledBase ? base(resolveOptions(enabledBase)) : undefined,\n\t\tenabledAstro ? astro(resolveOptions(enabledAstro)) : undefined,\n\t\tenabledSortImports ? sortImports(resolveOptions(enabledSortImports)) : undefined,\n\n\t\t...extraConfigs,\n\n\t\t/**\n\t\t * Tailwind plugin most always be the last one to avoid conflicts\n\t\t * @see https://github.com/tailwindlabs/prettier-plugin-tailwindcss#compatibility-with-other-prettier-plugins\n\t\t */\n\t\tenabledTailwindcss ? tailwindcss(resolveOptions(enabledTailwindcss)) : undefined,\n\t];\n\n\tconst accumulatedConfig = await combineConfigs(configArray);\n\n\treturn accumulatedConfig;\n};\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/configs/astro.ts","../src/configs/base.ts","../src/configs/tailwindcss.ts","../src/configs/sort.ts","../src/factory.ts"],"sourcesContent":["import type { ExtractOptions, OptionsPrettierConfig } from \"@/types\";\nimport { ensurePackages } from \"@/utils\";\n\nexport const astro = async (\n\toptions: ExtractOptions<OptionsPrettierConfig[\"astro\"]>\n): Promise<typeof options> => {\n\tawait ensurePackages([\"prettier-plugin-astro\"]);\n\n\treturn {\n\t\t...options,\n\n\t\toverrides: [\n\t\t\t{\n\t\t\t\tfiles: \"*.astro\",\n\t\t\t\toptions: { parser: \"astro\" },\n\t\t\t},\n\t\t\t...(options.overrides ?? []),\n\t\t],\n\n\t\tplugins: [\"prettier-plugin-astro\", ...(options.plugins ?? [])],\n\t};\n};\n","import type { ExtractOptions, OptionsPrettierConfig } from \"@/types\";\n\nexport const base = (options: ExtractOptions<OptionsPrettierConfig[\"base\"]>): typeof options => {\n\treturn {\n\t\texperimentalOperatorPosition: \"start\",\n\t\texperimentalTernaries: true,\n\t\tjsxSingleQuote: false,\n\t\tprintWidth: 107,\n\t\tsingleQuote: false,\n\t\ttabWidth: 3,\n\t\ttrailingComma: \"es5\",\n\t\tuseTabs: true,\n\n\t\t...options,\n\t};\n};\n","import { getDefaultTailwindSettings } from \"@/constants/defaults\";\nimport type { ExtractOptions, OptionsPrettierConfig } from \"@/types\";\nimport { ensurePackages } from \"@/utils\";\n\nexport const tailwindcss = async (\n\toptions: ExtractOptions<OptionsPrettierConfig[\"tailwindcss\"]>\n): Promise<typeof options> => {\n\tawait ensurePackages([\n\t\t\"prettier-plugin-tailwindcss\",\n\t\t\"prettier-plugin-classnames\",\n\t\t\"prettier-plugin-merge\",\n\t]);\n\n\tconst tailwindSettings = getDefaultTailwindSettings();\n\n\treturn {\n\t\ttailwindStylesheet: tailwindSettings.tailwindStylesheet,\n\n\t\t...options,\n\n\t\tcustomAttributes: [...tailwindSettings.tailwindAttributes, ...(options.customAttributes ?? [])],\n\t\tcustomFunctions: [...tailwindSettings.tailwindFunctions, ...(options.customFunctions ?? [])],\n\n\t\tplugins: [\n\t\t\t\"prettier-plugin-tailwindcss\",\n\t\t\t\"prettier-plugin-classnames\",\n\n\t\t\t...(options.plugins ?? []),\n\n\t\t\t/**\n\t\t\t * The 'merge' plugin must always come last\n\t\t\t * @see https://github.com/ony3000/prettier-plugin-merge#why-prettier-plugin-merge\n\t\t\t */\n\t\t\t\"prettier-plugin-merge\",\n\t\t],\n\n\t\ttailwindAttributes: [...tailwindSettings.tailwindAttributes, ...(options.tailwindAttributes ?? [])],\n\t\ttailwindFunctions: [...tailwindSettings.tailwindFunctions, ...(options.tailwindFunctions ?? [])],\n\t};\n};\n","import { getDefaultImportSortingOrder } from \"@/constants/defaults\";\nimport type { ExtractOptions, OptionsPrettierConfig } from \"@/types\";\nimport { ensurePackages } from \"@/utils\";\n\nexport const sortImports = async (\n\toptions: ExtractOptions<OptionsPrettierConfig[\"sortImports\"]>\n): Promise<typeof options> => {\n\tawait ensurePackages([\"@ianvs/prettier-plugin-sort-imports\"]);\n\n\tconst sortingOrder = getDefaultImportSortingOrder();\n\n\treturn {\n\t\t...options,\n\n\t\timportOrder: [...sortingOrder.main, ...(options.importOrder ?? []), sortingOrder.css],\n\t\timportOrderSafeSideEffects: [sortingOrder.css, ...(options.importOrderSafeSideEffects ?? [])],\n\t\timportOrderTypeScriptVersion: \"5.9.3\",\n\n\t\tplugins: [\"@zayne-labs/prettier-config/plugins/safe-sort-imports\", ...(options.plugins ?? [])],\n\t};\n};\n","import type { Awaitable } from \"@zayne-labs/toolkit-type-helpers\";\nimport { astro, base, sortImports, tailwindcss } from \"./configs\";\nimport type { OptionsPrettierConfig, ResolvedPrettierConfig } from \"./types\";\nimport { combineConfigs, resolveOptions } from \"./utils\";\n\n/**\n * @description Factory function for creating a customized Prettier configuration.\n * Combines base, Astro, and Tailwind CSS configurations based on the provided options.\n * Any Array values (like `plugins` and `overrides`) are merged, while other values are overwritten.\n *\n * @example\n * ```ts\n * // prettier.config.ts\n * import { zayne } from \"@zayne-labs/prettier-config\";\n *\n * export default zayne(\n * {\n * base: true,\n * tailwindcss: { tailwindStylesheet: \"./src/styles.css\" },\n * astro: true,\n * },\n * // Extra config to merge (optional)\n * {\n * useTabs: false,\n * }\n * );\n * ```\n */\nexport const zayne = async (\n\toptions: OptionsPrettierConfig = {},\n\t...extraConfigs: ResolvedPrettierConfig[]\n) => {\n\tconst {\n\t\tastro: enabledAstro = false,\n\t\tbase: enabledBase = true,\n\t\tsortImports: enabledSortImports = true,\n\t\ttailwindcss: enabledTailwindcss = false,\n\t} = options;\n\n\tconst configArray: Array<Awaitable<ResolvedPrettierConfig | undefined>> = [\n\t\tenabledBase ? base(resolveOptions(enabledBase)) : undefined,\n\t\tenabledAstro ? astro(resolveOptions(enabledAstro)) : undefined,\n\t\tenabledSortImports ? sortImports(resolveOptions(enabledSortImports)) : undefined,\n\n\t\t...extraConfigs,\n\n\t\t/**\n\t\t * Tailwind plugin most always be the last one to avoid conflicts\n\t\t * @see https://github.com/tailwindlabs/prettier-plugin-tailwindcss#compatibility-with-other-prettier-plugins\n\t\t */\n\t\tenabledTailwindcss ? tailwindcss(resolveOptions(enabledTailwindcss)) : undefined,\n\t];\n\n\tconst accumulatedConfig = await combineConfigs(configArray);\n\n\treturn accumulatedConfig;\n};\n"],"mappings":";;;AAGA,MAAa,QAAQ,OACpB,YAC6B;AAC7B,OAAM,eAAe,CAAC,wBAAwB,CAAC;AAE/C,QAAO;EACN,GAAG;EAEH,WAAW,CACV;GACC,OAAO;GACP,SAAS,EAAE,QAAQ,SAAS;GAC5B,EACD,GAAI,QAAQ,aAAa,EAAE,CAC3B;EAED,SAAS,CAAC,yBAAyB,GAAI,QAAQ,WAAW,EAAE,CAAE;EAC9D;;;;AClBF,MAAa,QAAQ,YAA2E;AAC/F,QAAO;EACN,8BAA8B;EAC9B,uBAAuB;EACvB,gBAAgB;EAChB,YAAY;EACZ,aAAa;EACb,UAAU;EACV,eAAe;EACf,SAAS;EAET,GAAG;EACH;;;;ACVF,MAAa,cAAc,OAC1B,YAC6B;AAC7B,OAAM,eAAe;EACpB;EACA;EACA;EACA,CAAC;CAEF,MAAM,mBAAmB,4BAA4B;AAErD,QAAO;EACN,oBAAoB,iBAAiB;EAErC,GAAG;EAEH,kBAAkB,CAAC,GAAG,iBAAiB,oBAAoB,GAAI,QAAQ,oBAAoB,EAAE,CAAE;EAC/F,iBAAiB,CAAC,GAAG,iBAAiB,mBAAmB,GAAI,QAAQ,mBAAmB,EAAE,CAAE;EAE5F,SAAS;GACR;GACA;GAEA,GAAI,QAAQ,WAAW,EAAE;GAMzB;GACA;EAED,oBAAoB,CAAC,GAAG,iBAAiB,oBAAoB,GAAI,QAAQ,sBAAsB,EAAE,CAAE;EACnG,mBAAmB,CAAC,GAAG,iBAAiB,mBAAmB,GAAI,QAAQ,qBAAqB,EAAE,CAAE;EAChG;;;;AClCF,MAAa,cAAc,OAC1B,YAC6B;AAC7B,OAAM,eAAe,CAAC,sCAAsC,CAAC;CAE7D,MAAM,eAAe,8BAA8B;AAEnD,QAAO;EACN,GAAG;EAEH,aAAa;GAAC,GAAG,aAAa;GAAM,GAAI,QAAQ,eAAe,EAAE;GAAG,aAAa;GAAI;EACrF,4BAA4B,CAAC,aAAa,KAAK,GAAI,QAAQ,8BAA8B,EAAE,CAAE;EAC7F,8BAA8B;EAE9B,SAAS,CAAC,yDAAyD,GAAI,QAAQ,WAAW,EAAE,CAAE;EAC9F;;;;;;;;;;;;;;;;;;;;;;;;;;;ACSF,MAAa,QAAQ,OACpB,UAAiC,EAAE,EACnC,GAAG,iBACC;CACJ,MAAM,EACL,OAAO,eAAe,OACtB,MAAM,cAAc,MACpB,aAAa,qBAAqB,MAClC,aAAa,qBAAqB,UAC/B;AAkBJ,QAF0B,MAAM,eAd0C;EACzE,cAAc,KAAK,eAAe,YAAY,CAAC,GAAG,KAAA;EAClD,eAAe,MAAM,eAAe,aAAa,CAAC,GAAG,KAAA;EACrD,qBAAqB,YAAY,eAAe,mBAAmB,CAAC,GAAG,KAAA;EAEvE,GAAG;EAMH,qBAAqB,YAAY,eAAe,mBAAmB,CAAC,GAAG,KAAA;EACvE,CAE0D"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { i as isPackageInScope, r as interopDefault } from "../utils-4qxCZ86b.js";
|
|
3
2
|
//#region src/plugins/safe-sort-imports.ts
|
|
4
3
|
/**
|
|
5
4
|
* @description This is a temporary fix until the plugin is updated to only load the parsers for the plugins that are in scope.
|
|
@@ -16,7 +15,7 @@ const getSafeSortPlugin = async () => {
|
|
|
16
15
|
return prettierSortImportsPlugin;
|
|
17
16
|
};
|
|
18
17
|
const safeSortPlugin = await getSafeSortPlugin();
|
|
19
|
-
|
|
20
18
|
//#endregion
|
|
21
19
|
export { safeSortPlugin as default };
|
|
20
|
+
|
|
22
21
|
//# sourceMappingURL=safe-sort-imports.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"safe-sort-imports.js","names":[],"sources":["../../src/plugins/safe-sort-imports.ts"],"sourcesContent":["import type { Parser, Printer } from \"prettier\";\nimport { interopDefault, isPackageInScope } from \"@/utils\";\n\n/**\n * @description This is a temporary fix until the plugin is updated to only load the parsers for the plugins that are in scope.\n * @see https://github.com/ianvs/prettier-plugin-sort-imports/issues/233\n */\nconst getSafeSortPlugin = async () => {\n\tconst prettierSortImportsPlugin = (await interopDefault(\n\t\timport(\"@ianvs/prettier-plugin-sort-imports\")\n\t)) as {\n\t\tparsers: Record<string, Parser>;\n\t\tprinters: Record<string, Printer>;\n\t};\n\n\tif (!isPackageInScope(\"prettier-plugin-ember-template-tag\")) {\n\t\tdelete prettierSortImportsPlugin.parsers[\"ember-template-tag\"];\n\t}\n\n\tif (!isPackageInScope(\"@prettier/plugin-oxc\")) {\n\t\tdelete prettierSortImportsPlugin.parsers.oxc;\n\t\tdelete prettierSortImportsPlugin.parsers[\"oxc-ts\"];\n\t\tdelete prettierSortImportsPlugin.printers[\"estree-oxc\"];\n\t}\n\n\treturn prettierSortImportsPlugin;\n};\n\nconst safeSortPlugin = await getSafeSortPlugin();\n\nexport default safeSortPlugin;\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"safe-sort-imports.js","names":[],"sources":["../../src/plugins/safe-sort-imports.ts"],"sourcesContent":["import type { Parser, Printer } from \"prettier\";\nimport { interopDefault, isPackageInScope } from \"@/utils\";\n\n/**\n * @description This is a temporary fix until the plugin is updated to only load the parsers for the plugins that are in scope.\n * @see https://github.com/ianvs/prettier-plugin-sort-imports/issues/233\n */\nconst getSafeSortPlugin = async () => {\n\tconst prettierSortImportsPlugin = (await interopDefault(\n\t\timport(\"@ianvs/prettier-plugin-sort-imports\")\n\t)) as {\n\t\tparsers: Record<string, Parser>;\n\t\tprinters: Record<string, Printer>;\n\t};\n\n\tif (!isPackageInScope(\"prettier-plugin-ember-template-tag\")) {\n\t\tdelete prettierSortImportsPlugin.parsers[\"ember-template-tag\"];\n\t}\n\n\tif (!isPackageInScope(\"@prettier/plugin-oxc\")) {\n\t\tdelete prettierSortImportsPlugin.parsers.oxc;\n\t\tdelete prettierSortImportsPlugin.parsers[\"oxc-ts\"];\n\t\tdelete prettierSortImportsPlugin.printers[\"estree-oxc\"];\n\t}\n\n\treturn prettierSortImportsPlugin;\n};\n\nconst safeSortPlugin = await getSafeSortPlugin();\n\nexport default safeSortPlugin;\n"],"mappings":";;;;;;AAOA,MAAM,oBAAoB,YAAY;CACrC,MAAM,4BAA6B,MAAM,eACxC,OAAO,uCACP;AAKD,KAAI,CAAC,iBAAiB,qCAAqC,CAC1D,QAAO,0BAA0B,QAAQ;AAG1C,KAAI,CAAC,iBAAiB,uBAAuB,EAAE;AAC9C,SAAO,0BAA0B,QAAQ;AACzC,SAAO,0BAA0B,QAAQ;AACzC,SAAO,0BAA0B,SAAS;;AAG3C,QAAO;;AAGR,MAAM,iBAAiB,MAAM,mBAAmB"}
|
|
@@ -176,4 +176,4 @@ type ResolvedPrettierConfig = Omit<Config & OptionsAstro & OptionsSortImports &
|
|
|
176
176
|
type ExtractOptions<TUnion> = Extract<TUnion, object>;
|
|
177
177
|
//#endregion
|
|
178
178
|
export { OptionsTailwindCss as a, OptionsSortImports as i, OptionsAstro as n, ResolvedPrettierConfig as o, OptionsPrettierConfig as r, ExtractOptions as t };
|
|
179
|
-
//# sourceMappingURL=types-
|
|
179
|
+
//# sourceMappingURL=types-DYlPXXa_.d.ts.map
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { fileURLToPath } from "node:url";
|
|
2
|
+
import { isArray, isObject } from "@zayne-labs/toolkit-type-helpers";
|
|
3
|
+
import { isPackageExists } from "local-pkg";
|
|
4
|
+
//#region src/utils.ts
|
|
5
|
+
/**
|
|
6
|
+
* @description Resolves a boolean or object option to an object.
|
|
7
|
+
* If the option is an object, it returns it as-is. Otherwise, returns an empty object.
|
|
8
|
+
*/
|
|
9
|
+
const resolveOptions = (option) => {
|
|
10
|
+
return isObject(option) ? option : {};
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* @description Merges two Prettier configurations.
|
|
14
|
+
* Array values (like `plugins` or `overrides`) are concatenated, while other values from the latter config overwrite the former.
|
|
15
|
+
*/
|
|
16
|
+
const mergeTwoConfigs = (formerConfig, latterConfig) => {
|
|
17
|
+
const configAccumulator = { ...formerConfig };
|
|
18
|
+
for (const [latterConfigKey, latterConfigValue] of Object.entries(latterConfig)) {
|
|
19
|
+
const accumulatedConfigValue = configAccumulator[latterConfigKey];
|
|
20
|
+
configAccumulator[latterConfigKey] = isArray(latterConfigValue) && isArray(accumulatedConfigValue) ? [...accumulatedConfigValue, ...latterConfigValue] : latterConfigValue;
|
|
21
|
+
}
|
|
22
|
+
return configAccumulator;
|
|
23
|
+
};
|
|
24
|
+
const interopDefault = async (module) => {
|
|
25
|
+
const resolved = await module;
|
|
26
|
+
return resolved.default ?? resolved;
|
|
27
|
+
};
|
|
28
|
+
const combineConfigs = async (configArray) => {
|
|
29
|
+
const resolvedConfigArray = await Promise.all(configArray);
|
|
30
|
+
let accumulatedConfig = {};
|
|
31
|
+
for (const config of resolvedConfigArray) {
|
|
32
|
+
if (!config) continue;
|
|
33
|
+
accumulatedConfig = mergeTwoConfigs(accumulatedConfig, config);
|
|
34
|
+
}
|
|
35
|
+
return accumulatedConfig;
|
|
36
|
+
};
|
|
37
|
+
const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
38
|
+
const isCwdInScope = isPackageExists("@zayne-labs/prettier-config");
|
|
39
|
+
const isPackageInScope = (name) => isPackageExists(name, { paths: [scopeUrl] });
|
|
40
|
+
/**
|
|
41
|
+
* @description
|
|
42
|
+
* - Ensures that packages are installed in the current scope.
|
|
43
|
+
* - If they are not installed, and the user is in a TTY, and the user is not in a CI environment,
|
|
44
|
+
* and the user is in the same scope as this package, then prompt the user to
|
|
45
|
+
* install the packages.
|
|
46
|
+
*
|
|
47
|
+
* @param packages - The packages to ensure are installed.
|
|
48
|
+
*/
|
|
49
|
+
const ensurePackages = async (packages) => {
|
|
50
|
+
if (process.env.CI || !process.stdout.isTTY || !isCwdInScope) return;
|
|
51
|
+
const nonExistingPackages = packages.filter((pkg) => pkg && !isPackageInScope(pkg));
|
|
52
|
+
if (nonExistingPackages.length === 0) return;
|
|
53
|
+
if (await (await import("@clack/prompts")).confirm({ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?` })) await (await import("@antfu/install-pkg")).installPackage(nonExistingPackages, { dev: true });
|
|
54
|
+
};
|
|
55
|
+
//#endregion
|
|
56
|
+
export { mergeTwoConfigs as a, isPackageInScope as i, ensurePackages as n, resolveOptions as o, interopDefault as r, combineConfigs as t };
|
|
57
|
+
|
|
58
|
+
//# sourceMappingURL=utils-4qxCZ86b.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils-4qxCZ86b.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import { fileURLToPath } from \"node:url\";\nimport { isArray, isObject, type Awaitable } from \"@zayne-labs/toolkit-type-helpers\";\nimport { isPackageExists } from \"local-pkg\";\nimport type { ResolvedPrettierConfig } from \"./types\";\n\n/**\n * @description Resolves a boolean or object option to an object.\n * If the option is an object, it returns it as-is. Otherwise, returns an empty object.\n */\nexport const resolveOptions = <TObject>(option: boolean | TObject | undefined) => {\n\treturn isObject(option) ? option : ({} as TObject);\n};\n\n/**\n * @description Merges two Prettier configurations.\n * Array values (like `plugins` or `overrides`) are concatenated, while other values from the latter config overwrite the former.\n */\nexport const mergeTwoConfigs = (\n\tformerConfig: ResolvedPrettierConfig,\n\tlatterConfig: ResolvedPrettierConfig\n): ResolvedPrettierConfig => {\n\tconst configAccumulator: ResolvedPrettierConfig = {\n\t\t...formerConfig,\n\t};\n\n\tfor (const [latterConfigKey, latterConfigValue] of Object.entries(latterConfig)) {\n\t\tconst accumulatedConfigValue = configAccumulator[latterConfigKey];\n\n\t\tconfigAccumulator[latterConfigKey] =\n\t\t\tisArray(latterConfigValue) && isArray(accumulatedConfigValue) ?\n\t\t\t\t[...accumulatedConfigValue, ...latterConfigValue]\n\t\t\t:\tlatterConfigValue;\n\t}\n\n\treturn configAccumulator;\n};\n\nexport const interopDefault = async <TModule>(\n\tmodule: Awaitable<TModule>\n): Promise<TModule extends { default: infer TDefaultExport } ? TDefaultExport : TModule> => {\n\tconst resolved = await module;\n\n\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- casting is necessary to prevent assignability ts issues at call-site\n\treturn (resolved as { default: never }).default ?? resolved;\n};\n\nexport const combineConfigs = async (\n\tconfigArray: Array<Awaitable<ResolvedPrettierConfig | undefined>>\n): Promise<ResolvedPrettierConfig> => {\n\t// eslint-disable-next-line ts-eslint/await-thenable -- Ignore\n\tconst resolvedConfigArray = await Promise.all(configArray);\n\n\tlet accumulatedConfig: ResolvedPrettierConfig = {};\n\n\tfor (const config of resolvedConfigArray) {\n\t\tif (!config) continue;\n\n\t\taccumulatedConfig = mergeTwoConfigs(accumulatedConfig, config);\n\t}\n\n\treturn accumulatedConfig;\n};\n\nconst scopeUrl = fileURLToPath(new URL(\".\", import.meta.url));\nconst isCwdInScope = isPackageExists(\"@zayne-labs/prettier-config\");\n\nexport const isPackageInScope = (name: string): boolean => isPackageExists(name, { paths: [scopeUrl] });\n\n/**\n * @description\n * - Ensures that packages are installed in the current scope.\n * - If they are not installed, and the user is in a TTY, and the user is not in a CI environment,\n * and the user is in the same scope as this package, then prompt the user to\n * install the packages.\n *\n * @param packages - The packages to ensure are installed.\n */\nexport const ensurePackages = async (packages: Array<string | undefined>): Promise<void> => {\n\tif (process.env.CI || !process.stdout.isTTY || !isCwdInScope) return;\n\n\tconst nonExistingPackages = packages.filter((pkg) => pkg && !isPackageInScope(pkg));\n\n\tif (nonExistingPackages.length === 0) return;\n\n\tconst clackPrompt = await import(\"@clack/prompts\");\n\n\tconst result = await clackPrompt.confirm({\n\t\tmessage: `${nonExistingPackages.length === 1 ? \"Package is\" : \"Packages are\"} required for this config: ${nonExistingPackages.join(\", \")}. Do you want to install them?`,\n\t});\n\n\tif (result) {\n\t\tconst antfuPkg = await import(\"@antfu/install-pkg\");\n\n\t\tawait antfuPkg.installPackage(nonExistingPackages as string[], { dev: true });\n\t}\n};\n"],"mappings":";;;;;;;;AASA,MAAa,kBAA2B,WAA0C;AACjF,QAAO,SAAS,OAAO,GAAG,SAAU,EAAE;;;;;;AAOvC,MAAa,mBACZ,cACA,iBAC4B;CAC5B,MAAM,oBAA4C,EACjD,GAAG,cACH;AAED,MAAK,MAAM,CAAC,iBAAiB,sBAAsB,OAAO,QAAQ,aAAa,EAAE;EAChF,MAAM,yBAAyB,kBAAkB;AAEjD,oBAAkB,mBACjB,QAAQ,kBAAkB,IAAI,QAAQ,uBAAuB,GAC5D,CAAC,GAAG,wBAAwB,GAAG,kBAAkB,GAChD;;AAGJ,QAAO;;AAGR,MAAa,iBAAiB,OAC7B,WAC2F;CAC3F,MAAM,WAAW,MAAM;AAGvB,QAAQ,SAAgC,WAAW;;AAGpD,MAAa,iBAAiB,OAC7B,gBACqC;CAErC,MAAM,sBAAsB,MAAM,QAAQ,IAAI,YAAY;CAE1D,IAAI,oBAA4C,EAAE;AAElD,MAAK,MAAM,UAAU,qBAAqB;AACzC,MAAI,CAAC,OAAQ;AAEb,sBAAoB,gBAAgB,mBAAmB,OAAO;;AAG/D,QAAO;;AAGR,MAAM,WAAW,cAAc,IAAI,IAAI,KAAK,OAAO,KAAK,IAAI,CAAC;AAC7D,MAAM,eAAe,gBAAgB,8BAA8B;AAEnE,MAAa,oBAAoB,SAA0B,gBAAgB,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;;;;;;;;;;AAWvG,MAAa,iBAAiB,OAAO,aAAuD;AAC3F,KAAI,QAAQ,IAAI,MAAM,CAAC,QAAQ,OAAO,SAAS,CAAC,aAAc;CAE9D,MAAM,sBAAsB,SAAS,QAAQ,QAAQ,OAAO,CAAC,iBAAiB,IAAI,CAAC;AAEnF,KAAI,oBAAoB,WAAW,EAAG;AAQtC,KAJe,OAFK,MAAM,OAAO,mBAEA,QAAQ,EACxC,SAAS,GAAG,oBAAoB,WAAW,IAAI,eAAe,eAAe,6BAA6B,oBAAoB,KAAK,KAAK,CAAC,iCACzI,CAAC,CAKD,QAFiB,MAAM,OAAO,uBAEf,eAAe,qBAAiC,EAAE,KAAK,MAAM,CAAC"}
|
package/dist/utils.d.ts
CHANGED
package/dist/utils.js
CHANGED
|
@@ -1,59 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isArray, isObject } from "@zayne-labs/toolkit-type-helpers";
|
|
3
|
-
import { isPackageExists } from "local-pkg";
|
|
4
|
-
|
|
5
|
-
//#region src/utils.ts
|
|
6
|
-
/**
|
|
7
|
-
* @description Resolves a boolean or object option to an object.
|
|
8
|
-
* If the option is an object, it returns it as-is. Otherwise, returns an empty object.
|
|
9
|
-
*/
|
|
10
|
-
const resolveOptions = (option) => {
|
|
11
|
-
return isObject(option) ? option : {};
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* @description Merges two Prettier configurations.
|
|
15
|
-
* Array values (like `plugins` or `overrides`) are concatenated, while other values from the latter config overwrite the former.
|
|
16
|
-
*/
|
|
17
|
-
const mergeTwoConfigs = (formerConfig, latterConfig) => {
|
|
18
|
-
const configAccumulator = { ...formerConfig };
|
|
19
|
-
for (const [latterConfigKey, latterConfigValue] of Object.entries(latterConfig)) {
|
|
20
|
-
const accumulatedConfigValue = configAccumulator[latterConfigKey];
|
|
21
|
-
configAccumulator[latterConfigKey] = isArray(latterConfigValue) && isArray(accumulatedConfigValue) ? [...accumulatedConfigValue, ...latterConfigValue] : latterConfigValue;
|
|
22
|
-
}
|
|
23
|
-
return configAccumulator;
|
|
24
|
-
};
|
|
25
|
-
const interopDefault = async (module) => {
|
|
26
|
-
const resolved = await module;
|
|
27
|
-
return resolved.default ?? resolved;
|
|
28
|
-
};
|
|
29
|
-
const combineConfigs = async (configArray) => {
|
|
30
|
-
const resolvedConfigArray = await Promise.all(configArray);
|
|
31
|
-
let accumulatedConfig = {};
|
|
32
|
-
for (const config of resolvedConfigArray) {
|
|
33
|
-
if (!config) continue;
|
|
34
|
-
accumulatedConfig = mergeTwoConfigs(accumulatedConfig, config);
|
|
35
|
-
}
|
|
36
|
-
return accumulatedConfig;
|
|
37
|
-
};
|
|
38
|
-
const scopeUrl = fileURLToPath(new URL(".", import.meta.url));
|
|
39
|
-
const isCwdInScope = isPackageExists("@zayne-labs/prettier-config");
|
|
40
|
-
const isPackageInScope = (name) => isPackageExists(name, { paths: [scopeUrl] });
|
|
41
|
-
/**
|
|
42
|
-
* @description
|
|
43
|
-
* - Ensures that packages are installed in the current scope.
|
|
44
|
-
* - If they are not installed, and the user is in a TTY, and the user is not in a CI environment,
|
|
45
|
-
* and the user is in the same scope as this package, then prompt the user to
|
|
46
|
-
* install the packages.
|
|
47
|
-
*
|
|
48
|
-
* @param packages - The packages to ensure are installed.
|
|
49
|
-
*/
|
|
50
|
-
const ensurePackages = async (packages) => {
|
|
51
|
-
if (process.env.CI || !process.stdout.isTTY || !isCwdInScope) return;
|
|
52
|
-
const nonExistingPackages = packages.filter((pkg) => pkg && !isPackageInScope(pkg));
|
|
53
|
-
if (nonExistingPackages.length === 0) return;
|
|
54
|
-
if (await (await import("@clack/prompts")).confirm({ message: `${nonExistingPackages.length === 1 ? "Package is" : "Packages are"} required for this config: ${nonExistingPackages.join(", ")}. Do you want to install them?` })) await (await import("@antfu/install-pkg")).installPackage(nonExistingPackages, { dev: true });
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
//#endregion
|
|
1
|
+
import { a as mergeTwoConfigs, i as isPackageInScope, n as ensurePackages, o as resolveOptions, r as interopDefault, t as combineConfigs } from "./utils-4qxCZ86b.js";
|
|
58
2
|
export { combineConfigs, ensurePackages, interopDefault, isPackageInScope, mergeTwoConfigs, resolveOptions };
|
|
59
|
-
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zayne-labs/prettier-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.11.
|
|
4
|
+
"version": "0.11.31",
|
|
5
5
|
"description": "Zayne Labs' Prettier config",
|
|
6
6
|
"author": "Ryan Zayne",
|
|
7
7
|
"license": "MIT",
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"@antfu/install-pkg": "1.1.0",
|
|
58
|
-
"@clack/prompts": "1.0
|
|
59
|
-
"@zayne-labs/toolkit-type-helpers": "0.12.
|
|
58
|
+
"@clack/prompts": "1.1.0",
|
|
59
|
+
"@zayne-labs/toolkit-type-helpers": "0.12.44",
|
|
60
60
|
"local-pkg": "1.1.2"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
@@ -67,12 +67,12 @@
|
|
|
67
67
|
"prettier": "3.8.1",
|
|
68
68
|
"prettier-plugin-astro": "0.14.1",
|
|
69
69
|
"prettier-plugin-classnames": "0.9.0",
|
|
70
|
-
"prettier-plugin-merge": "0.
|
|
70
|
+
"prettier-plugin-merge": "0.10.0",
|
|
71
71
|
"prettier-plugin-tailwindcss": "0.7.2",
|
|
72
|
-
"publint": "0.3.
|
|
73
|
-
"tsdown": "0.
|
|
72
|
+
"publint": "0.3.18",
|
|
73
|
+
"tsdown": "0.21.1",
|
|
74
74
|
"typescript": "5.9.3",
|
|
75
|
-
"@zayne-labs/tsconfig": "0.11.
|
|
75
|
+
"@zayne-labs/tsconfig": "0.11.31"
|
|
76
76
|
},
|
|
77
77
|
"publishConfig": {
|
|
78
78
|
"access": "public",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.js","names":[],"sources":["../../src/constants/defaults.ts"],"sourcesContent":["import { defineEnumDeep } from \"@zayne-labs/toolkit-type-helpers\";\n\nexport const getDefaultTailwindSettings = () => {\n\treturn defineEnumDeep({\n\t\ttailwindAttributes: [\"className\", \"classNames\", \"classes\"],\n\t\ttailwindFunctions: [\"cnMerge\", \"cnJoin\", \"cn\", \"tv\", \"tw\"],\n\t\ttailwindStylesheet: \"./tailwind.css\",\n\t});\n};\n\nexport const getDefaultImportSortingOrder = () => {\n\treturn defineEnumDeep({\n\t\t// CSS files (always last)\n\t\tcss: \".css$\",\n\n\t\tmain: [\n\t\t\t// URLs (e.g., https://example.org)\n\t\t\t\"^https?://\",\n\t\t\t// Protocol imports (node:, bun:, jsr:, npm:, etc.)\n\t\t\t\"<BUILTIN_MODULES>\",\n\t\t\t\"^(bun|jsr|npm):\",\n\t\t\t// Third-party packages\n\t\t\t\"<THIRD_PARTY_MODULES>\",\n\t\t\t// Aliases (@/, @@/, #, ~, $, %)\n\t\t\t\"^(@@?/|[#$%~])\",\n\t\t\t// Relative and absolute paths (excluding CSS)\n\t\t\t\"^(?!.*[.]css$)[./].*$\",\n\t\t],\n\t});\n};\n"],"mappings":";;;AAEA,MAAa,mCAAmC;AAC/C,QAAO,eAAe;EACrB,oBAAoB;GAAC;GAAa;GAAc;GAAU;EAC1D,mBAAmB;GAAC;GAAW;GAAU;GAAM;GAAM;GAAK;EAC1D,oBAAoB;EACpB,CAAC;;AAGH,MAAa,qCAAqC;AACjD,QAAO,eAAe;EAErB,KAAK;EAEL,MAAM;GAEL;GAEA;GACA;GAEA;GAEA;GAEA;GACA;EACD,CAAC"}
|
package/dist/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","names":[],"sources":["../src/utils.ts"],"sourcesContent":["import { fileURLToPath } from \"node:url\";\nimport { isArray, isObject, type Awaitable } from \"@zayne-labs/toolkit-type-helpers\";\nimport { isPackageExists } from \"local-pkg\";\nimport type { ResolvedPrettierConfig } from \"./types\";\n\n/**\n * @description Resolves a boolean or object option to an object.\n * If the option is an object, it returns it as-is. Otherwise, returns an empty object.\n */\nexport const resolveOptions = <TObject>(option: boolean | TObject | undefined) => {\n\treturn isObject(option) ? option : ({} as TObject);\n};\n\n/**\n * @description Merges two Prettier configurations.\n * Array values (like `plugins` or `overrides`) are concatenated, while other values from the latter config overwrite the former.\n */\nexport const mergeTwoConfigs = (\n\tformerConfig: ResolvedPrettierConfig,\n\tlatterConfig: ResolvedPrettierConfig\n): ResolvedPrettierConfig => {\n\tconst configAccumulator: ResolvedPrettierConfig = {\n\t\t...formerConfig,\n\t};\n\n\tfor (const [latterConfigKey, latterConfigValue] of Object.entries(latterConfig)) {\n\t\tconst accumulatedConfigValue = configAccumulator[latterConfigKey];\n\n\t\tconfigAccumulator[latterConfigKey] =\n\t\t\tisArray(latterConfigValue) && isArray(accumulatedConfigValue) ?\n\t\t\t\t[...accumulatedConfigValue, ...latterConfigValue]\n\t\t\t:\tlatterConfigValue;\n\t}\n\n\treturn configAccumulator;\n};\n\nexport const interopDefault = async <TModule>(\n\tmodule: Awaitable<TModule>\n): Promise<TModule extends { default: infer TDefaultExport } ? TDefaultExport : TModule> => {\n\tconst resolved = await module;\n\n\t// eslint-disable-next-line ts-eslint/no-unnecessary-condition -- casting is necessary to prevent assignability ts issues at call-site\n\treturn (resolved as { default: never }).default ?? resolved;\n};\n\nexport const combineConfigs = async (\n\tconfigArray: Array<Awaitable<ResolvedPrettierConfig | undefined>>\n): Promise<ResolvedPrettierConfig> => {\n\t// eslint-disable-next-line ts-eslint/await-thenable -- Ignore\n\tconst resolvedConfigArray = await Promise.all(configArray);\n\n\tlet accumulatedConfig: ResolvedPrettierConfig = {};\n\n\tfor (const config of resolvedConfigArray) {\n\t\tif (!config) continue;\n\n\t\taccumulatedConfig = mergeTwoConfigs(accumulatedConfig, config);\n\t}\n\n\treturn accumulatedConfig;\n};\n\nconst scopeUrl = fileURLToPath(new URL(\".\", import.meta.url));\nconst isCwdInScope = isPackageExists(\"@zayne-labs/prettier-config\");\n\nexport const isPackageInScope = (name: string): boolean => isPackageExists(name, { paths: [scopeUrl] });\n\n/**\n * @description\n * - Ensures that packages are installed in the current scope.\n * - If they are not installed, and the user is in a TTY, and the user is not in a CI environment,\n * and the user is in the same scope as this package, then prompt the user to\n * install the packages.\n *\n * @param packages - The packages to ensure are installed.\n */\nexport const ensurePackages = async (packages: Array<string | undefined>): Promise<void> => {\n\tif (process.env.CI || !process.stdout.isTTY || !isCwdInScope) return;\n\n\tconst nonExistingPackages = packages.filter((pkg) => pkg && !isPackageInScope(pkg));\n\n\tif (nonExistingPackages.length === 0) return;\n\n\tconst clackPrompt = await import(\"@clack/prompts\");\n\n\tconst result = await clackPrompt.confirm({\n\t\tmessage: `${nonExistingPackages.length === 1 ? \"Package is\" : \"Packages are\"} required for this config: ${nonExistingPackages.join(\", \")}. Do you want to install them?`,\n\t});\n\n\tif (result) {\n\t\tconst antfuPkg = await import(\"@antfu/install-pkg\");\n\n\t\tawait antfuPkg.installPackage(nonExistingPackages as string[], { dev: true });\n\t}\n};\n"],"mappings":";;;;;;;;;AASA,MAAa,kBAA2B,WAA0C;AACjF,QAAO,SAAS,OAAO,GAAG,SAAU,EAAE;;;;;;AAOvC,MAAa,mBACZ,cACA,iBAC4B;CAC5B,MAAM,oBAA4C,EACjD,GAAG,cACH;AAED,MAAK,MAAM,CAAC,iBAAiB,sBAAsB,OAAO,QAAQ,aAAa,EAAE;EAChF,MAAM,yBAAyB,kBAAkB;AAEjD,oBAAkB,mBACjB,QAAQ,kBAAkB,IAAI,QAAQ,uBAAuB,GAC5D,CAAC,GAAG,wBAAwB,GAAG,kBAAkB,GAChD;;AAGJ,QAAO;;AAGR,MAAa,iBAAiB,OAC7B,WAC2F;CAC3F,MAAM,WAAW,MAAM;AAGvB,QAAQ,SAAgC,WAAW;;AAGpD,MAAa,iBAAiB,OAC7B,gBACqC;CAErC,MAAM,sBAAsB,MAAM,QAAQ,IAAI,YAAY;CAE1D,IAAI,oBAA4C,EAAE;AAElD,MAAK,MAAM,UAAU,qBAAqB;AACzC,MAAI,CAAC,OAAQ;AAEb,sBAAoB,gBAAgB,mBAAmB,OAAO;;AAG/D,QAAO;;AAGR,MAAM,WAAW,cAAc,IAAI,IAAI,KAAK,OAAO,KAAK,IAAI,CAAC;AAC7D,MAAM,eAAe,gBAAgB,8BAA8B;AAEnE,MAAa,oBAAoB,SAA0B,gBAAgB,MAAM,EAAE,OAAO,CAAC,SAAS,EAAE,CAAC;;;;;;;;;;AAWvG,MAAa,iBAAiB,OAAO,aAAuD;AAC3F,KAAI,QAAQ,IAAI,MAAM,CAAC,QAAQ,OAAO,SAAS,CAAC,aAAc;CAE9D,MAAM,sBAAsB,SAAS,QAAQ,QAAQ,OAAO,CAAC,iBAAiB,IAAI,CAAC;AAEnF,KAAI,oBAAoB,WAAW,EAAG;AAQtC,KAJe,OAFK,MAAM,OAAO,mBAEA,QAAQ,EACxC,SAAS,GAAG,oBAAoB,WAAW,IAAI,eAAe,eAAe,6BAA6B,oBAAoB,KAAK,KAAK,CAAC,iCACzI,CAAC,CAKD,QAFiB,MAAM,OAAO,uBAEf,eAAe,qBAAiC,EAAE,KAAK,MAAM,CAAC"}
|