diff --git a/.env.example b/.env.example index 64dd9ba976..464d2983fc 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,8 @@ -# for uploading to portal +# Example environment variables +# These are for reference only - use .env.local for local development + +# For uploading to Code PushUp portal CP_API_KEY= + +# Note: For local development with tsx/TypeScript execution, +# copy .env.local.example to .env.local and configure NODE_OPTIONS there diff --git a/.env.local b/.env.local new file mode 100644 index 0000000000..67d48d3925 --- /dev/null +++ b/.env.local @@ -0,0 +1,9 @@ +# Local development environment variables +# Copy this to .env.local (gitignored) and customize for your setup + +# Enable tsx for TypeScript execution in Nx +# This allows running local generator/executor directly as .ts files without pre-compilation +# This allowes the local plugins to import files with .js extensions (same as the packages in the repository) +NODE_OPTIONS=--import tsx +# This is used to resolve the paths in the local generator/executor so local packages can be imported as path aliases +TSX_TSCONFIG_PATH=tsconfig.base.json diff --git a/.env.local.example b/.env.local.example new file mode 100644 index 0000000000..fe63e05eee --- /dev/null +++ b/.env.local.example @@ -0,0 +1,12 @@ +# Local development environment variables +# Copy this to .env.local (gitignored) and customize for your setup + +# Enable tsx for TypeScript execution in Nx +# This allows running local generator/executor directly as .ts files without pre-compilation +# This allowes the local plugins to import files with .js extensions (same as the packages in the repository) +NODE_OPTIONS=--import tsx +# This is used to resolve the paths in the local generator/executor so local packages can be imported as path aliases +TSX_TSCONFIG_PATH=tsconfig.base.json + +# Local API keys (optional - only if testing upload features) +# CP_API_KEY=your_api_key_here diff --git a/.gitignore b/.gitignore index 31d7e1678c..6ba3d0b23a 100644 --- a/.gitignore +++ b/.gitignore @@ -57,4 +57,4 @@ vitest.config.*.timestamp* .cursor/rules/nx-rules.mdc .github/instructions/nx.instructions.md -code-pushup.config.bundled_*.mjs \ No newline at end of file +code-pushup.config.bundled_*.mjs diff --git a/e2e/ci-e2e/mocks/fixtures/basic/.env.local b/e2e/ci-e2e/mocks/fixtures/basic/.env.local new file mode 100644 index 0000000000..7b643f70cf --- /dev/null +++ b/e2e/ci-e2e/mocks/fixtures/basic/.env.local @@ -0,0 +1,8 @@ +# Local development environment variables +# Copy this to .env.local (gitignored) and customize for your setup + +# Enable tsx for TypeScript execution in Nx +# This allows running local generator/executor directly as .ts files without pre-compilation +# This allows the local plugins to import files with .js extensions (same as the packages in the repository) +NODE_OPTIONS=--import tsx +# This is used to resolve the paths in the local generator/executor so local packages can be imported as path aliases diff --git a/e2e/ci-e2e/mocks/fixtures/basic/tsconfig.base.json b/e2e/ci-e2e/mocks/fixtures/basic/tsconfig.base.json new file mode 100644 index 0000000000..63c63149b8 --- /dev/null +++ b/e2e/ci-e2e/mocks/fixtures/basic/tsconfig.base.json @@ -0,0 +1,24 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "rootDir": ".", + "sourceMap": true, + "strict": true, + "noUncheckedIndexedAccess": true, + "declaration": false, + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "importHelpers": false, + "target": "es2022", + "module": "esnext", + "lib": ["es2023", "dom"], + "skipLibCheck": true, + "skipDefaultLibCheck": true, + "baseUrl": ".", + "resolveJsonModule": true, + "allowSyntheticDefaultImports": true, + "verbatimModuleSyntax": true + }, + "exclude": ["node_modules", "tmp"] +} diff --git a/e2e/ci-e2e/mocks/fixtures/npm-workspaces/.env.local b/e2e/ci-e2e/mocks/fixtures/npm-workspaces/.env.local new file mode 100644 index 0000000000..568496dd57 --- /dev/null +++ b/e2e/ci-e2e/mocks/fixtures/npm-workspaces/.env.local @@ -0,0 +1,8 @@ +# Local development environment variables +# Copy this to .env.local (gitignored) and customize for your setup + +# Enable tsx for TypeScript execution in Nx +# This allows running local generator/executor directly as .ts files without pre-compilation +# This allowes the local plugins to import files with .js extensions (same as the packages in the repository) +NODE_OPTIONS=--import tsx +# This is used to resolve the paths in the local generator/executor so local packages can be imported as path aliases diff --git a/e2e/ci-e2e/mocks/fixtures/npm-workspaces/tsconfig.base.json b/e2e/ci-e2e/mocks/fixtures/npm-workspaces/tsconfig.base.json new file mode 100644 index 0000000000..63c63149b8 --- /dev/null +++ b/e2e/ci-e2e/mocks/fixtures/npm-workspaces/tsconfig.base.json @@ -0,0 +1,24 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "rootDir": ".", + "sourceMap": true, + "strict": true, + "noUncheckedIndexedAccess": true, + "declaration": false, + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "importHelpers": false, + "target": "es2022", + "module": "esnext", + "lib": ["es2023", "dom"], + "skipLibCheck": true, + "skipDefaultLibCheck": true, + "baseUrl": ".", + "resolveJsonModule": true, + "allowSyntheticDefaultImports": true, + "verbatimModuleSyntax": true + }, + "exclude": ["node_modules", "tmp"] +} diff --git a/e2e/ci-e2e/mocks/fixtures/nx-monorepo/.env.local b/e2e/ci-e2e/mocks/fixtures/nx-monorepo/.env.local new file mode 100644 index 0000000000..568496dd57 --- /dev/null +++ b/e2e/ci-e2e/mocks/fixtures/nx-monorepo/.env.local @@ -0,0 +1,8 @@ +# Local development environment variables +# Copy this to .env.local (gitignored) and customize for your setup + +# Enable tsx for TypeScript execution in Nx +# This allows running local generator/executor directly as .ts files without pre-compilation +# This allowes the local plugins to import files with .js extensions (same as the packages in the repository) +NODE_OPTIONS=--import tsx +# This is used to resolve the paths in the local generator/executor so local packages can be imported as path aliases diff --git a/e2e/ci-e2e/mocks/fixtures/nx-monorepo/tsconfig.base.json b/e2e/ci-e2e/mocks/fixtures/nx-monorepo/tsconfig.base.json new file mode 100644 index 0000000000..63c63149b8 --- /dev/null +++ b/e2e/ci-e2e/mocks/fixtures/nx-monorepo/tsconfig.base.json @@ -0,0 +1,24 @@ +{ + "compileOnSave": false, + "compilerOptions": { + "rootDir": ".", + "sourceMap": true, + "strict": true, + "noUncheckedIndexedAccess": true, + "declaration": false, + "moduleResolution": "node", + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "importHelpers": false, + "target": "es2022", + "module": "esnext", + "lib": ["es2023", "dom"], + "skipLibCheck": true, + "skipDefaultLibCheck": true, + "baseUrl": ".", + "resolveJsonModule": true, + "allowSyntheticDefaultImports": true, + "verbatimModuleSyntax": true + }, + "exclude": ["node_modules", "tmp"] +} diff --git a/nx.json b/nx.json index c77d9dff8c..53fdff630b 100644 --- a/nx.json +++ b/nx.json @@ -40,7 +40,12 @@ { "env": "NODE_OPTIONS" }, { "env": "TSX_TSCONFIG_PATH" } ], - "sharedGlobals": [{ "runtime": "node -v" }, { "runtime": "npm -v" }] + "sharedGlobals": [ + { "runtime": "node -v" }, + { "runtime": "npm -v" }, + { "env": "NODE_OPTIONS" }, + { "env": "TSX_TSCONFIG_PATH" } + ] }, "targetDefaults": { "lint": { diff --git a/package.json b/package.json index 52a48a7d47..bc8f121639 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "scripts": { "prepare": "husky install", "commit": "git-cz", - "knip": "knip" + "knip": "knip", + "nx": "NODE_OPTIONS='--import tsx' tsx --tsconfig=tsconfig.base.json ./node_modules/.bin/nx" }, "private": true, "dependencies": { diff --git a/tools/zod2md-jsdocs/src/lib/constants.ts b/tools/zod2md-jsdocs/src/lib/constants.ts new file mode 100644 index 0000000000..28992a1320 --- /dev/null +++ b/tools/zod2md-jsdocs/src/lib/constants.ts @@ -0,0 +1,2 @@ +export const ZOD2MD_CONFIG_FILE = 'zod2md.config.ts'; +export const GENERATE_DOCS_TARGET_NAME = 'generate-docs'; diff --git a/tools/zod2md-jsdocs/src/nx-plugin.ts b/tools/zod2md-jsdocs/src/nx-plugin.ts index 36cefc9836..ae8ff14ccc 100644 --- a/tools/zod2md-jsdocs/src/nx-plugin.ts +++ b/tools/zod2md-jsdocs/src/nx-plugin.ts @@ -1,8 +1,9 @@ import type { CreateNodesV2, NxPlugin, TargetConfiguration } from '@nx/devkit'; import * as path from 'node:path'; - -const ZOD2MD_CONFIG_FILE = 'zod2md.config.ts'; -const GENERATE_DOCS_TARGET_NAME = 'generate-docs'; +import { + GENERATE_DOCS_TARGET_NAME, + ZOD2MD_CONFIG_FILE, +} from './lib/constants.js'; type DocsTargetConfigParams = { config: string;