@nxrocks/nx-quarkus
Version:
Nx Plugin to generate, run, package, build (and more) Quarkus projects inside your Nx workspace
52 lines • 2.79 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.generateQuarkusProject = generateQuarkusProject;
const devkit_1 = require("@nx/devkit");
const node_fetch_1 = require("node-fetch");
const quarkus_utils_1 = require("../../../utils/quarkus-utils");
const index_1 = require("../../../index");
const common_jvm_1 = require("@nxrocks/common-jvm");
async function generateQuarkusProject(tree, options) {
const downloadUrl = (0, quarkus_utils_1.buildQuarkusDownloadUrl)(options);
devkit_1.logger.info(`⬇️ Downloading Quarkus project zip from : ${downloadUrl}...`);
const response = await (0, node_fetch_1.default)(downloadUrl, (0, common_jvm_1.getCommonHttpHeaders)(index_1.NX_QUARKUS_PKG, downloadUrl, options.proxyUrl));
devkit_1.logger.info(`📦 Extracting Quarkus project zip to '${(0, devkit_1.joinPathFragments)(devkit_1.workspaceRoot, options.projectRoot)}'...`);
if (response.ok) {
await (0, common_jvm_1.extractFromZipStream)(response.body, (entryPath, entryContent) => {
const filePath = entryPath.replace(`${options.artifactId}/`, ''); // remove the inner folder in the zip
const execPermission = filePath.endsWith('mvnw') || filePath.endsWith('gradlew')
? '755'
: undefined;
if ((0, common_jvm_1.getMavenWrapperFiles)().includes(filePath) ||
(0, common_jvm_1.getGradleWrapperFiles)().includes(filePath)) {
if (options.transformIntoMultiModule) {
tree.write(`${options.moduleRoot}/${filePath}`, entryContent, {
mode: execPermission,
});
}
if (options.keepProjectLevelWrapper) {
tree.write(`${options.projectRoot}/${filePath}`, entryContent, {
mode: execPermission,
});
}
}
else {
tree.write(`${options.projectRoot}/${filePath}`, entryContent, {
mode: execPermission,
});
}
});
}
else {
throw new Error((0, devkit_1.stripIndents) `
❌ Error downloading Quarkus project zip from '${options.quarkusInitializerUrl}'
If the problem persists, please open an issue at https://github.com/tinesoft/nxrocks/issues, with the following information:
------------------------------------------------------
Download URL: ${downloadUrl}
Response status: ${response.status}
Response headers: ${JSON.stringify(response.headers)}
Response body: ${await response.text()}
------------------------------------------------------`);
}
}
//# sourceMappingURL=generate-quarkus-project.js.map