Skip to content
This repository was archived by the owner on Sep 4, 2020. It is now read-only.

Commit 0f1e8c5

Browse files
author
clouless
committed
1.4.3 optimze building of demo
1 parent 0221ec4 commit 0f1e8c5

File tree

3 files changed

+18
-8
lines changed

3 files changed

+18
-8
lines changed

LIBRARY_DEMO.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ So what happens when I am in my Library e.g. toggle and want the demo angular pr
1414
* Those files should contain the whole demo code, see [pagination for example]().
1515
* 4. The `dist-demo/src/app/app.component.ts` is patched.
1616
* `/*___IMPORTS___*/` is replaced by e.g. `src/demo/demo.imports.txt'`
17-
* 5. `yarn start:demo` is executed internally and your demo is hosted at http://localhost:4200
17+
* 5. `yarn build:demo` followed by `yarn start:demo` is executed internally and your demo is hosted at http://localhost:4200
1818

1919

2020
Put this into your libraries `package.json`
2121

2222
```
2323
"scripts": {
2424
"build": "node ./node_modules/@cloukit/library-build-chain/build.js",
25-
"build:demo": "node ./node_modules/@cloukit/library-build-chain/build.js --demo",
25+
"build:demo": "node ./node_modules/@cloukit/library-build-chain/build.js --demo --install",
2626
"start:demo": "node ./node_modules/@cloukit/library-build-chain/build.js --demo --run",
2727
"watch": "node ./node_modules/@cloukit/library-build-chain/build.js --watch",
2828
"test": "echo \"ok\""

build.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ const relativePath = (_path) => {
2727
// COMPODOC
2828
//
2929
const buildCompodoc = (packageJsonName, packageJsonVersion) => {
30+
if (shell.test('-d', relativePath('./documentation'))) shell.rm('-rf', relativePath('./documentation/'));
3031
//
3132
// COMPODOC
3233
//
@@ -149,17 +150,14 @@ const buildPackage = (languageTarget, watch) => {
149150
// INIT
150151
//
151152
const initialCleanup = () => {
152-
if (shell.test('-d', relativePath('./documentation'))) shell.rm('-rf', relativePath('./documentation/'));
153153
if (shell.test('-d', relativePath('./dist'))) shell.rm('-rf', relativePath('./dist/'));
154154
shell.mkdir(relativePath('./dist/'));
155-
if (shell.test('-d', relativePath('./dist-demo'))) shell.rm('-rf', relativePath('./dist-demo/'));
156155
};
157156

158157
if (argv.watch) {
159158
var gaze = new Gaze('./src/**/*');
160159
gaze.on('all', (event, filepath) => {
161160
try {
162-
//initialCleanup();
163161
buildPackage('es5', true);
164162
buildPackage('es2015', true);
165163
shell.echo(chalk.green('>> =============='));
@@ -187,16 +185,28 @@ if (argv.watch) {
187185
//
188186
if (argv.demo) {
189187
shell.echo(chalk.blue('>> creating dist-demo'));
188+
if (shell.test('-d', relativePath('./dist-demo'))) {
189+
if (shell.test('-d', relativePath('./dist-demo/node_modules'))) {
190+
shell.echo(chalk.blue('>> demo node_modules exists. retaining it.'));
191+
shell.mv(relativePath('./dist-demo/node_modules'), relativePath('./_dist_demo_node_modules'));
192+
}
193+
shell.rm('-rf', relativePath('./dist-demo/'));
194+
}
190195
shell.cp('-r', `./node_modules/@cloukit/library-build-chain/demo-template`, `./dist-demo`);
196+
if (shell.test('-d', relativePath('./_dist_demo_node_modules'))) {
197+
shell.mv(relativePath('_dist_demo_node_modules'), relativePath('./dist-demo/node_modules'));
198+
}
191199
shell.cp('-r', `./src/*`, `./dist-demo/src/`);
192200
const libraryImports = shell.cat('./src/demo/demo.imports.txt').stdout;
193201
shell.sed('-i',
194202
'[/][*]___IMPORTS___[*][/]',
195203
libraryImports,
196204
'./dist-demo/src/app/app.module.ts');
197205
shell.cd(relativePath('./dist-demo/'));
198-
shell.echo(chalk.blue('>> yarn install (this takes time!)'));
199-
shell.exec(`yarn config set "strict-ssl" false && yarn`);
206+
if (argv.install) {
207+
shell.echo(chalk.blue('>> yarn install (this takes time!)'));
208+
shell.exec(`yarn config set "strict-ssl" false && yarn`);
209+
}
200210
shell.echo(chalk.blue('>> ng build'));
201211
shell.exec(`ng build`);
202212
if (argv.run) {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cloukit/library-build-chain",
3-
"version": "1.4.2",
3+
"version": "1.4.3",
44
"description": "Common code to build cloukit Angular Modules",
55
"author": "Bernhard Grünewaldt",
66
"license": "MIT",

0 commit comments

Comments
 (0)