From 1ca60304a162149e491762d679d3946f5318781c Mon Sep 17 00:00:00 2001 From: Alex McKinney Date: Tue, 26 Nov 2024 14:39:12 -0700 Subject: [PATCH] chore(cli): Add @fern-api/cli-logger (#5287) --- packages/cli/cli-logger/.depcheckrc.json | 10 ++++ packages/cli/cli-logger/.prettierrc.cjs | 1 + packages/cli/cli-logger/package.json | 43 +++++++++++++++++ .../{logger => cli-logger}/src/formatLog.ts | 0 packages/cli/cli-logger/src/index.ts | 1 + packages/cli/cli-logger/tsconfig.json | 11 +++++ packages/cli/cli-logger/vitest.config.ts | 1 + packages/cli/cli/package.json | 1 + .../src/commands/validate/logViolations.ts | 3 +- packages/cli/cli/tsconfig.json | 1 + packages/cli/lazy-fern-workspace/package.json | 1 + .../handleFailedWorkspaceParserResult.ts | 3 +- .../cli/lazy-fern-workspace/tsconfig.json | 1 + packages/cli/logger/package.json | 4 +- packages/cli/logger/src/index.ts | 1 - packages/cli/workspace-loader/package.json | 1 + .../src/handleFailedWorkspaceParserResult.ts | 3 +- packages/cli/workspace-loader/tsconfig.json | 1 + pnpm-lock.yaml | 46 ++++++++++++++++--- 19 files changed, 120 insertions(+), 13 deletions(-) create mode 100644 packages/cli/cli-logger/.depcheckrc.json create mode 100644 packages/cli/cli-logger/.prettierrc.cjs create mode 100644 packages/cli/cli-logger/package.json rename packages/cli/{logger => cli-logger}/src/formatLog.ts (100%) create mode 100644 packages/cli/cli-logger/src/index.ts create mode 100644 packages/cli/cli-logger/tsconfig.json create mode 100644 packages/cli/cli-logger/vitest.config.ts diff --git a/packages/cli/cli-logger/.depcheckrc.json b/packages/cli/cli-logger/.depcheckrc.json new file mode 100644 index 00000000000..a3a4f43188c --- /dev/null +++ b/packages/cli/cli-logger/.depcheckrc.json @@ -0,0 +1,10 @@ +{ + "ignores": [ + "@types/jest", + "globals", + "@types/node" + ], + "ignore-patterns": [ + "lib" + ] +} \ No newline at end of file diff --git a/packages/cli/cli-logger/.prettierrc.cjs b/packages/cli/cli-logger/.prettierrc.cjs new file mode 100644 index 00000000000..39cf0d0b8c9 --- /dev/null +++ b/packages/cli/cli-logger/.prettierrc.cjs @@ -0,0 +1 @@ +module.exports = require("../../../.prettierrc.json"); diff --git a/packages/cli/cli-logger/package.json b/packages/cli/cli-logger/package.json new file mode 100644 index 00000000000..88bcf7df6a3 --- /dev/null +++ b/packages/cli/cli-logger/package.json @@ -0,0 +1,43 @@ +{ + "name": "@fern-api/cli-logger", + "version": "0.0.0", + "repository": { + "type": "git", + "url": "https://github.com/fern-api/fern.git", + "directory": "packages/cli/cli-logger" + }, + "private": true, + "files": [ + "lib" + ], + "type": "module", + "source": "src/index.ts", + "main": "lib/index.js", + "types": "lib/index.d.ts", + "sideEffects": false, + "scripts": { + "clean": "rm -rf ./lib && tsc --build --clean", + "compile": "tsc --build", + "test": "vitest --passWithNoTests --run", + "test:update": "vitest --passWithNoTests --run -u", + "lint:eslint": "eslint --max-warnings 0 . --ignore-path=../../../.eslintignore", + "lint:eslint:fix": "yarn lint:eslint --fix", + "format": "prettier --write --ignore-unknown --ignore-path ../../../shared/.prettierignore \"**\"", + "format:check": "prettier --check --ignore-unknown --ignore-path ../../../shared/.prettierignore \"**\"", + "organize-imports": "organize-imports-cli tsconfig.json", + "depcheck": "depcheck" + }, + "dependencies": { + "chalk": "^5.3.0" + }, + "devDependencies": { + "@types/jest": "^29.5.12", + "@types/node": "18.7.18", + "depcheck": "^1.4.6", + "eslint": "^8.56.0", + "vitest": "^2.1.4", + "organize-imports-cli": "^0.10.0", + "prettier": "^2.7.1", + "typescript": "4.6.4" + } +} \ No newline at end of file diff --git a/packages/cli/logger/src/formatLog.ts b/packages/cli/cli-logger/src/formatLog.ts similarity index 100% rename from packages/cli/logger/src/formatLog.ts rename to packages/cli/cli-logger/src/formatLog.ts diff --git a/packages/cli/cli-logger/src/index.ts b/packages/cli/cli-logger/src/index.ts new file mode 100644 index 00000000000..a555e9e4360 --- /dev/null +++ b/packages/cli/cli-logger/src/index.ts @@ -0,0 +1 @@ +export { formatLog } from "./formatLog"; diff --git a/packages/cli/cli-logger/tsconfig.json b/packages/cli/cli-logger/tsconfig.json new file mode 100644 index 00000000000..93c6abdc960 --- /dev/null +++ b/packages/cli/cli-logger/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../../shared/tsconfig.shared.json", + "compilerOptions": { + "composite": true, + "outDir": "lib", + "rootDir": "src" + }, + "include": [ + "./src/**/*" + ] +} \ No newline at end of file diff --git a/packages/cli/cli-logger/vitest.config.ts b/packages/cli/cli-logger/vitest.config.ts new file mode 100644 index 00000000000..fecc099c58a --- /dev/null +++ b/packages/cli/cli-logger/vitest.config.ts @@ -0,0 +1 @@ +export { default } from "../../../shared/vitest.config"; diff --git a/packages/cli/cli/package.json b/packages/cli/cli/package.json index 327ca6c19ab..dfd7dfd92ce 100644 --- a/packages/cli/cli/package.json +++ b/packages/cli/cli/package.json @@ -41,6 +41,7 @@ "@fern-api/docs-resolver": "workspace:*", "@fern-api/api-workspace-commons": "workspace:*", "@fern-api/auth": "workspace:*", + "@fern-api/cli-logger": "workspace:*", "@fern-api/cli-migrations": "workspace:*", "@fern-api/configuration": "workspace:*", "@fern-api/core": "workspace:*", diff --git a/packages/cli/cli/src/commands/validate/logViolations.ts b/packages/cli/cli/src/commands/validate/logViolations.ts index 8094d7b3951..4b56567c8f9 100644 --- a/packages/cli/cli/src/commands/validate/logViolations.ts +++ b/packages/cli/cli/src/commands/validate/logViolations.ts @@ -1,5 +1,6 @@ import { assertNever } from "@fern-api/core-utils"; -import { formatLog, LogLevel } from "@fern-api/logger"; +import { LogLevel } from "@fern-api/logger"; +import { formatLog } from "@fern-api/cli-logger"; import { TaskContext } from "@fern-api/task-context"; import { ValidationViolation } from "@fern-api/fern-definition-validator"; import chalk from "chalk"; diff --git a/packages/cli/cli/tsconfig.json b/packages/cli/cli/tsconfig.json index 5c255cce9ef..95e0b4fbeac 100644 --- a/packages/cli/cli/tsconfig.json +++ b/packages/cli/cli/tsconfig.json @@ -16,6 +16,7 @@ { "path": "../generation/local-generation/local-workspace-runner" }, { "path": "../generation/remote-generation/remote-workspace-runner" }, { "path": "../init" }, + { "path": "../cli-logger" }, { "path": "../logger" }, { "path": "../login" }, { "path": "../mock" }, diff --git a/packages/cli/lazy-fern-workspace/package.json b/packages/cli/lazy-fern-workspace/package.json index a04467b6ea7..9d0a6db4995 100644 --- a/packages/cli/lazy-fern-workspace/package.json +++ b/packages/cli/lazy-fern-workspace/package.json @@ -29,6 +29,7 @@ }, "dependencies": { "@fern-api/api-workspace-commons": "workspace:*", + "@fern-api/cli-logger": "workspace:*", "@fern-api/configuration": "workspace:*", "@fern-api/core": "workspace:*", "@fern-api/core-utils": "workspace:*", diff --git a/packages/cli/lazy-fern-workspace/src/utils/handleFailedWorkspaceParserResult.ts b/packages/cli/lazy-fern-workspace/src/utils/handleFailedWorkspaceParserResult.ts index 26774de52f9..3f04c56f20c 100644 --- a/packages/cli/lazy-fern-workspace/src/utils/handleFailedWorkspaceParserResult.ts +++ b/packages/cli/lazy-fern-workspace/src/utils/handleFailedWorkspaceParserResult.ts @@ -1,7 +1,8 @@ import { DEPENDENCIES_FILENAME } from "@fern-api/configuration"; import { assertNever, entries } from "@fern-api/core-utils"; import { RelativeFilePath } from "@fern-api/fs-utils"; -import { formatLog, Logger } from "@fern-api/logger"; +import { Logger } from "@fern-api/logger"; +import { formatLog } from "@fern-api/cli-logger"; import chalk from "chalk"; import { YAMLException } from "js-yaml"; import { ZodIssue, ZodIssueCode } from "zod"; diff --git a/packages/cli/lazy-fern-workspace/tsconfig.json b/packages/cli/lazy-fern-workspace/tsconfig.json index 8b6bed8327d..46701e99011 100644 --- a/packages/cli/lazy-fern-workspace/tsconfig.json +++ b/packages/cli/lazy-fern-workspace/tsconfig.json @@ -9,6 +9,7 @@ { "path": "../api-importers/conjure/conjure-to-fern" }, { "path": "../../core" }, { "path": "../configuration" }, + { "path": "../cli-logger" }, { "path": "../logger" }, { "path": "../api-importers/openapi/openapi-ir-to-fern" }, { "path": "../api-importers/openapi/openapi-ir-parser" }, diff --git a/packages/cli/logger/package.json b/packages/cli/logger/package.json index f0f9aac4d1a..e1b82531987 100644 --- a/packages/cli/logger/package.json +++ b/packages/cli/logger/package.json @@ -28,12 +28,10 @@ "depcheck": "depcheck" }, "dependencies": { - "@fern-api/core-utils": "workspace:*", - "chalk": "^5.3.0" + "@fern-api/core-utils": "workspace:*" }, "devDependencies": { "@types/jest": "^29.5.12", - "@types/node": "18.7.18", "depcheck": "^1.4.6", "eslint": "^8.56.0", "vitest": "^2.1.4", diff --git a/packages/cli/logger/src/index.ts b/packages/cli/logger/src/index.ts index e29dd26e70c..095549f1491 100644 --- a/packages/cli/logger/src/index.ts +++ b/packages/cli/logger/src/index.ts @@ -1,6 +1,5 @@ export { CONSOLE_LOGGER } from "./console"; export { createLogger } from "./createLogger"; -export { formatLog } from "./formatLog"; export { type Logger } from "./Logger"; export { LogLevel, LOG_LEVELS } from "./LogLevel"; export { NOOP_LOGGER } from "./noop"; diff --git a/packages/cli/workspace-loader/package.json b/packages/cli/workspace-loader/package.json index 9fafa11b583..ce4b88c72fb 100644 --- a/packages/cli/workspace-loader/package.json +++ b/packages/cli/workspace-loader/package.json @@ -33,6 +33,7 @@ "@fern-api/configuration": "workspace:*", "@fern-api/core-utils": "workspace:*", "@fern-api/fs-utils": "workspace:*", + "@fern-api/cli-logger": "workspace:*", "@fern-api/logger": "workspace:*", "@fern-api/logging-execa": "workspace:*", "@fern-api/task-context": "workspace:*", diff --git a/packages/cli/workspace-loader/src/handleFailedWorkspaceParserResult.ts b/packages/cli/workspace-loader/src/handleFailedWorkspaceParserResult.ts index 0044a85ff6e..b921705bd43 100644 --- a/packages/cli/workspace-loader/src/handleFailedWorkspaceParserResult.ts +++ b/packages/cli/workspace-loader/src/handleFailedWorkspaceParserResult.ts @@ -1,7 +1,8 @@ import { DEPENDENCIES_FILENAME } from "@fern-api/configuration"; import { assertNever, entries } from "@fern-api/core-utils"; import { RelativeFilePath } from "@fern-api/fs-utils"; -import { formatLog, Logger } from "@fern-api/logger"; +import { Logger } from "@fern-api/logger"; +import { formatLog } from "@fern-api/cli-logger"; import chalk from "chalk"; import { YAMLException } from "js-yaml"; import { ZodIssue, ZodIssueCode } from "zod"; diff --git a/packages/cli/workspace-loader/tsconfig.json b/packages/cli/workspace-loader/tsconfig.json index 006eaf35610..a65f38410b8 100644 --- a/packages/cli/workspace-loader/tsconfig.json +++ b/packages/cli/workspace-loader/tsconfig.json @@ -8,6 +8,7 @@ { "path": "../../commons/logging-execa" }, { "path": "../../core" }, { "path": "../configuration" }, + { "path": "../cli-logger" }, { "path": "../logger" }, { "path": "../api-importers/openapi/openapi-ir-parser" }, { "path": "../semver-utils" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 333aaa11021..9694671f02e 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -3745,6 +3745,9 @@ importers: '@fern-api/auth': specifier: workspace:* version: link:../auth + '@fern-api/cli-logger': + specifier: workspace:* + version: link:../cli-logger '@fern-api/cli-migrations': specifier: workspace:* version: link:../cli-migrations @@ -3965,6 +3968,37 @@ importers: specifier: ^17.4.1 version: 17.7.2 + packages/cli/cli-logger: + dependencies: + chalk: + specifier: ^5.3.0 + version: 5.3.0 + devDependencies: + '@types/jest': + specifier: ^29.5.12 + version: 29.5.12 + '@types/node': + specifier: 18.7.18 + version: 18.7.18 + depcheck: + specifier: ^1.4.6 + version: 1.4.6 + eslint: + specifier: ^8.56.0 + version: 8.56.0 + organize-imports-cli: + specifier: ^0.10.0 + version: 0.10.0 + prettier: + specifier: ^2.7.1 + version: 2.7.1 + typescript: + specifier: 4.6.4 + version: 4.6.4 + vitest: + specifier: ^2.1.4 + version: 2.1.4(@types/node@18.7.18)(jsdom@20.0.3)(sass@1.72.0)(terser@5.31.5) + packages/cli/cli-migrations: dependencies: '@fern-api/configuration': @@ -5371,6 +5405,9 @@ importers: '@fern-api/api-workspace-commons': specifier: workspace:* version: link:../workspace-commons + '@fern-api/cli-logger': + specifier: workspace:* + version: link:../cli-logger '@fern-api/configuration': specifier: workspace:* version: link:../configuration @@ -5486,16 +5523,10 @@ importers: '@fern-api/core-utils': specifier: workspace:* version: link:../../commons/core-utils - chalk: - specifier: ^5.3.0 - version: 5.3.0 devDependencies: '@types/jest': specifier: ^29.5.12 version: 29.5.12 - '@types/node': - specifier: 18.7.18 - version: 18.7.18 depcheck: specifier: ^1.4.6 version: 1.4.6 @@ -5909,6 +5940,9 @@ importers: '@fern-api/api-workspace-commons': specifier: workspace:* version: link:../workspace-commons + '@fern-api/cli-logger': + specifier: workspace:* + version: link:../cli-logger '@fern-api/configuration': specifier: workspace:* version: link:../configuration