Skip to content

Commit

Permalink
--wip-- [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewvolk committed Jul 31, 2024
1 parent c00b6fb commit 98c5927
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions packages/create-catalyst/src/commands/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { Https } from '../utils/https';
import { installDependencies } from '../utils/install-dependencies';
import { login } from '../utils/login';
import { parse } from '../utils/parse';
import { patchYarn } from '../utils/patch-yarn';
import { getPackageManager, packageManagerChoices } from '../utils/pm';
import { spinner } from '../utils/spinner';
import { writeEnv } from '../utils/write-env';
Expand Down Expand Up @@ -249,6 +250,8 @@ export const create = new Command('create')

console.log(`\nUsing ${chalk.bold(packageManager)}\n`);

patchYarn({ projectDir });

await installDependencies(projectDir, packageManager);

await spinner(exec(`${packageManager} run --prefix ${projectDir} generate`), {
Expand Down
26 changes: 26 additions & 0 deletions packages/create-catalyst/src/utils/patch-yarn.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { outputFileSync, readJsonSync, writeJsonSync } from 'fs-extra/esm';
import set from 'lodash.set';
import { join } from 'path';
import * as z from 'zod';

export const patchYarn = ({ projectDir }: { projectDir: string }) => {
const userAgent = process.env.npm_config_user_agent || '';
const usingYarnBerry = userAgent.includes('yarn/2') || userAgent.includes('yarn/3');

if (!usingYarnBerry) {
return;
}

const yarnrcYml = 'nodeLinker: node-modules\n';

outputFileSync(join(projectDir, '.yarnrc.yml'), yarnrcYml);

const packageJson = z
.object({})
.passthrough()
.parse(readJsonSync(join(projectDir, 'package.json')));

set(packageJson, 'devDependencies.eslint-plugin-prettier', '');

writeJsonSync(join(projectDir, 'package.json'), packageJson, { spaces: 2 });
};

0 comments on commit 98c5927

Please sign in to comment.