1
1
# non-npm-package-json-files
2
2
Get a collection of package.json files for non-NPM packages
3
3
4
- # Requirements
4
+ ## Why?
5
+
6
+ We needed ` package.json ` files from real projects that aren't packages published to NPM. While
7
+ NPM can tell you the absolute usage of NPM packages in terms of download numbers, we were
8
+ interested in the set of dependencies that people were using together in a given project.
9
+
10
+ More details about how we used a sample of these package.json files to simulation for StackAid:
11
+ [ StackAid in Beta] ( https://www.stackaid.us/blog/stackaid-in-beta )
12
+
13
+ ## Requirements
5
14
6
15
* [ Brew] ( https://brew.sh ) (MacOSX)
7
16
* [ Task] ( https://taskfile.dev )
@@ -16,7 +25,7 @@ On MacOS:
16
25
brew install brew install go-task/tap/go-task && task brew:requirements
17
26
```
18
27
19
- # Get Sourcegraph Access Token
28
+ ## Get a Sourcegraph access token
20
29
21
30
Use the ` src ` CLI to see if you're authenticated:
22
31
``` shell
@@ -34,3 +43,43 @@ SRC_ACCESS_TOKEN=<your access token>
34
43
Once configured correctly, rerun ` src:login ` task to confirm your
35
44
configuration.
36
45
46
+ ## Query Sourcegraph
47
+
48
+ To query for all package.json files on GitHub that aren't in ` node_modules ` or directories such
49
+ as ` test ` , ` fixture ` or ` examples ` :
50
+
51
+ ``` shell
52
+ task src:query
53
+ ```
54
+
55
+ The command will take about 1 minute and return just over 1M results. The results file in the data
56
+ directory: ` ./data/src_github_results.jsonl ` and it should look like this:
57
+
58
+ ``` json lines
59
+ {"type" :" path" ,"path" :" package.json" ,"repository" :" freeCodeCamp/freeCodeCamp" ,"branches" :[" " ],"commit" :" 382717cce4ea5593eb623ba5ef0bd47c534411d1" }
60
+ {"type" :" path" ,"path" :" web/package.json" ,"repository" :" freeCodeCamp/freeCodeCamp" ,"branches" :[" " ],"commit" :" 382717cce4ea5593eb623ba5ef0bd47c534411d1" }
61
+ {"type" :" path" ,"path" :" curriculum/package.json" ,"repository" :" freeCodeCamp/freeCodeCamp" ,"branches" :[" " ],"commit" :" 382717cce4ea5593eb623ba5ef0bd47c534411d1" }
62
+ {"type" :" path" ,"path" :" tools/crowdin/package.json" ,"repository" :" freeCodeCamp/freeCodeCamp" ,"branches" :[" " ],"commit" :" 382717cce4ea5593eb623ba5ef0bd47c534411d1" }
63
+ {"type" :" path" ,"path" :" tools/scripts/seed/package.json" ,"repository" :" freeCodeCamp/freeCodeCamp" ,"branches" :[" " ],"commit" :" 382717cce4ea5593eb623ba5ef0bd47c534411d1" }
64
+ ```
65
+
66
+ To convert the file to a CSV:
67
+
68
+ ``` shell
69
+ task src:query:csv
70
+ ```
71
+
72
+ The results will be in ` ./data/src_github_results.csv ` and it should looks this this:
73
+
74
+ ``` csv
75
+ repo,commit_sha,path
76
+ freeCodeCamp/freeCodeCamp,382717cce4ea5593eb623ba5ef0bd47c534411d1,package.json
77
+ freeCodeCamp/freeCodeCamp,382717cce4ea5593eb623ba5ef0bd47c534411d1,web/package.json
78
+ freeCodeCamp/freeCodeCamp,382717cce4ea5593eb623ba5ef0bd47c534411d1,curriculum/package.json
79
+ freeCodeCamp/freeCodeCamp,382717cce4ea5593eb623ba5ef0bd47c534411d1,tools/crowdin/package.json
80
+ freeCodeCamp/freeCodeCamp,382717cce4ea5593eb623ba5ef0bd47c534411d1,tools/scripts/seed/package.json
81
+ ```
82
+
83
+ ## Debug Sourcegraph query
84
+
85
+ Try the [ query] ( https://sourcegraph.com/search?q=context:global+file:%28%5E%7C/%29package.json%24+fork:no+-file:%28%5E%7C/%29%5C.+-file:%28%5E%7C/%29%28node_modules%7Ctest%7Ctests%7Cfixture%7Cfixtures%7Cexamples%29/+count:all+archived:no+-file:%28%5E%7C/%29vendor/+&patternType=standard ) on Sourcegraph!
0 commit comments