From 135796b8cfb80c0449d5d42e57134e9a6881dee2 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 e02f50d0f5f80e97adccff6034c7ab8eb2d3f8f4 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 35ec9daad070692ef6fb121dcacd33b14c3bc937 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 | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Manual.md b/Manual.md index 4f954b840be..b08e3686b37 100644 --- a/Manual.md +++ b/Manual.md @@ -915,6 +915,9 @@ 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). + - `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 @@ -1616,6 +1619,23 @@ The following variables influence how Haskell packages are built: - `make_build_args`: This is passed as-is to `stack build ...`, so you can add your `--flag ...` parameters there. + +### Node.js packages + +Node.js packages should be built with the `nodejs` build style, if possible. +The `nodejs` build style takes care of downloading yarn/npm dependencies +and running builds via package.json scripts. + +The following template variables influence how Node.js packages are built: +- `nodejs_build_script`: the package.json script that builds the app files + (default: `build`). +- `nodejs_install_script`: app installing script, which most probably + doesn't even exist and you should redefine `do_install` + in your build script. +- `nodejs_packager`: whether the build script should use yarn or npm. + Set to `yarn` if the `yarn.lock` file exists, else it's set to `npm` +- `NODE_ENV`: set to `production` by default + ### Font packages