UNPKG

@nxext/stencil

Version:

Nx plugin for stenciljs

49 lines 2.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.hasError = void 0; exports.calculateStyle = calculateStyle; exports.isBuildableStencilProject = isBuildableStencilProject; exports.readNxVersion = readNxVersion; const devkit_1 = require("@nx/devkit"); const stencil_core_utils_1 = require("../stencil-core-utils"); function calculateStyle(style) { const styleDefault = stencil_core_utils_1.SupportedStyles.css; if (style == undefined) { return styleDefault; } return /^(css|scss)$/.test(style) ? style : styleDefault; } function isBuildableStencilProject(project, tree) { // Back-compat: workspaces that still ship an explicit // `@nxext/stencil:build` target in project.json. const target = project.targets && project.targets['build'] ? project.targets['build'] : {}; if (target && target.executor === `@nxext/stencil:build`) { return true; } // Crystal path: only buildable libs get a `package.json` at the project // root (written by `make-lib-buildable` / the library generator when // `buildable: true`). Non-buildable libs ship a `stencil.config.ts` too, // but strictly for component authoring — they aren't shippable. if (tree && tree.exists(`${project.root}/package.json`)) { return true; } return false; } const hasError = (diagnostics) => { if (diagnostics == null || diagnostics.length === 0) { return false; } return diagnostics.some((d) => d.level === 'error' && d.type !== 'runtime'); }; exports.hasError = hasError; function readNxVersion(host) { const packageJson = (0, devkit_1.readJson)(host, 'package.json'); const nxVersion = packageJson.devDependencies['@nx/workspace'] ? packageJson.devDependencies['@nx/workspace'] : packageJson.dependencies['@nx/workspace']; if (!nxVersion) { throw new Error('@nx/workspace is not a dependency.'); } return nxVersion; } //# sourceMappingURL=utillities.js.map