Skip to content

Commit b3c40ca

Browse files
committed
fix: resolve path issues in workspace-plugins executors
- Fix lerna.json path resolution in build executors using workspaceRoot - Fix package.json path resolution in build executor - Update build script to ensure workspace-plugins is built before other targets - Resolves 'Cannot find module lerna.json' errors in CI builds - All build targets now work: sync-entry, build, visual-stories [ci visual]
1 parent e9bdbd0 commit b3c40ca

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"packageManager": "yarn@4.10.3",
1010
"scripts": {
1111
"transform-stories": "ts-node stories-transformer.ts",
12-
"build": "npx nx run-many --target=build --all",
12+
"build": "npx nx build workspace-plugins && npx nx run-many --target=build --all",
1313
"build:prod": "yarn run build --configuration=production --skip-nx-cache",
1414
"build:theming-preview": "npx nx run theming-preview:build",
1515
"build:visual-stories": "nx run-many --target=build-visual --all",

packages/workspace-plugins/src/executors/build-theming-preview/executor.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import { BuildThemingPreviewExecutorSchema } from './schema';
22
import fs from 'fs-extra';
33
import { execSync } from 'child_process';
44
import { processWithPostCss } from '../shared/postcss';
5-
import { ExecutorContext, logger, readJsonFile, writeJsonFile } from '@nx/devkit';
5+
import { ExecutorContext, logger, readJsonFile, writeJsonFile, workspaceRoot } from '@nx/devkit';
66

77
import { readFileSync } from 'fs';
8+
import path from 'path';
89

9-
const lernaJson = JSON.parse(readFileSync('lerna.json', 'utf-8'));
10+
const lernaJson = JSON.parse(readFileSync(path.resolve(workspaceRoot, 'lerna.json'), 'utf-8'));
1011
const { copySync } = fs;
1112

1213
export default async function runExecutor(options: BuildThemingPreviewExecutorSchema, context: Required<ExecutorContext>) {

packages/workspace-plugins/src/executors/build/executor.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,15 @@ import { processWithPostCss } from '../shared/postcss';
88
import { mkdirpSync } from 'fs-extra';
99
import { parse } from 'path';
1010
import { parse as semverParse } from 'semver';
11+
import path from 'path';
12+
import { workspaceRoot } from '@nx/devkit';
1113

1214
const aboveMinorVersion = (version: string) => {
1315
const parsed = semverParse(version);
1416
return `^${parsed!.major}.${parsed!.minor}.0`;
1517
};
16-
const lernaJson = JSON.parse(readFileSync('lerna.json', 'utf-8'));
17-
const packageJson = JSON.parse(readFileSync('package.json', 'utf-8'));
18+
const lernaJson = JSON.parse(readFileSync(path.resolve(workspaceRoot, 'lerna.json'), 'utf-8'));
19+
const packageJson = JSON.parse(readFileSync(path.resolve(workspaceRoot, 'package.json'), 'utf-8'));
1820
const versions = {
1921
VERSION_PLACEHOLDER: lernaJson.version,
2022
SAP_THEMING_VERSION: aboveMinorVersion(packageJson.devDependencies['@sap-theming/theming-base-content'])

packages/workspace-plugins/src/executors/shared/postcss.plugins.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import postcssCleaner from './postcss-cleaner';
22
import postcssRemoveFonts from './postcss-remove-fonts';
3+
import path from 'path';
4+
import { workspaceRoot } from '@nx/devkit';
35

46
const autoprefixer = require('autoprefixer');
57
const postcssBanner = require('postcss-banner');
68
const postcssNormalizeCharset = require('postcss-normalize-charset');
79
const postcssImport = require('postcss-import');
8-
const packageVersion = require('../../../../../lerna.json').version;
10+
const packageVersion = require(path.resolve(workspaceRoot, 'lerna.json')).version;
911
const year = new Date().getFullYear();
1012
const cssnano = require('cssnano');
1113

0 commit comments

Comments
 (0)