From cf172217b1ea17856a70f669733a411fe0daf6f1 Mon Sep 17 00:00:00 2001 From: selfisekai Date: Thu, 30 Jul 2020 11:19:10 +0200 Subject: [PATCH 1/3] nodejs build style --- common/build-style/nodejs.sh | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 common/build-style/nodejs.sh diff --git a/common/build-style/nodejs.sh b/common/build-style/nodejs.sh new file mode 100644 index 00000000000..c9e749d3342 --- /dev/null +++ b/common/build-style/nodejs.sh @@ -0,0 +1,37 @@ +# +# This helper is for templates for Node.js packages (including Electron.js) +# + +do_configure() { + if [ -f "yarn.lock" ]; then + : ${nodejs_packager:=yarn} + else + : ${nodejs_packager:=npm} + fi + + $nodejs_packager install +} + +do_build() { + if [ -f "yarn.lock" ]; then + : ${nodejs_packager:=yarn} + else + : ${nodejs_packager:=npm} + fi + + : ${nodejs_build_script:=build} + + $nodejs_packager run $nodejs_build_script +} + +do_install() { + if [ -f "yarn.lock" ]; then + : ${nodejs_packager:=yarn} + else + : ${nodejs_packager:=npm} + fi + + : ${nodejs_install_script:=pack} # name suggested by https://github.com/electron-userland/electron-builder#quick-setup-guide + + $nodejs_packager run $nodejs_install_script +} From 90627422b037395cb64b2dbca67363248f767585 Mon Sep 17 00:00:00 2001 From: selfisekai Date: Thu, 5 Nov 2020 19:04:58 +0100 Subject: [PATCH 2/3] node build_style: set NODE_ENV --- common/build-style/nodejs.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/common/build-style/nodejs.sh b/common/build-style/nodejs.sh index c9e749d3342..98268b33de0 100644 --- a/common/build-style/nodejs.sh +++ b/common/build-style/nodejs.sh @@ -3,6 +3,7 @@ # do_configure() { + : ${NODE_ENV:=production} if [ -f "yarn.lock" ]; then : ${nodejs_packager:=yarn} else @@ -13,6 +14,7 @@ do_configure() { } do_build() { + : ${NODE_ENV:=production} if [ -f "yarn.lock" ]; then : ${nodejs_packager:=yarn} else @@ -24,7 +26,9 @@ do_build() { $nodejs_packager run $nodejs_build_script } +# it's really likely that it won't suit anybody's needs but whatever do_install() { + : ${NODE_ENV:=production} if [ -f "yarn.lock" ]; then : ${nodejs_packager:=yarn} else From d86eefe22f4c8e00881f64f7c1d1dd2b1078255a Mon Sep 17 00:00:00 2001 From: Laura Liberda Date: Sat, 2 Jan 2021 21:14:42 +0100 Subject: [PATCH 3/3] docs: nodejs build style basic information --- Manual.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Manual.md b/Manual.md index 4f954b840be..937bdfd7c41 100644 --- a/Manual.md +++ b/Manual.md @@ -915,6 +915,15 @@ depend on additional packages. This build style does not install dependencies to the root directory, and only checks if a binary package is available in repositories. +- `nodejs` For apps made in Node.js that get built with npm or yarn +(including Electron.js apps). The variable `nodejs_build_script` must be set +to the package.json script that builds the app files (default: `build`). +The variable `nodejs_install_script` must be set to app installing script, +which most probably doesn't even exist and you should redefine `do_install` +in your build script. The variable `nodejs_packager` is set to `yarn` +if the `yarn.lock` file exists, else it's set to `npm`, but you can overwrite it. +`NODE_ENV` is set to `production` by default. + - `R-cran` For packages that are available on The Comprehensive R Archive Network (CRAN). The build style requires the `pkgname` to start with `R-cran-` and any dashes (`-`) in the CRAN-given version to be replaced