Skip to content

Commit

Permalink
fix: getModernVersion exits the process
Browse files Browse the repository at this point in the history
  • Loading branch information
caohuilin committed Oct 12, 2024
1 parent 3d45683 commit 2f01e22
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@
"overrides": {
"@types/react": "^18",
"@types/react-dom": "^18",
"@modern-js/plugin-i18n":"workspace:*",
"@modern-js/codesmith-api-app":"0.0.0-canary-20241012064243",
"@modern-js/codesmith-api-ejs":"0.0.0-canary-20241012064243",
"@modern-js/codesmith-api-fs":"0.0.0-canary-20241012064243",
Expand Down
9 changes: 2 additions & 7 deletions packages/generator/generators/module-generator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@ export const handleTemplateFile = async (
appApi: AppAPI,
) => {
generator.logger?.timing(`🕐 Get Modern.js module-tools version`);
const getModernVersionPromise = getModernVersion(
const modernVersion = await getModernVersion(
Solution.MWA,
context.config.registry,
context.config.distTag,
);
generator.logger?.timing(`🕐 Get Modern.js module-tools version`, true);

const {
isMonorepoSubProject,
Expand Down Expand Up @@ -130,12 +131,6 @@ export const handleTemplateFile = async (
);
}

let modernVersion;

await getModernVersionPromise.then(version => {
modernVersion = version;
generator.logger?.timing(`🕐 Get Modern.js module-tools version`, true);
});
await appApi.forgeTemplate(
'templates/base-template/**/*',
undefined,
Expand Down
9 changes: 2 additions & 7 deletions packages/generator/generators/mwa-generator/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@ export const handleTemplateFile = async (
appApi: AppAPI,
) => {
generator.logger?.timing(`🕐 Get Modern.js app-tools version`);
const getModernVersionPromise = getModernVersion(
const modernVersion = await getModernVersion(
Solution.MWA,
context.config.registry,
context.config.distTag,
);
generator.logger?.timing(`🕐 Get Modern.js app-tools version`, true);

const { isMonorepoSubProject, projectDir = '' } = context.config;

Expand Down Expand Up @@ -125,12 +126,6 @@ export const handleTemplateFile = async (
{ ...context.config, hasPlugin: false },
);

let modernVersion;

await getModernVersionPromise.then(version => {
modernVersion = version;
generator.logger?.timing(`🕐 Get Modern.js app-tools version`, true);
});
await appApi.forgeTemplate(
'templates/base-template/**/*',
undefined,
Expand Down
4 changes: 2 additions & 2 deletions packages/toolkit/create/src/createAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export async function createAction(projectDir: string, options: Options) {
registryUrl: registry === '' ? undefined : registry,
});

// const prepareGlobalPromise = smith.prepareGlobal();
const prepareGlobalPromise = smith.prepareGlobal();

const prepareGeneratorPromise = smith.prepareGenerators([
`@modern-js/repo-generator@${distTag || 'latest'}`,
Expand Down Expand Up @@ -168,7 +168,7 @@ export async function createAction(projectDir: string, options: Options) {
generator = require.resolve(REPO_GENERATOR);
} else if (!path.isAbsolute(generator) && distTag) {
generator = `${generator}@${distTag}`;
await Promise.all([prepareGeneratorPromise]);
await Promise.all([prepareGlobalPromise, prepareGeneratorPromise]);
}

const task: RunnerTask = [
Expand Down

0 comments on commit 2f01e22

Please sign in to comment.