Adjust all build processes

This commit is contained in:
Savanni D'Gerinel 2025-02-17 15:44:01 -05:00
parent 0d39690560
commit a1dc573fc5
14 changed files with 66 additions and 39 deletions

View File

@ -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"
},

View File

@ -1,4 +1,4 @@
import { Connection } from './lib'
import { Connection } from './index'
describe('what happens in an authentication', () => {
it('handles a successful response', async () => {

View File

@ -11,5 +11,5 @@
"strict": true,
"skipLibCheck": true
},
"include": ["gen", "src"]
"include": ["src/**/*"]
}

View File

@ -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 };

2
visions/types/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
gen/
dist/

View File

@ -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

View File

@ -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"
},

View File

@ -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"
}
}

View File

@ -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:

0
visions/ui/index.html Normal file
View File

View File

@ -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
}
}
}

View File

@ -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"
}
}

View File

@ -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
}
}