@polylith/builder 0.1.19 → 0.1.20

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.
package/App.js CHANGED
@@ -67,7 +67,7 @@ export default class App {
67
67
  this.configs = [];
68
68
  this.manualChunkType = 'function';
69
69
  this.manualChunks = [];
70
- this.files = new Files(this.sourcePath, this.destPath);
70
+ this.files = new Files(this.sourcePath, this.destPath, this.testPath);
71
71
  this.cssSpecs = [];
72
72
  this.cssFiles = [];
73
73
  this.liveReload = true;
@@ -248,7 +248,7 @@ export default class App {
248
248
  * Call this method to find all the css files specified by the css specs
249
249
  */
250
250
  async findMainCss() {
251
- var files = new Files(this.sourcePath, this.destPath)
251
+ var files = new Files(this.sourcePath, this.destPath, this.testPath)
252
252
 
253
253
  // Find all the files from the added css specs. Also add them to be copied
254
254
  this.cssSpecs.forEach(function(spec) {
@@ -584,7 +584,7 @@ export default class App {
584
584
  loader(this.loadables),
585
585
  features(this.featureIndexes),
586
586
  styles(),
587
- resources(this.name, this.files)
587
+ resources(this.name, this.files, true)
588
588
  ];
589
589
 
590
590
  var config = {
@@ -680,7 +680,7 @@ export default class App {
680
680
  destination: this.htmlTemplate.destination,
681
681
  templateVars: this.templateVariables,
682
682
  }),
683
- resources(this.name, this.files)
683
+ resources(this.name, this.files, false)
684
684
  ];
685
685
 
686
686
  if (this.liveReload) {
package/Files.js CHANGED
@@ -17,12 +17,17 @@ export default class Files {
17
17
  * destination directory
18
18
  * @param {String} src the abolute path to the applications source
19
19
  * directory
20
+ *
21
+ * @param {String} src the abolute path to the applications test
22
+ * directory
20
23
  */
21
- constructor(src, dest) {
24
+ constructor(src, dest, testDest) {
22
25
  this.dest = dest;
26
+ this.testDest = testDest;
23
27
  this.src = src;
24
28
  /** @type {CopyInfoList} */
25
29
  this.files = {};
30
+ this.testFiles = {};
26
31
  this.specs = [];
27
32
  }
28
33
 
@@ -66,6 +71,21 @@ export default class Files {
66
71
  return destFilename;
67
72
  }
68
73
 
74
+ makeTestDestination() {
75
+ var fullPath = searchRoot;
76
+ var relativePath = srcFilename.slice(fullPath.length + 1);
77
+ var destFilename = '';
78
+
79
+ if (spec.keepNest) {
80
+ destFilename = path.join(this.dest, spec.testDest, relativePath);
81
+ } else {
82
+ destFilename = path.join(this.dest, spec.testDest, path.basename(srcFilename));
83
+ }
84
+
85
+ return destFilename;
86
+
87
+ }
88
+
69
89
  /**
70
90
  * Call this method once per spec to add a list of files to the complete
71
91
  * list of all the files to be copied. If multiple files are found through
@@ -97,12 +117,14 @@ export default class Files {
97
117
  }
98
118
 
99
119
  var destination = this.makeDestination(searchRoot, spec, file);
120
+ var testDestination = this.makeTestDestination(searchRoot, spec, file);
100
121
  var uri = destination.slice(this.dest.length + 1);
101
122
 
102
123
  foundFiles[file] = {
103
124
  name: file,
104
125
  searchRoot: searchRoot,
105
126
  destFilename: destination,
127
+ testDestFilename: testDestination,
106
128
  uri: uri,
107
129
  spec: spec,
108
130
  }
@@ -132,10 +154,10 @@ export default class Files {
132
154
  *
133
155
  * @param {String} file the full path of the file to be copied
134
156
  */
135
- async copyOneFile(file, updated) {
157
+ async copyOneFile(file, updated, forTest) {
136
158
  file = forceToPosix(file);
137
159
 
138
- var destination = this.files[file] && this.files[file].destFilename;
160
+ var destination = forTest ? this.files[file] && this.files[file].testDestFilename : this.files[file] && this.files[file].destFilename;
139
161
 
140
162
  if (destination && updated) {
141
163
  console.log(`file ${file} updated, copied to ${destination}`);
@@ -191,15 +213,17 @@ export default class Files {
191
213
  /**
192
214
  * Call this method to copy all the files that have been specified by
193
215
  * calling addResourceSpec to their destination directories
216
+ *
217
+ * @param {Boolean} forTest set true if copying files to test destination
194
218
  */
195
- async copyFiles() {
219
+ async copyFiles(forTest) {
196
220
  await this.findAllFiles();
197
221
 
198
222
  var filenames = Object.keys(this.files);
199
223
 
200
224
  // using a for loop because we are making async calls
201
225
  for (let srcFilename of filenames) {
202
- let destFilename = this.files[srcFilename].destFilename;
226
+ let destFilename = forTest ? this.files[srcFilename].testDestFilename : this.files[srcFilename].destFilename;
203
227
  let destFilePath = path.dirname(destFilename);
204
228
 
205
229
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@polylith/builder",
3
- "version": "0.1.19",
3
+ "version": "0.1.20",
4
4
  "description": "The polylith builder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -6,7 +6,7 @@ var copied= {}
6
6
  * copy
7
7
  * @returns {Object} the plugin
8
8
  */
9
- export default function(name, files) {
9
+ export default function(name, files, forTest) {
10
10
  return {
11
11
  name: "copy-resources",
12
12
 
@@ -26,7 +26,7 @@ export default function(name, files) {
26
26
  if (copied[name]) return;
27
27
  return new Promise(async function (resolve, reject) {
28
28
  try {
29
- await files.copyFiles();
29
+ await files.copyFiles(forTest);
30
30
  resolve(true)
31
31
  copied[name] = true;
32
32
  } catch (e) {