@polylith/builder 0.1.23 → 0.1.24

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 (2) hide show
  1. package/App.js +40 -7
  2. package/package.json +1 -1
package/App.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import path from 'node:path';
2
2
  import {readFile, writeFile, stat} from 'node:fs/promises';
3
-
3
+ import express from 'express';
4
4
  import * as rollup from 'rollup';
5
5
  import { babel } from '@rollup/plugin-babel';
6
6
  import * as resolve from '@rollup/plugin-node-resolve';
@@ -97,10 +97,24 @@ export default class App {
97
97
  this.routerRoot = root;
98
98
  }
99
99
 
100
+ /**
101
+ * Call this method to set the relative path from the project root, to a
102
+ * module that exports a default asynchrounsous method that takes an express
103
+ * router and will add to it the application specific routes.
104
+ *
105
+ * @param {String} modulePath
106
+ */
100
107
  setRouterModule(modulePath) {
101
108
  this.modulePath = path.posix.join(this.root, modulePath);
102
109
  }
103
110
 
111
+ /**
112
+ * This is called by the polylith server to setup routing for the
113
+ * application
114
+ *
115
+ * @param {express.Router} appRouter
116
+ * @returns {Promise}
117
+ */
104
118
  async router(appRouter) {
105
119
  if (!this.modulePath) return;
106
120
 
@@ -161,7 +175,6 @@ export default class App {
161
175
  codeBlock +=
162
176
  ` </script>
163
177
  `
164
-
165
178
  return codeBlock;
166
179
  }
167
180
 
@@ -209,8 +222,8 @@ export default class App {
209
222
  * inserted. To specify where the value should be inserted in the template
210
223
  * file add the string "${variableName}" in the location.
211
224
  *
212
- * @param {*} name
213
- * @param {*} value
225
+ * @param {String} name the name of the template variable
226
+ * @param {String} value that will be replaced
214
227
  */
215
228
  setTemplateVariable(name, value) {
216
229
  this.templateVariables[name] = value;
@@ -218,6 +231,7 @@ export default class App {
218
231
 
219
232
  /**
220
233
  * Call this to add a configuration object to the application
234
+ *
221
235
  * @param {Object} config a configuration object that will be added to the
222
236
  * configuration store. Use get from @polylith/config to access
223
237
  */
@@ -465,6 +479,9 @@ export default class App {
465
479
  } else if (indexExists) this.featureIndexes.push(indexPath);
466
480
  }
467
481
 
482
+ /**
483
+ * Call this method to load the features for building the application
484
+ */
468
485
  async buildFeatures() {
469
486
  var features = this.features;
470
487
 
@@ -473,6 +490,9 @@ export default class App {
473
490
  }
474
491
  }
475
492
 
493
+ /**
494
+ * Call this method to load the features when building the tests
495
+ */
476
496
  async testFeatures() {
477
497
  var features = this.features;
478
498
 
@@ -481,8 +501,8 @@ export default class App {
481
501
  }
482
502
  }
483
503
 
484
-
485
504
  /**
505
+ * Call this method to add a module that can be loaded during runtime
486
506
  *
487
507
  * @param {String} root the relative path from the source root to the
488
508
  * feature directory. Loadable paths are assumed to be relative to this
@@ -626,8 +646,7 @@ export default class App {
626
646
  };
627
647
 
628
648
  return config;
629
-
630
- }
649
+ }
631
650
 
632
651
  /**
633
652
  * Call this method to create the configuration for building the app
@@ -730,6 +749,11 @@ export default class App {
730
749
  return config;
731
750
  }
732
751
 
752
+ /**
753
+ * Call this method to build the tests for the application
754
+ *
755
+ * @returns true if successful, false otherwise
756
+ */
733
757
  async test() {
734
758
  this.testing = true;
735
759
  if (!this.testPath || !this.spec) {
@@ -748,6 +772,11 @@ export default class App {
748
772
  return true;
749
773
  }
750
774
 
775
+ /**
776
+ * Call this method to build the application
777
+ *
778
+ * @returns true if successful, false otherwise
779
+ */
751
780
  async build() {
752
781
  this.testing = false;
753
782
  await this.buildFeatures();
@@ -761,6 +790,10 @@ export default class App {
761
790
  return true;
762
791
  }
763
792
 
793
+ /**
794
+ * Call this method to watch the source for changes, and rebuild when they
795
+ * happen.
796
+ */
764
797
  watch() {
765
798
  var watchConfig = {
766
799
  ...this.config.input,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polylith/builder",
3
- "version": "0.1.23",
3
+ "version": "0.1.24",
4
4
  "description": "The polylith builder",
5
5
  "main": "index.js",
6
6
  "type": "module",