Skip to content

Commit

Permalink
Change indent spaces from 4 to 2 && changed max-len to 999 due to errors
Browse files Browse the repository at this point in the history
  • Loading branch information
DemogorGod committed Oct 10, 2023
1 parent d9eaccd commit f999f2a
Show file tree
Hide file tree
Showing 5 changed files with 311 additions and 300 deletions.
4 changes: 2 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
"@typescript-eslint"
],
"rules": {
"indent": ["error", 4],
"indent": ["error", 2],
"semi": ["error", "never"],
"quotes": ["error", "single"],
"vue/multi-word-component-names": "off",
"max-len": ["error", { "code": 150 }],
"max-len": ["error", { "code": 999 }]
},
"ignorePatterns": [
"contracts/**/scripts/resources",
Expand Down
48 changes: 23 additions & 25 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"[html]": {
"editor.defaultFormatter": "Vue.volar"
},
"[vue]": {
"editor.defaultFormatter": "Vue.volar"
},
"[javascript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"eslint.validate": [
"vue",
"typescript"
],
"css.lint.unknownAtRules": "ignore",
"jupyter.notebookFileRoot": "${fileDirname}",
"volar.inlayHints.eventArgumentInInlineHandlers": false,
"eslint.format.enable": true,
"eslint.run": "onType"
}
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"[html]": {
"editor.defaultFormatter": "Vue.volar"
},
"[vue]": {
"editor.defaultFormatter": "Vue.volar"
},
"[javascript]": {
"editor.defaultFormatter": "vscode.typescript-language-features"
},
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"eslint.validate": ["vue", "typescript"],
"css.lint.unknownAtRules": "ignore",
"jupyter.notebookFileRoot": "${fileDirname}",
"volar.inlayHints.eventArgumentInInlineHandlers": false,
"eslint.format.enable": true,
"eslint.run": "onType",
"terminal.integrated.defaultProfile.windows": ""
}
12 changes: 7 additions & 5 deletions apps/web/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
<script lang="ts" setup>
import { RouterView } from 'vue-router'
import DefaultLayout from '@/layouts/default-layout.vue'
import { RouterView } from 'vue-router'
import DefaultLayout from '@/layouts/default-layout.vue'
function helloChris() {
console.log('sjfd;askdnmj')
}
</script>

