@ascua/mdfiles 0.3.7 → 0.3.9

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/lib/files.js +15 -4
  2. package/package.json +3 -2
package/lib/files.js CHANGED
@@ -3,6 +3,7 @@
3
3
  const Plugin = require('broccoli-caching-writer');
4
4
  const frontmatter = require('front-matter');
5
5
  const mkdirp = require('mkdirp');
6
+ const crypto = require('crypto');
6
7
  const path = require('path');
7
8
  const fs = require('fs');
8
9
 
@@ -26,16 +27,23 @@ module.exports = class Trees extends Plugin {
26
27
 
27
28
  if (this.opts.type === 'addon') {
28
29
 
29
- let output = this.opts.folders.reduce((list, folder) => {
30
+ let content = this.opts.folders.reduce((list, folder) => {
31
+
32
+ let text = JSON.stringify(output[folder.name]);
33
+ let hash = crypto.createHash('md5').update(text).digest('hex').substring(0,6);
34
+
30
35
  list[folder.name] = path.join(
31
36
  this.opts.rootURL,
32
37
  this.opts.outputDir,
33
38
  folder.name,
34
- 'index.json'
39
+ `index-${hash}.json`
35
40
  );
41
+
36
42
  return list;
43
+
37
44
  }, {});
38
- let buffer = `export default ${JSON.stringify(output)}`;
45
+
46
+ let buffer = `export default ${JSON.stringify(content)}`;
39
47
  fs.writeFileSync(path.join(this.outputPath, 'files.js'), buffer);
40
48
 
41
49
  }
@@ -44,13 +52,16 @@ module.exports = class Trees extends Plugin {
44
52
 
45
53
  for (const [name, entries] of Object.entries(output)) {
46
54
 
55
+ let text = JSON.stringify(entries);
56
+ let hash = crypto.createHash('md5').update(text).digest('hex').substring(0,6);
57
+
47
58
  // Write the index.json file contents
48
59
 
49
60
  let buffer = JSON.stringify(entries.map(v => {
50
61
  return { name: v.name, path: v.path, attributes: v.attributes };
51
62
  }));
52
63
  let folder = path.join(this.outputPath, this.opts.outputDir, name);
53
- let file = path.join(folder, 'index.json');
64
+ let file = path.join(folder, `index-${hash}.json`);
54
65
  mkdirp.sync(folder);
55
66
  fs.writeFileSync(file, buffer);
56
67
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ascua/mdfiles",
3
- "version": "0.3.7",
3
+ "version": "0.3.9",
4
4
  "description": "Small description for @ascua/mdfiles goes here",
5
5
  "keywords": [
6
6
  "ember-addon"
@@ -18,6 +18,7 @@
18
18
  "broccoli-merge-trees": "^4.2.0",
19
19
  "ember-cli-babel": "^7.26.6",
20
20
  "ember-cli-htmlbars": "^5.7.1",
21
+ "ember-fetch": "^8.1.2",
21
22
  "front-matter": "^4.0.2"
22
23
  },
23
24
  "ember-addon": {
@@ -30,5 +31,5 @@
30
31
  "publishConfig": {
31
32
  "access": "public"
32
33
  },
33
- "gitHead": "8d4a6ba81af71d9fab9c88be6d83871399bfbc9d"
34
+ "gitHead": "423cafce26a8a0fd23ff2232113f87095140e118"
34
35
  }