@clickview/ship-it 0.0.2 → 0.0.4-dev.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config.json +5 -0
- package/lib/config.json +5 -0
- package/lib/src/api-clients/GitLabApiClient.js +1 -1
- package/lib/src/api-clients/git-lab/GitLabApiClient.js +341 -0
- package/lib/src/api-clients/git-lab/GitLabMapper.js +61 -0
- package/lib/src/api-clients/index.js +2 -1
- package/lib/src/api-clients/team-city/TeamCityApiClient.js +85 -0
- package/lib/src/commands/BumpPackagesCommand.js +12 -6
- package/lib/src/commands/CommitPackageVersionsCommand.js +78 -0
- package/lib/src/commands/CreateBranchCommand.js +12 -14
- package/lib/src/commands/CreateMergeRequestCommand.js +16 -18
- package/lib/src/commands/CreateReleaseNotesCommand.js +6 -8
- package/lib/src/commands/InstallPackagesCommand.js +76 -0
- package/lib/src/commands/ReleaseCommand.js +31 -24
- package/lib/src/commands/StartConsumingProjectBuildsCommand.js +76 -0
- package/lib/src/commands/StatusCommand.js +3 -5
- package/lib/src/commands/ValidateMergeRequestCommand.js +76 -0
- package/lib/src/commands/VersionCommand.js +3 -5
- package/lib/src/commands/index.js +3 -0
- package/lib/src/constants/CommandTypeMapping.js +16 -0
- package/lib/src/constants/MonorepoPackageJsonFiles.js +13 -0
- package/lib/src/constants/TeamCityBuildIDs.js +13 -0
- package/lib/src/constants/index.js +18 -0
- package/lib/src/errors/ShipItError.js +32 -0
- package/lib/src/errors/index.js +17 -0
- package/lib/src/index.js +2 -85
- package/lib/src/interfaces/VersionType.js +2 -0
- package/lib/src/interfaces/command-cli-options/MilestoneCommandCliOptions.js +2 -0
- package/lib/src/interfaces/command-cli-options/ReleaseCommandCliOptions.js +2 -0
- package/lib/src/interfaces/command-cli-options/index.js +18 -0
- package/lib/src/interfaces/command-options/BumpPackagesCommandOptions.js +2 -0
- package/lib/src/interfaces/command-options/CommitPackageVersionsCommandOptions.js +2 -0
- package/lib/src/interfaces/command-options/DockerMilestoneCommandOptions.js +2 -0
- package/lib/src/interfaces/command-options/InstallPackagesCommandOptions.js +2 -0
- package/lib/src/interfaces/command-options/MilestoneCommandOptions.js +2 -0
- package/lib/src/interfaces/command-options/ReleaseCommandOptions.js +2 -0
- package/lib/src/interfaces/command-options/ValidateMRCommandOptions.js +2 -0
- package/lib/src/interfaces/command-options/index.js +21 -0
- package/lib/src/interfaces/index.js +3 -1
- package/lib/src/interfaces/models/Milestone.js +2 -0
- package/lib/src/interfaces/models/index.js +1 -0
- package/lib/src/inversify.config.js +13 -0
- package/lib/src/services/GitLabService.js +128 -34
- package/lib/src/services/TeamCityService.js +34 -0
- package/lib/src/services/index.js +1 -0
- package/lib/src/startup/AddMilestoneCommand.js +81 -0
- package/lib/src/startup/GetAction.js +68 -0
- package/lib/src/startup/SetupCommands.js +114 -0
- package/lib/src/tasks/BumpPackagesTask.js +114 -238
- package/lib/src/tasks/BumpVersionTxtTask.js +13 -26
- package/lib/src/tasks/CommitLocalPackagesTask.js +137 -0
- package/lib/src/tasks/CommitPackageVersionsTask.js +105 -0
- package/lib/src/tasks/CreateBranchTask.js +35 -32
- package/lib/src/tasks/CreateMergeRequestTask.js +22 -37
- package/lib/src/tasks/CreateReleaseNotesTask.js +2 -6
- package/lib/src/tasks/InstallPackagesTask.js +337 -0
- package/lib/src/tasks/StartConsumingProjectBuildsTask.js +143 -0
- package/lib/src/tasks/StartMonorepoBuildTask.js +95 -0
- package/lib/src/tasks/ValidateCommitsTask.js +6 -14
- package/lib/src/tasks/ValidateDescriptionsTask.js +15 -16
- package/lib/src/tasks/ValidateMergeRequestTask.js +108 -0
- package/lib/src/tasks/ValidateTask.js +7 -8
- package/lib/src/tasks/VersionTask.js +7 -20
- package/lib/src/tasks/index.js +5 -0
- package/lib/src/types.js +13 -2
- package/lib/src/utils/BranchNames.js +2 -0
- package/lib/src/utils/Descriptions.js +28 -23
- package/lib/src/utils/ProjectIds.js +10 -6
- package/package.json +24 -23
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.processMilestoneCommandOptions = exports.getAddMilestoneCommand = void 0;
|
|
40
|
+
var utils_1 = require("../utils");
|
|
41
|
+
function processOptions(options) {
|
|
42
|
+
var opts = {
|
|
43
|
+
milestone: options.milestone,
|
|
44
|
+
version: 'minor'
|
|
45
|
+
};
|
|
46
|
+
if (options.projectIds)
|
|
47
|
+
opts.projectIds = utils_1.ProjectIds.getProjectIds(options.projectIds);
|
|
48
|
+
if (options.hotfix && options.major)
|
|
49
|
+
throw new Error('Cannot pass both --hotfix and --major options');
|
|
50
|
+
if (options.major)
|
|
51
|
+
opts.version = 'major';
|
|
52
|
+
if (options.hotfix)
|
|
53
|
+
opts.version = 'patch';
|
|
54
|
+
return opts;
|
|
55
|
+
}
|
|
56
|
+
exports.processMilestoneCommandOptions = processOptions;
|
|
57
|
+
var getAddMilestoneCommand = function (program, getAction) {
|
|
58
|
+
return function addMilestoneCommand(name, description) {
|
|
59
|
+
var _this = this;
|
|
60
|
+
program.command(name)
|
|
61
|
+
.description(description)
|
|
62
|
+
.requiredOption('-m, --milestone <milestone>')
|
|
63
|
+
.option('-p, --projectIds <projectIds...>')
|
|
64
|
+
.option('--hotfix')
|
|
65
|
+
.option('--major')
|
|
66
|
+
.action(function (opts) { return __awaiter(_this, void 0, void 0, function () {
|
|
67
|
+
var options;
|
|
68
|
+
return __generator(this, function (_a) {
|
|
69
|
+
switch (_a.label) {
|
|
70
|
+
case 0:
|
|
71
|
+
options = processOptions(opts);
|
|
72
|
+
return [4 /*yield*/, getAction(name)(options)];
|
|
73
|
+
case 1:
|
|
74
|
+
_a.sent();
|
|
75
|
+
return [2 /*return*/];
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
}); });
|
|
79
|
+
};
|
|
80
|
+
};
|
|
81
|
+
exports.getAddMilestoneCommand = getAddMilestoneCommand;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.getActionBuilder = void 0;
|
|
40
|
+
var constants_1 = require("../constants");
|
|
41
|
+
var errors_1 = require("../errors");
|
|
42
|
+
var getActionBuilder = function (program, container) {
|
|
43
|
+
return function (command) {
|
|
44
|
+
return function (options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
+
var result, err_1;
|
|
46
|
+
return __generator(this, function (_a) {
|
|
47
|
+
switch (_a.label) {
|
|
48
|
+
case 0:
|
|
49
|
+
_a.trys.push([0, 2, , 3]);
|
|
50
|
+
return [4 /*yield*/, container.get(constants_1.CommandTypeMapping[command]).run(options)];
|
|
51
|
+
case 1:
|
|
52
|
+
result = _a.sent();
|
|
53
|
+
if (!result)
|
|
54
|
+
program.error('Command did not successfully complete');
|
|
55
|
+
return [3 /*break*/, 3];
|
|
56
|
+
case 2:
|
|
57
|
+
err_1 = _a.sent();
|
|
58
|
+
if (!(err_1 instanceof errors_1.ShipItError))
|
|
59
|
+
throw err_1;
|
|
60
|
+
program.error(err_1.message);
|
|
61
|
+
return [3 /*break*/, 3];
|
|
62
|
+
case 3: return [2 /*return*/];
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}); };
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
exports.getActionBuilder = getActionBuilder;
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
+
};
|
|
52
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
+
exports.setupCommands = void 0;
|
|
54
|
+
var lodash_1 = __importDefault(require("lodash"));
|
|
55
|
+
var CommandTypeMapping_1 = require("../constants/CommandTypeMapping");
|
|
56
|
+
var AddMilestoneCommand_1 = require("./AddMilestoneCommand");
|
|
57
|
+
var GetAction_1 = require("./GetAction");
|
|
58
|
+
function setupCommands(program, container) {
|
|
59
|
+
var _this = this;
|
|
60
|
+
var getAction = (0, GetAction_1.getActionBuilder)(program, container);
|
|
61
|
+
var addMilestoneCommand = (0, AddMilestoneCommand_1.getAddMilestoneCommand)(program, getAction);
|
|
62
|
+
// All commands below accept the same options
|
|
63
|
+
addMilestoneCommand('status', 'Get the status of all MRs in a milestone');
|
|
64
|
+
addMilestoneCommand('version', 'Display the versions that will be used for the release');
|
|
65
|
+
addMilestoneCommand('create-branches', 'Create release branches for all projects that are part of a milestone');
|
|
66
|
+
addMilestoneCommand('create-mrs', 'Create merge requests for all projects that are part of a milestone');
|
|
67
|
+
addMilestoneCommand('create-notes', 'Builds descriptions for all projects that are part of a milestone');
|
|
68
|
+
program.command('release')
|
|
69
|
+
.description('Create releases for all projects that are part of a milestone')
|
|
70
|
+
.requiredOption('-m, --milestone <milestone>')
|
|
71
|
+
.option('-p, --projectIds <projectIds...>')
|
|
72
|
+
.option('--hotfix')
|
|
73
|
+
.option('--major')
|
|
74
|
+
.option('--trigger-monorepo-build')
|
|
75
|
+
.action(function (options) { return __awaiter(_this, void 0, void 0, function () {
|
|
76
|
+
var milestoneCommandOptions, releaseCommandOptions;
|
|
77
|
+
return __generator(this, function (_a) {
|
|
78
|
+
milestoneCommandOptions = (0, AddMilestoneCommand_1.processMilestoneCommandOptions)(lodash_1.default.omit(options, 'triggerMonorepoBuild'));
|
|
79
|
+
releaseCommandOptions = __assign(__assign({}, milestoneCommandOptions), { triggerMonorepoBuild: !!options.triggerMonorepoBuild });
|
|
80
|
+
container.get(CommandTypeMapping_1.CommandTypeMapping['release'])
|
|
81
|
+
.run(releaseCommandOptions);
|
|
82
|
+
return [2 /*return*/];
|
|
83
|
+
});
|
|
84
|
+
}); });
|
|
85
|
+
program.command('bump-packages')
|
|
86
|
+
.description('Bump clickview npm package versions in monorepo to their next version')
|
|
87
|
+
.requiredOption('-b, --branchName <branchName>')
|
|
88
|
+
.option('-p, --preId <preId>')
|
|
89
|
+
.action(getAction('bump-packages'));
|
|
90
|
+
program.command('install-packages')
|
|
91
|
+
.description('Install the latest clickview npm packages in all consuming projects that are part of a milestone')
|
|
92
|
+
.option('-m, --milestone <milestone>')
|
|
93
|
+
.option('-b, --branchName <monorepoBranchName>')
|
|
94
|
+
.option('-p, --projectIds <projectIds...>')
|
|
95
|
+
.action(getAction('install-packages'));
|
|
96
|
+
program.command('start-consuming-project-builds')
|
|
97
|
+
.description('Trigger TeamCity builds in all consuming projects that are a part of a milestone')
|
|
98
|
+
.option('-m, --milestone <milestone>')
|
|
99
|
+
.option('--monorepoBranchName <monorepoBranchName>')
|
|
100
|
+
.option('-p, --projectIds <projectIds...>')
|
|
101
|
+
.action(function (options) { return __awaiter(_this, void 0, void 0, function () {
|
|
102
|
+
return __generator(this, function (_a) {
|
|
103
|
+
container.get(CommandTypeMapping_1.CommandTypeMapping['start-consuming-project-builds'])
|
|
104
|
+
.run(options);
|
|
105
|
+
return [2 /*return*/];
|
|
106
|
+
});
|
|
107
|
+
}); });
|
|
108
|
+
program.command('validate-mr')
|
|
109
|
+
.description('Validate a merge request in a single project, ensuring it has a milestone and valid description')
|
|
110
|
+
.option('-p, --projectId <projectId>')
|
|
111
|
+
.option('-b, --branchName <branchName>')
|
|
112
|
+
.action(getAction('validate-mr'));
|
|
113
|
+
}
|
|
114
|
+
exports.setupCommands = setupCommands;
|