Skip to content

Commit

Permalink
Allowed passing -ns flag to migrate to nested component structure
Browse files Browse the repository at this point in the history
  • Loading branch information
ijlee2 committed Apr 26, 2020
1 parent f534b56 commit e92bb50
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 2 deletions.
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,43 @@ cd your/project/path
npx github:ember-codemods/ember-component-template-colocation-migrator
```

By default, the migrator changes the **classic** component structure to the **flat** component structure.

```
your-project-name
├── app
│ └── components
│ ├── foo-bar
│ │ ├── baz.hbs
│ │ └── baz.js
│ ├── foo-bar.hbs
│ └── foo-bar.js
│ ...
```

If you want to change from **classic** to **nested**, you can add the `-ns` flag:

```sh
cd your/project/path
npx github:ember-codemods/ember-component-template-colocation-migrator -ns
```

The nested component structure looks like:

```
your-project-name
├── app
│ └── components
│ └── foo-bar
│ ├── baz
│ │ ├── index.hbs
│ │ └── index.js
│ ├── index.hbs
│ └── index.js
│ ...
```


### Running Tests

* `npm run test`
* `npm run test`
13 changes: 12 additions & 1 deletion bin/ember-component-template-colocation-migrator
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,19 @@ let options = {
let parsed = nopt(options);
let projectRoot = parsed['project-root'] || process.cwd();

const args = process.argv.slice(2);

// Allow passing the flag, -fs (flat) or -ns (nested), to specify component structure
let newComponentStructure = 'flat';

if (args.includes('-fs')) {
newComponentStructure = 'flat';

} else if (args.includes('-ns')) {
newComponentStructure = 'nested';

}

let migrator = new Migrator({
projectRoot,
newComponentStructure
Expand All @@ -25,4 +36,4 @@ migrator.execute().then(function() {
console.log('Codemod finished successfully!');
}).catch(function(error) {
console.error(error.stack);
});
});

0 comments on commit e92bb50

Please sign in to comment.