git-truck 0.8.7-0 → 0.8.7-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 (75) hide show
  1. package/build/index.js +10 -10
  2. package/package.json +6 -2
  3. package/.eslintrc.json +0 -23
  4. package/.github/workflows/bump-version.yml +0 -43
  5. package/.github/workflows/test-and-build.yml +0 -40
  6. package/.husky/pre-commit +0 -4
  7. package/.vscode/extensions.json +0 -7
  8. package/.vscode/launch.json +0 -24
  9. package/.vscode/settings.json +0 -6
  10. package/CONTRIBUTING.md +0 -26
  11. package/dev.js +0 -23
  12. package/post-build.js +0 -14
  13. package/project-statement.md +0 -43
  14. package/remix.config.js +0 -21
  15. package/remix.env.d.ts +0 -2
  16. package/server.ts +0 -105
  17. package/src/analyzer/analyze.server.ts +0 -288
  18. package/src/analyzer/analyze.test.ts +0 -30
  19. package/src/analyzer/args.server.ts +0 -48
  20. package/src/analyzer/coauthors.server.ts +0 -17
  21. package/src/analyzer/constants.ts +0 -1
  22. package/src/analyzer/git-caller.server.ts +0 -290
  23. package/src/analyzer/hydrate.server.ts +0 -186
  24. package/src/analyzer/log.server.ts +0 -94
  25. package/src/analyzer/model.ts +0 -121
  26. package/src/analyzer/postprocessing.server.ts +0 -70
  27. package/src/analyzer/queue.ts +0 -87
  28. package/src/analyzer/util.server.ts +0 -197
  29. package/src/analyzer/util.test.ts +0 -8
  30. package/src/authorUnionUtil.test.ts +0 -78
  31. package/src/authorUnionUtil.ts +0 -71
  32. package/src/components/AnalyzingIndicator.tsx +0 -55
  33. package/src/components/Animations.ts +0 -14
  34. package/src/components/AuthorDistFragment.tsx +0 -27
  35. package/src/components/AuthorDistOther.tsx +0 -22
  36. package/src/components/Chart.tsx +0 -400
  37. package/src/components/Details.tsx +0 -297
  38. package/src/components/EnumSelect.tsx +0 -26
  39. package/src/components/GlobalInfo.tsx +0 -67
  40. package/src/components/HiddenFiles.tsx +0 -84
  41. package/src/components/Legend.tsx +0 -123
  42. package/src/components/LegendFragment.tsx +0 -29
  43. package/src/components/LegendOther.tsx +0 -42
  44. package/src/components/Main.tsx +0 -102
  45. package/src/components/Options.tsx +0 -36
  46. package/src/components/Providers.tsx +0 -88
  47. package/src/components/SearchBar.tsx +0 -105
  48. package/src/components/SidePanel.tsx +0 -11
  49. package/src/components/Spacer.tsx +0 -71
  50. package/src/components/Toggle.tsx +0 -58
  51. package/src/components/Tooltip.tsx +0 -124
  52. package/src/components/util.tsx +0 -185
  53. package/src/const.ts +0 -6
  54. package/src/contexts/ClickedContext.ts +0 -17
  55. package/src/contexts/DataContext.ts +0 -12
  56. package/src/contexts/MetricContext.ts +0 -12
  57. package/src/contexts/OptionsContext.ts +0 -51
  58. package/src/contexts/PathContext.ts +0 -16
  59. package/src/contexts/SearchContext.ts +0 -19
  60. package/src/entry.client.tsx +0 -10
  61. package/src/entry.server.tsx +0 -23
  62. package/src/extension-color.ts +0 -34
  63. package/src/hooks.ts +0 -26
  64. package/src/lang-map.d.ts +0 -3
  65. package/src/metrics.ts +0 -364
  66. package/src/root.tsx +0 -81
  67. package/src/routes/$repo.tsx +0 -149
  68. package/src/routes/index.tsx +0 -172
  69. package/src/styles/App.css +0 -3
  70. package/src/styles/Chart.css +0 -26
  71. package/src/styles/index.css +0 -47
  72. package/src/styles/vars.css +0 -22
  73. package/src/util.ts +0 -55
  74. package/truckconfig.json +0 -22
  75. package/tsconfig.json +0 -22
