From 0995db41a8f3c8d6d2a3b302fa67e71761088e7a Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Wed, 19 Aug 2020 00:12:04 +0300 Subject: [PATCH 1/5] ci: create publish-utils.js --- npm/package-lock.json | 15 ++++++++++----- npm/package.json | 1 + npm/publish-utils.js | 21 +++++++++++++++++++++ 3 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 npm/publish-utils.js diff --git a/npm/package-lock.json b/npm/package-lock.json index b50344e0c5..926f7179fb 100644 --- a/npm/package-lock.json +++ b/npm/package-lock.json @@ -2209,11 +2209,9 @@ } }, "commander": { - "version": "2.20.3", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", - "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", - "dev": true, - "optional": true + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-6.0.0.tgz", + "integrity": "sha512-s7EA+hDtTYNhuXkTlhqew4txMZVdszBmKWSPEMxGr8ru8JXR7bLUFIAtPhcSuFdJQ0ILMxnJi8GkQL0yvDy/YA==" }, "compare-func": { "version": "1.3.2", @@ -7411,6 +7409,13 @@ "source-map": "~0.6.1" }, "dependencies": { + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true, + "optional": true + }, "source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", diff --git a/npm/package.json b/npm/package.json index 3baede1175..984aeb29f9 100644 --- a/npm/package.json +++ b/npm/package.json @@ -13,6 +13,7 @@ "npm-check-updates": "^3.1.25" }, "dependencies": { + "commander": "^6.0.0", "execa": "^3.4.0", "fs-extra": "^8.1.0" } diff --git a/npm/publish-utils.js b/npm/publish-utils.js new file mode 100644 index 0000000000..8d0e1d2cc2 --- /dev/null +++ b/npm/publish-utils.js @@ -0,0 +1,21 @@ +const { program } = require('commander'); +const fse = require('fs-extra'); + +program.version('0.0.1'); +program.option('-n, --nextVersion', 'version in common.props'); +program.option('-r, --rc', 'whether version is rc'); + +program.parse(process.argv); + +if (program.nextVersion) console.log(getVersion()); + +if (program.rc) console.log(getVersion().includes('rc')); + +function getVersion() { + const commonProps = fse.readFileSync('../common.props').toString(); + const versionTag = ''; + const versionEndTag = ''; + const first = commonProps.indexOf(versionTag) + versionTag.length; + const last = commonProps.indexOf(versionEndTag); + return commonProps.substring(first, last); +} From 53c3cf76732f0a5d96559af0da67533c7a11cf9c Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Wed, 19 Aug 2020 00:12:27 +0300 Subject: [PATCH 2/5] ci: improve the publish.ps1 to be able to publish rc packages --- npm/publish.ps1 | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/npm/publish.ps1 b/npm/publish.ps1 index d507d00c4d..f878860369 100644 --- a/npm/publish.ps1 +++ b/npm/publish.ps1 @@ -4,21 +4,31 @@ param( npm install -$NextVersion = $(node get-version.js) -$rootFolder = (Get-Item -Path "./" -Verbose).FullName +$NextVersion = $(node publish-utils.js --nextVersion) +$RootFolder = (Get-Item -Path "./" -Verbose).FullName if(-Not $Version) { $Version = $NextVersion; } +$NgPacksPublishCommand = "npm run publish-packages -- --nextVersion $Version --skipGit" +$PacksPublishCommand = "npm run lerna -- exec 'npm publish --registry https://registry.npmjs.org'" + +$IsRc = $(node publish-utils.js --rc) -eq "true"; + +if($IsRc) { + $NgPacksPublishCommand += " --rc" + $PacksPublishCommand = $PacksPublishCommand.Substring(0,$PacksPublishCommand.Length-1) + " --tag next'" +} + $commands = ( "cd ng-packs\scripts", "npm install", - "npm run publish-packages -- --nextVersion $Version", + $NgPacksPublishCommand, "cd ../../", "npm run lerna -- version $Version --yes --no-commit-hooks --skip-git --force-publish", "npm run replace-with-tilde", - "npm run lerna -- exec 'npm publish --registry https://registry.npmjs.org'", + $PacksPublishCommand, "npm run update-gulp" ) @@ -27,7 +37,7 @@ foreach ($command in $commands) { Invoke-Expression $command if($LASTEXITCODE -ne '0' -And $command -notlike '*cd *'){ Write-Host ("Process failed! " + $command) - Set-Location $rootFolder + Set-Location $RootFolder exit $LASTEXITCODE } } \ No newline at end of file From f818db3425ca8ed9113bd06e9a2b14463984f331 Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Wed, 19 Aug 2020 00:12:56 +0300 Subject: [PATCH 3/5] ci: add new tag condition to publish.ts --- npm/ng-packs/scripts/publish.ts | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/npm/ng-packs/scripts/publish.ts b/npm/ng-packs/scripts/publish.ts index 1514d229fc..e76af16601 100644 --- a/npm/ng-packs/scripts/publish.ts +++ b/npm/ng-packs/scripts/publish.ts @@ -8,7 +8,9 @@ program '-v, --nextVersion ', 'next semantic version. Available versions: ["major", "minor", "patch", "premajor", "preminor", "prepatch", "prerelease", "or type a custom version"]', ) - .option('-p, --preview', 'publish with preview tag'); + .option('-p, --preview', 'publishes with preview tag') + .option('-r, --rc', 'publishes with next tag') + .option('-g, --skipGit', 'skips git push'); program.parse(process.argv); @@ -55,14 +57,13 @@ const publish = async () => { await fse.rename('../lerna.publish.json', '../lerna.json'); + let tag: string; + if (program.preview) tag = 'preview'; + if (program.rc) tag = 'next'; + await execa( 'yarn', - [ - 'lerna', - 'exec', - '--', - `"npm publish --registry ${registry}${program.preview ? ' --tag preview' : ''}"`, - ], + ['lerna', 'exec', '--', `"npm publish --registry ${registry}${tag ? ` --tag ${tag}` : ''}"`], { stdout: 'inherit', cwd: '../', @@ -71,7 +72,7 @@ const publish = async () => { await fse.rename('../lerna.json', '../lerna.publish.json'); - if (!program.preview) { + if (!program.preview && !program.skipGit) { await execa('git', ['add', '../packages/*', '../package.json', '../lerna.version.json'], { stdout: 'inherit', }); From 04108a6969597acb4b31429d02a05dc5a0e85600 Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Wed, 19 Aug 2020 00:13:11 +0300 Subject: [PATCH 4/5] ci: update preview-publish.ps1 --- npm/get-version.js | 10 ---------- npm/preview-publish.ps1 | 6 +++--- 2 files changed, 3 insertions(+), 13 deletions(-) delete mode 100644 npm/get-version.js diff --git a/npm/get-version.js b/npm/get-version.js deleted file mode 100644 index 5198ee913a..0000000000 --- a/npm/get-version.js +++ /dev/null @@ -1,10 +0,0 @@ -const fse = require('fs-extra'); - -const commonProps = fse.readFileSync('../common.props').toString(); - -const versionTag = ''; -const versionEndTag = ''; -const first = commonProps.indexOf(versionTag) + versionTag.length; -const last = commonProps.indexOf(versionEndTag); - -console.log(commonProps.substring(first, last)); diff --git a/npm/preview-publish.ps1 b/npm/preview-publish.ps1 index 524c8afcaa..dc01d2ed1c 100644 --- a/npm/preview-publish.ps1 +++ b/npm/preview-publish.ps1 @@ -8,8 +8,8 @@ param( npm install -$NextVersion = $(node get-version.js) -$rootFolder = (Get-Item -Path "./" -Verbose).FullName +$NextVersion = $(node publish-utils.js --nextVersion) +$RootFolder = (Get-Item -Path "./" -Verbose).FullName if(-Not $Version) { $Version = $NextVersion; @@ -34,7 +34,7 @@ foreach ($command in $commands) { Invoke-Expression $command if($LASTEXITCODE -ne '0' -And $command -notlike '*cd *'){ Write-Host ("Process failed! " + $command) - Set-Location $rootFolder + Set-Location $RootFolder exit $LASTEXITCODE } } \ No newline at end of file From fde78000824e831bd966247ecb9e74c88624142a Mon Sep 17 00:00:00 2001 From: mehmet-erim Date: Wed, 19 Aug 2020 00:16:07 +0300 Subject: [PATCH 5/5] chore: update angular.yml --- .github/workflows/angular.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/angular.yml b/.github/workflows/angular.yml index 60051c2dc1..1b4d37bd39 100644 --- a/.github/workflows/angular.yml +++ b/.github/workflows/angular.yml @@ -3,6 +3,7 @@ on: pull_request: paths: - 'npm/ng-packs/**' + - '!npm/ng-packs/scripts/**' jobs: build-test-lint: runs-on: ubuntu-18.04