Skip to content

Commit d6b6805

Browse files
committed
fix(create-rstack): use pnpm for the Turborepo template
1 parent 3691fdf commit d6b6805

4 files changed

Lines changed: 17 additions & 30 deletions

File tree

packages/create-rstack/src/index.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
import {
99
access,
1010
appendFile,
11-
copyFile,
1211
mkdir,
1312
readFile,
1413
writeFile,
@@ -229,29 +228,13 @@ const injectStagedSetup = async ({
229228
]);
230229
};
231230

232-
const configureTurborepo = async ({
233-
templateName,
234-
distFolder,
235-
}: GitResolvedContext): Promise<void> => {
236-
if (templateName !== 'turborepo') {
237-
return;
238-
}
239-
240-
// The toolkit may skip this file based on the invoking package manager.
241-
await copyFile(
242-
path.join(packageRoot, 'template-turborepo/pnpm-workspace.yaml'),
243-
path.join(distFolder, 'pnpm-workspace.yaml'),
244-
);
245-
};
246-
247231
await create({
248232
root: packageRoot,
249233
name: 'rstack',
250234
templates: templateNames,
251235
builtinTools: [],
252236
getTemplateName,
253-
onGitResolved: async (context) => {
254-
await configureTurborepo(context);
255-
await injectStagedSetup(context);
256-
},
237+
getPackageManager: ({ templateName }) =>
238+
templateName === 'turborepo' ? 'pnpm' : undefined,
239+
onGitResolved: injectStagedSetup,
257240
});

packages/create-rstack/tests/create.test.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,11 @@ const createProject = async (
210210
{
211211
args = [],
212212
initializeGitIn,
213+
userAgent = 'pnpm/11.20.0',
213214
}: {
214215
args?: string[];
215216
initializeGitIn?: 'parent' | 'project';
217+
userAgent?: string;
216218
} = {},
217219
) => {
218220
const tempDirectory = await mkdtemp(path.join(tmpdir(), 'create-rstack-'));
@@ -233,7 +235,7 @@ const createProject = async (
233235
cwd: tempDirectory,
234236
env: {
235237
...process.env,
236-
npm_config_user_agent: 'pnpm/11.20.0',
238+
npm_config_user_agent: userAgent,
237239
},
238240
},
239241
);
@@ -296,8 +298,10 @@ test.each(docTemplates)(
296298
},
297299
);
298300

299-
test('creates the Turborepo template with pnpm', async () => {
300-
const projectDirectory = await createProject('turborepo');
301+
test('creates the Turborepo template with pnpm when invoked using npm', async () => {
302+
const projectDirectory = await createProject('turborepo', {
303+
userAgent: 'npm/11.0.0',
304+
});
301305
const packageJson = await readProjectPackage(projectDirectory);
302306
const appPackage = await readProjectPackage(
303307
path.join(projectDirectory, 'apps/web'),

pnpm-lock.yaml

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pnpm-workspace.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ catalog:
2222
'@rspress/plugin-client-redirects': '^2.0.21'
2323
'@rspress/plugin-sitemap': '^2.0.21'
2424
'@rstackjs/doc-ui': '1.14.11'
25-
'@rstackjs/create-toolkit': '2.2.4'
25+
'@rstackjs/create-toolkit': '2.2.6'
2626
'@rstackjs/load-config': ^0.1.2
2727
'@rstackjs/test-utils': ^0.2.0
2828
'@rstest/adapter-rsbuild': '~0.11.12'

0 commit comments

Comments
 (0)