Skip to content

Commit 8c2d514

Browse files
committed
Deployment
1 parent fd43816 commit 8c2d514

File tree

6 files changed

+40
-126
lines changed

6 files changed

+40
-126
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ jobs:
4949
gulp test --coverage ${BROWSERS}
5050
- name: Package
5151
run: |
52-
gulp docs
52+
npm run docs
53+
npm run typedoc
5354
gulp package
5455
gulp bower
5556
- name: Publish Test Results

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ services:
1111
script:
1212
- gulp build
1313
- gulp test --coverage
14-
- gulp docs
14+
- npm docs
15+
- npm typedoc
1516
- gulp package
1617
- gulp bower
1718
- cat ./coverage/lcov.info | ./node_modules/.bin/coveralls || true

gulpfile.js

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const yargs = require('yargs');
1414
const path = require('path');
1515
const htmllint = require('gulp-htmllint');
1616
const typescript = require('gulp-typescript');
17-
const typedoc = require('gulp-typedoc');
1817

1918
const pkg = require('./package.json');
2019
const tsProject = typescript.createProject('./tsconfig.json');
@@ -33,7 +32,6 @@ gulp.task('lint-html', lintHtmlTask);
3332
gulp.task('lint-js', lintJsTask);
3433
gulp.task('lint', gulp.parallel('lint-html', 'lint-js'));
3534
gulp.task('tsc', typescriptTask);
36-
gulp.task('docs', docsTask);
3735
gulp.task('unittest', unittestTask);
3836
gulp.task('test', gulp.parallel('lint', 'tsc', 'unittest'));
3937
gulp.task('library-size', librarySizeTask);
@@ -142,25 +140,6 @@ function lintHtmlTask() {
142140
}));
143141
}
144142

145-
function docsTask(done) {
146-
const bin = require.resolve('gitbook-cli/bin/gitbook.js');
147-
const cmd = argv.watch ? 'serve' : 'build';
148-
149-
return run(bin, ['install', './'])
150-
.then(() => run(bin, [cmd, './', './dist/docs']))
151-
.then(() => {
152-
const config = {
153-
moduleResolution: 'Node',
154-
target: 'ES6',
155-
out: './dist/docs/typedoc'
156-
};
157-
gulp.src(['./src/**/*.js'], {read: false})
158-
.pipe(typedoc(config, done));
159-
}).catch((err) => {
160-
done(new Error(err.stdout || err));
161-
});
162-
}
163-
164143
function unittestTask(done) {
165144
// use `env.test` from `babel.config.json` for karma builds
166145
process.env.NODE_ENV = 'test';

package-lock.json

Lines changed: 0 additions & 82 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@
2929
"dist/*.css",
3030
"dist/*.js"
3131
],
32+
"scripts": {
33+
"docs": "cd docs && npm install && npm run build && mkdir -p ../dist && cp -r build ../dist/docs",
34+
"typedoc": "npx typedoc"
35+
},
3236
"devDependencies": {
3337
"@babel/core": "^7.9.0",
3438
"@babel/plugin-proposal-class-properties": "^7.8.3",
@@ -53,7 +57,6 @@
5357
"gulp-size": "^3.0.0",
5458
"gulp-streamify": "^1.0.2",
5559
"gulp-terser": "^1.2.0",
56-
"gulp-typedoc": "^2.2.4",
5760
"gulp-typescript": "^6.0.0-alpha.1",
5861
"gulp-zip": "^5.0.1",
5962
"jasmine": "^3.5.0",

scripts/deploy.sh

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,27 @@ else
1818
exit 0
1919
fi
2020

21+
function move_sample_scripts {
22+
local subdirectory=$1
23+
for f in $(find ./samples/$subdirectory -name '*.html'); do
24+
sed -i -E "s/((\.\.\/)+dist\/)/..\/\1$subdirectory\//" $f
25+
done
26+
}
27+
28+
function update_next {
29+
# Update next if we're on master
30+
# https://www.chartjs.org/docs/next/
31+
# https://www.chartjs.org/samples/next/
32+
if [ "$VERSION" == "master" ]
33+
then
34+
rm -rf next/docs
35+
cp -r ../dist/docs next
36+
rm -rf next/samples
37+
cp -r ../dist/samples next
38+
move_sample_scripts next
39+
fi
40+
}
41+
2142
function update_latest {
2243
local out_path=$1
2344

@@ -29,44 +50,35 @@ function update_latest {
2950

3051
# Don't update "latest" on alpha or beta releases
3152
if [[ "$latest" =~ ^[^-]+$ ]]; then
32-
rm -f $out_path/latest
33-
ln -s $latest $out_path/latest
53+
rm -rf latest/docs
54+
cp -r ../dist/docs latest
55+
rm -rf latest/samples
56+
cp -r ../dist/samples latest
57+
move_sample_scripts lastest
3458
fi
35-
36-
# Always update "next"
37-
rm -f $out_path/next
38-
ln -s $latest $out_path/next
3959
}
4060

41-
function deploy_files {
61+
function deploy_versioned_files {
4262
local in_files=$1
4363
local out_path=$2
4464
rm -rf $out_path/$VERSION
4565
mkdir -p $out_path/$VERSION
4666
cp -r $in_files $out_path/$VERSION
47-
update_latest $out_path
4867
}
4968

5069
# Clone the repository and checkout the gh-pages branch
5170
git clone $TARGET_REPO_URL $TARGET_DIR
5271
cd $TARGET_DIR
5372
git checkout $TARGET_BRANCH
5473

55-
# Copy dist files
56-
deploy_files '../dist/*.js' './dist'
57-
58-
# Copy generated documentation
59-
deploy_files '../dist/docs/*' './docs'
74+
# Copy distribution files
75+
deploy_versioned_files 'dist/Chart*.js' './dist'
6076

61-
# Copy samples ...
62-
deploy_files '../samples/*' './samples'
77+
update_next
6378

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

69-
git add -A
81+
git add --all
7082

7183
git remote add auth-origin $TARGET_REPO_URL
7284
git config --global user.email "$GITHUB_AUTH_EMAIL"

0 commit comments

Comments
 (0)