From d184326054688a1447e4115fa5f39d650eb54327 Mon Sep 17 00:00:00 2001 From: Sreekanth Narayanan Date: Sat, 31 Aug 2024 17:48:21 +0530 Subject: [PATCH] fix(tooling): fix tooling to build and test in windows --- .../tools/src/models/package/package.ts | 40 +++++++++++++++---- packages/legacy/tools/src/utils/jest/jest.ts | 1 + 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/packages/legacy/tools/src/models/package/package.ts b/packages/legacy/tools/src/models/package/package.ts index c336e4e0ed0..19bdb6cdbf6 100644 --- a/packages/legacy/tools/src/models/package/package.ts +++ b/packages/legacy/tools/src/models/package/package.ts @@ -61,6 +61,8 @@ class Package { const inputPath = path.join(this.data.packageRoot, source); + console.log('sreenara package.build', inputPath); + const javascriptFileCollector = javascript ? Package.getFiles({ location: inputPath, pattern: CONSTANTS.PATTERNS.JAVASCRIPT, targets: undefined }) : Promise.resolve([]); @@ -73,6 +75,8 @@ class Package { .then(([javascriptFiles, typescriptFiles]) => { const sourceFiles = [...javascriptFiles, ...typescriptFiles]; + console.log('sreenara package.build', sourceFiles); + const files = sourceFiles.map((file) => new PackageFile({ directory: source, location: file.replace(inputPath, ''), @@ -97,25 +101,44 @@ class Package { * @param config - Test configuration Object. * @returns - Promise resolving to this Package instance. */ - public test(config: TestConfig): Promise { + public async test(config: TestConfig): Promise { const testDirectory = path.join(this.data.packageRoot, CONSTANTS.TEST_DIRECTORIES.ROOT); - const unitTestFileCollector = config.unit - ? Package.getFiles({ + console.log( + 'sreenara test config, pattern, location', + config, + CONSTANTS.PATTERNS.TEST, + path.join(testDirectory, CONSTANTS.TEST_DIRECTORIES.UNIT), + ); + let unitTestFileCollector = config.unit + ? await Package.getFiles({ location: path.join(testDirectory, CONSTANTS.TEST_DIRECTORIES.UNIT), pattern: CONSTANTS.PATTERNS.TEST, targets: config.targets, }) : Promise.resolve([]); - const integrationTestFileCollector = config.integration - ? Package.getFiles({ + console.log('sreenara unitTestFileCollector before changes', unitTestFileCollector); + unitTestFileCollector = (unitTestFileCollector as unknown as string[]).map((filename) => { + const newFile = filename.replace(/\\/g, '/'); + console.log('new filename', newFile); + return newFile; + }); + console.log('sreenara unitTestFileCollector after changes', unitTestFileCollector); + let integrationTestFileCollector = config.integration + ? await Package.getFiles({ location: path.join(testDirectory, CONSTANTS.TEST_DIRECTORIES.INTEGRATION), pattern: CONSTANTS.PATTERNS.TEST, targets: config.targets, }) : Promise.resolve([]); + integrationTestFileCollector = (integrationTestFileCollector as unknown as string[]).map((filename) => { + const newFile = filename.replace(/\\/g, '/'); + console.log('new filename', newFile); + return newFile; + }); + return Promise.all([unitTestFileCollector, integrationTestFileCollector]) .then(async ([unitFiles, integrationFiles]) => { if (config.runner === 'jest') { @@ -159,13 +182,16 @@ class Package { */ protected static getFiles({ location, pattern, targets }: { location: string, pattern: string, targets: string | undefined }): Promise> { + console.log('sreenara package.getFiles()', location, pattern, targets); let target; if (!targets) { - target = path.join(location, pattern); + // target = path.posix.join(location, pattern); + target = path.join(location, pattern).replace(/\\/g, '/'); } else { - target = path.join(location, targets); + target = path.join(location, targets).replace(/\\/g, '/'); } + console.log('sreenara package.getFiles() target', target); return glob.glob(target); } diff --git a/packages/legacy/tools/src/utils/jest/jest.ts b/packages/legacy/tools/src/utils/jest/jest.ts index 195261167f1..e9518c6e61c 100644 --- a/packages/legacy/tools/src/utils/jest/jest.ts +++ b/packages/legacy/tools/src/utils/jest/jest.ts @@ -13,6 +13,7 @@ class Jest { * @returns - Empty Promise. */ public static test({ files }: { files: Array }): Promise { + console.log('sreenara running jest.test files', files); return Jest.wrapper.run(files); }