From 13db52c104cc7353583943f26800408d09195f86 Mon Sep 17 00:00:00 2001 From: Andrey Platov Date: Wed, 4 Aug 2021 19:13:14 +0200 Subject: [PATCH] typescript to copy json files Signed-off-by: Andrey Platov --- dev/server/package.json | 7 +- dev/server/src/index.ts | 5 +- dev/server/src/server.ts | 4 +- dev/storage/src/storage.ts | 9 +-- packages/core/src/hierarchy.ts | 1 - .../profiles/default/config/typescript.json | 76 +++++++++++++++++++ 6 files changed, 87 insertions(+), 15 deletions(-) create mode 100644 packages/platform-rig/profiles/default/config/typescript.json diff --git a/dev/server/package.json b/dev/server/package.json index 5866fe2d91..f06292ad6a 100644 --- a/dev/server/package.json +++ b/dev/server/package.json @@ -6,11 +6,8 @@ "license": "EPL-2.0", "scripts": { "build": "heft build", - "build:docs": "api-extractor run --local", - "test": "jest", - "lint": "ts-standard src", - "lint:fix": "eslint --fix ./src", - "format": "prettier --write 'src/**/*.{ts*,js*,yml}' && ts-standard --fix src" + "start": "node lib/index.js", + "lint:fix": "eslint --fix src" }, "devDependencies": { "@anticrm/platform-rig":"~0.6.0", diff --git a/dev/server/src/index.ts b/dev/server/src/index.ts index 65ead4648c..3542bd8526 100644 --- a/dev/server/src/index.ts +++ b/dev/server/src/index.ts @@ -14,4 +14,7 @@ // limitations under the License. // -export { start } from './server' +import { start } from './server' + +// eslint-disable-next-line @typescript-eslint/no-floating-promises +start(3333) diff --git a/dev/server/src/server.ts b/dev/server/src/server.ts index 7eecf22ac4..0caf1456fc 100644 --- a/dev/server/src/server.ts +++ b/dev/server/src/server.ts @@ -21,7 +21,7 @@ import { DevSession } from './session' /** * @public */ -export async function start (): Promise { +export async function start (port: number, host?: string): Promise { const storage = await createStorage() - startJsonRpc(server => new DevSession(server, storage), 3333) + startJsonRpc(server => new DevSession(server, storage), port, host) } diff --git a/dev/storage/src/storage.ts b/dev/storage/src/storage.ts index c2e4be8f34..4ca86b1aa4 100644 --- a/dev/storage/src/storage.ts +++ b/dev/storage/src/storage.ts @@ -25,6 +25,8 @@ import type { import { getResource } from '@anticrm/platform' import core, { ModelDb, TxDb, Hierarchy, DOMAIN_TX, DefaultTxFactory } from '@anticrm/core' +import * as txJson from './model.tx.json' + /** * @public */ @@ -37,10 +39,6 @@ export interface ServerStorage { tx: (tx: Tx) => Promise } -async function getModel (): Promise { - return import('./model.tx.json') as unknown as Tx[] -} - class DevStorage implements ServerStorage { private readonly txFactory: DefaultTxFactory @@ -91,8 +89,7 @@ class DevStorage implements ServerStorage { * @returns */ export async function createStorage (): Promise { - const txes = await getModel() - + const txes = txJson as unknown as Tx[] const hierarchy = new Hierarchy() for (const tx of txes) hierarchy.tx(tx) diff --git a/packages/core/src/hierarchy.ts b/packages/core/src/hierarchy.ts index d0bd05c9bc..727d4bc7c0 100644 --- a/packages/core/src/hierarchy.ts +++ b/packages/core/src/hierarchy.ts @@ -157,7 +157,6 @@ export class Hierarchy { this.attributes.set(_class, attributes) } attributes.set(attribute.name, attribute) - console.log('added attribute:', _class, attribute.name) } getAttribute (_class: Ref>, name: string): AnyAttribute { diff --git a/packages/platform-rig/profiles/default/config/typescript.json b/packages/platform-rig/profiles/default/config/typescript.json new file mode 100644 index 0000000000..aea78e1837 --- /dev/null +++ b/packages/platform-rig/profiles/default/config/typescript.json @@ -0,0 +1,76 @@ +/** + * Configures the TypeScript plugin for Heft. This plugin also manages linting. + */ + { + "$schema": "https://developer.microsoft.com/json-schemas/heft/typescript.schema.json", + + /** + * Can be set to "copy" or "hardlink". If set to "copy", copy files from cache. + * If set to "hardlink", files will be hardlinked to the cache location. + * This option is useful when producing a tarball of build output as TAR files don't + * handle these hardlinks correctly. "hardlink" is the default behavior. + */ + // "copyFromCacheMode": "copy", + + /** + * If provided, emit these module kinds in addition to the modules specified in the tsconfig. + * Note that this option only applies to the main tsconfig.json configuration. + */ + "additionalModuleKindsToEmit": [ + // { + // /** + // * (Required) Must be one of "commonjs", "amd", "umd", "system", "es2015", "esnext" + // */ + // "moduleKind": "amd", + // + // /** + // * (Required) The name of the folder where the output will be written. + // */ + // "outFolderName": "lib-amd" + // } + ], + + /** + * Specifies the intermediary folder that tests will use. Because Jest uses the + * Node.js runtime to execute tests, the module format must be CommonJS. + * + * The default value is "lib". + */ + // "emitFolderNameForTests": "lib-commonjs", + + /** + * If set to "true", the TSlint task will not be invoked. + */ + // "disableTslint": true, + + /** + * Set this to change the maximum number of file handles that will be opened concurrently for writing. + * The default is 50. + */ + // "maxWriteParallelism": 50, + + /** + * Describes the way files should be statically coped from src to TS output folders + */ + "staticAssetsToCopy": { + /** + * File extensions that should be copied from the src folder to the destination folder(s). + */ + "fileExtensions": [".json"] + + /** + * Glob patterns that should be explicitly included. + */ + // "includeGlobs": [ + // "some/path/*.js" + // ], + + /** + * Glob patterns that should be explicitly excluded. This takes precedence over globs listed + * in "includeGlobs" and files that match the file extensions provided in "fileExtensions". + */ + // "excludeGlobs": [ + // "some/path/*.css" + // ] + } + } \ No newline at end of file