Skip to content

Commit cfaf330

Browse files
author
Peter Collins
committed
Ionitron tweet
Must be run with release command Move code to bottom of gulp file Add twitter keys Send off a test tweet Update twitter secrets Awesome it worked, delete always tweet
1 parent 577d595 commit cfaf330

File tree

4 files changed

+162
-145
lines changed

4 files changed

+162
-145
lines changed

.travis.yml

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
language: node_js
22
node_js:
3-
- 0.10
4-
3+
- 0.1
54
env:
65
global:
76
- secure: C49JZxX08FSiXEZYpIFDs4YRdZGB0Hyygkk8zFknALLxPCREwk/MLhs64FOftgcVYjyo1CpmEZfmlKdHDnuko8mUjERrn/3iFHO2Fi0Z/zbj1pDkHlkoeIWGu3JS9y5mDAC1N0AO+pbMQp1jy+qTbHZsBsRCM4tVeEoLVdLmwOU=
87
- secure: EXFisiY1QVmeXLOQRcZHcY3kJNfUUhBgVfe8492Ion/+djwi/e6bRbuZvU8Axvz26CpdRwS9IWSsZm7J3Eu+g3ORsBqILbJ0hTO4m7UJyt8hZxeRJZEOmQI2S0NcOFkIdSgNbrvxZoF8ZNFrp96kQWR3/5wMYRGcxtu/1JTqVy0=
98
- secure: QGukWuP7Li6RDnvxszY/qX/nySshmwiOYQJOKyG0YqAGjV4aFxfdA1pOffqPXEYn2KK6eB5DDx3YjDgtVnBClxV26CUdDhwy0reNKj8UrzgN/NSYeFy6EnOZMDz+DtPJXpUSXnGa3HtaOxbxG8mrpPFSPEeCY6Ci4M119hyslFY=
10-
9+
- secure: ANeKOUjQA68r92tf4qW4/uqT+kn7jTG9nPwZD2nE0G3RpWFfLa0/g1IXqGb9w5ILxwnKFB6yzBQu9ERjHY595jshFTeJhUei35fJyZy56S9eG7eLqZGjHgz+1G7tsKd7mikkGNCF0OyLh/BtMucqWFPsARlQTJpjl79Ctv7vitU=
10+
- secure: ClLLhCzhh6nGAWxEmmMFZXoLfFes3qYhEmr6CrrH4jKoAn2Zw/AWRQgcchAcvELUOZuhOh5JKMFTq7yqBFDI5zRIaB+AKM6B7lyl5F6jCKR4IdLYtW/3f0nbmL/z1y046g4Prr//2LDQ5H/uQ1syqRkrd9W+mMundVuNewaObf8=
11+
- secure: 2fk0b82A5q+FtU8M5MUIjxfbm+nxlDC3e7eHksgqfRY7v8odHWjJxJliBF50sP8qkVsop3HRONtxHcX09RpYfjAg2JVWd0QNtKF3PtpyJQO1Oe3oRBLCQSLM3H2O8vp0lXOrqjP3gKCVcqKZftPOJkR1HwwSmgCuDEkEBja/WlU=
12+
- secure: venr/q6rVyF2AbiT34XjWZvtXXOPKSusgbIcpNRoSBhs/fxJu6LKZ1byPJsdohBPLxsxd6J+3RJLU+dQul49uY6HCk7+uFETgQAU/H+DE3585eHaUwOyuOoYv/psoEuMXAopbAekJwZw/rnnpGh73CxychuQQUVDsJnt5QsbOwI=
1113
notifications:
1214
hipchat:
1315
rooms:
1416
secure: mkHfRTsuxidtOOORbJJ0Jspb/DSa8jAiQwWWUljqLwefy1p4HGC9P/rLdXXg3vsjiulCzyjEkfvDWAHXvu34GhGWfQuD8U140Fon1Os3AO5Hbme+yRmjXmTcgH8XetSLQufyBBMqXHMd6o1tkxXql1p54G1IShhgAdPNe76d5ZE=
15-
1617
before_install:
1718
- npm install -g gulp protractor
18-
1919
before_script:
2020
- export DISPLAY=:99.0
2121
- sh -e /etc/init.d/xvfb start
22-
2322
script:
2423
- ./scripts/travis/ci.sh

