@ng-builders/semrel
Version:
Custom Angular CLI builders
70 lines • 2.96 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const tslib_1 = require("tslib");
const architect_1 = require("@angular-devkit/architect");
const semantic_release_1 = tslib_1.__importDefault(require("semantic-release"));
const release_notes_generator_1 = require("./release-notes-generator");
const commit_analyzer_1 = require("./commit-analyzer");
const npm_1 = require("./npm");
const plugins_1 = require("./plugins");
const prepare_1 = require("./prepare");
const platform_plugin_1 = require("./platform-plugin");
function runRelease(options, builderContext) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const { npm: { pkgRoot }, dryRun, publishable, branches } = options;
const { project } = builderContext.target;
const { outputPath } = yield builderContext
.getTargetOptions({
project,
target: 'build'
})
.catch(() => ({ outputPath: null }));
const publishPath = outputPath !== null && outputPath !== void 0 ? outputPath : pkgRoot;
if (publishable && !publishPath) {
return {
success: false,
error: `Builder can't detect output path for the '${project}' project automatically. Please, provide the 'npm.pkgRoot' option`
};
}
else if (publishable) {
builderContext.logger.info(`The directory ${publishPath} will be used for publishing`);
}
return semantic_release_1.default({
tagFormat: `${project}@\${version}`,
branches,
extends: undefined,
dryRun,
plugins: plugins_1.plugins([
prepare_1.preparePlugin({ publishable, publishPath }),
commit_analyzer_1.commitAnalyzer({ project }),
release_notes_generator_1.releaseNotesGenerator({ project }),
npm_1.npm({ publishable, publishPath }),
platform_plugin_1.platformPlugin(options, builderContext)
])
}, {
env: Object.assign({}, process.env),
cwd: '.'
})
.then(result => {
if (result) {
const { nextRelease: { version } } = result;
builderContext.logger.info(`The '${project}' project released with version ${version}`);
}
else {
builderContext.logger.info(`No new release for the '${project}' project`);
}
return { success: true };
})
.catch(err => {
builderContext.logger.error(err);
return {
success: false,
error: `The automated release failed with error: ${err}`
};
});
});
}
exports.runRelease = runRelease;
exports.SemrelBuilder = architect_1.createBuilder(runRelease);
exports.default = exports.SemrelBuilder;
//# sourceMappingURL=index.js.map