Skip to content

Commit

Permalink
Deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
benmccann committed Apr 28, 2020
1 parent fd43816 commit 8c2d514
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 126 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ jobs:
gulp test --coverage ${BROWSERS}
- name: Package
run: |
gulp docs
npm run docs
npm run typedoc
gulp package
gulp bower
- name: Publish Test Results
Expand Down
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ services:
script:
- gulp build
- gulp test --coverage
- gulp docs
- npm docs
- npm typedoc
- gulp package
- gulp bower
- cat ./coverage/lcov.info | ./node_modules/.bin/coveralls || true
Expand Down
21 changes: 0 additions & 21 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ const yargs = require('yargs');
const path = require('path');
const htmllint = require('gulp-htmllint');
const typescript = require('gulp-typescript');
const typedoc = require('gulp-typedoc');

const pkg = require('./package.json');
const tsProject = typescript.createProject('./tsconfig.json');
Expand All @@ -33,7 +32,6 @@ gulp.task('lint-html', lintHtmlTask);
gulp.task('lint-js', lintJsTask);
gulp.task('lint', gulp.parallel('lint-html', 'lint-js'));
gulp.task('tsc', typescriptTask);
gulp.task('docs', docsTask);
gulp.task('unittest', unittestTask);
gulp.task('test', gulp.parallel('lint', 'tsc', 'unittest'));
gulp.task('library-size', librarySizeTask);
Expand Down Expand Up @@ -142,25 +140,6 @@ function lintHtmlTask() {
}));
}

function docsTask(done) {
const bin = require.resolve('gitbook-cli/bin/gitbook.js');
const cmd = argv.watch ? 'serve' : 'build';

return run(bin, ['install', './'])
.then(() => run(bin, [cmd, './', './dist/docs']))
.then(() => {
const config = {
moduleResolution: 'Node',
target: 'ES6',
out: './dist/docs/typedoc'
};
gulp.src(['./src/**/*.js'], {read: false})
.pipe(typedoc(config, done));
}).catch((err) => {
done(new Error(err.stdout || err));
});
}

function unittestTask(done) {
// use `env.test` from `babel.config.json` for karma builds
process.env.NODE_ENV = 'test';
Expand Down
82 changes: 0 additions & 82 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
"dist/*.css",
"dist/*.js"
],
"scripts": {
"docs": "cd docs && npm install && npm run build && mkdir -p ../dist && cp -r build ../dist/docs",
"typedoc": "npx typedoc"
},
"devDependencies": {
"@babel/core": "^7.9.0",
"@babel/plugin-proposal-class-properties": "^7.8.3",
Expand All @@ -53,7 +57,6 @@
"gulp-size": "^3.0.0",
"gulp-streamify": "^1.0.2",
"gulp-terser": "^1.2.0",
"gulp-typedoc": "^2.2.4",
"gulp-typescript": "^6.0.0-alpha.1",
"gulp-zip": "^5.0.1",
"jasmine": "^3.5.0",
Expand Down
52 changes: 32 additions & 20 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,27 @@ else
exit 0
fi

function move_sample_scripts {
local subdirectory=$1
for f in $(find ./samples/$subdirectory -name '*.html'); do
sed -i -E "s/((\.\.\/)+dist\/)/..\/\1$subdirectory\//" $f
done
}

function update_next {
# Update next if we're on master
# https://www.chartjs.org/docs/next/
# https://www.chartjs.org/samples/next/
if [ "$VERSION" == "master" ]
then
rm -rf next/docs
cp -r ../dist/docs next
rm -rf next/samples
cp -r ../dist/samples next
move_sample_scripts next
fi
}

function update_latest {
local out_path=$1

Expand All @@ -29,44 +50,35 @@ function update_latest {

# Don't update "latest" on alpha or beta releases
if [[ "$latest" =~ ^[^-]+$ ]]; then
rm -f $out_path/latest
ln -s $latest $out_path/latest
rm -rf latest/docs
cp -r ../dist/docs latest
rm -rf latest/samples
cp -r ../dist/samples latest
move_sample_scripts lastest
fi

# Always update "next"
rm -f $out_path/next
ln -s $latest $out_path/next
}

function deploy_files {
function deploy_versioned_files {
local in_files=$1
local out_path=$2
rm -rf $out_path/$VERSION
mkdir -p $out_path/$VERSION
cp -r $in_files $out_path/$VERSION
update_latest $out_path
}

# Clone the repository and checkout the gh-pages branch
git clone $TARGET_REPO_URL $TARGET_DIR
cd $TARGET_DIR
git checkout $TARGET_BRANCH

# Copy dist files
deploy_files '../dist/*.js' './dist'

# Copy generated documentation
deploy_files '../dist/docs/*' './docs'
# Copy distribution files
deploy_versioned_files 'dist/Chart*.js' './dist'

# Copy samples ...
deploy_files '../samples/*' './samples'
update_next

# ... and relocate samples Chart/js scripts
for f in $(find ./samples/$VERSION -name '*.html'); do
sed -i -E "s/((\.\.\/)+dist\/)/..\/\1$VERSION\//" $f
done
update_latest

git add -A
git add --all

git remote add auth-origin $TARGET_REPO_URL
git config --global user.email "$GITHUB_AUTH_EMAIL"
Expand Down

0 comments on commit 8c2d514

Please sign in to comment.