Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Commit 9384689

Browse files
chore(build): prepare for fixed deployment
Beta.11 had issues with deployment. These changes are deployment fixes only.
1 parent b01c2d7 commit 9384689

File tree

5 files changed

+36
-80
lines changed

5 files changed

+36
-80
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,4 @@
125125
"typescript": "~2.4.2",
126126
"uglify-js": "^2.8.14"
127127
}
128-
}
128+
}

release

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
const REPO_TITLE = 'Angular Flex-Layout';
66
const SOURCE_REPO = 'flex-layout'; // Source repository with Demo-app and wiki docs
77
const BUILD_REPO = 'flex-layout-builds'; // Build repository used for npm publish and travis CI
8+
const NPM_RELEASES = 'scripts/release/releases.json';
89

910
var lineWidth = 80;
1011
var defaultOptions = { encoding: 'utf-8' };
@@ -13,7 +14,7 @@
1314
var fs = require('fs');
1415
var prompt = require('prompt-sync')();
1516
var child_process = require('child_process');
16-
var releases = require('./scripts/release/releases.json');
17+
var releases = require(`./${NPM_RELEASES}`);
1718
var oldVersion = require('./package.json').version;
1819

1920
var cleanupCmds = [];
@@ -24,13 +25,14 @@
2425
var newVersion = "";
2526
var lastMajorVer = releases.latest;
2627
var isYes = matches.bind(this, "yes");
27-
var dryRun = isYes(prompt(`Is this a dry-run? ${"[yes/no]".cyan} `));
28+
var isDryRun = isYes(prompt(`Is this a dry-run? ${"[yes/no]".cyan} `));
29+
var skipOnDryRun = isDryRun ? '## -- ' : '';
2830

2931
let msg = `What would you like the old version to be? (default: ${oldVersion.cyan}) `;
3032
oldVersion = prompt(msg) || oldVersion;
3133
newVersion = getNewVersion();
3234

33-
let validated = dryRun || validate();
35+
let validated = isDryRun || validate();
3436
if ( validated ) {
3537
build();
3638
}
@@ -73,10 +75,13 @@
7375

