@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
|
@@ -47,302 +47,178 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
51
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
52
|
-
};
|
|
53
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
51
|
exports.BumpPackagesTask = void 0;
|
|
55
52
|
require("reflect-metadata");
|
|
56
53
|
var inversify_1 = require("inversify");
|
|
57
|
-
var
|
|
58
|
-
var semver_1 = __importDefault(require("semver"));
|
|
59
|
-
var child_process_1 = __importDefault(require("child_process"));
|
|
54
|
+
var child_process_1 = require("child_process");
|
|
60
55
|
var types_1 = require("../types");
|
|
61
56
|
var services_1 = require("../services");
|
|
57
|
+
var MonorepoPackageJsonFiles_1 = require("../constants/MonorepoPackageJsonFiles");
|
|
62
58
|
var utils_1 = require("../utils");
|
|
63
|
-
var
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
'packages/projects/library-editor/package.json',
|
|
69
|
-
'packages/projects/lite/package.json',
|
|
70
|
-
'packages/projects/online/package.json',
|
|
71
|
-
'packages/projects/reports/package.json'
|
|
72
|
-
];
|
|
73
|
-
var ROOT_DIRECTORIES = {
|
|
74
|
-
// Curator
|
|
75
|
-
62: 'src/ClickView.Curator.Web/Assets',
|
|
76
|
-
// Library Editor
|
|
77
|
-
534: 'src/ClickView.Cloud',
|
|
78
|
-
// Lite
|
|
79
|
-
822: 'src/ClickView.Lite',
|
|
80
|
-
// Online
|
|
81
|
-
109: 'src/ClickView.Web.Online.Pages',
|
|
82
|
-
// Reports
|
|
83
|
-
970: 'src/ClickView.Analytics.Web'
|
|
84
|
-
};
|
|
59
|
+
var RELEASE_BRANCH_REGEX = /^release\/(\d|\.)+$/;
|
|
60
|
+
var HOTFIX_BRANCH_REGEX = /^hotfix\/(\d|\.)+$/;
|
|
61
|
+
var DEV_VERSION_REGEX = /-dev\.\d+$/;
|
|
62
|
+
var RC_VERSION_REGEX = /-rc\.\d+$/;
|
|
63
|
+
var SHARED_LERNA_OPTIONS = '--exact --no-git-tag-version --no-push --yes';
|
|
85
64
|
var BumpPackagesTask = /** @class */ (function () {
|
|
86
65
|
function BumpPackagesTask(service) {
|
|
87
|
-
this.
|
|
66
|
+
this.isReleaseBranch = false;
|
|
67
|
+
this.isHotfixBranch = false;
|
|
68
|
+
this.service = service;
|
|
88
69
|
}
|
|
89
70
|
BumpPackagesTask.prototype.run = function (options) {
|
|
90
71
|
return __awaiter(this, void 0, void 0, function () {
|
|
91
|
-
var
|
|
92
|
-
return __generator(this, function (
|
|
93
|
-
switch (
|
|
72
|
+
var branch, isValid, lernaVersionCmd;
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
switch (_a.label) {
|
|
94
75
|
case 0:
|
|
95
|
-
utils_1.Logger.logTask('Bumping npm
|
|
96
|
-
|
|
76
|
+
utils_1.Logger.logTask('Bumping clickview npm package versions');
|
|
77
|
+
this.isReleaseBranch = RELEASE_BRANCH_REGEX.test(options.branchName);
|
|
78
|
+
this.isHotfixBranch = HOTFIX_BRANCH_REGEX.test(options.branchName);
|
|
79
|
+
return [4 /*yield*/, this.service.getBranch(utils_1.ProjectIds.MONOREPO_PROJECT_ID, options.branchName)];
|
|
97
80
|
case 1:
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
if (!monorepo) {
|
|
102
|
-
utils_1.Logger.logError("Monorepo was not in this release");
|
|
81
|
+
branch = _a.sent();
|
|
82
|
+
if (!branch) {
|
|
83
|
+
utils_1.Logger.logError("Branch with name ".concat(options.branchName, " was not be found."));
|
|
103
84
|
return [2 /*return*/, false];
|
|
104
85
|
}
|
|
105
|
-
|
|
106
|
-
|
|
86
|
+
isValid = this.validateOptions(options);
|
|
87
|
+
if (!isValid)
|
|
107
88
|
return [2 /*return*/, false];
|
|
108
|
-
|
|
109
|
-
return [4 /*yield*/, this.getBranchName(monorepo.id, options.version)];
|
|
89
|
+
return [4 /*yield*/, this.getLernaCommand(options)];
|
|
110
90
|
case 2:
|
|
111
|
-
|
|
112
|
-
if (!
|
|
113
|
-
utils_1.Logger.logError(
|
|
91
|
+
lernaVersionCmd = _a.sent();
|
|
92
|
+
if (!lernaVersionCmd) {
|
|
93
|
+
utils_1.Logger.logError('Something went wrong while trying to detect which versioning script to run with Lerna.');
|
|
114
94
|
return [2 /*return*/, false];
|
|
115
95
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
utils_1.Logger.logMessage("Versions identified for ".concat(monorepoBranchName));
|
|
120
|
-
Object.keys(versions).forEach(function (key) {
|
|
121
|
-
utils_1.Logger.logMessage("- [".concat(key, "]: ").concat(versions[key]));
|
|
122
|
-
});
|
|
123
|
-
// let cont = true;
|
|
124
|
-
utils_1.Logger.logMessage('\nBumping packages:\n');
|
|
125
|
-
_i = 0, consumingProjects_1 = consumingProjects;
|
|
126
|
-
_c.label = 4;
|
|
127
|
-
case 4:
|
|
128
|
-
if (!(_i < consumingProjects_1.length)) return [3 /*break*/, 8];
|
|
129
|
-
project = consumingProjects_1[_i];
|
|
130
|
-
return [4 /*yield*/, this.getBranchName(project.id, options.version)];
|
|
131
|
-
case 5:
|
|
132
|
-
branchName = _c.sent();
|
|
133
|
-
// TODO: potentially add a validate branches task and removing the branch checking from this task
|
|
134
|
-
// so that bump packages can't be run until create release is run
|
|
135
|
-
if (!branchName) {
|
|
136
|
-
utils_1.Logger.logError("[".concat(project.title, "]: branch does not exist"));
|
|
137
|
-
return [3 /*break*/, 7];
|
|
138
|
-
}
|
|
139
|
-
return [4 /*yield*/, this.updateAndSavePackageFiles(project, options.milestone, branchName, versions)];
|
|
140
|
-
case 6:
|
|
141
|
-
_c.sent();
|
|
142
|
-
_c.label = 7;
|
|
143
|
-
case 7:
|
|
144
|
-
_i++;
|
|
145
|
-
return [3 /*break*/, 4];
|
|
146
|
-
case 8:
|
|
147
|
-
for (_a = 0, consumingProjects_2 = consumingProjects; _a < consumingProjects_2.length; _a++) {
|
|
148
|
-
project = consumingProjects_2[_a];
|
|
149
|
-
utils_1.Logger.logInfo("[".concat(project.title, "]: Running npm i --package-lock-only"));
|
|
150
|
-
this.npmInstall(project, options.milestone);
|
|
151
|
-
utils_1.Logger.logInfo('\n');
|
|
152
|
-
}
|
|
153
|
-
/**
|
|
154
|
-
* TODO: Need to not commit when there's no changes
|
|
155
|
-
*/
|
|
156
|
-
utils_1.Logger.logMessage('Committing files');
|
|
157
|
-
_b = 0, consumingProjects_3 = consumingProjects;
|
|
158
|
-
_c.label = 9;
|
|
159
|
-
case 9:
|
|
160
|
-
if (!(_b < consumingProjects_3.length)) return [3 /*break*/, 13];
|
|
161
|
-
project = consumingProjects_3[_b];
|
|
162
|
-
return [4 /*yield*/, this.getBranchName(project.id, options.version)];
|
|
163
|
-
case 10:
|
|
164
|
-
branchName = _c.sent();
|
|
165
|
-
if (!branchName) {
|
|
166
|
-
utils_1.Logger.logError("[".concat(project.title, "]: branch does not exist"));
|
|
167
|
-
return [3 /*break*/, 12];
|
|
168
|
-
}
|
|
169
|
-
return [4 /*yield*/, this.commitUpdatedFiles(project, options.milestone, branchName)];
|
|
170
|
-
case 11:
|
|
171
|
-
_c.sent();
|
|
172
|
-
utils_1.Logger.logMessage("[".concat(project.title, "]: File changes committed"));
|
|
173
|
-
_c.label = 12;
|
|
174
|
-
case 12:
|
|
175
|
-
_b++;
|
|
176
|
-
return [3 /*break*/, 9];
|
|
177
|
-
case 13: return [2 /*return*/, true];
|
|
96
|
+
(0, child_process_1.execSync)(lernaVersionCmd);
|
|
97
|
+
utils_1.Logger.logSuccess('Successfully executed Lerna versioning command.');
|
|
98
|
+
return [2 /*return*/, true];
|
|
178
99
|
}
|
|
179
100
|
});
|
|
180
101
|
});
|
|
181
102
|
};
|
|
182
|
-
BumpPackagesTask.prototype.
|
|
103
|
+
BumpPackagesTask.prototype.validateOptions = function (options) {
|
|
104
|
+
var isValidReleaseBranch = this.isReleaseBranch || this.isHotfixBranch;
|
|
105
|
+
if (options.preId && options.preId !== 'rc' && options.preId !== 'dev') {
|
|
106
|
+
utils_1.Logger.logError("Argument for \"preId\" can only be \"rc\" or \"dev\". You entered: ".concat(options.preId));
|
|
107
|
+
return false;
|
|
108
|
+
}
|
|
109
|
+
if (options.preId === 'dev' && isValidReleaseBranch) {
|
|
110
|
+
utils_1.Logger.logError('Dev versions cannot be generated on release or hotfix branches.');
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
if (options.preId === 'rc' && !isValidReleaseBranch) {
|
|
114
|
+
utils_1.Logger.logError('Release Candidate versions can only be generated on release or hotfix branches.');
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
if (!options.preId && !isValidReleaseBranch) {
|
|
118
|
+
utils_1.Logger.logError('Production package versions can only be generated on release or hotfix branches.');
|
|
119
|
+
return false;
|
|
120
|
+
}
|
|
121
|
+
return true;
|
|
122
|
+
};
|
|
123
|
+
BumpPackagesTask.prototype.getFileText = function (projectId, branchName, fileName) {
|
|
183
124
|
return __awaiter(this, void 0, void 0, function () {
|
|
184
|
-
var
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
case 0:
|
|
189
|
-
rootDir = ROOT_DIRECTORIES[project.id];
|
|
190
|
-
outputPath = this.getOutputPath(project, milestone);
|
|
191
|
-
_b = {
|
|
192
|
-
filePath: "".concat(rootDir, "/package.json")
|
|
193
|
-
};
|
|
194
|
-
return [4 /*yield*/, fs_extra_1.default.readFile("".concat(outputPath, "/package.json"), 'utf8')];
|
|
125
|
+
var file, buff;
|
|
126
|
+
return __generator(this, function (_a) {
|
|
127
|
+
switch (_a.label) {
|
|
128
|
+
case 0: return [4 /*yield*/, this.service.getFile(projectId, branchName, fileName)];
|
|
195
129
|
case 1:
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
return [4 /*yield*/, fs_extra_1.default.readFile("".concat(outputPath, "/package-lock.json"), 'utf8')];
|
|
202
|
-
case 2:
|
|
203
|
-
commitFiles = _a.concat([(_c.content = _d.sent(),
|
|
204
|
-
_c)]);
|
|
205
|
-
return [4 /*yield*/, this._service.commit(project.id, branchName, 'Bumping @clickview npm packages', commitFiles)];
|
|
206
|
-
case 3:
|
|
207
|
-
_d.sent();
|
|
208
|
-
return [2 /*return*/];
|
|
130
|
+
file = _a.sent();
|
|
131
|
+
if (!file)
|
|
132
|
+
return [2 /*return*/, ''];
|
|
133
|
+
buff = Buffer.from(file.content, 'base64');
|
|
134
|
+
return [2 /*return*/, buff.toString('utf-8')];
|
|
209
135
|
}
|
|
210
136
|
});
|
|
211
137
|
});
|
|
212
138
|
};
|
|
213
|
-
BumpPackagesTask.prototype.
|
|
214
|
-
var outputPath = this.getOutputPath(project, milestone);
|
|
215
|
-
child_process_1.default.execSync('npm i --package-lock-only', {
|
|
216
|
-
cwd: outputPath,
|
|
217
|
-
// Uncomment if we want to silence
|
|
218
|
-
// stdio: 'pipe'
|
|
219
|
-
});
|
|
220
|
-
};
|
|
221
|
-
BumpPackagesTask.prototype.updateAndSavePackageFiles = function (project, milestone, branchName, versions) {
|
|
139
|
+
BumpPackagesTask.prototype.getLernaCommand = function (options) {
|
|
222
140
|
return __awaiter(this, void 0, void 0, function () {
|
|
223
|
-
var
|
|
141
|
+
var isInPrerelease;
|
|
224
142
|
return __generator(this, function (_a) {
|
|
225
143
|
switch (_a.label) {
|
|
226
|
-
case 0:
|
|
227
|
-
rootDir = ROOT_DIRECTORIES[project.id];
|
|
228
|
-
return [4 /*yield*/, this.getFileText(project.id, branchName, "".concat(rootDir, "/package.json"))];
|
|
144
|
+
case 0: return [4 /*yield*/, this.isInPrerelease(options.branchName)];
|
|
229
145
|
case 1:
|
|
230
|
-
|
|
231
|
-
return [4 /*yield*/, this.getFileText(project.id, branchName, "".concat(rootDir, "/package-lock.json"))];
|
|
232
|
-
case 2:
|
|
233
|
-
packageLock = _a.sent();
|
|
234
|
-
packageJsonObj = JSON.parse(packageJson);
|
|
235
|
-
utils_1.Logger.logMessage(project.title);
|
|
146
|
+
isInPrerelease = _a.sent();
|
|
236
147
|
/**
|
|
237
|
-
*
|
|
238
|
-
*
|
|
148
|
+
* The `lerna version prerelease` script only cares about incrementing the preId part
|
|
149
|
+
* of the version number. That's why we run this if `isInPrerelease` is true.
|
|
150
|
+
*
|
|
151
|
+
* E.g. this would change 0.0.1-dev.0 to 0.0.0-dev.1
|
|
239
152
|
*/
|
|
240
|
-
if (
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
153
|
+
if (isInPrerelease && options.preId) {
|
|
154
|
+
utils_1.Logger.logMessage("Incrementing \"".concat(options.preId, "\" preId for each package."));
|
|
155
|
+
return [2 /*return*/, "lerna version prerelease --preid ".concat(options.preId, " ").concat(SHARED_LERNA_OPTIONS)];
|
|
156
|
+
}
|
|
157
|
+
// Bump the patch with the preId "dev". We currently only support dev prereleases on patch versions
|
|
158
|
+
if (options.preId === 'dev') {
|
|
159
|
+
utils_1.Logger.logMessage("Incrementing the patch version for each package and appending preId: \"dev\".");
|
|
160
|
+
return [2 /*return*/, "lerna version prepatch --preid dev ".concat(SHARED_LERNA_OPTIONS)];
|
|
161
|
+
}
|
|
162
|
+
if (options.preId === 'rc') {
|
|
163
|
+
// Bump the minor number with the preId "rc". Release branches always bump the minor number.
|
|
164
|
+
if (this.isReleaseBranch) {
|
|
165
|
+
utils_1.Logger.logMessage("Incrementing the minor version for each package and appending preId: \"rc\".");
|
|
166
|
+
return [2 /*return*/, "lerna version preminor --preid rc ".concat(SHARED_LERNA_OPTIONS)];
|
|
167
|
+
}
|
|
168
|
+
// Bump the patch with the preId "rc". Hotfix branches always bump the patch number.
|
|
169
|
+
if (this.isHotfixBranch) {
|
|
170
|
+
utils_1.Logger.logMessage("Incrementing the patch version for each package and appending preId: \"rc\".");
|
|
171
|
+
return [2 /*return*/, "lerna version prepatch --preid rc ".concat(SHARED_LERNA_OPTIONS)];
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* If no preId is provided, we bump the version number to a production version.
|
|
176
|
+
*
|
|
177
|
+
* Release branch = minor bump
|
|
178
|
+
* Hotfix branch = patch bump
|
|
179
|
+
*/
|
|
180
|
+
if (this.isReleaseBranch) {
|
|
181
|
+
utils_1.Logger.logMessage('Updating each package to production release version.');
|
|
182
|
+
return [2 /*return*/, "lerna version minor ".concat(SHARED_LERNA_OPTIONS)];
|
|
183
|
+
}
|
|
184
|
+
if (this.isHotfixBranch) {
|
|
185
|
+
utils_1.Logger.logMessage('Updating each package to production hotfix version.');
|
|
186
|
+
return [2 /*return*/, "lerna version patch ".concat(SHARED_LERNA_OPTIONS)];
|
|
187
|
+
}
|
|
188
|
+
// Should never be reached
|
|
189
|
+
return [2 /*return*/, ''];
|
|
252
190
|
}
|
|
253
191
|
});
|
|
254
192
|
});
|
|
255
193
|
};
|
|
256
|
-
BumpPackagesTask.prototype.
|
|
257
|
-
Object.keys(deps).forEach(function (key) {
|
|
258
|
-
if (!key.startsWith('@clickview'))
|
|
259
|
-
return;
|
|
260
|
-
if (!versions[key])
|
|
261
|
-
return;
|
|
262
|
-
var oldVersion = deps[key];
|
|
263
|
-
var newVersion = versions[key];
|
|
264
|
-
if (oldVersion === newVersion) {
|
|
265
|
-
utils_1.Logger.logWarning("- [".concat(key, "]: ").concat(versions[key], " is up to date"));
|
|
266
|
-
return;
|
|
267
|
-
}
|
|
268
|
-
if (semver_1.default.compare(oldVersion, newVersion) === 1) {
|
|
269
|
-
utils_1.Logger.logError("- [".concat(key, "]: ").concat(deps[key], " -> ").concat(versions[key], " downgrade detected"));
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
packageJson = packageJson.replace("\"".concat(key, "\": \"").concat(deps[key], "\""), "\"".concat(key, "\": \"").concat(versions[key], "\""));
|
|
273
|
-
utils_1.Logger.logMessage("- [".concat(key, "]: ").concat(deps[key], " -> ").concat(versions[key]));
|
|
274
|
-
});
|
|
275
|
-
return packageJson;
|
|
276
|
-
};
|
|
277
|
-
BumpPackagesTask.prototype.getPackageVersions = function (branchName) {
|
|
194
|
+
BumpPackagesTask.prototype.isInPrerelease = function (branchName) {
|
|
278
195
|
return __awaiter(this, void 0, void 0, function () {
|
|
279
|
-
var
|
|
196
|
+
var _i, MONOREPO_PACKAGE_JSON_FILES_1, file, text, json;
|
|
280
197
|
return __generator(this, function (_a) {
|
|
281
198
|
switch (_a.label) {
|
|
282
199
|
case 0:
|
|
283
|
-
|
|
284
|
-
_i = 0, MONOREPO_PACKAGES_FILES_1 = MONOREPO_PACKAGES_FILES;
|
|
200
|
+
_i = 0, MONOREPO_PACKAGE_JSON_FILES_1 = MonorepoPackageJsonFiles_1.MONOREPO_PACKAGE_JSON_FILES;
|
|
285
201
|
_a.label = 1;
|
|
286
202
|
case 1:
|
|
287
|
-
if (!(_i <
|
|
288
|
-
file =
|
|
203
|
+
if (!(_i < MONOREPO_PACKAGE_JSON_FILES_1.length)) return [3 /*break*/, 4];
|
|
204
|
+
file = MONOREPO_PACKAGE_JSON_FILES_1[_i];
|
|
289
205
|
return [4 /*yield*/, this.getFileText(utils_1.ProjectIds.MONOREPO_PROJECT_ID, branchName, file)];
|
|
290
206
|
case 2:
|
|
291
207
|
text = _a.sent();
|
|
292
208
|
json = JSON.parse(text);
|
|
293
|
-
|
|
209
|
+
if (RC_VERSION_REGEX.test(json.version))
|
|
210
|
+
return [2 /*return*/, true];
|
|
211
|
+
if (DEV_VERSION_REGEX.test(json.version))
|
|
212
|
+
return [2 /*return*/, true];
|
|
294
213
|
_a.label = 3;
|
|
295
214
|
case 3:
|
|
296
215
|
_i++;
|
|
297
216
|
return [3 /*break*/, 1];
|
|
298
|
-
case 4: return [2 /*return*/,
|
|
299
|
-
}
|
|
300
|
-
});
|
|
301
|
-
});
|
|
302
|
-
};
|
|
303
|
-
BumpPackagesTask.prototype.getFileText = function (projectId, branchName, fileName) {
|
|
304
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
305
|
-
var file, buff;
|
|
306
|
-
return __generator(this, function (_a) {
|
|
307
|
-
switch (_a.label) {
|
|
308
|
-
case 0: return [4 /*yield*/, this._service.getFile(projectId, branchName, fileName)];
|
|
309
|
-
case 1:
|
|
310
|
-
file = _a.sent();
|
|
311
|
-
if (!file)
|
|
312
|
-
return [2 /*return*/, ''];
|
|
313
|
-
buff = Buffer.from(file.content, 'base64');
|
|
314
|
-
return [2 /*return*/, buff.toString('utf-8')];
|
|
217
|
+
case 4: return [2 /*return*/, false];
|
|
315
218
|
}
|
|
316
219
|
});
|
|
317
220
|
});
|
|
318
221
|
};
|
|
319
|
-
BumpPackagesTask.prototype.getBranchName = function (projectId, version) {
|
|
320
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
321
|
-
var currentVersionTag, nextVersion, branchName, branch;
|
|
322
|
-
return __generator(this, function (_a) {
|
|
323
|
-
switch (_a.label) {
|
|
324
|
-
case 0: return [4 /*yield*/, this._service.getCurrentVersionTag(projectId)];
|
|
325
|
-
case 1:
|
|
326
|
-
currentVersionTag = _a.sent();
|
|
327
|
-
if (!currentVersionTag)
|
|
328
|
-
return [2 /*return*/, null];
|
|
329
|
-
return [4 /*yield*/, utils_1.Versions.getNextVersion(currentVersionTag.name, version)];
|
|
330
|
-
case 2:
|
|
331
|
-
nextVersion = _a.sent();
|
|
332
|
-
branchName = utils_1.BranchNames.getRelease(nextVersion);
|
|
333
|
-
return [4 /*yield*/, this._service.getBranch(projectId, branchName)];
|
|
334
|
-
case 3:
|
|
335
|
-
branch = _a.sent();
|
|
336
|
-
if (!branch)
|
|
337
|
-
return [2 /*return*/, null];
|
|
338
|
-
return [2 /*return*/, branchName];
|
|
339
|
-
}
|
|
340
|
-
});
|
|
341
|
-
});
|
|
342
|
-
};
|
|
343
|
-
BumpPackagesTask.prototype.getOutputPath = function (project, milestone) {
|
|
344
|
-
return "./temp/".concat(milestone, "/").concat(project.title);
|
|
345
|
-
};
|
|
346
222
|
BumpPackagesTask = __decorate([
|
|
347
223
|
(0, inversify_1.injectable)(),
|
|
348
224
|
__param(0, (0, inversify_1.inject)(types_1.SERVICES.GitLabService)),
|
|
@@ -54,53 +54,40 @@ var inversify_1 = require("inversify");
|
|
|
54
54
|
var Logger_1 = require("../utils/Logger");
|
|
55
55
|
var types_1 = require("../types");
|
|
56
56
|
var services_1 = require("../services");
|
|
57
|
-
var utils_1 = require("../utils");
|
|
58
57
|
var BumpVersionTxtTask = /** @class */ (function () {
|
|
59
58
|
function BumpVersionTxtTask(service) {
|
|
60
|
-
this.
|
|
59
|
+
this.service = service;
|
|
61
60
|
}
|
|
62
61
|
BumpVersionTxtTask.prototype.run = function (options) {
|
|
63
62
|
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
-
var projects,
|
|
65
|
-
return __generator(this, function (
|
|
66
|
-
switch (
|
|
63
|
+
var projects, _i, projects_1, project, _a, nextVersion, branchName, versionBumped;
|
|
64
|
+
return __generator(this, function (_b) {
|
|
65
|
+
switch (_b.label) {
|
|
67
66
|
case 0:
|
|
68
67
|
Logger_1.Logger.logTask('Bumping version.txt');
|
|
69
|
-
return [4 /*yield*/, this.
|
|
68
|
+
return [4 /*yield*/, this.service.getProjects(options)];
|
|
70
69
|
case 1:
|
|
71
|
-
projects =
|
|
72
|
-
if (!projects.length) {
|
|
73
|
-
Logger_1.Logger.logError("No projects could be found with the specified options");
|
|
74
|
-
return [2 /*return*/, false];
|
|
75
|
-
}
|
|
76
|
-
cont = true;
|
|
70
|
+
projects = _b.sent();
|
|
77
71
|
_i = 0, projects_1 = projects;
|
|
78
|
-
|
|
72
|
+
_b.label = 2;
|
|
79
73
|
case 2:
|
|
80
74
|
if (!(_i < projects_1.length)) return [3 /*break*/, 6];
|
|
81
75
|
project = projects_1[_i];
|
|
82
|
-
return [4 /*yield*/, this.
|
|
76
|
+
return [4 /*yield*/, this.service.getNextBranchInfo(project.id, options.version)];
|
|
83
77
|
case 3:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
Logger_1.Logger.logError("[".concat(project.title, "]: Could not find current version tag"));
|
|
87
|
-
cont = false;
|
|
88
|
-
return [3 /*break*/, 5];
|
|
89
|
-
}
|
|
90
|
-
nextVersion = utils_1.Versions.getNextVersion(currentVersionTag.name, options.version);
|
|
91
|
-
branchName = utils_1.BranchNames.getRelease(nextVersion);
|
|
92
|
-
return [4 /*yield*/, this._service.bumpVersionTxt(project.id, branchName, nextVersion)];
|
|
78
|
+
_a = _b.sent(), nextVersion = _a.nextVersion, branchName = _a.branchName;
|
|
79
|
+
return [4 /*yield*/, this.service.bumpVersionTxt(project.id, branchName, nextVersion)];
|
|
93
80
|
case 4:
|
|
94
|
-
versionBumped =
|
|
81
|
+
versionBumped = _b.sent();
|
|
95
82
|
if (versionBumped)
|
|
96
83
|
Logger_1.Logger.logMessage("[".concat(project.title, "]: Bumped to ").concat(nextVersion));
|
|
97
84
|
else
|
|
98
85
|
Logger_1.Logger.logWarning("[".concat(project.title, "]: Has already been bumped, or does not have a version.txt"));
|
|
99
|
-
|
|
86
|
+
_b.label = 5;
|
|
100
87
|
case 5:
|
|
101
88
|
_i++;
|
|
102
89
|
return [3 /*break*/, 2];
|
|
103
|
-
case 6: return [2 /*return*/,
|
|
90
|
+
case 6: return [2 /*return*/, true];
|
|
104
91
|
}
|
|
105
92
|
});
|
|
106
93
|
});
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
15
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
16
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
17
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
18
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
19
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
20
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
24
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
25
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
26
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
27
|
+
function step(op) {
|
|
28
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
29
|
+
while (_) try {
|
|
30
|
+
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;
|
|
31
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
32
|
+
switch (op[0]) {
|
|
33
|
+
case 0: case 1: t = op; break;
|
|
34
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
35
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
36
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
37
|
+
default:
|
|
38
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
39
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
40
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
41
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
42
|
+
if (t[2]) _.ops.pop();
|
|
43
|
+
_.trys.pop(); continue;
|
|
44
|
+
}
|
|
45
|
+
op = body.call(thisArg, _);
|
|
46
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
47
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
51
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
52
|
+
};
|
|
53
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
54
|
+
exports.CommitLocalPackagesTask = void 0;
|
|
55
|
+
require("reflect-metadata");
|
|
56
|
+
var fs_1 = __importDefault(require("fs"));
|
|
57
|
+
var inversify_1 = require("inversify");
|
|
58
|
+
var types_1 = require("../types");
|
|
59
|
+
var services_1 = require("../services");
|
|
60
|
+
var MonorepoPackageJsonFiles_1 = require("../constants/MonorepoPackageJsonFiles");
|
|
61
|
+
var utils_1 = require("../utils");
|
|
62
|
+
var CommitLocalPackagesTask = /** @class */ (function () {
|
|
63
|
+
function CommitLocalPackagesTask(service) {
|
|
64
|
+
this.service = service;
|
|
65
|
+
}
|
|
66
|
+
CommitLocalPackagesTask.prototype.run = function (options) {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
68
|
+
var mergeRequest, commitFiles;
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
switch (_a.label) {
|
|
71
|
+
case 0:
|
|
72
|
+
utils_1.Logger.logTask('Committing clickview npm package versions');
|
|
73
|
+
return [4 /*yield*/, this.service.getMergeRequest(utils_1.ProjectIds.MONOREPO_PROJECT_ID, options.branchName)];
|
|
74
|
+
case 1:
|
|
75
|
+
mergeRequest = _a.sent();
|
|
76
|
+
return [4 /*yield*/, this.getCommitFiles()];
|
|
77
|
+
case 2:
|
|
78
|
+
commitFiles = _a.sent();
|
|
79
|
+
console.log('commit files', commitFiles);
|
|
80
|
+
// await this.service.commit(
|
|
81
|
+
// ProjectIds.MONOREPO_PROJECT_ID,
|
|
82
|
+
// options.branchName,
|
|
83
|
+
// 'Bump package versions',
|
|
84
|
+
// commitFiles
|
|
85
|
+
// );
|
|
86
|
+
return [2 /*return*/, true];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
CommitLocalPackagesTask.prototype.getCommitFiles = function () {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
+
var commitFiles, _i, MONOREPO_PACKAGE_JSON_FILES_1, filePath;
|
|
94
|
+
return __generator(this, function (_a) {
|
|
95
|
+
commitFiles = [];
|
|
96
|
+
for (_i = 0, MONOREPO_PACKAGE_JSON_FILES_1 = MonorepoPackageJsonFiles_1.MONOREPO_PACKAGE_JSON_FILES; _i < MONOREPO_PACKAGE_JSON_FILES_1.length; _i++) {
|
|
97
|
+
filePath = MONOREPO_PACKAGE_JSON_FILES_1[_i];
|
|
98
|
+
console.log('reading file', filePath);
|
|
99
|
+
commitFiles.push({
|
|
100
|
+
filePath: filePath,
|
|
101
|
+
content: fs_1.default.readFileSync(filePath, { encoding: 'utf8' })
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
return [2 /*return*/, commitFiles];
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
CommitLocalPackagesTask = __decorate([
|
|
109
|
+
inversify_1.injectable(),
|
|
110
|
+
__param(0, inversify_1.inject(types_1.SERVICES.GitLabService)),
|
|
111
|
+
__metadata("design:paramtypes", [services_1.GitLabService])
|
|
112
|
+
], CommitLocalPackagesTask);
|
|
113
|
+
return CommitLocalPackagesTask;
|
|
114
|
+
}());
|
|
115
|
+
exports.CommitLocalPackagesTask = CommitLocalPackagesTask;
|
|
116
|
+
// function getPackageJsonPaths(): string[] {
|
|
117
|
+
// const packageJsonPaths: string[] = [];
|
|
118
|
+
// // Walk through the file system and push the path of each package.json file to the array
|
|
119
|
+
// function findPackageJsonPathsInDirectory(startPath: string) {
|
|
120
|
+
// const files = fs.readdirSync(startPath);
|
|
121
|
+
// files.forEach(file => {
|
|
122
|
+
// const filename = path.join(startPath, file);
|
|
123
|
+
// const stat = fs.lstatSync(filename);
|
|
124
|
+
// if (stat.isDirectory())
|
|
125
|
+
// return findPackageJsonPathsInDirectory(filename);
|
|
126
|
+
// if (!filename.includes('package.json'))
|
|
127
|
+
// return;
|
|
128
|
+
// // Ignore any `package.json` files found under `node_modules`
|
|
129
|
+
// if (filename.includes('node_modules'))
|
|
130
|
+
// return;
|
|
131
|
+
// packageJsonPaths.push(filename);
|
|
132
|
+
// });
|
|
133
|
+
// };
|
|
134
|
+
// const packagesRoot = path.resolve(__dirname, '../../../packages');
|
|
135
|
+
// findPackageJsonPathsInDirectory(packagesRoot); // Start from the `/packages` folder
|
|
136
|
+
// return packageJsonPaths;
|
|
137
|
+
// }
|