git-stack-cli 1.0.2 → 1.0.4

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 (79) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/index.cjs +3 -3
  3. package/package.json +15 -8
  4. package/rollup.config.mjs +46 -0
  5. package/scripts/.eslintrc.cjs +61 -0
  6. package/scripts/build-standalone.ts +73 -0
  7. package/scripts/core/create_asset.ts +21 -0
  8. package/scripts/core/file.ts +36 -0
  9. package/scripts/core/spawn.ts +62 -0
  10. package/scripts/npm-prepublishOnly.ts +8 -0
  11. package/scripts/release-brew.ts +69 -0
  12. package/scripts/release-github.ts +34 -0
  13. package/scripts/release-npm.ts +109 -0
  14. package/scripts/tsconfig.json +35 -0
  15. package/src/__fixtures__/metadata.ts +666 -0
  16. package/src/app/App.tsx +65 -0
  17. package/src/app/AutoUpdate.tsx +229 -0
  18. package/src/app/Await.tsx +82 -0
  19. package/src/app/Brackets.tsx +22 -0
  20. package/src/app/Command.tsx +19 -0
  21. package/src/app/Debug.tsx +52 -0
  22. package/src/app/DependencyCheck.tsx +155 -0
  23. package/src/app/Exit.tsx +25 -0
  24. package/src/app/FormatText.tsx +26 -0
  25. package/src/app/GatherMetadata.tsx +145 -0
  26. package/src/app/GithubApiError.tsx +78 -0
  27. package/src/app/LocalCommitStatus.tsx +70 -0
  28. package/src/app/LocalMergeRebase.tsx +230 -0
  29. package/src/app/LogTimestamp.tsx +12 -0
  30. package/src/app/Main.tsx +52 -0
  31. package/src/app/ManualRebase.tsx +308 -0
  32. package/src/app/MultiSelect.tsx +246 -0
  33. package/src/app/Output.tsx +37 -0
  34. package/src/app/Parens.tsx +21 -0
  35. package/src/app/PostRebaseStatus.tsx +33 -0
  36. package/src/app/PreLocalMergeRebase.tsx +31 -0
  37. package/src/app/PreSelectCommitRanges.tsx +31 -0
  38. package/src/app/Providers.tsx +11 -0
  39. package/src/app/RebaseCheck.tsx +96 -0
  40. package/src/app/SelectCommitRanges.tsx +372 -0
  41. package/src/app/Status.tsx +82 -0
  42. package/src/app/StatusTable.tsx +155 -0
  43. package/src/app/Store.tsx +252 -0
  44. package/src/app/Table.tsx +137 -0
  45. package/src/app/TextInput.tsx +88 -0
  46. package/src/app/Url.tsx +19 -0
  47. package/src/app/Waterfall.tsx +37 -0
  48. package/src/app/YesNoPrompt.tsx +73 -0
  49. package/src/command.ts +78 -0
  50. package/src/core/CommitMetadata.ts +212 -0
  51. package/src/core/Metadata.test.ts +41 -0
  52. package/src/core/Metadata.ts +51 -0
  53. package/src/core/StackSummaryTable.test.ts +157 -0
  54. package/src/core/StackSummaryTable.ts +127 -0
  55. package/src/core/Timer.ts +44 -0
  56. package/src/core/assertNever.ts +4 -0
  57. package/src/core/cache.ts +49 -0
  58. package/src/core/capitalize.ts +5 -0
  59. package/src/core/chalk.ts +103 -0
  60. package/src/core/clamp.ts +6 -0
  61. package/src/core/cli.ts +161 -0
  62. package/src/core/colors.ts +23 -0
  63. package/src/core/date.ts +25 -0
  64. package/src/core/fetch_json.ts +26 -0
  65. package/src/core/github.tsx +215 -0
  66. package/src/core/invariant.ts +5 -0
  67. package/src/core/is_command_available.ts +21 -0
  68. package/src/core/is_finite_value.ts +3 -0
  69. package/src/core/json.ts +32 -0
  70. package/src/core/match_group.ts +10 -0
  71. package/src/core/read_json.ts +12 -0
  72. package/src/core/safe_quote.ts +10 -0
  73. package/src/core/semver_compare.ts +27 -0
  74. package/src/core/short_id.ts +87 -0
  75. package/src/core/sleep.ts +3 -0
  76. package/src/core/wrap_index.ts +11 -0
  77. package/src/index.tsx +22 -0
  78. package/src/types/global.d.ts +7 -0
  79. package/tsconfig.json +53 -0
