@socketsecurity/cli 0.14.130 → 0.14.132

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/bin/cli.js +37 -44
  2. package/bin/npx-cli.js +1 -3
  3. package/dist/{module-sync/cli.js → cli.js} +55 -36
  4. package/dist/cli.js.map +1 -0
  5. package/dist/constants.js +8 -25
  6. package/dist/constants.js.map +1 -1
  7. package/dist/{module-sync/shadow-bin.js → shadow-bin.js} +52 -1
  8. package/dist/shadow-bin.js.map +1 -0
  9. package/dist/{module-sync/shadow-npm-inject.js → shadow-npm-inject.js} +60 -16
  10. package/dist/shadow-npm-inject.js.map +1 -0
  11. package/dist/shadow-npm-paths.js.map +1 -0
  12. package/dist/{module-sync/vendor.js → vendor.js} +10320 -4778
  13. package/dist/vendor.js.map +1 -0
  14. package/package.json +16 -26
  15. package/dist/constants.d.ts +0 -285
  16. package/dist/module-sync/arborist-helpers.d.ts +0 -68
  17. package/dist/module-sync/artifact.d.ts +0 -63
  18. package/dist/module-sync/cli.d.ts +0 -2
  19. package/dist/module-sync/cli.js.map +0 -1
  20. package/dist/module-sync/cmd.d.ts +0 -4
  21. package/dist/module-sync/config.d.ts +0 -44
  22. package/dist/module-sync/constants.js +0 -3
  23. package/dist/module-sync/edge.d.ts +0 -78
  24. package/dist/module-sync/errors.d.ts +0 -29
  25. package/dist/module-sync/fs.d.ts +0 -63
  26. package/dist/module-sync/index.d.ts +0 -34
  27. package/dist/module-sync/node.d.ts +0 -121
  28. package/dist/module-sync/override-set.d.ts +0 -43
  29. package/dist/module-sync/package-environment.d.ts +0 -83
  30. package/dist/module-sync/path-resolve.d.ts +0 -15
  31. package/dist/module-sync/sdk.d.ts +0 -9
  32. package/dist/module-sync/semver.d.ts +0 -17
  33. package/dist/module-sync/shadow-bin.d.ts +0 -5
  34. package/dist/module-sync/shadow-bin.js.map +0 -1
  35. package/dist/module-sync/shadow-npm-inject.d.ts +0 -1
  36. package/dist/module-sync/shadow-npm-inject.js.map +0 -1
  37. package/dist/module-sync/shadow-npm-paths.d.ts +0 -27
  38. package/dist/module-sync/shadow-npm-paths.js.map +0 -1
  39. package/dist/module-sync/socket-package-alert.d.ts +0 -104
  40. package/dist/module-sync/vendor.d.ts +0 -0
  41. package/dist/module-sync/vendor.js.map +0 -1
  42. package/dist/require/cli.d.ts +0 -2
  43. package/dist/require/cli.js +0 -12336
  44. package/dist/require/cli.js.map +0 -1
  45. package/dist/require/constants.js +0 -3
  46. package/dist/require/shadow-bin.d.ts +0 -5
  47. package/dist/require/shadow-bin.js +0 -106
  48. package/dist/require/shadow-bin.js.map +0 -1
  49. package/dist/require/shadow-npm-inject.d.ts +0 -1
  50. package/dist/require/shadow-npm-inject.js +0 -2596
  51. package/dist/require/shadow-npm-inject.js.map +0 -1
  52. package/dist/require/shadow-npm-paths.d.ts +0 -27
  53. package/dist/require/shadow-npm-paths.js +0 -292
  54. package/dist/require/shadow-npm-paths.js.map +0 -1
  55. package/dist/require/vendor.js +0 -3
  56. /package/dist/{module-sync/shadow-npm-paths.js → shadow-npm-paths.js} +0 -0
