diff --git a/CHANGELOG.md b/CHANGELOG.md index f51bc650..95758e75 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## 14.1.5 - 2024-10-18 + +### Added + +- Added static mock service worker js file mapping. #TINY-11415 + ## 14.1.4 - 2024-03-27 ### Fixed diff --git a/Jenkinsfile b/Jenkinsfile index a20104b4..b0fbdeca 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -21,19 +21,35 @@ timestamps { stage("test") { exec('yarn test') - - bedrockBrowsers( - prepareTests: { - yarnInstall() - exec('yarn build') - }, - testDirs: [ 'modules/sample/src/test/ts/**/pass' ], - custom: '--config modules/sample/tsconfig.json --customRoutes modules/sample/routes.json --polyfills Promise Symbol' - ) } + } + + // Testing + stage("bedrock testing") { + bedrockRemoteBrowsers( + platforms: [ + [ browser: 'chrome', provider: 'aws', buckets: 2 ], + [ browser: 'firefox', provider: 'aws', buckets: 2 ], + [ browser: 'edge', provider: 'lambdatest', buckets: 1 ], + [ browser: 'chrome', provider: 'lambdatest', os: 'macOS Sonoma', buckets: 1 ], + [ browser: 'firefox', provider: 'lambdatest', os: 'macOS Sonoma', buckets: 1 ], + [ browser: 'safari', provider: 'lambdatest', os: 'macOS Sonoma', buckets: 1 ], + ], + prepareTests: { + yarnInstall() + sh 'yarn build' + }, + testDirs: [ 'modules/sample/src/test/ts/**/pass' ], + custom: '--config modules/sample/tsconfig.json --customRoutes modules/sample/routes.json --polyfills Promise Symbol' + ) + } - if (isReleaseBranch()) { - stage("publish") { + // Publish + if (isReleaseBranch()) { + stage("publish") { + tinyPods.node() { + yarnInstall() + sh 'yarn build' tinyNpm.withNpmPublishCredentials { // We need to tell git to ignore the changes to .npmrc when publishing exec('git update-index --assume-unchanged .npmrc') diff --git a/modules/server/src/main/ts/bedrock/server/Routes.ts b/modules/server/src/main/ts/bedrock/server/Routes.ts index 61fe0f3c..0b8173fe 100644 --- a/modules/server/src/main/ts/bedrock/server/Routes.ts +++ b/modules/server/src/main/ts/bedrock/server/Routes.ts @@ -214,3 +214,26 @@ export const nodeResolve = (method: HTTPMethod, prefix: string, source: string): }; }; +export const nodeResolveFile = (method: HTTPMethod, url: string, projectDir: string, moduleName: string, subPath: string): Route => { + const go: RouteGoFunc = (request, response, done) => { + const failure = (status: number, data: string) => { + doResponse(request, response, status, 'text/plain', data); + done(); + }; + + try { + const moduleResolvedPath = require.resolve(path.join(moduleName, 'package.json'), { paths: [ projectDir ] }); + const router = createServer(path.dirname(moduleResolvedPath)); + request.url = '/' + subPath; + router(request, response, done); + } catch (e) { + failure(404, `Failed to resolve static node file for module path: ${moduleName}/${subPath}`); + } + }; + + return { + matches: [Matchers.methodMatch(method), Matchers.urlMatch(url)], + go + }; +}; + diff --git a/modules/server/src/main/ts/bedrock/server/RunnerRoutes.ts b/modules/server/src/main/ts/bedrock/server/RunnerRoutes.ts index 0d8c47d2..02628c03 100644 --- a/modules/server/src/main/ts/bedrock/server/RunnerRoutes.ts +++ b/modules/server/src/main/ts/bedrock/server/RunnerRoutes.ts @@ -101,6 +101,7 @@ export const generate = async (mode: string, projectdir: string, basedir: string Routes.routing('GET', '/lib/jquery', path.dirname(require.resolve('jquery'))), Routes.routing('GET', '/lib/core-js-bundle', path.dirname(require.resolve('core-js-bundle'))), Routes.routing('GET', '/css', path.join(basedir, 'src/resources/css')), + Routes.nodeResolveFile('GET', '/mockServiceWorker.js', projectdir, 'msw', 'lib/mockServiceWorker.js'), // test code Routes.asyncJs('GET', '/compiled/tests.js', (done) => {