Permalink
Browse files

chore(gulp): update gulp scripts

  • Loading branch information...
1 parent 17fe72e commit 12c9fd12bd48ef74345810ab07b78641bd5a7b31 @danbucholtz danbucholtz committed with adamdbradley Sep 13, 2016
View
Oops, something went wrong.
@@ -0,0 +1,40 @@
+import { join } from 'path';
+
+
+// Names
+export const COMPONENTS_NAME = 'components';
+export const DIST_NAME = 'dist';
+export const E2E_NAME = 'e2e';
+export const PACKAGE_NAME = 'ionic-angular';
+export const SCRIPTS_NAME = 'scripts';
+export const BUILD_NAME = 'build';
+export const SRC_NAME = 'src';
+export const VENDOR_NAME = 'vendor';
+export const NODE_MODULES = 'node_modules';
+export const COMMONJS_MODULE = 'commonjs';
+export const ES_MODULE = 'es2015';
+
+
+// File Paths
+export const PROJECT_ROOT = join(__dirname, '../..');
+export const DIST_ROOT = join(PROJECT_ROOT, DIST_NAME);
+export const DIST_E2E_ROOT = join(DIST_ROOT, E2E_NAME);
+export const DIST_E2E_COMPONENTS_ROOT = join(DIST_E2E_ROOT, COMPONENTS_NAME);
+export const DIST_BUILD_ROOT = join(DIST_ROOT, PACKAGE_NAME);
+export const DIST_BUILD_COMMONJS_ROOT = join(DIST_BUILD_ROOT, COMMONJS_MODULE);
+export const DIST_VENDOR_ROOT = join(DIST_ROOT, VENDOR_NAME);
+export const NODE_MODULES_ROOT = join(PROJECT_ROOT, NODE_MODULES);
+export const SCRIPTS_ROOT = join(PROJECT_ROOT, SCRIPTS_NAME);
+export const SRC_ROOT = join(PROJECT_ROOT, SRC_NAME);
+export const SRC_COMPONENTS_ROOT = join(SRC_ROOT, COMPONENTS_NAME);
+
+
+// NPM
+export const NPM_VENDOR_FILES = [
+ '@angular', 'core-js/client', 'rxjs', 'systemjs/dist', 'zone.js/dist'
+];
+
+
+// SERVER
+export const LOCAL_SERVER_PORT = 8080;
+
@@ -0,0 +1,9 @@
+import './tasks/build';
+import './tasks/clean';
+import './tasks/default';
+import './tasks/e2e';
+import './tasks/lint';
+import './tasks/release';
+import './tasks/snapshot';
+import './tasks/test';
+//import './tasks/theme';
@@ -0,0 +1,51 @@
+import { COMMONJS_MODULE, DIST_BUILD_ROOT, DIST_BUILD_COMMONJS_ROOT, ES_MODULE } from '../constants';
+import { task } from 'gulp';
+import { copySourceToDest, copySwiperToPath, createTempTsConfig, deleteFiles, runNgc} from '../util';
+
+
+export function buildIonicAngularCommonJs(excludeSpec: boolean, done: Function) {
+ const stream = copySourceToDest(DIST_BUILD_COMMONJS_ROOT, excludeSpec, true);
+ stream.on('end', () => {
+ // the source files are copied, copy over a tsconfig from
+ createTempTsConfig(['./**/*.ts'], COMMONJS_MODULE, `${DIST_BUILD_COMMONJS_ROOT}/tsconfig.json`);
+ runNgc(`${DIST_BUILD_COMMONJS_ROOT}/tsconfig.json`, (err) => {
+ if (err) {
+ done(err);
+ return;
+ }
+
+ copySwiperToPath(`${DIST_BUILD_COMMONJS_ROOT}/components/slides`, COMMONJS_MODULE);
+ // clean up any .ts files that remain, as well as unneeded swiper stuff
+ deleteFiles([`${DIST_BUILD_COMMONJS_ROOT}/**/*.ts`, `!${DIST_BUILD_COMMONJS_ROOT}/**/*.ngfactory.ts`, `!${DIST_BUILD_COMMONJS_ROOT}/**/*.d.ts`], done);
+ });
+ });
+}
+
+export function buildIonicAngularEsm(done: Function) {
+ const stream = copySourceToDest(DIST_BUILD_ROOT, true, true);
+ stream.on('end', () => {
+ // the source files are copied, copy over a tsconfig from
+ createTempTsConfig(['./**/*.ts'], ES_MODULE, `${DIST_BUILD_ROOT}/tsconfig.json`);
+ runNgc(`${DIST_BUILD_ROOT}/tsconfig.json`, (err) => {
+ if (err) {
+ done(err);
+ return;
+ }
+ copySwiperToPath(`${DIST_BUILD_ROOT}/components/slides`, ES_MODULE);
+ // clean up any .ts files that remain
+ deleteFiles([`${DIST_BUILD_ROOT}/**/*.ts`, `!${DIST_BUILD_ROOT}/**/*.ngfactory.ts`, `!${DIST_BUILD_ROOT}/**/*.d.ts`], done);
+ });
+ });
+}
+
+/* this task builds out the necessary stuff for karma */
+task('compile.karma', (done: Function) => {
+ buildIonicAngularCommonJs(false, done);
+});
+
+/* this task builds out the ionic-angular (commonjs and esm) directories for release */
+task('compile.release', (done: Function) => {
+ buildIonicAngularEsm(() => {
+ buildIonicAngularCommonJs(true, done);
+ });
+});
@@ -0,0 +1,12 @@
+import { task } from 'gulp';
+
+
+task('clean', (done: () => void) => {
+ const del = require('del');
+ del(['dist/**'], done);
+});
+
+task('clean.src', (done: () => void) => {
+ const del = require('del');
+ del(['src/**/*.js', 'src/**/*.d.ts', '!src/components/slides/swiper-widget.*'], done);
+});
@@ -0,0 +1,17 @@
+const gulp = require('gulp');
+
+
+gulp.task('default', help);
+
+gulp.task('help', help);
+
+function help() {
+ const taskList = Object.keys(gulp.tasks)
+ .filter(taskName => taskName !== 'default' && taskName !== 'help')
+ .sort()
+ .map(taskName => taskName = ' ' + taskName);
+
+ console.log(taskList.join('\n'));
+}
+
+gulp.task('validate', ['lint', 'test']);
Oops, something went wrong.

0 comments on commit 12c9fd1

Please sign in to comment.