Skip to content

Commit

Permalink
Moves baseconfig to dedicated configuration package at packages/confi…
Browse files Browse the repository at this point in the history
…g (@my/config). This prevents centralization in packages/app and simplify the project
  • Loading branch information
jcarlosn committed Jul 7, 2024
1 parent 5dbdb54 commit c3ce229
Show file tree
Hide file tree
Showing 19 changed files with 62 additions and 10 deletions.
1 change: 1 addition & 0 deletions apps/admin-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"clean": "shx rm -rf dist"
},
"dependencies": {
"@my/config": "*",
"app": "*",
"chokidar": "^3.5.3",
"cookie-parser": "^1.4.6",
Expand Down
2 changes: 1 addition & 1 deletion apps/admin-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion apps/admin-api/src/proxy.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
1 change: 0 additions & 1 deletion apps/admin-api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"clean": "shx rm -rf dist"
},
"dependencies": {
"@my/config": "*",
"aedes": "^0.50.0",
"bcrypt": "^5.1.1",
"chokidar": "^3.5.3",
Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/api.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion apps/api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
1 change: 0 additions & 1 deletion apps/api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions apps/electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion apps/electron/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
1 change: 1 addition & 0 deletions apps/next-compiled/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions apps/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion apps/next/pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
19 changes: 19 additions & 0 deletions packages/config/package.json
Original file line number Diff line number Diff line change
@@ -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": "*"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions packages/config/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './BaseConfig';
16 changes: 16 additions & 0 deletions packages/config/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"]
}
1 change: 0 additions & 1 deletion packages/protobase/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
"dependencies": {
"handlebars": "4.7.8"
},

"devDependencies": {
"typescript": "~5.3.3"
}
Expand Down
14 changes: 14 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c3ce229

Please sign in to comment.