gulpfile.js

+153-138
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
var gulp = require('gulp');
2+
var pkg = require('./package.json');
3+
var semver = require('semver');
4+
var through = require('through');
5+
6+
var argv = require('minimist')(process.argv.slice(2));
7+
18
var _ = require('lodash');
29
var buildConfig = require('./config/build.config.js');
310
var changelog = require('conventional-changelog');
@@ -13,13 +20,6 @@ var http = require('http');
1320
var cp = require('child_process');
1421
var fs = require('fs');
1522

16-
var gulp = require('gulp');
17-
var pkg = require('./package.json');
18-
var semver = require('semver');
19-
var through = require('through');
20-
21-
var argv = require('minimist')(process.argv.slice(2));
22-
2323
var concat = require('gulp-concat');
2424
var footer = require('gulp-footer');
2525
var gulpif = require('gulp-if');
@@ -30,6 +30,7 @@ var rename = require('gulp-rename');
3030
var sass = require('gulp-sass');
3131
var stripDebug = require('gulp-strip-debug');
3232
var template = require('gulp-template');
33+
var twitter = require('gulp-twitter');
3334
var uglify = require('gulp-uglify');
3435
var gutil = require('gulp-util');
3536

@@ -43,140 +44,9 @@ if (IS_RELEASE_BUILD) {
4344
);
4445
}
4546

46-
4747
gulp.task('default', ['build']);
4848
gulp.task('build', ['bundle', 'sass']);
4949

