Skip to content

Commit

Permalink
Fix some bugs to make import scores work again for npm (#18)
Browse files Browse the repository at this point in the history
* change key from go to golang to match api response

* Fix the api url for fetching package scores

* bump patch version
  • Loading branch information
tmpvar authored Sep 12, 2024
1 parent 0e761c1 commit ce39531
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-socket-security",
"displayName": "Socket Security",
"description": "Editor integration with Socket Security",
"version": "1.1.0",
"version": "1.1.1",
"private": true,
"preview": false,
"categories": [
Expand Down
8 changes: 4 additions & 4 deletions src/data/report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export async function activate(context: vscode.ExtensionContext, disposables?: A
const watchTargets = [
...Object.values(supportedFiles.npm),
...Object.values(supportedFiles.pypi),
...Object.values(supportedFiles.go)
...Object.values(supportedFiles.golang)
].map(info => info.pattern);

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

const goModParents = new Set(goModFiles.map(file => uriParent(file.uri)))
const goExtraFilePatterns = Object.keys(globPatterns.go)
const goExtraFilePatterns = Object.keys(globPatterns.golang)
.filter(name => name !== 'gomod')
.map(name => globPatterns.go[name])
.map(name => globPatterns.golang[name])

const goExtraFiles = (await Promise.all(
goExtraFilePatterns.map(p => findWorkspaceFiles(`**/${p.pattern}`, hashCacheKey))
Expand Down
2 changes: 1 addition & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export async function activate(context: ExtensionContext) {
const watchTargets = {
npm: ['packagejson'],
pypi: ['pipfile', 'requirements', 'pyproject'],
go: ['gomod', 'gosum']
golang: ['gomod', 'gosum']
}

const watchTargetValues = Object.entries(watchTargets).flatMap(([eco, names]) => names.map(name => ({
Expand Down
2 changes: 1 addition & 1 deletion src/ui/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ export function activate(
return existing.score;
}
const score = new Promise<PackageScore>((f, r) => {
const req = https.get(`https://socket.dev/api/${eco}/package/scores?name=${pkgName}`);
const req = https.get(`https://socket.dev/api/${eco}/package-info/score?name=${pkgName}`);
function cleanupReq() {
try {
req.destroy();
Expand Down
4 changes: 2 additions & 2 deletions src/ui/go-mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ async function provideCodeLenses(document: vscode.TextDocument, token: vscode.Ca
export async function registerCodeLensProvider() {
const globPatterns = await getGlobPatterns();
return vscode.languages.registerCodeLensProvider({
pattern: `**/${globPatterns.go.gomod.pattern}`,
pattern: `**/${globPatterns.golang.gomod.pattern}`,
scheme: undefined
}, {
provideCodeLenses
Expand All @@ -52,7 +52,7 @@ export async function registerCodeLensProvider() {
export async function registerCodeActionsProvider() {
const patterns = await getGlobPatterns();
return vscode.languages.registerCodeActionsProvider({
pattern: `**/${patterns.go.gomod.pattern}`,
pattern: `**/${patterns.golang.gomod.pattern}`,
scheme: undefined
}, {
provideCodeActions
Expand Down
2 changes: 1 addition & 1 deletion src/ui/parse-externals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ export async function parseExternals(doc: Pick<vscode.TextDocument, 'getText' |
});
}
}
} else if (micromatch.isMatch(basename, globPatterns.go.gomod.pattern)) {
} else if (micromatch.isMatch(basename, globPatterns.golang.gomod.pattern)) {
const parsed = await parseGoMod(src)
if (!parsed) return null

Expand Down

0 comments on commit ce39531

Please sign in to comment.