From aedd71d93a750bedb4d2ae381cba2b2b6e024fb9 Mon Sep 17 00:00:00 2001 From: Bharat Kashyap Date: Fri, 26 Jul 2024 13:36:36 +0530 Subject: [PATCH 1/4] fix: Skips install on `--example` --- packages/create-toolpad-app/src/index.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/create-toolpad-app/src/index.ts b/packages/create-toolpad-app/src/index.ts index fca7da2cf53..384e220e82a 100644 --- a/packages/create-toolpad-app/src/index.ts +++ b/packages/create-toolpad-app/src/index.ts @@ -264,6 +264,19 @@ const run = async () => { // If the user has provided an example, download and extract it if (args.example) { await downloadAndExtractExample(absolutePath, args.example); + // eslint-disable-next-line no-console + console.log(`${chalk.cyan('info')} - Installing dependencies`); + // eslint-disable-next-line no-console + console.log(); + await execa(packageManager, ['install'], { stdio: 'inherit', cwd: absolutePath }); + // eslint-disable-next-line no-console + console.log(); + // eslint-disable-next-line no-console + console.log( + `${chalk.green('success')} - Installed "${args.example}" at ${chalk.cyan(absolutePath)}`, + ); + // eslint-disable-next-line no-console + console.log(); } // If the core flag is set, create a new project with Toolpad Core else if (coreFlag) { From 305cc1fa7dc21648b5060859410441c454245247 Mon Sep 17 00:00:00 2001 From: Bharat Kashyap Date: Fri, 26 Jul 2024 16:29:55 +0530 Subject: [PATCH 2/4] fix: eslint causing `ERESOLVE`, install example deps, clean up --- examples/core-tutorial/package.json | 1 - packages/create-toolpad-app/src/examples.ts | 2 - packages/create-toolpad-app/src/index.ts | 65 +++++++++------------ 3 files changed, 28 insertions(+), 40 deletions(-) diff --git a/examples/core-tutorial/package.json b/examples/core-tutorial/package.json index 41f9fca3715..5afb84bce87 100644 --- a/examples/core-tutorial/package.json +++ b/examples/core-tutorial/package.json @@ -23,7 +23,6 @@ "@types/node": "^20.14.9", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", - "eslint": "^9.6.0", "eslint-config-next": "^14.2.4" } } diff --git a/packages/create-toolpad-app/src/examples.ts b/packages/create-toolpad-app/src/examples.ts index 93f4e4c64a9..f8f8445dfcc 100644 --- a/packages/create-toolpad-app/src/examples.ts +++ b/packages/create-toolpad-app/src/examples.ts @@ -50,8 +50,6 @@ export async function downloadAndExtractExample(root: string, name: string) { filter: (p) => p.includes(`mui-toolpad-master/examples/${name}/`), }); - // eslint-disable-next-line no-console - console.log(); // eslint-disable-next-line no-console console.log( `${chalk.green('success')} - Downloaded and extracted "${name}" to ${chalk.cyan(root)}`, diff --git a/packages/create-toolpad-app/src/index.ts b/packages/create-toolpad-app/src/index.ts index 384e220e82a..32ac7f7213d 100644 --- a/packages/create-toolpad-app/src/index.ts +++ b/packages/create-toolpad-app/src/index.ts @@ -1,4 +1,5 @@ #!/usr/bin/env node +/* eslint-disable no-console */ import * as fs from 'fs/promises'; import { constants as fsConstants } from 'fs'; @@ -110,13 +111,10 @@ const validatePath = async (relativePath: string): Promise => // Create a new `package.json` file and install dependencies const scaffoldStudioProject = async (absolutePath: string, installFlag: boolean): Promise => { - // eslint-disable-next-line no-console console.log(); - // eslint-disable-next-line no-console console.log( `${chalk.cyan('info')} - Creating Toolpad Studio project in ${chalk.cyan(absolutePath)}`, ); - // eslint-disable-next-line no-console console.log(); const packageJson: PackageJson = { @@ -133,11 +131,10 @@ const scaffoldStudioProject = async (absolutePath: string, installFlag: boolean) }; const DEFAULT_GENERATED_GITIGNORE_FILE = '.gitignore'; - // eslint-disable-next-line no-console + console.log(`${chalk.cyan('info')} - Initializing package.json file`); await fs.writeFile(path.join(absolutePath, 'package.json'), JSON.stringify(packageJson, null, 2)); - // eslint-disable-next-line no-console console.log(`${chalk.cyan('info')} - Initializing .gitignore file`); await fs.copyFile( path.resolve(__dirname, `./gitignoreTemplate`), @@ -145,48 +142,43 @@ const scaffoldStudioProject = async (absolutePath: string, installFlag: boolean) ); if (installFlag) { - // eslint-disable-next-line no-console console.log(`${chalk.cyan('info')} - Installing dependencies`); - // eslint-disable-next-line no-console + console.log(); await execa(packageManager, ['install'], { stdio: 'inherit', cwd: absolutePath }); - // eslint-disable-next-line no-console console.log(); - // eslint-disable-next-line no-console + console.log(`${chalk.green('success')} - Dependencies installed successfully!`); - // eslint-disable-next-line no-console + console.log(); } }; const scaffoldCoreProject = async (absolutePath: string): Promise => { - // eslint-disable-next-line no-console console.log(); - // eslint-disable-next-line no-console + console.log( `${chalk.cyan('info')} - Creating Toolpad Core project in ${chalk.cyan(absolutePath)}`, ); - // eslint-disable-next-line no-console + console.log(); const files = generateProject({ name: path.basename(absolutePath) }); await writeFiles(absolutePath, files); - // eslint-disable-next-line no-console console.log(`${chalk.cyan('info')} - Installing dependencies`); - // eslint-disable-next-line no-console + console.log(); await execa(packageManager, ['install'], { stdio: 'inherit', cwd: absolutePath }); - // eslint-disable-next-line no-console console.log(); - // eslint-disable-next-line no-console + console.log( `${chalk.green('success')} - Created Toolpad Core project at ${chalk.cyan(absolutePath)}`, ); - // eslint-disable-next-line no-console + console.log(); }; @@ -200,7 +192,6 @@ const run = async () => { // check the node version before create if (!satisfies(process.version, pkgJson.engines.node)) { - // eslint-disable-next-line no-console console.log( `${chalk.red('error')} - Your node version ${ process.version @@ -240,11 +231,10 @@ const run = async () => { if (pathArg) { const pathValidOrError = await validatePath(pathArg); if (typeof pathValidOrError === 'string') { - // eslint-disable-next-line no-console console.log(); - // eslint-disable-next-line no-console + console.log(pathValidOrError); - // eslint-disable-next-line no-console + console.log(); process.exit(1); } @@ -264,19 +254,21 @@ const run = async () => { // If the user has provided an example, download and extract it if (args.example) { await downloadAndExtractExample(absolutePath, args.example); - // eslint-disable-next-line no-console - console.log(`${chalk.cyan('info')} - Installing dependencies`); - // eslint-disable-next-line no-console - console.log(); - await execa(packageManager, ['install'], { stdio: 'inherit', cwd: absolutePath }); - // eslint-disable-next-line no-console - console.log(); - // eslint-disable-next-line no-console - console.log( - `${chalk.green('success')} - Installed "${args.example}" at ${chalk.cyan(absolutePath)}`, - ); - // eslint-disable-next-line no-console - console.log(); + + if (installFlag) { + console.log(`${chalk.cyan('info')} - Installing dependencies`); + + console.log(); + await execa(packageManager, ['install'], { stdio: 'inherit', cwd: absolutePath }); + + console.log(); + + console.log( + `${chalk.green('success')} - Installed "${args.example}" at ${chalk.cyan(absolutePath)}`, + ); + + console.log(); + } } // If the core flag is set, create a new project with Toolpad Core else if (coreFlag) { @@ -302,9 +294,8 @@ const run = async () => { packageManager === 'yarn' ? '' : ' run' } dev`, )}`; - // eslint-disable-next-line no-console + console.log(message); - // eslint-disable-next-line no-console console.log(); }; From 096ec8fed7582d50d90d532e110c84df3b3a1258 Mon Sep 17 00:00:00 2001 From: Bharat Kashyap Date: Fri, 26 Jul 2024 17:06:04 +0530 Subject: [PATCH 3/4] fix: CI --- pnpm-lock.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a2278b465fd..0e4d12e4d4c 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -191,7 +191,7 @@ importers: version: 7.34.3(eslint@8.57.0) eslint-plugin-react-compiler: specifier: latest - version: 0.0.0-experimental-0998c1e-20240625(eslint@8.57.0) + version: 0.0.0-experimental-9ed098e-20240725(eslint@8.57.0) eslint-plugin-react-hooks: specifier: 4.6.2 version: 4.6.2(eslint@8.57.0) @@ -5755,8 +5755,8 @@ packages: peerDependencies: eslint: '>=7.0.0' - eslint-plugin-react-compiler@0.0.0-experimental-0998c1e-20240625: - resolution: {integrity: sha512-npq2RomExoQI3jETs4OrifaygyJYgOcX/q74Q9OC7GmffLh5zSJaQpzjs2fi61NMNkJyIvTBD0C6sKTGGcetOw==} + eslint-plugin-react-compiler@0.0.0-experimental-9ed098e-20240725: + resolution: {integrity: sha512-Xv2iD8kU6R4Wdjdh1WhdP8UnSqSV+/XcadxwBCmMr836fQUoXGuw/uVGc01v9opZs9SwKzo+8My6ayVCgAinPA==} engines: {node: ^14.17.0 || ^16.0.0 || >= 18.0.0} peerDependencies: eslint: '>=7' @@ -15503,7 +15503,7 @@ snapshots: globals: 13.24.0 rambda: 7.5.0 - eslint-plugin-react-compiler@0.0.0-experimental-0998c1e-20240625(eslint@8.57.0): + eslint-plugin-react-compiler@0.0.0-experimental-9ed098e-20240725(eslint@8.57.0): dependencies: '@babel/core': 7.24.9 '@babel/parser': 7.24.8 From baf991898329be1bb3d68b43c7da31bcf2585a36 Mon Sep 17 00:00:00 2001 From: Bharat Kashyap Date: Sat, 27 Jul 2024 11:43:55 +0530 Subject: [PATCH 4/4] fix: Jan review --- packages/create-toolpad-app/src/index.ts | 46 +++++++++++++++--------- 1 file changed, 29 insertions(+), 17 deletions(-) diff --git a/packages/create-toolpad-app/src/index.ts b/packages/create-toolpad-app/src/index.ts index 32ac7f7213d..a2013dae422 100644 --- a/packages/create-toolpad-app/src/index.ts +++ b/packages/create-toolpad-app/src/index.ts @@ -1,5 +1,4 @@ #!/usr/bin/env node -/* eslint-disable no-console */ import * as fs from 'fs/promises'; import { constants as fsConstants } from 'fs'; @@ -111,10 +110,13 @@ const validatePath = async (relativePath: string): Promise => // Create a new `package.json` file and install dependencies const scaffoldStudioProject = async (absolutePath: string, installFlag: boolean): Promise => { + // eslint-disable-next-line no-console console.log(); + // eslint-disable-next-line no-console console.log( `${chalk.cyan('info')} - Creating Toolpad Studio project in ${chalk.cyan(absolutePath)}`, ); + // eslint-disable-next-line no-console console.log(); const packageJson: PackageJson = { @@ -131,10 +133,11 @@ const scaffoldStudioProject = async (absolutePath: string, installFlag: boolean) }; const DEFAULT_GENERATED_GITIGNORE_FILE = '.gitignore'; - + // eslint-disable-next-line no-console console.log(`${chalk.cyan('info')} - Initializing package.json file`); await fs.writeFile(path.join(absolutePath, 'package.json'), JSON.stringify(packageJson, null, 2)); + // eslint-disable-next-line no-console console.log(`${chalk.cyan('info')} - Initializing .gitignore file`); await fs.copyFile( path.resolve(__dirname, `./gitignoreTemplate`), @@ -142,43 +145,48 @@ const scaffoldStudioProject = async (absolutePath: string, installFlag: boolean) ); if (installFlag) { + // eslint-disable-next-line no-console console.log(`${chalk.cyan('info')} - Installing dependencies`); - + // eslint-disable-next-line no-console console.log(); await execa(packageManager, ['install'], { stdio: 'inherit', cwd: absolutePath }); + // eslint-disable-next-line no-console console.log(); - + // eslint-disable-next-line no-console console.log(`${chalk.green('success')} - Dependencies installed successfully!`); - + // eslint-disable-next-line no-console console.log(); } }; const scaffoldCoreProject = async (absolutePath: string): Promise => { + // eslint-disable-next-line no-console console.log(); - + // eslint-disable-next-line no-console console.log( `${chalk.cyan('info')} - Creating Toolpad Core project in ${chalk.cyan(absolutePath)}`, ); - + // eslint-disable-next-line no-console console.log(); const files = generateProject({ name: path.basename(absolutePath) }); await writeFiles(absolutePath, files); + // eslint-disable-next-line no-console console.log(`${chalk.cyan('info')} - Installing dependencies`); - + // eslint-disable-next-line no-console console.log(); await execa(packageManager, ['install'], { stdio: 'inherit', cwd: absolutePath }); + // eslint-disable-next-line no-console console.log(); - + // eslint-disable-next-line no-console console.log( `${chalk.green('success')} - Created Toolpad Core project at ${chalk.cyan(absolutePath)}`, ); - + // eslint-disable-next-line no-console console.log(); }; @@ -192,6 +200,7 @@ const run = async () => { // check the node version before create if (!satisfies(process.version, pkgJson.engines.node)) { + // eslint-disable-next-line no-console console.log( `${chalk.red('error')} - Your node version ${ process.version @@ -231,10 +240,11 @@ const run = async () => { if (pathArg) { const pathValidOrError = await validatePath(pathArg); if (typeof pathValidOrError === 'string') { + // eslint-disable-next-line no-console console.log(); - + // eslint-disable-next-line no-console console.log(pathValidOrError); - + // eslint-disable-next-line no-console console.log(); process.exit(1); } @@ -256,17 +266,18 @@ const run = async () => { await downloadAndExtractExample(absolutePath, args.example); if (installFlag) { + // eslint-disable-next-line no-console console.log(`${chalk.cyan('info')} - Installing dependencies`); - + // eslint-disable-next-line no-console console.log(); await execa(packageManager, ['install'], { stdio: 'inherit', cwd: absolutePath }); - + // eslint-disable-next-line no-console console.log(); - + // eslint-disable-next-line no-console console.log( `${chalk.green('success')} - Installed "${args.example}" at ${chalk.cyan(absolutePath)}`, ); - + // eslint-disable-next-line no-console console.log(); } } @@ -294,8 +305,9 @@ const run = async () => { packageManager === 'yarn' ? '' : ' run' } dev`, )}`; - + // eslint-disable-next-line no-console console.log(message); + // eslint-disable-next-line no-console console.log(); };