UNPKG

1.47 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.ciWorkflowGenerator = void 0;
4const tslib_1 = require("tslib");
5const devkit_1 = require("@nrwl/devkit");
6const default_base_1 = require("../../utilities/default-base");
7function ciWorkflowGenerator(host, schema) {
8 return tslib_1.__awaiter(this, void 0, void 0, function* () {
9 const ci = schema.ci;
10 const options = normalizeOptions(schema);
11 const nxJson = (0, devkit_1.readJson)(host, 'nx.json');
12 const nxCloudUsed = Object.values(nxJson.tasksRunnerOptions).find((r) => r.runner == '@nrwl/nx-cloud');
13 if (!nxCloudUsed) {
14 throw new Error('This workspace is not connected to Nx Cloud.');
15 }
16 (0, devkit_1.generateFiles)(host, (0, devkit_1.joinPathFragments)(__dirname, 'files', ci), '', options);
17 yield (0, devkit_1.formatFiles)(host);
18 });
19}
20exports.ciWorkflowGenerator = ciWorkflowGenerator;
21function normalizeOptions(options) {
22 const { name: workflowName, fileName: workflowFileName } = (0, devkit_1.names)(options.name || 'CI');
23 const { exec: packageManagerPrefix, ciInstall: packageManagerInstall } = (0, devkit_1.getPackageManagerCommand)();
24 return {
25 workflowName,
26 workflowFileName,
27 packageManagerInstall,
28 packageManagerPrefix,
29 mainBranch: (0, default_base_1.deduceDefaultBase)(),
30 tmpl: '',
31 };
32}
33//# sourceMappingURL=ci-workflow.js.map
\No newline at end of file