git-truck 0.8.4-1 → 0.8.6-experimental

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.
Files changed (41) hide show
  1. package/README.md +17 -13
  2. package/cli.js +2 -0
  3. package/dev.js +4 -2
  4. package/package.json +4 -4
  5. package/server.ts +13 -8
  6. package/src/analyzer/analyze.server.ts +288 -322
  7. package/src/analyzer/analyze.test.ts +30 -30
  8. package/src/analyzer/args.server.ts +20 -6
  9. package/src/analyzer/constants.ts +1 -1
  10. package/src/analyzer/git-caller.server.ts +290 -0
  11. package/src/analyzer/hydrate.server.ts +186 -186
  12. package/src/analyzer/model.ts +13 -2
  13. package/src/analyzer/{util.ts → util.server.ts} +27 -33
  14. package/src/analyzer/util.test.ts +1 -1
  15. package/src/components/AnalyzingIndicator.tsx +55 -0
  16. package/src/components/Animations.ts +14 -0
  17. package/src/components/Chart.tsx +29 -8
  18. package/src/components/Details.tsx +8 -7
  19. package/src/components/GlobalInfo.tsx +19 -8
  20. package/src/components/HiddenFiles.tsx +3 -3
  21. package/src/components/Legend.tsx +1 -1
  22. package/src/components/LegendOther.tsx +42 -42
  23. package/src/components/Main.tsx +1 -1
  24. package/src/components/SearchBar.tsx +1 -6
  25. package/src/components/util.tsx +19 -10
  26. package/src/const.ts +6 -6
  27. package/src/contexts/ClickedContext.ts +17 -17
  28. package/src/contexts/DataContext.ts +12 -12
  29. package/src/contexts/MetricContext.ts +12 -12
  30. package/src/contexts/OptionsContext.ts +51 -51
  31. package/src/contexts/SearchContext.ts +19 -19
  32. package/src/lang-map.d.ts +3 -3
  33. package/src/metrics.ts +3 -2
  34. package/src/root.tsx +44 -1
  35. package/src/routes/{repo.tsx → $repo.tsx} +59 -15
  36. package/src/routes/index.tsx +156 -46
  37. package/build/index.js +0 -6838
  38. package/post-build.js +0 -14
  39. package/public/favicon.ico +0 -0
  40. package/src/analyzer/git-caller.ts +0 -117
  41. package/src/analyzer/index.ts +0 -4
package/README.md CHANGED
@@ -18,9 +18,9 @@ To check if these programs are installed, and what version you have, run `node -
18
18
 
19
19
  ## [Get started](#get-started)
20
20
 
21
- 1. In your favorite shell (for example cmd, PowerShell, etc.), navigate to the root directory of a git project you want to visualize.
22
- 2. Execute the command `npx git-truck@latest`. Click `y` if it asks you to download the tool. A blank browser-window will open and Git Truck will now start analyzing your project (This might take a while to run, especially on big projects, you can follow the progress in your terminal). If you get an error in the terminal, you can try installing the tool globally by running `npm i -g git-truck@latest` and then run `git-truck` instead.
23
- 3. When Git Truck is done analyzing your project, it will show the visualization in your browser. Enjoy!
21
+ 1. Within a git repository, or a directory containing git repositories, run the command `npx git-truck@latest`.
22
+ 2. Press `y` if it asks you to download the package.
23
+ 3. The application will now open in your default browser.
24
24
 
25
25
  ## [I got an error or I want to give feedback, what do i do?](#i-got-an-error-or-i-want-to-give-feedback-what-do-i-do)
26
26
 
@@ -38,19 +38,23 @@ npx git-truck [args]
38
38
 
39
39
  ### [Arguments](#arguments)
40
40
 
41
- | arg | description | default value |
42
- | :--------: | :-------------------------------------------------------------------: | :----------------: |
43
- | `--branch` | branch name | checked out branch |
44
- | `--path` | path to git repository | current directory |
45
- | `--log` | output log level. See [here](./src/analyzer/log.server.ts) for values | - |
46
- | `--port` | port to use for the program | 3000 |
41
+ | arg | description | default value |
42
+ | :------------------: | :-------------------------------------------------------------------: | :----------------: |
43
+ | `--branch` | branch name | checked out branch |
44
+ | `--path` | path to a folder or a git repository | current directory |
45
+ | `--log` | output log level. See [here](./src/analyzer/log.server.ts) for values | - |
46
+ | `--port` | port to use for the program | 3000 |
47
+ | `--invalidate-cache` | bypass analyzer cache manually | - |
48
+
49
+ **Note:** Using `--invalidate-cache` will cause the analyzer to run every time the client talks to the server.
47
50
 
48
51
  ### [Configuration](#configuration)
49
52
 
50
53
  You can add a `truckconfig.json` file to the root of your project, where you can define the arguments you want.
51
- Additionally you can define which git-aliases should be considered as the same person.
54
+ Additionally you can define which git-aliases should be considered as the same person using `unionedAuthors`. If provided, the first name in the array is used as the name of the person.
52
55
  You can also define files to ignore.
53
- Example:
56
+
57
+ **Example:**
54
58
 
55
59
  ```json
