web/lukegbcom: add rehype-toc and rehype-slug
This commit is contained in:
parent
31e8fe723d
commit
0991cea3c3
5 changed files with 1993 additions and 102 deletions
|
@ -1,8 +1,8 @@
|
||||||
# This file has been generated by node2nix 1.9.0. Do not edit!
|
# This file has been generated by node2nix 1.11.1. Do not edit!
|
||||||
|
|
||||||
{pkgs ? import <nixpkgs> {
|
{pkgs ? import <nixpkgs> {
|
||||||
inherit system;
|
inherit system;
|
||||||
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-12_x"}:
|
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs_16"}:
|
||||||
|
|
||||||
let
|
let
|
||||||
nodeEnv = import ./node-env.nix {
|
nodeEnv = import ./node-env.nix {
|
||||||
|
|
|
@ -98,7 +98,7 @@ let
|
||||||
''
|
''
|
||||||
+ (lib.concatMapStrings (dependency:
|
+ (lib.concatMapStrings (dependency:
|
||||||
''
|
''
|
||||||
if [ ! -e "${dependency.name}" ]; then
|
if [ ! -e "${dependency.packageName}" ]; then
|
||||||
${composePackage dependency}
|
${composePackage dependency}
|
||||||
fi
|
fi
|
||||||
''
|
''
|
||||||
|
@ -165,7 +165,11 @@ let
|
||||||
if(process.argv[2] == "development") {
|
if(process.argv[2] == "development") {
|
||||||
replaceDependencies(packageObj.devDependencies);
|
replaceDependencies(packageObj.devDependencies);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
packageObj.devDependencies = {};
|
||||||
|
}
|
||||||
replaceDependencies(packageObj.optionalDependencies);
|
replaceDependencies(packageObj.optionalDependencies);
|
||||||
|
replaceDependencies(packageObj.peerDependencies);
|
||||||
|
|
||||||
/* Write the fixed package.json file */
|
/* Write the fixed package.json file */
|
||||||
fs.writeFileSync("package.json", JSON.stringify(packageObj, null, 2));
|
fs.writeFileSync("package.json", JSON.stringify(packageObj, null, 2));
|
||||||
|
@ -257,8 +261,8 @@ let
|
||||||
var packageLock = JSON.parse(fs.readFileSync("./package-lock.json"));
|
var packageLock = JSON.parse(fs.readFileSync("./package-lock.json"));
|
||||||
|
|
||||||
if(![1, 2].includes(packageLock.lockfileVersion)) {
|
if(![1, 2].includes(packageLock.lockfileVersion)) {
|
||||||
process.stderr.write("Sorry, I only understand lock file versions 1 and 2!\n");
|
process.stderr.write("Sorry, I only understand lock file versions 1 and 2!\n");
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(packageLock.dependencies !== undefined) {
|
if(packageLock.dependencies !== undefined) {
|
||||||
|
@ -270,7 +274,7 @@ let
|
||||||
|
|
||||||
# Reconstructs a package-lock file from the node_modules/ folder structure and package.json files with dummy sha1 hashes
|
# Reconstructs a package-lock file from the node_modules/ folder structure and package.json files with dummy sha1 hashes
|
||||||
reconstructPackageLock = writeTextFile {
|
reconstructPackageLock = writeTextFile {
|
||||||
name = "addintegrityfields.js";
|
name = "reconstructpackagelock.js";
|
||||||
text = ''
|
text = ''
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
var path = require('path');
|
var path = require('path');
|
||||||
|
@ -280,25 +284,43 @@ let
|
||||||
var lockObj = {
|
var lockObj = {
|
||||||
name: packageObj.name,
|
name: packageObj.name,
|
||||||
version: packageObj.version,
|
version: packageObj.version,
|
||||||
lockfileVersion: 1,
|
lockfileVersion: 2,
|
||||||
requires: true,
|
requires: true,
|
||||||
|
packages: {
|
||||||
|
"": {
|
||||||
|
name: packageObj.name,
|
||||||
|
version: packageObj.version,
|
||||||
|
license: packageObj.license,
|
||||||
|
bin: packageObj.bin,
|
||||||
|
dependencies: packageObj.dependencies,
|
||||||
|
engines: packageObj.engines,
|
||||||
|
optionalDependencies: packageObj.optionalDependencies
|
||||||
|
}
|
||||||
|
},
|
||||||
dependencies: {}
|
dependencies: {}
|
||||||
};
|
};
|
||||||
|
|
||||||
function augmentPackageJSON(filePath, dependencies) {
|
function augmentPackageJSON(filePath, packages, dependencies) {
|
||||||
var packageJSON = path.join(filePath, "package.json");
|
var packageJSON = path.join(filePath, "package.json");
|
||||||
if(fs.existsSync(packageJSON)) {
|
if(fs.existsSync(packageJSON)) {
|
||||||
var packageObj = JSON.parse(fs.readFileSync(packageJSON));
|
var packageObj = JSON.parse(fs.readFileSync(packageJSON));
|
||||||
|
packages[filePath] = {
|
||||||
|
version: packageObj.version,
|
||||||
|
integrity: "sha1-000000000000000000000000000=",
|
||||||
|
dependencies: packageObj.dependencies,
|
||||||
|
engines: packageObj.engines,
|
||||||
|
optionalDependencies: packageObj.optionalDependencies
|
||||||
|
};
|
||||||
dependencies[packageObj.name] = {
|
dependencies[packageObj.name] = {
|
||||||
version: packageObj.version,
|
version: packageObj.version,
|
||||||
integrity: "sha1-000000000000000000000000000=",
|
integrity: "sha1-000000000000000000000000000=",
|
||||||
dependencies: {}
|
dependencies: {}
|
||||||
};
|
};
|
||||||
processDependencies(path.join(filePath, "node_modules"), dependencies[packageObj.name].dependencies);
|
processDependencies(path.join(filePath, "node_modules"), packages, dependencies[packageObj.name].dependencies);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function processDependencies(dir, dependencies) {
|
function processDependencies(dir, packages, dependencies) {
|
||||||
if(fs.existsSync(dir)) {
|
if(fs.existsSync(dir)) {
|
||||||
var files = fs.readdirSync(dir);
|
var files = fs.readdirSync(dir);
|
||||||
|
|
||||||
|
@ -314,23 +336,84 @@ let
|
||||||
pkgFiles.forEach(function(entry) {
|
pkgFiles.forEach(function(entry) {
|
||||||
if(stats.isDirectory()) {
|
if(stats.isDirectory()) {
|
||||||
var pkgFilePath = path.join(filePath, entry);
|
var pkgFilePath = path.join(filePath, entry);
|
||||||
augmentPackageJSON(pkgFilePath, dependencies);
|
augmentPackageJSON(pkgFilePath, packages, dependencies);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
augmentPackageJSON(filePath, dependencies);
|
augmentPackageJSON(filePath, packages, dependencies);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
processDependencies("node_modules", lockObj.dependencies);
|
processDependencies("node_modules", lockObj.packages, lockObj.dependencies);
|
||||||
|
|
||||||
fs.writeFileSync("package-lock.json", JSON.stringify(lockObj, null, 2));
|
fs.writeFileSync("package-lock.json", JSON.stringify(lockObj, null, 2));
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Script that links bins defined in package.json to the node_modules bin directory
|
||||||
|
# NPM does not do this for top-level packages itself anymore as of v7
|
||||||
|
linkBinsScript = writeTextFile {
|
||||||
|
name = "linkbins.js";
|
||||||
|
text = ''
|
||||||
|
var fs = require('fs');
|
||||||
|
var path = require('path');
|
||||||
|
|
||||||
|
var packageObj = JSON.parse(fs.readFileSync("package.json"));
|
||||||
|
|
||||||
|
var nodeModules = Array(packageObj.name.split("/").length).fill("..").join(path.sep);
|
||||||
|
|
||||||
|
if(packageObj.bin !== undefined) {
|
||||||
|
fs.mkdirSync(path.join(nodeModules, ".bin"))
|
||||||
|
|
||||||
|
if(typeof packageObj.bin == "object") {
|
||||||
|
Object.keys(packageObj.bin).forEach(function(exe) {
|
||||||
|
if(fs.existsSync(packageObj.bin[exe])) {
|
||||||
|
console.log("linking bin '" + exe + "'");
|
||||||
|
fs.symlinkSync(
|
||||||
|
path.join("..", packageObj.name, packageObj.bin[exe]),
|
||||||
|
path.join(nodeModules, ".bin", exe)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log("skipping non-existent bin '" + exe + "'");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(fs.existsSync(packageObj.bin)) {
|
||||||
|
console.log("linking bin '" + packageObj.bin + "'");
|
||||||
|
fs.symlinkSync(
|
||||||
|
path.join("..", packageObj.name, packageObj.bin),
|
||||||
|
path.join(nodeModules, ".bin", packageObj.name.split("/").pop())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log("skipping non-existent bin '" + packageObj.bin + "'");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(packageObj.directories !== undefined && packageObj.directories.bin !== undefined) {
|
||||||
|
fs.mkdirSync(path.join(nodeModules, ".bin"))
|
||||||
|
|
||||||
|
fs.readdirSync(packageObj.directories.bin).forEach(function(exe) {
|
||||||
|
if(fs.existsSync(path.join(packageObj.directories.bin, exe))) {
|
||||||
|
console.log("linking bin '" + exe + "'");
|
||||||
|
fs.symlinkSync(
|
||||||
|
path.join("..", packageObj.name, packageObj.directories.bin, exe),
|
||||||
|
path.join(nodeModules, ".bin", exe)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
console.log("skipping non-existent bin '" + exe + "'");
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
prepareAndInvokeNPM = {packageName, bypassCache, reconstructLock, npmFlags, production}:
|
prepareAndInvokeNPM = {packageName, bypassCache, reconstructLock, npmFlags, production}:
|
||||||
let
|
let
|
||||||
forceOfflineFlag = if bypassCache then "--offline" else "--registry http://www.example.com";
|
forceOfflineFlag = if bypassCache then "--offline" else "--registry http://www.example.com";
|
||||||
|
@ -377,20 +460,25 @@ let
|
||||||
|
|
||||||
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${lib.optionalString production "--production"} rebuild
|
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${lib.optionalString production "--production"} rebuild
|
||||||
|
|
||||||
|
runHook postRebuild
|
||||||
|
|
||||||
if [ "''${dontNpmInstall-}" != "1" ]
|
if [ "''${dontNpmInstall-}" != "1" ]
|
||||||
then
|
then
|
||||||
# NPM tries to download packages even when they already exist if npm-shrinkwrap is used.
|
# NPM tries to download packages even when they already exist if npm-shrinkwrap is used.
|
||||||
rm -f npm-shrinkwrap.json
|
rm -f npm-shrinkwrap.json
|
||||||
|
|
||||||
npm ${forceOfflineFlag} --nodedir=${nodeSources} ${npmFlags} ${lib.optionalString production "--production"} install
|
npm ${forceOfflineFlag} --nodedir=${nodeSources} --no-bin-links --ignore-scripts ${npmFlags} ${lib.optionalString production "--production"} install
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Link executables defined in package.json
|
||||||
|
node ${linkBinsScript}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
# Builds and composes an NPM package including all its dependencies
|
# Builds and composes an NPM package including all its dependencies
|
||||||
buildNodePackage =
|
buildNodePackage =
|
||||||
{ name
|
{ name
|
||||||
, packageName
|
, packageName
|
||||||
, version
|
, version ? null
|
||||||
, dependencies ? []
|
, dependencies ? []
|
||||||
, buildInputs ? []
|
, buildInputs ? []
|
||||||
, production ? true
|
, production ? true
|
||||||
|
@ -409,7 +497,7 @@ let
|
||||||
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" "meta" ];
|
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "preRebuild" "unpackPhase" "buildPhase" "meta" ];
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation ({
|
stdenv.mkDerivation ({
|
||||||
name = "${name}-${version}";
|
name = "${name}${if version == null then "" else "-${version}"}";
|
||||||
buildInputs = [ tarWrapper python nodejs ]
|
buildInputs = [ tarWrapper python nodejs ]
|
||||||
++ lib.optional (stdenv.isLinux) utillinux
|
++ lib.optional (stdenv.isLinux) utillinux
|
||||||
++ lib.optional (stdenv.isDarwin) libtool
|
++ lib.optional (stdenv.isDarwin) libtool
|
||||||
|
@ -441,6 +529,17 @@ let
|
||||||
if [ -d "$out/lib/node_modules/.bin" ]
|
if [ -d "$out/lib/node_modules/.bin" ]
|
||||||
then
|
then
|
||||||
ln -s $out/lib/node_modules/.bin $out/bin
|
ln -s $out/lib/node_modules/.bin $out/bin
|
||||||
|
|
||||||
|
# Fixup all executables
|
||||||
|
ls $out/bin/* | while read i
|
||||||
|
do
|
||||||
|
file="$(readlink -f "$i")"
|
||||||
|
chmod u+rwx "$file"
|
||||||
|
if isScript "$file"
|
||||||
|
then
|
||||||
|
sed -i 's/\r$//' "$file" # convert crlf to lf
|
||||||
|
fi
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create symlinks to the deployed manual page folders, if applicable
|
# Create symlinks to the deployed manual page folders, if applicable
|
||||||
|
@ -471,7 +570,7 @@ let
|
||||||
buildNodeDependencies =
|
buildNodeDependencies =
|
||||||
{ name
|
{ name
|
||||||
, packageName
|
, packageName
|
||||||
, version
|
, version ? null
|
||||||
, src
|
, src
|
||||||
, dependencies ? []
|
, dependencies ? []
|
||||||
, buildInputs ? []
|
, buildInputs ? []
|
||||||
|
@ -489,7 +588,7 @@ let
|
||||||
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" ];
|
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" ];
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation ({
|
stdenv.mkDerivation ({
|
||||||
name = "node-dependencies-${name}-${version}";
|
name = "node-dependencies-${name}${if version == null then "" else "-${version}"}";
|
||||||
|
|
||||||
buildInputs = [ tarWrapper python nodejs ]
|
buildInputs = [ tarWrapper python nodejs ]
|
||||||
++ lib.optional (stdenv.isLinux) utillinux
|
++ lib.optional (stdenv.isLinux) utillinux
|
||||||
|
@ -519,6 +618,7 @@ let
|
||||||
if [ -f ${src}/package-lock.json ]
|
if [ -f ${src}/package-lock.json ]
|
||||||
then
|
then
|
||||||
cp ${src}/package-lock.json .
|
cp ${src}/package-lock.json .
|
||||||
|
chmod 644 package-lock.json
|
||||||
fi
|
fi
|
||||||
''}
|
''}
|
||||||
|
|
||||||
|
@ -541,7 +641,7 @@ let
|
||||||
buildNodeShell =
|
buildNodeShell =
|
||||||
{ name
|
{ name
|
||||||
, packageName
|
, packageName
|
||||||
, version
|
, version ? null
|
||||||
, src
|
, src
|
||||||
, dependencies ? []
|
, dependencies ? []
|
||||||
, buildInputs ? []
|
, buildInputs ? []
|
||||||
|
@ -557,9 +657,10 @@ let
|
||||||
|
|
||||||
let
|
let
|
||||||
nodeDependencies = buildNodeDependencies args;
|
nodeDependencies = buildNodeDependencies args;
|
||||||
|
extraArgs = removeAttrs args [ "name" "dependencies" "buildInputs" "dontStrip" "dontNpmInstall" "unpackPhase" "buildPhase" ];
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation ({
|
||||||
name = "node-shell-${name}-${version}";
|
name = "node-shell-${name}${if version == null then "" else "-${version}"}";
|
||||||
|
|
||||||
buildInputs = [ python nodejs ] ++ lib.optional (stdenv.isLinux) utillinux ++ buildInputs;
|
buildInputs = [ python nodejs ] ++ lib.optional (stdenv.isLinux) utillinux ++ buildInputs;
|
||||||
buildCommand = ''
|
buildCommand = ''
|
||||||
|
@ -578,7 +679,7 @@ let
|
||||||
export NODE_PATH=${nodeDependencies}/lib/node_modules
|
export NODE_PATH=${nodeDependencies}/lib/node_modules
|
||||||
export PATH="${nodeDependencies}/bin:$PATH"
|
export PATH="${nodeDependencies}/bin:$PATH"
|
||||||
'';
|
'';
|
||||||
};
|
} // extraArgs);
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
buildNodeSourceDist = lib.makeOverridable buildNodeSourceDist;
|
buildNodeSourceDist = lib.makeOverridable buildNodeSourceDist;
|
||||||
|
|
File diff suppressed because it is too large
Load diff
1276
web/lukegbcom/package-lock.json
generated
1276
web/lukegbcom/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -23,10 +23,12 @@
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
"rehype-highlight": "^5.0.2",
|
"rehype-highlight": "^5.0.2",
|
||||||
|
"rehype-slug": "^5.1.0",
|
||||||
"rehype-stringify": "^9.0.3",
|
"rehype-stringify": "^9.0.3",
|
||||||
"remark-gfm": "^3.0.1",
|
"remark-gfm": "^3.0.1",
|
||||||
"remark-parse": "^10.0.1",
|
"remark-parse": "^10.0.1",
|
||||||
"remark-rehype": "^10.1.0",
|
"remark-rehype": "^10.1.0",
|
||||||
|
"remark-toc": "^8.0.1",
|
||||||
"sass": "^1.49.11",
|
"sass": "^1.49.11",
|
||||||
"unified": "^10.1.2",
|
"unified": "^10.1.2",
|
||||||
"zbar.wasm": "^2.1.1"
|
"zbar.wasm": "^2.1.1"
|
||||||
|
|
Loading…
Reference in a new issue