| 1 |
/** |
| 2 |
* Returns file paths of vue assets |
| 3 |
*/ |
| 4 |
|
| 5 |
/* global module, require */ |
| 6 |
function assets() { |
| 7 |
'use strict'; |
| 8 |
|
| 9 |
// const grunt = require('grunt'); |
| 10 |
const fs = require('fs'); |
| 11 |
let paths = { |
| 12 |
mixins: ['assets/js/utils/jquery-siaf-start.js'], |
| 13 |
components: ['assets/js/utils/jquery-siaf-start.js'], |
| 14 |
componentTemplates: [], |
| 15 |
spa: { |
| 16 |
app: [], |
| 17 |
components: [], |
| 18 |
mixins: [], |
| 19 |
templates: [] |
| 20 |
} |
| 21 |
}; |
| 22 |
|
| 23 |
// mixins |
| 24 |
// const mixinsPath = './admin/form-builder/assets/js/mixins/'; |
| 25 |
// let mixins = fs.readdirSync(mixinsPath); |
| 26 |
|
| 27 |
// mixins.forEach((mixin) => { |
| 28 |
// const path = `${mixinsPath}${mixin}`; |
| 29 |
|
| 30 |
// if (grunt.file.isFile(path)) { |
| 31 |
// paths.mixins.push(path); |
| 32 |
// } |
| 33 |
// }); |
| 34 |
|
| 35 |
// components |
| 36 |
const componentPath = './assets/components/'; |
| 37 |
let components = fs.readdirSync(componentPath); |
| 38 |
|
| 39 |
components.forEach((component) => { |
| 40 |
const path = `${componentPath}${component}`; |
| 41 |
|
| 42 |
if (fs.lstatSync(path).isDirectory()) { |
| 43 |
paths.components.push(path + '/index.js'); |
| 44 |
paths.componentTemplates.push(path + '/template.php'); |
| 45 |
} |
| 46 |
}); |
| 47 |
|
| 48 |
paths.mixins.push('assets/js/utils/jquery-siaf-end.js'); |
| 49 |
paths.components.push('assets/js/utils/jquery-siaf-end.js'); |
| 50 |
|
| 51 |
// SPA component paths |
| 52 |
const spaComponentPath = './assets/spa/components/'; |
| 53 |
let spaComponents = fs.readdirSync(spaComponentPath); |
| 54 |
|
| 55 |
spaComponents.forEach((component) => { |
| 56 |
const path = `${spaComponentPath}${component}`; |
| 57 |
|
| 58 |
if (fs.lstatSync(path).isDirectory()) { |
| 59 |
paths.spa.components.push(path + '/index.js'); |
| 60 |
paths.spa.templates.push(path + '/template.php'); |
| 61 |
} |
| 62 |
}); |
| 63 |
|
| 64 |
// spa mixins |
| 65 |
const spaMixinsPath = './assets/spa/mixins/'; |
| 66 |
let spaMixins = fs.readdirSync(spaMixinsPath); |
| 67 |
|
| 68 |
spaMixins.forEach((mixin) => { |
| 69 |
const path = `${spaMixinsPath}${mixin}`; |
| 70 |
|
| 71 |
paths.spa.mixins.push(path); |
| 72 |
}); |
| 73 |
|
| 74 |
let app = paths.spa.app.concat( paths.spa.components ); |
| 75 |
app.push( './assets/spa/app.js' ); |
| 76 |
|
| 77 |
paths.spa.app = app; |
| 78 |
|
| 79 |
return paths; |
| 80 |
} |
| 81 |
|
| 82 |
module.exports = assets(); |
| 83 |
|