chore
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
"db:push": "vp run server:db:push",
|
||||
"env:check": "vp run env:doctor",
|
||||
"fmt": "vp check --fix",
|
||||
"sdk:build": "vp run sdk-build",
|
||||
"typecheck": "vp run typecheck:all"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -2,15 +2,16 @@
|
||||
"name": "@repo/client-sbi",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"module": "index.ts",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./src/index.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./src/index.ts",
|
||||
"import": "./src/index.ts"
|
||||
"import": "./dist/index.mjs"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build": "cd ../.. && vp run @repo/mnie-types#build && cd packages/client-sbi && vp pack",
|
||||
"clean": "rm -rf dist",
|
||||
"typecheck": "tsc"
|
||||
},
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
export type * from '@repo/mnie-types'
|
||||
export type { SbiClientMethods } from '@repo/mnie-types'
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { defineConfig } from 'vite-plus'
|
||||
|
||||
export default defineConfig({
|
||||
pack: {
|
||||
entry: ['src/index.ts'],
|
||||
deps: {
|
||||
alwaysBundle: [/^@repo\//, 'iconv-lite', 'safer-buffer'],
|
||||
onlyBundle: false,
|
||||
},
|
||||
dts: { eager: true },
|
||||
format: ['esm'],
|
||||
platform: 'node',
|
||||
},
|
||||
})
|
||||
@@ -2,10 +2,13 @@
|
||||
"name": "@repo/mnie-cli",
|
||||
"private": true,
|
||||
"bin": {
|
||||
"mnie": "./src/index.ts"
|
||||
"mnie": "./dist/index.mjs"
|
||||
},
|
||||
"type": "module",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.mts",
|
||||
"scripts": {
|
||||
"build": "cd ../.. && vp run @repo/mnie-sdk#build && cd packages/mnie-cli && vp pack",
|
||||
"clean": "rm -rf dist",
|
||||
"typecheck": "tsc"
|
||||
},
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#!/usr/bin/env bun
|
||||
#!/usr/bin/env node
|
||||
import { spawn } from 'node:child_process'
|
||||
import { createHash, randomBytes } from 'node:crypto'
|
||||
import { chmod, mkdir, readFile, writeFile } from 'node:fs/promises'
|
||||
import { createServer } from 'node:http'
|
||||
import { homedir } from 'node:os'
|
||||
import { dirname, join } from 'node:path'
|
||||
import { createMnieClient } from '@repo/mnie-sdk'
|
||||
@@ -191,27 +193,34 @@ const listenForOAuthCallback = async () => {
|
||||
resolveCode = resolve
|
||||
rejectCode = reject
|
||||
})
|
||||
const server = Bun.serve({
|
||||
hostname: '127.0.0.1',
|
||||
port: 0,
|
||||
fetch(request) {
|
||||
const url = new URL(request.url)
|
||||
const server = createServer((request, response) => {
|
||||
const url = new URL(request.url ?? '/', 'http://127.0.0.1')
|
||||
const error = url.searchParams.get('error')
|
||||
const value = url.searchParams.get('code')
|
||||
queueMicrotask(() => server.stop(true))
|
||||
queueMicrotask(() => server.close())
|
||||
if (error) {
|
||||
rejectCode(new Error(error))
|
||||
return new Response('Mnie login failed. You can close this tab.', { status: 400 })
|
||||
response.writeHead(400, { 'content-type': 'text/plain; charset=utf-8' })
|
||||
response.end('Mnie login failed. You can close this tab.')
|
||||
return
|
||||
}
|
||||
if (!value) {
|
||||
rejectCode(new Error('oauth callback did not include a code'))
|
||||
return new Response('Mnie login failed. You can close this tab.', { status: 400 })
|
||||
response.writeHead(400, { 'content-type': 'text/plain; charset=utf-8' })
|
||||
response.end('Mnie login failed. You can close this tab.')
|
||||
return
|
||||
}
|
||||
resolveCode(value)
|
||||
return new Response('Mnie login complete. You can close this tab.')
|
||||
},
|
||||
response.writeHead(200, { 'content-type': 'text/plain; charset=utf-8' })
|
||||
response.end('Mnie login complete. You can close this tab.')
|
||||
})
|
||||
return { port: server.port, code }
|
||||
await new Promise<void>((resolve, reject) => {
|
||||
server.once('error', reject)
|
||||
server.listen(0, '127.0.0.1', () => resolve())
|
||||
})
|
||||
const address = server.address()
|
||||
if (!address || typeof address === 'string') throw new Error('failed to bind oauth callback')
|
||||
return { port: address.port, code }
|
||||
}
|
||||
|
||||
const registerOAuthClient = async (origin: string, redirectUri: string) => {
|
||||
@@ -254,7 +263,7 @@ const openBrowser = (url: string) => {
|
||||
const command =
|
||||
process.platform === 'darwin' ? 'open' : process.platform === 'win32' ? 'cmd' : 'xdg-open'
|
||||
const args = process.platform === 'win32' ? ['/c', 'start', '', url] : [url]
|
||||
Bun.spawn({ cmd: [command, ...args], stdout: 'ignore', stderr: 'ignore' })
|
||||
spawn(command, args, { detached: true, stdio: 'ignore' }).unref()
|
||||
}
|
||||
|
||||
const rpc = async (args: string[]) => {
|
||||
@@ -285,7 +294,7 @@ const rpc = async (args: string[]) => {
|
||||
}
|
||||
|
||||
const main = async () => {
|
||||
const [command, subcommand, ...rest] = Bun.argv.slice(2)
|
||||
const [command, subcommand, ...rest] = process.argv.slice(2)
|
||||
if (!command || command === '--help' || command === '-h') {
|
||||
console.log(help)
|
||||
return
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { defineConfig } from 'vite-plus'
|
||||
|
||||
export default defineConfig({
|
||||
pack: {
|
||||
entry: ['src/index.ts'],
|
||||
deps: {
|
||||
alwaysBundle: [/^@repo\//, /^@napi-rs\/keyring/],
|
||||
onlyBundle: false,
|
||||
},
|
||||
dts: true,
|
||||
format: ['esm'],
|
||||
platform: 'node',
|
||||
},
|
||||
})
|
||||
@@ -2,15 +2,16 @@
|
||||
"name": "@repo/mnie-sdk",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"module": "./src/index.ts",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./src/index.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./src/index.ts",
|
||||
"import": "./src/index.ts"
|
||||
"import": "./dist/index.mjs"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build": "cd ../.. && vp run @repo/mnie-types#build && cd packages/mnie-sdk && vp pack",
|
||||
"clean": "rm -rf dist",
|
||||
"typecheck": "tsc"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import { defineConfig } from 'vite-plus'
|
||||
|
||||
export default defineConfig({
|
||||
pack: {
|
||||
entry: ['src/index.ts'],
|
||||
deps: {
|
||||
alwaysBundle: [/^@repo\//],
|
||||
onlyBundle: false,
|
||||
},
|
||||
dts: { eager: true },
|
||||
format: ['esm'],
|
||||
platform: 'node',
|
||||
},
|
||||
})
|
||||
@@ -2,14 +2,16 @@
|
||||
"name": "@repo/mnie-types",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./src/index.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./src/index.ts",
|
||||
"import": "./src/index.ts"
|
||||
"import": "./dist/index.mjs"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"build": "vp pack",
|
||||
"clean": "rm -rf dist",
|
||||
"typecheck": "tsc"
|
||||
},
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import { defineConfig } from 'vite-plus'
|
||||
|
||||
export default defineConfig({
|
||||
pack: {
|
||||
entry: ['src/index.ts'],
|
||||
dts: { eager: true },
|
||||
format: ['esm'],
|
||||
platform: 'neutral',
|
||||
fixedExtension: true,
|
||||
},
|
||||
})
|
||||
+9
-1
@@ -15,7 +15,15 @@ export default defineConfig({
|
||||
},
|
||||
'app:build': {
|
||||
command: 'vp run @repo/mnie-app#build',
|
||||
dependsOn: ['typecheck:all'],
|
||||
dependsOn: ['typecheck:all', 'sdk-build'],
|
||||
},
|
||||
'sdk-build': {
|
||||
command: [
|
||||
'vp run @repo/mnie-types#build',
|
||||
'vp run @repo/client-sbi#build',
|
||||
'vp run @repo/mnie-sdk#build',
|
||||
'vp run @repo/mnie-cli#build',
|
||||
],
|
||||
},
|
||||
'app:start': {
|
||||
command: 'vp run @repo/mnie-app#start',
|
||||
|
||||
Reference in New Issue
Block a user