Skip to content

Commit

Permalink
fix: 修复在使用 yarn 管理包时产生的系统错误
Browse files Browse the repository at this point in the history
  • Loading branch information
WangJM001 committed Jun 19, 2024
1 parent a9e5e4c commit f3adaa1
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/create-poros/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "create-poros",
"version": "1.1.5",
"version": "1.1.6",
"description": "create-poros",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
3 changes: 3 additions & 0 deletions packages/create-poros/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ interface ITemplateParams extends ITemplatePluginParams {
name: string;
version: string;
npmClient: ENpmClient;
isYarn: boolean;
registry: string;
author: string;
email: string;
Expand Down Expand Up @@ -59,6 +60,7 @@ const DEFAULT_DATA = {
author: 'poros',
version: pkg.version,
npmClient: ENpmClient.pnpm,
isYarn: false,
registry: ERegistry.npm,
withHusky: false,
extraNpmrc: '',
Expand Down Expand Up @@ -212,6 +214,7 @@ export default async ({ cwd, args, defaultData = DEFAULT_DATA }: IGeneratorOpts)
: ({
version: version.includes('-canary.') ? version : `^${version}`,
npmClient,
isYarn: npmClient === ENpmClient.yarn,
registry,
author,
email,
Expand Down
2 changes: 1 addition & 1 deletion packages/create-poros/templates/app/package.json.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build:win": "poros build --win --x64 --ia32",
"dev": "poros dev",
"format": "prettier --cache --write .",
"postinstall": "poros setup",{{#withHusky}}
"postinstall": "{{#isYarn}}poros patch & {{/isYarn}}poros setup",{{#withHusky}}
"prepare": "husky install",{{/withHusky}}
"rebuild-deps": "poros rebuild-deps",
"setup": "poros setup",
Expand Down
4 changes: 3 additions & 1 deletion packages/poros/src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { chalk, checkLocal, logger, printHelp, setNoDeprecation, setNodeTitle, yParser } from '@umijs/utils';
import { chalk, checkLocal, execa, logger, printHelp, setNoDeprecation, setNodeTitle, yParser } from '@umijs/utils';
import { dev } from 'umi/dist/cli/dev';
import { DEV_COMMAND, MIN_NODE_VERSION } from 'umi/dist/constants';
import { Service } from 'umi/dist/service/service';
Expand Down Expand Up @@ -55,6 +55,8 @@ export async function run(opts: IOpts = {}) {
platform: process.platform,
arch: process.arch === 'arm' ? 'armv7l' : process.arch,
});
} else if (command === 'patch') {
await execa.execa('node', ['../scripts/postinstall'], { cwd: __dirname });
} else {
logger.info(chalk.cyan.bold(`Poros v${version}`));

Expand Down

0 comments on commit f3adaa1

Please sign in to comment.