Skip to content
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"format": "prettier --write src",
"test": "FORCE_COLOR=1 vitest run --coverage",
"prepublishOnly": "npm run test",
"generate-fixable-replacements": "tsx src/scripts/generate-fixable-replacements.ts"
"generate-fixable-replacements": "node scripts/generate-fixable-replacements.ts"
},
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {join, dirname} from 'node:path';
import {fileURLToPath} from 'node:url';
import {all} from 'module-replacements';
import {codemods} from 'module-replacements-codemods';
import {fixableReplacements} from '../commands/fixable-replacements.js';
import {fixableReplacements} from '../lib/commands/fixable-replacements.js';

const __dirname = dirname(fileURLToPath(import.meta.url));

Expand All @@ -23,9 +23,9 @@ async function generateFixableReplacements() {
const to = existing?.to ?? 'TODO';

newCode += ` {\n`;
newCode += ` from: "${replacement.moduleName}",\n`;
newCode += ` to: "${to}",\n`;
newCode += ` factory: codemods["${replacement.moduleName}"]\n`;
newCode += ` from: '${replacement.moduleName}',\n`;
newCode += ` to: '${to}',\n`;
newCode += ` factory: codemods['${replacement.moduleName}']\n`;
newCode += ` },\n`;
count++;
}
Expand All @@ -36,12 +36,14 @@ async function generateFixableReplacements() {
const outputPath = join(
__dirname,
'..',
'commands',
'lib/commands',
'fixable-replacements.ts'
);
await writeFile(outputPath, newCode);

console.log(`✅ Generated fixable-replacements.ts with ${count} replacements`);

console.log(
`✅ Generated fixable-replacements.ts with ${count} replacements`
);
console.log(`📁 Output: ${outputPath}`);
}

Expand Down
16 changes: 4 additions & 12 deletions src/cli.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {createRequire} from 'node:module';
import {cli, define, lazy, type LazyCommand} from 'gunshi';
import * as prompts from '@clack/prompts';
import c from 'picocolors';
import {meta as analyzeMeta} from './commands/analyze.meta.js';
import {meta as migrateMeta} from './commands/migrate.meta.js';
import {pino} from 'pino';
import {renderUsage} from 'gunshi/renderer';

const version = createRequire(import.meta.url)('../package.json').version;

Expand All @@ -22,17 +22,9 @@ export const logger = pino({

const defaultCommand = define({
args: {},
async run() {
prompts.intro('Please choose a command to run:');
prompts.log.message(
[
`--analyze (${c.dim('analyzes the package for warnings/errors')})`,
`--migrate (${c.dim('migrates packages to their suggested alternatives')})`
].join('\n')
);
prompts.outro(
'Use `<command> --help` to read more about a specific command'
);
async run(ctx) {
const usage = await renderUsage(ctx);
console.log(usage);
}
});

Expand Down
Loading