mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-23 16:56:07 +00:00
update workspace tooling
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
959c52a78e
commit
02717f4450
@ -85,7 +85,6 @@ specifiers:
|
|||||||
cross-env: ^7.0.3
|
cross-env: ^7.0.3
|
||||||
css-loader: ^5.2.1
|
css-loader: ^5.2.1
|
||||||
dotenv-webpack: ^7.0.2
|
dotenv-webpack: ^7.0.2
|
||||||
esbuild: ^0.12.24
|
|
||||||
eslint: ^7.32.0
|
eslint: ^7.32.0
|
||||||
eslint-config-standard-with-typescript: ^20.0.0
|
eslint-config-standard-with-typescript: ^20.0.0
|
||||||
eslint-plugin-import: '2'
|
eslint-plugin-import: '2'
|
||||||
@ -201,7 +200,6 @@ dependencies:
|
|||||||
cross-env: 7.0.3
|
cross-env: 7.0.3
|
||||||
css-loader: 5.2.7_webpack@5.48.0
|
css-loader: 5.2.7_webpack@5.48.0
|
||||||
dotenv-webpack: 7.0.3_webpack@5.48.0
|
dotenv-webpack: 7.0.3_webpack@5.48.0
|
||||||
esbuild: 0.12.24
|
|
||||||
eslint: 7.32.0
|
eslint: 7.32.0
|
||||||
eslint-config-standard-with-typescript: 20.0.0_2e482f375e273d762fe67cbd5e194b49
|
eslint-config-standard-with-typescript: 20.0.0_2e482f375e273d762fe67cbd5e194b49
|
||||||
eslint-plugin-import: 2.23.4_eslint@7.32.0
|
eslint-plugin-import: 2.23.4_eslint@7.32.0
|
||||||
@ -10000,7 +9998,7 @@ packages:
|
|||||||
dev: false
|
dev: false
|
||||||
|
|
||||||
file:projects/workspace.tgz_6c259fadfeb3a4b20890aefe87070b8b:
|
file:projects/workspace.tgz_6c259fadfeb3a4b20890aefe87070b8b:
|
||||||
resolution: {integrity: sha512-Ircelx/9snTrdceAfj7OBTqmR1tZ/cTtPtdf3zcmTJ+EwFh0rhWQJgd80CSeny6I8wMC+UXcKUk5mGHDqcmKcw==, tarball: file:projects/workspace.tgz}
|
resolution: {integrity: sha512-8vO7UTqdUdxIPbiMIKXV54zDnFD63L75+7Z9mTnVO5Ln6Nb5rf+ZfYloA2pDauRKp0Rf7ItIYPhjmEpp8QE+Ow==, tarball: file:projects/workspace.tgz}
|
||||||
id: file:projects/workspace.tgz
|
id: file:projects/workspace.tgz
|
||||||
name: '@rush-temp/workspace'
|
name: '@rush-temp/workspace'
|
||||||
version: 0.0.0
|
version: 0.0.0
|
||||||
@ -10013,6 +10011,7 @@ packages:
|
|||||||
eslint-plugin-import: 2.23.4_eslint@7.32.0
|
eslint-plugin-import: 2.23.4_eslint@7.32.0
|
||||||
eslint-plugin-node: 11.1.0_eslint@7.32.0
|
eslint-plugin-node: 11.1.0_eslint@7.32.0
|
||||||
eslint-plugin-promise: 4.3.1
|
eslint-plugin-promise: 4.3.1
|
||||||
|
jwt-simple: 0.5.6
|
||||||
mongodb: 4.1.1
|
mongodb: 4.1.1
|
||||||
ts-node: 10.2.1_typescript@4.3.5
|
ts-node: 10.2.1_typescript@4.3.5
|
||||||
transitivePeerDependencies:
|
transitivePeerDependencies:
|
||||||
|
@ -4,5 +4,7 @@ WORKDIR /usr/src/app
|
|||||||
|
|
||||||
COPY bundle.js ./
|
COPY bundle.js ./
|
||||||
|
|
||||||
|
ENV TRANSACTOR_URL ws://transactor/
|
||||||
|
|
||||||
EXPOSE 8080
|
EXPOSE 8080
|
||||||
CMD [ "bash" ]
|
CMD [ "bash" ]
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@anticrm/core": "~0.6.11",
|
"@anticrm/core": "~0.6.11",
|
||||||
"mongodb": "^4.1.0"
|
"mongodb": "^4.1.0",
|
||||||
|
"@anticrm/contrib": "~0.6.0",
|
||||||
|
"jwt-simple": "~0.5.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,14 +14,20 @@
|
|||||||
// limitations under the License.
|
// limitations under the License.
|
||||||
//
|
//
|
||||||
|
|
||||||
import { createModel } from '.'
|
import { createWorkspace } from '.'
|
||||||
|
|
||||||
const url = process.env.MONGO_URL
|
const mongoUrl = process.env.MONGO_URL
|
||||||
if (url === undefined) {
|
if (mongoUrl === undefined) {
|
||||||
console.error('please provide mongodb url.')
|
console.error('please provide mongodb url.')
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const transactorUrl = process.env.TRANSACTOR_URL
|
||||||
|
if (transactorUrl === undefined) {
|
||||||
|
console.error('please provide transactor url.')
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
const db = process.argv[2]
|
const db = process.argv[2]
|
||||||
if (db === undefined) {
|
if (db === undefined) {
|
||||||
console.error('Please specify the database.')
|
console.error('Please specify the database.')
|
||||||
@ -29,6 +35,6 @@ if (db === undefined) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
console.log('creating model...')
|
console.log('creating model...')
|
||||||
createModel(url, db).then(rows => {
|
createWorkspace(mongoUrl, db, transactorUrl).then(() => {
|
||||||
console.log(`done, ${rows} rows inserted.`)
|
console.log(`done.`)
|
||||||
}).catch(error => { console.error(error) })
|
}).catch(error => { console.error(error) })
|
||||||
|
@ -15,25 +15,40 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import { MongoClient, Document } from 'mongodb'
|
import { MongoClient, Document } from 'mongodb'
|
||||||
import { DOMAIN_TX } from '@anticrm/core'
|
import core, { DOMAIN_TX, Tx } from '@anticrm/core'
|
||||||
|
import { createContributingClient } from '@anticrm/contrib'
|
||||||
|
import { encode } from 'jwt-simple'
|
||||||
|
|
||||||
import * as txJson from './model.tx.json'
|
import * as txJson from './model.tx.json'
|
||||||
|
|
||||||
const txes = (txJson as any).default
|
const txes = (txJson as any).default as Tx[]
|
||||||
|
|
||||||
console.log(txes)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
*/
|
*/
|
||||||
export async function createModel (url: string, dbName: string): Promise<number> {
|
export async function createWorkspace (mongoUrl: string, dbName: string, clientUrl: string): Promise<void> {
|
||||||
const client = new MongoClient(url)
|
const client = new MongoClient(mongoUrl)
|
||||||
try {
|
try {
|
||||||
await client.connect()
|
await client.connect()
|
||||||
const db = client.db(dbName)
|
const db = client.db(dbName)
|
||||||
|
|
||||||
|
console.log('dropping database...')
|
||||||
await db.dropDatabase()
|
await db.dropDatabase()
|
||||||
const result = await db.collection(DOMAIN_TX).insertMany(txes as Document[])
|
|
||||||
return result.insertedCount
|
console.log('creating model...')
|
||||||
|
const model = txes.filter(tx => tx.objectSpace === core.space.Model)
|
||||||
|
const result = await db.collection(DOMAIN_TX).insertMany(model as Document[])
|
||||||
|
console.log(`${result.insertedCount} model transactions inserted.`)
|
||||||
|
|
||||||
|
console.log('creating data...')
|
||||||
|
const data = txes.filter(tx => tx.objectSpace !== core.space.Model)
|
||||||
|
const token = encode({ email: 'anticrm@hc.engineering', workspace: dbName }, 'secret')
|
||||||
|
const url = new URL(`/${token}`, clientUrl)
|
||||||
|
const contrib = await createContributingClient(url.href)
|
||||||
|
for (const tx of data) {
|
||||||
|
await contrib.tx(tx)
|
||||||
|
}
|
||||||
|
contrib.close()
|
||||||
} finally {
|
} finally {
|
||||||
await client.close()
|
await client.close()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user