-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #791 from jpverde/main
feat(back): #789 build package lock
- Loading branch information
Showing
3 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3707,6 +3707,31 @@ It appends: | |
- `node_modules/.bin` to `PATH`. | ||
- `node_modules` to [NODE_PATH][NODE_PATH]. | ||
Pre-requisites: | ||
1. You can generate a `package-lock.json` using a specific `node` version | ||
like this: | ||
```bash | ||
m github:fluidattacks/[email protected] /utils/makeNodeJsLockfile \ | ||
"${node_js_version}" \ | ||
"${package_json}" \ | ||
"${package_lock} | ||
``` | ||
- Supported `node_js_version`s are: `10`, `12`, `14` and `16`. | ||
- `package_json` is the **absolute path** to the `package.json` file in your | ||
project. | ||
- `package_lock` is the **absolute path** | ||
to the `package-lock.json` file in your project, this file can be an empty | ||
file. | ||
Note: the reason behind this script is to maintain `lock` versions through the | ||
construction of `makeNodeJsEnvironment`, since you can have an updated version | ||
of `nodejs` or `npm` but not the same as the version stored on the | ||
[Nixpkgs][NIXPKGS] repository. This doesn't affect your local version | ||
of `npm` or `nodejs`. | ||
Types: | ||
- makeNodeJsEnvironment (`function { ... } -> package`): | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# shellcheck shell=bash | ||
|
||
function main { | ||
local node_js_version="${1}" | ||
local package_json="${2}" | ||
local package_lock="${3}" | ||
local npm_install_args=( | ||
--audit false | ||
--ignore-scripts true | ||
) | ||
|
||
case "${node_js_version}" in | ||
10) npm=__argNode10__/bin/npm ;; | ||
12) npm=__argNode12__/bin/npm ;; | ||
14) npm=__argNode14__/bin/npm ;; | ||
16) npm=__argNode16__/bin/npm ;; | ||
*) critical NodeJs version not supported: "${node_js_version}" ;; | ||
esac \ | ||
&& pushd "$(mktemp -d)" \ | ||
&& copy "${package_json}" package.json \ | ||
&& "${npm}" install "${npm_install_args[@]}" \ | ||
&& copy package-lock.json "${package_lock}" \ | ||
&& popd || return 1 | ||
} | ||
|
||
main "${@}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ __nixpkgs__ | ||
, makeNodeJsVersion | ||
, makeScript | ||
, ... | ||
}: | ||
makeScript { | ||
entrypoint = ./entrypoint.sh; | ||
name = "make-node-js-lockfile"; | ||
replace = { | ||
__argNode10__ = makeNodeJsVersion "10"; | ||
__argNode12__ = makeNodeJsVersion "12"; | ||
__argNode14__ = makeNodeJsVersion "14"; | ||
__argNode16__ = makeNodeJsVersion "16"; | ||
}; | ||
} |