Skip to content

Commit

Permalink
fix: metadata version number injection error (#4606)
Browse files Browse the repository at this point in the history
* fix: metadata version number injection error

* chore: update deps
  • Loading branch information
anncwb authored Oct 10, 2024
1 parent 437cb02 commit f923f59
Show file tree
Hide file tree
Showing 13 changed files with 299 additions and 208 deletions.
7 changes: 3 additions & 4 deletions internal/tailwind-config/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import type { Config } from 'tailwindcss';

import fs from 'node:fs';
import path from 'node:path';

import { getPackagesSync } from '@vben/node-utils';
Expand All @@ -19,9 +18,9 @@ const tailwindPackages: string[] = [];

packages.forEach((pkg) => {
// apps目录下和 @vben-core/tailwind-ui 包需要使用到 tailwindcss ui
if (fs.existsSync(path.join(pkg.dir, 'tailwind.config.mjs'))) {
tailwindPackages.push(pkg.dir);
}
// if (fs.existsSync(path.join(pkg.dir, 'tailwind.config.mjs'))) {
tailwindPackages.push(pkg.dir);
// }
});

const shadcnUiColors = {
Expand Down
1 change: 1 addition & 0 deletions internal/vite-config/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"vite-plugin-vue-devtools": "catalog:"
},
"devDependencies": {
"@pnpm/workspace.read-manifest": "catalog:",
"@types/archiver": "catalog:",
"@types/html-minifier-terser": "catalog:",
"@vben/node-utils": "workspace:*",
Expand Down
31 changes: 28 additions & 3 deletions internal/vite-config/src/plugins/inject-metadata.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
import type { PluginOption } from 'vite';

import { dateUtil, getPackages, readPackageJSON } from '@vben/node-utils';
import {
dateUtil,
findMonorepoRoot,
getPackages,
readPackageJSON,
} from '@vben/node-utils';

import { readWorkspaceManifest } from '@pnpm/workspace.read-manifest';

function resolvePackageVersion(
pkgsMeta: Record<string, string>,
name: string,
value: string,
catalog: Record<string, string>,
) {
if (value.includes('catalog:')) {
return catalog[name];
}

if (value.includes('workspace')) {
return pkgsMeta[name];
}

return value;
}

async function resolveMonorepoDependencies() {
const { packages } = await getPackages();
const manifest = await readWorkspaceManifest(findMonorepoRoot());
const catalog = manifest?.catalog || {};

const resultDevDependencies: Record<string, string | undefined> = {};
const resultDependencies: Record<string, string | undefined> = {};
Expand All @@ -27,10 +42,20 @@ async function resolveMonorepoDependencies() {
for (const { packageJson } of packages) {
const { dependencies = {}, devDependencies = {} } = packageJson;
for (const [key, value] of Object.entries(dependencies)) {
resultDependencies[key] = resolvePackageVersion(pkgsMeta, key, value);
resultDependencies[key] = resolvePackageVersion(
pkgsMeta,
key,
value,
catalog,
);
}
for (const [key, value] of Object.entries(devDependencies)) {
resultDevDependencies[key] = resolvePackageVersion(pkgsMeta, key, value);
resultDevDependencies[key] = resolvePackageVersion(
pkgsMeta,
key,
value,
catalog,
);
}
}
return {
Expand Down
1 change: 0 additions & 1 deletion packages/effects/access/postcss.config.mjs

This file was deleted.

1 change: 0 additions & 1 deletion packages/effects/access/tailwind.config.mjs

This file was deleted.

1 change: 0 additions & 1 deletion packages/effects/common-ui/postcss.config.mjs

This file was deleted.

1 change: 0 additions & 1 deletion packages/effects/common-ui/tailwind.config.mjs

This file was deleted.

1 change: 0 additions & 1 deletion packages/effects/layouts/postcss.config.mjs

This file was deleted.

1 change: 0 additions & 1 deletion packages/effects/layouts/tailwind.config.mjs

This file was deleted.

1 change: 0 additions & 1 deletion packages/effects/plugins/postcss.config.mjs

This file was deleted.

1 change: 0 additions & 1 deletion packages/effects/plugins/tailwind.config.mjs

This file was deleted.

Loading

0 comments on commit f923f59

Please sign in to comment.