NativeScript / plugins

@nativescript plugins to help with your developments.
https://docs.nativescript.org/plugins/index.html
Apache License 2.0
190 stars 109 forks source link

What are the dependencies? #467

Closed Erudition closed 1 year ago

Erudition commented 1 year ago

I'm having a lot of trouble getting this project running. The Readme says to just run npm run setup but it seems to be wayyy more complicated than that.

  1. After searching this repo for some of the issues, someone casually mentioned that NS needs node 12-14 only. Needed to downgrade node, fine, so that's one dependency that should probably mentioned.
  2. The setup scrips also assume a yarn installation, even though it's not taken care of automatically in package.json or anything, so I figured out to install yarn.
  3. The npm run setup gives me Usage Error: Couldn't find a configuration settings named "ignore-engines", which I found was historically an option, so I guess there's also a dependency on a specific version of yarn. Skipping that option-setting part of the command worked for now, moving on...
  4. The npm start command runs nps, another dependency that isn't handled by the setup script or mentioned anywhere.
  5. Turns out nps isn't enough, you quickly run into errors if you don't also install other dependencies like nps-i, perhaps even nps-utils.
  6. Then I keep getting an error (from that nps-i command) that /nativescript-plugins/package-scripts.js is Module not found. Indeed, there is no package-scripts file there, so why was nps just run with that expectation, I don't know.
  7. Then I found the .npsrc file, which seems to point to an alternative path to the above file, which explains that, but nps doesn't seem to know about it, and info online about this file is scarce.
  8. Finally I found an npm package called nps-with-rc that seems to add this .npsrc file... another assumed dependency? Unfortunately, installing this package with npm i nps-with-rc did not help.

After a work day spent on this, I just can't get the tooling right to even run the very first command in the documentation. Is this all documented somewhere I just don't know about? Would love to contribute here, but I can't get set up for building...

NathanWalker commented 1 year ago

Hi @Erudition couple things:

  1. Node 18+ is recommended. We’ll add a note about this to readme - we generally would not note this as we tend to follow LTS which is 18 right now however you can even use 19.
  2. Most issues mentioned are likely related to 1.
  3. The one thing not mentioned in this particular readme is that this workspace has grown exponentially fast. Given that, it’s recommended to use “focus modes” when contributing here (npm start > focus.{something}) - that would isolate the workspace to just one plugin at a time to focus on it.
    • Generally we try to keep "UI" plugins away from "SDK" related plugins since UI plugins often bring in aspects which may need more resource setup. For example, since the swift-ui plugin is currently managed here, we have testing code for it here: https://github.com/NativeScript/plugins/blob/main/tools/assets/App_Resources/iOS/src/BasicViewProvider.swift ... however when focusing on any other plugins, you would need to rename those .swift > .off so they aren't included in the demo to work with other plugins. Since the supporting .swift files include SwiftUIProvider which comes from only the swift-ui plugin.
  4. To help in future we will likely split some of these plugins out across some other workspaces to pair it down.
NathanWalker commented 1 year ago

@Erudition added these notes here: https://github.com/NativeScript/plugins/blob/main/README.md#prerequisites Thank you for mentioning ❤️

Erudition commented 1 year ago

Thanks so much for the swift response! I think the bullets I mentioned aren't fully covered, though. I see this added to the readme:

Node 18+ is recommended yarn is recommended

That said, I hacked at it some more, and learned that I had to not only install yarn and nps, but do so after the npm run setup script (which deletes node-modules) so that yarn and nps could be reached (as again, they're not in package.json and don't come with npm install, nor nps with yarn install) and that yarn install does a whole bunch of stuff but in my case didn't actually recreate the node-modules folder - I managed to fix that by running npm install first, then yarn install. Now, suddenly, nps is finding the relocated package-scripts.json. Thanks!

I'm almost ready to push my contributions to local-notifications, but alas the nps project-specific "build" script (nor build.all) seems to actually run the gradle build required for the plugin...

NathanWalker commented 1 year ago

@Erudition really excellent. Thank you for all this and the forthcoming contribution. On node version recommendation, it should also work with 16 as others have been productive using that as well. Long story short, we try to not get in the weeds on node versions due to fact that many actually work. Just generally we recommend LTS versions, but again even latest 19 works.

Regarding yarn, I just added that as well (yarn v1 is required) - good point 🤗 https://github.com/NativeScript/plugins#prerequisites

nps is not required to be handled directly at all. Assuming node/yarn are there, npm run setup should very much handle all that for you. nps is a transient dependency from @nstudio/nps-i which is relied upon by @nativescript/plugin-tools themselves: https://github.com/NativeScript/plugin-tools/blob/a6489fb49d2884178d88dab628ad3e59df34bfc8/packages/plugin-tools/package.json#L38 https://github.com/nstudio/nps-i/blob/809b0328bb03c0deb5a9b8042a659367a5ae8ea1/package.json#L18

Erudition commented 1 year ago

Huh, I don't know why npm install or yarn didn't automatically add it, then. Maybe transitive dev dependencies aren't added to node-modules/.bin (and thus PATH) by default the way root dependencies are.