scripts/release.js
function versionRelease(version) {
    return new Promise((resolve, reject) => {
        const [pkgPath, pkg] = getPackageObject();
        const bumpVersion = (version, isReleaseType, throwOnEqual) => {
            const newVersion = isReleaseType ? semver.inc(pkg.version, version) : semver.valid(version);

            if (newVersion === null) {
                reject(new Error(`version must be one of: "recommended", first", major", "minor", "patch", or a semantic version`));
                return;
            }

            if (throwOnEqual && semver.eq(pkg.version, newVersion)) {
                reject(new Error(`version to be bumped is equal to package version: ${newVersion}`));
                return;
            }

            const oldVersion = pkg.version;
            pkg.version = newVersion;

            try {
                fs.writeFileSync(pkgPath, JSON.stringify(pkg, undefined, tabAsSpace));

                // Update version in package-lock file
                const [pkgLckPath, pkgLck] = getPackageObject(undefined, "package-lock.json");
                pkgLck.version = newVersion;
                fs.writeFileSync(pkgLckPath, JSON.stringify(pkgLck, undefined, tabAsSpace));
            } catch (err) {
                reject(new Error(`version couldn't be bumped: ${err.message}`));
                return;
            }

            resolve(`bumped from ${oldVersion} to ${newVersion}`);
        };

        if (version === "recommended") {
            conventionalRecommendedBump({
                preset: "angular"
            }, (err, result) => {
                if (err) {
                    reject(new Error(`conventional recommended bump failed: ${err.message}`));
                    return;
                }
                bumpVersion(result.releaseType, true, true);
            });
            return;
        }

        if (version === "first") {
            bumpVersion(pkg.version, false, false);
            return;
        }

        const isReleaseType = version === "major" || version === "minor" || version === "patch";
        bumpVersion(version, isReleaseType, true);
    });
}
function versionRelease(version) {
    return new Promise((resolve, reject) => {
        const [pkgPath, pkg] = getPackageObject();
        const bumpVersion = (version, isReleaseType, throwOnEqual) => {
            const newVersion = isReleaseType ? semver.inc(pkg.version, version) : semver.valid(version);

            if (newVersion === null) {
                reject(new Error(`version must be one of: "recommended", first", major", "minor", "patch", or a semantic version`));
                return;
            }

            if (throwOnEqual && semver.eq(pkg.version, newVersion)) {
                reject(new Error(`version to be bumped is equal to package version: ${newVersion}`));
                return;
            }

            const oldVersion = pkg.version;
            pkg.version = newVersion;

            try {
                fs.writeFileSync(pkgPath, JSON.stringify(pkg, undefined, tabAsSpace));

                // Update version in package-lock file
                const [pkgLckPath, pkgLck] = getPackageObject(undefined, "package-lock.json");
                pkgLck.version = newVersion;
                fs.writeFileSync(pkgLckPath, JSON.stringify(pkgLck, undefined, tabAsSpace));
            } catch (err) {
                reject(new Error(`version couldn't be bumped: ${err.message}`));
                return;
            }

            resolve(`bumped from ${oldVersion} to ${newVersion}`);
        };

        if (version === "recommended") {
            conventionalRecommendedBump({
                preset: "angular"
            }, (err, result) => {
                if (err) {
                    reject(new Error(`conventional recommended bump failed: ${err.message}`));
                    return;
                }
                bumpVersion(result.releaseType, true, true);
            });
            return;
        }

        if (version === "first") {
            bumpVersion(pkg.version, false, false);
            return;
        }

        const isReleaseType = version === "major" || version === "minor" || version === "patch";
        bumpVersion(version, isReleaseType, true);
    });
}
function versionRelease ( version ) { return new Promise ( ( resolve , reject ) => { const [ pkgPath , pkg ] = getPackageObject ( ) ; const bumpVersion = ( version , isReleaseType , throwOnEqual ) => { const newVersion = isReleaseType ? semver . inc ( pkg . version , version ) : semver . valid ( version ) ; if ( newVersion === null ) { reject ( new Error ( ` ` ) ) ; return ; } if ( throwOnEqual && semver . eq ( pkg . version , newVersion ) ) { reject ( new Error ( ` ${ newVersion } ` ) ) ; return ; } const oldVersion = pkg . version ; pkg . version = newVersion ; try { fs . writeFileSync ( pkgPath , JSON . stringify ( pkg , undefined , tabAsSpace ) ) ; // Update version in package-lock file const [ pkgLckPath , pkgLck ] = getPackageObject ( undefined , "package-lock.json" ) ; pkgLck . version = newVersion ; fs . writeFileSync ( pkgLckPath , JSON . stringify ( pkgLck , undefined , tabAsSpace ) ) ; } catch ( err ) { reject ( new Error ( ` ${ err . message } ` ) ) ; return ; } resolve ( ` ${ oldVersion } ${ newVersion } ` ) ; } ; if ( version === "recommended" ) { conventionalRecommendedBump ( { preset : "angular" } , ( err , result ) => { if ( err ) { reject ( new Error ( ` ${ err . message } ` ) ) ; return ; } bumpVersion ( result . releaseType , true , true ) ; } ) ; return ; } if ( version === "first" ) { bumpVersion ( pkg . version , false , false ) ; return ; } const isReleaseType = version === "major" || version === "minor" || version === "patch" ; bumpVersion ( version , isReleaseType , true ) ; } ) ; }
Automatically bumps the package version according to the
specified version parameter.

The given version parameter can have the following values:
"recommended", "first", major", "minor", "patch", or a valid
semantic version string.

If the version is `recommended`, a recommended version bump is computed based
on conventional commits. An error is reported, if the recommended version
cannot be computed because there are no commits for this release at all.

If the version is "first", the package version is bumped to
the current version specified in package.json.

If the version is "major", "minor" or "patch", the
package version is incremented to the next major, minor, or
patch version, respectively.

If the version is a valid semantic version string, the
package version is bumped to this version.

In any of the above cases except "first", an error is reported
if the new version to be bumped is equal to the current package version.

Returns a promise that resolves to the bumped version, or a promise
that is rejected in case an error occured.
Automatically bumps the package version according to the specified version parameter .