@stacksjs/git 0.58.27 → 0.58.43

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 (2) hide show
  1. package/dist/index.js +40 -0
  2. package/package.json +3 -3
package/dist/index.js CHANGED
@@ -1,6 +1,46 @@
1
1
  // @bun
2
2
  // src/index.ts
3
3
  import * as changelog from "changelogen";
4
+ function useGitHub() {
5
+ function getTimeDifference(givenDateString) {
6
+ const givenDate = new Date(givenDateString);
7
+ const currentDate = new Date;
8
+ const timeDifference = currentDate.getTime() - givenDate.getTime();
9
+ const secondsDifference = Math.floor(timeDifference / 1000);
10
+ const minutesDifference = Math.floor(secondsDifference / 60);
11
+ const hoursDifference = Math.floor(minutesDifference / 60);
12
+ const daysDifference = Math.floor(hoursDifference / 24);
13
+ const weeksDifference = Math.floor(daysDifference / 7);
14
+ if (secondsDifference < 60) {
15
+ return `${secondsDifference}s`;
16
+ } else if (minutesDifference < 60) {
17
+ const remainingSeconds = secondsDifference % 60;
18
+ return `${minutesDifference}m ${remainingSeconds}s`;
19
+ } else if (hoursDifference < 24) {
20
+ const remainingMinutes = minutesDifference % 60;
21
+ return `${hoursDifference}h ${remainingMinutes}m`;
22
+ } else if (weeksDifference < 7) {
23
+ const remainingHours = hoursDifference % 24;
24
+ return `${daysDifference}d ${remainingHours}h`;
25
+ }
26
+ return `${weeksDifference}w`;
27
+ }
28
+ function formatDuration(durationInSeconds) {
29
+ const minutes = Math.floor(durationInSeconds / 60);
30
+ const seconds = durationInSeconds % 60;
31
+ if (minutes > 1)
32
+ return `${minutes}m ${seconds}s`;
33
+ return `${seconds}s`;
34
+ }
35
+ function getActionRunDuration(startTime, endTime) {
36
+ const start = new Date(startTime);
37
+ const end = new Date(endTime);
38
+ const durationInSeconds = Math.floor((end.getTime() - start.getTime()) / 1000);
39
+ return formatDuration(durationInSeconds);
40
+ }
41
+ return { getTimeDifference, formatDuration, getActionRunDuration };
42
+ }
4
43
  export {
44
+ useGitHub,
5
45
  changelog
6
46
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/git",
3
3
  "type": "module",
4
- "version": "0.58.27",
4
+ "version": "0.58.43",
5
5
  "description": "The Stacks git utilities & conventions.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -47,7 +47,7 @@
47
47
  "prepublishOnly": "bun --bun run build"
48
48
  },
49
49
  "peerDependencies": {
50
- "bumpp": "^9.2.1",
50
+ "bumpp": "^9.3.0",
51
51
  "changelogen": "^0.5.5",
52
52
  "commitizen": "^4.3.0",
53
53
  "cz-git": "^1.8.0",
@@ -55,7 +55,7 @@
55
55
  "simple-git-hooks": "^2.9.0"
56
56
  },
57
57
  "dependencies": {
58
- "bumpp": "^9.2.1",
58
+ "bumpp": "^9.3.0",
59
59
  "changelogen": "^0.5.5",
60
60
  "commitizen": "^4.3.0",
61
61
  "cz-git": "^1.8.0",