Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: rename to esperf #7

Merged
merged 1 commit into from
Aug 9, 2024
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
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
# module-replacements CLI
# esperf

> A command-line utility for detecting and fixing performance problems in
> JavaScript projects.

## Install

```sh
npm i -S module-replacements-cli
npm i -S esperf

# or
npx esperf
```

## Usage
Expand All @@ -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
Expand Down
7 changes: 3 additions & 4 deletions package-lock.json

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

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand Down
35 changes: 31 additions & 4 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,40 @@ function isDependenciesLike(obj: unknown): obj is Record<string, string> {
}

export async function run(): Promise<void> {
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<void> {
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.
Expand Down Expand Up @@ -208,6 +237,4 @@ export async function run(): Promise<void> {
if (options.fix) {
await fixFiles(scanFilesResult);
}

cl.outro('All checks complete!');
}