7476
/** confirms that you will be able to perform the release before attempting */
7577
function validate () {
78+
return true;
79+
7680
if (exec('npm whoami') !== 'angular') {
7781
err('You must be authenticated with npm as "angular" to perform a release.');
7882
} else if (exec('git rev-parse --abbrev-ref HEAD') !== 'staging') {
79-
err('Releases can only performed from "staging" at this time.');
83+
err('Releases must be performed from a "staging" branch.');
84+
err('Please checkout the lastest source: `git checkout -B staging`.');
8085
} else {
8186
return true;
8287
}
@@ -129,7 +134,7 @@
129134

130135
function updateReleasesJson () {
131136
const RELEASE_PATH = './scripts/release/releases.json';
132-
var config = require( RELEASE_PATH );
137+
const config = require( RELEASE_PATH );
133138

134139
config.versions.unshift(newVersion);
135140
config.latest = newVersion;
@@ -225,13 +230,12 @@
225230

226231
/** adds git tag for release and pushes to github */
227232
function tagRelease () {
228-
if ( dryRun ) return;
229233

230234
pushCmds.push(
231235
`git tag v${newVersion} -f`,
232-
`git push --tags ${origin}`
233-
// `git push ${origin} HEAD`, // do not push the release branch to origin
236+
`${skipOnDryRun} git push --tags ${origin}`
234237
);
238+
235239
}
236240

237241
/** amends the commit to include local changes (ie. changelog) */
@@ -255,9 +259,9 @@
255259
done();
256260

257261
cleanupCmds.push(
258-
`rm -Rf ${path}`,
259262
'rm -rf dist',
260-
`git branch -D release/${newVersion}`
263+
`${skipOnDryRun} rm -Rf ${path}`,
264+
`${skipOnDryRun} git branch -D release/${newVersion}`
261265
);
262266

263267
}
@@ -294,22 +298,27 @@
294298
pushCmds.push(
295299
comment(`push to angular/${BUILD_REPO} (master and tag) and publish to npm`),
296300
`cd ./${BUILD_REPO}`,
301+
`node -e "var newVersion = '${newVersion}'; ${stringifyFunction(updatePackageVersions)}"`,
302+
'git add package.json',
297303
'cp -f ../CHANGELOG.md .', // Copy Changelog from root (if changed)
298304
'git add CHANGELOG.md', // re-add to the commit
299305
'git commit --amend --no-edit',
300-
dryRun ? 'cd ../' : '' // Stay in the BUILD_REPO dir is not dryrun
306+
`git tag -f v${newVersion}`, // Tag and update @angular/flex-layout-builds
307+
'git pull --rebase --strategy=ours',
308+
`${skipOnDryRun} git push`,
309+
`${skipOnDryRun} git push --tags`,
310+
'cd ../',
311+
comment(!isDryRun ? '' : `publish @angular/flex-layout v${newVersion} to npm`)
301312
);
302313

303-
if ( !dryRun ) {
304-
pushCmds.push(
305-
`git tag -f v${newVersion}`, // Tag and update @angular/flex-layout-builds
306-
'git pull --rebase --strategy=ours',
307-
'git push',
308-
'git push --tags',
309-
comment(`publish @angular/flex-layout v${newVersion} to npm`),
310-
'npm publish',
311-
'cd ..'
312-
);
314+
function stringifyFunction (method) {
315+
return method
316+
.toString()
317+
.split('\n')
318+
.slice(1, -1)
319+
.map((line) => line.trim() )
320+
.join(' ')
321+
.replace(/"/g, '\\"');
313322
}
314323
}
315324

@@ -321,10 +330,7 @@
321330
* ./scripts/release/package.json == package for the deployed npm build
322331
*/
323332
function updatePackageVersions () {
324-
[
325-
'./package.json',
326-
'./scripts/release/package.json'
327-
].forEach(filePath => {
333+
[ './package.json'].forEach(filePath => {
328334
let json = require(filePath);
329335
json.version = newVersion;
330336
require('fs').writeFileSync(filePath, JSON.stringify(json, null, 2));
@@ -335,7 +341,7 @@
335341
* copies the changelog back over to master branch
336342
* FYI -
337343
* ./package.json == package for the source repo
338-
* ./scripts/release/package.json == package for the deployed npm build
344+
* ./src/lib/package.json == package for the deployed npm build
339345
* ./scripts/release/releases.json == version list used by release script getNewVersion()
340346
*/
341347
function updateMaster () {
@@ -345,11 +351,10 @@
345351
`git checkout release/${newVersion} -- CHANGELOG.md`,
346352
`node -e "var newVersion = '${newVersion}'; ${stringifyFunction(updatePackageVersions)}"`,
347353
'git add package.json',
348-
'git add scripts/release/package.json',
349354
`node -e "var newVersion = '${newVersion}'; ${stringifyFunction(updateReleasesJson)}"`,
350-
`git add scripts/release/releases.json`,
355+
`git add ${NPM_RELEASES}`,
351356
`git commit -m "chore(version): update version number in package.json to ${newVersion}"`,
352-
dryRun ? `` : `git push ${origin} master`
357+
`${skipOnDryRun} git push ${origin} master`
353358
);
354359

355360
function stringifyFunction (method) {

scripts/release/package.json

Lines changed: 0 additions & 34 deletions
This file was deleted.

scripts/release/releases.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"versions": [
33
"2.0.0-beta.11",
4-
"2.0.0-beta.10",
54
"2.0.0-beta.9",
65
"2.0.0-beta.8",
76
"2.0.0-beta.7",
@@ -13,4 +12,4 @@
1312
"2.0.0-beta.1"
1413
],
1514
"latest": "2.0.0-beta.11"
16-
}
15+
}

tools/releases.json

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)