diff --git a/package.json b/package.json index 9c2695cda..da7bd4dfc 100644 --- a/package.json +++ b/package.json @@ -41,8 +41,7 @@ "version:alpha": "lerna version prerelease --preid alpha --force-publish=* --no-git-tag-version -m \"chore(versions): publish packages %s\"", "release:force": "lerna publish from-package --yes --no-git-tag-version", "release": "lerna publish", - "run:example": "tsx -r dotenv/config -r tsconfig-paths/register ./examples/index.ts", - "prepare": "[ -z \"$CI\" ] && echo \"packages/pro-plugins/\" > .git/info/exclude || true" + "run:example": "tsx -r dotenv/config -r tsconfig-paths/register ./examples/index.ts" }, "resolutions": { "@types/react": "^17.0.0", diff --git a/packages/core/cli/src/commands/postinstall.js b/packages/core/cli/src/commands/postinstall.js index aa3565865..539afdf8b 100644 --- a/packages/core/cli/src/commands/postinstall.js +++ b/packages/core/cli/src/commands/postinstall.js @@ -9,11 +9,27 @@ const { Command } = require('commander'); const { run, isDev, isPackageValid, generatePlaywrightPath } = require('../util'); -const { resolve } = require('path'); -const { existsSync } = require('fs'); +const { dirname, resolve } = require('path'); +const { existsSync, mkdirSync, readFileSync, appendFileSync } = require('fs'); const { readFile, writeFile } = require('fs').promises; const { createStoragePluginsSymlink, createDevPluginsSymlink } = require('@nocobase/utils/plugin-symlink'); +function writeToExclude() { + const excludePath = resolve(process.cwd(), '.git', 'info', 'exclude'); + const content = 'packages/pro-plugins/\n'; + const dirPath = dirname(excludePath); + if (!existsSync(dirPath)) { + mkdirSync(dirPath, { recursive: true }); + } + let fileContent = ''; + if (existsSync(excludePath)) { + fileContent = readFileSync(excludePath, 'utf-8'); + } + if (!fileContent.includes(content)) { + appendFileSync(excludePath, content); + } +} + /** * @param {Command} cli */ @@ -24,6 +40,8 @@ module.exports = (cli) => { .allowUnknownOption() .option('--skip-umi') .action(async (options) => { + writeToExclude(); + generatePlaywrightPath(true); await createStoragePluginsSymlink(); if (!isDev()) {