package/build/index.js CHANGED
@@ -1853,7 +1853,7 @@ function handleRequest(request, responseStatusCode, responseHeaders, remixContex
1853
1853
  });
1854
1854
  }
1855
1855
 
1856
- // route:C:\Users\Tjoms\Documents\GitHub\git-visual\src\root.tsx
1856
+ // route:C:\Users\jonas\p\git-truck\src\root.tsx
1857
1857
  var root_exports = {};
1858
1858
  __export(root_exports, {
1859
1859
  CatchBoundary: () => CatchBoundary,
@@ -1877,7 +1877,7 @@ var styles_default = "/build/_assets/index-OING3CPO.css";
1877
1877
  // src/styles/Chart.css
1878
1878
  var Chart_default = "/build/_assets/Chart-OOZGWRB3.css";
1879
1879
 
1880
- // route:C:\Users\Tjoms\Documents\GitHub\git-visual\src\root.tsx
1880
+ // route:C:\Users\jonas\p\git-truck\src\root.tsx
1881
1881
  var import_react = require("react");
1882
1882
 
1883
1883
  // src/components/util.tsx
@@ -2044,7 +2044,7 @@ var Grower = import_styled_components2.default.div`
2044
2044
  flex-grow: 1;
2045
2045
  `;
2046
2046
 
2047
- // route:C:\Users\Tjoms\Documents\GitHub\git-visual\src\root.tsx
2047
+ // route:C:\Users\jonas\p\git-truck\src\root.tsx
2048
2048
  var meta = () => {
2049
2049
  return { title: "Git Truck \u{1F69B}" };
2050
2050
  };
@@ -2075,7 +2075,7 @@ var ErrorBoundary = ({ error: error2 }) => {
2075
2075
  return /* @__PURE__ */ React.createElement("html", null, /* @__PURE__ */ React.createElement("head", null, /* @__PURE__ */ React.createElement("title", null, "Oops! An error wasn't handled"), /* @__PURE__ */ React.createElement(import_remix2.Meta, null), /* @__PURE__ */ React.createElement(import_remix2.Links, null)), /* @__PURE__ */ React.createElement("body", null, /* @__PURE__ */ React.createElement("h1", null, error2.message), /* @__PURE__ */ React.createElement(Code, null, error2.stack), /* @__PURE__ */ React.createElement(import_remix2.Scripts, null)));
2076
2076
  };
2077
2077
 
2078
- // route:C:\Users\Tjoms\Documents\GitHub\git-visual\src\routes\$repo.tsx
2078
+ // route:C:\Users\jonas\p\git-truck\src\routes\$repo.tsx
2079
2079
  var repo_exports = {};
2080
2080
  __export(repo_exports, {
2081
2081
  ErrorBoundary: () => ErrorBoundary2,
@@ -4650,7 +4650,7 @@ var scripts = {
4650
4650
  test: "jest --coverage",
4651
4651
  clean: "rimraf -rf build public/build .cache .temp",
4652
4652
  tsc: "tsc",
4653
- build: "remix setup node && cross-env NODE_ENV=production remix build && node ./post-build.js",
4653
+ build: "rimraf -rf build public/build && remix setup node && cross-env NODE_ENV=production remix build && node ./post-build.js",
4654
4654
  dev: "cross-env NODE_ENV=development remix build && node dev.js",
4655
4655
  "dev:remix": "cross-env NODE_ENV=development remix watch",
4656
4656
  postinstall: "npm run build",
@@ -6484,7 +6484,7 @@ function HiddenFiles() {
6484
6484
  }))), /* @__PURE__ */ React.createElement(Code, null, hiddenFileFormat(hidden))))) : null);
6485
6485
  }
6486
6486
 
