textlint: 14.3.0 -> 15.2.1 (#434490)

This commit is contained in:
OTABI Tomoya 2025-08-18 23:05:20 +09:00 committed by GitHub
commit 966774277f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 74 additions and 49 deletions

View File

@ -1,12 +1,11 @@
{
lib,
stdenv,
buildNpmPackage,
fetchFromGitHub,
autoconf,
automake,
makeWrapper,
python311,
nodejs-slim,
pnpm_9,
versionCheckHook,
runCommand,
textlint,
textlint-plugin-latex2e,
@ -27,53 +26,83 @@
textlint-rule-write-good,
}:
buildNpmPackage rec {
stdenv.mkDerivation (finalAttrs: {
pname = "textlint";
version = "14.3.0";
version = "15.2.1";
src = fetchFromGitHub {
owner = "textlint";
repo = "textlint";
tag = "v${version}";
hash = "sha256-FbPJr7oTsU7WC5RTXyG7X5d0KPJJqRbjGwM/F023Cx8=";
tag = "v${finalAttrs.version}";
hash = "sha256-xjtmYz+O+Sn697OrBkPddv1Ma5UsOkO5v4SGlhsaYWA=";
};
patches = [
# this package uses lerna and requires building many workspaces.
# this patch removes unnecessary workspaces,
# reducing package size and build time.
./remove-workspaces.patch
# The upstream lockfile contains "overrides" configuration that conflicts with Nix's build environment.
# We remove these overrides to allow pnpm to install dependencies without modifying the lockfile,
# which would break the reproducible build process.
#
# Without this patch, pnpm fails with:
# ERR_PNPM_LOCKFILE_CONFIG_MISMATCH Cannot proceed with the frozen installation. The current "overrides" configuration doesn't match the value found in the lockfile
# Update your lockfile using "pnpm install --no-frozen-lockfile"
# ERROR: pnpm failed to install dependencies
./remove-overrides.patch
];
npmDepsHash = "sha256-l+1JntqIPttuYXKsVEdJOB1qQfsoheZk+7Z7OJ67z5E=";
pnpmDeps = pnpm_9.fetchDeps {
inherit (finalAttrs)
pname
version
src
patches
;
fetcherVersion = 1;
hash = "sha256-TyKtH4HjCDTydVd/poG05Yh5nRSfcrSPzFLEE3Oq2uo=";
};
nativeBuildInputs = [
autoconf
automake
]
++ lib.optionals (stdenv.hostPlatform.system == "aarch64-linux") [
# File "/build/source/node_modules/node-gyp/gyp/gyp_main.py", line 42, in <module>
# npm error ModuleNotFoundError: No module named 'distutils'
python311
makeWrapper
nodejs-slim
pnpm_9.configHook
];
buildPhase = ''
runHook preBuild
pnpm --filter textlint... build
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/{bin,lib}
mkdir -p $out/{bin,lib/node_modules}
npm prune --omit=dev --no-save
rm -r node_modules/.cache
rm -r packages/textlint-{scripts,tester}
rm -r packages/@textlint/*/test
rm -r node_modules
rm -r packages/textlint/node_modules
rm -r packages/@textlint/**/node_modules
pnpm install --offline --ignore-scripts --frozen-lockfile --prod --filter textlint...
cp -r node_modules $out/lib
cp -r packages $out/lib
ln -s $out/lib/node_modules/textlint/bin/textlint.js $out/bin/textlint
cp -r packages/{textlint,@textlint} $out/lib/node_modules
cp -r node_modules/.pnpm $out/lib/node_modules
makeWrapper "${lib.getExe nodejs-slim}" "$out/bin/textlint" \
--add-flags "$out/lib/node_modules/textlint/bin/textlint.js"
# Remove dangling symlinks to packages we didn't copy to $out
find $out/lib/node_modules/.pnpm -type l -exec test ! -e {} \; -delete
# Remove test directories recursively
find $out/lib/node_modules -type d -name "test" -exec rm -rf {} +
runHook postInstall
'';
nativeInstallCheckInputs = [ versionCheckHook ];
doInstallCheck = true;
passthru = {
withPackages =
ps:
@ -139,9 +168,10 @@ buildNpmPackage rec {
meta = {
description = "Pluggable natural language linter for text and markdown";
homepage = "https://github.com/textlint/textlint";
changelog = "https://github.com/textlint/textlint/blob/${src.rev}/CHANGELOG.md";
changelog = "https://github.com/textlint/textlint/blob/${finalAttrs.src.tag}/CHANGELOG.md";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [ natsukium ];
mainProgram = "textlint";
platforms = nodejs-slim.meta.platforms;
};
}
})

View File

@ -0,0 +1,14 @@
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 1f0e8f8b..68a9c06a 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -4,9 +4,6 @@ settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
-overrides:
- '@textlint/ast-node-types': workspace:*
-
importers:
.:

View File

@ -1,19 +0,0 @@
diff --git a/package.json b/package.json
index 9dd7fdc6..c5e74f88 100644
--- a/package.json
+++ b/package.json
@@ -56,12 +56,8 @@
"trailingComma": "none"
},
"workspaces": [
- "packages/*",
- "examples/*",
- "packages/@textlint/*",
- "packages/textlint-scripts/examples/*",
- "test/*",
- "website"
+ "packages/textlint",
+ "packages/@textlint/*"
],
"packageManager": "npm@9.9.2"
}