@codiac.io/codiac-cli 1.2.172 → 1.2.174
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/README.md +1 -1
- package/lib/command-base-tenantless.js +7 -0
- package/lib/command-base-tenantless.js.map +1 -1
- package/lib/commands/build.d.ts +1 -0
- package/lib/commands/build.js +3 -2
- package/lib/commands/build.js.map +1 -1
- package/lib/commands/csp/login.js +11 -0
- package/lib/commands/csp/login.js.map +1 -1
- package/lib/commands/images/add.js +1 -1
- package/lib/commands/images/add.js.map +1 -1
- package/lib/commands/images/version/bump.d.ts +18 -0
- package/lib/commands/images/version/bump.js +61 -0
- package/lib/commands/images/version/bump.js.map +1 -0
- package/lib/commands/images/version.js +1 -1
- package/lib/commands/images/version.js.map +1 -1
- package/lib/ops/LocalOps.d.ts +4 -31
- package/lib/ops/LocalOps.js +94 -156
- package/lib/ops/LocalOps.js.map +1 -1
- package/lib/ops/test/when-versions-are-parsed.spec.js +8 -6
- package/lib/ops/test/when-versions-are-parsed.spec.js.map +1 -1
- package/lib/ops/workspace-versioner.d.ts +122 -0
- package/lib/ops/workspace-versioner.js +292 -0
- package/lib/ops/workspace-versioner.js.map +1 -0
- package/oclif.manifest.json +80 -4
- package/package.json +1 -1
package/lib/ops/LocalOps.js
CHANGED
|
@@ -11,7 +11,6 @@ const figlet = require("figlet");
|
|
|
11
11
|
const rimraf = require("rimraf");
|
|
12
12
|
const _ = require("lodash");
|
|
13
13
|
const escapeStringRegexp = require("escape-string-regexp");
|
|
14
|
-
const semver = require("semver");
|
|
15
14
|
const fse = require("fs-extra");
|
|
16
15
|
// Ours
|
|
17
16
|
const codiac_common_1 = require("@codiac.io/codiac-common");
|
|
@@ -28,6 +27,7 @@ const cli_context_repo_1 = require("./data/cli-context-repo");
|
|
|
28
27
|
const npm_config_repo_1 = require("./data/npm-config-repo");
|
|
29
28
|
const dx_constants_1 = require("./dx-constants");
|
|
30
29
|
const _1 = require(".");
|
|
30
|
+
const workspace_versioner_1 = require("./workspace-versioner");
|
|
31
31
|
let LocalOps = class LocalOps {
|
|
32
32
|
// constructor(private ioc: Container, public codiacVersion: string, private _projectRoot: string, private _cfgRepo: CliContextRepo, private ux: IUserInputProvider, private styler: IOutputStyler, private logger: IBetterLogger) {
|
|
33
33
|
// this._cliExec = new CliExec(logger);
|
|
@@ -121,6 +121,12 @@ let LocalOps = class LocalOps {
|
|
|
121
121
|
}
|
|
122
122
|
return this._logger;
|
|
123
123
|
}
|
|
124
|
+
get _workspaceVersioner() {
|
|
125
|
+
if (this.__workspaceVersioner === undefined) {
|
|
126
|
+
this.__workspaceVersioner = this.ioc.get(workspace_versioner_1.WorkspaceVersioner);
|
|
127
|
+
}
|
|
128
|
+
return this.__workspaceVersioner;
|
|
129
|
+
}
|
|
124
130
|
// --------------------------------------------------------------------
|
|
125
131
|
// END LAZY-LOADED PROPERTIES
|
|
126
132
|
// ====================================================================
|
|
@@ -1987,10 +1993,11 @@ let LocalOps = class LocalOps {
|
|
|
1987
1993
|
if (this.cliConfig.addBranchNameToPrereleases === true) {
|
|
1988
1994
|
let currentBranch = yield this.gitCurrentBranchNameFor(this._projectRoot);
|
|
1989
1995
|
if (this.isMainBranch(currentBranch) === false) {
|
|
1990
|
-
|
|
1996
|
+
increment.preId = currentBranch;
|
|
1997
|
+
// cfg.codeVersion = this.addPrereleaseId(cfg.codeVersion, currentBranch);
|
|
1991
1998
|
}
|
|
1992
1999
|
}
|
|
1993
|
-
let codeVersion = yield this.incrementCodeVersion(cfg, increment);
|
|
2000
|
+
let codeVersion = yield this._workspaceVersioner.incrementCodeVersion(cfg, increment);
|
|
1994
2001
|
yield this.npmIncrementVersion(increment);
|
|
1995
2002
|
}
|
|
1996
2003
|
}
|
|
@@ -2002,66 +2009,6 @@ let LocalOps = class LocalOps {
|
|
|
2002
2009
|
}));
|
|
2003
2010
|
});
|
|
2004
2011
|
}
|
|
2005
|
-
/** Prefixes the prerelease version segment
|
|
2006
|
-
* with the given prerelease identifier.
|
|
2007
|
-
*
|
|
2008
|
-
* using format: `[major].[minor].[patch]-[id].[prereleaseNumber]`
|
|
2009
|
-
*
|
|
2010
|
-
* eg: `1.2.3` remains `1.2.3`
|
|
2011
|
-
* eg: `1.2.3-4` becomes `1.2.3-thisBranch.4`
|
|
2012
|
-
* eg: `1.2.3-toro.4` becomes `1.2.3-thisBranch.4` */
|
|
2013
|
-
addPrereleaseId(version, prereleaseId) {
|
|
2014
|
-
let output = version;
|
|
2015
|
-
let parts = semver.parse(version);
|
|
2016
|
-
// let ultimateId = /[^\w\d\.-]/g.exec(id);
|
|
2017
|
-
let ultimateId = prereleaseId.replace(/[^\w\d\.-]|_/g, "-");
|
|
2018
|
-
console.log(ultimateId);
|
|
2019
|
-
if (parts) {
|
|
2020
|
-
let pre = parts.prerelease; // semver.prerelease(version);
|
|
2021
|
-
if (pre === null) {
|
|
2022
|
-
// CASE 0) no prerelease at all.
|
|
2023
|
-
}
|
|
2024
|
-
else {
|
|
2025
|
-
let newPre;
|
|
2026
|
-
let newBuild = [...parts.build];
|
|
2027
|
-
if (pre.length == 1) {
|
|
2028
|
-
if (typeof pre[0] === 'number') {
|
|
2029
|
-
// CASE 1) prerelease is a number
|
|
2030
|
-
output = `${ultimateId}.${pre[0]}`;
|
|
2031
|
-
newPre = [ultimateId, 0];
|
|
2032
|
-
newBuild = [];
|
|
2033
|
-
}
|
|
2034
|
-
else {
|
|
2035
|
-
// CASE 2) just a string body - no numeric suffix
|
|
2036
|
-
newPre = [ultimateId, 0];
|
|
2037
|
-
newBuild = [];
|
|
2038
|
-
}
|
|
2039
|
-
}
|
|
2040
|
-
else if (pre.length == 2) {
|
|
2041
|
-
// CASE 3) string body with numeric suffix
|
|
2042
|
-
if (pre[0] === ultimateId) {
|
|
2043
|
-
// CASE 3A) id already in prerelease
|
|
2044
|
-
newPre = [...pre]; // id is already in the prerelease; keep it as is.
|
|
2045
|
-
}
|
|
2046
|
-
else {
|
|
2047
|
-
// CASE 3B) given version has a diff prerelease id
|
|
2048
|
-
newPre = [ultimateId, 0];
|
|
2049
|
-
newBuild = [];
|
|
2050
|
-
}
|
|
2051
|
-
}
|
|
2052
|
-
else {
|
|
2053
|
-
// more than two segments in prerelease?
|
|
2054
|
-
// Is this the case when a build number is attached? eg: [id].[number]+[build]
|
|
2055
|
-
newPre = [...pre]; // not supporting this case yet...
|
|
2056
|
-
}
|
|
2057
|
-
output = `${parts.major}.${parts.minor}.${parts.patch}`;
|
|
2058
|
-
if (newPre.length > 0) {
|
|
2059
|
-
output = output.concat(`-${newPre.join(".")}${newBuild.length > 0 ? "+" + newBuild.join(".") : ""}`);
|
|
2060
|
-
}
|
|
2061
|
-
}
|
|
2062
|
-
}
|
|
2063
|
-
return output;
|
|
2064
|
-
}
|
|
2065
2012
|
/** Bumps the version as specified.
|
|
2066
2013
|
* NOTE!!! Currently uses npm for this!
|
|
2067
2014
|
*
|
|
@@ -2092,6 +2039,10 @@ let LocalOps = class LocalOps {
|
|
|
2092
2039
|
this.logger.notice(`Incrementing ${"patch"} version number...`);
|
|
2093
2040
|
yield this._cliExec.execAsyncStdOut(`npm version patch ${dontCommitIt}`, { cwd: this._projectRoot });
|
|
2094
2041
|
}
|
|
2042
|
+
else if (newVersion.preId) {
|
|
2043
|
+
this.logger.notice(`Incrementing ${"prerelease"} id and version number...`);
|
|
2044
|
+
yield this._cliExec.execAsyncStdOut(`npm version prerelease --preid ${newVersion.preId} ${dontCommitIt}`, { cwd: this._projectRoot });
|
|
2045
|
+
}
|
|
2095
2046
|
else if (newVersion.prerelease) {
|
|
2096
2047
|
this.logger.notice(`Incrementing ${"prerelease"} version number...`);
|
|
2097
2048
|
yield this._cliExec.execAsyncStdOut(`npm version prerelease ${dontCommitIt}`, { cwd: this._projectRoot });
|
|
@@ -2105,97 +2056,83 @@ let LocalOps = class LocalOps {
|
|
|
2105
2056
|
}));
|
|
2106
2057
|
});
|
|
2107
2058
|
}
|
|
2108
|
-
/** Increments the project code version number by the given increment.
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
incrementCodeVersion(cfg, increment) {
|
|
2116
|
-
|
|
2117
|
-
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
|
|
2134
|
-
|
|
2135
|
-
|
|
2136
|
-
|
|
2137
|
-
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
|
|
2141
|
-
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
|
|
2148
|
-
|
|
2149
|
-
|
|
2150
|
-
|
|
2151
|
-
|
|
2152
|
-
|
|
2153
|
-
|
|
2154
|
-
|
|
2155
|
-
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
2159
|
-
|
|
2160
|
-
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
|
|
2166
|
-
|
|
2167
|
-
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
}
|
|
2186
|
-
else if (increment.prerelease) {
|
|
2187
|
-
this.logger.notice(`Incrementing ${"prerelease"} version number...`);
|
|
2188
|
-
newVersion = semver.inc(existing, "prerelease");
|
|
2189
|
-
}
|
|
2190
|
-
if (newVersion == null)
|
|
2191
|
-
throw new contracts_1.CodiacError(`Cannot increment; current version number [${existing}] is not a valid semantic version.`);
|
|
2192
|
-
}
|
|
2193
|
-
return newVersion;
|
|
2194
|
-
}
|
|
2195
|
-
catch (err) {
|
|
2196
|
-
throw err;
|
|
2197
|
-
}
|
|
2198
|
-
}
|
|
2059
|
+
// /** Increments the project code version number by the given increment.
|
|
2060
|
+
// * Retains existing version number if no increment is specified.
|
|
2061
|
+
// * Writes changes to the project config (aka: codiac.json).
|
|
2062
|
+
// * Throws if existing version is invalid.
|
|
2063
|
+
// *
|
|
2064
|
+
// * @param cfg Project config doc (aka: codiac.json deserialized)
|
|
2065
|
+
// */
|
|
2066
|
+
// private async incrementCodeVersion(cfg: ProjectConfig, increment: VersionBump): Promise<ProjectConfig> {
|
|
2067
|
+
// return new Promise<ProjectConfig>(async (resolve, reject) => {
|
|
2068
|
+
// try {
|
|
2069
|
+
// let newVersion = this._imageVersioner.incrementVersion(cfg.codeVersion, increment);
|
|
2070
|
+
// if (newVersion != cfg.codeVersion) {
|
|
2071
|
+
// cfg.codeVersion = newVersion;
|
|
2072
|
+
// await this._projCfgRepo.updateProjectConfigFile(cfg);
|
|
2073
|
+
// }
|
|
2074
|
+
// resolve(cfg);
|
|
2075
|
+
// } catch (err) {
|
|
2076
|
+
// reject(err);
|
|
2077
|
+
// }
|
|
2078
|
+
// });
|
|
2079
|
+
// }
|
|
2080
|
+
// /** Increments the version number of the given image export by the given increment.
|
|
2081
|
+
// * Retains existing version number if no increment is specified.
|
|
2082
|
+
// * Sets to the default init version number if the imageExport doesnt yet have a version declared.
|
|
2083
|
+
// * Writes changes to the project config (aka: codiac.json).
|
|
2084
|
+
// * Throws if existing version is invalid.
|
|
2085
|
+
// *
|
|
2086
|
+
// * @param cfg Project config doc (aka: codiac.json deserialized)
|
|
2087
|
+
// */
|
|
2088
|
+
// private async incrementImageVersion(imageExport: ImageExport, cfg: ProjectConfig, increment: VersionBump): Promise<ImageExport> {
|
|
2089
|
+
// return new Promise<ImageExport>(async (resolve, reject) => {
|
|
2090
|
+
// try {
|
|
2091
|
+
// if (!imageExport.version) imageExport.version = DxConstants.DEFAULT_INIT_IMAGE_VERSION;
|
|
2092
|
+
// let newVersion = this.incrementVersion(imageExport.version, increment);
|
|
2093
|
+
// if (newVersion != imageExport.version) {
|
|
2094
|
+
// imageExport.version = newVersion;
|
|
2095
|
+
// if (!cfg.images) cfg.images = {};
|
|
2096
|
+
// cfg.images[imageExport.name] = imageExport;
|
|
2097
|
+
// await this._projCfgRepo.updateProjectConfigFile(cfg);
|
|
2098
|
+
// }
|
|
2099
|
+
// resolve(imageExport);
|
|
2100
|
+
// } catch (err) {
|
|
2101
|
+
// reject(err);
|
|
2102
|
+
// }
|
|
2103
|
+
// });
|
|
2104
|
+
// }
|
|
2105
|
+
// /** Increments the given semantic version nnumber by the given increment.
|
|
2106
|
+
// * Returns existing version number if no increment is specified.
|
|
2107
|
+
// * Throws if existing version is invalid.
|
|
2108
|
+
// */
|
|
2109
|
+
// public incrementVersion(existing: string, increment: VersionBump): string {
|
|
2110
|
+
// try {
|
|
2111
|
+
// let newVersion: string | null = existing;
|
|
2112
|
+
// if (increment) {
|
|
2113
|
+
// if (increment.fullName) {
|
|
2114
|
+
// this.logger.notice(`Applying new version number ${this.styler.hilite(increment.fullName)}...`);
|
|
2115
|
+
// newVersion = increment.fullName;
|
|
2116
|
+
// } else if (increment.major) {
|
|
2117
|
+
// this.logger.notice(`Incrementing ${"major"} version number...`);
|
|
2118
|
+
// newVersion = semver.inc(existing, "major");
|
|
2119
|
+
// } else if (increment.minor) {
|
|
2120
|
+
// this.logger.notice(`Incrementing ${"minor"} version number...`);
|
|
2121
|
+
// newVersion = semver.inc(existing, "minor");
|
|
2122
|
+
// } else if (increment.patch) {
|
|
2123
|
+
// this.logger.notice(`Incrementing ${"patch"} version number...`);
|
|
2124
|
+
// newVersion = semver.inc(existing, "patch");
|
|
2125
|
+
// } else if (increment.prerelease) {
|
|
2126
|
+
// this.logger.notice(`Incrementing ${"prerelease"} version number...`);
|
|
2127
|
+
// newVersion = semver.inc(existing, "prerelease");
|
|
2128
|
+
// }
|
|
2129
|
+
// if (newVersion == null) throw new CodiacError(`Cannot increment; current version number [${existing}] is not a valid semantic version.`);
|
|
2130
|
+
// }
|
|
2131
|
+
// return newVersion;
|
|
2132
|
+
// } catch (err) {
|
|
2133
|
+
// throw err;
|
|
2134
|
+
// }
|
|
2135
|
+
// }
|
|
2199
2136
|
/**
|
|
2200
2137
|
* @param subm The sourced dependency project to build.
|
|
2201
2138
|
* @param clear (Optional: defaults to false) Clears the output folder before build.
|
|
@@ -2339,10 +2276,11 @@ let LocalOps = class LocalOps {
|
|
|
2339
2276
|
if (this.cliConfig.addBranchNameToPrereleases === true) {
|
|
2340
2277
|
let currentBranch = yield this.gitCurrentBranchNameFor(this._projectRoot);
|
|
2341
2278
|
if (this.isMainBranch(currentBranch) === false) {
|
|
2342
|
-
|
|
2279
|
+
versionBump.preId = currentBranch;
|
|
2280
|
+
// imageExport.version = this.addPrereleaseId(imageExport.version, currentBranch);
|
|
2343
2281
|
}
|
|
2344
2282
|
}
|
|
2345
|
-
imageExport = yield this.incrementImageVersion(imageExport, cfg, versionBump);
|
|
2283
|
+
imageExport = yield this._workspaceVersioner.incrementImageVersion(imageExport, cfg, versionBump);
|
|
2346
2284
|
}
|
|
2347
2285
|
let versionStamp = imageExport.version || projectVersion; // <---- ImageExports can have their own versions, otherwise fall back to project code version.
|
|
2348
2286
|
yield this.buildSingleImage(imageExport, versionStamp, noCache, buildContext, targetStage);
|