pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

npm.mk: try to do less work in update-cache



Module Name:	pkgsrc-wip
Committed By:	Thomas Klausner <wiz%NetBSD.org@localhost>
Pushed By:	wiz
Date:		Mon Dec 29 13:12:53 2025 +0100
Changeset:	f241019f05b66267d19f31f8d6971009197dd317

Modified Files:
	prettier/npm.mk

Log Message:
npm.mk: try to do less work in update-cache

Doesn't help for node-re2 because it builds during install either way
but that seems to be install-from-cache's fault (and node-re2's for
using that).

Avoid 'configure' dependency, but 'update-cache' still needs to be run
with an unpacked source tree, not sure on which target to hang this.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=f241019f05b66267d19f31f8d6971009197dd317

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 prettier/npm.mk | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diffs:
diff --git a/prettier/npm.mk b/prettier/npm.mk
index 40fc94c8de..d8bc75d378 100644
--- a/prettier/npm.mk
+++ b/prettier/npm.mk
@@ -21,8 +21,8 @@ post-extract:
 
 # install dependencies from the cache
 do-build:
-	cd ${WRKSRC} && ${SETENV} ${INSTALL_ENV} npm config set cache=${WRKDIR}/npmcache
-	cd ${WRKSRC} && ${SETENV} ${INSTALL_ENV} npm ci --no-audit --no-fund
+	cd ${WRKSRC} && ${SETENV} ${BUILD_ENV} npm config set cache=${WRKDIR}/npmcache
+	cd ${WRKSRC} && ${SETENV} ${BUILD_ENV} npm ci --no-audit --no-fund
 
 # install the project into ${DESTDIR}
 # but this uses symlinks, so replace symlink with files
@@ -37,9 +37,11 @@ ALLOW_NETWORK_ACCESS=	yes
 .endif
 
 .PHONY: update-cache
-update-cache: configure
+update-cache:
 	${RM} -rf ${WRKDIR}/npmcache
+	${RM} -rf ${WRKSRC}/node_modules
 	cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} npm config set cache=${WRKDIR}/npmcache
+	cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} npm cache clean --force
 # use node-shrinkwrap.json to wire down dependencies
 # make one if it doesn't exist, but prefer upstream package-lock.json to re-creating it
 # directly calling 'npm shrinkwrap' doesn't work reliably
@@ -51,7 +53,9 @@ update-cache: configure
 		${MKDIR} ${FILESDIR} || ${TRUE}; \
 		${CP} ${WRKSRC}/npm-shrinkwrap.json ${FILESDIR}/; \
 	fi
-	cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} npm install --no-fund --no-audit
+	cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} npm install --no-fund --no-audit --dry-run > ${WRKDIR}/npm-dependencies
+	sed -En 's,add (.*) (.*),npm cache add \1@\2,p' ${WRKDIR}/npm-dependencies > ${WRKDIR}/npm-dependencies.commands
+	cd ${WRKSRC} && ${SETENV} ${MAKE_ENV} ${SH} ${WRKDIR}/npm-dependencies.commands
 	cd ${WRKDIR} && ${SETENV} ${MAKE_ENV} tar -czf ${DISTNAME}-dependencies.tar.gz npmcache/_cacache
 	${ECHO} new tarball in ${WRKDIR}/${DISTNAME}-dependencies.tar.gz - please check it and move it to ${DISTDIR}
 	${ECHO} then add it to DISTFILES and re-generate the distinfo file, and upload it for other users


Home | Main Index | Thread Index | Old Index