6487
- // route:C:\Users\Tjoms\Documents\GitHub\git-visual\src\routes\$repo.tsx
6487
+ // route:C:\Users\jonas\p\git-truck\src\routes\$repo.tsx
6488
6488
  var import_semver_compare = __toESM(require("semver-compare"));
6489
6489
 
6490
6490
  // src/components/Details.tsx
@@ -6769,7 +6769,7 @@ function hasZeroContributions(authors2) {
6769
6769
  return true;
6770
6770
  }
6771
6771
 
6772
- // route:C:\Users\Tjoms\Documents\GitHub\git-visual\src\routes\$repo.tsx
6772
+ // route:C:\Users\jonas\p\git-truck\src\routes\$repo.tsx
6773
6773
  var import_path9 = require("path");
6774
6774
  var invalidateCache = false;
6775
6775
  var loader = async ({ params, request }) => {
@@ -6851,7 +6851,7 @@ function Index() {
6851
6851
  }, "npx git-truck@latest"))) : null, /* @__PURE__ */ React.createElement(Grower, null), /* @__PURE__ */ React.createElement(Details, null), data.hiddenFiles.length > 0 ? /* @__PURE__ */ React.createElement(HiddenFiles, null) : null, /* @__PURE__ */ React.createElement(Legend, null))));
6852
6852
  }
6853
6853
 
6854
- // route:C:\Users\Tjoms\Documents\GitHub\git-visual\src\routes\index.tsx
6854
+ // route:C:\Users\jonas\p\git-truck\src\routes\index.tsx
6855
6855
  var routes_exports = {};
6856
6856
  __export(routes_exports, {
6857
6857
  action: () => action2,
@@ -6911,7 +6911,7 @@ function AnalyzingIndicator() {
6911
6911
  }))));
6912
6912
  }
6913
6913
 
6914
- // route:C:\Users\Tjoms\Documents\GitHub\git-visual\src\routes\index.tsx
6914
+ // route:C:\Users\jonas\p\git-truck\src\routes\index.tsx
6915
6915
  var import_path10 = require("path");
6916
6916
  var import_react_use4 = require("react-use");
6917
6917
  var hasRedirected = false;
