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

feat: migrate allow passing path or component #273

Closed
Closed
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
5 changes: 5 additions & 0 deletions .changeset/giant-sloths-exist.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'sv': patch
---

feat: `migrate` allow passing path or component
8 changes: 6 additions & 2 deletions packages/cli/commands/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { getUserAgent } from '../common.ts';
export const migrate = new Command('migrate')
.description('a CLI for migrating Svelte(Kit) codebases')
.argument('<migration>', 'migration to run')
.argument('[path]', 'component path or directory to migrate')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems confusing to me because I doubt that all the migrations will accept a path. I think the args should be dependent on the migration. For now I think I'd just pass the args through without trying to list them here

maybe after #274 is merged we can use the same CLI parsing library for both and share the args across packages or something

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's indeed a valid argument. Now that the migrate code is here, we can think about this directly while implementing #278

Closing here.

.option('-C, --cwd <path>', 'path to working directory', process.cwd())
.configureHelp({
formatHelp() {
Expand All @@ -15,8 +16,11 @@ export const migrate = new Command('migrate')
return '';
}
})
.action((migration, options) => {
runMigrate(options.cwd, [migration]);
.action((migration, path, options) => {
const args = [migration];
if (path) args.push(path);

runMigrate(options.cwd, args);
});

function runMigrate(cwd: string, args: string[]) {
Expand Down