mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-20 12:29:55 +08:00
chore(ci): sync paralell demo builds via s3
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@ -22,6 +22,7 @@ $RECYCLE.BIN/
|
|||||||
.DS_Store
|
.DS_Store
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
UserInterfaceState.xcuserstate
|
UserInterfaceState.xcuserstate
|
||||||
|
.env
|
||||||
|
|
||||||
.package.tmp.json
|
.package.tmp.json
|
||||||
|
|
||||||
|
@ -68,6 +68,7 @@
|
|||||||
"del": "2.2.2",
|
"del": "2.2.2",
|
||||||
"dgeni": "^0.4.7",
|
"dgeni": "^0.4.7",
|
||||||
"dgeni-packages": "^0.16.10",
|
"dgeni-packages": "^0.16.10",
|
||||||
|
"dotenv": "4.0.0",
|
||||||
"event-stream": "3.3.4",
|
"event-stream": "3.3.4",
|
||||||
"file-loader": "0.9.0",
|
"file-loader": "0.9.0",
|
||||||
"fs-extra": "^2.0.0",
|
"fs-extra": "^2.0.0",
|
||||||
@ -120,6 +121,7 @@
|
|||||||
"rollup-plugin-node-resolve": "3.0.0",
|
"rollup-plugin-node-resolve": "3.0.0",
|
||||||
"rollup-plugin-uglify": "1.0.1",
|
"rollup-plugin-uglify": "1.0.1",
|
||||||
"run-sequence": "1.2.2",
|
"run-sequence": "1.2.2",
|
||||||
|
"s3": "4.4.0",
|
||||||
"sassdoc": "2.2.1",
|
"sassdoc": "2.2.1",
|
||||||
"semver": "5.3.0",
|
"semver": "5.3.0",
|
||||||
"serve-static": "1.11.1",
|
"serve-static": "1.11.1",
|
||||||
|
@ -19,7 +19,8 @@ function run {
|
|||||||
cd ..
|
cd ..
|
||||||
VERSION=$(readJsonProp "package.json" "version")
|
VERSION=$(readJsonProp "package.json" "version")
|
||||||
|
|
||||||
#compile API Demos
|
# download and copy over API Demos
|
||||||
|
./node_modules/.bin/gulp demos.download
|
||||||
./node_modules/.bin/gulp docs.demos --production=true
|
./node_modules/.bin/gulp docs.demos --production=true
|
||||||
|
|
||||||
# if release, copy old version to seperate folder and blow out docs root api
|
# if release, copy old version to seperate folder and blow out docs root api
|
||||||
|
@ -4,6 +4,7 @@ import * as glob from 'glob';
|
|||||||
import { task } from 'gulp';
|
import { task } from 'gulp';
|
||||||
import * as del from 'del';
|
import * as del from 'del';
|
||||||
import * as runSequence from 'run-sequence';
|
import * as runSequence from 'run-sequence';
|
||||||
|
import * as s3 from 's3';
|
||||||
import { argv } from 'yargs';
|
import { argv } from 'yargs';
|
||||||
|
|
||||||
|
|
||||||
@ -12,6 +13,9 @@ import { createTempTsConfig, getFolderInfo, runAppScriptsBuild, writePolyfills }
|
|||||||
|
|
||||||
import * as pAll from 'p-all';
|
import * as pAll from 'p-all';
|
||||||
|
|
||||||
|
import * as dotenv from 'dotenv';
|
||||||
|
dotenv.config();
|
||||||
|
|
||||||
task('demos.prepare', (done: Function) => {
|
task('demos.prepare', (done: Function) => {
|
||||||
runSequence('demos.clean', 'demos.polyfill', 'demos.sass', (err: any) => done(err));
|
runSequence('demos.clean', 'demos.polyfill', 'demos.sass', (err: any) => done(err));
|
||||||
});
|
});
|
||||||
@ -95,9 +99,19 @@ function buildDemo(filePath: string) {
|
|||||||
const appNgModulePath = join(dirname(filePath), 'app.module.ts');
|
const appNgModulePath = join(dirname(filePath), 'app.module.ts');
|
||||||
const distDir = join(distTestRoot, 'www');
|
const distDir = join(distTestRoot, 'www');
|
||||||
|
|
||||||
return runAppScriptsBuild(appEntryPoint, appNgModulePath, ionicAngularDir, distDir, pathToWriteFile, ionicAngularDir, sassConfigPath, copyConfigPath).then(() => {
|
return runAppScriptsBuild(
|
||||||
|
appEntryPoint,
|
||||||
|
appNgModulePath,
|
||||||
|
ionicAngularDir,
|
||||||
|
distDir,
|
||||||
|
pathToWriteFile,
|
||||||
|
ionicAngularDir,
|
||||||
|
sassConfigPath,
|
||||||
|
copyConfigPath
|
||||||
|
).then(() => {
|
||||||
const end = Date.now();
|
const end = Date.now();
|
||||||
console.log(`${filePath} took a total of ${(end - start) / 1000} seconds to build`);
|
console.log(`${filePath} took a total of ${(end - start) / 1000} seconds to build`);
|
||||||
|
uploadToS3(pathToWriteFile);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,6 +126,78 @@ function chunkArrayInGroups(arr, size) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function uploadToS3(path) {
|
||||||
|
// fail silently if envars not present
|
||||||
|
if (!process.env.AWS_KEY || !process.env.AWS_SECRET) {
|
||||||
|
return new Promise((resolve) => {resolve();});
|
||||||
|
}
|
||||||
|
|
||||||
|
let client = s3.createClient({
|
||||||
|
s3Options: {
|
||||||
|
accessKeyId: process.env.AWS_KEY,
|
||||||
|
secretAccessKey: process.env.AWS_SECRET
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// get demo name from path
|
||||||
|
let demo = path.split('/')[path.split('/').length - 2];
|
||||||
|
|
||||||
|
let params = {
|
||||||
|
localDir: path.replace('tsconfig.json',''),
|
||||||
|
deleteRemoved: true,
|
||||||
|
s3Params: {
|
||||||
|
Bucket: "ionic-demos",
|
||||||
|
Prefix: demo,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
var uploader = client.uploadDir(params);
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
uploader.on('error', function(err) {
|
||||||
|
console.error("s3 Upload Error:", err.stack);
|
||||||
|
reject();
|
||||||
|
});
|
||||||
|
uploader.on('end', function() {
|
||||||
|
console.log(demo, " demo uploaded to s3");
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
task('demos.download', (done: Function) => {
|
||||||
|
if (!process.env.AWS_KEY || !process.env.AWS_SECRET) {
|
||||||
|
return new Promise((resolve) => {resolve();});
|
||||||
|
}
|
||||||
|
|
||||||
|
let client = s3.createClient({
|
||||||
|
s3Options: {
|
||||||
|
accessKeyId: process.env.AWS_KEY,
|
||||||
|
secretAccessKey: process.env.AWS_SECRET
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
let params = {
|
||||||
|
localDir: join(process.cwd(), 'dist', 'demos', 'src'),
|
||||||
|
s3Params: {
|
||||||
|
Bucket: "ionic-demos",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
let uploader = client.downloadDir(params);
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
uploader.on('error', function(err) {
|
||||||
|
console.error("s3 Download Error:", err.stack);
|
||||||
|
reject();
|
||||||
|
});
|
||||||
|
uploader.on('end', function() {
|
||||||
|
console.log("Demos downloaded from s3");
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
|
||||||
task('demos.clean', (done: Function) => {
|
task('demos.clean', (done: Function) => {
|
||||||
// this is a super hack, but it works for now
|
// this is a super hack, but it works for now
|
||||||
if (argv.skipClean) {
|
if (argv.skipClean) {
|
||||||
|
Reference in New Issue
Block a user