Skip to content
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
23 changes: 3 additions & 20 deletions packages/create-rstack/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
import {
access,
appendFile,
copyFile,
mkdir,
readFile,
writeFile,
Expand Down Expand Up @@ -229,29 +228,13 @@ const injectStagedSetup = async ({
]);
};

const configureTurborepo = async ({
templateName,
distFolder,
}: GitResolvedContext): Promise<void> => {
if (templateName !== 'turborepo') {
return;
}

// The toolkit may skip this file based on the invoking package manager.
await copyFile(
path.join(packageRoot, 'template-turborepo/pnpm-workspace.yaml'),
path.join(distFolder, 'pnpm-workspace.yaml'),
);
};

await create({
root: packageRoot,
name: 'rstack',
templates: templateNames,
builtinTools: [],
getTemplateName,
onGitResolved: async (context) => {
await configureTurborepo(context);
await injectStagedSetup(context);
},
getPackageManager: ({ templateName }) =>
templateName === 'turborepo' ? 'pnpm' : undefined,
onGitResolved: injectStagedSetup,
});
10 changes: 7 additions & 3 deletions packages/create-rstack/tests/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,11 @@ const createProject = async (
{
args = [],
initializeGitIn,
userAgent = 'pnpm/11.20.0',
}: {
args?: string[];
initializeGitIn?: 'parent' | 'project';
userAgent?: string;
} = {},
) => {
const tempDirectory = await mkdtemp(path.join(tmpdir(), 'create-rstack-'));
Expand All @@ -233,7 +235,7 @@ const createProject = async (
cwd: tempDirectory,
env: {
...process.env,
npm_config_user_agent: 'pnpm/11.20.0',
npm_config_user_agent: userAgent,
},
},
);
Expand Down Expand Up @@ -296,8 +298,10 @@ test.each(docTemplates)(
},
);

test('creates the Turborepo template with pnpm', async () => {
const projectDirectory = await createProject('turborepo');
test('creates the Turborepo template with pnpm when invoked using npm', async () => {
const projectDirectory = await createProject('turborepo', {
userAgent: 'npm/11.0.0',
});
const packageJson = await readProjectPackage(projectDirectory);
const appPackage = await readProjectPackage(
path.join(projectDirectory, 'apps/web'),
Expand Down
12 changes: 6 additions & 6 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ catalog:
'@rspress/plugin-client-redirects': '^2.0.21'
'@rspress/plugin-sitemap': '^2.0.21'
'@rstackjs/doc-ui': '1.14.11'
'@rstackjs/create-toolkit': '2.2.4'
'@rstackjs/create-toolkit': '2.2.6'
'@rstackjs/load-config': ^0.1.2
'@rstackjs/test-utils': ^0.2.0
'@rstest/adapter-rsbuild': '~0.11.12'
Expand Down