chore(build): reorganization for local testing & demos

This commit is contained in:
Andrew Joslin
2014-05-22 16:45:57 -06:00
parent 9f334ffea1
commit ceb26da2dd
60 changed files with 242 additions and 482 deletions

1
.gitignore vendored
View File

@@ -2,6 +2,7 @@
node_modules
*.sw[mnpcod]
*.log
*.tmp
log.txt
example/cordova/iOS/www/js/framework

View File

@@ -1,7 +1,7 @@
{
"name": "ionic",
"version": "1.0.0-beta.6",
"codename": "cadmium-camel",
"codename": "gadolinium-gator",
"homepage": "https://github.com/driftyco/ionic",
"authors": [
"Max Lynch <max@drifty.com>",

View File

@@ -3,8 +3,6 @@ var fs = require('fs');
module.exports = {
dist: 'dist',
distJs: 'dist/js',
distCss: 'dist/css',
releasePostUrl: fs.readFileSync('config/RELEASE_POST_URL'),
banner:

View File

View File

@@ -0,0 +1,19 @@
var path = require('canonical-path');
var _ = require('lodash');
var projectBase = path.resolve(__dirname, '../..');
module.exports = function(config) {
config.set('logging.level', 'info');
config.set('rendering.templateFolders', [
path.resolve(__dirname, 'templates/demo')
]);
config.set('basePath', __dirname);
config.set('source.projectPath', '.');
config.set('rendering.outputFolder', path.resolve(projectBase, 'temp/ionic-demo'));
};

View File

@@ -1,13 +1,11 @@
var path = require('canonical-path');
var basePath = path.resolve(__dirname, '..');
var _ = require('lodash');
var basePackage = require('dgeni-packages/ngdoc');
var pkg = require('../package.json');
var projectBase = path.resolve(__dirname, '../..');
var pkg = require('../../package.json');
module.exports = function(config) {
config.set('currentVersion', process.env.DOC_VERSION || 'nightly');
config = basePackage(config);
@@ -19,36 +17,35 @@ module.exports = function(config) {
config.set('basePath', __dirname);
config.set('source.projectPath', '.');
config.set('rendering.outputFolder', '../temp/ionic-site');
var versionData = require('./generate-versions')(config);
config.set('versionData', versionData);
config.set('rendering.contentsFolder', path.join('docs', versionData.current.folder));
config.set('demos.outputFolder', path.join(__dirname, '../temp/ionic-demo'));
config.set('rendering.outputFolder', path.resolve(projectBase, 'dist/ionic-site'));
//contentsFolder is set in the version-data processor
config.set('processing.api-docs', {
outputPath: 'api/${docType}/${name}/index.md',
path: 'api/${docType}/${name}/',
moduleOutputPath: 'api/module/${name}/index.md',
modulePath: 'api/module/${name}/',
mergeableTypes: {
demo: 'demos'
}
modulePath: 'api/module/${name}/'
});
config.append('rendering.filters', [
require('./filters/capital')
]);
config.set('source.files', [
{ pattern: 'js/**/*.js', basePath: basePath }
]);
config.append('processing.inlineTagDefinitions', [
require('./inline-tag-defs/link')
]);
config.set('source.files', [
{ pattern: 'js/**/*.js', basePath: projectBase }
]);
config.append('processing.processors', [
require('./processors/version-data'),
require('./processors/index-page'),
require('./processors/jekyll'),
]);
config.append('rendering.filters', [
require('./filters/capital')
]);
config.append('processing.tagDefinitions', require('./tag-defs'));
//Don't conflict with the jekyll tags
@@ -61,14 +58,5 @@ module.exports = function(config) {
commentEnd: '#>'
});
config.append('processing.processors', [
require('./processors/latest-version'),
require('./processors/keywords'),
require('./processors/index-page'),
require('./processors/version-data'),
require('./processors/jekyll'),
require('./processors/demos')
]);
return config;
};

View File

@@ -1,31 +1,29 @@
var path = require('canonical-path');
var log = require('winston');
var currentVersion;
var contentsFolder;
module.exports = {
name: 'index-page',
runAfter: ['adding-extra-docs'],
runBefore: ['extra-docs-added'],
description: 'Create documentation index page',
init: function(config) {
currentVersion = config.get('currentVersion');
contentsFolder = config.get('rendering.contentsFolder');
},
process: function(docs, config) {
var currentVersion = config.get('currentVersion');
var contentsFolder = config.get('rendering.contentsFolder');
var latestVersion = config.get('versionData.latest');
docs.push({
docType: 'index-page',
id: 'index-page',
currentVersion: currentVersion,
template: 'index.template.html',
template: 'api_index.template.html',
outputPath: contentsFolder + '/api/index.md'
});
if (config.get('versionData').latest.name !== currentVersion) {
if (latestVersion.name !== currentVersion) {
docs.push({
docType: 'index-page',
id: 'index-page',
currentVersion: currentVersion,
template: 'index.template.html',
template: 'api_index.template.html',
outputPath: contentsFolder + '/api/index.md'
});
}

View File

@@ -0,0 +1,51 @@
var _ = require('lodash');
var fs = require('fs');
var semver = require('semver');
var path = require('canonical-path');
module.exports = {
name: 'version-data',
runBefore: ['reading-files'],
description: 'Expose version data to templates',
process: function(extraData, config) {
var basePath = config.get('basePath');
var outputFolder = config.get('rendering.outputFolder');
var currentVersion = config.get('currentVersion');
var docsBaseFolder = path.resolve(basePath, outputFolder, 'docs');
var versions;
try {
versions = fs.readdirSync(docsBaseFolder)
.filter(semver.valid)
.sort(semver.rcompare);
} catch(e) {
versions = [];
}
!_.contains(versions, currentVersion) && versions.unshift(currentVersion);
!_.contains(versions, 'nightly') && versions.unshift('nightly');
//First semver valid version is latest
var latestVersion = _.find(versions, semver.valid);
versions = versions.map(function(version) {
//Latest version is in docs root
var folder = version == latestVersion ? '' : version;
return {
href: path.join('/docs', folder),
folder: folder,
name: version
};
});
var versionData = {
list: versions,
current: _.find(versions, { name: currentVersion }),
latest: _.find(versions, {name: latestVersion}) || _.first(versions)
};
config.set('rendering.contentsFolder', path.join('docs', versionData.current.folder));
config.set('versionData', versionData);
extraData.version = versionData;
}
};

View File

@@ -20,7 +20,6 @@ module.exports = [
{ name: 'alias' },
{ name: 'demo' },
{ name: 'javascript' },
{ name: 'css' },
{ name: 'html' },
{ name: 'ngModule' }
{ name: 'css' }
];

View File

@@ -1,5 +1,9 @@
---
<@ include "lib/yaml.template.html" @>
layout: "docs_api"
version: "<$ version.current.name $>"
versionHref: "<$ version.current.href $>"
path: ""
title: Javascript
header_sub_title: Extend Ionic even further with the power of AngularJS
searchable: false

View File

View File

@@ -1,91 +0,0 @@
var _ = require('lodash');
var log = require('winston');
var fs = require('fs');
var path = require('canonical-path');
// Keywords to ignore
var wordsToIgnore = [];
var propertiesToIgnore;
var areasToSearch;
// Keywords start with "ng:" or one of $, _ or a letter
var KEYWORD_REGEX = /^((ng:|[\$_a-z])[\w\-_]+)/;
module.exports = {
name: 'keywords',
runAfter: ['docs-processed'],
runBefore: ['adding-extra-docs'],
description: 'This processor extracts all the keywords from the document',
init: function(config) {
// Load up the keywords to ignore, if specified in the config
if ( config.processing.search && config.processing.search.ignoreWordsFile ) {
var ignoreWordsPath = path.resolve(config.basePath, config.processing.search.ignoreWordsFile);
wordsToIgnore = fs.readFileSync(ignoreWordsPath, 'utf8').toString().split(/[,\s\n\r]+/gm);
log.debug('Loaded ignore words from "' + ignoreWordsPath + '"');
log.silly(wordsToIgnore);
}
areasToSearch = _.indexBy(config.get('processing.search.areasToSearch', ['api', 'guide', 'misc', 'error', 'tutorial']));
propertiesToIgnore = _.indexBy(config.get('processing.search.propertiesToIgnore', []));
log.debug('Properties to ignore', propertiesToIgnore);
},
process: function(docs) {
var ignoreWordsMap = _.indexBy(wordsToIgnore);
// If the title contains a name starting with ng, e.g. "ngController", then add the module name
// without the ng to the title text, e.g. "controller".
function extractTitleWords(title) {
var match = /ng([A-Z]\w*)/.exec(title);
if ( match ) {
title = title + ' ' + match[1].toLowerCase();
}
return title;
}
function extractWords(text, words, keywordMap) {
var tokens = text.toLowerCase().split(/[\.\s,`'"#]+/mg);
_.forEach(tokens, function(token){
var match = token.match(KEYWORD_REGEX);
if (match){
key = match[1];
if ( !keywordMap[key]) {
keywordMap[key] = true;
words.push(key);
}
}
});
}
// We are only interested in docs that live in the right area
docs = _.filter(docs, function(doc) { return areasToSearch[doc.area]; });
_.forEach(docs, function(doc) {
var words = [];
var keywordMap = _.clone(ignoreWordsMap);
// Search each top level property of the document for search terms
_.forEach(doc, function(value, key) {
if ( _.isString(value) && !propertiesToIgnore[key] ) {
extractWords(value, words, keywordMap);
}
});
doc.searchTerms = {
titleWords: extractTitleWords(doc.name),
keywords: _.sortBy(words).join(' ')
};
});
}
};

View File

@@ -1,22 +0,0 @@
var copy = require('cp-r');
var mkdirp = require('mkdirp');
var path = require('canonical-path');
module.exports = {
name: 'latest-version',
runAfter: ['write-files'],
description: 'Copy the latest version (that was compiled to docs/latest) into docs/versionName',
process: function(docs, config) {
var versionData = config.get('versionData');
var docsBase = path.join(config.get('basePath'), config.get('rendering.outputFolder'), 'docs');
var versionDir = path.join(docsBase, versionData.latest.name);
var latestDir = path.join(docsBase, 'api');
mkdirp(versionDir, function() {
copy(latestDir, path.join(versionDir, 'api'), {
deleteFirst: true
});
});
}
};

View File

@@ -1,8 +0,0 @@
module.exports = {
name: 'version-data',
runBefore: ['api-docs'],
description: 'Expose version data to templates',
process: function(extraData, config) {
extraData.version = config.get('versionData');
}
};

View File

@@ -1 +0,0 @@
<$ doc.contents $>

View File

@@ -1 +0,0 @@
<$ doc.contents $>

View File

@@ -1 +0,0 @@
<$ doc.contents $>

View File

@@ -1 +0,0 @@
<$ doc.contents $>

View File

@@ -1 +0,0 @@
<$ doc.contents $>

View File

@@ -1,5 +1,6 @@
var gulp = require('gulp');
var karma = require('karma').server;
var path = require('canonical-path');
var pkg = require('./package.json');
var semver = require('semver');
var through = require('through');
@@ -47,6 +48,10 @@ if (IS_RELEASE_BUILD) {
);
}
if (argv.dist) {
buildConfig.dist = argv.dist;
}
gulp.task('default', ['build']);
gulp.task('build', ['bundle', 'sass']);
gulp.task('validate', ['jshint', 'ddescribe-iit', 'karma']);
@@ -57,8 +62,11 @@ gulp.task('docs', function(done) {
console.log('Usage: gulp docs --doc-version=(nightly|versionName)');
return process.exit(1);
}
process.env.DOC_VERSION = docVersion;
return dgeni.generator(__dirname + '/docs/docs.config.js')().then(function() {
var config = dgeni.loadConfig(path.join(__dirname, '/config/dgeni/docs.config.js'));
config.set('currentVersion', docVersion);
return dgeni.generator(config)().then(function() {
gutil.log('Docs for', gutil.colors.cyan(docVersion), 'generated!');
});
});
@@ -106,12 +114,12 @@ gulp.task('bundle', [
}))
.pipe(header(buildConfig.bundleBanner))
.pipe(concat('ionic.bundle.min.js'))
.pipe(gulp.dest(buildConfig.distJs));
.pipe(gulp.dest(buildConfig.dist + '/js'));
return gulp.src(buildConfig.ionicBundleFiles)
.pipe(header(buildConfig.bundleBanner))
.pipe(concat('ionic.bundle.js'))
.pipe(gulp.dest(buildConfig.distJs));
.pipe(gulp.dest(buildConfig.dist + '/js'));
});
gulp.task('jshint', function() {
@@ -149,11 +157,11 @@ gulp.task('scripts', function() {
.pipe(header(buildConfig.closureStart))
.pipe(footer(buildConfig.closureEnd))
.pipe(header(banner))
.pipe(gulp.dest(buildConfig.distJs))
.pipe(gulp.dest(buildConfig.dist + '/js'))
.pipe(gulpif(IS_RELEASE_BUILD, uglify()))
.pipe(rename({ extname: '.min.js' }))
.pipe(header(banner))
.pipe(gulp.dest(buildConfig.distJs));
.pipe(gulp.dest(buildConfig.dist + '/js'));
});
gulp.task('scripts-ng', function() {
@@ -163,11 +171,11 @@ gulp.task('scripts-ng', function() {
.pipe(header(buildConfig.closureStart))
.pipe(footer(buildConfig.closureEnd))
.pipe(header(banner))
.pipe(gulp.dest(buildConfig.distJs))
.pipe(gulp.dest(buildConfig.dist + '/js'))
.pipe(gulpif(IS_RELEASE_BUILD, uglify()))
.pipe(rename({ extname: '.min.js' }))
.pipe(header(banner))
.pipe(gulp.dest(buildConfig.distJs));
.pipe(gulp.dest(buildConfig.dist + '/js'));
});
gulp.task('sass', function(done) {
@@ -184,10 +192,10 @@ gulp.task('sass', function(done) {
}
}))
.pipe(concat('ionic.css'))
.pipe(gulp.dest(buildConfig.distCss))
.pipe(gulp.dest(buildConfig.dist + '/css'))
.pipe(gulpif(IS_RELEASE_BUILD, minifyCss()))
.pipe(rename({ extname: '.min.css' }))
.pipe(gulp.dest(buildConfig.distCss))
.pipe(gulp.dest(buildConfig.dist + '/css'))
.on('end', done);
});
@@ -204,7 +212,7 @@ gulp.task('version', function() {
time: time
}))
.pipe(rename('version.json'))
.pipe(gulp.dest('dist'));
.pipe(gulp.dest(buildConfig.dist));
});
gulp.task('release-tweet', function(done) {

View File

@@ -8,39 +8,34 @@ ARG_DEFS=(
)
function init {
PROJECT_DIR=$SCRIPT_DIR/../..
TMP_DIR=$PROJECT_DIR/temp
BUILD_DIR=$PROJECT_DIR/dist
APPBASE_DIR=$IONIC_DIST_DIR/app-base
APPBASE_LIB_DIR=$APPBASE_DIR/www/lib/ionic
echo "-- Cloning ionic-app-base..."
APPBASE_DIR=$TMP_DIR/app-base
rm -rf $APPBASE_DIR
mkdir -p $APPBASE_DIR
git clone \
https://driftyco:$GH_TOKEN@github.com/driftyco/ionic-app-base.git \
$APPBASE_DIR \
--depth=1
}
function run {
cd ../..
rm -rf $APPBASE_DIR
mkdir -p $APPBASE_DIR
echo "-- Cloning ionic-app-base..."
git clone \
https://$GH_ORG:$GH_TOKEN@github.com/$GH_ORG/ionic-app-base.git \
$APPBASE_DIR \
--depth=10
cd $APPBASE_DIR
echo "-- Updating files..."
rm -rf $APPBASE_DIR/www/lib/ionic
mkdir -p $APPBASE_DIR/www/lib/ionic
replaceJsonProp "$APPBASE_DIR/bower.json" "ionic" "driftyco/ionic-bower#$VERSION"
rm -rf $APPBASE_LIB_DIR
mkdir -p $APPBASE_LIB_DIR
cp -Rf $BUILD_DIR/* $APPBASE_DIR/www/lib/ionic
cp -Rf $IONIC_BUILD_DIR/* $APPBASE_LIB_DIR
cp -Rf $IONIC_SCSS_DIR $APPBASE_LIB_DIR
mkdir -p $APPBASE_DIR/www/lib/ionic/scss
cp -Rf $PROJECT_DIR/scss/* $APPBASE_DIR/www/lib/ionic/scss
replaceJsonProp "$APPBASE_DIR/bower.json" "ionic" "driftyco\/ionic-bower#$VERSION"
git add -A
git commit -am "release: update ionic to v$VERSION"

View File

@@ -12,37 +12,31 @@ ARG_DEFS=(
)
function init {
TMP_DIR=$SCRIPT_DIR/../../temp
BUILD_DIR=$SCRIPT_DIR/../../dist
PROJECT_DIR=$SCRIPT_DIR/../..
BOWER_DIR=$IONIC_DIST_DIR/ionic-bower
BOWER_DIR=$TMP_DIR/ionic-bower
}
function run {
echo "-- Cloning ionic-bower..."
rm -rf $BOWER_DIR
mkdir -p $BOWER_DIR
echo "-- Cloning ionic-bower..."
git clone https://$GH_ORG:$GH_TOKEN@github.com/$GH_ORG/ionic-bower.git \
git clone https://driftyco:$GH_TOKEN@github.com/driftyco/ionic-bower.git \
$BOWER_DIR \
--depth=10
--depth=1
}
function run {
# move the files from the build
echo "-- Putting build files in ionic-bower..."
cd $BOWER_DIR
cp -Rf $BUILD_DIR/* $BOWER_DIR
cp -Rf $PROJECT_DIR/scss $BOWER_DIR
cp -Rf $IONIC_BUILD_DIR/* $BOWER_DIR
cp -Rf $IONIC_SCSS_DIR $BOWER_DIR
# Angular dependencies are managed by bower, don't include them
rm -rf $BOWER_DIR/js/angular*
rm -rf $BOWER_DIR/CHANGELOG*
rm -rf $BOWER_DIR/version.json # unneeded
rm -rf $BOWER_DIR/{js/angular*,CHANGELOG*,version.json}
echo "-- Copying bower.json from project_dir and renaming main files"
node -p "var b = require('$PROJECT_DIR/bower.json'); \
node -p "var b = require('$IONIC_DIR/bower.json'); \
delete b.ignore; \
b.main = b.main.map(function(s) { return s.replace(/^release\//,''); }); \
JSON.stringify(b,null,2);" \

View File

@@ -10,34 +10,33 @@ ARG_DEFS=(
)
function init {
PROJECT_DIR=$SCRIPT_DIR/../..
BUILD_DIR=$SCRIPT_DIR/../../dist
CDN_DIR=$IONIC_DIST_DIR/ionic-code
IONIC_CODE_DIR=$SCRIPT_DIR/../../temp/ionic-code
rm -rf $IONIC_CODE_DIR
mkdir -p $IONIC_CODE_DIR
echo "-- Cloning ionic-code..."
rm -rf $CDN_DIR
mkdir -p $CDN_DIR
git clone https://driftyco:$GH_TOKEN@github.com/driftyco/ionic-code.git \
$CDN_DIR \
--branch gh-pages \
--depth=1
}
function run {
echo "-- Cloning ionic-code..."
git clone https://$GH_ORG:$GH_TOKEN@github.com/$GH_ORG/ionic-code.git \
$IONIC_CODE_DIR \
--depth=10 \
--branch gh-pages
VERSION_DIR=$CDN_DIR/$VERSION_NAME
VERSION_DIR=$IONIC_CODE_DIR/$VERSION_NAME
rm -rf $VERSION_DIR
mkdir -p $VERSION_DIR
cd $VERSION_DIR
cp -Rf $BUILD_DIR/* $VERSION_DIR
cp -Rf $IONIC_BUILD_DIR/* $VERSION_DIR
echo "-- Generating versions.json..."
cd $IONIC_CODE_DIR/builder
cd $CDN_DIR/builder
python ./generate.py
cd $IONIC_CODE_DIR
cd $CDN_DIR
git add -A
git commit -am "release: $VERSION ($VERSION_NAME)"

View File

@@ -1,43 +0,0 @@
echo "#####################################"
echo "# Update ionic-angular-cordova-seed #"
echo "#####################################"
ARG_DEFS=(
"--version=(.*)"
)
function init {
TMP_DIR=$SCRIPT_DIR/../../temp
BUILD_DIR=$SCRIPT_DIR/../../dist
SEED_DIR=$TMP_DIR/seed
rm -rf $SEED_DIR
mkdir -p $SEED_DIR
}
function run {
cd ../..
rm -rf $SEED_DIR
mkdir -p $SEED_DIR
echo "-- Cloning ionic-angular-cordova-seed..."
git clone \
https://$GH_ORG:$GH_TOKEN@github.com/$GH_ORG/ionic-angular-cordova-seed.git \
$SEED_DIR \
--depth=10
cd $SEED_DIR
echo "-- Updating files..."
cp -Rf $BUILD_DIR/* $SEED_DIR/www/lib/
git add -A
git commit -am "release: update ionic to v$VERSION"
git push -q origin master
echo "-- ionic-angular-cordova-seed files update to v$VERSION successfully!"
}
source $(dirname $0)/../utils.inc

View File

@@ -1,40 +1,32 @@
ARG_DEFS=(
"[--version-name=(.*)]"
"--action=(clone|updateConfig|docs|demos)"
"--action=(updateConfig|docs)"
)
function init {
PROJECT_DIR=$SCRIPT_DIR/../..
BUILD_DIR=$SCRIPT_DIR/../../dist
SITE_DIR=$IONIC_DIST_DIR/ionic-site
IONIC_SITE_DIR=$SCRIPT_DIR/../../temp/ionic-site
}
function clone {
echo "#################################"
echo "## Cloning ionic-site repo.... ##"
echo "#################################"
rm -rf $IONIC_SITE_DIR
mkdir -p $IONIC_SITE_DIR
git clone https://$GH_ORG:$GH_TOKEN@github.com/$GH_ORG/ionic-site.git \
$IONIC_SITE_DIR \
--depth=10 \
--branch=gh-pages
echo "-- Cloning ionic-site..."
# rm -rf $SITE_DIR
# mkdir -p $SITE_DIR
# git clone https://driftyco:$GH_TOKEN@github.com/driftyco/ionic-site.git \
# $SITE_DIR \
# --depth=1 \
# --branch=gh-pages
}
function updateConfig {
echo "#####################################"
echo "## Cloning ionic-site config.yml... #"
echo "## Updating ionic-site config.yml.. #"
echo "#####################################"
VERSION=$(readJsonProp "$BUILD_DIR/version.json" "version")
CODENAME=$(readJsonProp "$BUILD_DIR/version.json" "codename")
DATE=$(readJsonProp "$BUILD_DIR/version.json" "date")
VERSION=$(readJsonProp "$IONIC_BUILD_DIR/version.json" "version")
CODENAME=$(readJsonProp "$IONIC_BUILD_DIR/version.json" "codename")
DATE=$(readJsonProp "$IONIC_BUILD_DIR/version.json" "date")
cd $IONIC_SITE_DIR
cd $SITE_DIR
$(replaceInFile "_config.yml" "latest_download:.*$" "latest_download: http:\/\/code.ionicframework.com\/$VERSION\/ionic-v$VERSION.zip")
$(replaceInFile "_config.yml" "latest_version:.*$" "latest_version: $VERSION \"$CODENAME\"")
@@ -50,17 +42,18 @@ function updateConfig {
# Example: ./scripts/site/publish.sh --action=docs --version-name=nightly
function docs {
echo "#####################################"
echo "## Updating docs for $VERSION_NAME ##"
echo "#####################################"
cd $PROJECT_DIR
cd $IONIC_DIR
gulp docs --doc-version="$VERSION_NAME"
gulp docs-index
VERSION=$(readJsonProp "package.json" "version")
cd $IONIC_SITE_DIR
cd $SITE_DIR
CHANGES=$(git status --porcelain)
@@ -76,29 +69,4 @@ function docs {
fi
}
function demos {
echo "######################################"
echo "## Updating demos for $VERSION_NAME ##"
echo "######################################"
cd $IONIC_SITE_DIR
mkdir -p demos
cp -Rf $PROJECT_DIR/demos/* demos
CHANGES=$(git status --porcelain)
VERSION=$(readJsonProp "$PROJECT_DIR/package.json" "version")
# if no changes, don't commit
if [[ "$CHANGES" == "" ]]; then
echo "-- No changes detected in demos for $VERSION; demos not updated."
else
git add -A
git commit -am "demos: update for $VERSION"
git push -q origin gh-pages
echo "-- Updated deoms for $VERSION successfully!"
fi
}
source $(dirname $0)/../utils.inc

16
scripts/travis/build.sh Executable file
View File

@@ -0,0 +1,16 @@
# run this from project root
# source ./scripts/travis/build.sh
export IONIC_DIR=$PWD
export IONIC_SCSS_DIR=$IONIC_DIR/scss
export IONIC_DIST_DIR=$IONIC_DIR/dist
export IONIC_BUILD_DIR=$IONIC_DIR/dist/build
echo IONIC_DIR=$IONIC_DIR
echo IONIC_SCSS_DIR=IONIC_SCSS_DIR=$IONIC_SCSS_DIR
echo IONIC_DIST_DIR=$IONIC_DIST_DIR
echo IONIC_BUILD_DIR=$IONIC_BUILD_DIR
mkdir -p $IONIC_DIST_DIR $IONIC_BUILD_DIR
gulp build --release --dist="$IONIC_BUILD_DIR"

View File

@@ -1,22 +0,0 @@
echo "###########################################"
echo "# Writing nightly version in package.json #"
echo "###########################################"
ARG_DEFS=(
)
function run {
cd ../..
VERSION=$(readJsonProp "package.json" "version")
NEW_VERSION="$VERSION-nightly-$TRAVIS_BUILD_NUMBER"
replaceJsonProp "package.json" "version" "$NEW_VERSION"
echo "-- Build version is $NEW_VERSION."
}
source $(dirname $0)/../utils.inc

View File

@@ -10,29 +10,27 @@ function init {
if [[ "$TRAVIS" == "true" ]]; then
git config --global user.name 'Ionitron'
git config --global user.email hi@ionicframework.com
export GH_ORG=driftyco
export RELEASE_REMOTE=origin
export GIT_PUSH_DRYRUN="false"
else
# For testing if we aren't on travis
export TRAVIS_BUILD_NUMBER=$RANDOM
export TRAVIS_PULL_REQUEST=false
export TRAVIS_COMMIT=$(git rev-parse HEAD)
export TRAVIS_BRANCH=master
# use your github username as GH_ORG to push to, and it will push to ORG/ionic-code, etc
export GH_ORG=ajoslin
export RELEASE_REMOTE=ajoslin
export GIT_PUSH_DRYRUN="true"
fi
}
function run {
cd ../..
echo "GH_ORG=$GH_ORG"
echo "GH_ORG=driftyco"
echo "RELEASE_REMOTE=$RELEASE_REMOTE"
echo "TRAVIS_BRANCH=$TRAVIS_BRANCH"
echo "TRAVIS_BUILD_NUMBER=$TRAVIS_BUILD_NUMBER"
echo "TRAVIS_PULL_REQUEST=$TRAVIS_PULL_REQUEST"
echo "TRAVIS_COMMIT=$TRAVIS_COMMIT"
echo "GIT_PUSH_DRYRUN=$GIT_PUSH_DRYRUN"
# check for stupid mistakes
gulp jshint
@@ -47,9 +45,9 @@ function run {
exit 0
fi
mkdir -p temp
git show $TRAVIS_COMMIT~1:package.json > temp/package.old.json
OLD_VERSION=$(readJsonProp "temp/package.old.json" "version")
git show $TRAVIS_COMMIT~1:package.json > package-old.json.tmp
OLD_VERSION=$(readJsonProp "package-old.json.tmp" "version")
VERSION=$(readJsonProp "package.json" "version")
CODENAME=$(readJsonProp "package.json" "codename")
@@ -77,13 +75,26 @@ function run {
echo "# Pushing out a new nightly release #"
echo "#####################################"
./scripts/travis/bump-nightly-version.sh
VERSION=$(readJsonProp "package.json" "version")
CODENAME=$(readJsonProp "package.json" "codename")
CURRENT_VERSION=$VERSION
VERSION="$CURRENT_VERSION-nightly-$TRAVIS_BUILD_NUMBER"
replaceJsonProp "package.json" "version" "$VERSION"
echo "-- Build version is $NEW_VERSION."
fi
# Build files after we are sure our version is correct
gulp build --release
export IONIC_DIR=$PWD
export IONIC_SCSS_DIR=$IONIC_DIR/scss
export IONIC_DIST_DIR=$IONIC_DIR/dist
export IONIC_BUILD_DIR=$IONIC_DIR/dist/build
mkdir -p $IONIC_DIST_DIR $IONIC_BUILD_DIR
gulp build --release --dist="$IONIC_BUILD_DIR"
echo "IONIC_DIR=$IONIC_DIR"
echo "IONIC_SCSS_DIR=IONIC_SCSS_DIR=$IONIC_SCSS_DIR"
echo "IONIC_DIST_DIR=$IONIC_DIST_DIR"
echo "IONIC_BUILD_DIR=$IONIC_BUILD_DIR"
if [[ $IS_RELEASE == "true" ]]; then
@@ -94,16 +105,13 @@ function run {
# Version name used on the CDN/docs: nightly or the version
VERSION_NAME=$VERSION
./scripts/site/publish.sh --action="clone"
./scripts/site/publish.sh --action="updateConfig"
./scripts/seed/publish.sh --version="$VERSION"
./scripts/app-base/publish.sh --version="$VERSION"
./scripts/travis/release-new-version.sh \
--action="tweetAndIrc" \
--version=$VERSION
gulp release-tweet
gulp release-irc
else
./scripts/site/publish.sh --action="clone"
VERSION_NAME="nightly"
@@ -118,10 +126,6 @@ function run {
--action="docs" \
--version-name="$VERSION_NAME"
./scripts/site/publish.sh \
--action="demos" \
--version-name="$VERSION_NAME"
./scripts/cdn/publish.sh \
--version=$VERSION \
--version-name="$VERSION_NAME"
@@ -150,4 +154,3 @@ function run {
}
source $(dirname $0)/../utils.inc

View File

@@ -3,139 +3,49 @@
ARG_DEFS=(
"--version=(.*)"
"[--old-version=(.*)]"
"--action=(.*)"
)
function init {
TMP_DIR=$SCRIPT_DIR/../../temp
BUILD_DIR=$SCRIPT_DIR/../../dist
PROJECT_DIR=$SCRIPT_DIR/../..
PUSH_DIR=$IONIC_DIST_DIR/ionic
IONIC_DIR=$TMP_DIR/ionic
echo "-- Cloning ionic master ..."
rm -rf $PUSH_DIR
mkdir -p $PUSH_DIR
git clone https://driftyco:$GH_TOKEN@github.com/driftyco/ionic.git \
$PUSH_DIR \
--depth=1
}
function push {
function run {
echo "##############################"
echo "# Pushing release $VERSION #"
echo "##############################"
cd ../..
rm -rf $IONIC_DIR
mkdir -p $IONIC_DIR
echo "-- Cloning ionic master ..."
git clone https://$GH_ORG:$GH_TOKEN@github.com/$GH_ORG/ionic.git \
$IONIC_DIR \
--depth=10
cd $IONIC_DIR
cd $PUSH_DIR
# Get first codename in list
CODENAME=$(readJsonProp "$PROJECT_DIR/package.json" "codename")
CODENAME=$(readJsonProp "$IONIC_DIR/package.json" "codename")
replaceJsonProp "package.json" "version" "$VERSION"
replaceJsonProp "bower.json" "version" "$VERSION"
replaceJsonProp "component.json" "version" "$VERSION"
echo "-- Putting built files into release folder"
rm -rf release
mkdir -p release
cp -Rf $PROJECT_DIR/dist/* release
cp -Rf $IONIC_BUILD_DIR/* release
git add -A
git commit -m "finalize-release: v$VERSION \"$CODENAME\""
git tag -f -m "v$VERSION" v$VERSION
git push -q $RELEASE_REMOTE master
git push -q $RELEASE_REMOTE v$VERSION
echo "-- v$VERSION \"$CODENAME\" pushed to $RELEASE_REMOTE/master successfully!"
}
# Unused. TODO remove and rewrite as node.js script
function github {
echo "-- Pushing out github release..."
# Get only newest things in changelog - sed until previous version is hit
sed -e '/'"$OLD_VERSION"'/,$d' $PROJECT_DIR/CHANGELOG.md | tail -n +3 \
> $TMP_DIR/CHANGELOG_NEW.md
CODENAME=$(readJsonProp "$IONIC_DIR/package.json" "codename")
# we have to get all releases, then find the one corresponding to this new tag
curl https://api.github.com/repos/$GH_ORG/ionic/releases > $TMP_DIR/releases.json
node -e "var releases = require('$TMP_DIR/releases.json'); \
var id; \
releases.forEach(function(r) { \
if (r.tag_name == 'v$VERSION') { \
id = r.id; \
} \
}); \
require('fs').writeFileSync('$TMP_DIR/RELEASE_ID', id || '');"
node -e "var fs = require('fs'); \
fs.writeFileSync('$TMP_DIR/github.json', JSON.stringify({ \
name: \"v$VERSION '$CODENAME'\", \
tag_name: \"v$VERSION\", \
body: fs.readFileSync('$TMP_DIR/CHANGELOG_NEW.md').toString() \
}));"
RELEASE_ID=$(cat $TMP_DIR/RELEASE_ID)
if [[ "$RELEASE_ID" == "" ]]; then
curl -X POST https://api.github.com/repos/$GH_ORG/ionic/releases \
-H "Authorization: token $GH_TOKEN" \
--data-binary @$TMP_DIR/github.json
else
curl -X PATCH https://api.github.com/repos/$GH_ORG/ionic/releases/$RELEASE_ID \
-H "Authorization: token $GH_TOKEN" \
--data-binary @$TMP_DIR/github.json
fi
echo "-- Github release pushed out successfully!"
}
# Unused. TODO remove and rewrite as node.js script
function discourse {
CODENAME=$(readJsonProp "$IONIC_DIR/package.json" "codename")
# Get only newest things in changelog - sed until previous version is hit
sed -e '/'"$OLD_VERSION"'/,$d' $PROJECT_DIR/CHANGELOG.md | tail -n +3 \
> $TMP_DIR/NEW_CHANGELOG.md
node -e "var fs=require('fs'); \
fs.writeFileSync('$TMP_DIR/discourse.json', \
\"api_key=$DISCOURSE_TOKEN\" + \
\"&api_username=Ionitron\" + \
\"&title=\" + encodeURIComponent(\"v$VERSION '$CODENAME' Released!\") + \
\"&raw=\" + encodeURIComponent(\"Download Instructions: https://github.com/driftyco/ionic#quick-start\n\n\" + fs.readFileSync('$TMP_DIR/CHANGELOG_NEW.md').toString()) \
)";
curl -X POST http://forum.ionicframework.com/posts \
-H 'Content-Type: application/x-www-form-urlencoded' \
--data-binary @$TMP_DIR/discourse.json \
> $TMP_DIR/discourse-response.json
touch $IONIC_DIR/config/RELEASE_POST_URL
OLD_POST_URL=$(cat $IONIC_DIR/config/RELEASE_POST_URL)
if [[ "$OLD_POST_URL" != "" ]]; then
curl -X PUT "$OLD_POST_URL/status" --data "api_key=$DISCOURSE_TOKEN&api_username=Ionitron&status=pinned&enabled=false"
fi
POST_URL=`node -e "var res = require('$TMP_DIR/discourse-response.json'); \
console.log(\"http://forum.ionicframework.com/t/\" + res.topic_slug + \"/\" + res.topic_id);"`
echo $POST_URL > $IONIC_DIR/config/RELEASE_POST_URL
curl -X PUT "$POST_URL/status" \
--data "api_key=$DISCOURSE_TOKEN&api_username=Ionitron&status=pinned&enabled=true"
# curl -X PUT "$POST_URL/status" \
# --data "api_key=$DISCOURSE_TOKEN&api_username=Ionitron&status=closed&enabled=true"
cd $IONIC_DIR
git add config
git commit config -m 'chore(release): update discourse post url'
git push -q origin master
git push -q origin v$VERSION
echo "-- v$VERSION \"$CODENAME\" pushed to origin/master successfully!"
}
function tweetAndIrc {