Skip to content
This repository was archived by the owner on Jun 16, 2022. It is now read-only.

Commit 91e43b0

Browse files
committed
Update go action repo with latest @github/dependency-snapshot-action pkg
1 parent a81a2b3 commit 91e43b0

File tree

3 files changed

+42
-18
lines changed

3 files changed

+42
-18
lines changed

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
"url": "https://github.com/dsp-testing/go-snapshot-action/issues"
2323
},
2424
"homepage": "https://github.com/dsp-testing/go-snapshot-action#readme",
25-
"dependencies": {
26-
"@github/dependency-snapshot-action": "^1.0.0"
27-
},
2825
"devDependencies": {
2926
"@typescript-eslint/eslint-plugin": "^5.20.0",
3027
"@typescript-eslint/parser": "^5.20.0",
@@ -33,5 +30,8 @@
3330
"eslint-plugin-import": "^2.26.0",
3431
"eslint-plugin-n": "^15.1.0",
3532
"eslint-plugin-promise": "^6.0.0"
33+
},
34+
"dependencies": {
35+
"@github/dependency-snapshot-action": "^1.0.0"
3636
}
3737
}

src/index.ts

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,28 +17,52 @@ parseDependents = function (contents: string) {
1717
const entries: ParsedDependencies = {}
1818
const repoName = splitStdoutArr[0][0]
1919
splitStdoutArr.forEach((line: string[]) => {
20-
if (line.length < 2 || line === undefined) return // skip empty lines
20+
if (line === undefined || line.length < 2) return // skip empty lines
2121

22-
let entry: Entry
23-
let dependencyString = `pkg:golang/${line[0]}`
22+
let targetEntry: Entry
23+
const targetPkg = `pkg:golang/${line[0]}`
24+
let dependencyEntry: Entry
25+
const dependencyPkg = `pkg:golang/${line[1]}`
2426

2527
const matchFound = line[0].match(repoName)
2628
if (matchFound && matchFound.index != null) {
27-
dependencyString = `pkg:golang/${line[1]}`
28-
entries[dependencyString] = new Entry(dependencyString, 'direct')
29+
entries[dependencyPkg] = new Entry(dependencyPkg, 'direct')
2930
return
3031
}
3132

32-
if (dependencyString in entries) {
33-
entry = entries[dependencyString]
33+
if (targetPkg in entries) {
34+
targetEntry = entries[targetPkg]
3435
} else {
35-
entry = new Entry(dependencyString, 'indirect')
36-
entries[dependencyString] = entry
36+
targetEntry = new Entry(targetPkg, 'indirect')
37+
entries[targetPkg] = targetEntry
3738
}
3839

39-
entry.addDependency(new Entry(`pkg:golang/${line[1]}`, 'indirect'))
40+
if (dependencyPkg in entries) {
41+
dependencyEntry = entries[dependencyPkg]
42+
} else {
43+
dependencyEntry = new Entry(dependencyPkg, 'indirect')
44+
entries[dependencyPkg] = dependencyEntry
45+
}
46+
47+
targetEntry.addDependency(dependencyEntry)
4048
})
4149
return entries
4250
}
4351

44-
run(parseDependents, undefined, 'go mod graph')
52+
const metadata = {
53+
foo: 1.0,
54+
bar: false,
55+
baz: 'somethingsomething',
56+
nullz: null
57+
}
58+
const detector = {
59+
name: 'Typescript Snapshot Detector',
60+
url: 'https://github.com/github/dependency_snapshot_action',
61+
version: '0.0.1'
62+
}
63+
64+
run(
65+
parseDependents,
66+
{ command: 'go mod graph' },
67+
{ metadata, detector }
68+
)

0 commit comments

Comments
 (0)