From 518e734f10f5265f5317a92ddb2774b376fb2dce Mon Sep 17 00:00:00 2001 From: Michael Date: Thu, 11 Apr 2024 19:31:37 +0200 Subject: [PATCH] fix(nx-plugin): build for CommonJS to use generators --- .../src/generators/configuration/generator.ts | 10 ++-------- packages/nx-plugin/src/generators/init/generator.ts | 10 +++++----- packages/nx-plugin/tsconfig.json | 2 +- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/packages/nx-plugin/src/generators/configuration/generator.ts b/packages/nx-plugin/src/generators/configuration/generator.ts index ca99324ee..068bfcd90 100644 --- a/packages/nx-plugin/src/generators/configuration/generator.ts +++ b/packages/nx-plugin/src/generators/configuration/generator.ts @@ -5,8 +5,7 @@ import { readProjectConfiguration, updateProjectConfiguration, } from '@nx/devkit'; -import { dirname, join } from 'node:path'; -import { fileURLToPath } from 'node:url'; +import { join } from 'node:path'; import { ui } from '@code-pushup/utils'; import { AddToProjectGeneratorSchema } from './schema'; @@ -23,12 +22,7 @@ export async function addToProjectGenerator( return; } - generateFiles( - tree, - join(fileURLToPath(dirname(import.meta.url)), 'files'), - root, - options, - ); + generateFiles(tree, join(__dirname, 'files'), root, options); updateProjectConfiguration(tree, options.project, { ...projectConfiguration, diff --git a/packages/nx-plugin/src/generators/init/generator.ts b/packages/nx-plugin/src/generators/init/generator.ts index 36f4bb0bc..82c81f63d 100644 --- a/packages/nx-plugin/src/generators/init/generator.ts +++ b/packages/nx-plugin/src/generators/init/generator.ts @@ -16,7 +16,7 @@ import { cpModelVersion, cpNxPluginVersion, cpUtilsVersion, -} from '../../utils/versions'; +} from '../versions'; import { InitGeneratorSchema } from './schema'; const nxPluginPackageName = '@code-pushup/nx-plugin'; @@ -29,10 +29,10 @@ function checkDependenciesInstalled(host: Tree) { packageJson.devDependencies = packageJson.devDependencies ?? {}; // base deps - devDependencies[nxPluginPackageName] = cpNxPluginVersion; - devDependencies['@code-pushup/models'] = cpModelVersion; - devDependencies['@code-pushup/utils'] = cpUtilsVersion; - devDependencies['@code-pushup/cli'] = cpCliVersion; + devDependencies[nxPluginPackageName] = cpNxPluginVersion(); + devDependencies['@code-pushup/models'] = cpModelVersion(); + devDependencies['@code-pushup/utils'] = cpUtilsVersion(); + devDependencies['@code-pushup/cli'] = cpCliVersion(); return addDependenciesToPackageJson(host, dependencies, devDependencies); } diff --git a/packages/nx-plugin/tsconfig.json b/packages/nx-plugin/tsconfig.json index 088e7dc47..a43ef3119 100644 --- a/packages/nx-plugin/tsconfig.json +++ b/packages/nx-plugin/tsconfig.json @@ -1,7 +1,7 @@ { "extends": "../../tsconfig.base.json", "compilerOptions": { - "module": "ESNext" + "module": "CommonJS" }, "files": [], "include": [],