diff --git a/apps/admin-api/package.json b/apps/admin-api/package.json index b4fd75a8b..146528ca0 100644 --- a/apps/admin-api/package.json +++ b/apps/admin-api/package.json @@ -22,6 +22,7 @@ "clean": "shx rm -rf dist" }, "dependencies": { + "@my/config": "*", "app": "*", "chokidar": "^3.5.3", "cookie-parser": "^1.4.6", diff --git a/apps/admin-api/src/index.ts b/apps/admin-api/src/index.ts index 085595ee9..66d73087a 100644 --- a/apps/admin-api/src/index.ts +++ b/apps/admin-api/src/index.ts @@ -9,7 +9,7 @@ moduleAlias.addAliases({ import dotenv from 'dotenv' import { setConfig, getConfig, getLogger } from 'protobase'; -import { getBaseConfig, getConfigWithoutSecrets } from '../../../packages/app/BaseConfig' +import { getBaseConfig, getConfigWithoutSecrets } from '@my/config' // get config vars dotenv.config({ path: '../../.env' }); global.defaultRoute = '/adminapi/v1' diff --git a/apps/admin-api/src/proxy.ts b/apps/admin-api/src/proxy.ts index 5f7ccd5e1..1b15639fe 100644 --- a/apps/admin-api/src/proxy.ts +++ b/apps/admin-api/src/proxy.ts @@ -1,6 +1,6 @@ import { getLogger } from 'protobase'; -import { getBaseConfig } from '../../../packages/app/BaseConfig' +import { getBaseConfig } from '@my/config' import { getServiceToken } from 'protonode' import http from 'http'; import httpProxy from 'http-proxy'; diff --git a/apps/admin-api/tsconfig.json b/apps/admin-api/tsconfig.json index 4fe2aa338..b195fd179 100644 --- a/apps/admin-api/tsconfig.json +++ b/apps/admin-api/tsconfig.json @@ -36,7 +36,6 @@ "./app/bundles/objects.ts", "./app/bundles/library.ts", "./app/bundles/storageProviders.ts", - "./app/BaseConfig.ts", "./app/conf.ts", "./app/initialData.ts", "./protolib/src/bundles/adminapi.ts", diff --git a/apps/api/package.json b/apps/api/package.json index 008a06992..0371bb5ed 100644 --- a/apps/api/package.json +++ b/apps/api/package.json @@ -20,6 +20,7 @@ "clean": "shx rm -rf dist" }, "dependencies": { + "@my/config": "*", "aedes": "^0.50.0", "bcrypt": "^5.1.1", "chokidar": "^3.5.3", diff --git a/apps/api/src/api.ts b/apps/api/src/api.ts index 0c05d6a46..be8de50ec 100644 --- a/apps/api/src/api.ts +++ b/apps/api/src/api.ts @@ -1,6 +1,6 @@ import { getApp, getMQTTClient, getServiceToken } from 'protonode' import { getLogger, getConfig } from 'protobase'; -import { getConfigWithoutSecrets } from 'app/BaseConfig' +import { getConfigWithoutSecrets } from '@my/config' import BundleContext from 'app/bundles/apiContext' import { generateEvent } from 'protolib/bundles/events/eventsLibrary'; diff --git a/apps/api/src/index.ts b/apps/api/src/index.ts index 3b47da463..a75eb3513 100644 --- a/apps/api/src/index.ts +++ b/apps/api/src/index.ts @@ -10,7 +10,7 @@ import dotenv from 'dotenv' dotenv.config({ path: '../../.env' }); import { getServiceToken } from 'protonode' import { setConfig, getLogger } from 'protobase'; -import { getBaseConfig } from 'app/BaseConfig' +import { getBaseConfig } from '@my/config' setConfig(getBaseConfig('api', process, getServiceToken())) require('events').EventEmitter.defaultMaxListeners = 100; const logger = getLogger() diff --git a/apps/api/tsconfig.json b/apps/api/tsconfig.json index a8cd7ce6f..b923c17e9 100644 --- a/apps/api/tsconfig.json +++ b/apps/api/tsconfig.json @@ -36,7 +36,6 @@ "./app/bundles/objects.ts", "./app/bundles/library.ts", "./app/bundles/storageProviders.ts", - "./app/BaseConfig.ts", "./app/initialData.ts", "./protolib/src/bundles/apiContext.ts", "./protolib/src/bundles/devices/devices/devicesSchemas.ts", diff --git a/apps/electron/package.json b/apps/electron/package.json index 87b798dce..6918a939c 100644 --- a/apps/electron/package.json +++ b/apps/electron/package.json @@ -28,6 +28,7 @@ "@types/react": "^18.0.27", "app": "0.0.0", "compare-versions": "^3.4.0", + "@my/config": "*", "dotenv": "^16.3.1", "electron": "28.0.0", "electron-builder": "^24.9.1", diff --git a/apps/electron/pages/_app.tsx b/apps/electron/pages/_app.tsx index c43760920..bf6f8da6b 100644 --- a/apps/electron/pages/_app.tsx +++ b/apps/electron/pages/_app.tsx @@ -24,7 +24,7 @@ import type { SolitoAppProps } from 'solito' import { AppConfig } from '../conf' import { Provider as JotaiProvider } from 'jotai' import { setConfig, initSchemaSystem } from 'protobase'; -import {getBaseConfig} from 'app/BaseConfig' +import { getBaseConfig } from '@my/config' import { useSession } from 'protolib/lib/Session' import {AppConfContext} from 'protolib/providers/AppConf' import { getBrokerUrl} from 'protolib/lib/Broker' diff --git a/apps/next-compiled/package.json b/apps/next-compiled/package.json index 978a44c5c..49aafc8dc 100644 --- a/apps/next-compiled/package.json +++ b/apps/next-compiled/package.json @@ -11,6 +11,7 @@ "dependencies": { "@craftjs/core": "0.2.0-beta.8", "@craftjs/layers": "0.2.1", + "@my/config": "*", "@protocraft/core": "0.2.4-2", "@protocraft/layers": "0.2.1-2", "@react-three/drei": "9.77.3", diff --git a/apps/next/package.json b/apps/next/package.json index 51d4edb8a..ebb4fc8fd 100644 --- a/apps/next/package.json +++ b/apps/next/package.json @@ -17,6 +17,7 @@ "dependencies": { "@craftjs/core": "0.2.0-beta.8", "@craftjs/layers": "0.2.1", + "@my/config": "*", "@protocraft/core": "0.2.4-2", "@protocraft/layers": "0.2.1-2", "@react-three/drei": "9.77.3", diff --git a/apps/next/pages/_app.tsx b/apps/next/pages/_app.tsx index cc8b65fb3..a0ac59e95 100644 --- a/apps/next/pages/_app.tsx +++ b/apps/next/pages/_app.tsx @@ -20,7 +20,7 @@ import 'react-chat-widget/lib/styles.css'; import { NextThemeProvider, useRootTheme } from '@tamagui/next-theme' import { setConfig, initSchemaSystem } from 'protobase'; -import { getBaseConfig } from 'app/BaseConfig' +import { getBaseConfig } from '@my/config' setConfig(getBaseConfig("next", process)) import { Provider } from 'app/provider' import Head from 'next/head' diff --git a/packages/config/package.json b/packages/config/package.json new file mode 100644 index 000000000..0b52441b5 --- /dev/null +++ b/packages/config/package.json @@ -0,0 +1,19 @@ +{ + "name": "@my/config", + "version": "1.0.0", + "description": "Protofy configuration package", + "main": "dist/index.js", + "types": "dist/index.d.ts", + "scripts": { + "build": "tsc" + }, + "files": [ + "dist" + ], + "devDependencies": { + "typescript": "~5.3.3" + }, + "dependencies": { + "protobase": "*" + } +} diff --git a/packages/app/BaseConfig.ts b/packages/config/src/BaseConfig.ts similarity index 97% rename from packages/app/BaseConfig.ts rename to packages/config/src/BaseConfig.ts index fae5f557c..964bf6e9f 100644 --- a/packages/app/BaseConfig.ts +++ b/packages/config/src/BaseConfig.ts @@ -68,7 +68,7 @@ export const getBaseConfig = (name, process, token?, config?) => { //adds log to mqtt if in server-side and a serviceToken is available ...(process && typeof window === "undefined" && token ? [ { - target: __dirname+'/../protolib/lib/RemoteTransport.ts', + target: __dirname+'/../../protolib/lib/RemoteTransport.ts', level: 'debug', options: { username: name, diff --git a/packages/config/src/index.ts b/packages/config/src/index.ts new file mode 100644 index 000000000..3027624ed --- /dev/null +++ b/packages/config/src/index.ts @@ -0,0 +1 @@ +export * from './BaseConfig'; \ No newline at end of file diff --git a/packages/config/tsconfig.json b/packages/config/tsconfig.json new file mode 100644 index 000000000..61a25cd2c --- /dev/null +++ b/packages/config/tsconfig.json @@ -0,0 +1,16 @@ +{ + "compilerOptions": { + "target": "es5", + "lib": ["dom", "esnext"], + "module": "commonjs", + "declaration": true, + "outDir": "./dist", + "rootDir": "./src", + "strict": false, + "esModuleInterop": true, + "skipLibCheck": true, + "forceConsistentCasingInFileNames": true + }, + "include": ["src/**/*"], + "exclude": ["node_modules", "dist"] + } \ No newline at end of file diff --git a/packages/protobase/package.json b/packages/protobase/package.json index 6f43ee372..ca56f4b3b 100644 --- a/packages/protobase/package.json +++ b/packages/protobase/package.json @@ -13,7 +13,6 @@ "dependencies": { "handlebars": "4.7.8" }, - "devDependencies": { "typescript": "~5.3.3" } diff --git a/yarn.lock b/yarn.lock index f3aa95ef1..beba1e686 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5250,6 +5250,15 @@ __metadata: languageName: node linkType: hard +"@my/config@npm:*, @my/config@workspace:packages/config": + version: 0.0.0-use.local + resolution: "@my/config@workspace:packages/config" + dependencies: + protobase: "npm:*" + typescript: "npm:~5.3.3" + languageName: unknown + linkType: soft + "@my/ui@npm:0.0.1, @my/ui@workspace:packages/ui": version: 0.0.0-use.local resolution: "@my/ui@workspace:packages/ui" @@ -10929,6 +10938,7 @@ __metadata: version: 0.0.0-use.local resolution: "admin-api@workspace:apps/admin-api" dependencies: + "@my/config": "npm:*" "@types/bcrypt": "npm:^5.0.0" "@types/express": "npm:^4.17.17" "@types/node": "npm:20.6.0" @@ -11262,6 +11272,7 @@ __metadata: version: 0.0.0-use.local resolution: "api@workspace:apps/api" dependencies: + "@my/config": "npm:*" "@types/bcrypt": "npm:^5.0.0" "@types/express": "npm:^4.17.17" "@types/node": "npm:20.6.0" @@ -23107,6 +23118,7 @@ __metadata: "@craftjs/core": "npm:0.2.0-beta.8" "@craftjs/layers": "npm:0.2.1" "@jest/globals": "npm:~29.7.0" + "@my/config": "npm:*" "@protocraft/core": "npm:0.2.4-2" "@protocraft/layers": "npm:0.2.1-2" "@react-three/drei": "npm:9.77.3" @@ -23233,6 +23245,7 @@ __metadata: "@craftjs/core": "npm:0.2.0-beta.8" "@craftjs/layers": "npm:0.2.1" "@jest/globals": "npm:~29.7.0" + "@my/config": "npm:*" "@protocraft/core": "npm:0.2.4-2" "@protocraft/layers": "npm:0.2.1-2" "@react-three/drei": "npm:9.77.3" @@ -25237,6 +25250,7 @@ __metadata: version: 0.0.0-use.local resolution: "protobase@workspace:packages/protobase" dependencies: + handlebars: "npm:4.7.8" typescript: "npm:~5.3.3" languageName: unknown linkType: soft