Skip to content

Commit 4c2ffb6

Browse files
committed
Installed yargs to parse command line options
1 parent e92bb50 commit 4c2ffb6

3 files changed

Lines changed: 112 additions & 4 deletions

File tree

bin/ember-component-template-colocation-migrator

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,18 @@ let options = {
1414
let parsed = nopt(options);
1515
let projectRoot = parsed['project-root'] || process.cwd();
1616

17-
const args = process.argv.slice(2);
17+
const { argv } = require('yargs');
1818

1919
// Allow passing the flag, -fs (flat) or -ns (nested), to specify component structure
20+
const changeToFlatStructure = argv.f && argv.s;
21+
const changeToNestedStructure = argv.n && argv.s;
22+
2023
let newComponentStructure = 'flat';
2124

22-
if (args.includes('-fs')) {
25+
if (changeToFlatStructure) {
2326
newComponentStructure = 'flat';
2427

25-
} else if (args.includes('-ns')) {
28+
} else if (changeToNestedStructure) {
2629
newComponentStructure = 'nested';
2730

2831
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
"fs-extra": "^7.0.1",
2929
"glob": "^7.1.4",
3030
"nopt": "^4.0.1",
31-
"remove-empty-directories": "^0.0.1"
31+
"remove-empty-directories": "^0.0.1",
32+
"yargs": "^15.3.1"
3233
},
3334
"repository": {
3435
"type": "git",

yarn.lock

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,14 @@ ansi-styles@^3.2.1:
330330
dependencies:
331331
color-convert "^1.9.0"
332332

333+
ansi-styles@^4.0.0:
334+
version "4.2.1"
335+
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.2.1.tgz#90ae75c424d008d2624c5bf29ead3177ebfcf359"
336+
integrity sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==
337+
dependencies:
338+
"@types/color-name" "^1.1.1"
339+
color-convert "^2.0.1"
340+
333341
ansi-styles@^4.1.0:
334342
version "4.2.0"
335343
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.2.0.tgz#5681f0dcf7ae5880a7841d8831c4724ed9cc0172"
@@ -463,6 +471,15 @@ cliui@^4.0.0:
463471
strip-ansi "^4.0.0"
464472
wrap-ansi "^2.0.0"
465473

474+
cliui@^6.0.0:
475+
version "6.0.0"
476+
resolved "https://registry.yarnpkg.com/cliui/-/cliui-6.0.0.tgz#511d702c0c4e41ca156d7d0e96021f23e13225b1"
477+
integrity sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==
478+
dependencies:
479+
string-width "^4.2.0"
480+
strip-ansi "^6.0.0"
481+
wrap-ansi "^6.2.0"
482+
466483
clone@^1.0.2:
467484
version "1.0.4"
468485
resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e"
@@ -636,6 +653,11 @@ emoji-regex@^7.0.1:
636653
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156"
637654
integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==
638655

656+
emoji-regex@^8.0.0:
657+
version "8.0.0"
658+
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
659+
integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==
660+
639661
empower-core@^1.2.0:
640662
version "1.2.0"
641663
resolved "https://registry.yarnpkg.com/empower-core/-/empower-core-1.2.0.tgz#ce3fb2484d5187fa29c23fba8344b0b2fdf5601c"
@@ -769,6 +791,14 @@ [email protected], find-up@^3.0.0:
769791
dependencies:
770792
locate-path "^3.0.0"
771793

794+
find-up@^4.1.0:
795+
version "4.1.0"
796+
resolved "https://registry.yarnpkg.com/find-up/-/find-up-4.1.0.tgz#97afe7d6cdc0bc5928584b7c8d7b16e8a9aa5d19"
797+
integrity sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==
798+
dependencies:
799+
locate-path "^5.0.0"
800+
path-exists "^4.0.0"
801+
772802
fixturify@^1.0.1:
773803
version "1.2.0"
774804
resolved "https://registry.yarnpkg.com/fixturify/-/fixturify-1.2.0.tgz#abe8c52dd27dbbfdb874a02893781c93425663ea"
@@ -998,6 +1028,11 @@ is-fullwidth-code-point@^2.0.0:
9981028
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f"
9991029
integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=
10001030

1031+
is-fullwidth-code-point@^3.0.0:
1032+
version "3.0.0"
1033+
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d"
1034+
integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==
1035+
10011036
is-glob@^4.0.1:
10021037
version "4.0.1"
10031038
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc"
@@ -1095,6 +1130,13 @@ locate-path@^3.0.0:
10951130
p-locate "^3.0.0"
10961131
path-exists "^3.0.0"
10971132

1133+
locate-path@^5.0.0:
1134+
version "5.0.0"
1135+
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0"
1136+
integrity sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==
1137+
dependencies:
1138+
p-locate "^4.1.0"
1139+
10981140
lodash@^4.17.11, lodash@^4.17.13, lodash@^4.17.14:
10991141
version "4.17.15"
11001142
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548"
@@ -1380,13 +1422,27 @@ p-limit@^2.0.0:
13801422
dependencies:
13811423
p-try "^2.0.0"
13821424

1425+
p-limit@^2.2.0:
1426+
version "2.3.0"
1427+
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1"
1428+
integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==
1429+
dependencies:
1430+
p-try "^2.0.0"
1431+
13831432
p-locate@^3.0.0:
13841433
version "3.0.0"
13851434
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4"
13861435
integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==
13871436
dependencies:
13881437
p-limit "^2.0.0"
13891438

1439+
p-locate@^4.1.0:
1440+
version "4.1.0"
1441+
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-4.1.0.tgz#a3428bb7088b3a60292f66919278b7c297ad4f07"
1442+
integrity sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==
1443+
dependencies:
1444+
p-limit "^2.2.0"
1445+
13901446
p-try@^2.0.0:
13911447
version "2.2.0"
13921448
resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6"
@@ -1397,6 +1453,11 @@ path-exists@^3.0.0:
13971453
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515"
13981454
integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=
13991455

1456+
path-exists@^4.0.0:
1457+
version "4.0.0"
1458+
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3"
1459+
integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==
1460+
14001461
path-is-absolute@^1.0.0:
14011462
version "1.0.1"
14021463
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
@@ -1672,6 +1733,15 @@ string-width@^3.0.0:
16721733
is-fullwidth-code-point "^2.0.0"
16731734
strip-ansi "^5.1.0"
16741735

1736+
string-width@^4.1.0, string-width@^4.2.0:
1737+
version "4.2.0"
1738+
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.0.tgz#952182c46cc7b2c313d1596e623992bd163b72b5"
1739+
integrity sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==
1740+
dependencies:
1741+
emoji-regex "^8.0.0"
1742+
is-fullwidth-code-point "^3.0.0"
1743+
strip-ansi "^6.0.0"
1744+
16751745
stringifier@^1.3.0:
16761746
version "1.4.0"
16771747
resolved "https://registry.yarnpkg.com/stringifier/-/stringifier-1.4.0.tgz#d704581567f4526265d00ed8ecb354a02c3fec28"
@@ -1845,6 +1915,15 @@ wrap-ansi@^2.0.0:
18451915
string-width "^1.0.1"
18461916
strip-ansi "^3.0.1"
18471917

1918+
wrap-ansi@^6.2.0:
1919+
version "6.2.0"
1920+
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-6.2.0.tgz#e9393ba07102e6c91a3b221478f0257cd2856e53"
1921+
integrity sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==
1922+
dependencies:
1923+
ansi-styles "^4.0.0"
1924+
string-width "^4.1.0"
1925+
strip-ansi "^6.0.0"
1926+
18481927
wrappy@1:
18491928
version "1.0.2"
18501929
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
@@ -1884,6 +1963,14 @@ yargs-parser@^13.0.0:
18841963
camelcase "^5.0.0"
18851964
decamelize "^1.2.0"
18861965

1966+
yargs-parser@^18.1.1:
1967+
version "18.1.3"
1968+
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-18.1.3.tgz#be68c4975c6b2abf469236b0c870362fab09a7b0"
1969+
integrity sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==
1970+
dependencies:
1971+
camelcase "^5.0.0"
1972+
decamelize "^1.2.0"
1973+
18871974
18881975
version "1.5.0"
18891976
resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-1.5.0.tgz#f2bb2a7e83cbc87bb95c8e572828a06c9add6e0d"
@@ -1927,3 +2014,20 @@ yargs@^12.0.5:
19272014
which-module "^2.0.0"
19282015
y18n "^3.2.1 || ^4.0.0"
19292016
yargs-parser "^11.1.1"
2017+
2018+
yargs@^15.3.1:
2019+
version "15.3.1"
2020+
resolved "https://registry.yarnpkg.com/yargs/-/yargs-15.3.1.tgz#9505b472763963e54afe60148ad27a330818e98b"
2021+
integrity sha512-92O1HWEjw27sBfgmXiixJWT5hRBp2eobqXicLtPBIDBhYB+1HpwZlXmbW2luivBJHBzki+7VyCLRtAkScbTBQA==
2022+
dependencies:
2023+
cliui "^6.0.0"
2024+
decamelize "^1.2.0"
2025+
find-up "^4.1.0"
2026+
get-caller-file "^2.0.1"
2027+
require-directory "^2.1.1"
2028+
require-main-filename "^2.0.0"
2029+
set-blocking "^2.0.0"
2030+
string-width "^4.2.0"
2031+
which-module "^2.0.0"
2032+
y18n "^4.0.0"
2033+
yargs-parser "^18.1.1"

0 commit comments

Comments
 (0)