Skip to content

Commit adfdbb1

Browse files
authored
fix: revert #10847 (#10882)
Reverts #10847
1 parent 157e277 commit adfdbb1

File tree

8 files changed

+709
-864
lines changed

8 files changed

+709
-864
lines changed

packages/create-turbo/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"dependencies": {
2626
"commander": "^11.0.0",
2727
"fs-extra": "^11.1.1",
28-
"inquirer": "^8.2.7",
28+
"inquirer": "^8.0.0",
2929
"picocolors": "1.0.1",
3030
"proxy-agent": "^6.5.0",
3131
"semver": "^7.3.8",

packages/turbo-codemod/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
"find-up": "4.1.0",
2929
"fs-extra": "^10.0.0",
3030
"gradient-string": "^2.0.0",
31-
"inquirer": "^8.2.7",
31+
"inquirer": "^8.2.4",
3232
"inquirer-file-tree-selection-prompt": "^1.0.19",
33-
"is-git-clean": "^1.1.0",
3433
"json5": "^2.2.3",
34+
"is-git-clean": "^1.1.0",
3535
"ora": "4.1.1",
3636
"picocolors": "1.0.1",
3737
"semver": "^7.3.7",

packages/turbo-gen/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
"@turbo/workspaces": "workspace:*",
2828
"commander": "^10.0.0",
2929
"fs-extra": "^10.1.0",
30-
"inquirer": "^8.2.7",
30+
"inquirer": "^8.2.4",
3131
"minimatch": "^9.0.0",
32-
"node-plop": "0.32.1",
32+
"node-plop": "^0.26.3",
3333
"picocolors": "1.0.1",
3434
"proxy-agent": "^6.5.0",
3535
"ts-node": "^10.9.2",
@@ -47,8 +47,8 @@
4747
"@types/inquirer": "^8.2.5",
4848
"@types/node": "^18.17.2",
4949
"@types/validate-npm-package-name": "^4.0.0",
50-
"jest": "^29.7.0",
5150
"publint": "^0.3.12",
51+
"jest": "^29.7.0",
5252
"ts-jest": "^29.2.5",
5353
"tsup": "^6.7.0",
5454
"typescript": "5.5.4"

packages/turbo-gen/src/generators/custom.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,7 @@ export async function generate({
1111
opts,
1212
}: CustomGeneratorArguments) {
1313
let isOnboarding = false;
14-
let generators = await getCustomGenerators({
15-
project,
16-
configPath: opts.config,
17-
});
14+
let generators = getCustomGenerators({ project, configPath: opts.config });
1815
if (!generators.length) {
1916
logger.error(`No generators found.`);
2017
logger.log();
@@ -43,10 +40,7 @@ export async function generate({
4340
logger.log();
4441

4542
// fetch generators again, and continue to selection prompt
46-
generators = await getCustomGenerators({
47-
project,
48-
configPath: opts.config,
49-
});
43+
generators = getCustomGenerators({ project, configPath: opts.config });
5044

5145
// something went wrong and we weren't able to find our new custom generator
5246
if (!generators.length) {

packages/turbo-gen/src/utils/plop.ts

Lines changed: 28 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import path from "node:path";
22
import fs from "fs-extra";
33
import type { Project } from "@turbo/workspaces";
44
import type { NodePlopAPI, PlopGenerator } from "node-plop";
5+
import nodePlop from "node-plop";
56
import { register } from "ts-node";
67
import { Separator } from "inquirer";
78
import { searchUp, getTurboConfigs, logger } from "@turbo/utils";
@@ -26,13 +27,13 @@ export type Generator = PlopGenerator & {
2627
name: string;
2728
};
2829

29-
export async function getPlop({
30+
export function getPlop({
3031
project,
3132
configPath,
3233
}: {
3334
project: Project;
3435
configPath?: string;
35-
}): Promise<NodePlopAPI | undefined> {
36+
}): NodePlopAPI | undefined {
3637
// init ts-node for plop to support ts configs
3738
register({
3839
transpileOnly: true,
@@ -55,8 +56,7 @@ export async function getPlop({
5556
}
5657

5758
try {
58-
const { default: nodePlop } = await import("node-plop");
59-
plop = await nodePlop(configPath, {
59+
plop = nodePlop(configPath, {
6060
destBasePath: configPath,
6161
force: false,
6262
});
@@ -65,33 +65,26 @@ export async function getPlop({
6565
}
6666
} else {
6767
// look for a root config
68-
const rootConfigPromises = SUPPORTED_ROOT_GENERATOR_CONFIGS.map(
69-
async (possiblePath) => {
70-
const plopFile = path.join(project.paths.root, possiblePath);
71-
if (!fs.existsSync(plopFile)) {
72-
return null;
73-
}
74-
75-
try {
76-
const { default: nodePlop } = await import("node-plop");
77-
return await nodePlop(plopFile, {
78-
destBasePath: project.paths.root,
79-
force: false,
80-
});
81-
} catch (e) {
82-
logger.error(e);
83-
return null;
84-
}
68+
for (const possiblePath of SUPPORTED_ROOT_GENERATOR_CONFIGS) {
69+
const plopFile = path.join(project.paths.root, possiblePath);
70+
if (!fs.existsSync(plopFile)) {
71+
continue;
8572
}
86-
);
8773

88-
const rootConfigs = await Promise.all(rootConfigPromises);
89-
plop = rootConfigs.find((config) => config !== null) || undefined;
74+
try {
75+
plop = nodePlop(plopFile, {
76+
destBasePath: project.paths.root,
77+
force: false,
78+
});
79+
break;
80+
} catch (e) {
81+
logger.error(e);
82+
}
83+
}
9084

9185
if (!plop && workspaceConfigs.length > 0) {
9286
// if no root config, use the first workspace config as the entrypoint
93-
const { default: nodePlop } = await import("node-plop");
94-
plop = await nodePlop(workspaceConfigs[0].config, {
87+
plop = nodePlop(workspaceConfigs[0].config, {
9588
destBasePath: workspaceConfigs[0].root,
9689
force: false,
9790
});
@@ -101,30 +94,29 @@ export async function getPlop({
10194

10295
if (plop) {
10396
// add in all the workspace configs
104-
const loadPromises = workspaceConfigs.map(async (c) => {
97+
workspaceConfigs.forEach((c) => {
10598
try {
106-
await plop.load(c.config, {
99+
plop.load(c.config, {
107100
destBasePath: c.root,
108101
force: false,
109102
});
110103
} catch (e) {
111104
logger.error(e);
112105
}
113106
});
114-
await Promise.all(loadPromises);
115107
}
116108

117109
return plop;
118110
}
119111

120-
export async function getCustomGenerators({
112+
export function getCustomGenerators({
121113
project,
122114
configPath,
123115
}: {
124116
project: Project;
125117
configPath?: string;
126-
}): Promise<Array<Generator | Separator>> {
127-
const plop = await getPlop({ project, configPath });
118+
}): Array<Generator | Separator> {
119+
const plop = getPlop({ project, configPath });
128120

129121
if (!plop) {
130122
return [];
@@ -174,16 +166,16 @@ export async function getCustomGenerators({
174166
return gensWithSeparators;
175167
}
176168

177-
export async function getCustomGenerator({
169+
export function getCustomGenerator({
178170
project,
179171
generator,
180172
configPath,
181173
}: {
182174
project: Project;
183175
generator: string;
184176
configPath?: string;
185-
}): Promise<string | undefined> {
186-
const plop = await getPlop({ project, configPath });
177+
}): string | undefined {
178+
const plop = getPlop({ project, configPath });
187179
if (!plop) {
188180
return undefined;
189181
}
@@ -257,7 +249,7 @@ export async function runCustomGenerator({
257249
bypassArgs?: Array<string>;
258250
configPath?: string;
259251
}): Promise<void> {
260-
const plop = await getPlop({ project, configPath });
252+
const plop = getPlop({ project, configPath });
261253
if (!plop) {
262254
throw new GeneratorError("Unable to load generators", {
263255
type: "plop_unable_to_load_config",

packages/turbo-gen/tsconfig.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"extends": "@turbo/tsconfig/library.json",
33
"exclude": ["src/templates", "dist", "node_modules"],
44
"compilerOptions": {
5-
"rootDir": ".",
6-
"module": "ESNext"
5+
"rootDir": "."
76
}
87
}

packages/turbo-workspaces/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
"fast-glob": "^3.2.12",
3131
"fs-extra": "^10.1.0",
3232
"gradient-string": "^2.0.0",
33-
"inquirer": "^8.2.7",
33+
"inquirer": "^8.0.0",
3434
"js-yaml": "^4.1.0",
3535
"ora": "4.1.1",
3636
"picocolors": "1.0.1",

0 commit comments

Comments
 (0)