-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add visual info when using cleanup script (#3)
- Loading branch information
1 parent
264bc1a
commit 91ddc22
Showing
3 changed files
with
186 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,71 @@ | ||
const path = require('path'); | ||
const replace = require('replace-in-file').sync; | ||
const remove = require('del').sync; | ||
const replace = require('replace-in-file'); | ||
const remove = require('del'); | ||
const Listr = require('listr'); | ||
|
||
const srcPath = path.join(__dirname, '..', 'src'); | ||
const testPath = path.join(__dirname, '..', 'test'); | ||
const srcAndTestPath = `{${testPath},${srcPath}}`; | ||
const routerPath = path.join(srcPath, 'interfaces', 'http', 'router.js'); | ||
const containerPath = path.join(srcPath, 'container.js'); | ||
|
||
// Remove the references of the files that will be removed | ||
|
||
replace({ | ||
files: routerPath, | ||
from: /\s*apiRouter.*UsersController'\)\);/, | ||
to: '' | ||
}); | ||
|
||
replace({ | ||
files: containerPath, | ||
from: [ | ||
/\s*const.*app\/user'\);/, | ||
/\s*const.*UsersRepository'\);/, | ||
/\, User: UserModel/, | ||
/\s*usersRepository.*\}\]/, | ||
/\,\s*UserModel/, | ||
/createUser.*\n/, | ||
/\s*getAllUsers.*GetAllUsers/, | ||
], | ||
to: '' | ||
}); | ||
|
||
// Remove example app files | ||
|
||
remove([ | ||
path.join(srcAndTestPath, 'app', 'user', '**'), | ||
path.join(srcAndTestPath, 'domain', 'user', '**'), | ||
path.join(srcAndTestPath, 'infra', 'user', '**'), | ||
path.join(srcPath, 'infra', 'database', 'migrate', '*.js'), | ||
path.join(srcPath, 'infra', 'database', 'seeds', '*.js'), | ||
path.join(srcPath, 'infra', 'database', 'models', 'User.js'), | ||
path.join(srcPath, 'interfaces', 'http', 'user', '**'), | ||
path.join(testPath, 'api', 'users', '**'), | ||
path.join(testPath, 'support', 'factories', '*.js') | ||
const tasks = new Listr([ | ||
{ | ||
title: 'Remove UsersController routes', | ||
task() { | ||
return replace({ | ||
files: routerPath, | ||
from: /\s*apiRouter.*UsersController'\)\);/, | ||
to: '' | ||
}); | ||
} | ||
}, | ||
{ | ||
title: 'Remove example files from DI container', | ||
task() { | ||
return replace({ | ||
files: containerPath, | ||
from: [ | ||
/\s*const.*app\/user'\);/, | ||
/\s*const.*UsersRepository'\);/, | ||
/\, User: UserModel/, | ||
/\s*usersRepository.*\}\]/, | ||
/\,\s*UserModel/, | ||
/createUser.*\n/, | ||
/\s*getAllUsers.*GetAllUsers/, | ||
], | ||
to: '' | ||
}); | ||
} | ||
}, | ||
{ | ||
title: 'Delete example files and tests', | ||
task() { | ||
return remove([ | ||
path.join(srcAndTestPath, 'app', 'user', '**'), | ||
path.join(srcAndTestPath, 'domain', 'user', '**'), | ||
path.join(srcAndTestPath, 'infra', 'user', '**'), | ||
path.join(srcPath, 'infra', 'database', 'migrate', '*.js'), | ||
path.join(srcPath, 'infra', 'database', 'seeds', '*.js'), | ||
path.join(srcPath, 'infra', 'database', 'models', 'User.js'), | ||
path.join(srcPath, 'interfaces', 'http', 'user', '**'), | ||
path.join(testPath, 'api', 'users', '**'), | ||
path.join(testPath, 'support', 'factories', '*.js') | ||
]); | ||
} | ||
}, | ||
{ | ||
title: 'Remove cleanup script from package.json', | ||
task() { | ||
return replace({ | ||
files: path.join(__dirname, '..', 'package.json'), | ||
from: /\,\s*\"cleanup.*cleanup\.js\"/, | ||
to: '' | ||
}); | ||
} | ||
} | ||
]); | ||
|
||
// Remove `cleanup` command from package.json | ||
|
||
replace({ | ||
files: path.join(__dirname, '..', 'package.json'), | ||
from: /\,\s*\"cleanup.*cleanup\.js\"/, | ||
to: '' | ||
tasks.run().catch((err) => { | ||
console.error(err); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,7 +64,7 @@ [email protected], amp@~0.3.1: | |
version "0.3.1" | ||
resolved "https://registry.yarnpkg.com/amp/-/amp-0.3.1.tgz#6adf8d58a74f361e82c1fa8d389c079e139fc47d" | ||
|
||
ansi-escapes@^1.1.0: | ||
ansi-escapes@^1.0.0, ansi-escapes@^1.1.0: | ||
version "1.4.0" | ||
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-1.4.0.tgz#d3a8a83b319aa67793662b13e761c7911422306e" | ||
|
||
|
@@ -436,18 +436,29 @@ cli-color@~0.3.2: | |
memoizee "~0.3.8" | ||
timers-ext "0.1" | ||
|
||
cli-cursor@^1.0.1: | ||
cli-cursor@^1.0.1, cli-cursor@^1.0.2: | ||
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-1.0.2.tgz#64da3f7d56a54412e59794bd62dc35295e8f2987" | ||
dependencies: | ||
restore-cursor "^1.0.1" | ||
|
||
cli-spinners@^0.1.2: | ||
version "0.1.2" | ||
resolved "https://registry.yarnpkg.com/cli-spinners/-/cli-spinners-0.1.2.tgz#bb764d88e185fb9e1e6a2a1f19772318f605e31c" | ||
|
||
[email protected]: | ||
version "0.3.1" | ||
resolved "https://registry.yarnpkg.com/cli-table/-/cli-table-0.3.1.tgz#f53b05266a8b1a0b934b3d0821e6e2dc5914ae23" | ||
dependencies: | ||
colors "1.0.3" | ||
|
||
cli-truncate@^0.2.1: | ||
version "0.2.1" | ||
resolved "https://registry.yarnpkg.com/cli-truncate/-/cli-truncate-0.2.1.tgz#9f15cfbb0705005369216c626ac7d05ab90dd574" | ||
dependencies: | ||
slice-ansi "0.0.4" | ||
string-width "^1.0.1" | ||
|
||
cli-width@^2.0.0: | ||
version "2.1.0" | ||
resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.1.0.tgz#b234ca209b29ef66fc518d9b98d5847b00edf00a" | ||
|
@@ -653,6 +664,10 @@ dashdash@^1.12.0: | |
dependencies: | ||
assert-plus "^1.0.0" | ||
|
||
date-fns@^1.27.2: | ||
version "1.28.2" | ||
resolved "https://registry.yarnpkg.com/date-fns/-/date-fns-1.28.2.tgz#19e4192d68875c0bf7c9537e3f296a8ec64853ef" | ||
|
||
date-format@^0.0.0: | ||
version "0.0.0" | ||
resolved "https://registry.yarnpkg.com/date-format/-/date-format-0.0.0.tgz#09206863ab070eb459acea5542cbd856b11966b3" | ||
|
@@ -806,6 +821,10 @@ [email protected]: | |
version "1.1.1" | ||
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" | ||
|
||
elegant-spinner@^1.0.1: | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/elegant-spinner/-/elegant-spinner-1.0.1.tgz#db043521c95d7e303fd8f345bedc3349cfb0729e" | ||
|
||
emitter-listener@^1.0.1: | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/emitter-listener/-/emitter-listener-1.0.1.tgz#b2499ea6e58230a52c268d5df261eecd9f10fe97" | ||
|
@@ -1196,7 +1215,7 @@ [email protected]: | |
version "1.0.8" | ||
resolved "https://registry.yarnpkg.com/fclone/-/fclone-1.0.8.tgz#a0d4a73d983249978c0e0671a161520b996467eb" | ||
|
||
figures@^1.3.5: | ||
figures@^1.3.5, figures@^1.7.0: | ||
version "1.7.0" | ||
resolved "https://registry.yarnpkg.com/figures/-/figures-1.7.0.tgz#cbe1e3affcf1cd44b80cadfed28dc793a9701d2e" | ||
dependencies: | ||
|
@@ -1746,6 +1765,16 @@ imurmurhash@^0.1.4: | |
version "0.1.4" | ||
resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" | ||
|
||
indent-string@^2.1.0: | ||
version "2.1.0" | ||
resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-2.1.0.tgz#8e2d48348742121b4a8218b7a137e9a52049dc80" | ||
dependencies: | ||
repeating "^2.0.0" | ||
|
||
indent-string@^3.0.0: | ||
version "3.1.0" | ||
resolved "https://registry.yarnpkg.com/indent-string/-/indent-string-3.1.0.tgz#08ff4334603388399b329e6b9538dc7a3cf5de7d" | ||
|
||
[email protected]: | ||
version "0.0.1" | ||
resolved "https://registry.yarnpkg.com/indexof/-/indexof-0.0.1.tgz#82dc336d232b9062179d05ab3293a66059fd435d" | ||
|
@@ -1927,6 +1956,10 @@ is-primitive@^2.0.0: | |
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575" | ||
|
||
is-promise@^2.1.0: | ||
version "2.1.0" | ||
resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa" | ||
|
||
is-property@^1.0.0: | ||
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84" | ||
|
@@ -1947,7 +1980,7 @@ is-resolvable@^1.0.0: | |
dependencies: | ||
tryit "^1.0.1" | ||
|
||
is-stream@^1.0.0: | ||
is-stream@^1.0.0, is-stream@^1.1.0: | ||
version "1.1.0" | ||
resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" | ||
|
||
|
@@ -2162,6 +2195,52 @@ liftoff@^2.1.0: | |
rechoir "^0.6.2" | ||
resolve "^1.1.7" | ||
|
||
listr-silent-renderer@^1.1.1: | ||
version "1.1.1" | ||
resolved "https://registry.yarnpkg.com/listr-silent-renderer/-/listr-silent-renderer-1.1.1.tgz#924b5a3757153770bf1a8e3fbf74b8bbf3f9242e" | ||
|
||
listr-update-renderer@^0.2.0: | ||
version "0.2.0" | ||
resolved "https://registry.yarnpkg.com/listr-update-renderer/-/listr-update-renderer-0.2.0.tgz#ca80e1779b4e70266807e8eed1ad6abe398550f9" | ||
dependencies: | ||
chalk "^1.1.3" | ||
cli-truncate "^0.2.1" | ||
elegant-spinner "^1.0.1" | ||
figures "^1.7.0" | ||
indent-string "^3.0.0" | ||
log-symbols "^1.0.2" | ||
log-update "^1.0.2" | ||
strip-ansi "^3.0.1" | ||
|
||
listr-verbose-renderer@^0.4.0: | ||
version "0.4.0" | ||
resolved "https://registry.yarnpkg.com/listr-verbose-renderer/-/listr-verbose-renderer-0.4.0.tgz#44dc01bb0c34a03c572154d4d08cde9b1dc5620f" | ||
dependencies: | ||
chalk "^1.1.3" | ||
cli-cursor "^1.0.2" | ||
date-fns "^1.27.2" | ||
figures "^1.7.0" | ||
|
||
listr@^0.11.0: | ||
version "0.11.0" | ||
resolved "https://registry.yarnpkg.com/listr/-/listr-0.11.0.tgz#5e778bc23806ac3ab984ed75564458151f39b03e" | ||
dependencies: | ||
chalk "^1.1.3" | ||
cli-truncate "^0.2.1" | ||
figures "^1.7.0" | ||
indent-string "^2.1.0" | ||
is-promise "^2.1.0" | ||
is-stream "^1.1.0" | ||
listr-silent-renderer "^1.1.1" | ||
listr-update-renderer "^0.2.0" | ||
listr-verbose-renderer "^0.4.0" | ||
log-symbols "^1.0.2" | ||
log-update "^1.0.2" | ||
ora "^0.2.3" | ||
rxjs "^5.0.0-beta.11" | ||
stream-to-observable "^0.1.0" | ||
strip-ansi "^3.0.1" | ||
|
||
load-json-file@^1.0.0: | ||
version "1.1.0" | ||
resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-1.1.0.tgz#956905708d58b4bab4c2261b04f59f31c99374c0" | ||
|
@@ -2345,6 +2424,19 @@ lodash@~1.0.1: | |
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-1.0.2.tgz#8f57560c83b59fc270bd3d561b690043430e2551" | ||
|
||
log-symbols@^1.0.2: | ||
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-1.0.2.tgz#376ff7b58ea3086a0f09facc74617eca501e1a18" | ||
dependencies: | ||
chalk "^1.0.0" | ||
|
||
log-update@^1.0.2: | ||
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/log-update/-/log-update-1.0.2.tgz#19929f64c4093d2d2e7075a1dad8af59c296b8d1" | ||
dependencies: | ||
ansi-escapes "^1.0.0" | ||
cli-cursor "^1.0.2" | ||
|
||
log4js@^1.1.1: | ||
version "1.1.1" | ||
resolved "https://registry.yarnpkg.com/log4js/-/log4js-1.1.1.tgz#c21d29c7604089e4f255833e7f94b3461de1ff43" | ||
|
@@ -2719,6 +2811,15 @@ options@>=0.0.5: | |
version "0.0.6" | ||
resolved "https://registry.yarnpkg.com/options/-/options-0.0.6.tgz#ec22d312806bb53e731773e7cdaefcf1c643128f" | ||
|
||
ora@^0.2.3: | ||
version "0.2.3" | ||
resolved "https://registry.yarnpkg.com/ora/-/ora-0.2.3.tgz#37527d220adcd53c39b73571d754156d5db657a4" | ||
dependencies: | ||
chalk "^1.1.1" | ||
cli-cursor "^1.0.2" | ||
cli-spinners "^0.1.2" | ||
object-assign "^4.0.1" | ||
|
||
orchestrator@^0.3.0: | ||
version "0.3.8" | ||
resolved "https://registry.yarnpkg.com/orchestrator/-/orchestrator-0.3.8.tgz#14e7e9e2764f7315fbac184e506c7aa6df94ad7e" | ||
|
@@ -3217,6 +3318,12 @@ repeating@^1.1.2: | |
dependencies: | ||
is-finite "^1.0.0" | ||
|
||
repeating@^2.0.0: | ||
version "2.0.1" | ||
resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" | ||
dependencies: | ||
is-finite "^1.0.0" | ||
|
||
[email protected]: | ||
version "0.0.1" | ||
resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-0.0.1.tgz#29bbd92078a739f0bcce2b4ee41e837953522924" | ||
|
@@ -3328,6 +3435,12 @@ rx-lite@^3.1.2: | |
version "3.1.2" | ||
resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-3.1.2.tgz#19ce502ca572665f3b647b10939f97fd1615f102" | ||
|
||
rxjs@^5.0.0-beta.11: | ||
version "5.3.0" | ||
resolved "https://registry.yarnpkg.com/rxjs/-/rxjs-5.3.0.tgz#d88ccbdd46af290cbdb97d5d8055e52453fabe2d" | ||
dependencies: | ||
symbol-observable "^1.0.1" | ||
|
||
semver-diff@^2.0.0: | ||
version "2.1.0" | ||
resolved "https://registry.yarnpkg.com/semver-diff/-/semver-diff-2.1.0.tgz#4bbb8437c8d37e4b0cf1a68fd726ec6d645d6d36" | ||
|
@@ -3604,6 +3717,10 @@ stream-shift@^1.0.0: | |
version "1.0.0" | ||
resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.0.tgz#d5c752825e5367e786f78e18e445ea223a155952" | ||
|
||
stream-to-observable@^0.1.0: | ||
version "0.1.0" | ||
resolved "https://registry.yarnpkg.com/stream-to-observable/-/stream-to-observable-0.1.0.tgz#45bf1d9f2d7dc09bed81f1c307c430e68b84cffe" | ||
|
||
streamroller@^0.4.0: | ||
version "0.4.0" | ||
resolved "https://registry.yarnpkg.com/streamroller/-/streamroller-0.4.0.tgz#a273f1f91994549a2ddd112ccaa2d1dd23cb758c" | ||
|
@@ -3715,6 +3832,10 @@ supports-color@^2.0.0: | |
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" | ||
|
||
symbol-observable@^1.0.1: | ||
version "1.0.4" | ||
resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.4.tgz#29bf615d4aa7121bdd898b22d4b3f9bc4e2aa03d" | ||
|
||
table@^3.7.8: | ||
version "3.8.3" | ||
resolved "https://registry.yarnpkg.com/table/-/table-3.8.3.tgz#2bbc542f0fda9861a755d3947fefd8b3f513855f" | ||
|