git-stack-cli 0.3.1 → 0.5.0
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.
- package/README.md +0 -54
- package/dist/__fixtures__/metadata.js +399 -475
- package/dist/app/App.js +8 -3
- package/dist/app/AutoUpdate.js +147 -0
- package/dist/app/Debug.js +4 -4
- package/dist/app/FormatText.js +3 -1
- package/dist/app/GatherMetadata copy.js +33 -29
- package/dist/app/GatherMetadata.js +30 -39
- package/dist/app/Input.js +15 -0
- package/dist/app/LocalCommitStatus.js +42 -0
- package/dist/app/LocalMergeRebase.js +113 -0
- package/dist/app/ManualRebase copy.js +127 -0
- package/dist/app/ManualRebase.js +23 -12
- package/dist/app/MultiSelect.js +2 -2
- package/dist/app/NPMAutoUpdate.js +34 -0
- package/dist/app/Parens copy.js +1 -1
- package/dist/app/PreLocalMergeRebase.js +21 -0
- package/dist/app/PreSelectCommitRanges copy.js +15 -23
- package/dist/app/PreSelectCommitRanges.js +10 -0
- package/dist/app/SelectCommitRanges.js +86 -71
- package/dist/app/Status.js +18 -3
- package/dist/app/StatusTable.js +30 -26
- package/dist/app/Store.js +32 -6
- package/dist/app/TextInput.js +37 -0
- package/dist/app/YesNoPrompt.js +1 -1
- package/dist/app/main.js +6 -0
- package/dist/command.js +15 -34
- package/dist/core/CommitMetadata.js +18 -4
- package/dist/core/Metadata.js +4 -3
- package/dist/core/cli.js +4 -0
- package/dist/core/github.js +26 -18
- package/dist/core/id.js +61 -0
- package/dist/core/readJson.js +3 -0
- package/dist/core/read_json.js +12 -0
- package/dist/core/safe_quote.js +9 -0
- package/dist/core/short_id.js +60 -0
- package/dist/core/sleep copy.js +3 -0
- package/package.json +2 -5
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
export function short_id() {
|
|
3
|
+
const timestamp = Date.now();
|
|
4
|
+
// 9 223 372 036 854 775 808
|
|
5
|
+
// 9 trillion possible values
|
|
6
|
+
// (2^53) * (2^10) = 2^63 = 9,223,372,036,854,775,808
|
|
7
|
+
const js_max_bits = 53;
|
|
8
|
+
const timestamp_bits = Math.floor(Math.log2(timestamp)) + 1;
|
|
9
|
+
// padding needed to reach 53 bits
|
|
10
|
+
const padding_bits = js_max_bits - timestamp_bits;
|
|
11
|
+
// random between 0 and 2^padding_bits - 1
|
|
12
|
+
const random = crypto.randomInt(0, Math.pow(2, padding_bits));
|
|
13
|
+
// combine timestamp and random value
|
|
14
|
+
const combined = interleave_bits(timestamp, random);
|
|
15
|
+
// console.debug({ combined, timestamp, random, padding_bits, timestamp_bits });
|
|
16
|
+
return encode(combined);
|
|
17
|
+
}
|
|
18
|
+
function binary(value) {
|
|
19
|
+
return BigInt(value).toString(2);
|
|
20
|
+
}
|
|
21
|
+
function rand_index(list) {
|
|
22
|
+
return Math.floor(Math.random() * list.length);
|
|
23
|
+
}
|
|
24
|
+
function interleave_bits(a, b) {
|
|
25
|
+
const a_binary = binary(a).split("");
|
|
26
|
+
const b_binary = binary(b).split("");
|
|
27
|
+
while (b_binary.length) {
|
|
28
|
+
// pull random bit out of b_binary
|
|
29
|
+
const b_index = rand_index(b_binary);
|
|
30
|
+
const [selected] = b_binary.splice(b_index, 1);
|
|
31
|
+
// insert random bit into a_binary
|
|
32
|
+
const a_index = rand_index(a_binary);
|
|
33
|
+
a_binary.splice(a_index, 0, selected);
|
|
34
|
+
}
|
|
35
|
+
// convert binary list back to integer
|
|
36
|
+
const a_value = parseInt(a_binary.join(""), 2);
|
|
37
|
+
return a_value;
|
|
38
|
+
}
|
|
39
|
+
function encode(value) {
|
|
40
|
+
// base64 encode (64 characters)
|
|
41
|
+
// max character necessary to encode is equal to maximum number
|
|
42
|
+
// of bits in value divided by bits per character in encoding
|
|
43
|
+
//
|
|
44
|
+
// Example
|
|
45
|
+
// in base64 each characters can represent 6 bits (2^6 = 64)
|
|
46
|
+
// 53 bits / 6 bits = 8.833333333333334 characters (9 characters)
|
|
47
|
+
//
|
|
48
|
+
// prettier-ignore
|
|
49
|
+
const chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-+";
|
|
50
|
+
const bits_per_char = Math.log2(chars.length);
|
|
51
|
+
const max_value_bits = 53;
|
|
52
|
+
const max_char_size = Math.ceil(max_value_bits / bits_per_char);
|
|
53
|
+
let result = "";
|
|
54
|
+
while (value > 0) {
|
|
55
|
+
result = chars[value % chars.length] + result;
|
|
56
|
+
value = Math.floor(value / chars.length);
|
|
57
|
+
}
|
|
58
|
+
// pad the result to necessary characters
|
|
59
|
+
return result.padStart(max_char_size, "=");
|
|
60
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "git-stack-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "magus",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,8 +11,7 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"preferGlobal": true,
|
|
13
13
|
"bin": {
|
|
14
|
-
"git-stack": "dist/index.js"
|
|
15
|
-
"git-multi-diff": "dist/index.js"
|
|
14
|
+
"git-stack": "dist/index.js"
|
|
16
15
|
},
|
|
17
16
|
"files": [
|
|
18
17
|
"dist"
|
|
@@ -30,7 +29,6 @@
|
|
|
30
29
|
"ink": "^4.4.1",
|
|
31
30
|
"react": "^18.2.0",
|
|
32
31
|
"react-intl": "^6.5.5",
|
|
33
|
-
"uuid": "^9.0.1",
|
|
34
32
|
"yargs": "^17.7.2",
|
|
35
33
|
"zustand": "^4.4.4"
|
|
36
34
|
},
|
|
@@ -38,7 +36,6 @@
|
|
|
38
36
|
"@types/chalk": "^2.2.0",
|
|
39
37
|
"@types/node": "^20.8.7",
|
|
40
38
|
"@types/react": "^18.2.33",
|
|
41
|
-
"@types/uuid": "^9.0.6",
|
|
42
39
|
"@types/yargs": "^17.0.29",
|
|
43
40
|
"@typescript-eslint/eslint-plugin": "^6.9.0",
|
|
44
41
|
"@typescript-eslint/parser": "^6.9.0",
|