@polylith/builder 0.2.3 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/App.js +10 -8
  2. package/package.json +3 -2
  3. package/plugin-watch.js +12 -0
package/App.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import path from 'node:path';
2
2
  import {readFile, writeFile, stat} from 'node:fs/promises';
3
+ import cc from "node-console-colors";
3
4
  import express from 'express';
4
5
  import * as rollup from 'rollup';
5
6
  import { babel } from '@rollup/plugin-babel';
@@ -17,6 +18,7 @@ import features from './plugin-features.js';
17
18
  import resources from "./plugin-copy-resources.js";
18
19
  import jsconfig from "./plugin-jsconfig.js";
19
20
  import loadConfigs from "./plugin-config.js";
21
+ import watchLog from "./plugin-watch.js";
20
22
 
21
23
  import {forceToPosix, fileExists} from './utils.js'
22
24
  import ConfigFeature from './ConfigFeature.js';
@@ -124,13 +126,13 @@ export default class App {
124
126
  await router(appRouter, this);
125
127
  return true;
126
128
  } catch(e) {
127
- console.error('error while building router', this.modulePath);
129
+ console.error(cc.set('fg_red'), 'error while building router', this.modulePath);
128
130
  console.log(e);
129
131
  }
130
132
  }
131
133
 
132
134
  async sendIndex(res) {
133
- var indexPath = path.join(this.root, this.htmlTemplate.destination);
135
+ var indexPath = path.posix.join(this.root, this.htmlTemplate.source);
134
136
  res.sendFile(indexPath)
135
137
  }
136
138
 
@@ -464,7 +466,7 @@ export default class App {
464
466
  let feature = module.default;
465
467
  await feature.build(this);
466
468
  } catch(e) {
467
- console.error('error while building feature', root);
469
+ console.error(cc.set('fg_red'), 'error while building feature', root);
468
470
  console.log(e);
469
471
  }
470
472
 
@@ -704,7 +706,8 @@ export default class App {
704
706
  destination: this.htmlTemplate.destination,
705
707
  templateVars: this.templateVariables,
706
708
  }),
707
- resources(this.name, this.files, false)
709
+ resources(this.name, this.files, false),
710
+ watchLog(),
708
711
  ];
709
712
 
710
713
  if (this.liveReload) {
@@ -808,21 +811,20 @@ export default class App {
808
811
 
809
812
  const watcher = rollup.watch(watchConfig);
810
813
  watcher.on('event', function(event) {
811
- console.log(event.code);
812
814
  if (event.result) {
813
815
  event.result.close();
814
816
  }
815
817
 
816
818
  if (event.code === 'ERROR') {
817
- console.error(event.error)
819
+ console.error(cc.set('fg_red'), event.error)
818
820
  }
819
821
 
820
822
  if (event.code === 'BUNDLE_START') {
821
- // console.log(event);
823
+ console.log(cc.set('fg_blue'), 'building...')
822
824
  }
823
825
 
824
826
  if (event.code === 'BUNDLE_END') {
825
- // console.log(event);
827
+ console.log(cc.set('fg_blue'), 'build complete')
826
828
  }
827
829
  }.bind(this));
828
830
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polylith/builder",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "description": "The polylith builder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -28,6 +28,7 @@
28
28
  "fast-glob": "^3.2.12",
29
29
  "fs-extra": "^10.0.0",
30
30
  "less": "^4.1.2",
31
+ "node-console-colors": "^1.1.5",
31
32
  "rollup": "^2.58.0",
32
33
  "rollup-plugin-html": "^0.2.1",
33
34
  "rollup-plugin-jsx": "^1.0.3",
@@ -36,4 +37,4 @@
36
37
  "rollup-plugin-styles": "^4.0.0",
37
38
  "sass": "^1.43.4"
38
39
  }
39
- }
40
+ }
@@ -0,0 +1,12 @@
1
+ import cc from "node-console-colors";
2
+
3
+ export default function watch() {
4
+ return {
5
+ name: 'watch-log',
6
+
7
+ watchChange(id, type) {
8
+ console.log(`${cc.set('fg_green')}${type.event}${cc.set('reset')} of file ${id}`)
9
+ return null;
10
+ }
11
+ };
12
+ }