@@ -7025,7 +7025,7 @@ var SLink = (0, import_styled_components18.default)(import_remix7.Link)`
7025
7025
 
7026
7026
  // server-assets-manifest:@remix-run/dev/assets-manifest
7027
7027
  init_react();
7028
- var assets_manifest_default = { "version": "5412442a", "entry": { "module": "/build/entry.client-LYPBBYXO.js", "imports": ["/build/_shared/chunk-3UBBWI7X.js", "/build/_shared/chunk-IWPB7HVR.js"] }, "routes": { "root": { "id": "root", "parentId": void 0, "path": "", "index": void 0, "caseSensitive": void 0, "module": "/build/root-VHDXTAMR.js", "imports": ["/build/_shared/chunk-XQMVET66.js"], "hasAction": false, "hasLoader": false, "hasCatchBoundary": true, "hasErrorBoundary": true }, "routes/$repo": { "id": "routes/$repo", "parentId": "root", "path": ":repo", "index": void 0, "caseSensitive": void 0, "module": "/build/routes/$repo-YXECZ46Y.js", "imports": ["/build/_shared/chunk-4JENRIWS.js"], "hasAction": true, "hasLoader": true, "hasCatchBoundary": false, "hasErrorBoundary": true }, "routes/index": { "id": "routes/index", "parentId": "root", "path": void 0, "index": true, "caseSensitive": void 0, "module": "/build/routes/index-VUMSNVVJ.js", "imports": ["/build/_shared/chunk-4JENRIWS.js"], "hasAction": true, "hasLoader": true, "hasCatchBoundary": false, "hasErrorBoundary": false } }, "url": "/build/manifest-5412442A.js" };
7028
+ var assets_manifest_default = { "version": "87dfcc32", "entry": { "module": "/build/entry.client-LYPBBYXO.js", "imports": ["/build/_shared/chunk-3UBBWI7X.js", "/build/_shared/chunk-IWPB7HVR.js"] }, "routes": { "root": { "id": "root", "parentId": void 0, "path": "", "index": void 0, "caseSensitive": void 0, "module": "/build/root-YFFMOAIE.js", "imports": ["/build/_shared/chunk-XQMVET66.js"], "hasAction": false, "hasLoader": false, "hasCatchBoundary": true, "hasErrorBoundary": true }, "routes/$repo": { "id": "routes/$repo", "parentId": "root", "path": ":repo", "index": void 0, "caseSensitive": void 0, "module": "/build/routes/$repo-ORF3ZRBA.js", "imports": ["/build/_shared/chunk-4JENRIWS.js"], "hasAction": true, "hasLoader": true, "hasCatchBoundary": false, "hasErrorBoundary": true }, "routes/index": { "id": "routes/index", "parentId": "root", "path": void 0, "index": true, "caseSensitive": void 0, "module": "/build/routes/index-JOOJGTNK.js", "imports": ["/build/_shared/chunk-4JENRIWS.js"], "hasAction": true, "hasLoader": true, "hasCatchBoundary": false, "hasErrorBoundary": false } }, "url": "/build/manifest-87DFCC32.js" };
7029
7029
 
7030
7030
  // server-entry-module:@remix-run/dev/server-build
7031
7031
  var entry = { module: entry_server_exports };
package/package.json CHANGED
@@ -1,16 +1,20 @@
1
1
  {
2
2
  "name": "git-truck",
3
- "version": "0.8.7-0",
3
+ "version": "0.8.7-experimental",
4
4
  "private": false,
5
5
  "description": "Visualizing a Git repository",
6
6
  "license": "MIT",
7
7
  "main": "./build/index.js",
8
8
  "bin": "./build/index.js",
9
+ "files": [
10
+ "build/index.js",
11
+ "build/public/**/*"
12
+ ],
9
13
  "scripts": {
10
14
  "test": "jest --coverage",
11
15
  "clean": "rimraf -rf build public/build .cache .temp",
12
16
  "tsc": "tsc",
13
- "build": "remix setup node && cross-env NODE_ENV=production remix build && node ./post-build.js",
17
+ "build": "rimraf -rf build public/build && remix setup node && cross-env NODE_ENV=production remix build && node ./post-build.js",
14
18
  "dev": "cross-env NODE_ENV=development remix build && node dev.js",
15
19
  "dev:remix": "cross-env NODE_ENV=development remix watch",
16
20
  "postinstall": "npm run build",
package/.eslintrc.json DELETED
@@ -1,23 +0,0 @@
1
- {
2
- "env": {
3
- "browser": false,
4
- "es2021": true
5
- },
6
- "extends": [
7
- "@remix-run/eslint-config",
8
- "eslint:recommended",
9
- "plugin:@typescript-eslint/recommended"
10
- ],
11
- "parser": "@typescript-eslint/parser",
12
- "parserOptions": {
13
- "ecmaVersion": "latest",
14
- "sourceType": "module"
15
- },
16
- "plugins": [
17
- "@typescript-eslint"
18
- ],
19
- "rules": {
20
- "no-case-declarations":"off"
21
- }
22
- }
23
-
@@ -1,43 +0,0 @@
1
- name: "Bump version"
2
-
3
- on:
4
- push:
5
- branches:
6
- - "main"
7
-
8
- jobs:
9
- bump-version:
10
- name: "Bump Version on main"
11
- runs-on: ubuntu-latest
12
-
13
- steps:
14
- - name: "Checkout source code"
15
- uses: "actions/checkout@v2"
16
- with:
17
- ref: ${{ github.ref }}
18
- token: ${{ secrets.TOKEN }}
19
- - name: "cat package.json"
20
- run: cat ./package.json
21
- - name: "Setup Node.js"
22
- uses: "actions/setup-node@v2"
23
- with:
24
- node-version: 16
25
- - name: Update version in package.json
26
- uses: "phips28/gh-action-bump-version@master"
27
- with:
28
- skip-tag: "true"
29
- minor-wording: "NewVersion"
30
- commit-message: "Bump version to {{version}}"
31
- env:
32
- GITHUB_TOKEN: ${{ secrets.TOKEN }}
33
-
34
- - run: npm install --package-lock-only --ignore-scripts
35
- - run: git add package-lock.json
36
- - run: git config user.email "version-bot@example.com"
37
- - run: git config user.name "Version Bot"
38
- - run: git commit --amend --no-edit
39
- # This part is not essential to the workflow, so exit softly with a zero exit code
40
- - run: git push --force || exit 0
41
-
42
- - name: "cat package.json"
43
- run: cat ./package.json
@@ -1,40 +0,0 @@
1
- # This workflow will do a clean install of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
- # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
3
-
4
- name: Test and build
5
-
6
- on:
7
- push:
8
- branches: [main]
9
- pull_request:
10
- branches: [main]
11
-
12
- jobs:
13
- test-and-build:
14
- runs-on: ubuntu-latest
15
-
16
- strategy:
17
- matrix:
18
- node-version: [16.x, 17.x]
19
- # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
20
-
21
- steps:
22
- - uses: actions/checkout@v2
23
- with:
24
- fetch-depth: '0'
25
-
26
- - name: Use Node.js ${{ matrix.node-version }}
27
- uses: actions/setup-node@v2
28
- with:
29
- node-version: ${{ matrix.node-version }}
30
- cache: 'npm'
31
-
32
- - run: npm ci
33
- - run: npm test
34
- - run: npm run build
35
- - run: npm run tsc
36
-
37
- - name: Upload coverage to Codecov
38
- uses: codecov/codecov-action@v2
39
- with:
40
- token: ${{ secrets.CODECOV_TOKEN }}
package/.husky/pre-commit DELETED
@@ -1,4 +0,0 @@
1
- #!/bin/sh
2
- . "$(dirname "$0")/_/husky.sh"
3
-
4
- npx lint-staged
@@ -1,7 +0,0 @@
1
- {
2
- "recommendations": [
3
- "esbenp.prettier-vscode",
4
- "styled-components.vscode-styled-components",
5
- "Orta.vscode-jest"
6
- ]
7
- }
@@ -1,24 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "name": "Debug Remix App",
9
- "program": "${workspaceFolder}/build/index.js",
10
- "request": "launch",
11
- "skipFiles": [
12
- "<node_internals>/**"
13
- ],
14
- "type": "pwa-node"
15
- },
16
- {
17
- "type": "pwa-chrome",
18
- "request": "launch",
19
- "name": "Launch visualization in chrome",
20
- "url": "http://localhost:3000",
21
- "webRoot": "${workspaceFolder}"
22
- }
23
- ]
24
- }
@@ -1,6 +0,0 @@
1
- {
2
- "editor.formatOnSave": false,
3
- "typescript.tsserver.experimental.enableProjectDiagnostics": false,
4
- "githubIssues.issueBranchTitle": "${issueNumber}/${sanitizedIssueTitle}",
5
- "editor.defaultFormatter": "esbenp.prettier-vscode"
6
- }
package/CONTRIBUTING.md DELETED
@@ -1,26 +0,0 @@
1
- # [Development](#development)
2
-
3
- 1. Install dependencies with `npm install`
4
- 2. Run git-truck in development mode with:
5
-
6
- ```sh
7
- npm run dev -- <args>
8
- ```
9
-
10
- _or using yarn:_ `yarn dev`
11
-
12
- This starts the app in development mode, rebuilding assets on file changes.
13
-
14
- For arguments, see [Arguments](#arguments).
15
-
16
- # [Husky](#husky)
17
-
18
- To enable husky, run `npx husky install`.
19
-
20
- # [Clean up](#clean-up)
21
-
22
- To clean up build artefacts, cached analyzations, etc., run:
23
-
24
- ```
25
- npm run clean
26
- ```
package/dev.js DELETED
@@ -1,23 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-var-requires */
2
- const runAll = require("npm-run-all")
3
- const open = require("open")
4
-
5
- ;(async () => {
6
- const getPortLib = (await import("get-port"))
7
- const getPort = getPortLib.default
8
- const port = await getPort({
9
- port: [80, ...getPortLib.portNumbers(3000, 4000)],
10
- })
11
-
12
- process.env["PORT"] = port.toString()
13
-
14
- open("http://localhost:" + port)
15
- await runAll(
16
- [`dev:node -- ${process.argv.slice(2).join(" ")}`, "dev:remix"],
17
- {
18
- parallel: true,
19
- stdout: process.stdout,
20
- stderr: process.stderr,
21
- }
22
- )
23
- })()
package/post-build.js DELETED
@@ -1,14 +0,0 @@
1
- const fs = require("fs")
2
-
3
- const shebang = "#!/usr/bin/env node\n"
4
- const buildPath = "./build/index.js"
5
-
6
- const data = fs.readFileSync(buildPath)
7
- const fd = fs.openSync(buildPath, "w+")
8
- const insert = Buffer.from(shebang)
9
- fs.writeSync(fd, insert, 0, insert.length, 0)
10
- fs.writeSync(fd, data, 0, data.length, insert.length)
11
- fs.close(fd, (err) => {
12
- if (err) throw err
13
- })
14
- fs.chmodSync(buildPath, "755")
@@ -1,43 +0,0 @@
1
- - [ ] Fill in project agreement
2
- - [ ] Problem statement
3
- - [ ] Approach
4
- - [ ] Product to be handed in
5
- - [ ] Invite Mircea to Project Agreement
6
- https://mit.itu.dk/ucs/pb/project.sml?project_id=8408528&mode=project
7
-
8
- ### Problem statement
9
-
10
- How can you visualize a codebase in an interactive, interesting, useful and insightful way?
11
-
12
- |Who |Function |Problem |Solution(abstract) |Product(concrete) |Implementation challenges |
13
- |:-: |:-: |:-: |:-: |:-: |:-: |
14
- |-Lead |Eval procedure |Say/do |Be informed |Procedure viz | |
15
- | | | | | | |
16
- |Tech lead |Task delegation |Truck factor, File dominance |Be informed of file dominance |blame/author viz |1 person - multiple users, 1 person override all files |
17
- |Mircea |Evaluate DevOps student projects |Many project to get familiar with |Overview |viz | |
18
- | |Enforce code style |Improper commit/pr sizing | |commit timeline, with files changed hightlighted | |
19
-
20
- ### Approach
21
-
22
- ### Product to be handed in
23
-
24
- ## Project agreement guidelines
25
- * What is the title of the project?
26
- * Problem statement. Consider the following:
27
- * To identify, define and delimit a problem within information technology.
28
- * To identify and analyse relevant means for solving the problem, such as academic theories, methods, literature, tools and other sources, as well as existing solutions to the problem.
29
- * To combine the selected means, develop them further if necessary, and apply them in a concerted effort towards the solution of the problem.
30
- * To evaluate the achieved solution.
31
- * To report in a coherent and stringent way the problem, the background research, the work towards the solution, the achieved solution, the evaluation, and other relevant material, while adhering to the academic standards.
32
- * To reflect upon the problem, the chosen approach, the achieved solution, and other findings.
33
- * Approach
34
- * Which activities you plan to implement to carry out the project, for
35
- instance study of literature, collecting and working up empirical data, development
36
- and test of prototype or production etc.
37
- * Product to be handed in
38
- * Describe what you intend to upload.
39
- * Type of examination (Group exam)
40
- * Practicalities (not necessarily required)
41
- * When will we work?
42
- * Where will we work?
43
- * When should we aim to be done with the project?
package/remix.config.js DELETED
@@ -1,21 +0,0 @@
1
- /**
2
- * @type {import('@remix-run/dev').AppConfig}
3
- */
4
- module.exports = {
5
- server: "./server.ts",
6
- ignoredRouteFiles: [".*", "components/*"],
7
- serverDependenciesToBundle: [
8
- "styled-components",
9
- "d3-hierarchy",
10
- "@react-aria/utils",
11
- "is-binary-path",
12
- "yargs-parser",
13
- "gitignore-parser",
14
- "latest-version"
15
- ],
16
- appDirectory: "src",
17
- // assetsBuildDirectory: "public/build",
18
- // serverBuildPath: "build/index.js",
19
- // publicPath: "/build/",
20
- // devServerPort: 8002
21
- }
package/remix.env.d.ts DELETED
@@ -1,2 +0,0 @@
1
- /// <reference types="@remix-run/dev" />
2
- /// <reference types="@remix-run/node/globals" />
package/server.ts DELETED
@@ -1,105 +0,0 @@
1
- import * as serverBuild from "@remix-run/dev/server-build"
2
- import { createRequestHandler } from "@remix-run/express"
3
- import compression from "compression"
4
- import express from "express"
5
- import latestVersion from "latest-version"
6
- import morgan from "morgan"
7
- import open from "open"
8
- import { join } from "path"
9
- import semverCompare from "semver-compare"
10
- import pkg from "./package.json"
11
- import { parseArgs } from "./src/analyzer/args.server"
12
-
13
- const args = parseArgs()
14
-
15
- ;(async () => {
16
- const latestV = await latestVersion(pkg.name)
17
- const currentV = pkg.version
18
-
19
- // Soft clear the console
20
- process.stdout.write("\u001b[2J\u001b[0;0H")
21
- console.log()
22
-
23
- const updateMessage =
24
- latestV && semverCompare(latestV, currentV) === 1
25
- ? ` [!] Update available: ${latestV}
26
-
27
- To update, run:
28
-
29
- npx git-truck@latest
30
-
31
- Or to install globally:
32
-
33
- npm install -g git-truck@latest
34
-
35
- `
36
- : " (latest)"
37
-
38
- console.log(`Git Truck version ${currentV}${updateMessage}`)
39
-
40
- if (args.h || args.help) {
41
- console.log()
42
- console.log(`See
43
-
44
- ${pkg.homepage}
45
-
46
- for usage instructions.`)
47
- console.log()
48
- process.exit(0)
49
- }
50
-
51
- const app = express()
52
-
53
- app.use(compression())
54
-
55
- // http://expressjs.com/en/advanced/best-practice-security.html#at-a-minimum-disable-x-powered-by-header
56
- app.disable("x-powered-by")
57
-
58
- const staticAssetsPath = join(__dirname, "../public/build")
59
- // Remix fingerprints its assets so we can cache forever.
60
- app.use("/build", express.static(staticAssetsPath, { immutable: true, maxAge: "1y" }))
61
-
62
- // Everything else (like favicon.ico) is cached for an hour. You may want to be
63
- // more aggressive with this caching.
64
- app.use(express.static(staticAssetsPath, { maxAge: "1h" }))
65
-
66
- app.use(morgan("tiny"))
67
-
68
- app.all(
69
- "*",
70
- createRequestHandler({
71
- build: serverBuild,
72
- mode: process.env.NODE_ENV,
73
- })
74
- )
75
-
76
- let devServerPort: number | null = null
77
- let userHasProvidedPort = false
78
- let minPort = 3000
79
-
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
- }
88
-
89
- const getPortLib = await import("get-port")
90
- const getPort = getPortLib.default
91
- const port = await getPort({
92
- port: devServerPort ?? [...(!userHasProvidedPort ? [80] : []), ...getPortLib.portNumbers(minPort, minPort + 1000)],
93
- })
94
- app.listen(port).once("listening", () => printOpen(port))
95
- })()
96
-
97
- async function printOpen(port: number) {
98
- console.log()
99
- console.log(`Now listening on port ${port}`)
100
- if (process.env.NODE_ENV !== "development") {
101
- const url = `http://localhost:${port}`
102
- console.log(`Opening ${url} in your browser`)
103
- await open(url)
104
- }
105
- }