* Copies frame.html to output folder, replaces js references to minified * copies, and generates symlink to it. * * @param {string} input * @param {string} outputName * @param {!Object} options * @return {!Promise}
(input, outputName, options)
| 649 | * @return {!Promise} |
| 650 | */ |
| 651 | async function thirdPartyBootstrap(input, outputName, options) { |
| 652 | const {fortesting, minify} = options; |
| 653 | const destDir = `dist.3p/${minify ? internalRuntimeVersion : 'current'}`; |
| 654 | await fs.ensureDir(destDir); |
| 655 | |
| 656 | if (!minify) { |
| 657 | await fs.copy(input, `${destDir}/${path.basename(input)}`); |
| 658 | return; |
| 659 | } |
| 660 | |
| 661 | // By default we use an absolute URL, that is independent of the |
| 662 | // actual frame host for the JS inside the frame. |
| 663 | // But during testing we need a relative reference because the |
| 664 | // version is not available on the absolute path. |
| 665 | const integrationJs = fortesting |
| 666 | ? './f.js' |
| 667 | : `https://${hostname3p}/${internalRuntimeVersion}/f.js`; |
| 668 | // Convert default relative URL to absolute min URL. |
| 669 | const html = fs |
| 670 | .readFileSync(input, 'utf8') |
| 671 | .replace(/\.\/integration\.js/g, integrationJs); |
| 672 | await fs.writeFile(`${destDir}/${outputName}`, html); |
| 673 | const aliasToLatestBuild = 'dist.3p/current-min'; |
| 674 | if (fs.existsSync(aliasToLatestBuild)) { |
| 675 | fs.unlinkSync(aliasToLatestBuild); |
| 676 | } |
| 677 | fs.symlinkSync('./' + internalRuntimeVersion, aliasToLatestBuild, 'dir'); |
| 678 | } |
| 679 | |
| 680 | /** |
| 681 | * Returns the list of dependencies for a given JS entrypoint by having esbuild |
no test coverage detected