Skip to content

Commit ce39531

Browse files
authored
Fix some bugs to make import scores work again for npm (#18)
* change key from go to golang to match api response * Fix the api url for fetching package scores * bump patch version
1 parent 0e761c1 commit ce39531

File tree

6 files changed

+10
-10
lines changed

6 files changed

+10
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "vscode-socket-security",
33
"displayName": "Socket Security",
44
"description": "Editor integration with Socket Security",
5-
"version": "1.1.0",
5+
"version": "1.1.1",
66
"private": true,
77
"preview": false,
88
"categories": [

src/data/report.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ export async function activate(context: vscode.ExtensionContext, disposables?: A
113113
const watchTargets = [
114114
...Object.values(supportedFiles.npm),
115115
...Object.values(supportedFiles.pypi),
116-
...Object.values(supportedFiles.go)
116+
...Object.values(supportedFiles.golang)
117117
].map(info => info.pattern);
118118

119119
addDisposablesTo(
@@ -291,7 +291,7 @@ export async function activate(context: vscode.ExtensionContext, disposables?: A
291291
...allPyFiles
292292
] = await Promise.all([
293293
findWorkspaceFiles(`**/${globPatterns.npm.packagejson.pattern}`, pkgJSONCacheKey),
294-
findWorkspaceFiles(`**/${globPatterns.go.gomod.pattern}`, goModCacheKey),
294+
findWorkspaceFiles(`**/${globPatterns.golang.gomod.pattern}`, goModCacheKey),
295295
findWorkspaceFiles(`**/${globPatterns.pypi.pipfile.pattern}`, pipfileCacheKey),
296296
findWorkspaceFiles(`**/${globPatterns.pypi.pyproject.pattern}`, pyprojectCacheKey),
297297
findWorkspaceFiles(`**/${globPatterns.pypi.requirements.pattern}`, requirementsCacheKey),
@@ -310,9 +310,9 @@ export async function activate(context: vscode.ExtensionContext, disposables?: A
310310
)).flat().filter(file => pkgJSONParents.has(uriParent(file.uri)))
311311

312312
const goModParents = new Set(goModFiles.map(file => uriParent(file.uri)))
313-
const goExtraFilePatterns = Object.keys(globPatterns.go)
313+
const goExtraFilePatterns = Object.keys(globPatterns.golang)
314314
.filter(name => name !== 'gomod')
315-
.map(name => globPatterns.go[name])
315+
.map(name => globPatterns.golang[name])
316316

317317
const goExtraFiles = (await Promise.all(
318318
goExtraFilePatterns.map(p => findWorkspaceFiles(`**/${p.pattern}`, hashCacheKey))

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export async function activate(context: ExtensionContext) {
6969
const watchTargets = {
7070
npm: ['packagejson'],
7171
pypi: ['pipfile', 'requirements', 'pyproject'],
72-
go: ['gomod', 'gosum']
72+
golang: ['gomod', 'gosum']
7373
}
7474

7575
const watchTargetValues = Object.entries(watchTargets).flatMap(([eco, names]) => names.map(name => ({

src/ui/file.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export function activate(
129129
return existing.score;
130130
}
131131
const score = new Promise<PackageScore>((f, r) => {
132-
const req = https.get(`https://socket.dev/api/${eco}/package/scores?name=${pkgName}`);
132+
const req = https.get(`https://socket.dev/api/${eco}/package-info/score?name=${pkgName}`);
133133
function cleanupReq() {
134134
try {
135135
req.destroy();

src/ui/go-mod.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async function provideCodeLenses(document: vscode.TextDocument, token: vscode.Ca
4242
export async function registerCodeLensProvider() {
4343
const globPatterns = await getGlobPatterns();
4444
return vscode.languages.registerCodeLensProvider({
45-
pattern: `**/${globPatterns.go.gomod.pattern}`,
45+
pattern: `**/${globPatterns.golang.gomod.pattern}`,
4646
scheme: undefined
4747
}, {
4848
provideCodeLenses
@@ -52,7 +52,7 @@ export async function registerCodeLensProvider() {
5252
export async function registerCodeActionsProvider() {
5353
const patterns = await getGlobPatterns();
5454
return vscode.languages.registerCodeActionsProvider({
55-
pattern: `**/${patterns.go.gomod.pattern}`,
55+
pattern: `**/${patterns.golang.gomod.pattern}`,
5656
scheme: undefined
5757
}, {
5858
provideCodeActions

src/ui/parse-externals.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ export async function parseExternals(doc: Pick<vscode.TextDocument, 'getText' |
509509
});
510510
}
511511
}
512-
} else if (micromatch.isMatch(basename, globPatterns.go.gomod.pattern)) {
512+
} else if (micromatch.isMatch(basename, globPatterns.golang.gomod.pattern)) {
513513
const parsed = await parseGoMod(src)
514514
if (!parsed) return null
515515

0 commit comments

Comments
 (0)