56
60
  {
@@ -60,7 +64,7 @@ Example:
60
64
  ["Bob", "Bobby Bob"],
61
65
  ["Alice", "aliiii", "alice alice"]
62
66
  ],
63
- "hiddenFiles": ["package-lock.json", "*.bin", "*.svg"]
67
+ "hiddenFiles": ["package-lock.json", "*.bin", "*.svg"],
68
+ "invalidateCache": true
64
69
  }
65
-
66
70
  ```
package/cli.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ require("./build/index.js")
package/dev.js CHANGED
@@ -6,12 +6,14 @@ const open = require("open")
6
6
  const getPortLib = (await import("get-port"))
7
7
  const getPort = getPortLib.default
8
8
  const port = await getPort({
9
- port: getPortLib.portNumbers(3000, 4000),
9
+ port: [80, ...getPortLib.portNumbers(3000, 4000)],
10
10
  })
11
11
 
12
+ process.env["PORT"] = port.toString()
13
+
12
14
  open("http://localhost:" + port)
13
15
  await runAll(
14
- [`dev:node -- --port ${port} ${process.argv.join(" ")}`, "dev:remix"],
16
+ [`dev:node -- ${process.argv.slice(2).join(" ")}`, "dev:remix"],
15
17
  {
16
18
  parallel: true,
17
19
  stdout: process.stdout,
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "git-truck",
3
- "version": "0.8.4-1",
3
+ "version": "0.8.6-experimental",
4
4
  "private": false,
5
5
  "description": "Visualizing a Git repository",
6
6
  "license": "MIT",
7
- "main": "./build/index.js",
8
- "bin": "./build/index.js",
7
+ "main": "./cli.js",
8
+ "bin": "./cli.js",
9
9
  "scripts": {
10
10
  "test": "jest --coverage",
11
11
  "clean": "rimraf -rf build public/build .cache .temp",
12
12
  "tsc": "tsc",
13
- "build": "remix setup node && cross-env NODE_ENV=production remix build && node ./post-build.js",
13
+ "build": "remix setup node && cross-env NODE_ENV=production remix build",
14
14
  "dev": "cross-env NODE_ENV=development remix build && node dev.js",
15
15
  "dev:remix": "cross-env NODE_ENV=development remix watch",
16
16
  "postinstall": "npm run build",
package/server.ts CHANGED
@@ -57,10 +57,7 @@ for usage instructions.`)
57
57
 
58
58
  const staticAssetsPath = join(__dirname, "../public/build")
59
59
  // Remix fingerprints its assets so we can cache forever.
60
- app.use(
61
- "/build",
62
- express.static(staticAssetsPath, { immutable: true, maxAge: "1y" })
63
- )
60
+ app.use("/build", express.static(staticAssetsPath, { immutable: true, maxAge: "1y" }))
64
61
 
65
62
  // Everything else (like favicon.ico) is cached for an hour. You may want to be
66
63
  // more aggressive with this caching.
@@ -76,16 +73,24 @@ for usage instructions.`)
76
73
  })
77
74
  )
78
75
 
76
+ let devServerPort: number | null = null
77
+ let userHasProvidedPort = false
79
78
  let minPort = 3000
80
79
 
81
- if (args.port && !isNaN(parseInt(args.port))) minPort = parseInt(args.port)
80
+ if (args.port && !isNaN(parseInt(args.port))) {
81
+ minPort = parseInt(args.port)
82
+ userHasProvidedPort = true
83
+ }
84
+
85
+ if (process.env["PORT"] && !isNaN(parseInt(process.env["PORT"]))) {
86
+ devServerPort = parseInt(process.env["PORT"])
87
+ }
82
88
 
83
89
  const getPortLib = await import("get-port")
84
90
  const getPort = getPortLib.default
85
91
  const port = await getPort({
86
- port: getPortLib.portNumbers(minPort, minPort + 1000),
92
+ port: devServerPort ?? [...(!userHasProvidedPort ? [80] : []), ...getPortLib.portNumbers(minPort, minPort + 1000)],
87
93
  })
88
-
89
94
  app.listen(port).once("listening", () => printOpen(port))
90
95
  })()
91
96
 
@@ -93,7 +98,7 @@ async function printOpen(port: number) {
93
98
  console.log()
94
99
  console.log(`Now listening on port ${port}`)
95
100
  if (process.env.NODE_ENV !== "development") {
96
- const url = "http://localhost:" + port
101
+ const url = `http://localhost:${port}`
97
102
  console.log(`Opening ${url} in your browser`)
98
103
  await open(url)
99
104
  }