unimonkiez / react-native-asset

Linking and unlinking of assets 🔥
302 stars 52 forks source link

Add an ability to run in incremental/decremental mode #10

Open iyegoroff opened 5 years ago

iyegoroff commented 5 years ago

When I run following commands:

$ react-native-asset ./node_modules/A/Resources
$ react-native-asset ./node_modules/B/Resources

it will end up linking only resources from module B and all resources from A will be unlinked.

So right now is impossible to use react-native-asset properly when developing third party react-native modules whose assets need to be linked. My suggestion is to add a key CLI parameter:

"rnpm": {
  "commands": {
    // relink only resources marked with "A" and mark these new resources with "A"
    "postlink": "npx react-native-asset ./node_modules/A/Resources -key A",
    // unlink only resources marked with "A"
    "postunlink": "npx react-native-asset -key A"
   }
}
unimonkiez commented 5 years ago

Why not simply use multiple folders per linking? Like so

react-native-asset -a ./node_modules/A/Resources ./node_modules/B/Resources
iyegoroff commented 5 years ago

Some context for this issue: https://github.com/iyegoroff/react-native-image-filter-kit/blob/3700e1e45217d169471ff412793f01d2d3d06db2/package.json#L98-L103 https://github.com/iyegoroff/react-native-image-filter-kit/blob/3700e1e45217d169471ff412793f01d2d3d06db2/examples/CustomNativeFilter/local_modules/react-native-image-filter-kit-haze-removal/package.json#L41-L46

I'm using react-native-asset with separate RN modules - not apps. Each module is responsible for its own resources, so when module "A" is being unlinked I need to remove only resources associated with "A" and left everything else untouched.

unimonkiez commented 5 years ago

Introducing keys sounds like an over-kill for your problem.. So when a developer links react-native-image-filter-kit, automatically you link for them the resources react-native-image-filter-kit needs?

If that's the case, adding non-required manifest-path option might be better!
Instead of using (or creating) their link-assets-manifest.json, create your own and call it image-filter-kit-link-assets-manifest.json.

the command line could look like this

npx react-native-asset ./node_modules/A/Resources --manifest-path ./A-link-assets-manifest.json