How to package npm and python dependencies in a deb? - node.js

I am developing small desktop application with web GUI (ReactJS) and python backend (Flask). I need to pack this application to deb-package for simple distribution.
For now scheme is pretty simple: I have standard setup.py file where python dependencies are described and debian/rules which uses dh-python to parse that file and extract dependencies to debian/control (if I understand correctly):
#!/usr/bin/make -f
export DH_VERBOSE = 1
export PYBUILD_NAME=myapp
%:
dh $# --with python3 --buildsystem=pybuild
All this works fine but the problem is that I need to manage npm-dependencies as well (for GUI part). I can't add something like npm run build as a custom build step to my setup.py since pybuild is setting proxy-server to avoid downloading of any side packages (only deb-dependencies are allowed). There are no deb-packages for my npm-dependencies and I don't want to create them myself.
So the only way I found is to add npm-dependencies (files like bootstrap.min.js, etc.) or bundle.js to git-repository, which seems bad. Is there any other way I can solve the problem?

Related

NodeJS: gherkin-lint: How to make a binary from this node module?

I am currently working on a set of BDD tests using Gherkin and Python. In order to have standardized feature files I want to include a git hook for the repo.
I found a good linter, gherkin-lint, but it's all Node.js oriented and I don't want to have to install Node to use it. I tried to create a binary package out of it using the Node pkg module, but It is complaining about the bin entry on package.json.
# pkg . -o gherkin-lint
> pkg#5.8.0
> Error! Bin file does not exist (taken from package.json 'bin' property)
/app/gherkin-lint/dist/main.js
I'm not a Node.js developer and don't have much knowledge of it. Is there a way to achieve what I'm trying to do?
Also, I found a formatter (reformat-gherkin) that is pre-commit oriented, but it is not a linter. It only formats the feature files indentation and doesn't look for bad-practices in the code, like duplicated tags, so it doesn't fit for what I'm trying to achieve.

How to make a Nodejs distributable command line application

I'm making a command line application with commander, inquirer and nightwatch as top dependencies. The main purpose of the app is for automation and testing.. Is there any way i can make this distributable instead of publishing it as npm package. I want the same functionality as those cli made with python, where it can be setup, and run on a target machine. is this possible? Thank you
Here are two open source projects (PKG and Nexe) that enable you to package your Node.js project into an executable:
https://github.com/zeit/pkg/blob/master/README.md
Or
https://github.com/nexe/nexe/blob/dev/README.md
You can use either one to make an executable of your project.

Building all code with Go and './...'

According to Ethereum Developers' Guide:
You can build all code using the go tool, placing the resulting binary
in $GOPATH/bin.
go install -v ./...
What does ./... do in the context of:
go install -v ./...
That will install any "main" packages found in the current or subdirectories,
"subdirectories": that is what the ./... syntax means.
It forces go install to consider not just the current folder/package ('.'), but also the ones in the sub-folders: "..."
See "What is a sensible way to layout a Go project": you can have multiple packages "main", in a library driven development:
Moving the main.go file out of your root allows you to build your application from the perspective of a library. Your application binary is simply a client of your application’s library.
Sometimes you might want users to interact in multiple ways so you create multiple binaries.
For example, if you had an “adder” package that that let users add numbers together, you may want to release a command line version as well as a web version.
You can easily do this by organizing your project like this:
adder/
adder.go
cmd/
adder/
main.go
adder-server/
main.go
Users can install your “adder” application binaries with “go get” using an ellipsis:
$ go get github.com/benbjohnson/adder/...
And voila, your user has “adder” and “adder-server” installed!
Similarly, a go install -v ./... would install “adder” and “adder-server” as well.
Note: the -v print the names of packages as they are compiled.

Writing a Go program that acts as an executable as well as a module

I am currently trying to do my first steps in Go. Now I've ported a tool that I once written in Node.js, and I was surprised how easy that was, and how clean and concise the code is.
Anyway, I've got a question that I was not able to figure out by myself so far: In Node.js it's possible to add the main entry as well as the bin entry to the package.json file. This basically means that you can create a module that works as a executable when installed using
$ npm install -g <module>
but as a library when installed using
$ npm install <module>
The trick here is that the first one uses the bin entry, which then internally uses a file from the module's lib folder, but the second version directly points to this lib file.
So ... now I would like to have the same behavior in Go: I would like to write a package that you can directly run as an executable, but that as well you can import into another application as a library. How would I do that?
Obviously I can't put two calls to package into a .go file. Any hints?
What about the solution in the following blog post? http://dan.munckton.co.uk/blog/2013/06/21/go-lang-packaging-creating-a-library-that-bundles-an-executable/

How to do a dojo build using nodejs?

I'm currently using the dojotoolkit and its build system.
I read the new build tutorial for 1.8 at http://dojotoolkit.org/documentation/tutorials/1.8/build/.
In the tutorial it mentions that you can speed up your build by using nodejs.
The build tool itself relies on Java (and, optionally, Node.js for even faster builds), so make sure that have you that installed as well.
But it fails to mention how to do this. Anyone know how this works?
I normally run it like this:
> node dojo/dojo.js load=build --profile myprofile.profile.js --release
This would build a release for the profile contained in myprofile.profile.js. It assumes you are in a directory, which contains both dojo and util as sub-directories. It also assumes that the path to node is set correctly.
If node is not configured in the path variable, you will need to use the full path to node:
> <path to node here> dojo/dojo.js load=build --profile myprofile.profile.js --release
On windows the path is normally C:\Program Files\nodejs\ but you might have to configure it as C:\PROGRA~1\nodejs\ to get it working.
Windows Notes:
The build scripts do not work with Node on Windows (except using Cygwin). If you are using Windows you can get it to work via the following patch:
Windows Patch
Use the attached node-win.patch file to edit the files: util/build/main.js and util/build/transforms/writeOptimized.js. The patch has worked for me 100% of the time and it a simple matter editing a few lines of code.
I've personally found the alternative to Node, using Rhino, useless. It always fails to detect the build paths correctly, no-matter what I set basePath to. I would strongly advise using Node over Rhino as it is more reliable and easier to setup.
The buildscript util/buildscripts/build.sh checks if node is in your path and if so uses it.
This is currently not working under Windows (http://bugs.dojotoolkit.org/ticket/15413).

Resources