Discourage dev dependencies in package.json.

pull/12/head
Joshua Potter 2023-12-03 19:38:47 -07:00
parent 55e1b42a73
commit 635395b9cc
7 changed files with 59 additions and 48 deletions

View File

@ -43,7 +43,8 @@ trap cleanup EXIT
cp -r template/* "$BUILD"
# Copy over the CommonJS module responsible for validating the given NAME.
cp validate.cjs "$BUILD"
mkdir "$BUILD"/bs.nodejs
cp validate.cjs "$BUILD"/bs.nodejs
# Explicitly set permissions on all copied files.
find "$BUILD" -type f -execdir chmod 644 {} +
@ -51,9 +52,8 @@ find "$BUILD" -type d -execdir chmod 755 {} +
# Validate the provided name is usable.
nix develop "$BUILD" --command bash -c \
"cd $BUILD &&
npm install validate-npm-package-name &&
node validate.cjs"
"npm --prefix $BUILD/bs.nodejs install validate-npm-package-name &&
node $BUILD/bs.nodejs/validate.cjs"
# Replace the placeholder name found in the template files.
sed -i "s/<NAME>/$NAME/g" "$BUILD/flake.nix"
@ -70,4 +70,4 @@ nix develop "$BUILD" --command bash -c \
# ============================================================
# Success! Copy contents to target directory.
cp -r "$BUILD"/!(node_modules|validate.cjs) "$OUT"
cp -r "$BUILD"/!(bs.nodejs) "$OUT"

View File

@ -28,6 +28,9 @@
src = ./.;
npmDepsHash = "<SHA_256>";
# Needed to properly invoke npm run build.
nativeBuildInputs = [ pkgs.typescript ];
installPhase = ''
mkdir $out
cp dist/index.js $out

View File

@ -8,22 +8,14 @@
"name": "<NAME>",
"version": "0.1.0",
"license": "ISC",
"devDependencies": {
"typescript": "^5.3.2"
"dependencies": {
"lodash": "^4.17.21"
}
},
"node_modules/typescript": {
"version": "5.3.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.2.tgz",
"integrity": "sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
}
}
}

View File

@ -11,7 +11,7 @@
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"typescript": "^5.3.2"
"dependencies": {
"lodash": "^4.17.21"
}
}

View File

@ -3,14 +3,29 @@
{nodeEnv, fetchurl, fetchgit, nix-gitignore, stdenv, lib, globalBuildInputs ? []}:
let
sources = {};
sources = {
"lodash-4.17.21" = {
name = "lodash";
packageName = "lodash";
version = "4.17.21";
src = fetchurl {
url = "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz";
sha512 = "v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==";
};
};
};
args = {
name = "<APP>";
packageName = "<APP>";
name = "blah";
packageName = "blah";
version = "0.1.0";
src = ./.;
dependencies = [
sources."lodash-4.17.21"
];
buildInputs = globalBuildInputs;
meta = {
description = "";
license = "ISC";
};
production = true;
bypassCache = true;

View File

@ -1,36 +1,28 @@
{
"name": "<APP>",
"name": "blah",
"version": "0.1.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "<APP>",
"name": "blah",
"version": "0.1.0",
"devDependencies": {
"typescript": "^5.3.2"
"license": "ISC",
"dependencies": {
"lodash": "^4.17.21"
}
},
"node_modules/typescript": {
"version": "5.3.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.2.tgz",
"integrity": "sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=14.17"
}
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
}
},
"dependencies": {
"typescript": {
"version": "5.3.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.3.2.tgz",
"integrity": "sha512-6l+RyNy7oAHDfxC4FzSJcz9vnjTKxrLpDG5M2Vu4SHRVNg6xzqZp6LYSR9zjqQTu8DU/f5xwxUdADOkbrIX2gQ==",
"dev": true
"lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg=="
}
}
}

View File

@ -1,8 +1,17 @@
{
"name": "<APP>",
"version": "0.1.0",
"devDependencies": {
"typescript": "^5.3.2"
"description": "",
"main": "index.js",
"scripts": {
"build": "tsc",
"format": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"",
"test": "echo \"Error: no test specified\" && exit 1"
},
"private": true
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"lodash": "^4.17.21"
}
}