From 5712dfdffef23c1357a111bd4e19d1a9d6a3be36 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 --- package-lock.json | 7 +++---- package.json | 5 ++--- src/main.ts | 35 +++++++++++++++++++++++++++++++---- 3 files changed, 36 insertions(+), 11 deletions(-) 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!'); }