-
-
Notifications
You must be signed in to change notification settings - Fork 197
NativeScript CLI Use Modules from Node Dev Dependencies #415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Great idea, @PanayotCankov . However I see one problem - in case I'm working on MacOS and my app's package.json is something like:
It will be useless on Windows as tns-ios package cannot be |
@rosen-vladimirov - perhaps using optionalDependencies? @PanayotCankov - we discussed removing the .tnsproject file and subsuming it into package.json - see #362 |
By the look of it we also have the versions in the .tnsproject file.
And there allready plans to remove it, moving the settings in the package.json. So after some iterations on the problem we narrowed it down to two things. Do not Copy Binaries From The .NPM CacheWe do not want to copy binaries from the tns-ios locally in the platforms/ios folder. Instead we want the Xcode to use the binaries installed in the .npm cache. Which comes to a tiny integration between the search logic in the CLI and some Xcode params. We also have to make sure that iOS specific code that uses the tns-ios package should catch up the right version:
Set up Development EnvironmentWhere we can rapidly make changes to the nativescript-cli and tns-ios repo clones and have the changes propagated to our example projects. What I had in mind was using link. With it you can |
This seems a great idea to me and may not currently think of some downsides of this approach. |
I would argue against using the npm cache rather than a local copy of the binaries. The cache might change over time and is more or less global as I understand it, this might lead to issues if you're working on multiple projects, some of which are outdated. |
During the development of the perf. profiler for iOS we were not able, using the real life scenario for the CLI, to:
This is slowing us down. As an argument we now have the reason for the v1.2.1 hotfix: https://github.com/NativeScript/nativescript-cli/pull/689/files |
💯 |
Currently you can add nativescript CLI as dev-dependency in your project.
After that you can use
These files are already removed from CLI's master branch, so with later versions, there will be no need to delete them manually. Should we close this issue? |
I have a issue: When I do tns platform add android -> reponse java is not set to your path All android support and library installed, 22, 23, android sdk builds tools 22, 23 as well I'have installed node by nvm package manager , i have used node version 10.30, 10.35, 12.07 and reinstalled nativescript client in every version of node Following path config in .bashrc gradle pathGRADLE_HOME=/usr/share/gradle-2.3 android pathANDROID_HOME=/usr/share/android-sdk-linux java pathJAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-amd64 I paste the resultat from tns platform add android --log trace nelson@developpeur:~/github/node/tes1$ tns platform add android --log trace stderr: stderr: Exec node-gyp -v stderr: Exec android -h
Exec mono --version Exec git --version stderr: stdout:Gradle 2.3Build time: 2015-02-16 05:09:33 UTC Groovy: 2.3.9 stderr: Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar Exec javac -version TypeError: Cannot read property '1' of null |
Closing this as everything is addressed as outline by @rosen-vladimirov #415 (comment) |
NativeScript CLI Use Modules from Node Dev Dependencies
Why is this Needed
Currently using custom versions of the nativescript-cli modules is tedious. It requires, for example, referencing the "tns-ios" or "tns-android" packages through "--frameworkPath". The option requires different libraries based on the context it is used. Furthermore working on changes that impact multiple modules is tedious. And the following features will help keeping things up in source control.
Reference to Grunt
The following reorganization is inspired by Grunt. It is a build tool we are already using happily for most of the nativescript-cli modules.
The Grunt build system exposes a
grunt
command. Executing it will search up the directory tree for a:gruntfile.js
When the file is located, it will be executed in node. Any grunt plugins required will be searched as standard node modules. Which means the gruntfile.js goes with a package.json. The modules are listed as dev dependencies:
And the modules are usually installed locally using
npm install
. This leads to similar structure:Now then, a subset of the nativescript-cli is pretty much a build system so it can benefit from similar approach. Currently, on build, we do transform the source files by eliminating platform postfixes, moving them from the app folder to the respective platform folder. In future we will have to provide hooks for different compilers (TypeScript, CoffeeScript etc.)
NativeScript-CLI
So following the grunt approach we can make the
tns
cli search up for a well known file,.tnsproject
,tnsfile.js
etc. and execute there. However thetns
in that case should be a simple bootstrapper that would require its implementation using the node require logic. If the required libraries are not found locally, then tns should fallback to a globally installed one.This way the current usage should be preserved. However custom builds of the nativescript modules can be installed locally in node_modules.
It Will Help CLI Development
For example if you are working on the tns-ios package that also requires changes in the nativescript-cli module you should provide the following package.json.
And get the output of the nativescript and tns-ios builds onto the note_modules of the nativescript app and then the
tns
command should use the artifacts from the so locally installed custom builds.Better Versioning and Better Source Control for the Users
The resulting project will be source control friendly. Currently we have binaries with the nativescript runtimes for Android and iOS that either get extracted within the project or symlinks are created.
With the suggested implementation the projects generated in platforms should query their binaries with some help from npm but the binaries themselves won't stay in source control.
When a repo containing a nativescript app is cloned, the developers can
npm install
the exact runtimes the app was written with. There would be nice for versioning and the apps will have clear indication what versions they were built with.Furthermore it will ease us separate platform specific code. For example currently the code for
tns debug ios
,tns library add ios
etc serve only for the NativeScript for iOS. With the offered approach they will easily move into thetns-ios
package.Downsides
The project scaffolding will be somewhat trickier. The
tns create
will have to install some additional files and furthernpm install
may be necessary within the newly created app.The text was updated successfully, but these errors were encountered: