This repository was archived by the owner on Sep 1, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +66
-0
lines changed
makes/utils/makeNodeJsLockfile Expand file tree Collapse file tree 3 files changed +66
-0
lines changed Original file line number Diff line number Diff line change @@ -3707,6 +3707,31 @@ It appends:
37073707- `node_modules/.bin` to `PATH`.
37083708- `node_modules` to [NODE_PATH][NODE_PATH].
37093709
3710+ Pre-requisites:
3711+
3712+ 1. You can generate a `package-lock.json` using a specific `node` version
3713+ like this:
3714+
3715+ ```bash
3716+ m github:fluidattacks/[email protected] /utils/makeNodeJsLockfile \ 3717+ "${node_js_version}" \
3718+ "${package_json}" \
3719+ "${package_lock}
3720+ ```
3721+
3722+ - Supported `node_js_version`s are: `10`, `12`, `14` and `16`.
3723+ - `package_json` is the **absolute path** to the `package.json` file in your
3724+ project.
3725+ - `package_lock` is the **absolute path**
3726+ to the `package-lock.json` file in your project, this file can be an empty
3727+ file.
3728+
3729+ Note: the reason behind this script is to maintain `lock` versions through the
3730+ construction of `makeNodeJsEnvironment`, since you can have an updated version
3731+ of `nodejs` or `npm` but not the same as the version stored on the
3732+ [Nixpkgs][NIXPKGS] repository. This doesn' t affect your local version
3733+ of ` npm` or ` nodejs` .
3734+
37103735Types:
37113736
37123737- makeNodeJsEnvironment (` function { ... } -> package` ):
Original file line number Diff line number Diff line change 1+ # shellcheck shell=bash
2+
3+ function main {
4+ local node_js_version=" ${1} "
5+ local package_json=" ${2} "
6+ local package_lock=" ${3} "
7+ local npm_install_args=(
8+ --audit false
9+ --ignore-scripts true
10+ )
11+
12+ case " ${node_js_version} " in
13+ 10) npm=__argNode10__/bin/npm ;;
14+ 12) npm=__argNode12__/bin/npm ;;
15+ 14) npm=__argNode14__/bin/npm ;;
16+ 16) npm=__argNode16__/bin/npm ;;
17+ * ) critical NodeJs version not supported: " ${node_js_version} " ;;
18+ esac \
19+ && pushd " $( mktemp -d) " \
20+ && copy " ${package_json} " package.json \
21+ && " ${npm} " install " ${npm_install_args[@]} " \
22+ && copy package-lock.json " ${package_lock} " \
23+ && popd || return 1
24+ }
25+
26+ main " ${@ } "
Original file line number Diff line number Diff line change 1+ { __nixpkgs__
2+ , makeNodeJsVersion
3+ , makeScript
4+ , ...
5+ } :
6+ makeScript {
7+ entrypoint = ./entrypoint.sh ;
8+ name = "make-node-js-lockfile" ;
9+ replace = {
10+ __argNode10__ = makeNodeJsVersion "10" ;
11+ __argNode12__ = makeNodeJsVersion "12" ;
12+ __argNode14__ = makeNodeJsVersion "14" ;
13+ __argNode16__ = makeNodeJsVersion "16" ;
14+ } ;
15+ }
You can’t perform that action at this time.
0 commit comments