From 2740a7ca7f5568a2abe7b36d561bcd890bca498b Mon Sep 17 00:00:00 2001 From: Achal Talati Date: Fri, 5 Jul 2024 13:25:20 +0530 Subject: [PATCH 1/3] pre-commit hook to check internal artifactory url --- vscode/esbuild.js | 22 ++++++++++++++++++++-- vscode/package.json | 5 +++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/vscode/esbuild.js b/vscode/esbuild.js index 5023fa6e..c06a1538 100644 --- a/vscode/esbuild.js +++ b/vscode/esbuild.js @@ -1,4 +1,6 @@ const { build } = require("esbuild"); +const fs = require('fs'); +const path = require('path'); const baseConfig = { bundle: true, @@ -28,7 +30,21 @@ const watchConfig = { }, }, }; - + +const NON_NPM_ARTIFACTORY = new RegExp( + String.raw`"resolved": "(?!https://registry.npmjs.org).*"`, + "g" +); + +const checkAritfactoryUrl = () => { + const data = fs.readFileSync(path.resolve(__dirname, 'package-lock.json'), { encoding: 'utf-8' }); + if (NON_NPM_ARTIFACTORY.test(data)) { + throw new Error("Found references to the internal registry in the file package-lock.json. Please fix it"); + } else { + console.log('No internal artifactory references found.'); + } +} + (async () => { const args = process.argv.slice(2); try { @@ -40,13 +56,15 @@ const watchConfig = { ...watchConfig, }); console.log("[watch] build finished"); + } else if(args.includes("--artifactory-check")){ + checkAritfactoryUrl(); } else { // Build source code await build(scriptConfig); console.log("build complete"); } } catch (err) { - process.stderr.write(err.stderr); + process.stderr.write(err.message); process.exit(1); } })(); \ No newline at end of file diff --git a/vscode/package.json b/vscode/package.json index 1354f380..9639a75c 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -760,8 +760,9 @@ "test": "node ./out/test/runTest.js", "nbcode": "node ./out/nbcode.js", "nbjavac": "node ./out/nbcode.js -J-Dnetbeans.close=true --modules --install .*nbjavac.*", - "apisupport": "node ./out/nbcode.js -J-Dnetbeans.close=true --modules --install '(org.netbeans.libs.xerces|org.netbeans.modules.editor.structure|org.netbeans.modules.xml|org.netbeans.modules.xml.axi|org.netbeans.modules.xml.retriever|org.netbeans.modules.xml.schema.model|org.netbeans.modules.xml.tax|org.netbeans.modules.xml.text|org.netbeans.modules.ant.browsetask|.*apisupport.*|org.netbeans.modules.debugger.jpda.ant)' && node ./out/nbcode.js -J-Dnetbeans.close=true --modules --enable .*apisupport.ant" - }, + "apisupport": "node ./out/nbcode.js -J-Dnetbeans.close=true --modules --install '(org.netbeans.libs.xerces|org.netbeans.modules.editor.structure|org.netbeans.modules.xml|org.netbeans.modules.xml.axi|org.netbeans.modules.xml.retriever|org.netbeans.modules.xml.schema.model|org.netbeans.modules.xml.tax|org.netbeans.modules.xml.text|org.netbeans.modules.ant.browsetask|.*apisupport.*|org.netbeans.modules.debugger.jpda.ant)' && node ./out/nbcode.js -J-Dnetbeans.close=true --modules --enable .*apisupport.ant", + "artifactory:check": "node ./esbuild.js --artifactory-check" + }, "devDependencies": { "@types/glob": "^7.1.1", "@types/mocha": "^9.0.0", From e1e9eb9ca151dc8cc2e632d1238bfb7f55ef3a77 Mon Sep 17 00:00:00 2001 From: Achal Talati Date: Wed, 31 Jul 2024 15:30:55 +0530 Subject: [PATCH 2/3] updated regex --- vscode/esbuild.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode/esbuild.js b/vscode/esbuild.js index c06a1538..0ca6e24f 100644 --- a/vscode/esbuild.js +++ b/vscode/esbuild.js @@ -32,7 +32,7 @@ const watchConfig = { }; const NON_NPM_ARTIFACTORY = new RegExp( - String.raw`"resolved": "(?!https://registry.npmjs.org).*"`, + String.raw`(")resolved\1\s*:\s*(")http[s]*://(?!registry.npmjs.org)[^"']+\2`, "g" ); From c5c0a6ff90cffea115cc00b81d8f5cbefec5b09f Mon Sep 17 00:00:00 2001 From: Achal Talati Date: Wed, 31 Jul 2024 21:01:36 +0530 Subject: [PATCH 3/3] updated regex --- vscode/esbuild.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vscode/esbuild.js b/vscode/esbuild.js index 0ca6e24f..3b07eafe 100644 --- a/vscode/esbuild.js +++ b/vscode/esbuild.js @@ -32,7 +32,7 @@ const watchConfig = { }; const NON_NPM_ARTIFACTORY = new RegExp( - String.raw`(")resolved\1\s*:\s*(")http[s]*://(?!registry.npmjs.org)[^"']+\2`, + String.raw`"resolved"\s*:\s*"http[s]*://(?!registry.npmjs.org)[^"]+"`, "g" );