diff --git a/npm/ng-packs/packages/.gitkeep b/npm/ng-packs/packages/.gitkeep deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/npm/ng-packs/packages/components/package.json b/npm/ng-packs/packages/components/package.json index 0f82063aa4..1a0102dd49 100644 --- a/npm/ng-packs/packages/components/package.json +++ b/npm/ng-packs/packages/components/package.json @@ -7,8 +7,8 @@ "url": "https://github.com/abpframework/abp.git" }, "peerDependencies": { - "@abp/ng.core": ">=5.0.0-beta.1-1", - "@abp/ng.theme.shared": ">=5.0.0-beta.1-1", + "@abp/ng.core": ">=5.0.0-beta.2", + "@abp/ng.theme.shared": ">=5.0.0-beta.2", "@ng-bootstrap/ng-bootstrap": ">=6.0.0" }, "dependencies": { diff --git a/npm/ng-packs/packages/core/package.json b/npm/ng-packs/packages/core/package.json index 9571c94e7b..5181701447 100644 --- a/npm/ng-packs/packages/core/package.json +++ b/npm/ng-packs/packages/core/package.json @@ -7,7 +7,7 @@ "url": "https://github.com/abpframework/abp.git" }, "dependencies": { - "@abp/utils": "^5.0.0-beta.2", + "@abp/utils": "~5.0.0-beta.2", "angular-oauth2-oidc": "^12.1.0", "just-clone": "^3.2.1", "just-compare": "^1.4.0", diff --git a/npm/ng-packs/scripts/publish.ts b/npm/ng-packs/scripts/publish.ts index ecc0408f2b..2ad098236c 100644 --- a/npm/ng-packs/scripts/publish.ts +++ b/npm/ng-packs/scripts/publish.ts @@ -11,7 +11,8 @@ program ) .option('-r, --registry ', 'target npm server registry') .option('-p, --preview', 'publishes with preview tag') - .option('-g, --skipGit', 'skips git push'); + .option('-sg, --skipGit', 'skips git push') + .option('-sv, --skipVersionValidation', 'skips version validation'); program.parse(process.argv); @@ -34,6 +35,20 @@ program.parse(process.argv); await updateVersion(program.nextVersion); + if (!program.skipVersionValidation) { + await execa( + 'yarn', + [ + 'validate-versions', + '--compareVersion', + program.nextVersion, + '--path', + '../ng-packs/packages', + ], + { stdout: 'inherit', cwd: '../../scripts' }, + ); + } + if (program.preview) await replaceWithPreview(program.nextVersion); await execa('yarn', ['build', '--noInstall', '--skipNgcc'], { stdout: 'inherit' }); diff --git a/npm/packs/core/package.json b/npm/packs/core/package.json index 67647f3f79..c925a8bdb0 100644 --- a/npm/packs/core/package.json +++ b/npm/packs/core/package.json @@ -10,7 +10,7 @@ "access": "public" }, "dependencies": { - "@abp/utils": "^5.0.0-beta.2" + "@abp/utils": "~5.0.0-beta.2" }, "gitHead": "bb4ea17d5996f01889134c138d00b6c8f858a431" } diff --git a/npm/publish-mvc.ps1 b/npm/publish-mvc.ps1 new file mode 100644 index 0000000000..6fbeaf50c5 --- /dev/null +++ b/npm/publish-mvc.ps1 @@ -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 "-------------------------" +} diff --git a/npm/publish.ps1 b/npm/publish-ng.ps1 similarity index 80% rename from npm/publish.ps1 rename to npm/publish-ng.ps1 index e563fc1fef..0ca666ae68 100644 --- a/npm/publish.ps1 +++ b/npm/publish-ng.ps1 @@ -17,7 +17,6 @@ if (-Not $Registry) { } $NgPacksPublishCommand = "npm run publish-packages -- --nextVersion $Version --skipGit --registry $Registry" -$PacksPublishCommand = "npm run lerna -- exec 'npm publish --registry $Registry'" $UpdateGulpCommand = "npm run update-gulp" $UpdateNgPacksCommand = "yarn update --registry $Registry" @@ -25,21 +24,16 @@ $IsPrerelase = $(node publish-utils.js --prerelase --customVersion $Version) -eq if ($IsPrerelase) { $UpdateGulpCommand += " -- --prerelase" - $PacksPublishCommand = $PacksPublishCommand.Substring(0, $PacksPublishCommand.Length - 1) + " --tag next'" $UpdateNgPacksCommand += " --prerelase" } $commands = ( - "npm run lerna -- version $Version --yes --no-commit-hooks --skip-git --force-publish", - "npm run replace-with-tilde", - $PacksPublishCommand, $UpdateNgPacksCommand, "cd ng-packs\scripts", "yarn install", $NgPacksPublishCommand, "cd ../../", "cd scripts", - "yarn", "yarn remove-lock-files", "cd ..", $UpdateGulpCommand diff --git a/npm/scripts/package.json b/npm/scripts/package.json index 89e935db21..4319a0183a 100644 --- a/npm/scripts/package.json +++ b/npm/scripts/package.json @@ -3,12 +3,15 @@ "version": "1.0.0", "description": "", "scripts": { - "remove-lock-files": "ts-node -r tsconfig-paths/register remove-lock-files.ts" + "remove-lock-files": "ts-node -r tsconfig-paths/register remove-lock-files.ts", + "report-npm-packages": "ts-node -r tsconfig-paths/register report-npm-packages.ts", + "validate-versions": "ts-node -r tsconfig-paths/register validate-versions.ts" }, "dependencies": { + "axios": "^0.24.0", "chalk": "^4.1.0", - "commander": "^6.1.0", - "execa": "^4.0.3", + "commander": "^8.3.0", + "execa": "^5.1.1", "fs-extra": "^9.0.1", "glob": "^7.1.6", "npm-check-updates": "^9.0.1", diff --git a/npm/scripts/report-npm-packages.ts b/npm/scripts/report-npm-packages.ts new file mode 100644 index 0000000000..05cdbd06e0 --- /dev/null +++ b/npm/scripts/report-npm-packages.ts @@ -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 to compare') + .requiredOption( + '-ra, --reportApi ', + 'api url to report status' + ) + .requiredOption( + '-ak, --accessKey ', + 'access key to use for report api' + ) + .requiredOption( + '-tc, --targetChannel ', + '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, + }); +} diff --git a/npm/scripts/validate-versions.ts b/npm/scripts/validate-versions.ts new file mode 100644 index 0000000000..98f636351a --- /dev/null +++ b/npm/scripts/validate-versions.ts @@ -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 to compare' + ); + program.requiredOption('-p, --path ', 'NPM packages folder path'); + program.option( + '-ep, --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, + 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); +} diff --git a/npm/scripts/yarn.lock b/npm/scripts/yarn.lock index 97051af1ba..bae2201646 100644 --- a/npm/scripts/yarn.lock +++ b/npm/scripts/yarn.lock @@ -231,6 +231,13 @@ aws4@^1.8.0: resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.10.1.tgz#e1e82e4f3e999e2cfd61b161280d16a111f86428" integrity sha512-zg7Hz2k5lI8kb7U32998pRRFin7zJlkfezGJjUc2heaD4Pw2wObakCDVzkKztTm/Ln7eiVvYsjqak0Ed4LkMDA== +axios@^0.24.0: + version "0.24.0" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.24.0.tgz#804e6fa1e4b9c5288501dd9dff56a7a0940d20d6" + integrity sha512-Q6cWsys88HoPgAaFAVUb0WpPk0O8iTeisR9IMqy9G8AbO4NlpVknrnQS03zzF9PGAWgO3cgletO3VjV/P7VztA== + dependencies: + follow-redirects "^1.14.4" + balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" @@ -415,6 +422,11 @@ commander@^6.1.0: resolved "https://registry.yarnpkg.com/commander/-/commander-6.1.0.tgz#f8d722b78103141006b66f4c7ba1e97315ba75bc" integrity sha512-wl7PNrYWd2y5mp1OK/LhTlv8Ff4kQJQRXXAvF+uU/TPNiVJUxZLRYGj/B0y/lPGAVcSbJqH2Za/cvHmrPMC8mA== +commander@^8.3.0: + version "8.3.0" + resolved "https://registry.yarnpkg.com/commander/-/commander-8.3.0.tgz#4837ea1b2da67b9c616a67afbb0fafee567bca66" + integrity sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww== + concat-map@0.0.1: version "0.0.1" resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" @@ -442,7 +454,7 @@ core-util-is@1.0.2, core-util-is@~1.0.0: resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= -cross-spawn@^7.0.0: +cross-spawn@^7.0.3: version "7.0.3" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6" integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w== @@ -584,19 +596,19 @@ esprima@^4.0.0: resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== -execa@^4.0.3: - version "4.0.3" - resolved "https://registry.yarnpkg.com/execa/-/execa-4.0.3.tgz#0a34dabbad6d66100bd6f2c576c8669403f317f2" - integrity sha512-WFDXGHckXPWZX19t1kCsXzOpqX9LWYNqn4C+HqZlk/V0imTkzJZqf87ZBhvpHaftERYknpk0fjSylnXVlVgI0A== +execa@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/execa/-/execa-5.1.1.tgz#f80ad9cbf4298f7bd1d4c9555c21e93741c411dd" + integrity sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg== dependencies: - cross-spawn "^7.0.0" - get-stream "^5.0.0" - human-signals "^1.1.1" + cross-spawn "^7.0.3" + get-stream "^6.0.0" + human-signals "^2.1.0" is-stream "^2.0.0" merge-stream "^2.0.0" - npm-run-path "^4.0.0" - onetime "^5.1.0" - signal-exit "^3.0.2" + npm-run-path "^4.0.1" + onetime "^5.1.2" + signal-exit "^3.0.3" strip-final-newline "^2.0.0" extend@~3.0.2: @@ -644,6 +656,11 @@ find-up@^3.0.0: dependencies: locate-path "^3.0.0" +follow-redirects@^1.14.4: + version "1.14.5" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.14.5.tgz#f09a5848981d3c772b5392309778523f8d85c381" + integrity sha512-wtphSXy7d4/OR+MvIFbCVBDzZ5520qV8XfPklSN5QtxuMUJZ+b0Wnst1e1lCDocfzuCkHqj8k0FpZqO+UIaKNA== + forever-agent@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/forever-agent/-/forever-agent-0.6.1.tgz#fbc71f0c41adeb37f96c577ad1ed42d8fdacca91" @@ -713,13 +730,18 @@ get-stream@^4.1.0: dependencies: pump "^3.0.0" -get-stream@^5.0.0, get-stream@^5.1.0: +get-stream@^5.1.0: version "5.2.0" resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-5.2.0.tgz#4966a1795ee5ace65e706c4b7beb71257d6e22d3" integrity sha512-nBF+F1rAZVCu/p7rjzgA+Yb4lfYXrpl7a6VmJrU8wF9I1CKvP/QwPNZHnOlwbTkY6dvtFIzFMSyQXbLoTQPRpA== dependencies: pump "^3.0.0" +get-stream@^6.0.0: + version "6.0.1" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-6.0.1.tgz#a262d8eef67aced57c2852ad6167526a43cbf7b7" + integrity sha512-ts6Wi+2j3jQjqi70w5AlN8DFnkSwC+MqmxEzdEALB2qXZYV3X/b1CTfgPLGJNMeAWxdPfU8FO1ms3NUfaHCPYg== + getpass@^0.1.1: version "0.1.7" resolved "https://registry.yarnpkg.com/getpass/-/getpass-0.1.7.tgz#5eff8e3e684d569ae4cb2b1282604e8ba62149fa" @@ -834,10 +856,10 @@ https-proxy-agent@^5.0.0: agent-base "6" debug "4" -human-signals@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-1.1.1.tgz#c5b1cd14f50aeae09ab6c59fe63ba3395fe4dfa3" - integrity sha512-SEQu7vl8KjNL2eoGBLF3+wAjpsNfA9XMlXAYj/3EdaNfAlxKthD1xjEQfGOUhllCGGJVNY34bRr6lPINhNjyZw== +human-signals@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" + integrity sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw== humanize-ms@^1.2.1: version "1.2.1" @@ -1427,7 +1449,7 @@ npm-registry-fetch@^8.1.3: minizlib "^2.0.0" npm-package-arg "^8.0.0" -npm-run-path@^4.0.0: +npm-run-path@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-4.0.1.tgz#b7ecd1e5ed53da8e37a55e1c2269e0b97ed748ea" integrity sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw== @@ -1466,7 +1488,7 @@ once@^1.3.0, once@^1.3.1, once@^1.4.0: dependencies: wrappy "1" -onetime@^5.1.0: +onetime@^5.1.2: version "5.1.2" resolved "https://registry.yarnpkg.com/onetime/-/onetime-5.1.2.tgz#d0e96ebb56b07476df1dd9c4806e5237985ca45e" integrity sha512-kbpaSSGJTWdAY5KPVeMOKXSrPtr8C8C7wodJbcsd51jRnmD+GZu8Y0VoU6Dm5Z4vWr0Ig/1NKuWRKf7j5aaYSg== @@ -1858,6 +1880,11 @@ signal-exit@^3.0.0, signal-exit@^3.0.2: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== +signal-exit@^3.0.3: + version "3.0.5" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.5.tgz#9e3e8cc0c75a99472b44321033a7702e7738252f" + integrity sha512-KWcOiKeQj6ZyXx7zq4YxSMgHRlod4czeBQZrPb8OKcohcqAXShm7E20kEMle9WBt26hFcAf0qLOcp5zmY7kOqQ== + sisteransi@^1.0.4: version "1.0.5" resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed"