From 78e283c11176c44bf0f44bf89bd48a53840f0a70 Mon Sep 17 00:00:00 2001 From: Sergey Andrievskiy Date: Tue, 15 Jan 2019 18:30:10 +0300 Subject: [PATCH] chore(playground): remove schematics watch task (#1154) --- DEV_DOCS.md | 7 +-- package.json | 4 +- scripts/gulp/gulpfile.ts | 1 - .../tasks/playground/playground-schematic.ts | 43 ------------------- 4 files changed, 6 insertions(+), 49 deletions(-) delete mode 100644 scripts/gulp/tasks/playground/playground-schematic.ts diff --git a/DEV_DOCS.md b/DEV_DOCS.md index 2b876f8563..49266f2fd7 100644 --- a/DEV_DOCS.md +++ b/DEV_DOCS.md @@ -401,7 +401,8 @@ add it to docs/structure.ts create example usage of your component src/playground/[with-layout|without-layout]/your-component/your-component-showcase.component.ts -module and route will be created automatically if you running playground or docs app. + +run 'npm run gen:playground' to generate boilerplate code, such as modules, routes, etc. your-component.component.ts (add line in docs section- * @stacked-example(Your component, your-component/your-component-showcase.component) ```` @@ -415,9 +416,9 @@ Playground is a set of modules containing all Nebular examples. It has two base directories: `with-layout` and `without-layout`. All components in `with-layout` directory will be nested inside of `nb-layout` component. Components from `without-layout` directory will be direct children of router outlet. Put components into `without-layout` directory, if they don't need to or can't be children of layout component, such as a layout itself. ## Playground schematic -Playground schematic watches playground files and generates all boilerplate code for you. Basically, after adding a new component, directive or service declaration, all needed modules and components routes will be generated or modified. +Playground schematic generates all boilerplate code for you. Basically, after adding a new component, directive or service declaration, all needed modules and components routes will be generated or modified. -Schematic starts if you run playground or docs app with `npm start` or `npm run docs:serve` commands. +You can run it via 'npm run gen:playground' command. ### How it works diff --git a/package.json b/package.json index e63e711a00..cfb465f758 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ "gulp": "gulp", "firebase": "firebase", "conventional-changelog": "conventional-changelog", - "prestart": "run-s build:schematics gen:playground", - "start": "run-p \"ng -- serve {@}\" \"gulp -- watch:gen:playground\" -- ", + "prestart": "npm run gen:playground", + "start": "ng serve", "start:prod": "npm run start -- --prod --aot", "start:wp": "npm run start:prod -- playground-wp", "docs:parse": "gulp docs", diff --git a/scripts/gulp/gulpfile.ts b/scripts/gulp/gulpfile.ts index d26b16ce33..b6f5e0c40b 100644 --- a/scripts/gulp/gulpfile.ts +++ b/scripts/gulp/gulpfile.ts @@ -5,6 +5,5 @@ import './tasks/bundle/bundle'; import './tasks/docs/docs'; import './tasks/copy-sources'; import './tasks/bump-versions'; -import './tasks/playground/playground-schematic'; task('default', ['copy-sources']); diff --git a/scripts/gulp/tasks/playground/playground-schematic.ts b/scripts/gulp/tasks/playground/playground-schematic.ts deleted file mode 100644 index f792ab851e..0000000000 --- a/scripts/gulp/tasks/playground/playground-schematic.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { exec } from 'child_process'; -import { task } from 'gulp'; -import { watch } from 'chokidar'; -import { PLAYGROUND_ROOT } from '../config'; - -const PG_GLOB = PLAYGROUND_ROOT + '**/*.ts'; -const DEBOUNCE_TIME = 3000; - -function debounce(callback, delay: number = DEBOUNCE_TIME) { - let timeoutId; - return function debounced() { - clearTimeout(timeoutId); - timeoutId = setTimeout(callback, delay); - } -} - -function startWatch() { - const watcher = watch(PG_GLOB, { ignoreInitial: true }); - const debouncedSchematic = debounce(() => stopWatchRunSchematic(watcher)); - watcher.on('add', debouncedSchematic); - watcher.on('change', debouncedSchematic); -} - -function stopWatchRunSchematic(watcher) { - watcher.close(); - exec('npm run gen:playground', logAndRestart); -} - -function logAndRestart(error: Error, stdout: string, stderr: string): void { - if (error) { - console.error(error); - } - if (stdout) { - // tslint:disable-next-line:no-console - console.log(stdout); - } - if (stderr) { - console.error(stderr); - } - startWatch(); -} - -task('watch:gen:playground', startWatch);