Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(okam): node 16 is needed when mako is enabled #11643

Merged
merged 3 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/preset-umi/src/features/okam/okam.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { checkVersion } from '@umijs/utils';
import { IApi } from '../../types';

export default (api: IApi) => {
api.onCheck(() => {
// mako 仅支持 node 16+
// ref: https://github.com/umijs/mako/issues/300
if (api.userConfig.mako) {
checkVersion(16, `Node 16 is required when using mako.`);
}
});
};
1 change: 1 addition & 0 deletions packages/preset-umi/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default () => {
require.resolve('./features/icons/icons'),
require.resolve('./features/mock/mock'),
require.resolve('./features/mpa/mpa'),
require.resolve('./features/okam/okam'),
require.resolve('./features/overrides/overrides'),
require.resolve('./features/phantomDependency/phantomDependency'),
require.resolve('./features/polyfill/polyfill'),
Expand Down
17 changes: 10 additions & 7 deletions packages/umi/src/cli/cli.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
import { logger, printHelp, setNoDeprecation, yParser } from '@umijs/utils';
import { DEV_COMMAND, FRAMEWORK_NAME } from '../constants';
import { Service } from '../service/service';
import { dev } from './dev';
import {
catchUnhandledRejection,
checkLocal,
checkVersion as checkNodeVersion,
logger,
printHelp,
setNoDeprecation,
setNodeTitle,
} from './node';
yParser,
} from '@umijs/utils';
import { DEV_COMMAND, FRAMEWORK_NAME, MIN_NODE_VERSION } from '../constants';
import { Service } from '../service/service';
import { dev } from './dev';

interface IOpts {
presets?: string[];
Expand All @@ -16,9 +19,9 @@ interface IOpts {
catchUnhandledRejection();

export async function run(opts?: IOpts) {
checkNodeVersion();
checkNodeVersion(MIN_NODE_VERSION);
checkLocal();
setNodeTitle();
setNodeTitle(FRAMEWORK_NAME);
setNoDeprecation();

const args = yParser(process.argv.slice(2), {
Expand Down
9 changes: 7 additions & 2 deletions packages/umi/src/cli/forkedDev.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { logger, printHelp, yParser, setNoDeprecation } from '@umijs/utils';
import {
logger,
printHelp,
setNoDeprecation,
setNodeTitle,
yParser,
} from '@umijs/utils';
import { DEV_COMMAND, FRAMEWORK_NAME } from '../constants';
import { Service } from '../service/service';
import { setNodeTitle } from './node';
setNodeTitle(`${FRAMEWORK_NAME}-dev`);
setNoDeprecation();

Expand Down
1 change: 1 addition & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export * from './isJavaScriptFile';
export * from './isLocalDev';
export * from './isMonorepo';
export * from './isStyleFile';
export * from './node';
export * from './npmClient';
export * from './randomColor/randomColor';
export * from './readDirFiles';
Expand Down
14 changes: 7 additions & 7 deletions packages/umi/src/cli/node.ts → packages/utils/src/node.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { isLocalDev, logger } from '@umijs/utils';
import { FRAMEWORK_NAME, MIN_NODE_VERSION } from '../constants';
import { isLocalDev, logger } from './';

const ver = parseInt(process.version.slice(1));

export function checkVersion() {
if (ver < MIN_NODE_VERSION || ver === 15 || ver === 17) {
export function checkVersion(minVersion: number, message?: string) {
if (ver < minVersion || ver === 15 || ver === 17 || ver === 19) {
logger.error(
`Your node version ${ver} is not supported, please upgrade to ${MIN_NODE_VERSION} or above except 15 or 17.`,
message ||
`Your node version ${ver} is not supported, please upgrade to ${minVersion} or above except 15 or 17.`,
);
process.exit(1);
}
Expand All @@ -18,9 +18,9 @@ export function checkLocal() {
}
}

export function setNodeTitle(name?: string) {
export function setNodeTitle(name: string) {
if (process.title === 'node') {
process.title = name || FRAMEWORK_NAME;
process.title = name;
}
}

Expand Down
Loading