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
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/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',
});
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/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
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);
+}
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