Skip to content

Commit

Permalink
feat(package): added support of angular schematics
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyNahas committed Mar 28, 2019
1 parent c08eff7 commit f65e6e4
Show file tree
Hide file tree
Showing 11 changed files with 874 additions and 10 deletions.
22 changes: 16 additions & 6 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,18 @@ gulp.task('build', ['clean'], (cb) => {
runSequence('compile', 'test', 'npm-package', 'rollup-bundle', cb);
});

// Build the schematics in dist
gulp.task('build:schematics', () => {
// return execDemoCmd(`build --preserve-symlinks --prod --aot --build-optimizer`, {cwd: `${config.demoDir}`});
return execCmd('tsc', '-p src/schematics/tsconfig.json').then(exitCode => {
if (exitCode === 0) {
return execCmd('webpack', '--config src/schematics/webpack.config.js --progress --colors');
} else {
Promise.reject(1);
}
});
});

// Same as 'build' but without cleaning temp folders (to avoid breaking demo app, if currently being served)
gulp.task('build-watch', (cb) => {
runSequence('compile', 'test', 'npm-package', 'rollup-bundle', cb);
Expand Down Expand Up @@ -300,7 +312,7 @@ gulp.task('build:watch-fast', ['build-watch-no-tests'], () => {
gulp.task('npm-package', (cb) => {
let pkgJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
let targetPkgJson = {};
let fieldsToCopy = ['version', 'description', 'keywords', 'author', 'repository', 'license', 'bugs', 'homepage'];
let fieldsToCopy = ['version', 'description', 'keywords', 'author', 'repository', 'license', 'bugs', 'homepage', 'schematics'];

targetPkgJson['name'] = config.libraryName;

Expand Down Expand Up @@ -491,8 +503,7 @@ gulp.task('serve:doc', ['clean:doc'], (cb) => {
const execDemoCmd = (args, opts) => {
if (fs.existsSync(`${config.demoDir}/node_modules`)) {
return execCmd('ng', args, opts, `/${config.demoDir}`);
}
else {
} else {
gulpUtil.log(gulpUtil.colors.yellow(`No 'node_modules' found in '${config.demoDir}'. Installing dependencies for you...`));
return helpers.installDependencies({cwd: `${config.demoDir}`})
.then(exitCode => exitCode === 0 ? execCmd('ng', args, opts, `/${config.demoDir}`) : Promise.reject())
Expand Down Expand Up @@ -657,7 +668,7 @@ gulp.task('create-new-tag', (cb) => {
});

// Build and then Publish 'dist' folder to NPM
gulp.task('npm-publish', ['build'], () => {
gulp.task('npm-publish', ['build', 'build:schematics'], () => {
return execExternalCmd('npm', `publish ${config.outputDir} --access public`)
});

Expand All @@ -672,8 +683,7 @@ gulp.task('release', (cb) => {
if (!readyToRelease()) {
gulpUtil.log(gulpUtil.colors.red('# Pre-Release Checks have failed. Please fix them and try again. Aborting...'));
cb();
}
else {
} else {
gulpUtil.log(gulpUtil.colors.green('# Pre-Release Checks have succeeded. Continuing...'));
runSequence(
'bump-version',
Expand Down
Loading

0 comments on commit f65e6e4

Please sign in to comment.