UNPKG

@nxext/stencil

Version:

Nx plugin for stenciljs

82 lines 3.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.initializeStencilConfig = void 0; const tslib_1 = require("tslib"); const node_1 = require("@stencil/core/sys/node"); const compiler_1 = require("@stencil/core/compiler"); const path_1 = require("path"); const fileutils_1 = require("@nrwl/workspace/src/utilities/fileutils"); const normalize_path_1 = require("../../utils/normalize-path"); const utillities_1 = require("../../utils/utillities"); function getCompilerExecutingPath() { return require.resolve('@stencil/core/compiler'); } function initializeStencilConfig(taskCommand, options, context, flags, dependencies = []) { return (0, tslib_1.__awaiter)(this, void 0, void 0, function* () { const logger = (0, node_1.createNodeLogger)({ process }); const sys = (0, node_1.createNodeSys)({ process }); if (sys.getCompilerExecutingPath == null) { sys.getCompilerExecutingPath = getCompilerExecutingPath; } if (flags.ci) { logger.enableColors(false); } const projectDir = context.workspace.projects[context.projectName].root; const projectRoot = (0, normalize_path_1.normalizePath)((0, path_1.join)(context.root, projectDir)); const distDir = (0, normalize_path_1.normalizePath)((0, path_1.join)(context.root, options.outputPath)); const configPath = (0, normalize_path_1.normalizePath)((0, path_1.join)(context.root, options.configPath)); let config = { flags }; if (options.tsConfig) { const tsconfig = (0, path_1.join)(context.root, options.tsConfig); config = Object.assign(Object.assign({}, config), { tsconfig: tsconfig }); } const loadConfigResults = yield (0, compiler_1.loadConfig)({ config, configPath, logger, sys }); const loadedConfig = loadConfigResults.config; if (loadedConfig.flags.task === 'build') { loadedConfig.rootDir = distDir; loadedConfig.packageJsonFilePath = (0, normalize_path_1.normalizePath)((0, path_1.join)(distDir, 'package.json')); } dependencies = dependencies .filter(dep => dep.node.type == 'lib') .map(dep => { const pkgJsonPath = `${dep.outputs[0]}/package.json`; if ((0, fileutils_1.fileExists)(pkgJsonPath)) { const pkgJson = (0, fileutils_1.readJsonFile)(pkgJsonPath); return { name: pkgJson.name, version: pkgJson.name, main: pkgJson.main }; } }); yield sys.ensureResources({ rootDir: loadedConfig.rootDir, logger, dependencies: dependencies }); const ensureDepsResults = yield sys.ensureDependencies({ rootDir: loadedConfig.rootDir, logger, dependencies: dependencies, }); logger.printDiagnostics(ensureDepsResults.diagnostics); if ((0, utillities_1.hasError)(ensureDepsResults.diagnostics)) { logger.printDiagnostics(ensureDepsResults.diagnostics); yield sys.exit(1); } return { pathCollection: { projectName: context.projectName, projectRoot: projectRoot, distDir: distDir, pkgJson: (0, path_1.join)(projectRoot, 'package.json') }, config: loadedConfig }; }); } exports.initializeStencilConfig = initializeStencilConfig; //# sourceMappingURL=stencil-config.js.map