diff --git a/scripts/prepare-demo-for-publish.mjs b/scripts/prepare-demo-for-publish.mjs index 6de68f813f..d56aaace73 100644 --- a/scripts/prepare-demo-for-publish.mjs +++ b/scripts/prepare-demo-for-publish.mjs @@ -15,26 +15,26 @@ limitations under the License. */ import { readdirSync, writeFileSync, readFileSync, copyFileSync } from 'node:fs'; -import { join, extname } from 'node:path'; +import path from 'node:path'; -const updateAssetsLoadingFile = path => { - let content = readFileSync(path, 'utf8').toString(); +const updateAssetsLoadingFile = filePath => { + let content = readFileSync(filePath, 'utf8').toString(); content = content.replaceAll('"/dev/public/assets/', '"assets/'); - writeFileSync(path, content); + writeFileSync(filePath, content); // eslint-disable-next-line no-console - console.info('Content of page updated', path); + console.info('Content of page updated', filePath); }; const demoRootDirectory = './build/demo'; const htmlPagesPath = join(demoRootDirectory, 'dev/public'); const pages = readdirSync(htmlPagesPath); -for (const page of pages.filter(file => extname(file).toLowerCase() === '.html')) { +for (const page of pages.filter(file => path.extname(file).toLowerCase() === '.html')) { // eslint-disable-next-line no-console console.info('Managing', page); // change the path of the assets in the current html page - updateAssetsLoadingFile(join(htmlPagesPath, page)); + updateAssetsLoadingFile(path.join(htmlPagesPath, page)); } // copy ./index.html in build/demo directory, to reproduce the hierarchy on the examples' repo, on the demo preview in GitHub -copyFileSync('./index.html', join(demoRootDirectory, 'index.html')); +copyFileSync('./index.html', path.join(demoRootDirectory, 'index.html')); diff --git a/scripts/utils/parseBpmn.ts b/scripts/utils/parseBpmn.ts index 2a01948726..1716d82615 100644 --- a/scripts/utils/parseBpmn.ts +++ b/scripts/utils/parseBpmn.ts @@ -17,7 +17,7 @@ limitations under the License. import type BpmnModel from '../../src/model/bpmn/internal/BpmnModel'; import type { BpmnJsonModel } from '../../src/model/bpmn/json/bpmn20'; -import { resolve as resolvePath } from 'node:path'; +import path from 'node:path'; import clipboardy from 'clipboardy'; import parseArgs from 'minimist'; @@ -27,7 +27,7 @@ import { ParsingMessageCollector } from '../../src/component/parser/parsing-mess import BpmnXmlParser from '../../src/component/parser/xml/BpmnXmlParser'; import { readFileSync } from '../../test/shared/file-helper'; -const __dirname = resolvePath(); +const __dirname = path.resolve(); const argv = parseArgs(process.argv.slice(2)); const bpmnFilePath = argv._[0]; const outputType = argv.output || 'json'; diff --git a/test/bundles/bundles.test.ts b/test/bundles/bundles.test.ts index 6388709c4b..03c7710766 100644 --- a/test/bundles/bundles.test.ts +++ b/test/bundles/bundles.test.ts @@ -18,7 +18,7 @@ import 'jest-playwright-preset'; import type { TargetedPageConfiguration } from '@test/shared/visu/bpmn-page-utils'; import type { Page } from 'playwright'; -import { resolve } from 'node:path'; +import path from 'node:path'; import { BpmnPageSvgTester } from '@test/shared/visu/bpmn-page-utils'; @@ -53,7 +53,7 @@ class BpmnStaticPageSvgTester extends BpmnPageSvgTester { super({ ...targetedPageConfiguration, diagramSubfolder: 'none' }, page); } override async gotoPageAndLoadBpmnDiagram(): Promise { - const url = `file://${resolve(__dirname, `static/${this.targetedPageConfiguration.targetedPage.pageFileName}.html`)}`; + const url = `file://${path.resolve(__dirname, `static/${this.targetedPageConfiguration.targetedPage.pageFileName}.html`)}`; await super.doGotoPageAndLoadBpmnDiagram(url, false); } } diff --git a/test/e2e/diagram.navigation.fit.test.ts b/test/e2e/diagram.navigation.fit.test.ts index 84f9e075ab..1a5392f760 100644 --- a/test/e2e/diagram.navigation.fit.test.ts +++ b/test/e2e/diagram.navigation.fit.test.ts @@ -17,7 +17,7 @@ limitations under the License. import type { ImageSnapshotThresholdConfig } from './helpers/visu/image-snapshot-config'; import type { MatchImageSnapshotOptions } from 'jest-image-snapshot'; -import { join } from 'node:path'; +import path from 'node:path'; import 'jest-playwright-preset'; @@ -41,23 +41,23 @@ class FitImageSnapshotConfigurator extends ImageSnapshotConfigurator { } private static buildSnapshotFitDirectory(parentDirectory: string, fitType: FitType, withMargin = false, margin?: number): string { - const rootFitDirectory = join(parentDirectory, `type-${fitType}`); + const rootFitDirectory = path.join(parentDirectory, `type-${fitType}`); if (!withMargin) { return rootFitDirectory; } - return join(rootFitDirectory, `margin-${margin == null || margin < 0 ? 0 : margin}`); + return path.join(rootFitDirectory, `margin-${margin == null || margin < 0 ? 0 : margin}`); } static buildOnLoadDiffDirectory(config: MatchImageSnapshotOptions, fitType: FitType, withMargin = false, margin?: number): string { - const onLoadDirectory = join(config.customDiffDir, 'on-load'); + const onLoadDirectory = path.join(config.customDiffDir, 'on-load'); return FitImageSnapshotConfigurator.buildSnapshotFitDirectory(onLoadDirectory, fitType, withMargin, margin); } static buildAfterLoadDiffDirectory(config: MatchImageSnapshotOptions, afterLoadFitType: FitType, onLoadFitType: FitType): string { - const afterLoadDirectory = join(config.customDiffDir, 'after-load'); + const afterLoadDirectory = path.join(config.customDiffDir, 'after-load'); const snapshotFitDirectory = FitImageSnapshotConfigurator.buildSnapshotFitDirectory(afterLoadDirectory, afterLoadFitType); - return join(snapshotFitDirectory, `on-load_type-${onLoadFitType}`); + return path.join(snapshotFitDirectory, `on-load_type-${onLoadFitType}`); } } diff --git a/test/e2e/diagram.navigation.zoom.pan.test.ts b/test/e2e/diagram.navigation.zoom.pan.test.ts index e18d4f4aa1..63c88b7497 100644 --- a/test/e2e/diagram.navigation.zoom.pan.test.ts +++ b/test/e2e/diagram.navigation.zoom.pan.test.ts @@ -17,7 +17,7 @@ limitations under the License. import type { ImageSnapshotThresholdConfig } from './helpers/visu/image-snapshot-config'; import type { Point } from '@test/shared/visu/bpmn-page-utils'; -import { join } from 'node:path'; +import path from 'node:path'; import debugLogger from 'debug'; import 'jest-playwright-preset'; @@ -122,7 +122,7 @@ describe('diagram navigation - zoom and pan with mouse', () => { expect(image).toMatchImageSnapshot({ ...config, customSnapshotIdentifier: 'initial.zoom', - customDiffDir: join(config.customDiffDir, `mouse-zoom-in-out-${xTimes}-times`), + customDiffDir: path.join(config.customDiffDir, `mouse-zoom-in-out-${xTimes}-times`), }); }); }); @@ -166,7 +166,7 @@ describe('diagram navigation - zoom with buttons', () => { expect(image).toMatchImageSnapshot({ ...config, customSnapshotIdentifier: 'initial.zoom', - customDiffDir: join(config.customDiffDir, `button-zoom-in-out-${xTimes}-times`), + customDiffDir: path.join(config.customDiffDir, `button-zoom-in-out-${xTimes}-times`), }); }); }); @@ -208,7 +208,7 @@ describe('diagram navigation - zoom with buttons and mouse', () => { expect(image).toMatchImageSnapshot({ ...config, customSnapshotIdentifier: 'initial.zoom', - customDiffDir: join(config.customDiffDir, `zoom-button-then-mouse-${firstZoom}-then-${secondZoom}`), + customDiffDir: path.join(config.customDiffDir, `zoom-button-then-mouse-${firstZoom}-then-${secondZoom}`), }); }); @@ -225,7 +225,7 @@ describe('diagram navigation - zoom with buttons and mouse', () => { expect(image).toMatchImageSnapshot({ ...config, customSnapshotIdentifier: 'initial.zoom', - customDiffDir: join(config.customDiffDir, `zoom-mouse-then-button-${firstZoom}-then-${secondZoom}`), + customDiffDir: path.join(config.customDiffDir, `zoom-mouse-then-button-${firstZoom}-then-${secondZoom}`), }); }); }); diff --git a/test/e2e/helpers/visu/image-snapshot-config.ts b/test/e2e/helpers/visu/image-snapshot-config.ts index 9b72627882..cf3b5b6253 100644 --- a/test/e2e/helpers/visu/image-snapshot-config.ts +++ b/test/e2e/helpers/visu/image-snapshot-config.ts @@ -16,7 +16,7 @@ limitations under the License. import type { MatchImageSnapshotOptions } from 'jest-image-snapshot'; -import { dirname, join } from 'node:path'; +import path from 'node:path'; import { configLog, getSimplePlatformName, getTestedBrowserFamily } from '@test/shared/visu/test-utils'; @@ -47,8 +47,8 @@ export class ImageSnapshotConfigurator { constructor(imageSnapshotThresholds: MultiBrowserImageSnapshotThresholds, snapshotsSubDirectoryName: string) { this.thresholdConfig = imageSnapshotThresholds.getThresholds(); this.defaultFailureThreshold = imageSnapshotThresholds.getDefault(); - this.defaultCustomDiffDir = join(ImageSnapshotConfigurator.getDiffDirectory(), snapshotsSubDirectoryName); - this.defaultCustomSnapshotsDir = join(ImageSnapshotConfigurator.getSnapshotsDirectory(), snapshotsSubDirectoryName); + this.defaultCustomDiffDir = path.join(ImageSnapshotConfigurator.getDiffDirectory(), snapshotsSubDirectoryName); + this.defaultCustomSnapshotsDir = path.join(ImageSnapshotConfigurator.getSnapshotsDirectory(), snapshotsSubDirectoryName); } getConfig(parameter: string | { fileName: string }): MatchImageSnapshotOptions { @@ -83,13 +83,13 @@ export class ImageSnapshotConfigurator { } static getSnapshotsDirectory(): string { - return join(dirname(expect.getState().testPath), '__image_snapshots__'); + return path.join(path.dirname(expect.getState().testPath), '__image_snapshots__'); } static getDiffDirectory(): string { - const testDirectoryName = dirname(expect.getState().testPath); + const testDirectoryName = path.dirname(expect.getState().testPath); // directory is relative to $ROOT/test/e2e - return join(testDirectoryName, '../../build/test-report/e2e/__diff_output__'); + return path.join(testDirectoryName, '../../build/test-report/e2e/__diff_output__'); } } diff --git a/test/e2e/overlays.rendering.test.ts b/test/e2e/overlays.rendering.test.ts index bcc5a247e3..f6a753998c 100644 --- a/test/e2e/overlays.rendering.test.ts +++ b/test/e2e/overlays.rendering.test.ts @@ -19,7 +19,7 @@ import type { ImageSnapshotThresholdConfig } from './helpers/visu/image-snapshot import type { OverlayEdgePosition, OverlayPosition, OverlayShapePosition } from '@lib/component/registry'; import type { Point } from '@test/shared/visu/bpmn-page-utils'; -import { join } from 'node:path'; +import path from 'node:path'; import debugLogger from 'debug'; @@ -125,15 +125,15 @@ class OverlaysPageTester extends PageTester { const pageTester = new OverlaysPageTester({ targetedPage: AvailableTestPages.OVERLAYS, diagramSubfolder: 'overlays' }, page); function getEdgeDirectory(directory: string): string { - return join(directory, `on.edge`); + return path.join(directory, `on.edge`); } function getEdgePositionDirectory(directory: string, position: OverlayEdgePosition): string { - return join(getEdgeDirectory(directory), `on-position-${position}`); + return path.join(getEdgeDirectory(directory), `on-position-${position}`); } function getShapeDirectory(directory: string): string { - return join(directory, `on.shape`); + return path.join(directory, `on.shape`); } describe('BPMN Shapes with overlays', () => { @@ -365,8 +365,8 @@ describe('Overlay style', () => { expect(image).toMatchImageSnapshot({ ...config, customSnapshotIdentifier: `add.overlay.with.custom.${style}`, - customSnapshotsDir: join(config.customSnapshotsDir, snapshotPath), - customDiffDir: join(config.customDiffDir, snapshotPath), + customSnapshotsDir: path.join(config.customSnapshotsDir, snapshotPath), + customDiffDir: path.join(config.customDiffDir, snapshotPath), }); }); }); diff --git a/test/shared/file-helper.ts b/test/shared/file-helper.ts index 008c475502..fcab8be7e8 100644 --- a/test/shared/file-helper.ts +++ b/test/shared/file-helper.ts @@ -15,13 +15,13 @@ limitations under the License. */ import { readdirSync, readFileSync as fsReadFileSync } from 'node:fs'; -import { join } from 'node:path'; +import path from 'node:path'; export function readFileSync(relativePathToSourceFile: string, encoding: BufferEncoding = 'utf8', directoryName = __dirname): string { - return fsReadFileSync(join(directoryName, relativePathToSourceFile), { encoding }); + return fsReadFileSync(path.join(directoryName, relativePathToSourceFile), { encoding }); } /** Returns the files in the given directory. The function doesn't do any recursion in sub directories. */ export function findFiles(relativePathToSourceDirectory: string): string[] { - return readdirSync(join(__dirname, relativePathToSourceDirectory)); + return readdirSync(path.join(__dirname, relativePathToSourceDirectory)); } diff --git a/test/shared/visu/test-utils.ts b/test/shared/visu/test-utils.ts index 2c5f65c207..d3b7f897b6 100644 --- a/test/shared/visu/test-utils.ts +++ b/test/shared/visu/test-utils.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { join } from 'node:path'; +import path from 'node:path'; import debugLogger from 'debug'; import 'jest-playwright-preset'; @@ -49,7 +49,7 @@ export function delay(time: number): Promise { } export function getBpmnDiagramNames(directoryName: string): string[] { - return findFiles(join('../fixtures/bpmn/', directoryName)) + return findFiles(path.join('../fixtures/bpmn/', directoryName)) .filter(filename => filename.endsWith('.bpmn')) .map(filename => filename.split('.').slice(0, -1).join('.')); } diff --git a/vite.config.js b/vite.config.js index 0a515e2902..54f03f77b6 100644 --- a/vite.config.js +++ b/vite.config.js @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -import { resolve } from 'node:path'; +import path from 'node:path'; import { defineConfig } from 'vite'; @@ -33,8 +33,8 @@ export default defineConfig(({ mode }) => { assetsDir: 'build/demo/dev/public/assets', rollupOptions: { input: { - index: resolve(__dirname, 'dev/public/index.html'), - 'elements-identification': resolve(__dirname, 'dev/public/elements-identification.html'), + index: path.resolve(__dirname, 'dev/public/index.html'), + 'elements-identification': path.resolve(__dirname, 'dev/public/elements-identification.html'), }, // No hash in asset names. We make the demo publicly available via the examples repository and served by statically.io // New versions are accessed using tags. The master branch is cached by statically.io and updated once a day.