@releaseotto/core
Version:
OTTO performs your action on new versioning of APIs, packages, schemas, etc. Keepings things nice and neatly automated.
66 lines • 3.37 kB
JavaScript
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
import { loadMetaConfig, writeMetaInformation } from "./utils/meta";
import { runAction } from "./commands/npm";
import { fetchLocation } from "./utils/location";
import { getVersionChangeToDo, getVersionDiffs } from "./utils/versionStrategies";
export function start(config) {
var _a, _b;
return __awaiter(this, void 0, void 0, function* () {
const metaLocation = fetchLocation(config);
const metaInfo = loadMetaConfig(metaLocation);
const versionDiffs = yield getVersionDiffs(config, metaInfo);
const versionChangeToDo = getVersionChangeToDo(config, versionDiffs);
if (versionChangeToDo !== null && config.location != undefined) {
if (((_a = config.action) === null || _a === void 0 ? void 0 : _a.type) && ((_b = config.action) === null || _b === void 0 ? void 0 : _b.type) === 'package') {
runAction(config, config.action.config);
}
//Save new config file
writeMetaInformation({
config,
versionDiffs
});
// for (const postAction of config.postMinusAction || []) {
// if (postAction?.type && postAction?.type === 'git-commit') {
// const commitConfig = GitCommit.unmarshal(JSON.stringify(postAction.config));
// let formattedCommit = commitConfig.commitMinusMessage;
// if (commitConfig.commitMinusType === 'conventional-commits') {
// formattedCommit = formatCommit(
// {
// rawCommitMessage: formattedCommit,
// context: {
// commit: toConventionalCommit({ semver: versionChangeToDo }),
// commitSentence: `${versionChangeToDo} version change`
// }
// });
// }
// commit({
// commitMessage: formattedCommit,
// location: path.dirname(metaLocation)
// // push: {
// // branch: location.branch,
// // origin: 'origin'
// // }
// });
// }
// }
}
});
}
export function check(config) {
return __awaiter(this, void 0, void 0, function* () {
const metaLocation = fetchLocation(config);
const metaInfo = loadMetaConfig(metaLocation);
const versionDiffs = yield getVersionDiffs(config, metaInfo);
const versionChangeToDo = getVersionChangeToDo(config, versionDiffs);
return versionChangeToDo !== null;
});
}
//# sourceMappingURL=index.js.map