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.
- package/README.md +1 -1
- package/dist/cjs/index.cjs +3 -3
- package/package.json +15 -8
- package/rollup.config.mjs +46 -0
- package/scripts/.eslintrc.cjs +61 -0
- package/scripts/build-standalone.ts +73 -0
- package/scripts/core/create_asset.ts +21 -0
- package/scripts/core/file.ts +36 -0
- package/scripts/core/spawn.ts +62 -0
- package/scripts/npm-prepublishOnly.ts +8 -0
- package/scripts/release-brew.ts +69 -0
- package/scripts/release-github.ts +34 -0
- package/scripts/release-npm.ts +109 -0
- package/scripts/tsconfig.json +35 -0
- package/src/__fixtures__/metadata.ts +666 -0
- package/src/app/App.tsx +65 -0
- package/src/app/AutoUpdate.tsx +229 -0
- package/src/app/Await.tsx +82 -0
- package/src/app/Brackets.tsx +22 -0
- package/src/app/Command.tsx +19 -0
- package/src/app/Debug.tsx +52 -0
- package/src/app/DependencyCheck.tsx +155 -0
- package/src/app/Exit.tsx +25 -0
- package/src/app/FormatText.tsx +26 -0
- package/src/app/GatherMetadata.tsx +145 -0
- package/src/app/GithubApiError.tsx +78 -0
- package/src/app/LocalCommitStatus.tsx +70 -0
- package/src/app/LocalMergeRebase.tsx +230 -0
- package/src/app/LogTimestamp.tsx +12 -0
- package/src/app/Main.tsx +52 -0
- package/src/app/ManualRebase.tsx +308 -0
- package/src/app/MultiSelect.tsx +246 -0
- package/src/app/Output.tsx +37 -0
- package/src/app/Parens.tsx +21 -0
- package/src/app/PostRebaseStatus.tsx +33 -0
- package/src/app/PreLocalMergeRebase.tsx +31 -0
- package/src/app/PreSelectCommitRanges.tsx +31 -0
- package/src/app/Providers.tsx +11 -0
- package/src/app/RebaseCheck.tsx +96 -0
- package/src/app/SelectCommitRanges.tsx +372 -0
- package/src/app/Status.tsx +82 -0
- package/src/app/StatusTable.tsx +155 -0
- package/src/app/Store.tsx +252 -0
- package/src/app/Table.tsx +137 -0
- package/src/app/TextInput.tsx +88 -0
- package/src/app/Url.tsx +19 -0
- package/src/app/Waterfall.tsx +37 -0
- package/src/app/YesNoPrompt.tsx +73 -0
- package/src/command.ts +78 -0
- package/src/core/CommitMetadata.ts +212 -0
- package/src/core/Metadata.test.ts +41 -0
- package/src/core/Metadata.ts +51 -0
- package/src/core/StackSummaryTable.test.ts +157 -0
- package/src/core/StackSummaryTable.ts +127 -0
- package/src/core/Timer.ts +44 -0
- package/src/core/assertNever.ts +4 -0
- package/src/core/cache.ts +49 -0
- package/src/core/capitalize.ts +5 -0
- package/src/core/chalk.ts +103 -0
- package/src/core/clamp.ts +6 -0
- package/src/core/cli.ts +161 -0
- package/src/core/colors.ts +23 -0
- package/src/core/date.ts +25 -0
- package/src/core/fetch_json.ts +26 -0
- package/src/core/github.tsx +215 -0
- package/src/core/invariant.ts +5 -0
- package/src/core/is_command_available.ts +21 -0
- package/src/core/is_finite_value.ts +3 -0
- package/src/core/json.ts +32 -0
- package/src/core/match_group.ts +10 -0
- package/src/core/read_json.ts +12 -0
- package/src/core/safe_quote.ts +10 -0
- package/src/core/semver_compare.ts +27 -0
- package/src/core/short_id.ts +87 -0
- package/src/core/sleep.ts +3 -0
- package/src/core/wrap_index.ts +11 -0
- package/src/index.tsx +22 -0
- package/src/types/global.d.ts +7 -0
- 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
|
+
}
|
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);
|
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
|
+
}
|