Skip to content

Commit 9c4682d

Browse files
committed
WIP
1 parent 76f0d6b commit 9c4682d

17 files changed

+286
-206
lines changed

.changeset/cold-ties-tan.md

-5
This file was deleted.

CHANGELOG.md

+120
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,125 @@
11
## [1.2.5](https://github.com/ThinAirThings/uix/compare/v1.2.4...v1.2.5) (2024-05-23)
22

3+
## 2.0.18
4+
5+
### Patch Changes
6+
7+
- fix delete node recursive delete
8+
9+
## 2.0.17
10+
11+
### Patch Changes
12+
13+
- fix deleteNode
14+
15+
## 2.0.16
16+
17+
### Patch Changes
18+
19+
- wip
20+
21+
## 2.0.15
22+
23+
### Patch Changes
24+
25+
- WIP
26+
27+
## 2.0.14
28+
29+
### Patch Changes
30+
31+
- WIP
32+
33+
## 2.0.13
34+
35+
### Patch Changes
36+
37+
- wip
38+
39+
## 2.0.12
40+
41+
### Patch Changes
42+
43+
- fix required envPath
44+
45+
## 2.0.11
46+
47+
### Patch Changes
48+
49+
- modify envPath
50+
51+
## 2.0.10
52+
53+
### Patch Changes
54+
55+
- add dotenv
56+
57+
## 2.0.9
58+
59+
### Patch Changes
60+
61+
- update package.json
62+
63+
## 2.0.8
64+
65+
### Patch Changes
66+
67+
- update package.json
68+
69+
## 2.0.7
70+
71+
### Patch Changes
72+
73+
- test
74+
75+
## 2.0.6
76+
77+
### Patch Changes
78+
79+
- update
80+
81+
## 2.0.5
82+
83+
### Patch Changes
84+
85+
- update dependencies
86+
87+
## 2.0.6
88+
89+
### Patch Changes
90+
91+
- pin deps
92+
93+
## 2.0.5
94+
95+
### Patch Changes
96+
97+
- update dep versions
98+
99+
## 2.0.4
100+
101+
### Patch Changes
102+
103+
- update dependencies
104+
105+
## 2.0.3
106+
107+
### Patch Changes
108+
109+
- modify dependencies
110+
111+
## 2.0.2
112+
113+
### Patch Changes
114+
115+
- pin react version
116+
117+
## 2.0.1
118+
119+
### Patch Changes
120+
121+
- 76f0d6b: added bin section to package.json
122+
3123
## 2.0.0
4124

5125
### Major Changes

package.json