@@ -0,0 +1,87 @@
1
+ import crypto from "node:crypto";
2
+
3
+ export function short_id() {
4
+ const timestamp = Date.now();
5
+
6
+ // 9 223 372 036 854 775 808
7
+ // 9 trillion possible values
8
+ // (2^53) * (2^10) = 2^63 = 9,223,372,036,854,775,808
9
+ const js_max_bits = 53;
10
+
11
+ const timestamp_bits = Math.floor(Math.log2(timestamp)) + 1;
12
+
13
+ // padding needed to reach 53 bits
14
+ const padding_bits = js_max_bits - timestamp_bits;
15
+
16
+ // random between 0 and 2^padding_bits - 1
17
+ const random = crypto.randomInt(0, Math.pow(2, padding_bits));
18
+
19
+ // combine timestamp and random value
20
+ const combined = interleave_bits(timestamp, random);
21
+
22
+ // console.debug({ combined, timestamp, random, padding_bits, timestamp_bits });
23
+
24
+ return encode(combined);
25
+ }
26
+
27
+ function binary(value: number) {
28
+ return BigInt(value).toString(2);
29
+ }
30
+
31
+ function rand_index(list: Array<any>) {
32
+ return Math.floor(Math.random() * list.length);
33
+ }
34
+
35
+ function interleave_bits(a: number, b: number) {
36
+ const a_binary = binary(a).split("");
37
+
38
+ const b_binary = binary(b).split("");
39
+
40
+ while (b_binary.length) {
41
+ // pull random bit out of b_binary
42
+
43
+ const b_index = rand_index(b_binary);
44
+
45
+ const [selected] = b_binary.splice(b_index, 1);
46
+
47
+ // insert random bit into a_binary
48
+
49
+ const a_index = rand_index(a_binary);
50
+
51
+ a_binary.splice(a_index, 0, selected);
52
+ }
53
+
54
+ // convert binary list back to integer
55
+
56
+ const a_value = parseInt(a_binary.join(""), 2);
57
+
58
+ return a_value;
59
+ }
60
+
61
+ function encode(value: number) {
62
+ // base64 encode (64 characters)
63
+ // max character necessary to encode is equal to maximum number
64
+ // of bits in value divided by bits per character in encoding
65
+ //
66
+ // Example
67
+ // in base64 each characters can represent 6 bits (2^6 = 64)
68
+ // 53 bits / 6 bits = 8.833333333333334 characters (9 characters)
69
+ //
70
+ // prettier-ignore
71
+ const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-+";
72
+
73
+ const bits_per_char = Math.log2(chars.length);
74
+ const max_value_bits = 53;
75
+ const max_char_size = Math.ceil(max_value_bits / bits_per_char);
76
+
77
+ let result = "";
78
+
79
+ while (value > 0) {
80
+ result = chars[value % chars.length] + result;
81
+
82
+ value = Math.floor(value / chars.length);
83
+ }
84
+
85
+ // pad the result to necessary characters
86
+ return result.padStart(max_char_size, "=");
87
+ }
@@ -0,0 +1,3 @@
1
+ export async function sleep(time: number) {
2
+ return new Promise((resolve) => setTimeout(resolve, time));
3
+ }
@@ -0,0 +1,11 @@
1
+ export function wrap_index(value: number, list: Array<unknown>) {
2
+ const max = list.length - 1;
3
+
4
+ if (value === -1) {
5
+ return max;
6
+ } else if (value > max) {
7
+ return 0;
8
+ }
9
+
10
+ return value;
11
+ }
package/src/index.tsx ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env node
2
+
3
+ import * as React from "react";
4
+
5
+ import * as Ink from "ink-cjs";
6
+
7
+ import { App } from "~/app/App";
8
+ import { Store } from "~/app/Store";
9
+ import { command } from "~/command";
10
+
11
+ command()
12
+ .then((argv) => {
13
+ const ink = Ink.render(<App />);
14
+
15
+ Store.setState((state) => {
16
+ state.ink = ink;
17
+ state.argv = argv;
18
+ state.cwd = process.cwd();
19
+ });
20
+ })
21
+ // eslint-disable-next-line no-console
22
+ .catch(console.error);
@@ -0,0 +1,7 @@
1
+ declare namespace NodeJS {
2
+ interface ProcessEnv {
3
+ PATH: string;
4
+ DEV?: "true" | "false";
5
+ CLI_VERSION?: string;
6
+ }
7
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "include": ["src/types/global.d.ts", "src"],
3
+ "exclude": ["node_modules"],
4
+
5
+ "compilerOptions": {
6
+ // prevent outputting any files, rollup will handle that
7
+ "noEmit": true,
8
+
9
+ "module": "es2022",
10
+ "moduleResolution": "bundler",
11
+
12
+ "moduleDetection": "force",
13
+ "target": "ESNext",
14
+ "lib": ["DOM", "DOM.Iterable", "ESNext"],
15
+
16
+ "baseUrl": ".",
17
+ "paths": {
18
+ "~/*": ["./src/*"]
19
+ },
20
+
21
+ "types": [
22
+ // add bun-types for resolving imports
23
+ //
24
+ // import { test, expect } from "bun:test";
25
+ //
26
+ "bun-types"
27
+ ],
28
+
29
+ // provide backwards compatibility
30
+ // nodejs allows you to import most commonjs packages with a default import
31
+ // this flag tells typescript that it's okay to use import on commonjs modules
32
+ "allowSyntheticDefaultImports": true,
33
+
34
+ // esm doesn't yet support json modules
35
+ "resolveJsonModule": false,
36
+
37
+ "jsx": "react",
38
+ "pretty": true,
39
+ "newLine": "lf",
40
+ "stripInternal": true,
41
+ "strict": true,
42
+ "noImplicitReturns": true,
43
+ "noImplicitOverride": true,
44
+ "noUnusedLocals": true,
45
+ "noUnusedParameters": true,
46
+ "noFallthroughCasesInSwitch": true,
47
+ // "noUncheckedIndexedAccess": true,
48
+ "noPropertyAccessFromIndexSignature": true,
49
+ "useDefineForClassFields": true,
50
+ "forceConsistentCasingInFileNames": true,
51
+ "skipLibCheck": true
52
+ }
53
+ }