Skip to content

Commit

Permalink
* scripts: support to custom lib order.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Nov 16, 2023
1 parent 813671a commit 0a3bfcf
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
18 changes: 9 additions & 9 deletions scripts/libs/lib-type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ export enum LibType {

export const libTypeOrders = {
[LibType.config]: 0,
[LibType.cssBase]: 1,
[LibType.control]: 2,
[LibType.jsHelpers]: 3,
[LibType.component]: 4,
[LibType.jsUI]: 5,
[LibType.cssUtilities]: 6,
[LibType.jsLib]: 7,
[LibType.other]: 8,
[LibType.examples]: 9,
[LibType.cssBase]: 10,
[LibType.control]: 20,
[LibType.jsHelpers]: 30,
[LibType.component]: 40,
[LibType.jsUI]: 50,
[LibType.cssUtilities]: 60,
[LibType.jsLib]: 70,
[LibType.other]: 80,
[LibType.examples]: 90,
};
5 changes: 2 additions & 3 deletions scripts/libs/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export async function getLibList(libPath: string | string[] = '', options: {root

export function sortLibList(libList: LibInfo[]) {
return libList.map((lib, idx) => {
lib.zui.order = (libTypeOrders[lib.zui.type] * 1000000000) + (lib.zui.sourceType === 'build-in' ? 10000000 : 11000000) + idx;
lib.zui.order = ((lib.zui.order ?? libTypeOrders[lib.zui.type]) * 1000000000) + (lib.zui.sourceType === 'build-in' ? 10000000 : 11000000) + idx;
return lib;
}).sort((a, b) => a.zui.order - b.zui.order);
}
Expand All @@ -155,11 +155,10 @@ export function createLibFromPackageJson(packageJson: Record<string, unknown>, o
name: defaultName,
extsName,
...(packageJson.zui as Record<string, unknown>),
order: 0,
packageJsonPath,
tailwindConfigPath,
},
} as LibInfo;
libInfo.zui.order = (libTypeOrders[libInfo.zui.type] * 100000000) + idx;
libInfo.zui.order = ((libInfo.zui.order ?? libTypeOrders[libInfo.zui.type]) * 100000000) + idx;
return libInfo;
}

0 comments on commit 0a3bfcf

Please sign in to comment.