-
Notifications
You must be signed in to change notification settings - Fork 14
/
build-zip.js
62 lines (53 loc) · 1.7 KB
/
build-zip.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
const { createWriteStream } = require('fs')
const archiver = require('archiver')
const pkg = require('./package.json')
const templateOutput = createWriteStream(`${__dirname}/tpl_lightning-v${pkg.version}.zip`)
const pluginOutput = createWriteStream(`${__dirname}/plg_sampledata-lightning_v${pkg.version}.zip`)
const template = archiver('zip', {
zlib: { level: 9 }
})
const plugin = archiver('zip', {
zlib: { level: 9 }
})
// Listen for all archive data to be written
templateOutput.on('close', () => {
console.log(`Template has been packaged successfully`)
})
pluginOutput.on('close', () => {
console.log(`Plugin has been packaged successfully`)
})
// Catch this error explicitly
template.on('error', (err) => {
throw err
})
plugin.on('error', (err) => {
throw err
})
// Pipe archive data to the file
template.pipe(templateOutput)
plugin.pipe(pluginOutput)
// Append the files and directories
template.file('component.php')
template.file('error.php')
template.file('helper.php')
template.file('favicon.ico')
template.file('index.php')
template.file('offline.php')
template.file('joomla.asset.json')
template.file('template_preview.png')
template.file('template_thumbnail.png')
template.file('templateDetails.xml')
template.directory('css/')
template.directory('favicon/')
template.directory('fields/')
template.directory('helper/')
template.directory('html/')
template.directory('js/')
template.directory('src/')
template.directory('language/')
template.directory('webfonts/')
plugin.directory('sampledata/')
// Finalise the template (ie we are done appending files but streams have to finish yet)
template.finalize()
// Finalise the plugin (ie we are done appending files but streams have to finish yet)
plugin.finalize()