mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Only set build metadata on build
Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
parent
6b464a873b
commit
73f184fa54
@ -19,64 +19,28 @@
|
|||||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
import * as fse from "fs-extra";
|
import * as fse from "fs-extra";
|
||||||
import * as path from "path";
|
|
||||||
import appInfo from "../package.json";
|
|
||||||
import semver from "semver";
|
|
||||||
import fastGlob from "fast-glob";
|
import fastGlob from "fast-glob";
|
||||||
|
|
||||||
const packagePath = path.join(__dirname, "../package.json");
|
function writeJson(filePath: string, oldContents: any, version: string) {
|
||||||
const versionInfo = semver.parse(appInfo.version);
|
return fse.writeJson(filePath, { ...oldContents, version }, { spaces: 2 });
|
||||||
const buildNumber = process.env.BUILD_NUMBER || Date.now().toString();
|
|
||||||
|
|
||||||
function getBuildChannel(): string {
|
|
||||||
/**
|
|
||||||
* Note: it is by design that we don't use `rc` as a build channel for these versions
|
|
||||||
*/
|
|
||||||
switch (versionInfo.prerelease?.[0]) {
|
|
||||||
case "beta":
|
|
||||||
return "beta";
|
|
||||||
case undefined:
|
|
||||||
return "latest";
|
|
||||||
default:
|
|
||||||
return "alpha";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function writeOutExtensionVersion(manifestPath: string) {
|
async function main() {
|
||||||
const extensionPackageJson = await fse.readJson(manifestPath);
|
const extensionPaths = await fastGlob(["extensions/*/package.json"]);
|
||||||
|
const packageJson = await fse.readJson("package.json");
|
||||||
|
const version = `${packageJson.version}+${process.env.BUILD_NUMBER || Date.now().toString()}`;
|
||||||
|
|
||||||
extensionPackageJson.version = appInfo.version;
|
await writeJson("package.json", packageJson, version);
|
||||||
|
|
||||||
return fse.writeJson(manifestPath, extensionPackageJson, {
|
async function modifyPackageVersion(filePath: string) {
|
||||||
spaces: 2,
|
return writeJson(filePath, await fse.readJson(filePath), version);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Promise.all(extensionPaths.map(modifyPackageVersion));
|
||||||
|
}
|
||||||
|
|
||||||
|
main()
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
process.exit(1);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
|
|
||||||
async function writeOutNewVersions() {
|
|
||||||
await Promise.all([
|
|
||||||
fse.writeJson(packagePath, appInfo, {
|
|
||||||
spaces: 2,
|
|
||||||
}),
|
|
||||||
...(await fastGlob(["extensions/*/package.json"])).map(writeOutExtensionVersion),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function main() {
|
|
||||||
const prereleaseParts: string[] = [getBuildChannel()];
|
|
||||||
|
|
||||||
if (versionInfo.prerelease) {
|
|
||||||
prereleaseParts.push(versionInfo.prerelease[1].toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
prereleaseParts.push(buildNumber);
|
|
||||||
|
|
||||||
appInfo.version = `${versionInfo.major}.${versionInfo.minor}.${versionInfo.patch}-${prereleaseParts.join(".")}`;
|
|
||||||
|
|
||||||
writeOutNewVersions()
|
|
||||||
.catch((error) => {
|
|
||||||
console.error(error);
|
|
||||||
process.exit(1);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
main();
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user