handle prerelase identifiers

pull/10098/head
Mehmet Erim 3 years ago
parent 92c5f61348
commit a7d8017d68

@ -11,7 +11,6 @@ program
)
.option('-r, --registry <registry>', 'target npm server registry')
.option('-p, --preview', 'publishes with preview tag')
.option('-r, --rc', 'publishes with next tag')
.option('-g, --skipGit', 'skips git push');
program.parse(process.argv);
@ -51,7 +50,7 @@ program.parse(process.argv);
let tag: string;
if (program.preview) tag = 'preview';
else if (program.rc || semverParse(program.nextVersion).prerelease?.length) tag = 'next';
else if (semverParse(program.nextVersion).prerelease?.length) tag = 'next';
await execa(
'yarn',

@ -1,39 +1,39 @@
const glob = require('glob');
var path = require('path');
const childProcess = require('child_process');
const { program } = require('commander');
const glob = require("glob");
var path = require("path");
const childProcess = require("child_process");
const { program } = require("commander");
program.version('0.0.1');
program.option('-r, --rc', 'whether version is rc');
program.option('-rg, --registry <registry>', 'target npm server registry')
program.version("0.0.1");
program.option("-r, --prerelase", "whether version is prerelase");
program.option("-rg, --registry <registry>", "target npm server registry");
program.parse(process.argv);
const packages = (process.argv[3] || 'abp').split(',').join('|');
const packages = (process.argv[3] || "abp").split(",").join("|");
const check = (pkgJsonPath) => {
try {
return childProcess
.execSync(
`ncu "/^@(${packages}).*$/" --packageFile ${pkgJsonPath} -u${
program.rc ? ' --target greatest' : ''
}${program.registry ? ` --registry ${program.registry}` : ''}`
program.prerelase ? " --target greatest" : ""
}${program.registry ? ` --registry ${program.registry}` : ""}`
)
.toString();
} catch (error) {
console.log('exec error: ' + error.message);
console.log("exec error: " + error.message);
process.exit(error.status);
}
};
const folder = process.argv[2] || '.';
const folder = process.argv[2] || ".";
glob(folder + '/**/package.json', {}, (er, files) => {
glob(folder + "/**/package.json", {}, (er, files) => {
files.forEach((file) => {
if (
file.includes('node_modules') ||
file.includes('ng-packs/dist') ||
file.includes('wwwroot') ||
file.includes('bin/Debug')
file.includes("node_modules") ||
file.includes("ng-packs/dist") ||
file.includes("wwwroot") ||
file.includes("bin/Debug")
) {
return;
}

@ -16,6 +16,7 @@
"dependencies": {
"commander": "^6.0.0",
"execa": "^3.4.0",
"fs-extra": "^8.1.0"
"fs-extra": "^8.1.0",
"semver": "^7.3.5"
}
}

@ -1,22 +1,24 @@
const { program } = require('commander');
const fse = require('fs-extra');
const { program } = require("commander");
const fse = require("fs-extra");
const semverParse = require("semver/functions/parse");
program.version('0.0.1');
program.option('-n, --nextVersion', 'version in common.props');
program.option('-r, --rc', 'whether version is rc');
program.option('-cv, --customVersion <customVersion>', 'set exact version');
program.version("0.0.1");
program.option("-n, --nextVersion", "version in common.props");
program.option("-pr, --prerelase", "whether version is prerelase");
program.option("-cv, --customVersion <customVersion>", "set exact version");
program.parse(process.argv);
if (program.nextVersion) console.log(getVersion());
if (program.rc) console.log(getVersion().includes('rc'));
if (program.prerelase)
console.log(!!semverParse(getVersion()).prerelease?.length);
function getVersion() {
if (program.customVersion) return program.customVersion;
const commonProps = fse.readFileSync('../common.props').toString();
const versionTag = '<Version>';
const versionEndTag = '</Version>';
const commonProps = fse.readFileSync("../common.props").toString();
const versionTag = "<Version>";
const versionEndTag = "</Version>";
const first = commonProps.indexOf(versionTag) + versionTag.length;
const last = commonProps.indexOf(versionEndTag);
return commonProps.substring(first, last);

@ -3,7 +3,7 @@ param(
[string]$Registry
)
npm install
yarn install
$NextVersion = $(node publish-utils.js --nextVersion)
$RootFolder = (Get-Item -Path "./" -Verbose).FullName
@ -21,13 +21,12 @@ $PacksPublishCommand = "npm run lerna -- exec 'npm publish --registry $Registry'
$UpdateGulpCommand = "npm run update-gulp"
$UpdateNgPacksCommand = "yarn update --registry $Registry"
$IsRc = $(node publish-utils.js --rc --customVersion $Version) -eq "true";
$IsPrerelase = $(node publish-utils.js --prerelase --customVersion $Version) -eq "true";
if ($IsRc) {
$NgPacksPublishCommand += " --rc"
$UpdateGulpCommand += " -- --rc"
if ($IsPrerelase) {
$UpdateGulpCommand += " -- --prerelase"
$PacksPublishCommand = $PacksPublishCommand.Substring(0, $PacksPublishCommand.Length - 1) + " --tag next'"
$UpdateNgPacksCommand += " --rc"
$UpdateNgPacksCommand += " --prerelase"
}
$commands = (
@ -36,7 +35,7 @@ $commands = (
$PacksPublishCommand,
$UpdateNgPacksCommand,
"cd ng-packs\scripts",
"npm install",
"yarn install",
$NgPacksPublishCommand,
"cd ../../",
"cd scripts",

@ -1,27 +1,27 @@
const glob = require('glob');
var path = require('path');
const childProcess = require('child_process');
const execa = require('execa');
const fse = require('fs-extra');
const { program } = require('commander');
const glob = require("glob");
var path = require("path");
const childProcess = require("child_process");
const execa = require("execa");
const fse = require("fs-extra");
const { program } = require("commander");
program.version('0.0.1');
program.option('-r, --rc', 'whether version is rc');
program.version("0.0.1");
program.option("-pr, --prerelase", "whether version is prerelase");
program.parse(process.argv);
const gulp = (folderPath) => {
if (
!fse.existsSync(folderPath + 'gulpfile.js') ||
!glob.sync(folderPath + '*.csproj').length
!fse.existsSync(folderPath + "gulpfile.js") ||
!glob.sync(folderPath + "*.csproj").length
) {
return;
}
try {
execa.sync(`yarn`, ['install'], { cwd: folderPath, stdio: 'inherit' });
execa.sync(`yarn`, ['gulp'], { cwd: folderPath, stdio: 'inherit' });
execa.sync(`yarn`, ["install"], { cwd: folderPath, stdio: "inherit" });
execa.sync(`yarn`, ["gulp"], { cwd: folderPath, stdio: "inherit" });
} catch (error) {
console.log('\x1b[31m', 'Error: ' + error.message);
console.log("\x1b[31m", "Error: " + error.message);
}
};
@ -30,30 +30,30 @@ const updatePackages = (pkgJsonPath) => {
const result = childProcess
.execSync(
`ncu "/^@abp.*$/" --packageFile ${pkgJsonPath} -u${
program.rc ? ' --target greatest' : ''
program.prerelase ? " --target greatest" : ""
}`
)
.toString();
console.log('\x1b[0m', result);
console.log("\x1b[0m", result);
} catch (error) {
console.log('\x1b[31m', 'Error: ' + error.message);
console.log("\x1b[31m", "Error: " + error.message);
}
};
console.time();
glob('../**/package.json', {}, (er, files) => {
glob("../**/package.json", {}, (er, files) => {
files = files.filter(
(f) =>
f &&
!f.includes('node_modules') &&
!f.includes('wwwroot') &&
!f.includes('bin') &&
!f.includes('obj')
!f.includes("node_modules") &&
!f.includes("wwwroot") &&
!f.includes("bin") &&
!f.includes("obj")
);
files.forEach((file) => {
updatePackages(file);
gulp(file.replace('package.json', ''));
gulp(file.replace("package.json", ""));
});
console.timeEnd();
});

Loading…
Cancel
Save