@@ -1,3 +0,0 @@
1
- 'use strict'
2
-
3
- module.exports = require('../module-sync/constants.js')
@@ -1,5 +0,0 @@
1
- declare function shadowBin(
2
- binName: 'npm' | 'npx',
3
- args?: string[]
4
- ): Promise<void>
5
- export { shadowBin as default }
@@ -1,106 +0,0 @@
1
- 'use strict'
2
-
3
- const process = require('node:process')
4
- const debug = require('@socketsecurity/registry/lib/debug')
5
- const npm = require('@socketsecurity/registry/lib/npm')
6
- const spawn = require('@socketsecurity/registry/lib/spawn')
7
- const path = require('node:path')
8
- const vendor = require('./vendor.js')
9
- const shadowNpmPaths = require('./shadow-npm-paths.js')
10
- const constants = require('./constants.js')
11
-
12
- const { CLI, NPX } = constants
13
- async function installLinks(realBinPath, binName) {
14
- const isNpx = binName === NPX
15
- // Find package manager being shadowed by this process.
16
- const binPath = isNpx
17
- ? shadowNpmPaths.getNpxBinPath()
18
- : shadowNpmPaths.getNpmBinPath()
19
- // Lazily access constants.WIN32.
20
- const { WIN32 } = constants
21
- // TODO: Is this early exit needed?
22
- if (WIN32 && binPath) {
23
- return binPath
24
- }
25
- const shadowed = isNpx
26
- ? shadowNpmPaths.isNpxBinPathShadowed()
27
- : shadowNpmPaths.isNpmBinPathShadowed()
28
- // Move our bin directory to front of PATH so its found first.
29
- if (!shadowed) {
30
- if (WIN32) {
31
- await vendor.libExports(
32
- // Lazily access constants.rootDistPath.
33
- path.join(constants.rootDistPath, `${binName}-${CLI}.js`),
34
- path.join(realBinPath, binName)
35
- )
36
- }
37
- const { env } = process
38
- env['PATH'] = `${realBinPath}${path.delimiter}${env['PATH']}`
39
- }
40
- return binPath
41
- }
42
-
43
- const { SOCKET_CLI_SAFE_BIN, SOCKET_CLI_SAFE_PROGRESS, SOCKET_IPC_HANDSHAKE } =
44
- constants
45
- async function shadowBin(binName, args = process.argv.slice(2)) {
46
- process.exitCode = 1
47
- const useDebug = debug.isDebug()
48
- const terminatorPos = args.indexOf('--')
49
- const rawBinArgs = terminatorPos === -1 ? args : args.slice(0, terminatorPos)
50
- const progressArg =
51
- rawBinArgs.findLast(npm.isProgressFlag) !== '--no-progress'
52
- const binArgs = rawBinArgs.filter(a => !npm.isProgressFlag(a))
53
- const otherArgs = terminatorPos === -1 ? [] : args.slice(terminatorPos)
54
- const isSilent = !useDebug && !binArgs.some(npm.isLoglevelFlag)
55
- // The default value of loglevel is "notice". We default to "error" which is
56
- // two levels quieter.
57
- const logLevelArgs = isSilent ? ['--loglevel', 'error'] : []
58
- const spawnPromise = spawn.spawn(
59
- // Lazily access constants.execPath.
60
- constants.execPath,
61
- [
62
- // Lazily access constants.nodeHardenFlags.
63
- ...constants.nodeHardenFlags,
64
- // Lazily access constants.nodeNoWarningsFlags.
65
- ...constants.nodeNoWarningsFlags,
66
- // Lazily access false.
67
- ...[],
68
- '--require',
69
- // Lazily access constants.distShadowNpmInjectPath.
70
- constants.distShadowNpmInjectPath,
71
- // Lazily access constants.shadowBinPath.
72
- await installLinks(constants.shadowBinPath, binName),
73
- // Add '--no-progress' to fix input being swallowed by the npm spinner.
74
- '--no-progress',
75
- // Add '--loglevel=error' if a loglevel flag is not provided and the
76
- // SOCKET_CLI_DEBUG environment variable is not truthy.
77
- ...logLevelArgs,
78
- ...binArgs,
79
- ...otherArgs
80
- ],
81
- {
82
- // 'inherit' + 'ipc'
83
- stdio: [0, 1, 2, 'ipc']
84
- }
85
- )
86
- // See https://nodejs.org/api/all.html#all_child_process_event-exit.
87
- spawnPromise.process.on('exit', (code, signalName) => {
88
- if (signalName) {
89
- process.kill(process.pid, signalName)
90
- } else if (code !== null) {
91
- // eslint-disable-next-line n/no-process-exit
92
- process.exit(code)
93
- }
94
- })
95
- spawnPromise.process.send({
96
- [SOCKET_IPC_HANDSHAKE]: {
97
- [SOCKET_CLI_SAFE_BIN]: binName,
98
- [SOCKET_CLI_SAFE_PROGRESS]: progressArg
99
- }
100
- })
101
- await spawnPromise
102
- }
103
-
104
- module.exports = shadowBin
105
- //# debugId=c07c77d4-8583-4c6b-9a6a-0361d5c81ac7
106
- //# sourceMappingURL=shadow-bin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shadow-bin.js","sources":["../../src/shadow/npm/link.ts","../../src/shadow/npm/bin.ts"],"sourcesContent":["import path from 'node:path'\nimport process from 'node:process'\n\nimport cmdShim from 'cmd-shim'\n\nimport {\n getNpmBinPath,\n getNpxBinPath,\n isNpmBinPathShadowed,\n isNpxBinPathShadowed\n} from './paths'\nimport constants from '../../constants'\n\nconst { CLI, NPX } = constants\n\nexport async function installLinks(\n realBinPath: string,\n binName: 'npm' | 'npx'\n): Promise<string> {\n const isNpx = binName === NPX\n // Find package manager being shadowed by this process.\n const binPath = isNpx ? getNpxBinPath() : getNpmBinPath()\n // Lazily access constants.WIN32.\n const { WIN32 } = constants\n // TODO: Is this early exit needed?\n if (WIN32 && binPath) {\n return binPath\n }\n const shadowed = isNpx ? isNpxBinPathShadowed() : isNpmBinPathShadowed()\n // Move our bin directory to front of PATH so its found first.\n if (!shadowed) {\n if (WIN32) {\n await cmdShim(\n // Lazily access constants.rootDistPath.\n path.join(constants.rootDistPath, `${binName}-${CLI}.js`),\n path.join(realBinPath, binName)\n )\n }\n const { env } = process\n env['PATH'] = `${realBinPath}${path.delimiter}${env['PATH']}`\n }\n return binPath\n}\n","import process from 'node:process'\n\nimport { isDebug } from '@socketsecurity/registry/lib/debug'\nimport {\n isLoglevelFlag,\n isProgressFlag\n} from '@socketsecurity/registry/lib/npm'\nimport { spawn } from '@socketsecurity/registry/lib/spawn'\n\nimport { installLinks } from './link'\nimport constants from '../../constants'\n\nconst { SOCKET_CLI_SAFE_BIN, SOCKET_CLI_SAFE_PROGRESS, SOCKET_IPC_HANDSHAKE } =\n constants\n\nexport default async function shadowBin(\n binName: 'npm' | 'npx',\n args = process.argv.slice(2)\n) {\n process.exitCode = 1\n const useDebug = isDebug()\n const terminatorPos = args.indexOf('--')\n const rawBinArgs = terminatorPos === -1 ? args : args.slice(0, terminatorPos)\n const progressArg = rawBinArgs.findLast(isProgressFlag) !== '--no-progress'\n const binArgs = rawBinArgs.filter(a => !isProgressFlag(a))\n const otherArgs = terminatorPos === -1 ? [] : args.slice(terminatorPos)\n const isSilent = !useDebug && !binArgs.some(isLoglevelFlag)\n // The default value of loglevel is \"notice\". We default to \"error\" which is\n // two levels quieter.\n const logLevelArgs = isSilent ? ['--loglevel', 'error'] : []\n const spawnPromise = spawn(\n // Lazily access constants.execPath.\n constants.execPath,\n [\n // Lazily access constants.nodeHardenFlags.\n ...constants.nodeHardenFlags,\n // Lazily access constants.nodeNoWarningsFlags.\n ...constants.nodeNoWarningsFlags,\n // Lazily access process.env['INLINED_SOCKET_CLI_SENTRY_BUILD'].\n ...(process.env['INLINED_SOCKET_CLI_SENTRY_BUILD']\n ? [\n '--require',\n // Lazily access constants.distInstrumentWithSentryPath.\n constants.distInstrumentWithSentryPath\n ]\n : []),\n '--require',\n // Lazily access constants.distShadowNpmInjectPath.\n constants.distShadowNpmInjectPath,\n // Lazily access constants.shadowBinPath.\n await installLinks(constants.shadowBinPath, binName),\n // Add '--no-progress' to fix input being swallowed by the npm spinner.\n '--no-progress',\n // Add '--loglevel=error' if a loglevel flag is not provided and the\n // SOCKET_CLI_DEBUG environment variable is not truthy.\n ...logLevelArgs,\n ...binArgs,\n ...otherArgs\n ],\n {\n // 'inherit' + 'ipc'\n stdio: [0, 1, 2, 'ipc']\n }\n )\n // See https://nodejs.org/api/all.html#all_child_process_event-exit.\n spawnPromise.process.on('exit', (code, signalName) => {\n if (signalName) {\n process.kill(process.pid, signalName)\n } else if (code !== null) {\n // eslint-disable-next-line n/no-process-exit\n process.exit(code)\n }\n })\n spawnPromise.process.send({\n [SOCKET_IPC_HANDSHAKE]: {\n [SOCKET_CLI_SAFE_BIN]: binName,\n [SOCKET_CLI_SAFE_PROGRESS]: progressArg\n }\n })\n await spawnPromise\n}\n"],"names":["NPX","WIN32","env","SOCKET_IPC_HANDSHAKE","constants","process","spawnPromise"],"mappings":";;;;;;;;;;;AAaA;;AAAaA;AAAI;AAEV;AAIL;AACA;;AAEA;;AACQC;AAAM;AACd;;AAEE;AACF;;AAEA;;AAEE;AACE;AACE;;AAIJ;;AACQC;AAAI;AACZA;AACF;AACA;AACF;;AC9BA;;;AAAuDC;AAAqB;AAG7D;;AAKb;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;;AAGE;;AAGE;;AAEA;;AAEA;;AASA;AACAC;AACA;AACA;AACA;;AAEA;AACA;;AAMA;;AAEF;AAEF;;AAEE;;AAEA;AACE;AACAC;AACF;AACF;AACAC;AACE;;AAEE;AACF;AACF;AACA;AACF;;","debugId":"c07c77d4-8583-4c6b-9a6a-0361d5c81ac7"}
@@ -1 +0,0 @@
1
- export {}