From a1dc573fc5efbf2eb33e9bfa5178c944065fbd3c Mon Sep 17 00:00:00 2001 From: Savanni D'Gerinel Date: Mon, 17 Feb 2025 15:44:01 -0500 Subject: [PATCH] Adjust all build processes --- visions/client/package.json | 7 ++-- .../client/src/{lib.test.ts => index.test.ts} | 2 +- visions/client/src/{lib.ts => index.ts} | 0 visions/client/tsconfig.json | 2 +- visions/client/visions.ts | 15 -------- visions/types/.gitignore | 2 ++ visions/types/Taskfile.yml | 3 +- visions/types/package.json | 7 ++-- visions/types/tsconfig.json | 11 +++--- visions/ui/Taskfile.yml | 5 ++- visions/ui/index.html | 0 visions/ui/package-lock.json | 35 ++++++++++++++++++- visions/ui/package.json | 4 ++- visions/ui/src/state.ts | 12 +++---- 14 files changed, 66 insertions(+), 39 deletions(-) rename visions/client/src/{lib.test.ts => index.test.ts} (99%) rename visions/client/src/{lib.ts => index.ts} (100%) delete mode 100644 visions/client/visions.ts create mode 100644 visions/types/.gitignore create mode 100644 visions/ui/index.html diff --git a/visions/client/package.json b/visions/client/package.json index df47a63..dfed43b 100644 --- a/visions/client/package.json +++ b/visions/client/package.json @@ -2,8 +2,11 @@ "name": "visions-client", "version": "0.0.1", "description": "Shared data types for Visions", - "main": "visions.js", - "types": "dist/lib.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "files": [ + "/dist" + ], "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/visions/client/src/lib.test.ts b/visions/client/src/index.test.ts similarity index 99% rename from visions/client/src/lib.test.ts rename to visions/client/src/index.test.ts index a02f3a5..17fdd2f 100644 --- a/visions/client/src/lib.test.ts +++ b/visions/client/src/index.test.ts @@ -1,4 +1,4 @@ -import { Connection } from './lib' +import { Connection } from './index' describe('what happens in an authentication', () => { it('handles a successful response', async () => { diff --git a/visions/client/src/lib.ts b/visions/client/src/index.ts similarity index 100% rename from visions/client/src/lib.ts rename to visions/client/src/index.ts diff --git a/visions/client/tsconfig.json b/visions/client/tsconfig.json index 410e8da..ec5e1bc 100644 --- a/visions/client/tsconfig.json +++ b/visions/client/tsconfig.json @@ -11,5 +11,5 @@ "strict": true, "skipLibCheck": true }, - "include": ["gen", "src"] + "include": ["src/**/*"] } diff --git a/visions/client/visions.ts b/visions/client/visions.ts deleted file mode 100644 index b077c64..0000000 --- a/visions/client/visions.ts +++ /dev/null @@ -1,15 +0,0 @@ -/* - Generated by typeshare 1.13.0 -*/ - -export type SessionId = string; - -export interface AuthRequest { - username: string; - password: string; -} - -export type AuthResponse = - | { type: "Success", content: SessionId } - | { type: "PasswordReset", content: SessionId }; - diff --git a/visions/types/.gitignore b/visions/types/.gitignore new file mode 100644 index 0000000..1d493a9 --- /dev/null +++ b/visions/types/.gitignore @@ -0,0 +1,2 @@ +gen/ +dist/ diff --git a/visions/types/Taskfile.yml b/visions/types/Taskfile.yml index 92d55c6..4ef6ee8 100644 --- a/visions/types/Taskfile.yml +++ b/visions/types/Taskfile.yml @@ -4,4 +4,5 @@ tasks: build: cmds: - npm install typescript - - typeshare --lang typescript --output-file dist/lib.ts ../server/src + - typeshare --lang typescript --output-file gen/index.ts ../server/src + - npx tsc diff --git a/visions/types/package.json b/visions/types/package.json index afed36a..ddc842e 100644 --- a/visions/types/package.json +++ b/visions/types/package.json @@ -2,8 +2,11 @@ "name": "visions-types", "version": "0.0.1", "description": "Shared data types for Visions", - "main": "visions.js", - "types": "dist/lib.js", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "files": [ + "/dist" + ], "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, diff --git a/visions/types/tsconfig.json b/visions/types/tsconfig.json index 79102a7..e274f73 100644 --- a/visions/types/tsconfig.json +++ b/visions/types/tsconfig.json @@ -1,7 +1,8 @@ { "compilerOptions": { - "target": "es2016", - "module": "commonjs", + "target": "es6", + "module": "es6", + "moduleResolution": "node", "declaration": true, "declarationMap": true, "sourceMap": true, @@ -9,7 +10,7 @@ "esModuleInterop": true, "forceConsistentCasingInFileNames": true, "strict": true, - "skipLibCheck": true - }, - "include": ["./gen/lib.ts"] + "skipLibCheck": true, + "rootDir": "./gen" + } } diff --git a/visions/ui/Taskfile.yml b/visions/ui/Taskfile.yml index 7785cad..dddd16f 100644 --- a/visions/ui/Taskfile.yml +++ b/visions/ui/Taskfile.yml @@ -5,11 +5,10 @@ tasks: cmds: - npm run fmt - dev: + build: cmds: - # - cd ../visions-types && task build - npm install - - npm run dev + - npx tsc --watch test: cmds: diff --git a/visions/ui/index.html b/visions/ui/index.html new file mode 100644 index 0000000..e69de29 diff --git a/visions/ui/package-lock.json b/visions/ui/package-lock.json index 77b455c..3479d7d 100644 --- a/visions/ui/package-lock.json +++ b/visions/ui/package-lock.json @@ -9,12 +9,37 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "lit": "^3.2.1" + "lit": "^3.2.1", + "visions-client": "file:../client", + "visions-types": "file:../types" }, "devDependencies": { "typescript": "^5.7.3" } }, + "../client": { + "name": "visions-client", + "version": "0.0.1", + "license": "ISC", + "dependencies": { + "visions-types": "file:../types" + }, + "devDependencies": { + "@types/jest": "^29.5.14", + "jest": "^29.7.0", + "prettier": "^3.5.1", + "ts-jest": "^29.2.5", + "typescript": "^5.7.3" + } + }, + "../types": { + "name": "visions-types", + "version": "0.0.1", + "license": "ISC", + "dependencies": { + "typescript": "^5.7.3" + } + }, "node_modules/@lit-labs/ssr-dom-shim": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.3.0.tgz", @@ -73,6 +98,14 @@ "engines": { "node": ">=14.17" } + }, + "node_modules/visions-client": { + "resolved": "../client", + "link": true + }, + "node_modules/visions-types": { + "resolved": "../types", + "link": true } } } diff --git a/visions/ui/package.json b/visions/ui/package.json index d6b3d52..514374a 100644 --- a/visions/ui/package.json +++ b/visions/ui/package.json @@ -13,6 +13,8 @@ "typescript": "^5.7.3" }, "dependencies": { - "lit": "^3.2.1" + "lit": "^3.2.1", + "visions-client": "file:../client", + "visions-types": "file:../types" } } diff --git a/visions/ui/src/state.ts b/visions/ui/src/state.ts index e46ccaf..93b5a60 100644 --- a/visions/ui/src/state.ts +++ b/visions/ui/src/state.ts @@ -1,5 +1,4 @@ import { Client } from 'visions-client' -import { ActionDispatch } from 'react' export type AuthState = | { type: 'unauthed' } @@ -13,9 +12,9 @@ export const initialState = (): State => ({ auth: { type: 'unauthed' }, }) -export const sessionId = (state: State) => string | undefined { - if (state.type === 'authed') { - return state.sessionId +export const sessionId = (state: State): string | undefined => { + if (state.auth.type === 'authed') { + return state.auth.sessionId } else { return undefined } @@ -37,16 +36,13 @@ export const reducer = (state: State, action: Action) => { export class Controller { client: Client state: State - dispatch: ActionDispatch<[action: Action]> constructor( client: Client, state: State, - dispatch: ActionDispatch<[action: Action]>, ) { this.client = client this.state = state - this.dispatch = dispatch } // On any request, there are four options. @@ -58,6 +54,7 @@ export class Controller { let response = await this.client.auth(username, password) switch (response.status) { case 'ok': { + /* this.dispatch({ type: 'set-auth', content: { @@ -65,6 +62,7 @@ export class Controller { sessionId: response.content.content, }, }) + */ return } }