@learncard/create-http-bridge 1.1.34
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/CHANGELOG.md +400 -0
- package/LICENSE +25 -0
- package/README.md +34 -0
- package/cli/App.tsx +74 -0
- package/cli/Banner.tsx +18 -0
- package/cli/Button.tsx +62 -0
- package/cli/Cloning.tsx +51 -0
- package/cli/Form.tsx +80 -0
- package/cli/FullScreenBox.tsx +19 -0
- package/cli/Info.tsx +79 -0
- package/cli/Input.tsx +33 -0
- package/cli/curriedStateSlice.ts +565 -0
- package/cli/index.tsx +17 -0
- package/cli/random.ts +3 -0
- package/cli/types.ts +8 -0
- package/dist/index.js +803 -0
- package/esbuildWasmPlugin.cjs +31 -0
- package/lambda.ts +18 -0
- package/package.json +56 -0
- package/project.json +22 -0
- package/rollup.config.js +12 -0
- package/serverless.yml +56 -0
- package/src/app.ts +297 -0
- package/src/didkit_wasm_bg.wasm +0 -0
- package/src/learn-card.ts +13 -0
- package/src/types.helpers.ts +7 -0
- package/src/validators.ts +59 -0
- package/tsconfig.json +36 -0
package/cli/Form.tsx
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box, useFocusManager } from 'ink';
|
|
3
|
+
import { Updater } from 'use-immer';
|
|
4
|
+
|
|
5
|
+
import { curriedStateSlice } from './curriedStateSlice';
|
|
6
|
+
|
|
7
|
+
import Input from './Input';
|
|
8
|
+
import Button from './Button';
|
|
9
|
+
|
|
10
|
+
import { FormState } from './types';
|
|
11
|
+
import { generateRandomSeed } from './random';
|
|
12
|
+
|
|
13
|
+
type FormProps = {
|
|
14
|
+
state: FormState;
|
|
15
|
+
setState: Updater<FormState>;
|
|
16
|
+
onSubmit: () => void;
|
|
17
|
+
onCancel: () => void;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const Form: React.FC<FormProps> = ({ state, setState, onSubmit, onCancel }) => {
|
|
21
|
+
const { focus } = useFocusManager();
|
|
22
|
+
|
|
23
|
+
const updateSlice = curriedStateSlice(setState);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<Box
|
|
27
|
+
flexGrow={1}
|
|
28
|
+
flexDirection="column"
|
|
29
|
+
padding={2}
|
|
30
|
+
borderStyle="round"
|
|
31
|
+
borderColor="yellow"
|
|
32
|
+
>
|
|
33
|
+
<Box flexGrow={1} flexDirection="column" alignItems="center">
|
|
34
|
+
<Box marginBottom={2} padding={1} flexDirection="column" borderStyle="round">
|
|
35
|
+
<Input
|
|
36
|
+
disabled
|
|
37
|
+
focusId="name"
|
|
38
|
+
prompt="Name:"
|
|
39
|
+
value={state.name}
|
|
40
|
+
onChange={updateSlice('name')}
|
|
41
|
+
onSubmit={() => focus('editName')}
|
|
42
|
+
/>
|
|
43
|
+
<Input
|
|
44
|
+
marginTop={1}
|
|
45
|
+
disabled
|
|
46
|
+
focusId="seed"
|
|
47
|
+
prompt="Seed:"
|
|
48
|
+
value={state.seed}
|
|
49
|
+
onChange={updateSlice('seed')}
|
|
50
|
+
onSubmit={() => focus('editSeed')}
|
|
51
|
+
/>
|
|
52
|
+
</Box>
|
|
53
|
+
|
|
54
|
+
<Button autoFocus focusId="editName" onClick={() => focus('name')} width={25}>
|
|
55
|
+
Edit Name
|
|
56
|
+
</Button>
|
|
57
|
+
<Button onClick={() => updateSlice('seed', generateRandomSeed())} width={25}>
|
|
58
|
+
Generate Random Seed
|
|
59
|
+
</Button>
|
|
60
|
+
<Button
|
|
61
|
+
focusId="editSeed"
|
|
62
|
+
onClick={() => {
|
|
63
|
+
updateSlice('seed', '');
|
|
64
|
+
focus('seed');
|
|
65
|
+
}}
|
|
66
|
+
width={25}
|
|
67
|
+
>
|
|
68
|
+
Enter Custom Seed
|
|
69
|
+
</Button>
|
|
70
|
+
</Box>
|
|
71
|
+
|
|
72
|
+
<Box height={5} width="100%" padding={2} justifyContent="space-between">
|
|
73
|
+
<Button onClick={onSubmit}>Ok</Button>
|
|
74
|
+
<Button onClick={onCancel}>Cancel</Button>
|
|
75
|
+
</Box>
|
|
76
|
+
</Box>
|
|
77
|
+
);
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
export default Form;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Box } from 'ink';
|
|
3
|
+
import useStdOutDimensions from 'ink-use-stdout-dimensions';
|
|
4
|
+
|
|
5
|
+
const FullScreenBox: typeof Box = React.forwardRef(function FullScreenBox(
|
|
6
|
+
{ children, ...props },
|
|
7
|
+
ref
|
|
8
|
+
) {
|
|
9
|
+
const [width, height] = useStdOutDimensions();
|
|
10
|
+
|
|
11
|
+
return (
|
|
12
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
13
|
+
<Box width={Math.min(width, 150)} height={Math.min(height - 1, 50)} {...props} ref={ref}>
|
|
14
|
+
{children}
|
|
15
|
+
</Box>
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export default FullScreenBox;
|
package/cli/Info.tsx
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react';
|
|
2
|
+
import { Text, Box } from 'ink';
|
|
3
|
+
import SyntaxHighlight from 'ink-syntax-highlight';
|
|
4
|
+
import { lookpath } from 'lookpath';
|
|
5
|
+
|
|
6
|
+
type InfoProps = {
|
|
7
|
+
path: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const Info: React.FC<InfoProps> = ({ path }) => {
|
|
11
|
+
const [pnpm, setPnpm] = useState(true);
|
|
12
|
+
const [aws, setAws] = useState(true);
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const checkForBinaries = async () => {
|
|
16
|
+
setPnpm(!!(await lookpath('pnpm')));
|
|
17
|
+
setAws(!!(await lookpath('aws')));
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
checkForBinaries();
|
|
21
|
+
}, []);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<Box
|
|
25
|
+
flexGrow={1}
|
|
26
|
+
flexDirection="column"
|
|
27
|
+
justifyContent="center"
|
|
28
|
+
alignItems="center"
|
|
29
|
+
padding={2}
|
|
30
|
+
borderStyle="round"
|
|
31
|
+
borderColor="yellow"
|
|
32
|
+
>
|
|
33
|
+
<Text>Success!</Text>
|
|
34
|
+
<Text>Your new Learn Card HTTP Bridge is ready to deploy!</Text>
|
|
35
|
+
{aws ? (
|
|
36
|
+
<Text>To deploy, run the following commands:</Text>
|
|
37
|
+
) : (
|
|
38
|
+
<>
|
|
39
|
+
<Text>It looks like you might not have serverless/AWS set up yet!</Text>
|
|
40
|
+
<Text>
|
|
41
|
+
Please review the instructions at
|
|
42
|
+
https://www.serverless.com/framework/docs/tutorial if you have any issues
|
|
43
|
+
deploying the Learn Card HTTP Bridge!
|
|
44
|
+
</Text>
|
|
45
|
+
<Text>
|
|
46
|
+
After you're all set up, run the following commands to deploy the Learn Card
|
|
47
|
+
HTTP Bridge!
|
|
48
|
+
</Text>
|
|
49
|
+
</>
|
|
50
|
+
)}
|
|
51
|
+
|
|
52
|
+
<Box borderStyle="round" flexDirection="column">
|
|
53
|
+
{!pnpm && (
|
|
54
|
+
<Text>
|
|
55
|
+
<Text color="green">{'$ '}</Text>
|
|
56
|
+
<SyntaxHighlight code="npm i -g pnpm # must use pnpm!" language="bash" />
|
|
57
|
+
</Text>
|
|
58
|
+
)}
|
|
59
|
+
<Text>
|
|
60
|
+
<Text color="green">{'$ '}</Text>
|
|
61
|
+
<SyntaxHighlight
|
|
62
|
+
code={`cd ${path}/packages/learn-card-bridge-http`}
|
|
63
|
+
language="bash"
|
|
64
|
+
/>
|
|
65
|
+
</Text>
|
|
66
|
+
<Text>
|
|
67
|
+
<Text color="green">{'$ '}</Text>
|
|
68
|
+
<SyntaxHighlight code="pnpm i" language="bash" />
|
|
69
|
+
</Text>
|
|
70
|
+
<Text>
|
|
71
|
+
<Text color="green">{'$ '}</Text>
|
|
72
|
+
<SyntaxHighlight code="pnpm serverless-deploy" language="bash" />
|
|
73
|
+
</Text>
|
|
74
|
+
</Box>
|
|
75
|
+
</Box>
|
|
76
|
+
);
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default Info;
|
package/cli/Input.tsx
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import React, { ComponentPropsWithRef } from 'react';
|
|
2
|
+
import { Text, Box, useFocus, DOMElement } from 'ink';
|
|
3
|
+
import TextInput from 'ink-text-input';
|
|
4
|
+
|
|
5
|
+
type InputProps = ComponentPropsWithRef<typeof Box> & {
|
|
6
|
+
disabled?: boolean;
|
|
7
|
+
autoFocus?: boolean;
|
|
8
|
+
focusId?: string;
|
|
9
|
+
prompt: string;
|
|
10
|
+
value: string;
|
|
11
|
+
onChange: (value: string) => void;
|
|
12
|
+
onSubmit: (value: string) => void;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const Input = React.forwardRef<DOMElement, InputProps>(function Input(
|
|
16
|
+
{ disabled = false, autoFocus = false, focusId, prompt, value, onChange, onSubmit, ...props },
|
|
17
|
+
ref
|
|
18
|
+
) {
|
|
19
|
+
const { isFocused } = useFocus({ autoFocus, id: focusId, isActive: !disabled });
|
|
20
|
+
|
|
21
|
+
return (
|
|
22
|
+
// eslint-disable-next-line react/jsx-props-no-spreading
|
|
23
|
+
<Box ref={ref} {...props}>
|
|
24
|
+
<Box marginRight={1}>
|
|
25
|
+
<Text color="blueBright">{prompt}</Text>
|
|
26
|
+
</Box>
|
|
27
|
+
|
|
28
|
+
<TextInput value={value} onChange={onChange} focus={isFocused} onSubmit={onSubmit} />
|
|
29
|
+
</Box>
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export default Input;
|