From e92bb50578809a402180fab9ad701cd7f6225d08 Mon Sep 17 00:00:00 2001 From: ijlee2 Date: Sun, 26 Apr 2020 18:45:00 -0500 Subject: [PATCH] Allowed passing -ns flag to migrate to nested component structure --- README.md | 39 ++++++++++++++++++- ...ber-component-template-colocation-migrator | 13 ++++++- 2 files changed, 50 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 23bfe78..1648454 100644 --- a/README.md +++ b/README.md @@ -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` \ No newline at end of file diff --git a/bin/ember-component-template-colocation-migrator b/bin/ember-component-template-colocation-migrator index 84cece2..34fa1fd 100755 --- a/bin/ember-component-template-colocation-migrator +++ b/bin/ember-component-template-colocation-migrator @@ -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 @@ -25,4 +36,4 @@ migrator.execute().then(function() { console.log('Codemod finished successfully!'); }).catch(function(error) { console.error(error.stack); -}); +}); \ No newline at end of file