diff --git a/.gitignore b/.gitignore index 674505c..6a95282 100644 --- a/.gitignore +++ b/.gitignore @@ -106,3 +106,7 @@ dist # Log4brains .log4brains + +# IntelliJ +*.iml +.idea diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c38c9a4..440b876 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,19 +9,20 @@ Thank you so much! :clap: ## Development ```bash +# First, uninstall any global version and install dependencies npm uninstall -g log4brains yarn install -yarn link-cli + +# Build all packages yarn build -yarn dev -# ... if it does not work, you may have to add this line to your ~/.bashrc (or similar): -# export PATH="$PATH:$(yarn global bin)" +# Link the CLI for local development (only the global-cli package supports linking) +cd packages/global-cli && yarn link && cd ../.. -# You can now develop -# `yarn dev` re-builds the changed packages live +# Start development mode (watches and rebuilds packages on changes) +yarn dev -# You can test the different packages directly on the Log4brains project +# You can now develop and test the CLI directly on the Log4brains project log4brains adr new log4brains preview log4brains build @@ -40,7 +41,7 @@ cd $(mktemp -d -t l4b-test-XXXX) log4brains init ``` -When you are done, run `yarn unlink-cli && npm install -g log4brains` to use the official version again. +When you are done, run `cd packages/global-cli && yarn unlink && cd ../.. && npm install -g log4brains` to use the official version again. ## Coding standards @@ -75,13 +76,13 @@ Log4brains follows a **simplified Git Flow** model. Here’s how the process wor ```bash yarn lint # enforced automatically before every commit with husky+lint-staged - yarn format:fix # enforced automatically before every commit with husky+lint-staged + yarn format --write # format code (format:fix script may not work correctly) yarn typescript # enforced automatically before every commit with husky - yarn test:changed # (or `yarn test` to run all the tests) + yarn test # run all tests (test:changed may have issues) # Simulate the execution on a fresh install: - yarn link-cli yarn build + cd packages/global-cli && yarn link && cd ../.. rm -rf node_modules yarn install --production --no-lockfile yarn e2e diff --git a/package.json b/package.json index 75a9230..e3e69bc 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ "eslint-plugin-promise": "^4.2.1", "eslint-plugin-react": "^7.20.6", "eslint-plugin-react-hooks": "^4.1.2", - "eslint-plugin-sonarjs": "^0.5.0", + "eslint-plugin-sonarjs": "^0.25.1", "husky": "^4.3.5", "jest": "^26.4.2", "jest-mock-extended": "^1.0.10", @@ -74,5 +74,6 @@ "commitizen": { "path": "cz-conventional-changelog" } - } + }, + "dependencies": {} } diff --git a/packages/cli/src/cli.ts b/packages/cli/src/cli.ts index 6a547df..031be49 100644 --- a/packages/cli/src/cli.ts +++ b/packages/cli/src/cli.ts @@ -16,7 +16,7 @@ const templateExampleUrl = let l4bInstance: Log4brains; function getL4bInstance(): Log4brains { if (!l4bInstance) { - l4bInstance = Log4brains.createFromCwd(process.env.LOG4BRAINS_CWD || "."); + l4bInstance = Log4brains.create(process.env.LOG4BRAINS_CWD); } return l4bInstance; } diff --git a/packages/web/cli/utils.ts b/packages/web/cli/utils.ts index 8cab912..0df2b7f 100644 --- a/packages/web/cli/utils.ts +++ b/packages/web/cli/utils.ts @@ -6,7 +6,7 @@ import path from "path"; let l4bInstance: Log4brains; export function getL4bInstance(): Log4brains { if (!l4bInstance) { - l4bInstance = Log4brains.createFromCwd(process.env.LOG4BRAINS_CWD || "."); + l4bInstance = Log4brains.create(process.env.LOG4BRAINS_CWD); } return l4bInstance; } diff --git a/packages/web/nextjs/src/lib/core-api/instance.ts b/packages/web/nextjs/src/lib/core-api/instance.ts index cb7347f..eb6ef05 100644 --- a/packages/web/nextjs/src/lib/core-api/instance.ts +++ b/packages/web/nextjs/src/lib/core-api/instance.ts @@ -8,14 +8,14 @@ export function getLog4brainsInstance(): Log4brains { if (!instance) { if (process.env.LOG4BRAINS_PHASE === "initial-build") { // Noop instance during "next build" phase - instance = Log4brains.createFromCwd( + instance = Log4brains.create( path.join( getConfig().serverRuntimeConfig.PROJECT_ROOT, - "lib/core-api/noop" + "src/lib/core-api/noop" ) ); } else { - instance = Log4brains.createFromCwd(process.env.LOG4BRAINS_CWD || "."); + instance = Log4brains.create(process.env.LOG4BRAINS_CWD); } } return instance; diff --git a/packages/web/package.json b/packages/web/package.json index 4fc5604..a8d35c0 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -36,7 +36,7 @@ "build:cli": "microbundle --no-compress --format es,cjs --tsconfig tsconfig.build.json --target node", "clean:cli": "rimraf ./dist", "dev:nextjs": "cd nextjs && cross-env LOG4BRAINS_CWD=../.. NODE_OPTIONS=--openssl-legacy-provider next", - "build:nextjs": "yarn clean:nextjs && cd nextjs && cross-env LOG4BRAINS_PHASE=initial-build NODE_OPTIONS=--openssl-legacy-provider next build", + "build:nextjs": "yarn clean:nextjs && cd nextjs && cross-env LOG4BRAINS_CWD=../.. LOG4BRAINS_PHASE=initial-build NODE_OPTIONS=--openssl-legacy-provider next build", "clean:nextjs": "rimraf ./nextjs/.next ./nextjs/.next-export", "serve": "serve .log4brains/out", "typescript": "tsc --noEmit && cd nextjs && tsc", diff --git a/yarn.lock b/yarn.lock index bc9a50a..1523364 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5856,9 +5856,9 @@ caniuse-api@^3.0.0: lodash.uniq "^4.5.0" caniuse-lite@^1.0.0, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001125, caniuse-lite@^1.0.30001202, caniuse-lite@^1.0.30001214, caniuse-lite@^1.0.30001219, caniuse-lite@^1.0.30001228: - version "1.0.30001687" - resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001687.tgz" - integrity sha512-0S/FDhf4ZiqrTUiQ39dKeUjYRjkv7lOZU1Dgif2rIqrTzX/1wV2hfKu9TOm1IHkdSijfLswxTFzl/cvir+SLSQ== + version "1.0.30001727" + resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001727.tgz" + integrity sha512-pB68nIHmbN6L/4C6MH1DokyR3bYqFwjaSs/sWDHGj4CTcFtQUQMuJftVwWkXq7mNWOybD3KhUv3oWHoGxgP14Q== capture-exit@^2.0.0: version "2.0.0" @@ -8235,10 +8235,10 @@ eslint-plugin-react@^7.20.6: resolve "^2.0.0-next.3" string.prototype.matchall "^4.0.4" -eslint-plugin-sonarjs@^0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.5.0.tgz#ce17b2daba65a874c2862213a9e38e8986ad7d7d" - integrity sha512-XW5MnzlRjhXpIdbULC/qAdJYHWw3rRLws/DyawdlPU/IdVr9AmRK1r2LaCvabwKOAW2XYYSo3kDX58E4MrB7PQ== +eslint-plugin-sonarjs@^0.25.1: + version "0.25.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-sonarjs/-/eslint-plugin-sonarjs-0.25.1.tgz#0619798dbc27b04fd0a8e6d0fb6adf7fa2cb5041" + integrity sha512-5IOKvj/GMBNqjxBdItfotfRHo7w48496GOu1hxdeXuD0mB1JBlDCViiLHETDTfA8pDAVSBimBEQoetRXYceQEw== eslint-scope@^3.7.1: version "3.7.3"