socket 0.14.78 → 0.14.79
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.
- package/dist/module-sync/cli.js +84 -64
- package/dist/module-sync/cli.js.map +1 -1
- package/dist/module-sync/shadow-npm-inject.js +52 -5
- package/dist/module-sync/shadow-npm-inject.js.map +1 -1
- package/dist/module-sync/shared.d.ts +11 -0
- package/dist/module-sync/types.d.ts +24 -79
- package/dist/require/cli.js +84 -64
- package/dist/require/cli.js.map +1 -1
- package/package.json +3 -1
- package/dist/module-sync/fs.d.ts +0 -61
package/dist/module-sync/cli.js
CHANGED
|
@@ -38,6 +38,7 @@ const prompts = require('@socketsecurity/registry/lib/prompts')
|
|
|
38
38
|
const shadowNpmPaths = require('./shadow-npm-paths.js')
|
|
39
39
|
const chalkTable = _socketInterop(require('chalk-table'))
|
|
40
40
|
const util = require('node:util')
|
|
41
|
+
const terminalLink = _socketInterop(require('terminal-link'))
|
|
41
42
|
const arrays = require('@socketsecurity/registry/lib/arrays')
|
|
42
43
|
const registry = require('@socketsecurity/registry')
|
|
43
44
|
const npm = require('@socketsecurity/registry/lib/npm')
|
|
@@ -55,7 +56,6 @@ const index_cjs = require('@socketregistry/hyrious__bun.lockb/index.cjs')
|
|
|
55
56
|
const sorts = require('@socketsecurity/registry/lib/sorts')
|
|
56
57
|
const registryConstants = require('@socketsecurity/registry/lib/constants')
|
|
57
58
|
const isInteractive = require('@socketregistry/is-interactive/index.cjs')
|
|
58
|
-
const terminalLink = _socketInterop(require('terminal-link'))
|
|
59
59
|
const npa = _socketInterop(require('npm-package-arg'))
|
|
60
60
|
const tinyglobby = _socketInterop(require('tinyglobby'))
|
|
61
61
|
const promises = require('@socketsecurity/registry/lib/promises')
|
|
@@ -915,7 +915,7 @@ function emitBanner(name) {
|
|
|
915
915
|
logger.logger.error(getAsciiHeader(name))
|
|
916
916
|
}
|
|
917
917
|
function getAsciiHeader(command) {
|
|
918
|
-
const cliVersion = '0.14.
|
|
918
|
+
const cliVersion = '0.14.79:a3df48b:dfff0bac:pub' // The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION_HASH']".
|
|
919
919
|
const nodeVersion = process$1.version
|
|
920
920
|
const apiToken = shadowNpmInject.getDefaultToken()
|
|
921
921
|
const shownToken = apiToken ? getLastFiveOfApiToken(apiToken) : 'no'
|
|
@@ -3778,6 +3778,35 @@ function getOctokit() {
|
|
|
3778
3778
|
}
|
|
3779
3779
|
return _octokit
|
|
3780
3780
|
}
|
|
3781
|
+
async function enableAutoMerge(prResponseData) {
|
|
3782
|
+
const octokit = getOctokit()
|
|
3783
|
+
const { node_id: prId, number: prNumber } = prResponseData
|
|
3784
|
+
try {
|
|
3785
|
+
await octokit.graphql(
|
|
3786
|
+
`
|
|
3787
|
+
mutation EnableAutoMerge($pullRequestId: ID!) {
|
|
3788
|
+
enablePullRequestAutoMerge(input: {
|
|
3789
|
+
pullRequestId: $pullRequestId,
|
|
3790
|
+
mergeMethod: SQUASH
|
|
3791
|
+
}) {
|
|
3792
|
+
pullRequest {
|
|
3793
|
+
number
|
|
3794
|
+
autoMergeRequest {
|
|
3795
|
+
enabledAt
|
|
3796
|
+
}
|
|
3797
|
+
}
|
|
3798
|
+
}
|
|
3799
|
+
}
|
|
3800
|
+
`,
|
|
3801
|
+
{
|
|
3802
|
+
pullRequestId: prId
|
|
3803
|
+
}
|
|
3804
|
+
)
|
|
3805
|
+
logger.logger.info(`Auto-merge enabled for PR #${prNumber}`)
|
|
3806
|
+
} catch (e) {
|
|
3807
|
+
logger.logger.error(`Failed to enable auto-merge for PR #${prNumber}:`, e)
|
|
3808
|
+
}
|
|
3809
|
+
}
|
|
3781
3810
|
async function openGitHubPullRequest(name, targetVersion, cwd = process.cwd()) {
|
|
3782
3811
|
// Lazily access constants.ENV[GITHUB_ACTIONS].
|
|
3783
3812
|
if (constants.ENV[GITHUB_ACTIONS]) {
|
|
@@ -3819,7 +3848,7 @@ async function openGitHubPullRequest(name, targetVersion, cwd = process.cwd()) {
|
|
|
3819
3848
|
})
|
|
3820
3849
|
}
|
|
3821
3850
|
const octokit = getOctokit()
|
|
3822
|
-
await octokit.pulls.create({
|
|
3851
|
+
return await octokit.pulls.create({
|
|
3823
3852
|
owner,
|
|
3824
3853
|
repo,
|
|
3825
3854
|
title: commitMsg,
|
|
@@ -3846,16 +3875,10 @@ async function install$1(idealTree, options) {
|
|
|
3846
3875
|
arb2.idealTree = idealTree
|
|
3847
3876
|
await arb2.reify()
|
|
3848
3877
|
}
|
|
3849
|
-
async function npmFix(
|
|
3850
|
-
|
|
3851
|
-
|
|
3852
|
-
|
|
3853
|
-
test = false,
|
|
3854
|
-
testScript = 'test'
|
|
3855
|
-
} = {
|
|
3856
|
-
__proto__: null,
|
|
3857
|
-
...options
|
|
3858
|
-
}
|
|
3878
|
+
async function npmFix(
|
|
3879
|
+
_pkgEnvDetails,
|
|
3880
|
+
{ autoMerge, cwd, rangeStyle, spinner, test, testScript }
|
|
3881
|
+
) {
|
|
3859
3882
|
spinner?.start()
|
|
3860
3883
|
const arb = new shadowNpmInject.SafeArborist({
|
|
3861
3884
|
path: cwd,
|
|
@@ -3951,7 +3974,8 @@ async function npmFix(_pkgEnvDetails, options) {
|
|
|
3951
3974
|
shadowNpmInject.updatePackageJsonFromNode(
|
|
3952
3975
|
editablePkgJson,
|
|
3953
3976
|
arb.idealTree,
|
|
3954
|
-
node
|
|
3977
|
+
node,
|
|
3978
|
+
rangeStyle
|
|
3955
3979
|
)
|
|
3956
3980
|
// eslint-disable-next-line no-await-in-loop
|
|
3957
3981
|
await editablePkgJson.save()
|
|
@@ -3975,7 +3999,15 @@ async function npmFix(_pkgEnvDetails, options) {
|
|
|
3975
3999
|
// Lazily access constants.ENV[CI].
|
|
3976
4000
|
if (constants.ENV[CI$1]) {
|
|
3977
4001
|
// eslint-disable-next-line no-await-in-loop
|
|
3978
|
-
await openGitHubPullRequest(
|
|
4002
|
+
const prResponse = await openGitHubPullRequest(
|
|
4003
|
+
name,
|
|
4004
|
+
targetVersion,
|
|
4005
|
+
cwd
|
|
4006
|
+
)
|
|
4007
|
+
if (autoMerge) {
|
|
4008
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4009
|
+
await enableAutoMerge(prResponse.data)
|
|
4010
|
+
}
|
|
3979
4011
|
}
|
|
3980
4012
|
} catch {
|
|
3981
4013
|
spinner?.error(`Reverting ${fixSpec}`)
|
|
@@ -4206,16 +4238,10 @@ async function install(pkgEnvDetails, options) {
|
|
|
4206
4238
|
stdio: 'ignore'
|
|
4207
4239
|
})
|
|
4208
4240
|
}
|
|
4209
|
-
async function pnpmFix(
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
|
|
4213
|
-
test = false,
|
|
4214
|
-
testScript = 'test'
|
|
4215
|
-
} = {
|
|
4216
|
-
__proto__: null,
|
|
4217
|
-
...options
|
|
4218
|
-
}
|
|
4241
|
+
async function pnpmFix(
|
|
4242
|
+
pkgEnvDetails,
|
|
4243
|
+
{ autoMerge, cwd, rangeStyle, spinner, test, testScript }
|
|
4244
|
+
) {
|
|
4219
4245
|
const lockfile = await lockfile_fs.readWantedLockfile(cwd, {
|
|
4220
4246
|
ignoreIncompatible: false
|
|
4221
4247
|
})
|
|
@@ -4345,7 +4371,8 @@ async function pnpmFix(pkgEnvDetails, options) {
|
|
|
4345
4371
|
shadowNpmInject.updatePackageJsonFromNode(
|
|
4346
4372
|
editablePkgJson,
|
|
4347
4373
|
arb.actualTree,
|
|
4348
|
-
node
|
|
4374
|
+
node,
|
|
4375
|
+
rangeStyle
|
|
4349
4376
|
)
|
|
4350
4377
|
// eslint-disable-next-line no-await-in-loop
|
|
4351
4378
|
await editablePkgJson.save()
|
|
@@ -4370,7 +4397,15 @@ async function pnpmFix(pkgEnvDetails, options) {
|
|
|
4370
4397
|
// Lazily access constants.ENV[CI].
|
|
4371
4398
|
if (constants.ENV[CI]) {
|
|
4372
4399
|
// eslint-disable-next-line no-await-in-loop
|
|
4373
|
-
await openGitHubPullRequest(
|
|
4400
|
+
const prResponse = await openGitHubPullRequest(
|
|
4401
|
+
name,
|
|
4402
|
+
targetVersion,
|
|
4403
|
+
cwd
|
|
4404
|
+
)
|
|
4405
|
+
if (autoMerge) {
|
|
4406
|
+
// eslint-disable-next-line no-await-in-loop
|
|
4407
|
+
await enableAutoMerge(prResponse.data)
|
|
4408
|
+
}
|
|
4374
4409
|
}
|
|
4375
4410
|
} catch {
|
|
4376
4411
|
spinner?.error(`Reverting ${fixSpec}`)
|
|
@@ -4797,48 +4832,27 @@ async function detectAndValidatePackageEnvironment(cwd, options) {
|
|
|
4797
4832
|
|
|
4798
4833
|
const { NPM: NPM$a, PNPM: PNPM$7 } = constants
|
|
4799
4834
|
const CMD_NAME$2 = 'socket fix'
|
|
4800
|
-
async function runFix({
|
|
4801
|
-
|
|
4802
|
-
|
|
4803
|
-
|
|
4804
|
-
|
|
4805
|
-
|
|
4806
|
-
}) {
|
|
4807
|
-
const pkgEnvDetails = await detectAndValidatePackageEnvironment(cwd, {
|
|
4835
|
+
async function runFix(options_) {
|
|
4836
|
+
const options = shadowNpmInject.assignDefaultFixOptions({
|
|
4837
|
+
__proto__: null,
|
|
4838
|
+
...options_
|
|
4839
|
+
})
|
|
4840
|
+
const pkgEnvDetails = await detectAndValidatePackageEnvironment(options.cwd, {
|
|
4808
4841
|
cmdName: CMD_NAME$2,
|
|
4809
4842
|
logger: logger.logger
|
|
4810
4843
|
})
|
|
4811
4844
|
if (!pkgEnvDetails) {
|
|
4812
|
-
spinner?.stop()
|
|
4813
4845
|
return
|
|
4814
4846
|
}
|
|
4815
4847
|
logger.logger.info(`Fixing packages for ${pkgEnvDetails.agent}`)
|
|
4816
|
-
|
|
4817
|
-
|
|
4818
|
-
|
|
4819
|
-
|
|
4820
|
-
|
|
4821
|
-
test,
|
|
4822
|
-
testScript
|
|
4823
|
-
})
|
|
4824
|
-
break
|
|
4825
|
-
}
|
|
4826
|
-
case PNPM$7: {
|
|
4827
|
-
await pnpmFix(pkgEnvDetails, {
|
|
4828
|
-
rangeStyle,
|
|
4829
|
-
spinner,
|
|
4830
|
-
test,
|
|
4831
|
-
testScript
|
|
4832
|
-
})
|
|
4833
|
-
break
|
|
4834
|
-
}
|
|
4848
|
+
const { agent } = pkgEnvDetails
|
|
4849
|
+
if (agent === NPM$a) {
|
|
4850
|
+
await npmFix(pkgEnvDetails, options)
|
|
4851
|
+
} else if (agent === PNPM$7) {
|
|
4852
|
+
await pnpmFix(pkgEnvDetails, options)
|
|
4835
4853
|
}
|
|
4836
|
-
spinner?.stop()
|
|
4837
|
-
// spinner.successAndStop('Socket.dev fix successful')
|
|
4838
4854
|
}
|
|
4839
4855
|
|
|
4840
|
-
const RangeStyles = ['caret', 'gt', 'lt', 'pin', 'preserve', 'tilde']
|
|
4841
|
-
|
|
4842
4856
|
const { DRY_RUN_BAIL_TEXT: DRY_RUN_BAIL_TEXT$w } = constants
|
|
4843
4857
|
const config$z = {
|
|
4844
4858
|
commandName: 'fix',
|
|
@@ -4846,6 +4860,11 @@ const config$z = {
|
|
|
4846
4860
|
hidden: true,
|
|
4847
4861
|
flags: {
|
|
4848
4862
|
...commonFlags,
|
|
4863
|
+
autoMerge: {
|
|
4864
|
+
type: 'boolean',
|
|
4865
|
+
default: true,
|
|
4866
|
+
description: `Enable auto-merge for pull requests that Socket opens.\n See ${terminalLink('GitHub documentation', 'https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/configuring-pull-request-merges/managing-auto-merge-for-pull-requests-in-your-repository')} for managing auto-merge for pull requests in your repository.`
|
|
4867
|
+
},
|
|
4849
4868
|
rangeStyle: {
|
|
4850
4869
|
type: 'string',
|
|
4851
4870
|
default: 'preserve',
|
|
@@ -4863,7 +4882,7 @@ const config$z = {
|
|
|
4863
4882
|
test: {
|
|
4864
4883
|
type: 'boolean',
|
|
4865
4884
|
default: true,
|
|
4866
|
-
description: '
|
|
4885
|
+
description: 'Verify the fix by running unit tests'
|
|
4867
4886
|
},
|
|
4868
4887
|
testScript: {
|
|
4869
4888
|
type: 'string',
|
|
@@ -4892,8 +4911,8 @@ async function run$z(argv, importMeta, { parentName }) {
|
|
|
4892
4911
|
parentName
|
|
4893
4912
|
})
|
|
4894
4913
|
const wasBadInput = handleBadInput({
|
|
4895
|
-
test: RangeStyles.includes(cli.flags['rangeStyle']),
|
|
4896
|
-
message: `Expecting range style of ${arrays.joinOr(RangeStyles)}`,
|
|
4914
|
+
test: shadowNpmInject.RangeStyles.includes(cli.flags['rangeStyle']),
|
|
4915
|
+
message: `Expecting range style of ${arrays.joinOr(shadowNpmInject.RangeStyles)}`,
|
|
4897
4916
|
pass: 'ok',
|
|
4898
4917
|
fail: 'missing'
|
|
4899
4918
|
})
|
|
@@ -4908,6 +4927,7 @@ async function run$z(argv, importMeta, { parentName }) {
|
|
|
4908
4927
|
// Lazily access constants.spinner.
|
|
4909
4928
|
const { spinner } = constants
|
|
4910
4929
|
await runFix({
|
|
4930
|
+
autoMerge: Boolean(cli.flags['autoMerge']),
|
|
4911
4931
|
spinner,
|
|
4912
4932
|
rangeStyle: cli.flags['rangeStyle'] ?? undefined,
|
|
4913
4933
|
test: Boolean(cli.flags['test']),
|
|
@@ -11281,7 +11301,7 @@ void (async () => {
|
|
|
11281
11301
|
await updateNotifier({
|
|
11282
11302
|
name: SOCKET_CLI_BIN_NAME,
|
|
11283
11303
|
// The '@rollup/plugin-replace' will replace "process.env['INLINED_SOCKET_CLI_VERSION']".
|
|
11284
|
-
version: '0.14.
|
|
11304
|
+
version: '0.14.79',
|
|
11285
11305
|
ttl: 86_400_000 /* 24 hours in milliseconds */
|
|
11286
11306
|
})
|
|
11287
11307
|
try {
|
|
@@ -11349,5 +11369,5 @@ void (async () => {
|
|
|
11349
11369
|
await shadowNpmInject.captureException(e)
|
|
11350
11370
|
}
|
|
11351
11371
|
})()
|
|
11352
|
-
//# debugId=
|
|
11372
|
+
//# debugId=b660eaf5-1e09-4d0e-9a7d-a1d707ccafed
|
|
11353
11373
|
//# sourceMappingURL=cli.js.map
|