Skip to content

Commit e92bb50

Browse files
committed
Allowed passing -ns flag to migrate to nested component structure
1 parent f534b56 commit e92bb50

File tree

2 files changed

+50
-2
lines changed

2 files changed

+50
-2
lines changed

README.md

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,43 @@ cd your/project/path
1616
npx github:ember-codemods/ember-component-template-colocation-migrator
1717
```
1818

19+
By default, the migrator changes the **classic** component structure to the **flat** component structure.
20+
21+
```
22+
your-project-name
23+
├── app
24+
│ └── components
25+
│ ├── foo-bar
26+
│ │ ├── baz.hbs
27+
│ │ └── baz.js
28+
│ ├── foo-bar.hbs
29+
│ └── foo-bar.js
30+
│ ...
31+
```
32+
33+
If you want to change from **classic** to **nested**, you can add the `-ns` flag:
34+
35+
```sh
36+
cd your/project/path
37+
npx github:ember-codemods/ember-component-template-colocation-migrator -ns
38+
```
39+
40+
The nested component structure looks like:
41+
42+
```
43+
your-project-name
44+
├── app
45+
│ └── components
46+
│ └── foo-bar
47+
│ ├── baz
48+
│ │ ├── index.hbs
49+
│ │ └── index.js
50+
│ ├── index.hbs
51+
│ └── index.js
52+
│ ...
53+
```
54+
55+
1956
### Running Tests
2057

21-
* `npm run test`
58+
* `npm run test`

bin/ember-component-template-colocation-migrator

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,19 @@ let options = {
1414
let parsed = nopt(options);
1515
let projectRoot = parsed['project-root'] || process.cwd();
1616

17+
const args = process.argv.slice(2);
18+
19+
// Allow passing the flag, -fs (flat) or -ns (nested), to specify component structure
1720
let newComponentStructure = 'flat';
1821

22+
if (args.includes('-fs')) {
23+
newComponentStructure = 'flat';
24+
25+
} else if (args.includes('-ns')) {
26+
newComponentStructure = 'nested';
27+
28+
}
29+
1930
let migrator = new Migrator({
2031
projectRoot,
2132
newComponentStructure
@@ -25,4 +36,4 @@ migrator.execute().then(function() {
2536
console.log('Codemod finished successfully!');
2637
}).catch(function(error) {
2738
console.error(error.stack);
28-
});
39+
});

0 commit comments

Comments
 (0)