Skip to content

Commit

Permalink
upgrading to angular 6
Browse files Browse the repository at this point in the history
  • Loading branch information
Hunter Horton committed Jul 2, 2018
1 parent c40195f commit 7e82194
Show file tree
Hide file tree
Showing 3 changed files with 505 additions and 511 deletions.
111 changes: 53 additions & 58 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable */
var gulp = require('gulp'),
path = require('path'),
ngc = require('@angular/compiler-cli/src/main').main,
rollup = require('gulp-rollup'),
del = require('del'),
runSequence = require('run-sequence'),
inlineResources = require('./tools/gulp/inline-resources');
path = require('path'),
ngc = require('@angular/compiler-cli/src/main').main,
rollup = require('gulp-rollup'),
del = require('del'),
runSequence = require('run-sequence'),
inlineResources = require('./tools/gulp/inline-resources');

const rootFolder = path.join(__dirname);
const srcFolder = path.join(rootFolder, 'src');
Expand All @@ -17,7 +17,7 @@ const distFolder = path.join(rootFolder, 'dist');
* 1. Delete /dist folder
*/
gulp.task('clean:dist', function () {
return deleteFolders([distFolder]);
return deleteFolders([distFolder]);
});

/**
Expand All @@ -26,17 +26,17 @@ gulp.task('clean:dist', function () {
* when copying to /.tmp.
*/
gulp.task('copy:source', function () {
return gulp.src([`${srcFolder}/**/*`, `!${srcFolder}/node_modules`])
.pipe(gulp.dest(tmpFolder));
return gulp.src([`${srcFolder}/**/*`, `!${srcFolder}/node_modules`])
.pipe(gulp.dest(tmpFolder));
});

/**
* 3. Inline template (.html) and style (.css) files into the the component .ts files.
* We do this on the /.tmp folder to avoid editing the original /src files
*/
gulp.task('inline-resources', function () {
return Promise.resolve()
.then(() => inlineResources(tmpFolder));
return Promise.resolve()
.then(() => inlineResources(tmpFolder));
});


Expand All @@ -45,15 +45,10 @@ gulp.task('inline-resources', function () {
* compiled modules to the /build folder.
*/
gulp.task('ngc', function () {
return ngc({
project: `${tmpFolder}/tsconfig.es5.json`
})
.then((exitCode) => {
if (exitCode === 1) {
// This error is caught in the 'compile' task by the runSequence method callback
// so that when ngc fails to compile, the whole compile process stops running
throw new Error('ngc compilation failed');
}
return ngc(['-p', `${tmpFolder}/tsconfig.es5.json`], (error) => {
if (error) {
throw new Error('ngc compilation failed: ' + error);
}
});
});

Expand All @@ -62,18 +57,18 @@ gulp.task('ngc', function () {
* generated file into the /dist folder
*/
gulp.task('rollup', function () {
return gulp.src(`${buildFolder}/**/*.js`)
// transform the files here.
.pipe(rollup({
// any option supported by Rollup can be set here.
entry: `${buildFolder}/index.js`,
external: [
'@angular/core',
'@angular/common'
],
format: 'es'
}))
.pipe(gulp.dest(distFolder));
return gulp.src(`${buildFolder}/**/*.js`)
// transform the files here.
.pipe(rollup({
// any option supported by Rollup can be set here.
entry: `${buildFolder}/index.js`,
external: [
'@angular/core',
'@angular/common'
],
format: 'es'
}))
.pipe(gulp.dest(distFolder));
});

/**
Expand All @@ -82,58 +77,58 @@ gulp.task('rollup', function () {
* on step 5.
*/
gulp.task('copy:build', function () {
return gulp.src([`${buildFolder}/**/*`, `!${buildFolder}/**/*.js`])
.pipe(gulp.dest(distFolder));
return gulp.src([`${buildFolder}/**/*`, `!${buildFolder}/**/*.js`])
.pipe(gulp.dest(distFolder));
});

/**
* 7. Copy package.json from /src to /dist
*/
gulp.task('copy:manifest', function () {
return gulp.src([`${srcFolder}/package.json`])
.pipe(gulp.dest(distFolder));
return gulp.src([`${srcFolder}/package.json`])
.pipe(gulp.dest(distFolder));
});

/**
* 8. Delete /.tmp folder
*/
gulp.task('clean:tmp', function () {
return deleteFolders([tmpFolder]);
return deleteFolders([tmpFolder]);
});

/**
* 9. Delete /build folder
*/
gulp.task('clean:build', function () {
return deleteFolders([buildFolder]);
return deleteFolders([buildFolder]);
});

gulp.task('compile', function () {
runSequence(
'clean:dist',
'copy:source',
'inline-resources',
'ngc',
'rollup',
'copy:build',
'copy:manifest',
'clean:build',
'clean:tmp',
function (err) {
if (err) {
console.log('ERROR:', err.message);
deleteFolders([distFolder, tmpFolder, buildFolder]);
} else {
console.log('Compilation finished succesfully');
}
});
runSequence(
'clean:dist',
'copy:source',
'inline-resources',
'ngc',
'rollup',
'copy:build',
'copy:manifest',
'clean:build',
'clean:tmp',
function (err) {
if (err) {
console.log('ERROR:', err.message);
deleteFolders([distFolder, tmpFolder, buildFolder]);
} else {
console.log('Compilation finished succesfully');
}
});
});

/**
* Watch for any change in the /src folder and compile files
*/
gulp.task('watch', function () {
gulp.watch(`${srcFolder}/**/*`, ['compile']);
gulp.watch(`${srcFolder}/**/*`, ['compile']);
});

gulp.task('clean', ['clean:dist', 'clean:tmp', 'clean:build']);
Expand All @@ -146,5 +141,5 @@ gulp.task('default', ['build:watch']);
* Deletes the specified folder
*/
function deleteFolders(folders) {
return del(folders);
return del(folders);
}
22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
"url": "https://github.com/bootsoon/ng-circle-progress/issues"
},
"devDependencies": {
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/compiler-cli": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/common": "6.0.7",
"@angular/compiler": "6.0.7",
"@angular/compiler-cli": "6.0.7",
"@angular/core": "6.0.7",
"@angular/platform-browser": "6.0.7",
"@angular/platform-browser-dynamic": "6.0.7",
"@types/jasmine": "2.5.38",
"@types/node": "~6.0.60",
"codelyzer": "~2.0.0",
"codelyzer": "4.4.2",
"core-js": "^2.4.1",
"del": "^2.2.2",
"gulp": "^3.9.1",
Expand All @@ -51,13 +51,13 @@
"protractor": "~5.1.0",
"rollup": "^0.41.6",
"run-sequence": "^1.2.2",
"rxjs": "^5.1.0",
"rxjs": "6.2.1",
"ts-node": "~2.0.0",
"tslint": "~4.5.0",
"typescript": "~2.2.0",
"tslint": "5.10.0",
"typescript": "@>=2.7.2 <2.8",
"zone.js": "^0.8.4"
},
"engines": {
"node": ">=6.0.0"
}
}
}
Loading

0 comments on commit 7e82194

Please sign in to comment.