From 51214639493ec39ca41dfc90a71d7f43750ba26d Mon Sep 17 00:00:00 2001 From: 43081j <43081j@users.noreply.github.com> Date: Fri, 9 Aug 2024 10:50:49 +0100 Subject: [PATCH] chore: rename to esperf --- README.md | 12 ++++++------ package-lock.json | 7 +++---- package.json | 5 ++--- src/main.ts | 35 +++++++++++++++++++++++++++++++---- 4 files changed, 42 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index c257baf..25e5d4c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# module-replacements CLI +# esperf > A command-line utility for detecting and fixing performance problems in > JavaScript projects. @@ -6,7 +6,10 @@ ## Install ```sh -npm i -S module-replacements-cli +npm i -S esperf + +# or +npx esperf ``` ## Usage @@ -17,10 +20,7 @@ The interactive CLI can guide you through the following steps: - Applying the replacements automatically ```sh -npx mr - -# or the full name -npx module-replacements +npx esperf ``` ## License diff --git a/package-lock.json b/package-lock.json index 702fa73..7dfde7e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,11 @@ { - "name": "mr-cli", + "name": "esperf", "version": "0.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "mr-cli", + "name": "esperf", "version": "0.0.1", "license": "MIT", "dependencies": { @@ -20,8 +20,7 @@ "tinyexec": "^0.1.2" }, "bin": { - "module-replacements": "lib/bin.js", - "mr": "lib/bin.js" + "esperf": "lib/bin.js" }, "devDependencies": { "@eslint/js": "^9.8.0", diff --git a/package.json b/package.json index 3042486..55e9b85 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "mr-cli", + "name": "esperf", "version": "0.0.1", "description": "A command-line utility for detecting performance issues", "main": "lib/main.js", @@ -9,8 +9,7 @@ "!lib/test" ], "bin": { - "module-replacements": "./lib/bin.js", - "mr": "./lib/bin.js" + "esperf": "./lib/bin.js" }, "scripts": { "clean:build": "premove lib", diff --git a/src/main.ts b/src/main.ts index a001de3..61318d9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -28,11 +28,40 @@ function isDependenciesLike(obj: unknown): obj is Record { } export async function run(): Promise { + cl.intro('esperf'); + + const tasks = await cl.multiselect({ + message: 'What would you like to do?', + initialValues: [ + 'module-replacements' + ], + options: [ + { + label: 'Scan for module replacements', + value: 'module-replacements' + } + ] + }); + + if (cl.isCancel(tasks)) { + cl.cancel('Operation cancelled'); + exit(0); + } + + for (const task of tasks) { + switch (task) { + case 'module-replacements': + await runModuleReplacements(); + break; + } + } + + cl.outro('All tasks complete!'); +} +async function runModuleReplacements(): Promise { const cwd = getCwd(); const packageManifest = await findPackage(cwd); - cl.intro('module-replacements'); - if (packageManifest === null) { cl.log.error(dedent` Could not find package.json. Please ensure that you run this command in a project which has one setup. @@ -208,6 +237,4 @@ export async function run(): Promise { if (options.fix) { await fixFiles(scanFilesResult); } - - cl.outro('All checks complete!'); }