UNPKG

@nxext/stencil

Version:

Nx plugin for stenciljs

60 lines 2.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.prepareConfigAndOutputargetPaths = prepareConfigAndOutputargetPaths; const tslib_1 = require("tslib"); const devkit_1 = require("@nx/devkit"); const fs_1 = require("fs"); const path_1 = require("path"); const e2e_testing_1 = require("./e2e-testing"); function copyOrCreatePackageJson(pathCollection) { const libPackageJson = { name: pathCollection.projectName, version: '0.0.0', main: './dist/index.cjs.js', module: './dist/index.js', es2015: './dist/esm/index.mjs', es2017: './dist/esm/index.mjs', types: './dist/types/index.d.ts', collection: './dist/collection/collection-manifest.json', 'collection:main': './dist/collection/index.js', unpkg: `./dist/${pathCollection.projectName}/${pathCollection.projectName}.js`, files: ['dist/', 'loader/'], }; if ((0, fs_1.existsSync)(pathCollection.pkgJson)) { if (pathCollection.projectRoot !== pathCollection.distDir) { (0, fs_1.copyFileSync)(pathCollection.pkgJson, (0, path_1.join)(pathCollection.distDir, (0, path_1.basename)(pathCollection.pkgJson))); } } else { (0, devkit_1.writeJsonFile)((0, devkit_1.joinPathFragments)(pathCollection.distDir, 'package.json'), libPackageJson); } } function prepareDistDirAndPkgJson(pathCollection) { if (!(0, fs_1.existsSync)(pathCollection.distDir)) { (0, fs_1.mkdirSync)(pathCollection.distDir, { recursive: true }); } copyOrCreatePackageJson(pathCollection); } /** * Bootstraps the stencil config for an executor run: ensures the dist * directory exists, scaffolds the publishable package.json inside it, * and (for e2e) stages a `package.e2e.json` at the project root. * * Output-target paths themselves are not rewritten. `initializeStencilConfig` * already overrides `config.rootDir` to the distDir, which redirects every * default output target — user-defined `dir`s are respected as-is. */ function prepareConfigAndOutputargetPaths(config, pathCollection) { return tslib_1.__awaiter(this, void 0, void 0, function* () { prepareDistDirAndPkgJson(pathCollection); if (config.flags.e2e) { (0, e2e_testing_1.prepareE2eTesting)(pathCollection); config.packageJsonFilePath = config.packageJsonFilePath.replace('package.json', 'package.e2e.json'); } else { config.packageJsonFilePath = config.packageJsonFilePath.replace(pathCollection.projectRoot, pathCollection.distDir); } return config; }); } //# sourceMappingURL=prepare-config-and-outputarget-paths.js.map