+15-19
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,28 @@
11
{
22
"name": "@thinairthings/uix",
33
"author": "Dan Lannan",
4-
"version": "2.0.0",
4+
"version": "2.0.18",
55
"type": "module",
6+
"types": "./dist/lib/index.d.ts",
67
"bin": {
78
"uix": "./dist/cli/cli.js"
89
},
910
"publishConfig": {
1011
"access": "public"
1112
},
1213
"scripts": {
13-
"dev": "tsup --watch",
14+
"dev": "nodemon",
1415
"build": "tsup",
1516
"build:run": "tsup-node && node dist/cli/cli.js",
1617
"test": "dotenvx run -f .env.test -- pnpm build && dotenvx run -f .env.test -- vitest run basic --test-timeout=100000",
17-
"uix": "dotenvx run -f .env.test -- node ./dist/cli/cli.js --path-to-config=./tests/uix/uix.config.ts"
18+
"uix": "dotenvx run -f .env.test -- node ./dist/cli/cli.js --path-to-config=./tests/uix/uix.config.ts",
19+
"wipset": "changeset && changeset version && changeset publish"
1820
},
1921
"exports": {
2022
".": {
2123
"types": "./dist/lib/index.d.ts",
22-
"default": "./dist/lib/index.js"
24+
"import": "./dist/lib/index.js",
25+
"require": "./dist/lib/index.cjs"
2326
}
2427
},
2528
"files": [
@@ -33,41 +36,34 @@
3336
"devDependencies": {
3437
"@babel/preset-env": "^7.24.7",
3538
"@sindresorhus/tsconfig": "^5.0.0",
36-
"@types/jest": "^29.5.12",
37-
"babel-jest": "^29.7.0",
38-
"effect": "^3.3.1",
39-
"jest": "^29.7.0",
39+
"@types/react": "^18.3.3",
4040
"nodemon": "^3.1.3",
41-
"react-devtools-core": "^5.2.0",
42-
"ts-jest": "^29.1.4",
4341
"tsup": "^8.1.0",
4442
"typescript": "^5.4.5",
43+
"vite": "^5.3.1",
4544
"vitest": "^1.6.0"
4645
},
4746
"dependencies": {
4847
"@changesets/cli": "^2.27.6",
4948
"@tanstack/react-query": "^5.32.0",
49+
"dotenv": "^16.4.5",
5050
"file-type": "^19.0.0",
5151
"immer": "^10.1.1",
5252
"ink": "^5.0.1",
53-
"ink-big-text": "^2.0.0",
54-
"ink-gradient": "^3.0.0",
55-
"ink-image": "^2.0.0",
56-
"ink-progress-bar": "^3.0.0",
5753
"ink-spinner": "^5.0.0",
5854
"neo4j-driver": "^5.21.0",
5955
"openai": "^4.49.0",
6056
"package-up": "^5.0.0",
6157
"pastel": "^3.0.0",
62-
"prop-types": "^15.8.1",
63-
"react": "^18.3.1",
64-
"terminal-image": "^2.0.0",
65-
"ts-morph": "^22.0.0",
6658
"tsx": "^4.15.2",
6759
"uuid": "^10.0.0",
68-
"vite": "^5.3.1",
6960
"znv": "^0.4.0",
7061
"zod": "^3.23.8",
7162
"zustand": "^4.5.2"
63+
},
64+
"peerDependencies": {
65+
"@types/react": ">=18.0.0 <19.0.0",
66+
"react": ">=18.0.0 <19.0.0",
67+
"react-devtools-core": "^4.19.1"
7268
}
7369
}
+16-16
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11

2-
import React, { FC } from 'react';
2+
import React, { FC, useState, useEffect } from 'react';
33
import { ReactQueryProvider } from './ReactQueryProvider';
4+
import dotenv from 'dotenv'
5+
import { Box } from 'ink';
46

5-
// const nullStream = new Writable({
6-
// write(chunk, encoding, callback) {
7-
// // Do nothing with the chunk
8-
// // You can reroute this to logs if you want
9-
// callback();
10-
// }
11-
// });
12-
// const { stderr } = useStderr()
13-
// useEffect(() => {
14-
// stderr.write = nullStream.write.bind(nullStream)
15-
// }, [stderr])
167
export const CommandEnvironment: FC<{
8+
envPath: string
179
Command: FC<any>
1810
}> = ({
11+
envPath,
1912
Command
2013
}) => {
21-
14+
const [envLoaded, setEnvLoaded] = useState(false)
15+
useEffect(() => {
16+
dotenv.config({ path: envPath })
17+
setEnvLoaded(true)
18+
}, [])
19+
if (!envLoaded) return
2220
return (
23-
<ReactQueryProvider>
24-
<Command />
25-
</ReactQueryProvider>
21+
<Box>
22+
<ReactQueryProvider>
23+
<Command />
24+
</ReactQueryProvider>
25+
</Box>
2626
)
2727
}

src/app/(hooks)/useOperation.ts src/app/(hooks)/useOperation.tsx

+31-12
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11

2-
import { FC, useEffect } from 'react'
2+
import React, { FC, useEffect } from 'react'
33
import { ErrType, Result, tryCatch } from '../../types/Result'
44
import { skipToken, useQuery } from '@tanstack/react-query'
55
import { applicationStore } from '../(stores)/applicationStore'
6+
import { Box } from 'ink'
67

78
type Strictify<T extends readonly any[]> = { [K in keyof T]-?: T[K] & {} }
89

@@ -52,9 +53,15 @@ export const useOperation = <
5253
if (!result) {
5354
applicationStore.setState(({ outputMap }) => {
5455
outputMap.set(operationKey, {
55-
Component: () => render.Pending({
56-
dependencies: dependencies as Strictify<Dependencies>
57-
}),
56+
Component: () => {
57+
return (
58+
<Box>
59+
<render.Pending
60+
dependencies={dependencies as Strictify<Dependencies>}
61+
/>
62+
</Box>
63+
)
64+
},
5865
operationState: 'pending'
5966
})
6067
})
@@ -64,10 +71,16 @@ export const useOperation = <
6471
if (error) {
6572
applicationStore.setState(({ outputMap }) => {
6673
outputMap.set(operationKey, {
67-
Component: () => render.Error({
68-
error,
69-
dependencies: dependencies as Strictify<Dependencies>
70-
}),
74+
Component: () => {
75+
return (
76+
<Box>
77+
<render.Error
78+
error={error}
79+
dependencies={dependencies as Strictify<Dependencies>}
80+
/>
81+
</Box>
82+
)
83+
},
7184
operationState: 'error'
7285
})
7386
})
@@ -76,10 +89,16 @@ export const useOperation = <
7689
if (data) {
7790
applicationStore.setState(({ outputMap }) => {
7891
outputMap.set(operationKey, {
79-
Component: () => render.Success({
80-
data,
81-
dependencies: dependencies as Strictify<Dependencies>
82-
}),
92+
Component: () => {
93+
return (
94+
<Box>
95+
<render.Success
96+
data={data}
97+
dependencies={dependencies as Strictify<Dependencies>}
98+
/>
99+
</Box>
100+
)
101+
},
83102
operationState: 'success'
84103
})
85104
})

src/app/(hooks)/useOperationv2.tsx

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import { skipToken, useQuery } from "@tanstack/react-query"
2+
import { ErrType, Result, tryCatch } from "../../types/Result"
3+
4+
5+
type Strictify<T extends readonly any[]> = { [K in keyof T]-?: T[K] & {} }
6+
export const useOperationv2 = <
7+
OperationKey extends string,
8+
T,
9+
ErrorType extends string,
10+
ErrorSubtype extends string,
11+
ErrorData extends Record<string, any> | undefined,
12+
Dependencies extends readonly any[]
13+
>({
14+
operationKey,
15+
tryOp,
16+
catchOp,
17+
finallyOp,
18+
dependencies
19+
}: {
20+
operationKey: OperationKey
21+
tryOp: (dependencies: Strictify<Dependencies>) => Promise<T> | T,
22+
catchOp: (error: any, dependencies: Strictify<Dependencies>) => Result<never, ErrType<ErrorType, ErrorSubtype, ErrorData>>,
23+
finallyOp?: (dependencies: Strictify<Dependencies>) => void,
24+
dependencies: Dependencies
25+
}) => {
26+
const { data, error } = useQuery({
27+
queryKey: [operationKey],
28+
queryFn: dependencies.length === 0
29+
? async () => {
30+
const { data, error } = await tryCatch({
31+
try: () => tryOp(dependencies as Strictify<Dependencies>),
32+
catch: (error) => catchOp(error, dependencies as Strictify<Dependencies>),
33+
finally: () => finallyOp?.(dependencies as Strictify<Dependencies>)
34+
})
35+
if (error) throw new Error(error.message)
36+
return data
37+
}
38+
: dependencies.every(dependency => (!!dependency))
39+
? async () => {
40+
const { data, error } = await tryCatch({
41+
try: () => tryOp(dependencies as Strictify<Dependencies>),
42+
catch: (error) => catchOp(error, dependencies as Strictify<Dependencies>),
43+
finally: () => finallyOp?.(dependencies as Strictify<Dependencies>)
44+
})
45+
if (error) throw new Error(error.message)
46+
return data
47+
}
48+
: skipToken
49+
})
50+
return { data, error }
51+
}

src/app/(stores)/applicationStore.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ applicationStore.subscribe(
3030
applicationStore.subscribe(
3131
state => state.outputMap,
3232
async outputMap => {
33-
if (![...outputMap].every(([_, { operationState }]) => operationState === 'success')) return
33+
if (![...outputMap].every(([_, { operationState }]) => operationState === 'success' || operationState === 'error')) return
3434
await applicationStore.getState().neo4jDriver?.close()
35+
3536
}
3637
)
3738

0 commit comments

Comments
 (0)