@ascua/mdfiles 0.3.8 → 0.3.10
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/lib/files.js +15 -4
- package/package.json +2 -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
|
|
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
|
-
|
|
39
|
+
`index-${hash}.json`
|
|
35
40
|
);
|
|
41
|
+
|
|
36
42
|
return list;
|
|
43
|
+
|
|
37
44
|
}, {});
|
|
38
|
-
|
|
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,
|
|
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.
|
|
3
|
+
"version": "0.3.10",
|
|
4
4
|
"description": "Small description for @ascua/mdfiles goes here",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ember-addon"
|
|
@@ -31,5 +31,5 @@
|
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"access": "public"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "b1cc09bc0228d44d2118fedb6849f95cf4d86060"
|
|
35
35
|
}
|