mirror of https://github.com/abpframework/abp.git
committed by
GitHub
11 changed files with 285 additions and 32 deletions
@ -0,0 +1,51 @@ |
|||||
|
param( |
||||
|
[string]$Version, |
||||
|
[string]$Registry |
||||
|
) |
||||
|
|
||||
|
yarn install |
||||
|
|
||||
|
$NextVersion = $(node publish-utils.js --nextVersion) |
||||
|
$RootFolder = (Get-Item -Path "./" -Verbose).FullName |
||||
|
|
||||
|
if (-Not $Version) { |
||||
|
$Version = $NextVersion; |
||||
|
} |
||||
|
|
||||
|
if (-Not $Registry) { |
||||
|
$Registry = "https://registry.npmjs.org"; |
||||
|
} |
||||
|
|
||||
|
$PacksPublishCommand = "npm run lerna -- exec 'npm publish --registry $Registry'" |
||||
|
|
||||
|
$IsPrerelase = $(node publish-utils.js --prerelase --customVersion $Version) -eq "true"; |
||||
|
|
||||
|
if ($IsPrerelase) { |
||||
|
$PacksPublishCommand = $PacksPublishCommand.Substring(0, $PacksPublishCommand.Length - 1) + " --tag next'" |
||||
|
} |
||||
|
|
||||
|
$commands = ( |
||||
|
"npm run lerna -- version $Version --yes --no-commit-hooks --skip-git --force-publish", |
||||
|
"yarn replace-with-tilde", |
||||
|
"cd scripts", |
||||
|
"yarn install", |
||||
|
"yarn validate-versions --compareVersion $Version --path ../packs", |
||||
|
"cd ..", |
||||
|
$PacksPublishCommand |
||||
|
) |
||||
|
|
||||
|
foreach ($command in $commands) { |
||||
|
$timer = [System.Diagnostics.Stopwatch]::StartNew() |
||||
|
Write-Host $command |
||||
|
Invoke-Expression $command |
||||
|
if ($LASTEXITCODE -ne '0' -And $command -notlike '*cd *') { |
||||
|
Write-Host ("Process failed! " + $command) |
||||
|
Set-Location $RootFolder |
||||
|
exit $LASTEXITCODE |
||||
|
} |
||||
|
$timer.Stop() |
||||
|
$total = $timer.Elapsed |
||||
|
Write-Output "-------------------------" |
||||
|
Write-Output "$command command took $total (Hours:Minutes:Seconds.Milliseconds)" |
||||
|
Write-Output "-------------------------" |
||||
|
} |
||||
@ -0,0 +1,81 @@ |
|||||
|
import axios from 'axios'; |
||||
|
import { program } from 'commander'; |
||||
|
import fse from 'fs-extra'; |
||||
|
import * as path from 'path'; |
||||
|
|
||||
|
(async () => { |
||||
|
initCommander(); |
||||
|
await checkPackages(); |
||||
|
})(); |
||||
|
|
||||
|
function initCommander() { |
||||
|
program |
||||
|
.requiredOption('-v, --compareVersion <version>', 'version to compare') |
||||
|
.requiredOption( |
||||
|
'-ra, --reportApi <report-api-url>', |
||||
|
'api url to report status' |
||||
|
) |
||||
|
.requiredOption( |
||||
|
'-ak, --accessKey <access-key>', |
||||
|
'access key to use for report api' |
||||
|
) |
||||
|
.requiredOption( |
||||
|
'-tc, --targetChannel <target-channel>', |
||||
|
'target channel to send message' |
||||
|
); |
||||
|
|
||||
|
program.parse(process.argv); |
||||
|
} |
||||
|
|
||||
|
async function checkPackages() { |
||||
|
const pkgJsonPaths = [ |
||||
|
...fse |
||||
|
.readdirSync('../packs') |
||||
|
.map((folder) => path.resolve(`../packs/${folder}/package.json`)), |
||||
|
...fse |
||||
|
.readdirSync('../ng-packs/packages') |
||||
|
.map((folder) => |
||||
|
path.resolve(`../ng-packs/packages/${folder}/package.json`) |
||||
|
), |
||||
|
, |
||||
|
]; |
||||
|
|
||||
|
const packageNames = pkgJsonPaths |
||||
|
.map((pkgJsonPath) => fse.readJSONSync(pkgJsonPath).name) |
||||
|
.filter((pkg) => !!pkg); |
||||
|
|
||||
|
const { compareVersion } = program.opts(); |
||||
|
|
||||
|
let discordMessage = `NPM Packages Publish Status\nVersion: **${compareVersion}**\n\n`; |
||||
|
|
||||
|
for (let i = 0; i < packageNames.length; i++) { |
||||
|
const packageName = packageNames[i]; |
||||
|
|
||||
|
const lastVersion = await axios |
||||
|
.get(`https://registry.npmjs.org/${packageName}`) |
||||
|
.then((res) => { |
||||
|
const versions = Object.keys(res.data.time); |
||||
|
return versions[versions.length - 1]; |
||||
|
}); |
||||
|
|
||||
|
let message; |
||||
|
if (lastVersion === compareVersion) { |
||||
|
message = `${packageName}: :ballot_box_with_check:\n`; |
||||
|
} else { |
||||
|
message = `${packageName}: :x:\n`; |
||||
|
} |
||||
|
|
||||
|
discordMessage += message; |
||||
|
console.log( |
||||
|
message.replace(':ballot_box_with_check:', '✔️').replace(':x', '✖️') |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
const { reportApi, targetChannel, accessKey } = program.opts(); |
||||
|
|
||||
|
await axios.post(reportApi, { |
||||
|
accessKey, |
||||
|
targetChannel, |
||||
|
message: discordMessage, |
||||
|
}); |
||||
|
} |
||||
@ -0,0 +1,82 @@ |
|||||
|
import { program } from 'commander'; |
||||
|
import fse from 'fs-extra'; |
||||
|
import * as path from 'path'; |
||||
|
import { log } from './utils/log'; |
||||
|
|
||||
|
let excludedPackages = []; |
||||
|
|
||||
|
(async () => { |
||||
|
initCommander(); |
||||
|
await compare(); |
||||
|
})(); |
||||
|
|
||||
|
function initCommander() { |
||||
|
program.requiredOption( |
||||
|
'-v, --compareVersion <version>', |
||||
|
'version to compare' |
||||
|
); |
||||
|
program.requiredOption('-p, --path <path>', 'NPM packages folder path'); |
||||
|
program.option( |
||||
|
'-ep, --excludedPackages <excludedpackages>', |
||||
|
'Packages that will not be checked. Can be passed with separeted comma (like @abp/utils,@abp/core)', |
||||
|
'' |
||||
|
); |
||||
|
program.parse(process.argv); |
||||
|
|
||||
|
excludedPackages = program.opts().excludedPackages.split(','); |
||||
|
} |
||||
|
|
||||
|
async function compare() { |
||||
|
let { compareVersion, path: packagesPath } = program.opts(); |
||||
|
packagesPath = path.resolve(packagesPath); |
||||
|
const packageFolders = await fse.readdir(packagesPath); |
||||
|
|
||||
|
for (let i = 0; i < packageFolders.length; i++) { |
||||
|
const folder = packageFolders[i]; |
||||
|
const pkgJsonPath = `${packagesPath}/${folder}/package.json`; |
||||
|
let pkgJson; |
||||
|
try { |
||||
|
pkgJson = await fse.readJSON(pkgJsonPath); |
||||
|
} catch (error) {} |
||||
|
|
||||
|
if ( |
||||
|
!excludedPackages.includes(pkgJson.name) && |
||||
|
pkgJson.version !== compareVersion |
||||
|
) { |
||||
|
throwError(pkgJsonPath, pkgJson.name); |
||||
|
} |
||||
|
|
||||
|
const { dependencies, peerDependencies } = pkgJson; |
||||
|
if (dependencies) await compareDependencies(dependencies, pkgJsonPath); |
||||
|
// if (peerDependencies) { // TODO: update peerDependencies while updating version
|
||||
|
// await compareDependencies(peerDependencies, pkgJsonPath);
|
||||
|
// }
|
||||
|
} |
||||
|
} |
||||
|
|
||||
|
async function compareDependencies( |
||||
|
dependencies: Record<string, string>, |
||||
|
filePath: string |
||||
|
) { |
||||
|
const { compareVersion } = program.opts(); |
||||
|
const entries = Object.entries(dependencies); |
||||
|
|
||||
|
for (let i = 0; i < entries.length; i++) { |
||||
|
const entry = entries[i]; |
||||
|
|
||||
|
if ( |
||||
|
!excludedPackages.includes(entry[0]) && |
||||
|
entry[0].match(/@(abp|volo)/)?.length && |
||||
|
entry[1] !== `~${compareVersion}` |
||||
|
) { |
||||
|
throwError(filePath, entry[0], `~${compareVersion}`); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
function throwError(filePath: string, pkg: string, version?: string) { |
||||
|
const { compareVersion } = program.opts(); |
||||
|
|
||||
|
log.error(`${filePath}: ${pkg} version is not ${version || compareVersion}`); |
||||
|
process.exit(1); |
||||
|
} |
||||
Loading…
Reference in new issue