diff --git a/npm/ng-packs/package.json b/npm/ng-packs/package.json index d8718d737f..6ba0a57603 100644 --- a/npm/ng-packs/package.json +++ b/npm/ng-packs/package.json @@ -48,7 +48,7 @@ "@abp/ng.tenant-management": "~4.4.2", "@abp/ng.theme.basic": "~4.4.2", "@abp/ng.theme.shared": "~4.4.2", - "@abp/utils": "^4.4.2", + "@abp/utils": "~4.4.2", "@angular-devkit/build-angular": "~12.2.0", "@angular-devkit/build-ng-packagr": "^0.1002.0", "@angular-devkit/schematics-cli": "~12.2.0", @@ -115,4 +115,4 @@ "typescript": "~4.3.5", "zone.js": "~0.11.4" } -} +} \ No newline at end of file diff --git a/npm/ng-packs/scripts/package.json b/npm/ng-packs/scripts/package.json index 3984a00b14..b0961239bb 100644 --- a/npm/ng-packs/scripts/package.json +++ b/npm/ng-packs/scripts/package.json @@ -17,7 +17,8 @@ "execa": "^2.0.3", "fs-extra": "^8.1.0", "glob": "^7.1.6", - "prompt-confirm": "^2.0.4" + "prompt-confirm": "^2.0.4", + "semver": "^7.3.5" }, "devDependencies": { "@types/fs-extra": "^8.0.1", diff --git a/npm/ng-packs/scripts/publish.ts b/npm/ng-packs/scripts/publish.ts index 75f677b4b9..ecc0408f2b 100644 --- a/npm/ng-packs/scripts/publish.ts +++ b/npm/ng-packs/scripts/publish.ts @@ -2,6 +2,7 @@ import program from 'commander'; import execa from 'execa'; import fse from 'fs-extra'; import replaceWithPreview from './replace-with-preview'; +const semverParse = require('semver/functions/parse'); program .option( @@ -10,7 +11,6 @@ program ) .option('-r, --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); @@ -50,7 +50,7 @@ program.parse(process.argv); let tag: string; if (program.preview) tag = 'preview'; - if (program.rc) tag = 'next'; + else if (semverParse(program.nextVersion).prerelease?.length) tag = 'next'; await execa( 'yarn', diff --git a/npm/ng-packs/scripts/yarn.lock b/npm/ng-packs/scripts/yarn.lock index 975620872f..0bee64a70e 100644 --- a/npm/ng-packs/scripts/yarn.lock +++ b/npm/ng-packs/scripts/yarn.lock @@ -834,6 +834,13 @@ loose-envify@^1.0.0: dependencies: js-tokens "^3.0.0 || ^4.0.0" +lru-cache@^6.0.0: + version "6.0.0" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" + integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== + dependencies: + yallist "^4.0.0" + make-error@^1.1.1: version "1.3.6" resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" @@ -1060,6 +1067,13 @@ regenerator-runtime@^0.11.0: resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== +semver@^7.3.5: + version "7.3.5" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7" + integrity sha512-PoeGJYh8HK4BTO/a9Tf6ZG3veo/A7ZVsYrSA6J8ny9nb3B1VrpkuN+z9OE5wfE5p6H4LchYZsegiQgbJD94ZFQ== + dependencies: + lru-cache "^6.0.0" + set-getter@^0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/set-getter/-/set-getter-0.1.1.tgz#a3110e1b461d31a9cfc8c5c9ee2e9737ad447102" @@ -1263,6 +1277,11 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= +yallist@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" + integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== + yn@3.1.1: version "3.1.1" resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" diff --git a/npm/ng-packs/yarn.lock b/npm/ng-packs/yarn.lock index ccd80d41f1..1d605fa81a 100644 --- a/npm/ng-packs/yarn.lock +++ b/npm/ng-packs/yarn.lock @@ -118,7 +118,7 @@ chart.js "^2.9.3" tslib "^2.0.0" -"@abp/utils@^4.4.2": +"@abp/utils@^4.4.2", "@abp/utils@~4.4.2": version "4.4.2" resolved "https://registry.yarnpkg.com/@abp/utils/-/utils-4.4.2.tgz#33d1a8c1199241e0c926fb3fd2f439d2925d5db1" integrity sha512-o/1XGKSOPB+yQH6c+yyMNSr/r8rzb3PoHkxKqDNEGEf79L6EwJ8Wm+4wKaoHjVrYQtn+d/40PLEdvGEwQxVvCw== diff --git a/npm/package-update-script.js b/npm/package-update-script.js index 58e24db554..27930f096c 100644 --- a/npm/package-update-script.js +++ b/npm/package-update-script.js @@ -4,8 +4,8 @@ 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 ', 'target npm server registry') +program.option('-pr, --prerelase', 'whether version is prerelase'); +program.option('-rg, --registry ', 'target npm server registry'); program.parse(process.argv); const packages = (process.argv[3] || 'abp').split(',').join('|'); @@ -15,7 +15,7 @@ const check = (pkgJsonPath) => { return childProcess .execSync( `ncu "/^@(${packages}).*$/" --packageFile ${pkgJsonPath} -u${ - program.rc ? ' --target greatest' : '' + program.prerelase ? ' --target greatest' : '' }${program.registry ? ` --registry ${program.registry}` : ''}` ) .toString(); diff --git a/npm/package.json b/npm/package.json index 724b0f7be1..2838e8eac0 100644 --- a/npm/package.json +++ b/npm/package.json @@ -16,6 +16,8 @@ "dependencies": { "commander": "^6.0.0", "execa": "^3.4.0", - "fs-extra": "^8.1.0" + "fast-glob": "^3.2.7", + "fs-extra": "^8.1.0", + "semver": "^7.3.5" } } diff --git a/npm/publish-utils.js b/npm/publish-utils.js index 395045c374..f3fb83c155 100644 --- a/npm/publish-utils.js +++ b/npm/publish-utils.js @@ -1,16 +1,18 @@ 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('-pr, --prerelase', 'whether version is prerelase'); program.option('-cv, --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; diff --git a/npm/publish.ps1 b/npm/publish.ps1 index 486c6c6f4e..e563fc1fef 100644 --- a/npm/publish.ps1 +++ b/npm/publish.ps1 @@ -3,7 +3,7 @@ param( [string]$Registry ) -npm install +yarn install $NextVersion = $(node publish-utils.js --nextVersion) $RootFolder = (Get-Item -Path "./" -Verbose).FullName @@ -21,15 +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 = ( @@ -38,7 +35,7 @@ $commands = ( $PacksPublishCommand, $UpdateNgPacksCommand, "cd ng-packs\scripts", - "npm install", + "yarn install", $NgPacksPublishCommand, "cd ../../", "cd scripts", diff --git a/npm/update-gulp.js b/npm/update-gulp.js index d6076978eb..678c6a043b 100644 --- a/npm/update-gulp.js +++ b/npm/update-gulp.js @@ -1,4 +1,4 @@ -const glob = require('glob'); +const glob = require('fast-glob'); var path = require('path'); const childProcess = require('child_process'); const execa = require('execa'); @@ -6,7 +6,7 @@ const fse = require('fs-extra'); const { program } = require('commander'); program.version('0.0.1'); -program.option('-r, --rc', 'whether version is rc'); +program.option('-pr, --prerelase', 'whether version is prerelase'); program.parse(process.argv); const gulp = (folderPath) => { @@ -18,8 +18,9 @@ const gulp = (folderPath) => { } try { - execa.sync(`yarn`, ['install'], { cwd: folderPath, stdio: 'inherit' }); - execa.sync(`yarn`, ['gulp'], { cwd: folderPath, stdio: 'inherit' }); + fse.removeSync(`${folderPath}/wwwroot/libs`); + 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); } @@ -30,7 +31,7 @@ const updatePackages = (pkgJsonPath) => { const result = childProcess .execSync( `ncu "/^@abp.*$/" --packageFile ${pkgJsonPath} -u${ - program.rc ? ' --target greatest' : '' + program.prerelase ? ' --target greatest' : '' }` ) .toString(); @@ -40,8 +41,9 @@ const updatePackages = (pkgJsonPath) => { } }; -console.time(); -glob('../**/package.json', {}, (er, files) => { +(async () => { + console.time(); + let files = await glob('../**/package.json'); files = files.filter( (f) => f && @@ -53,7 +55,9 @@ glob('../**/package.json', {}, (er, files) => { files.forEach((file) => { updatePackages(file); - gulp(file.replace('package.json', '')); + const folderPath = file.replace('package.json', ''); + gulp(folderPath); }); + console.timeEnd(); -}); +})(); diff --git a/npm/yarn.lock b/npm/yarn.lock index 5924e105bb..38e7e00716 100644 --- a/npm/yarn.lock +++ b/npm/yarn.lock @@ -2266,7 +2266,7 @@ fast-glob@^2.2.6: merge2 "^1.2.3" micromatch "^3.1.10" -fast-glob@^3.1.1: +fast-glob@^3.1.1, fast-glob@^3.2.7: version "3.2.7" resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.7.tgz#fd6cb7a2d7e9aa7a7846111e85a196d6b2f766a1" integrity sha512-rYGMRwip6lUMvYD3BTScMwT1HtAs2d71SMv66Vrxs0IekGZEjhM0pcMfjQPnknBt2zeCwQMEupiN02ZP4DiT1Q==