Skip to content

Commit

Permalink
feat(build): fluidattacks#1378 deprecate makenodejs
Browse files Browse the repository at this point in the history
- Deprecate `makeNodeJsModules` and `makeNodeJsEnvironment`.

Signed-off-by: Robin Quintero <[email protected]>
  • Loading branch information
rohaquinlop committed Oct 23, 2024
1 parent 382fe21 commit 7750a71
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 380 deletions.
21 changes: 0 additions & 21 deletions docs/src/api/builtins/utilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,6 @@ Utilities provide an easy mechanism
for calling functions from makes
without having to specify them on any file.

## makeNodeJsLock

You can generate a `package-lock.json` for
[makeNodeJsEnvironment](/api/extensions/node.js/#makenodejsenvironment)
like this:

```bash
m github:fluidattacks/[email protected] /utils/makeNodeJsLock \
"${node_js_version}" \
"${package_json_dir}" \
"${lockfile_version}"
```

- Supported `node_js_version`s are: `18`, `20` and `21`.
- `package_json_dir` is the **absolute path** to the directory that contains
the `package.json` file in your project.
- The `package-lock.json` file will be generated in the same directory that
contains the `package.json` file.
- The `lockfile_version` is an optional argument, defaults to `2` and can be
`1` or `2`.

## makePythonLock

You can generate a `poetry.lock` for
Expand Down
202 changes: 0 additions & 202 deletions docs/src/api/extensions/node.js.md

This file was deleted.

24 changes: 0 additions & 24 deletions makes/utils/makeNodeJsLock/entrypoint.sh

This file was deleted.

10 changes: 0 additions & 10 deletions makes/utils/makeNodeJsLock/main.nix

This file was deleted.

3 changes: 0 additions & 3 deletions src/args/agnostic.nix
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ let
makeEnvVars = import ./make-env-vars/default.nix self;
makeEnvVarsForTerraform =
import ./make-env-vars-for-terraform/default.nix self;
makeNodeJsEnvironment =
import ./make-node-js-environment/default.nix self;
makeNodeJsModules = import ./make-node-js-modules/default.nix self;
makeNomadEnvironment = import ./make-nomad-environment/default.nix self;
makePythonEnvironment = import ./make-python-environment/default.nix self;
makePythonPoetryEnvironment =
Expand Down
16 changes: 3 additions & 13 deletions src/args/lint-git-commit-msg/default.nix
Original file line number Diff line number Diff line change
@@ -1,23 +1,13 @@
{ __nixpkgs__, makeNodeJsEnvironment, makeScript, ... }:
{ __nixpkgs__, makeScript, makeDerivation, makeSearchPaths, ... }:
{ branch, config, name, parser, src, }:
let
commitlint = makeNodeJsEnvironment {
name = "commitlint";
nodeJsVersion = "21";
packageJson = ./commitlint/package.json;
packageLockJson = ./commitlint/package-lock.json;
};
in makeScript {
makeScript {
name = "lint-git-commit-msg-for-${name}";
replace = {
__argBranch__ = branch;
__argConfig__ = config;
__argParser__ = parser;
__argSrc__ = src;
};
searchPaths = {
bin = [ __nixpkgs__.git ];
source = [ commitlint ];
};
searchPaths = { bin = [ __nixpkgs__.git __nixpkgs__.nodejs_21 ]; };
entrypoint = ./entrypoint.sh;
}
7 changes: 6 additions & 1 deletion src/args/lint-git-commit-msg/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ function main {
--parser-preset __argParser__
--config __argConfig__
)
local commitlint_path="src/args/lint-git-commit-msg/commitlint"

cd __argSrc__ \
pushd "${commitlint_path}" \
&& npm ci \
&& export PATH="${PWD}/node_modules/.bin:${PATH}" \
&& popd \
&& cd __argSrc__ \
&& commit_diff="origin/${main_branch}..HEAD" \
&& commit_hashes="$(git --no-pager log --pretty=%h "${commit_diff}")" \
&& for commit_hash in ${commit_hashes}; do
Expand Down
16 changes: 0 additions & 16 deletions src/args/lint-with-ajv/builder.sh

This file was deleted.

24 changes: 8 additions & 16 deletions src/args/lint-with-ajv/default.nix
Original file line number Diff line number Diff line change
@@ -1,20 +1,12 @@
{ makeDerivation, makeNodeJsEnvironment, toBashArray, ... }:
{ __nixpkgs__, makeScript, projectPath, toBashArray, ... }:
{ name, schema, targets, }:
makeDerivation {
env = {
envSchema = schema;
envTargets = toBashArray targets;
makeScript {
replace = {
__argSchema__ = schema;
__argTargets__ = toBashArray targets;
__argAjvPath__ = projectPath "/src/args/lint-with-ajv/ajv-cli";
};
name = "lint-with-ajv-for-${name}";
searchPaths = {
source = [
(makeNodeJsEnvironment {
name = "ajv-cli";
nodeJsVersion = "21";
packageJson = ./ajv-cli/package.json;
packageLockJson = ./ajv-cli/package-lock.json;
})
];
};
builder = ./builder.sh;
searchPaths.bin = [ __nixpkgs__.nodejs_21 ];
entrypoint = ./entrypoint.sh;
}
20 changes: 20 additions & 0 deletions src/args/lint-with-ajv/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# shellcheck shell=bash

function main {
source "${__argTargets__}/template" local targets

pushd "${__argAjvPath__}" \
&& npm ci \
&& export PATH="${PWD}/node_modules/.bin:${PATH}" \
&& popd \
&& info "Compiling schema: ${__argSchema__}" \
&& ajv compile -s "${__argSchema__}" \
&& for target in "${targets[@]}"; do
info "Linting data: ${target}" \
&& ajv validate -s "${__argSchema__}" -d "${target}" \
|| return 1
done \
&& touch "${out}"
}

main "${@}"
Loading

0 comments on commit 7750a71

Please sign in to comment.