UNPKG

@jnxplus/nx-maven

Version:

[![npm version](https://badge.fury.io/js/@jnxplus%2Fnx-maven.svg)](https://badge.fury.io/js/@jnxplus%2Fnx-maven)

44 lines 1.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = default_1; const tslib_1 = require("tslib"); const devkit_1 = require("@nx/devkit"); const path = require("path"); const utils_1 = require("../../utils"); function normalizeOptions(tree, options) { const dot = '.'; const mavenRootDirectory = (0, utils_1.getMavenRootDirectory)(); return Object.assign(Object.assign({}, options), { dot, mavenRootDirectory }); } function addFiles(tree, options) { const templateOptions = Object.assign(Object.assign({}, options), { offsetFromRoot: (0, devkit_1.offsetFromRoot)(tree.root), template: '' }); (0, devkit_1.generateFiles)(tree, path.join(__dirname, '..', 'init', 'files', 'maven', 'wrapper'), options.mavenRootDirectory, templateOptions); } function default_1(tree, options) { return tslib_1.__awaiter(this, void 0, void 0, function* () { const normalizedOptions = normalizeOptions(tree, options); addFiles(tree, normalizedOptions); if (!options.skipGitignore) { updateGitIgnore(tree); } tree.changePermissions((0, devkit_1.joinPathFragments)(normalizedOptions.mavenRootDirectory, 'mvnw'), '755'); tree.changePermissions((0, devkit_1.joinPathFragments)(normalizedOptions.mavenRootDirectory, 'mvnw.cmd'), '755'); if (!options.skipFormat) { yield (0, devkit_1.formatFiles)(tree); } }); } function updateGitIgnore(tree) { const filePath = '.gitignore'; const contents = tree.read(filePath, 'utf-8') || ''; let mavenIgnore = ''; const mavenIgnore1 = '\n\n# Maven Wrapper'; const mavenIgnore2 = '\n.mvn/'; const mavenIgnore3 = '\nmvnw'; const mavenIgnore4 = '\nmvnw.cmd'; mavenIgnore = mavenIgnore1 + mavenIgnore2 + mavenIgnore3 + mavenIgnore4; const newContents = contents.concat(mavenIgnore); tree.write(filePath, newContents); } //# sourceMappingURL=generator.js.map