Clean up dev workflow a bit

This commit is contained in:
Tristan Daniël Maat 2022-08-01 21:14:18 +01:00
parent 689afa04e8
commit af062715d9
Signed by: tlater
GPG key ID: 49670FD774E43268
9 changed files with 2198 additions and 67 deletions

View file

@ -6,6 +6,7 @@
(pug-mode (pug-mode
(tab-width . 2)) (tab-width . 2))
(scss-mode (scss-mode
(css-indent-offset . 2))) (css-indent-offset . 2))
(auto-mode-alist . (("update-lockfile" . sh-mode))))

View file

@ -11,7 +11,7 @@
}, },
"posthtml-favicons": { "posthtml-favicons": {
"root": "src", "root": "src",
"outDir": "./dist/browser/", "outDir": "./dist/",
"configuration": { "configuration": {
"appName": "tlater.net", "appName": "tlater.net",
"appShortName": "tlater.net", "appShortName": "tlater.net",

View file

@ -4,10 +4,12 @@ Website templates bundled with parcel.
## Updating ## Updating
When adding/removing packages from `package.json`, the corresponding
`package-lock.json` needs to be updated. Use `nix/update-lockfile` for
this.
When ignoring semver is desired, use:
```sh ```sh
npm-check-updates -u npm-check-updates -u
rm node_modules # Yeah, npm gets confused if it can't write here
npm install --package-lock-only
rm -rf node_modules
direnv reload
``` ```

View file

@ -25,55 +25,15 @@
}) })
]; ];
pkgs = import nixpkgs {inherit system overlays;}; pkgs = import nixpkgs {inherit system overlays;};
package = import ./nix/package.nix {inherit self nix-filter pkgs;};
in { in {
packages.${system} = rec { packages.${system} = rec {
tlaternet-templates = pkgs.npmlock2nix.build { tlaternet-templates = package.package;
src = pkgs.lib.cleanSource self;
buildInputs = with pkgs; [
util-linux
];
installPhase = ''
cp -r dist $out/
'';
node_modules_attrs = {
buildInputs = with pkgs; [
pkg-config
python3
vips
glib
];
};
};
default = tlaternet-templates; default = tlaternet-templates;
}; };
devShells.${system} = { devShells.${system} = {
default = pkgs.npmlock2nix.shell { default = package.shell;
src = nix-filter.lib {
root = self;
include = [
"package.json"
"package-lock.json"
];
};
buildInputs = with pkgs.nodePackages; [
npm-check-updates
];
node_modules_attrs = {
buildInputs = with pkgs; [
pkg-config
python3
vips
glib
];
};
};
}; };
}; };
} }

44
nix/package.nix Normal file
View file

@ -0,0 +1,44 @@
{
self,
nix-filter,
pkgs,
}: let
node_modules_attrs = {
# Dependencies that should be available in the node build
buildInputs = with pkgs; [
pkg-config
python3
vips
glib
];
};
# Dependencies that should be available outside of the node build
buildInputs = with pkgs; [
util-linux
];
in {
package = pkgs.npmlock2nix.build {
inherit buildInputs node_modules_attrs;
src = pkgs.lib.cleanSource self;
buildCommands = ["npm run build-dist"];
installPhase = ''
cp -r dist $out/
'';
};
shell = pkgs.npmlock2nix.shell {
inherit buildInputs node_modules_attrs;
src = nix-filter.lib {
root = self;
include = [
"package.json"
"package-lock.json"
];
};
};
}

17
nix/update-lockfile Executable file
View file

@ -0,0 +1,17 @@
#!/usr/bin/env -S nix run 'github:clhodapp/nix-runner/32a984cfa14e740a34d14fad16fc479dec72bf07'
#!pure
#!package nixpkgs#bash
#!package nixpkgs#coreutils
#!package nixpkgs#direnv
#!package nixpkgs#git
#!package nixpkgs#nodejs-14_x
#!command bash
# shellcheck shell=bash
set -eu
cd "$(git rev-parse --show-toplevel)"
unlink node_modules
npm install --package-lock-only
rm -rf node_modules
direnv reload

2114
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -34,23 +34,16 @@
"sass": "^1.53.0", "sass": "^1.53.0",
"typescript": "^4.7.4", "typescript": "^4.7.4",
"typescript-language-server": "^0.11.2", "typescript-language-server": "^0.11.2",
"vscode-langservers-extracted": "^4.2.1" "vscode-langservers-extracted": "^4.2.1",
"npm-check-updates": "^16.0.5"
}, },
"scripts": { "scripts": {
"build": "parcel build --no-autoinstall src/index.html && rename '.html' '.html.hbs' dist/browser/*.html", "build": "parcel build --no-autoinstall",
"serve": "parcel serve --no-autoinstall src/index.html", "serve": "parcel serve --no-autoinstall",
"watch": "parcel watch --no-autoinstall src/index.html", "watch": "parcel watch --no-autoinstall",
"build-dist": "parcel build --no-cache --no-autoinstall src/index.html && rename '.html' '.html.hbs' dist/browser/*.html" "build-dist": "parcel build --no-cache --no-autoinstall && rename '.html' '.html.hbs' dist/*.html",
"check": "tsc --noEmit"
}, },
"targets": { "source": "src/index.html",
"browser": { "browserslist": "> 1%, not dead"
"engines": {
"browsers": [
">1%",
"not dead"
]
},
"distDir": "dist"
}
}
} }

View file

@ -3,7 +3,7 @@
"strictNullChecks": true, "strictNullChecks": true,
"strictPropertyInitialization": true, "strictPropertyInitialization": true,
"esModuleInterop": true, "esModuleInterop": true,
"jsx": "react" "jsx": "react",
"isolatedModules": true
} }
} }