diff --git a/.config/rollup.dist.config.mjs b/.config/rollup.dist.config.mjs index 12f471e73..caa36da56 100644 --- a/.config/rollup.dist.config.mjs +++ b/.config/rollup.dist.config.mjs @@ -9,11 +9,11 @@ import commonjsPlugin from '@rollup/plugin-commonjs' import jsonPlugin from '@rollup/plugin-json' import { nodeResolve } from '@rollup/plugin-node-resolve' import { glob as tinyGlob } from 'tinyglobby' +import trash from 'trash' import { isDirEmptySync, readJson, - remove, writeJson, } from '@socketsecurity/registry/lib/fs' import { hasKeys, toSortedObject } from '@socketsecurity/registry/lib/objects' @@ -41,8 +41,8 @@ const { NODE_MODULES, NODE_MODULES_GLOB_RECURSIVE, ROLLUP_EXTERNAL_SUFFIX, - SHADOW_BIN, - SHADOW_INJECT, + SHADOW_NPM_BIN, + SHADOW_NPM_INJECT, SLASH_NODE_MODULES_SLASH, SOCKET_CLI_BIN_NAME, SOCKET_CLI_BIN_NAME_ALIAS, @@ -62,7 +62,7 @@ const { const BLESSED = 'blessed' const BLESSED_CONTRIB = 'blessed-contrib' const COANA_TECH_CLI = '@coana-tech/cli' -const EXTERNAL = 'external' +const LICENSE_MD = `LICENSE.md` const SENTRY_NODE = '@sentry/node' const SOCKET_DESCRIPTION = 'CLI for Socket.dev' const SOCKET_DESCRIPTION_WITH_SENTRY = `${SOCKET_DESCRIPTION}, includes Sentry error handling, otherwise identical to the regular \`${SOCKET_CLI_BIN_NAME}\` package` @@ -85,6 +85,77 @@ async function copyBashCompletion() { await fs.copyFile(filepath, destPath) } +async function copyExternalPackages() { + // Lazily access constants path properties. + const { blessedContribPath, blessedPath, coanaPath, socketRegistryPath } = + constants + const nmPath = path.join(constants.rootPath, NODE_MODULES) + const blessedContribNmPath = path.join(nmPath, BLESSED_CONTRIB) + + // Copy package folders. + await Promise.all([ + ...EXTERNAL_PACKAGES + // Skip copying 'blessed-contrib' over because we already + // have it bundled as ./external/blessed-contrib. + .filter(n => n !== BLESSED_CONTRIB) + // Copy the other packages over to ./external/. + .map(n => + copyPackage(n, { + strict: + // Skip adding 'use strict' directives to Coana and + // Socket packages. + n !== COANA_TECH_CLI && n !== SOCKET_SECURITY_REGISTRY, + }), + ), + // Copy 'blessed-contrib' license over to + // ./external/blessed-contrib/LICENSE.md. + await fs.cp( + `${blessedContribNmPath}/${LICENSE_MD}`, + `${blessedContribPath}/${LICENSE_MD}`, + ), + ]) + // Cleanup package files. + await Promise.all( + [ + [blessedPath, ['lib/**/*.js', 'usr/**/**', 'vendor/**/*.js', 'LICENSE*']], + [blessedContribPath, ['lib/**/*.js', 'index.js', 'LICENSE*']], + [coanaPath, ['**/*.mjs']], + [ + socketRegistryPath, + [ + 'external/**/*.js', + 'lib/**/*.js', + 'index.js', + 'extensions.json', + 'manifest.json', + 'LICENSE*', + ], + ], + ].map(async ({ 0: thePath, 1: ignorePatterns }) => { + await removeFiles(thePath, { exclude: ignorePatterns }) + await removeEmptyDirs(thePath) + }), + ) + // Rewire 'blessed' inside 'blessed-contrib'. + await Promise.all( + ( + await tinyGlob(['**/*.js'], { + absolute: true, + cwd: blessedContribPath, + ignore: [NODE_MODULES_GLOB_RECURSIVE], + }) + ).map(async p => { + const relPath = path.relative(path.dirname(p), blessedPath) + const content = await fs.readFile(p, 'utf8') + const modded = content.replace( + /(?<=require\(["'])blessed(?=(?:\/[^"']+)?["']\))/g, + () => relPath, + ) + await fs.writeFile(p, modded, 'utf8') + }), + ) +} + async function copyPackage(pkgName, options) { const { strict = true } = { __proto__: null, ...options } // Lazily access constants path properties. @@ -217,37 +288,32 @@ async function updatePackageLockFile() { } async function removeEmptyDirs(thePath) { - const dirPaths = ( - await tinyGlob(['**/'], { - ignore: [NODE_MODULES_GLOB_RECURSIVE], - absolute: true, - cwd: thePath, - onlyDirectories: true, - }) + await trash( + ( + await tinyGlob(['**/'], { + ignore: [NODE_MODULES_GLOB_RECURSIVE], + absolute: true, + cwd: thePath, + onlyDirectories: true, + }) + ) + // Sort directory paths longest to shortest. + .sort((a, b) => b.length - a.length) + .filter(isDirEmptySync), ) - // Sort directory paths longest to shortest. - .sort((a, b) => b.length - a.length) - for (const dirPath of dirPaths) { - if (isDirEmptySync(dirPath)) { - // eslint-disable-next-line no-await-in-loop - await remove(dirPath) - } - } } async function removeFiles(thePath, options) { const { exclude } = { __proto__: null, ...options } const ignore = Array.isArray(exclude) ? exclude : exclude ? [exclude] : [] - return await Promise.all( - ( - await tinyGlob(['**/*'], { - absolute: true, - onlyFiles: true, - cwd: thePath, - dot: true, - ignore, - }) - ).map(p => remove(p)), + return await trash( + await tinyGlob(['**/*'], { + absolute: true, + onlyFiles: true, + cwd: thePath, + dot: true, + ignore, + }), ) } @@ -289,9 +355,9 @@ function resetDependencies(deps) { export default async () => { // Lazily access constants path properties. - const { configPath, distPath, externalPath, rootPath, srcPath } = constants + const { configPath, distPath, rootPath, srcPath } = constants const constantsSrcPath = path.join(srcPath, `constants.mts`) - const externalSrcPath = path.join(srcPath, EXTERNAL) + const externalSrcPath = path.join(srcPath, 'external') const nmPath = path.join(rootPath, NODE_MODULES) const shadowNpmBinSrcPath = path.join(srcPath, 'shadow/npm/bin.mts') const shadowNpmInjectSrcPath = path.join(srcPath, 'shadow/npm/inject.mts') @@ -356,8 +422,8 @@ export default async () => { input: { cli: `${srcPath}/cli.mts`, [CONSTANTS]: `${srcPath}/constants.mts`, - [SHADOW_BIN]: `${srcPath}/shadow/npm/bin.mts`, - [SHADOW_INJECT]: `${srcPath}/shadow/npm/inject.mts`, + [SHADOW_NPM_BIN]: `${srcPath}/shadow/npm/bin.mts`, + [SHADOW_NPM_INJECT]: `${srcPath}/shadow/npm/inject.mts`, // Lazily access constants.ENV[INLINED_SOCKET_CLI_SENTRY_BUILD]. ...(constants.ENV[INLINED_SOCKET_CLI_SENTRY_BUILD] ? { @@ -379,9 +445,9 @@ export default async () => { case constantsSrcPath: return CONSTANTS case shadowNpmBinSrcPath: - return SHADOW_BIN + return SHADOW_NPM_BIN case shadowNpmInjectSrcPath: - return SHADOW_INJECT + return SHADOW_NPM_INJECT default: if (id.startsWith(utilsSrcPath)) { return UTILS @@ -429,72 +495,10 @@ export default async () => { copyInitGradle(), copyBashCompletion(), updatePackageJson(), - remove(path.join(distPath, `${VENDOR}.js.map`)), - ...EXTERNAL_PACKAGES.map(n => - copyPackage(n, { - strict: - n !== COANA_TECH_CLI && n !== SOCKET_SECURITY_REGISTRY, - }), - ), + // Remove dist/vendor.js.map file. + trash([path.join(distPath, `${VENDOR}.js.map`)]), + copyExternalPackages(), ]) - - const blessedExternalPath = path.join(externalPath, BLESSED) - const blessedContribExternalPath = path.join( - externalPath, - BLESSED_CONTRIB, - ) - const filesEntries = [ - [ - blessedExternalPath, - ['lib/**/*.js', 'usr/**/**', 'vendor/**/*.js', 'LICENSE*'], - ], - [ - blessedContribExternalPath, - ['lib/**/*.js', 'index.js', 'LICENSE*'], - ], - [path.join(externalPath, COANA_TECH_CLI), ['**/*.mjs']], - [ - path.join(externalPath, SOCKET_SECURITY_REGISTRY), - [ - 'external/**/*.js', - 'lib/**/*.js', - 'index.js', - 'extensions.json', - 'manifest.json', - 'LICENSE*', - ], - ], - ] - - await Promise.all( - filesEntries.map(async ({ 0: thePath, 1: ignorePatterns }) => { - await removeFiles(thePath, { exclude: ignorePatterns }) - await removeEmptyDirs(thePath) - }), - ) - - // Rewire 'blessed' inside 'blessed-contrib'. - await Promise.all( - ( - await tinyGlob(['**/*.js'], { - absolute: true, - cwd: blessedContribExternalPath, - ignore: [NODE_MODULES_GLOB_RECURSIVE], - }) - ).map(async p => { - const relPath = path.relative( - path.dirname(p), - blessedExternalPath, - ) - const content = await fs.readFile(p, 'utf8') - const modded = content.replace( - /(?<=require\(["'])blessed(?=(?:\/[^"']+)?["']\))/g, - () => relPath, - ) - await fs.writeFile(p, modded, 'utf8') - }), - ) - // Update package-lock.json AFTER package.json. await updatePackageLockFile() }, diff --git a/bin/cli.js b/bin/cli.js index 63229faaf..c6e0f3d81 100755 --- a/bin/cli.js +++ b/bin/cli.js @@ -28,8 +28,8 @@ spawn( ...(constants.ENV.INLINED_SOCKET_CLI_SENTRY_BUILD ? [ '--require', - // Lazily access constants.distInstrumentWithSentryPath. - constants.distInstrumentWithSentryPath, + // Lazily access constants.instrumentWithSentryPath. + constants.instrumentWithSentryPath, ] : []), // Lazily access constants.distCliPath. diff --git a/package-lock.json b/package-lock.json index 7b9c87ec1..f84541301 100644 --- a/package-lock.json +++ b/package-lock.json @@ -100,6 +100,7 @@ "terminal-link": "2.1.1", "tiny-updater": "3.5.3", "tinyglobby": "0.2.14", + "trash": "9.0.0", "type-coverage": "2.29.7", "typescript-eslint": "8.33.1", "unplugin-purge-polyfills": "0.1.0", @@ -4065,6 +4066,118 @@ "node": "^18.17.0 || >=20.5.0" } }, + "node_modules/@sindresorhus/chunkify": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@sindresorhus/chunkify/-/chunkify-1.0.0.tgz", + "integrity": "sha512-YJOcVaEasXWcttXetXn0jd6Gtm9wFHQ1gViTPcxhESwkMCOoA4kwFsNr9EGcmsARGx7jXQZWmOR4zQotRcI9hw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@sindresorhus/df": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/@sindresorhus/df/-/df-3.1.1.tgz", + "integrity": "sha512-SME/vtXaJcnQ/HpeV6P82Egy+jThn11IKfwW8+/XVoRD0rmPHVTeKMtww1oWdVnMykzVPjmrDN9S8NBndPEHCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "execa": "^2.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sindresorhus/df/node_modules/execa": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-2.1.0.tgz", + "integrity": "sha512-Y/URAVapfbYy2Xp/gb6A0E7iR8xeqOCXsuuaoMn7A5PzrXUK84E1gyiEfq0wQd/GHA6GsoHWwhNq8anb0mleIw==", + "dev": true, + "license": "MIT", + "dependencies": { + "cross-spawn": "^7.0.0", + "get-stream": "^5.0.0", + "is-stream": "^2.0.0", + "merge-stream": "^2.0.0", + "npm-run-path": "^3.0.0", + "onetime": "^5.1.0", + "p-finally": "^2.0.0", + "signal-exit": "^3.0.2", + "strip-final-newline": "^2.0.0" + }, + "engines": { + "node": "^8.12.0 || >=9.7.0" + } + }, + "node_modules/@sindresorhus/df/node_modules/get-stream": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-5.2.0.tgz", + "integrity": "sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA==", + "dev": true, + "license": "MIT", + "dependencies": { + "pump": "^3.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@sindresorhus/df/node_modules/is-stream": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.1.tgz", + "integrity": "sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@sindresorhus/df/node_modules/npm-run-path": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-3.1.0.tgz", + "integrity": "sha512-Dbl4A/VfiVGLgQv29URL9xshU8XDY1GeLy+fsaZ1AA8JDSfjvr5P5+pzRbWqRSBxk6/DW7MIh8lTM/PaGnP2kg==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/@sindresorhus/df/node_modules/onetime": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/onetime/-/onetime-5.1.2.tgz", + "integrity": "sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "mimic-fn": "^2.1.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@sindresorhus/df/node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==", + "dev": true, + "license": "ISC" + }, "node_modules/@sindresorhus/is": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/@sindresorhus/is/-/is-7.0.1.tgz", @@ -4172,6 +4285,16 @@ "node": "18.20.7 || ^20.18.3 || >=22.14.0" } }, + "node_modules/@stroncium/procfs": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@stroncium/procfs/-/procfs-1.2.1.tgz", + "integrity": "sha512-X1Iui3FUNZP18EUvysTHxt+Avu2nlVzyf90YM8OYgP6SGzTzzX/0JgObfO1AQQDzuZtNNz29bVh8h5R97JrjxA==", + "dev": true, + "license": "CC0-1.0", + "engines": { + "node": ">=8" + } + }, "node_modules/@szmarczak/http-timer": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-5.0.1.tgz", @@ -5510,6 +5633,29 @@ "dev": true, "license": "Python-2.0" }, + "node_modules/array-union": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-union/-/array-union-1.0.2.tgz", + "integrity": "sha512-Dxr6QJj/RdU/hCaBjOfxW+q6lyuVE6JFWIrAUpuOOhoJJoQ99cUn3igRaHVB5P9WrgFVN0FfArM3x0cueOU8ng==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-uniq": "^1.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/array-uniq": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/array-uniq/-/array-uniq-1.0.3.tgz", + "integrity": "sha512-MNha4BWQ6JbwhFhj03YK552f7cb3AzoE8SzeljgChvL1dl3IcvggXVz1DilzySZkCja+CXuZbdW7yATchWn8/Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/arrify": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz", @@ -8397,6 +8543,42 @@ "node": ">=0.3.1" } }, + "node_modules/dir-glob": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-2.2.2.tgz", + "integrity": "sha512-f9LBi5QWzIW3I6e//uxZoLBlUt9kcp66qo0sSCxL6YZKc75R1c4MFCoe/LaZiBGmgujvQdxc5Bn3QhfyvK5Hsw==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-type": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/dir-glob/node_modules/path-type": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", + "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", + "dev": true, + "license": "MIT", + "dependencies": { + "pify": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/dir-glob/node_modules/pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/dom-serializer": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-2.0.0.tgz", @@ -8622,7 +8804,6 @@ "integrity": "sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==", "dev": true, "license": "MIT", - "optional": true, "dependencies": { "once": "^1.4.0" } @@ -9980,8 +10161,7 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==", "dev": true, - "license": "ISC", - "optional": true + "license": "ISC" }, "node_modules/fsevents": { "version": "2.3.3", @@ -10792,7 +10972,6 @@ "deprecated": "This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.", "dev": true, "license": "ISC", - "optional": true, "dependencies": { "once": "^1.3.0", "wrappy": "1" @@ -12452,6 +12631,47 @@ "node": "*" } }, + "node_modules/mount-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/mount-point/-/mount-point-3.0.0.tgz", + "integrity": "sha512-jAhfD7ZCG+dbESZjcY1SdFVFqSJkh/yGbdsifHcPkvuLRO5ugK0Ssmd9jdATu29BTd4JiN+vkpMzVvsUgP3SZA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sindresorhus/df": "^1.0.1", + "pify": "^2.3.0", + "pinkie-promise": "^2.0.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/mount-point/node_modules/@sindresorhus/df": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@sindresorhus/df/-/df-1.0.1.tgz", + "integrity": "sha512-1Hyp7NQnD/u4DSxR2DGW78TF9k7R0wZ8ev0BpMAIzA6yTQSHqNb5wTuvtcPYf4FWbVse2rW7RgDsyL8ua2vXHw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/move-file": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/move-file/-/move-file-3.1.0.tgz", + "integrity": "sha512-4aE3U7CCBWgrQlQDMq8da4woBWDGHioJFiOZ8Ie6Yq2uwYQ9V2kGhTz4x3u6Wc+OU17nw0yc3rJ/lQ4jIiPe3A==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-exists": "^5.0.0" + }, + "engines": { + "node": "^12.20.0 || ^14.13.1 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -12995,7 +13215,6 @@ "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", "dev": true, "license": "ISC", - "optional": true, "dependencies": { "wrappy": "1" } @@ -13063,6 +13282,16 @@ "node": ">= 0.8.0" } }, + "node_modules/os-homedir": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/os-homedir/-/os-homedir-1.0.2.tgz", + "integrity": "sha512-B5JU3cabzk8c67mRRd3ECmROafjYMXbuzlwtqdM8IbS8ktlTix8aFGb2bAGKrSRIlnfKwovGUUr72JUPyOb6kQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/outvariant": { "version": "1.4.3", "resolved": "https://registry.npmjs.org/outvariant/-/outvariant-1.4.3.tgz", @@ -13132,6 +13361,16 @@ "node": ">=14.16" } }, + "node_modules/p-finally": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-2.0.1.tgz", + "integrity": "sha512-vpm09aKwq6H9phqRQzecoDpD8TmVyGw70qmWlyq5onxY7tqyTTFVvxMykxQSQKILBSFlbXpypIw2T1Ml7+DDtw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, "node_modules/p-limit": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz", @@ -13456,7 +13695,6 @@ "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", "dev": true, "license": "MIT", - "optional": true, "engines": { "node": ">=0.10.0" } @@ -13608,6 +13846,39 @@ "node": ">=0.10" } }, + "node_modules/pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha512-udgsAY+fTnvv7kI7aaxbqwWNb0AHiB0qBO89PZKPkoTmGOgdbrHDKD+0B2X4uTfJ/FT1R09r9gTsjUjNJotuog==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pinkie": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/pinkie/-/pinkie-2.0.4.tgz", + "integrity": "sha512-MnUuEycAemtSaeFSjXKW/aroV7akBbY+Sv+RkyqFjgAe73F+MR0TBWKBRDkmfWq/HiFmdavfZ1G7h4SPZXaCSg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/pinkie-promise": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/pinkie-promise/-/pinkie-promise-2.0.1.tgz", + "integrity": "sha512-0Gni6D4UcLTbv9c57DfxDGdr41XfgUjqWZu492f0cIGr16zDU06BWP/RAEvOuo7CQ0CNjHaLlM59YJJFm3NWlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "pinkie": "^2.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/pkg-types": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-1.3.1.tgz", @@ -13828,7 +14099,6 @@ "integrity": "sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==", "dev": true, "license": "MIT", - "optional": true, "dependencies": { "end-of-stream": "^1.1.0", "once": "^1.3.1" @@ -16358,6 +16628,119 @@ "license": "MIT", "optional": true }, + "node_modules/trash": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/trash/-/trash-9.0.0.tgz", + "integrity": "sha512-6U3A0olN4C16iiPZvoF93AcZDNZtv/nI2bHb2m/sO3h/m8VPzg9tPdd3n3LVcYLWz7ui0AHaXYhIuRjzGW9ptg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sindresorhus/chunkify": "^1.0.0", + "@stroncium/procfs": "^1.2.1", + "globby": "^7.1.1", + "is-path-inside": "^4.0.0", + "move-file": "^3.1.0", + "p-map": "^7.0.2", + "xdg-trashdir": "^3.1.0" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/trash/node_modules/brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "node_modules/trash/node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "deprecated": "Glob versions prior to v9 are no longer supported", + "dev": true, + "license": "ISC", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/trash/node_modules/globby": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/globby/-/globby-7.1.1.tgz", + "integrity": "sha512-yANWAN2DUcBtuus5Cpd+SKROzXHs2iVXFZt/Ykrfz6SAXqacLX25NZpltE+39ceMexYF4TtEadjuSTw8+3wX4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-union": "^1.0.1", + "dir-glob": "^2.0.0", + "glob": "^7.1.2", + "ignore": "^3.3.5", + "pify": "^3.0.0", + "slash": "^1.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/trash/node_modules/ignore": { + "version": "3.3.10", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-3.3.10.tgz", + "integrity": "sha512-Pgs951kaMm5GXP7MOvxERINe3gsaVjUWFm+UZPSq9xYriQAksyhg0csnS0KXSNRD5NmNdapXEpjxG49+AKh/ug==", + "dev": true, + "license": "MIT" + }, + "node_modules/trash/node_modules/minimatch": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz", + "integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^1.1.7" + }, + "engines": { + "node": "*" + } + }, + "node_modules/trash/node_modules/pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/trash/node_modules/slash": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-1.0.0.tgz", + "integrity": "sha512-3TYDR7xWt4dIqV2JauJr+EJeW356RXijHeUlO+8djJ+uBXPn8/2dpzBc8yQhh583sVvc9CvFAeQVgijsH+PNNg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/treeverse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/treeverse/-/treeverse-3.0.0.tgz", @@ -16830,6 +17213,19 @@ "punycode": "^2.1.0" } }, + "node_modules/user-home": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/user-home/-/user-home-2.0.0.tgz", + "integrity": "sha512-KMWqdlOcjCYdtIJpicDSFBQ8nFwS2i9sslAd6f4+CBGcU4gist2REnr2fxj2YocvJFxSF3ZOHLYLVZnUxv4BZQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "os-homedir": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -17430,8 +17826,7 @@ "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==", "dev": true, - "license": "ISC", - "optional": true + "license": "ISC" }, "node_modules/write-file-atomic": { "version": "5.0.1", @@ -17457,6 +17852,32 @@ "node": ">=0.4.0" } }, + "node_modules/xdg-basedir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/xdg-basedir/-/xdg-basedir-4.0.0.tgz", + "integrity": "sha512-PSNhEJDejZYV7h50BohL09Er9VaIefr2LMAf3OEmpCkjOi34eYyQYAXUTjEQtZJTKcF0E2UKTh+osDLsgNim9Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/xdg-trashdir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/xdg-trashdir/-/xdg-trashdir-3.1.0.tgz", + "integrity": "sha512-N1XQngeqMBoj9wM4ZFadVV2MymImeiFfYD+fJrNlcVcOHsJFFQe7n3b+aBoTPwARuq2HQxukfzVpQmAk1gN4sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@sindresorhus/df": "^3.1.1", + "mount-point": "^3.0.0", + "user-home": "^2.0.0", + "xdg-basedir": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/xml-js": { "version": "1.6.11", "resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.11.tgz", diff --git a/package.json b/package.json index 85a616fca..56d362a72 100644 --- a/package.json +++ b/package.json @@ -163,6 +163,7 @@ "terminal-link": "2.1.1", "tiny-updater": "3.5.3", "tinyglobby": "0.2.14", + "trash": "9.0.0", "type-coverage": "2.29.7", "typescript-eslint": "8.33.1", "unplugin-purge-polyfills": "0.1.0", diff --git a/scripts/constants.js b/scripts/constants.js index 6e103e04e..576f61e0a 100644 --- a/scripts/constants.js +++ b/scripts/constants.js @@ -24,8 +24,8 @@ const INLINED_SOCKET_CLI_VERSION_HASH = 'INLINED_SOCKET_CLI_VERSION_HASH' const INLINED_SYNP_VERSION = 'INLINED_SYNP_VERSION' const INSTRUMENT_WITH_SENTRY = 'instrument-with-sentry' const ROLLUP_EXTERNAL_SUFFIX = '?commonjs-external' -const SHADOW_BIN = 'shadow-bin' -const SHADOW_INJECT = 'shadow-inject' +const SHADOW_NPM_BIN = 'shadow-npm-bin' +const SHADOW_NPM_INJECT = 'shadow-npm-inject' const SLASH_NODE_MODULES_SLASH = '/node_modules/' const SOCKET = 'socket' const SOCKET_CLI_BIN_NAME = 'socket' @@ -64,6 +64,22 @@ const LAZY_ENV = () => { }) } +const lazyBlessedContribPath = () => + // Lazily access constants.externalPath. + path.join(constants.externalPath, 'blessed-contrib') + +const lazyBlessedPath = () => + // Lazily access constants.externalPath. + path.join(constants.externalPath, 'blessed') + +const lazyCoanaBinPath = () => + // Lazily access constants.coanaPath. + path.join(constants.coanaPath, 'cli.mjs') + +const lazyCoanaPath = () => + // Lazily access constants.externalPath. + path.join(constants.externalPath, '@coana-tech/cli') + const lazyConfigPath = () => // Lazily access constants.rootPath. path.join(constants.rootPath, '.config') @@ -86,6 +102,10 @@ const lazyRootPackageLockPath = () => const lazyRootPath = () => path.resolve(__dirname, '..') +const lazySocketRegistryPath = () => + // Lazily access constants.externalPath. + path.join(constants.externalPath, '@socketsecurity/registry') + const lazySrcPath = () => // Lazily access constants.rootPath. path.join(constants.rootPath, 'src') @@ -106,8 +126,8 @@ const constants = createConstantsObject( INLINED_SYNP_VERSION, INSTRUMENT_WITH_SENTRY, ROLLUP_EXTERNAL_SUFFIX, - SHADOW_BIN, - SHADOW_INJECT, + SHADOW_NPM_BIN, + SHADOW_NPM_INJECT, SLASH_NODE_MODULES_SLASH, SOCKET, SOCKET_CLI_BIN_NAME, @@ -124,23 +144,34 @@ const constants = createConstantsObject( UTILS, VENDOR, WITH_SENTRY, + blessedContribPath: undefined, + blessedOptions: undefined, + blessedPath: undefined, + coanaBinPath: undefined, + coanaPath: undefined, configPath: undefined, distPath: undefined, externalPath: undefined, rootPackageJsonPath: undefined, rootPath: undefined, + socketRegistryPath: undefined, srcPath: undefined, }, { getters: { ...registryConstantsAttribs.getters, ENV: LAZY_ENV, + blessedContribPath: lazyBlessedContribPath, + blessedPath: lazyBlessedPath, + coanaBinPath: lazyCoanaBinPath, + coanaPath: lazyCoanaPath, configPath: lazyConfigPath, distPath: lazyDistPath, externalPath: lazyExternalPath, rootPackageJsonPath: lazyRootPackageJsonPath, rootPackageLockPath: lazyRootPackageLockPath, rootPath: lazyRootPath, + socketRegistryPath: lazySocketRegistryPath, srcPath: lazySrcPath, }, }, diff --git a/src/commands/npm/cmd-npm.mts b/src/commands/npm/cmd-npm.mts index ea3b08dc3..62833a137 100644 --- a/src/commands/npm/cmd-npm.mts +++ b/src/commands/npm/cmd-npm.mts @@ -49,7 +49,7 @@ async function run( return } - // Lazily access constants.distShadowBinPath. - const shadowBin = require(constants.distShadowBinPath) + // Lazily access constants.shadowNpmBinPath. + const shadowBin = require(constants.shadowNpmBinPath) await shadowBin('npm', argv) } diff --git a/src/commands/npx/cmd-npx.mts b/src/commands/npx/cmd-npx.mts index bdb283105..ac19aa03a 100644 --- a/src/commands/npx/cmd-npx.mts +++ b/src/commands/npx/cmd-npx.mts @@ -49,7 +49,7 @@ async function run( return } - // Lazily access constants.distShadowBinPath. - const shadowBin = require(constants.distShadowBinPath) + // Lazily access constants.shadowNpmBinPath. + const shadowBin = require(constants.shadowNpmBinPath) await shadowBin('npx', argv) } diff --git a/src/constants.mts b/src/constants.mts index d7b8ef164..087f53799 100644 --- a/src/constants.mts +++ b/src/constants.mts @@ -107,8 +107,8 @@ type Constants = Remap< readonly NPM_REGISTRY_URL: 'https://registry.npmjs.org' readonly PNPM: 'pnpm' readonly REDACTED: '' - readonly SHADOW_BIN: 'shadow-bin' - readonly SHADOW_INJECT: 'shadow-inject' + readonly SHADOW_NPM_BIN: 'shadow-npm-bin' + readonly SHADOW_NPM_INJECT: 'shadow-npm-inject' readonly SOCKET: 'socket' readonly SOCKET_CLI_ACCEPT_RISKS: 'SOCKET_CLI_ACCEPT_RISKS' readonly SOCKET_CLI_BIN_NAME: 'socket' @@ -139,27 +139,31 @@ type Constants = Remap< readonly bashRcPath: string readonly binCliPath: string readonly binPath: string + readonly blessedContribPath: string readonly blessedOptions: { smartCSR: boolean term: string useBCE: boolean } + readonly blessedPath: string readonly coanaBinPath: string + readonly coanaPath: string readonly distCliPath: string - readonly distInstrumentWithSentryPath: string readonly distPath: string - readonly distShadowBinPath: string readonly externalPath: string - readonly distShadowInjectPath: string readonly githubCachePath: string readonly homePath: string + readonly instrumentWithSentryPath: string readonly minimumVersionByAgent: Map readonly nmBinPath: string readonly nodeHardenFlags: string[] readonly rootPath: string readonly shadowBinPath: string + readonly shadowNpmBinPath: string + readonly shadowNpmInjectPath: string readonly socketAppDataPath: string readonly socketCachePath: string + readonly socketRegistryPath: string readonly zshRcPath: string } > @@ -181,8 +185,8 @@ const NPM_BUGGY_OVERRIDES_PATCHED_VERSION = '11.2.0' const NPM_REGISTRY_URL = 'https://registry.npmjs.org' const PNPM = 'pnpm' const REDACTED = '' -const SHADOW_BIN = 'shadow-bin' -const SHADOW_INJECT = 'shadow-inject' +const SHADOW_NPM_BIN = 'shadow-npm-bin' +const SHADOW_NPM_INJECT = 'shadow-npm-inject' const SOCKET = 'socket' const SOCKET_CLI_ACCEPT_RISKS = 'SOCKET_CLI_ACCEPT_RISKS' const SOCKET_CLI_BIN_NAME = 'socket' @@ -371,6 +375,10 @@ const lazyBinCliPath = () => // Lazily access constants.binPath. path.join(constants.binPath, 'cli.js') +const lazyBlessedContribPath = () => + // Lazily access constants.externalPath. + path.join(constants.externalPath, 'blessed-contrib') + const lazyBlessedOptions = () => Object.freeze({ smartCSR: true, @@ -379,29 +387,25 @@ const lazyBlessedOptions = () => useBCE: true, }) -const lazyCoanaBinPath = () => +const lazyBlessedPath = () => // Lazily access constants.externalPath. - path.join(constants.externalPath, '@coana-tech/cli/cli.mjs') + path.join(constants.externalPath, 'blessed') -const lazyDistPath = () => - // Lazily access constants.rootPath. - path.join(constants.rootPath, 'dist') +const lazyCoanaBinPath = () => + // Lazily access constants.coanaPath. + path.join(constants.coanaPath, 'cli.mjs') + +const lazyCoanaPath = () => + // Lazily access constants.externalPath. + path.join(constants.externalPath, '@coana-tech/cli') const lazyDistCliPath = () => // Lazily access constants.distPath. path.join(constants.distPath, 'cli.js') -const lazyDistInstrumentWithSentryPath = () => - // Lazily access constants.distPath. - path.join(constants.distPath, 'instrument-with-sentry.js') - -const lazyDistShadowBinPath = () => - // Lazily access constants.distPath. - path.join(constants.distPath, `${SHADOW_BIN}.js`) - -const lazyDistShadowInjectPath = () => - // Lazily access constants.distPath. - path.join(constants.distPath, `${SHADOW_INJECT}.js`) +const lazyDistPath = () => + // Lazily access constants.rootPath. + path.join(constants.rootPath, 'dist') const lazyExternalPath = () => // Lazily access constants.rootPath. @@ -413,6 +417,10 @@ const lazyGithubCachePath = () => const lazyHomePath = () => os.homedir() +const lazyInstrumentWithSentryPath = () => + // Lazily access constants.distPath. + path.join(constants.distPath, 'instrument-with-sentry.js') + const lazyMinimumVersionByAgent = () => new Map([ // Bun >=1.1.39 supports the text-based lockfile. @@ -464,6 +472,18 @@ const lazyNodeHardenFlags = () => const lazyRootPath = () => path.join(realpathSync.native(__dirname), '..') +const lazyShadowBinPath = () => + // Lazily access constants.rootPath. + path.join(constants.rootPath, 'shadow-bin') + +const lazyShadowNpmBinPath = () => + // Lazily access constants.distPath. + path.join(constants.distPath, `${SHADOW_NPM_BIN}.js`) + +const lazyShadowNpmInjectPath = () => + // Lazily access constants.distPath. + path.join(constants.distPath, `${SHADOW_NPM_INJECT}.js`) + const lazySocketAppDataPath = (): string | undefined => { // Get the OS app data folder: // - Win: %LOCALAPPDATA% or fail? @@ -504,9 +524,9 @@ const lazySocketCachePath = () => // Lazily access constants.rootPath. path.join(constants.rootPath, '.cache') -const lazyShadowBinPath = () => - // Lazily access constants.rootPath. - path.join(constants.rootPath, SHADOW_BIN) +const lazySocketRegistryPath = () => + // Lazily access constants.externalPath. + path.join(constants.externalPath, '@socketsecurity/registry') const lazyZshRcPath = () => // Lazily access constants.homePath. @@ -532,8 +552,8 @@ const constants: Constants = createConstantsObject( NPM_REGISTRY_URL, PNPM, REDACTED, - SHADOW_BIN, - SHADOW_INJECT, + SHADOW_NPM_BIN, + SHADOW_NPM_INJECT, SOCKET, SOCKET_CLI_ACCEPT_RISKS, SOCKET_CLI_BIN_NAME, @@ -563,23 +583,27 @@ const constants: Constants = createConstantsObject( bashRcPath: undefined, binPath: undefined, binCliPath: undefined, + blessedContribPath: undefined, blessedOptions: undefined, + blessedPath: undefined, coanaBinPath: undefined, + coanaPath: undefined, distCliPath: undefined, - distInstrumentWithSentryPath: undefined, distPath: undefined, - distShadowBinPath: undefined, - distShadowInjectPath: undefined, externalPath: undefined, githubCachePath: undefined, homePath: undefined, + instrumentWithSentryPath: undefined, minimumVersionByAgent: undefined, nmBinPath: undefined, nodeHardenFlags: undefined, rootPath: undefined, shadowBinPath: undefined, + shadowNpmInjectPath: undefined, + shadowNpmBinPath: undefined, socketAppDataPath: undefined, socketCachePath: undefined, + socketRegistryPath: undefined, zshRcPath: undefined, }, { @@ -589,23 +613,27 @@ const constants: Constants = createConstantsObject( bashRcPath: lazyBashRcPath, binCliPath: lazyBinCliPath, binPath: lazyBinPath, + blessedContribPath: lazyBlessedContribPath, blessedOptions: lazyBlessedOptions, + blessedPath: lazyBlessedPath, coanaBinPath: lazyCoanaBinPath, + coanaPath: lazyCoanaPath, distCliPath: lazyDistCliPath, - distInstrumentWithSentryPath: lazyDistInstrumentWithSentryPath, distPath: lazyDistPath, - distShadowBinPath: lazyDistShadowBinPath, - distShadowInjectPath: lazyDistShadowInjectPath, externalPath: lazyExternalPath, githubCachePath: lazyGithubCachePath, homePath: lazyHomePath, + instrumentWithSentryPath: lazyInstrumentWithSentryPath, minimumVersionByAgent: lazyMinimumVersionByAgent, nmBinPath: lazyNmBinPath, nodeHardenFlags: lazyNodeHardenFlags, rootPath: lazyRootPath, shadowBinPath: lazyShadowBinPath, + shadowNpmBinPath: lazyShadowNpmBinPath, + shadowNpmInjectPath: lazyShadowNpmInjectPath, socketAppDataPath: lazySocketAppDataPath, socketCachePath: lazySocketCachePath, + socketRegistryPath: lazySocketRegistryPath, zshRcPath: lazyZshRcPath, }, internals: { diff --git a/src/shadow/npm/bin.mts b/src/shadow/npm/bin.mts index 59db96d73..cbbe45dd1 100755 --- a/src/shadow/npm/bin.mts +++ b/src/shadow/npm/bin.mts @@ -75,13 +75,13 @@ export default async function shadowBin( ...(constants.ENV.INLINED_SOCKET_CLI_SENTRY_BUILD ? [ '--require', - // Lazily access constants.distInstrumentWithSentryPath. - constants.distInstrumentWithSentryPath, + // Lazily access constants.instrumentWithSentryPath. + constants.instrumentWithSentryPath, ] : []), '--require', - // Lazily access constants.distShadowInjectPath. - constants.distShadowInjectPath, + // Lazily access constants.shadowNpmInjectPath. + constants.shadowNpmInjectPath, // Lazily access constants.shadowBinPath. await installLinks(constants.shadowBinPath, binName), ...(useDebug ? ['--trace-uncaught', '--trace-warnings'] : []), diff --git a/src/shadow/npm/install.mts b/src/shadow/npm/install.mts index 6dfc7a73d..ce4dff023 100644 --- a/src/shadow/npm/install.mts +++ b/src/shadow/npm/install.mts @@ -75,13 +75,13 @@ export function safeNpmInstall( ...(constants.ENV.INLINED_SOCKET_CLI_SENTRY_BUILD ? [ '--require', - // Lazily access constants.distInstrumentWithSentryPath. - constants.distInstrumentWithSentryPath, + // Lazily access constants.instrumentWithSentryPath. + constants.instrumentWithSentryPath, ] : []), '--require', - // Lazily access constants.distShadowInjectPath. - constants.distShadowInjectPath, + // Lazily access constants.shadowNpmInjectPath. + constants.shadowNpmInjectPath, realExecPathSync(agentExecPath), 'install', // Avoid code paths for 'audit' and 'fund'.