<template>
<Suspense>
<component
:is="DefaultLayout"
>
<component :is="DefaultLayout">
<RouterView />
</component>
</Suspense>
Expand Down
100 changes: 51 additions & 49 deletions services/users/scripts/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,60 +9,62 @@ import { JsonSchema, Schema, accountSchema, nonceSchema, operatorSchema, userSch
*/
void async function () {

if (process.env.STAGE !== 'local') {
await loadCredentials()
const dbCredentials = await getSecret(`${process.env.PROJECT}-users-db-credentials-${process.env.STAGE}`)
const { port: dbPort, host: dbHost, dbname: dbName, username: dbUser, password: dbPassword } = JSON.parse(dbCredentials as string)
process.env.DB_HOST = dbHost
process.env.DB_PORT = dbPort
process.env.DB_NAME = dbName
process.env.DB_USER = dbUser
process.env.DB_PASSWORD = dbPassword
const sessionsCredentials = await getSecret(`${process.env.PROJECT}-sessions-credentials-${process.env.STAGE}`)
const { host: sessionsHost, key: sessionsKey } = JSON.parse(sessionsCredentials as string)
process.env.SESSIONS_HOST = sessionsHost
process.env.SESSIONS_KEY = sessionsKey
}
if (process.env.STAGE !== 'local') {
await loadCredentials()
const dbCredentials = await getSecret(`${process.env.PROJECT}-users-db-credentials-${process.env.STAGE}`)
const { port: dbPort, host: dbHost, dbname: dbName, username: dbUser, password: dbPassword } = JSON.parse(dbCredentials as string)
process.env.DB_HOST = dbHost
process.env.DB_PORT = dbPort
process.env.DB_NAME = dbName
process.env.DB_USER = dbUser
process.env.DB_PASSWORD = dbPassword
const sessionsCredentials = await getSecret(`${process.env.PROJECT}-sessions-credentials-${process.env.STAGE}`)
const { host: sessionsHost, key: sessionsKey } = JSON.parse(sessionsCredentials as string)
process.env.SESSIONS_HOST = sessionsHost
process.env.SESSIONS_KEY = sessionsKey
}

const resourceDir = './scripts'
const resourceDir = './scripts'

const tableSchemas = {
account: accountSchema,
operator: operatorSchema,
nonce: nonceSchema,
user: userSchema,
userAccount: userAccountSchema
}
const tableSchemas = {
account: accountSchema,
operator: operatorSchema,
nonce: nonceSchema,
user: userSchema,
userAccount: userAccountSchema
}

let sqlSchema = ''
for (const table of Object.keys(tableSchemas)) {
const tableSchema = tableSchemas[table] as JsonSchema
const schema = new Schema(tableSchema)
const postgresTable = schema.getPostgresTable()
console.log(`${schema.getTitle()} JSON schema parsed to SQL`)
sqlSchema += `${postgresTable}\n\n`
}
let sqlSchema = ''
for (const table of Object.keys(tableSchemas)) {
const tableSchema = tableSchemas[table] as JsonSchema
const schema = new Schema(tableSchema)
const postgresTable = schema.getPostgresTable()
console.log(`${schema.getTitle()} JSON schema parsed to SQL`)
sqlSchema += `${postgresTable}\n\n`
}

const sqlDir = `${resourceDir}/.out/sql`
if (!fs.existsSync(sqlDir)) fs.mkdirSync(sqlDir, { recursive: true })
fs.writeFileSync(`${sqlDir}/schema.sql`, sqlSchema)
const sqlDir = `${resourceDir}/.out/sql`
if (!fs.existsSync(sqlDir)) fs.mkdirSync(sqlDir, { recursive: true })
fs.writeFileSync(`${sqlDir}/schema.sql`, sqlSchema)

const stackName = 'casimir-users-db'
await run(`docker compose -p ${stackName} -f ${resourceDir}/docker-compose.yaml up -d`)
let dbReady = false
while (!dbReady) {
const health = await run('docker inspect --format=\'{{lower .State.Health.Status}}\' postgres') as string
dbReady = health.trim() === 'healthy'
await new Promise(resolve => setTimeout(resolve, 2500))
}
const atlas = await run('which atlas') as string
if (!atlas || atlas.includes('not found')) {
if (os.platform() === 'darwin') {
await run('echo y | brew install atlas')
} else {
throw new Error('Please install atlas using `curl -sSf https://atlasgo.sh | sh`')
}
const stackName = 'casimir-users-db'
await run(`docker compose -p ${stackName} -f ${resourceDir}/docker-compose.yaml up -d`)
let dbReady = false
while (!dbReady) {
const health = await run('docker inspect --format=\'{{lower .State.Health.Status}}\' postgres') as string
dbReady = health.trim() === 'healthy'
await new Promise(resolve => setTimeout(resolve, 2500))
}
const atlas = await run('which atlas') as string
if (!atlas || atlas.includes('not found')) {
if (os.platform() === 'darwin') {
await run('echo y | brew install atlas')
} else {
throw new Error('Please install atlas using `curl -sSf https://atlasgo.sh | sh`')
}
}

await run(`atlas schema apply --url "postgres://postgres:password@localhost:5432/users?sslmode=disable" --to "file://${sqlDir}/schema.sql" --dev-url "docker://postgres/15" --auto-approve`)
await run(
`atlas schema apply --url "postgres://postgres:password@localhost:5432/users?sslmode=disable" --to "file://
${sqlDir}/schema.sql" --dev-url "docker://postgres/15" --auto-approve`)
}()
Loading

0 comments on commit f999f2a

Please sign in to comment.