@zayne-labs/prettier-config 0.13.14 → 0.13.15
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.d.ts +2 -3
- package/dist/index.d.ts +7 -8
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/plugins/safe-sort-imports.d.ts +0 -1
- package/dist/plugins/safe-sort-imports.js +1 -1
- package/dist/{types-BvFb4aYp.d.ts → types-DJPsI734.d.ts} +3 -4
- package/dist/{utils-D5XWgHFL.js → utils-CRitUEuM.js} +2 -2
- package/dist/{utils-D5XWgHFL.js.map → utils-CRitUEuM.js.map} +1 -1
- package/dist/utils.d.ts +7 -9
- package/dist/utils.js +1 -1
- package/package.json +15 -15
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
//#region src/constants/defaults.d.ts
|
|
2
|
-
declare const getDefaultTailwindSettings: () => {
|
|
2
|
+
export declare const getDefaultTailwindSettings: () => {
|
|
3
3
|
tailwindAttributes: ["className", "classNames", "classes", "class", "/.*Classes/", "toastOptions"];
|
|
4
4
|
tailwindFunctions: ["cnMerge", "cnJoin", "cn", "tv", "tw", "css", "twMerge", "twJoin", "clsx", "/^get[A-Z][a-zA-Z0-9]*Props$/"];
|
|
5
5
|
tailwindStylesheet: "./tailwind.css";
|
|
6
6
|
};
|
|
7
|
-
declare const getDefaultImportSortingOrder: () => {
|
|
7
|
+
export declare const getDefaultImportSortingOrder: () => {
|
|
8
8
|
css: ".css$";
|
|
9
9
|
main: ["^https?://", "<BUILTIN_MODULES>", "^(bun|jsr|npm):", "<THIRD_PARTY_MODULES>", "^(@@?/|[#$%~])", "^(?!.*[.]css$)[./].*$"];
|
|
10
10
|
};
|
|
11
11
|
//#endregion
|
|
12
|
-
export { getDefaultImportSortingOrder, getDefaultTailwindSettings };
|
|
13
12
|
//# sourceMappingURL=defaults.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import { a as OptionsTailwindCss, i as OptionsSortImports, n as OptionsAstro, o as ResolvedPrettierConfig, r as OptionsPrettierConfig, t as ExtractOptions } from "./types-
|
|
2
|
-
|
|
1
|
+
import { a as OptionsTailwindCss, i as OptionsSortImports, n as OptionsAstro, o as ResolvedPrettierConfig, r as OptionsPrettierConfig, t as ExtractOptions } from "./types-DJPsI734.js";
|
|
3
2
|
//#region src/configs/astro.d.ts
|
|
4
|
-
declare const astro: (options: ExtractOptions<OptionsPrettierConfig["astro"]>) => Promise<typeof options>;
|
|
3
|
+
export declare const astro: (options: ExtractOptions<OptionsPrettierConfig["astro"]>) => Promise<typeof options>;
|
|
5
4
|
//#endregion
|
|
6
5
|
//#region src/configs/base.d.ts
|
|
7
|
-
declare const base: (options: ExtractOptions<OptionsPrettierConfig["base"]>) => typeof options;
|
|
6
|
+
export declare const base: (options: ExtractOptions<OptionsPrettierConfig["base"]>) => typeof options;
|
|
8
7
|
//#endregion
|
|
9
8
|
//#region src/configs/tailwindcss.d.ts
|
|
10
|
-
declare const tailwindcss: (options: ExtractOptions<OptionsPrettierConfig["tailwindcss"]>) => Promise<typeof options>;
|
|
9
|
+
export declare const tailwindcss: (options: ExtractOptions<OptionsPrettierConfig["tailwindcss"]>) => Promise<typeof options>;
|
|
11
10
|
//#endregion
|
|
12
11
|
//#region src/configs/sort.d.ts
|
|
13
|
-
declare const sortImports: (options: ExtractOptions<OptionsPrettierConfig["sortImports"]>) => Promise<typeof options>;
|
|
12
|
+
export declare const sortImports: (options: ExtractOptions<OptionsPrettierConfig["sortImports"]>) => Promise<typeof options>;
|
|
14
13
|
//#endregion
|
|
15
14
|
//#region src/factory.d.ts
|
|
16
15
|
/**
|
|
@@ -36,7 +35,7 @@ declare const sortImports: (options: ExtractOptions<OptionsPrettierConfig["sortI
|
|
|
36
35
|
* );
|
|
37
36
|
* ```
|
|
38
37
|
*/
|
|
39
|
-
declare const zayne: (options?: OptionsPrettierConfig, ...extraConfigs: ResolvedPrettierConfig[]) => Promise<ResolvedPrettierConfig>;
|
|
38
|
+
export declare const zayne: (options?: OptionsPrettierConfig, ...extraConfigs: ResolvedPrettierConfig[]) => Promise<ResolvedPrettierConfig>;
|
|
40
39
|
//#endregion
|
|
41
|
-
export { ExtractOptions, OptionsAstro, OptionsPrettierConfig, OptionsSortImports, OptionsTailwindCss, ResolvedPrettierConfig
|
|
40
|
+
export { ExtractOptions, OptionsAstro, OptionsPrettierConfig, OptionsSortImports, OptionsTailwindCss, ResolvedPrettierConfig };
|
|
42
41
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as ensurePackages, o as resolveOptions, t as combineConfigs } from "./utils-
|
|
1
|
+
import { n as ensurePackages, o as resolveOptions, t as combineConfigs } from "./utils-CRitUEuM.js";
|
|
2
2
|
import { n as getDefaultTailwindSettings, t as getDefaultImportSortingOrder } from "./defaults-DwaL-Owc.js";
|
|
3
3
|
//#region src/configs/astro.ts
|
|
4
4
|
const astro = async (options) => {
|
|
@@ -95,13 +95,14 @@ const sortImports = async (options) => {
|
|
|
95
95
|
*/
|
|
96
96
|
const zayne = async (options = {}, ...extraConfigs) => {
|
|
97
97
|
const { astro: enabledAstro = false, base: enabledBase = true, sortImports: enabledSortImports = true, tailwindcss: enabledTailwindcss = false } = options;
|
|
98
|
-
|
|
98
|
+
const configArray = [
|
|
99
99
|
enabledBase ? base(resolveOptions(enabledBase)) : void 0,
|
|
100
100
|
enabledAstro ? astro(resolveOptions(enabledAstro)) : void 0,
|
|
101
101
|
enabledSortImports ? sortImports(resolveOptions(enabledSortImports)) : void 0,
|
|
102
102
|
...extraConfigs,
|
|
103
103
|
enabledTailwindcss ? tailwindcss(resolveOptions(enabledTailwindcss)) : void 0
|
|
104
|
-
]
|
|
104
|
+
];
|
|
105
|
+
return await combineConfigs(configArray);
|
|
105
106
|
};
|
|
106
107
|
//#endregion
|
|
107
108
|
export { astro, base, sortImports, tailwindcss, zayne };
|
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 zayneDefaultSettings = getDefaultTailwindSettings();\n\n\treturn {\n\t\ttailwindStylesheet: zayneDefaultSettings.tailwindStylesheet,\n\n\t\t...options,\n\n\t\tcustomAttributes: [...zayneDefaultSettings.tailwindAttributes, ...(options.customAttributes ?? [])],\n\t\tcustomFunctions: [...zayneDefaultSettings.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: [\n\t\t\t...zayneDefaultSettings.tailwindAttributes,\n\t\t\t...(options.tailwindAttributes ?? []),\n\t\t],\n\t\ttailwindFunctions: [...zayneDefaultSettings.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;CAC7B,MAAM,eAAe,CAAC,uBAAuB,CAAC;CAE9C,OAAO;EACN,GAAG;EAEH,WAAW,CACV;GACC,OAAO;GACP,SAAS,EAAE,QAAQ,QAAQ;EAC5B,GACA,GAAI,QAAQ,aAAa,CAAC,CAC3B;EAEA,SAAS,CAAC,yBAAyB,GAAI,QAAQ,WAAW,CAAC,CAAE;CAC9D;AACD;;;ACnBA,M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
|
|
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 zayneDefaultSettings = getDefaultTailwindSettings();\n\n\treturn {\n\t\ttailwindStylesheet: zayneDefaultSettings.tailwindStylesheet,\n\n\t\t...options,\n\n\t\tcustomAttributes: [...zayneDefaultSettings.tailwindAttributes, ...(options.customAttributes ?? [])],\n\t\tcustomFunctions: [...zayneDefaultSettings.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: [\n\t\t\t...zayneDefaultSettings.tailwindAttributes,\n\t\t\t...(options.tailwindAttributes ?? []),\n\t\t],\n\t\ttailwindFunctions: [...zayneDefaultSettings.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;CAC7B,MAAM,eAAe,CAAC,uBAAuB,CAAC;CAE9C,OAAO;EACN,GAAG;EAEH,WAAW,CACV;GACC,OAAO;GACP,SAAS,EAAE,QAAQ,QAAQ;EAC5B,GACA,GAAI,QAAQ,aAAa,CAAC,CAC3B;EAEA,SAAS,CAAC,yBAAyB,GAAI,QAAQ,WAAW,CAAC,CAAE;CAC9D;AACD;;;ACnBA,MAAa,QAAQ,YAA2E;CAC/F,OAAO;EACN,8BAA8B;E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AW,CAAC,IAAI,KAAA;EAClD,eAAe,MAAM,eAAe,YAAY,CAAC,IAAI,KAAA;EACrD,qBAAqB,YAAY,eAAe,kBAAkB,CAAC,IAAI,KAAA;EAEvE,GAAG;EAMH,qBAAqB,YAAY,eAAe,kBAAkB,CAAC,IAAI,KAAA;CACxE;CAIA,OAAO,MAFyB,eAAe,WAAW;AAG3D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as isPackageInScope, r as interopDefault } from "../utils-
|
|
1
|
+
import { i as isPackageInScope, r as interopDefault } from "../utils-CRitUEuM.js";
|
|
2
2
|
//#region src/plugins/safe-sort-imports.ts
|
|
3
3
|
/**
|
|
4
4
|
* @description This is a temporary fix until the plugin is updated to only load the parsers for the plugins that are in scope.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AnyString, ExtractUnion } from "@zayne-labs/toolkit-type-helpers";
|
|
2
2
|
import { Config, Plugin } from "prettier";
|
|
3
|
-
|
|
4
3
|
//#region src/types.d.ts
|
|
5
4
|
type RestOfAllowedPluginTypes = AnyString | Plugin | URL;
|
|
6
5
|
type OptionsClassNames = {
|
|
@@ -77,7 +76,7 @@ type OptionsAstro = {
|
|
|
77
76
|
* @docs [prettier-plugin-astro#astroskipfrontmatter](https://github.com/withastro/prettier-plugin-astro#astroskipfrontmatter)
|
|
78
77
|
*/
|
|
79
78
|
astroSkipFrontmatter?: boolean;
|
|
80
|
-
overrides?: Array<
|
|
79
|
+
overrides?: Array<NonNullable<Config["overrides"]>[number] |
|
|
81
80
|
/**
|
|
82
81
|
* @docs [prettier-plugin-astro#recommended-configuration](https://github.com/withastro/prettier-plugin-astro#recommended-configuration)
|
|
83
82
|
*/
|
|
@@ -86,7 +85,7 @@ type OptionsAstro = {
|
|
|
86
85
|
options: {
|
|
87
86
|
parser: "astro";
|
|
88
87
|
};
|
|
89
|
-
}
|
|
88
|
+
}>;
|
|
90
89
|
plugins?: Array<"prettier-plugin-astro" | RestOfAllowedPluginTypes>;
|
|
91
90
|
};
|
|
92
91
|
type OptionsSortImports = {
|
|
@@ -176,4 +175,4 @@ type ResolvedPrettierConfig = Omit<Config & OptionsAstro & OptionsSortImports &
|
|
|
176
175
|
type ExtractOptions<TUnion> = Extract<TUnion, object>;
|
|
177
176
|
//#endregion
|
|
178
177
|
export { OptionsTailwindCss as a, OptionsSortImports as i, OptionsAstro as n, ResolvedPrettierConfig as o, OptionsPrettierConfig as r, ExtractOptions as t };
|
|
179
|
-
//# sourceMappingURL=types-
|
|
178
|
+
//# sourceMappingURL=types-DJPsI734.d.ts.map
|
|
@@ -47,7 +47,7 @@ const isPackageInScope = (name) => isPackageExists(name, { paths: [scopeUrl] });
|
|
|
47
47
|
* @param packages - The packages to ensure are installed.
|
|
48
48
|
*/
|
|
49
49
|
const ensurePackages = async (packages) => {
|
|
50
|
-
if (process.env.CI || !process.stdout.isTTY
|
|
50
|
+
if (!isCwdInScope || process.env.CI || !process.stdout.isTTY) return;
|
|
51
51
|
const nonExistingPackages = packages.filter((pkg) => pkg && !isPackageInScope(pkg));
|
|
52
52
|
if (nonExistingPackages.length === 0) return;
|
|
53
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 });
|
|
@@ -55,4 +55,4 @@ const ensurePackages = async (packages) => {
|
|
|
55
55
|
//#endregion
|
|
56
56
|
export { mergeTwoConfigs as a, isPackageInScope as i, ensurePackages as n, resolveOptions as o, interopDefault as r, combineConfigs as t };
|
|
57
57
|
|
|
58
|
-
//# sourceMappingURL=utils-
|
|
58
|
+
//# sourceMappingURL=utils-CRitUEuM.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils-
|
|
1
|
+
{"version":3,"file":"utils-CRitUEuM.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 (!isCwdInScope || process.env.CI || !process.stdout.isTTY) 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;CACjF,OAAO,SAAS,MAAM,IAAI,SAAU,CAAC;AACtC;;;;;AAMA,MAAa,mBACZ,cACA,iBAC4B;CAC5B,MAAM,oBAA4C,EACjD,GAAG,aACJ;CAEA,KAAK,MAAM,CAAC,iBAAiB,sBAAsB,OAAO,QAAQ,YAAY,GAAG;EAChF,MAAM,yBAAyB,kBAAkB;EAEjD,kBAAkB,mBACjB,QAAQ,iBAAiB,KAAK,QAAQ,sBAAsB,IAC3D,CAAC,GAAG,wBAAwB,GAAG,iBAAiB,IAC/C;CACJ;CAEA,OAAO;AACR;AAEA,MAAa,iBAAiB,OAC7B,WAC2F;CAC3F,MAAM,WAAW,MAAM;CAGvB,OAAQ,SAAgC,WAAW;AACpD;AAEA,MAAa,iBAAiB,OAC7B,gBACqC;CAErC,MAAM,sBAAsB,MAAM,QAAQ,IAAI,WAAW;CAEzD,IAAI,oBAA4C,CAAC;CAEjD,KAAK,MAAM,UAAU,qBAAqB;EACzC,IAAI,CAAC,QAAQ;EAEb,oBAAoB,gBAAgB,mBAAmB,MAAM;CAC9D;CAEA,OAAO;AACR;AAEA,MAAM,WAAW,cAAc,IAAI,IAAI,KAAK,YAAY,GAAG,CAAC;AAC5D,MAAM,eAAe,gBAAgB,6BAA6B;AAElE,MAAa,oBAAoB,SAA0B,gBAAgB,MAAM,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC;;;;;;;;;;AAWtG,MAAa,iBAAiB,OAAO,aAAuD;CAC3F,IAAI,CAAC,gBAAgB,QAAQ,IAAI,MAAM,CAAC,QAAQ,OAAO,OAAO;CAE9D,MAAM,sBAAsB,SAAS,QAAQ,QAAQ,OAAO,CAAC,iBAAiB,GAAG,CAAC;CAElF,IAAI,oBAAoB,WAAW,GAAG;CAQtC,IAAI,OAJiB,MAFK,OAAO,kBAAA,CAEA,QAAQ,EACxC,SAAS,GAAG,oBAAoB,WAAW,IAAI,eAAe,eAAe,6BAA6B,oBAAoB,KAAK,IAAI,EAAE,gCAC1I,CAAC,GAKA,OAAM,MAFiB,OAAO,sBAAA,CAEf,eAAe,qBAAiC,EAAE,KAAK,KAAK,CAAC;AAE9E"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
|
-
import { o as ResolvedPrettierConfig } from "./types-
|
|
1
|
+
import { o as ResolvedPrettierConfig } from "./types-DJPsI734.js";
|
|
2
2
|
import { Awaitable } from "@zayne-labs/toolkit-type-helpers";
|
|
3
|
-
|
|
4
3
|
//#region src/utils.d.ts
|
|
5
4
|
/**
|
|
6
5
|
* @description Resolves a boolean or object option to an object.
|
|
7
6
|
* If the option is an object, it returns it as-is. Otherwise, returns an empty object.
|
|
8
7
|
*/
|
|
9
|
-
declare const resolveOptions: <TObject>(option: boolean | TObject | undefined) => TObject;
|
|
8
|
+
export declare const resolveOptions: <TObject>(option: boolean | TObject | undefined) => TObject;
|
|
10
9
|
/**
|
|
11
10
|
* @description Merges two Prettier configurations.
|
|
12
11
|
* Array values (like `plugins` or `overrides`) are concatenated, while other values from the latter config overwrite the former.
|
|
13
12
|
*/
|
|
14
|
-
declare const mergeTwoConfigs: (formerConfig: ResolvedPrettierConfig, latterConfig: ResolvedPrettierConfig) => ResolvedPrettierConfig;
|
|
15
|
-
declare const interopDefault: <TModule>(module: Awaitable<TModule>) => Promise<TModule extends {
|
|
13
|
+
export declare const mergeTwoConfigs: (formerConfig: ResolvedPrettierConfig, latterConfig: ResolvedPrettierConfig) => ResolvedPrettierConfig;
|
|
14
|
+
export declare const interopDefault: <TModule>(module: Awaitable<TModule>) => Promise<TModule extends {
|
|
16
15
|
default: infer TDefaultExport;
|
|
17
16
|
} ? TDefaultExport : TModule>;
|
|
18
|
-
declare const combineConfigs: (configArray: Array<Awaitable<ResolvedPrettierConfig | undefined>>) => Promise<ResolvedPrettierConfig>;
|
|
19
|
-
declare const isPackageInScope: (name: string) => boolean;
|
|
17
|
+
export declare const combineConfigs: (configArray: Array<Awaitable<ResolvedPrettierConfig | undefined>>) => Promise<ResolvedPrettierConfig>;
|
|
18
|
+
export declare const isPackageInScope: (name: string) => boolean;
|
|
20
19
|
/**
|
|
21
20
|
* @description
|
|
22
21
|
* - Ensures that packages are installed in the current scope.
|
|
@@ -26,7 +25,6 @@ declare const isPackageInScope: (name: string) => boolean;
|
|
|
26
25
|
*
|
|
27
26
|
* @param packages - The packages to ensure are installed.
|
|
28
27
|
*/
|
|
29
|
-
declare const ensurePackages: (packages: Array<string | undefined>) => Promise<void>;
|
|
28
|
+
export declare const ensurePackages: (packages: Array<string | undefined>) => Promise<void>;
|
|
30
29
|
//#endregion
|
|
31
|
-
export { combineConfigs, ensurePackages, interopDefault, isPackageInScope, mergeTwoConfigs, resolveOptions };
|
|
32
30
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as mergeTwoConfigs, i as isPackageInScope, n as ensurePackages, o as resolveOptions, r as interopDefault, t as combineConfigs } from "./utils-
|
|
1
|
+
import { a as mergeTwoConfigs, i as isPackageInScope, n as ensurePackages, o as resolveOptions, r as interopDefault, t as combineConfigs } from "./utils-CRitUEuM.js";
|
|
2
2
|
export { combineConfigs, ensurePackages, interopDefault, isPackageInScope, mergeTwoConfigs, resolveOptions };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zayne-labs/prettier-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.13.
|
|
4
|
+
"version": "0.13.15",
|
|
5
5
|
"description": "Zayne Labs' Prettier config",
|
|
6
6
|
"author": "Ryan Zayne",
|
|
7
7
|
"license": "MIT",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
},
|
|
34
34
|
"peerDependencies": {
|
|
35
35
|
"@ianvs/prettier-plugin-sort-imports": "^4.7.1",
|
|
36
|
-
"prettier": "^3.
|
|
36
|
+
"prettier": "^3.9.6",
|
|
37
37
|
"prettier-plugin-astro": "^0.14.1",
|
|
38
|
-
"prettier-plugin-classnames": "^0.10.
|
|
38
|
+
"prettier-plugin-classnames": "^0.10.4",
|
|
39
39
|
"prettier-plugin-merge": "^0.10.1",
|
|
40
|
-
"prettier-plugin-tailwindcss": "^0.8.
|
|
40
|
+
"prettier-plugin-tailwindcss": "^0.8.1"
|
|
41
41
|
},
|
|
42
42
|
"peerDependenciesMeta": {
|
|
43
43
|
"prettier-plugin-astro": {
|
|
@@ -54,25 +54,25 @@
|
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@antfu/install-pkg": "
|
|
58
|
-
"@clack/prompts": "1.
|
|
59
|
-
"@zayne-labs/toolkit-type-helpers": "0.12.
|
|
57
|
+
"@antfu/install-pkg": "2.0.1",
|
|
58
|
+
"@clack/prompts": "1.8.0",
|
|
59
|
+
"@zayne-labs/toolkit-type-helpers": "0.12.59",
|
|
60
60
|
"local-pkg": "1.2.1"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@ianvs/prettier-plugin-sort-imports": "^4.7.1",
|
|
64
64
|
"@total-typescript/ts-reset": "0.6.1",
|
|
65
|
-
"
|
|
65
|
+
"@zayne-labs/tsconfig": "0.13.15",
|
|
66
|
+
"concurrently": "10.0.5",
|
|
66
67
|
"cross-env": "10.1.0",
|
|
67
|
-
"prettier": "^3.
|
|
68
|
+
"prettier": "^3.9.6",
|
|
68
69
|
"prettier-plugin-astro": "^0.14.1",
|
|
69
|
-
"prettier-plugin-classnames": "^0.10.
|
|
70
|
+
"prettier-plugin-classnames": "^0.10.4",
|
|
70
71
|
"prettier-plugin-merge": "^0.10.1",
|
|
71
|
-
"prettier-plugin-tailwindcss": "^0.8.
|
|
72
|
-
"publint": "0.3.
|
|
73
|
-
"tsdown": "0.
|
|
74
|
-
"typescript": "6.0.3"
|
|
75
|
-
"@zayne-labs/tsconfig": "0.13.14"
|
|
72
|
+
"prettier-plugin-tailwindcss": "^0.8.1",
|
|
73
|
+
"publint": "0.3.24",
|
|
74
|
+
"tsdown": "0.23.0",
|
|
75
|
+
"typescript": "6.0.3"
|
|
76
76
|
},
|
|
77
77
|
"publishConfig": {
|
|
78
78
|
"access": "public",
|