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" cp -r template/* "$BUILD"
# Copy over the CommonJS module responsible for validating the given NAME. # 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. # Explicitly set permissions on all copied files.
find "$BUILD" -type f -execdir chmod 644 {} + find "$BUILD" -type f -execdir chmod 644 {} +
@ -51,9 +52,8 @@ find "$BUILD" -type d -execdir chmod 755 {} +
# Validate the provided name is usable. # Validate the provided name is usable.
nix develop "$BUILD" --command bash -c \ nix develop "$BUILD" --command bash -c \
"cd $BUILD && "npm --prefix $BUILD/bs.nodejs install validate-npm-package-name &&
npm install validate-npm-package-name && node $BUILD/bs.nodejs/validate.cjs"
node validate.cjs"
# Replace the placeholder name found in the template files. # Replace the placeholder name found in the template files.
sed -i "s/<NAME>/$NAME/g" "$BUILD/flake.nix" 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. # 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 = ./.; src = ./.;
npmDepsHash = "<SHA_256>"; npmDepsHash = "<SHA_256>";
# Needed to properly invoke npm run build.
nativeBuildInputs = [ pkgs.typescript ];
installPhase = '' installPhase = ''
mkdir $out mkdir $out
cp dist/index.js $out cp dist/index.js $out

View File

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

View File

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

View File

@ -3,14 +3,29 @@
{nodeEnv, fetchurl, fetchgit, nix-gitignore, stdenv, lib, globalBuildInputs ? []}: {nodeEnv, fetchurl, fetchgit, nix-gitignore, stdenv, lib, globalBuildInputs ? []}:
let 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 = { args = {
name = "<APP>"; name = "blah";
packageName = "<APP>"; packageName = "blah";
version = "0.1.0"; version = "0.1.0";
src = ./.; src = ./.;
dependencies = [
sources."lodash-4.17.21"
];
buildInputs = globalBuildInputs; buildInputs = globalBuildInputs;
meta = { meta = {
description = "";
license = "ISC";
}; };
production = true; production = true;
bypassCache = true; bypassCache = true;

View File

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

View File

@ -1,8 +1,17 @@
{ {
"name": "<APP>", "name": "<APP>",
"version": "0.1.0", "version": "0.1.0",
"devDependencies": { "description": "",
"typescript": "^5.3.2" "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"
}
} }