add shorter aliases for use-component and infer-components commands, fixes #131

- use-component -> require
- infer-components -> require-all
This commit is contained in:
Artur Girenko 2017-09-28 23:22:52 +02:00
parent db198010c9
commit ac78028655
2 changed files with 34 additions and 9 deletions

View File

@ -245,13 +245,13 @@ This feature is available since re-natal@0.7.0
#### Manually registering dependencies with use-component command
You can register a single dependency manually by running `use-component` command:
You can register a single dependency manually by running `require` command:
```
$ re-natal use-component some-library/Component
$ re-natal require some-library/Component
```
or for a platform-specific component use the optional platform parameter:
```
$ re-natal use-component some-library/ComponentIOS ios
$ re-natal require some-library/ComponentIOS ios
```
Then, regenerate index.*.js files:
```
@ -262,6 +262,14 @@ Lastly, you will have to restart the packager and reload your app.
NOTE: If you mistyped something, or no longer use the component and would like to remove it,
manually open `.re-natal` and fix it there (it's just a list of names in JSON format, so the process should be straight forward).
#### Scanning for dependencies with require-all command
If you have used new modules in your code you can run:
```
$ re-natal require-all
```
This will scan your code for `(js/require ...)` calls and add new required modules automatically.
After this, you still need to run `use-figwheel` command to regenerate index.*.js files.
## REPL
You have to reload your app, and should see the REPL coming up with the prompt.

View File

@ -846,10 +846,17 @@ useComponent = (name, platform) ->
logErr message
logModuleDifferences = (platform, existingModules, newModules) ->
modules = new Set(existingModules)
diff = new Set(newModules.filter((m) -> !modules.has(m)))
if(diff.size isnt 0)
log "new #{platform} component import found #{Array.from(diff)}"
existingModuleSet = new Set(existingModules)
newModuleSet = new Set(newModules)
addedModules = new Set(newModules.filter((m) -> !existingModuleSet.has(m)))
removedModules = new Set(existingModules.filter((m) -> !newModuleSet.has(m)))
if(removedModules.size isnt 0)
log "removed #{platform} modules #{Array.from(removedModules)}"
if(addedModules.size isnt 0)
log "new #{platform} modules found #{Array.from(addedModules)}"
inferComponents = () ->
requiresByPlatform = buildRequireByPlatformMap()
@ -937,12 +944,22 @@ cli.command 'use-ios-device <type>'
configureDevHostForIosDevice type
cli.command 'use-component <name> [<platform>]'
.description 'configures a custom component to work with figwheel. name is the value you pass to (js/require) function.'
.description 'configures a custom component to work with figwheel. Same as \'require\' command.'
.action (name, platform) ->
useComponent(name, platform)
cli.command 'require <name> [<platform>]'
.description 'configures an external module to work with figwheel. name is the value you pass to (js/require) function.'
.action (name, platform) ->
useComponent(name, platform)
cli.command 'infer-components'
.description 'parses all cljs files in this project, extracts all (js/require) components calls and uses them to populate the re-natal file'
.description 'parses all cljs files in this project, extracts all (js/require) calls and adds required modules to .re-natal file'
.action () ->
inferComponents()
cli.command 'require-all'
.description 'parses all cljs files in this project, extracts all (js/require) calls and adds required modules to .re-natal file'
.action () ->
inferComponents()