UNPKG

@nx-plugins/astro

Version:

The Nx Plugin for Astro that contains executors, generators, and utilities for managing Astro applications and libraries within an Nx workspace.

56 lines 2.76 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.filePathPrefix = exports.astroProjectSchematic = void 0; const tslib_1 = require("tslib"); const devkit_1 = require("@nrwl/devkit"); const generator_1 = require("../init/generator"); const create_project_1 = require("./lib/create-project"); const create_files_1 = require("./lib/create-files"); const linter_1 = require("@nrwl/linter"); const run_tasks_in_serial_1 = require("@nrwl/workspace/src/utilities/run-tasks-in-serial"); const add_linter_1 = require("./lib/add-linter"); const add_e2e_runner_1 = require("./lib/add-e2e-runner"); const add_unit_runner_1 = require("./lib/add-unit-runner"); const schemaDefaults = { standaloneConfig: true, skipFormat: false, skipPackageJson: false, js: false, e2eTestRunner: 'playwright-test', linter: linter_1.Linter.EsLint, setParserOptionsProject: false, unitTestRunner: 'vitest', }; function normalizeOptions(tree, options) { const { appsDir } = (0, devkit_1.getWorkspaceLayout)(tree); const projectName = filePathPrefix(options.directory ? `${options.directory}-${options.name}` : options.name); const projectRoot = options.directory ? (0, devkit_1.joinPathFragments)(appsDir, (0, devkit_1.names)(options.directory).fileName, options.name) : (0, devkit_1.joinPathFragments)(appsDir, options.name); return Object.assign(Object.assign(Object.assign({}, schemaDefaults), options), { projectName, projectRoot }); } function astroProjectGenerator(tree, schema) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const options = normalizeOptions(tree, schema); const installTask = (0, generator_1.default)(tree, { skipPackageJson: options.skipPackageJson, }); (0, create_project_1.createProject)(tree, options); (0, create_files_1.createFiles)(tree, options); const addE2e = yield (0, add_e2e_runner_1.addE2ERunner)(tree, options); const addLint = yield (0, add_linter_1.addLinter)(tree, options); const addTest = yield (0, add_unit_runner_1.addUnitTestRunner)(tree, options); if (!schema.skipFormat) { yield (0, devkit_1.formatFiles)(tree); } return (0, run_tasks_in_serial_1.runTasksInSerial)(installTask, addE2e, addLint, addTest); }); } exports.default = astroProjectGenerator; exports.astroProjectSchematic = (0, devkit_1.convertNxGenerator)(astroProjectGenerator); function filePathPrefix(directory) { return `${(0, devkit_1.names)(directory).fileName}`.replace(new RegExp('/', 'g'), '-'); } exports.filePathPrefix = filePathPrefix; //# sourceMappingURL=generator.js.map