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", "name": "visions-client",
"version": "0.0.1", "version": "0.0.1",
"description": "Shared data types for Visions", "description": "Shared data types for Visions",
"main": "visions.js", "main": "dist/index.js",
"types": "dist/lib.js", "types": "dist/index.d.ts",
"files": [
"/dist"
],
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "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', () => { describe('what happens in an authentication', () => {
it('handles a successful response', async () => { it('handles a successful response', async () => {

View File

@ -11,5 +11,5 @@
"strict": true, "strict": true,
"skipLibCheck": 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: build:
cmds: cmds:
- npm install typescript - 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", "name": "visions-types",
"version": "0.0.1", "version": "0.0.1",
"description": "Shared data types for Visions", "description": "Shared data types for Visions",
"main": "visions.js", "main": "dist/index.js",
"types": "dist/lib.js", "types": "dist/index.d.ts",
"files": [
"/dist"
],
"scripts": { "scripts": {
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },

View File

@ -1,7 +1,8 @@
{ {
"compilerOptions": { "compilerOptions": {
"target": "es2016", "target": "es6",
"module": "commonjs", "module": "es6",
"moduleResolution": "node",
"declaration": true, "declaration": true,
"declarationMap": true, "declarationMap": true,
"sourceMap": true, "sourceMap": true,
@ -9,7 +10,7 @@
"esModuleInterop": true, "esModuleInterop": true,
"forceConsistentCasingInFileNames": true, "forceConsistentCasingInFileNames": true,
"strict": true, "strict": true,
"skipLibCheck": true "skipLibCheck": true,
}, "rootDir": "./gen"
"include": ["./gen/lib.ts"] }
} }

View File

@ -5,11 +5,10 @@ tasks:
cmds: cmds:
- npm run fmt - npm run fmt
dev: build:
cmds: cmds:
# - cd ../visions-types && task build
- npm install - npm install
- npm run dev - npx tsc --watch
test: test:
cmds: cmds:

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

View File

@ -9,12 +9,37 @@
"version": "1.0.0", "version": "1.0.0",
"license": "ISC", "license": "ISC",
"dependencies": { "dependencies": {
"lit": "^3.2.1" "lit": "^3.2.1",
"visions-client": "file:../client",
"visions-types": "file:../types"
}, },
"devDependencies": { "devDependencies": {
"typescript": "^5.7.3" "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": { "node_modules/@lit-labs/ssr-dom-shim": {
"version": "1.3.0", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.3.0.tgz", "resolved": "https://registry.npmjs.org/@lit-labs/ssr-dom-shim/-/ssr-dom-shim-1.3.0.tgz",
@ -73,6 +98,14 @@
"engines": { "engines": {
"node": ">=14.17" "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" "typescript": "^5.7.3"
}, },
"dependencies": { "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 { Client } from 'visions-client'
import { ActionDispatch } from 'react'
export type AuthState = export type AuthState =
| { type: 'unauthed' } | { type: 'unauthed' }
@ -13,9 +12,9 @@ export const initialState = (): State => ({
auth: { type: 'unauthed' }, auth: { type: 'unauthed' },
}) })
export const sessionId = (state: State) => string | undefined { export const sessionId = (state: State): string | undefined => {
if (state.type === 'authed') { if (state.auth.type === 'authed') {
return state.sessionId return state.auth.sessionId
} else { } else {
return undefined return undefined
} }
@ -37,16 +36,13 @@ export const reducer = (state: State, action: Action) => {
export class Controller { export class Controller {
client: Client client: Client
state: State state: State
dispatch: ActionDispatch<[action: Action]>
constructor( constructor(
client: Client, client: Client,
state: State, state: State,
dispatch: ActionDispatch<[action: Action]>,
) { ) {
this.client = client this.client = client
this.state = state this.state = state
this.dispatch = dispatch
} }
// On any request, there are four options. // On any request, there are four options.
@ -58,6 +54,7 @@ export class Controller {
let response = await this.client.auth(username, password) let response = await this.client.auth(username, password)
switch (response.status) { switch (response.status) {
case 'ok': { case 'ok': {
/*
this.dispatch({ this.dispatch({
type: 'set-auth', type: 'set-auth',
content: { content: {
@ -65,6 +62,7 @@ export class Controller {
sessionId: response.content.content, sessionId: response.content.content,
}, },
}) })
*/
return return
} }
} }