50-
gulp.task('docs-index', function() {
51-
var idx = lunr(function() {
52-
this.field('path');
53-
this.field('title', {boost: 10});
54-
this.field('body');
55-
this.ref('id');
56-
});
57-
var ref = {};
58-
var refId = 0;
59-
60-
function addToIndex(path, title, layout, body) {
61-
// Add the data to the indexer and ref object
62-
idx.add({'path': path, 'body': body, 'title': title, id: refId});
63-
ref[refId] = {'p': path, 't': title, 'l': layout};
64-
refId++;
65-
}
66-
67-
return gulp.src([
68-
'tmp/ionic-site/docs/{components,guide,api,overview}/**/*.{md,html,markdown}',
69-
'tmp/ionic-site/docs/index.html',
70-
'tmp/ionic-site/getting-started/index.html',
71-
'tmp/ionic-site/tutorials/**/*.{md,html,markdown}',
72-
'tmp/ionic-site/_posts/**/*.{md,html,markdown}'
73-
])
74-
.pipe(es.map(function(file, callback) {
75-
//docs for gulp file objects: https://github.com/wearefractal/vinyl
76-
var contents = file.contents.toString(); //was buffer
77-
78-
// Grab relative path from ionic-site root
79-
var relpath = file.path.replace(/^.*?tmp\/ionic-site\//, '');
80-
81-
// Read out the yaml portion of the Jekyll file
82-
var yamlStartIndex = contents.indexOf('---');
83-
84-
if (yamlStartIndex === -1) {
85-
return callback();
86-
}
87-
88-
// read Jekyll's page yaml variables at the top of the file
89-
var yamlEndIndex = contents.indexOf('---', yamlStartIndex+3); //starting from start
90-
var yamlRaw = contents.substring(yamlStartIndex+3, yamlEndIndex);
91-
92-
var pageData = yaml.safeLoad(yamlRaw);
93-
if(!pageData.title || !pageData.layout) {
94-
return callback();
95-
}
96-
97-
// manually set to not be searchable, or for a blog post, manually set to be searchable
98-
if(pageData.searchable === false || (pageData.layout == 'post' && pageData.searchable !== true)) {
99-
return callback();
100-
}
101-
102-
// clean up some content so code variables are searchable too
103-
contents = contents.substring(yamlEndIndex+3);
104-
contents = contents.replace(/<code?>/gi, '');
105-
contents = contents.replace(/<\/code>/gi, '');
106-
contents = contents.replace(/<code?></gi, '');
107-
contents = contents.replace(/><\/code>/gi, '');
108-
contents = contents.replace(/`</gi, '');
109-
contents = contents.replace(/>`/gi, '');
110-
111-
// create a clean path to the URL
112-
var path = '/' + relpath.replace('index.md', '')
113-
.replace('index.html', '')
114-
.replace('.md', '.html')
115-
.replace('.markdown', '.html');
116-
if(pageData.layout == 'post') {
117-
path = '/blog/' + path.substring(19).replace('.html', '/');
118-
}
119-
120-
if(pageData.search_sections === true) {
121-
// each section within the content should be its own search result
122-
var section = { body: '', title: '' };
123-
var isTitleOpen = false;
124-
125-
var parser = new htmlparser.Parser({
126-
ontext: function(text){
127-
if(isTitleOpen) {
128-
section.title += text; // get the title of this section
129-
} else {
130-
section.body += text.replace(/{%.*%}/, '', 'g'); // Ignore any Jekyll expressions
131-
}
132-
},
133-
onopentag: function(name, attrs) {
134-
if(name == 'section' && attrs.id) {
135-
// start building new section data
136-
section = { body: '', path: path + '#' + attrs.id, title: '' };
137-
} else if( (name == 'h1' || name == 'h2' || name == 'h3') && attrs.class == 'title') {
138-
isTitleOpen = true; // the next text will be this sections title
139-
}
140-
},
141-
onclosetag: function(name) {
142-
if(name == 'section') {
143-
// section closed, index this section then clear it out
144-
addToIndex(section.path, section.title, pageData.layout, section.body);
145-
section = { body: '', title: '' };
146-
} else if( (name == 'h1' || name == 'h2' || name == 'h3') && isTitleOpen) {
147-
isTitleOpen = false;
148-
}
149-
}
150-
});
151-
parser.write(contents);
152-
parser.end();
153-
154-
} else {
155-
// index the entire page
156-
var body = '';
157-
var parser = new htmlparser.Parser({
158-
ontext: function(text){
159-
body += text.replace(/{%.*%}/, '', 'g'); // Ignore any Jekyll expressions
160-
}
161-
});
162-
parser.write(contents);
163-
parser.end();
164-
165-
addToIndex(path, pageData.title, pageData.layout, body);
166-
}
167-
168-
callback();
169-
170-
})).on('end', function() {
171-
// Write out as one json file
172-
mkdirp.sync('tmp/ionic-site/data');
173-
fs.writeFileSync(
174-
'tmp/ionic-site/data/index.json',
175-
JSON.stringify({'ref': ref, 'index': idx.toJSON()})
176-
);
177-
});
178-
});
179-
18050
gulp.task('docs', function(done) {
18151
var docVersion = argv['doc-version'];
18252
if (docVersion != 'nightly' && !semver.valid(docVersion)) {
@@ -317,6 +187,151 @@ gulp.task('version', function() {
317187
.pipe(gulp.dest('dist'));
318188
});
319189

190+
gulp.task('tweet', function() {
191+
var oauth = {
192+
consumerKey: process.env.TWITTER_CONSUMER_KEY,
193+
consumerSecret: process.env.TWITTER_CONSUMER_SECRET,
194+
accessToken: process.env.TWITTER_ACCESS_TOKEN,
195+
accessTokenSecret: process.env.TWITTER_ACCESS_TOKEN_SECRET
196+
};
197+
var exclamations = ["Aah","Ah","Aha","All right","Aw","Ay","Aye","Bah","Boy","By golly","Boom","Cheerio","Cheers","Come on","Crikey","Dear me","Egads","Fiddle-dee-dee","Gadzooks","Gangway","G'day","Gee whiz","Gesundheit","Get outta here","Good golly","Good job","Gosh","Gracious","Great","Gulp","Ha","Ha-ha","Hah","Hallelujah","Harrumph","Hey","Hooray","Hot dog","Hurray","Huzza","I say","La-di-dah","Look","Look here","Long time","Lordy","Most certainly","My my","My word","Oh","Oho","Oh-oh","Oh no","Okay","Okey-dokey","Ooh","Oye","Phew","Quite","Ready","Right on","Roger that","Rumble","Say","See ya","Snap","Sup","Ta-da","Take that","Tally ho","Thanks","Toodles","Touche","Tut-tut","Very nice","Very well","Voila","Vroom","Well done","Well, well","Whoa","Whoopee","Whew","Word up","Wow","Wuzzup","Ya","Yea","Yeah","Yippee","Yo","Yoo-hoo","You bet","You don't say","You know","Yow","Yum","Yummy","Zap","Zounds","Zowie"];
198+
if(IS_RELEASE_BUILD && argv.codeversion && argv.codename) {
199+
var tweet = exclamations[Math.floor(Math.random()*exclamations.length)]+'! Just released @IonicFramework '+argv.codename+' v'+argv.codeversion+' https://github.com/driftyco/ionic/releases/tag/v'+argv.codeversion;
200+
console.log(tweet);
201+
return gulp.src('package.json')
202+
.pipe(twitter(oauth, tweet));
203+
}
204+
});
205+
206+
gulp.task('docs-index', function() {
207+
var idx = lunr(function() {
208+
this.field('path');
209+
this.field('title', {boost: 10});
210+
this.field('body');
211+
this.ref('id');
212+
});
213+
var ref = {};
214+
var refId = 0;
215+
216+
function addToIndex(path, title, layout, body) {
217+
// Add the data to the indexer and ref object
218+
idx.add({'path': path, 'body': body, 'title': title, id: refId});
219+
ref[refId] = {'p': path, 't': title, 'l': layout};
220+
refId++;
221+
}
222+
223+
return gulp.src([
224+
'tmp/ionic-site/docs/{components,guide,api,overview}/**/*.{md,html,markdown}',
225+
'tmp/ionic-site/docs/index.html',
226+
'tmp/ionic-site/getting-started/index.html',
227+
'tmp/ionic-site/tutorials/**/*.{md,html,markdown}',
228+
'tmp/ionic-site/_posts/**/*.{md,html,markdown}'
229+
])
230+
.pipe(es.map(function(file, callback) {
231+
//docs for gulp file objects: https://github.com/wearefractal/vinyl
232+
var contents = file.contents.toString(); //was buffer
233+
234+
// Grab relative path from ionic-site root
235+
var relpath = file.path.replace(/^.*?tmp\/ionic-site\//, '');
236+
237+
// Read out the yaml portion of the Jekyll file
238+
var yamlStartIndex = contents.indexOf('---');
239+
240+
if (yamlStartIndex === -1) {
241+
return callback();
242+
}
243+
244+
// read Jekyll's page yaml variables at the top of the file
245+
var yamlEndIndex = contents.indexOf('---', yamlStartIndex+3); //starting from start
246+
var yamlRaw = contents.substring(yamlStartIndex+3, yamlEndIndex);
247+
248+
var pageData = yaml.safeLoad(yamlRaw);
249+
if(!pageData.title || !pageData.layout) {
250+
return callback();
251+
}
252+
253+
// manually set to not be searchable, or for a blog post, manually set to be searchable
254+
if(pageData.searchable === false || (pageData.layout == 'post' && pageData.searchable !== true)) {
255+
return callback();
256+
}
257+
258+
// clean up some content so code variables are searchable too
259+
contents = contents.substring(yamlEndIndex+3);
260+
contents = contents.replace(/<code?>/gi, '');
261+
contents = contents.replace(/<\/code>/gi, '');
262+
contents = contents.replace(/<code?></gi, '');
263+
contents = contents.replace(/><\/code>/gi, '');
264+
contents = contents.replace(/`</gi, '');
265+
contents = contents.replace(/>`/gi, '');
266+
267+
// create a clean path to the URL
268+
var path = '/' + relpath.replace('index.md', '')
269+
.replace('index.html', '')
270+
.replace('.md', '.html')
271+
.replace('.markdown', '.html');
272+
if(pageData.layout == 'post') {
273+
path = '/blog/' + path.substring(19).replace('.html', '/');
274+
}
275+
276+
if(pageData.search_sections === true) {
277+
// each section within the content should be its own search result
278+
var section = { body: '', title: '' };
279+
var isTitleOpen = false;
280+
281+
var parser = new htmlparser.Parser({
282+
ontext: function(text){
283+
if(isTitleOpen) {
284+
section.title += text; // get the title of this section
285+
} else {
286+
section.body += text.replace(/{%.*%}/, '', 'g'); // Ignore any Jekyll expressions
287+
}
288+
},
289+
onopentag: function(name, attrs) {
290+
if(name == 'section' && attrs.id) {
291+
// start building new section data
292+
section = { body: '', path: path + '#' + attrs.id, title: '' };
293+
} else if( (name == 'h1' || name == 'h2' || name == 'h3') && attrs.class == 'title') {
294+
isTitleOpen = true; // the next text will be this sections title
295+
}
296+
},
297+
onclosetag: function(name) {
298+
if(name == 'section') {
299+
// section closed, index this section then clear it out
300+
addToIndex(section.path, section.title, pageData.layout, section.body);
301+
section = { body: '', title: '' };
302+
} else if( (name == 'h1' || name == 'h2' || name == 'h3') && isTitleOpen) {
303+
isTitleOpen = false;
304+
}
305+
}
306+
});
307+
parser.write(contents);
308+
parser.end();
309+
310+
} else {
311+
// index the entire page
312+
var body = '';
313+
var parser = new htmlparser.Parser({
314+
ontext: function(text){
315+
body += text.replace(/{%.*%}/, '', 'g'); // Ignore any Jekyll expressions
316+
}
317+
});
318+
parser.write(contents);
319+
parser.end();
320+
321+
addToIndex(path, pageData.title, pageData.layout, body);
322+
}
323+
324+
callback();
325+
326+
})).on('end', function() {
327+
// Write out as one json file
328+
mkdirp.sync('tmp/ionic-site/data');
329+
fs.writeFileSync(
330+
'tmp/ionic-site/data/index.json',
331+
JSON.stringify({'ref': ref, 'index': idx.toJSON()})
332+
);
333+
});
334+
});
320335

321336
gulp.task('sauce-connect', sauceConnect);
322337

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@
4444
"js-yaml": "3.0.2",
4545
"event-stream": "3.1.0",
4646
"gulp-strip-debug": "^0.3.0",
47-
"gulp-footer": "^1.0.4"
47+
"gulp-footer": "^1.0.4",
48+
"gulp-twitter": "0.0.3"
4849
},
4950
"licenses": [
5051
{

scripts/travis/release-new-version.sh

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ function run {
5252
git push -q $RELEASE_REMOTE v$VERSION
5353

5454
echo "-- v$VERSION \"$CODENAME\" pushed to $RELEASE_REMOTE/master successfully!"
55+
56+
gulp tweet --release --codeversion "$VERSION" --codename "$CODENAME"
5557
}
5658

5759
source $(dirname $0)/../utils.inc

0 commit comments

Comments
 (0)