Move to using memory-tar-create
parent
c193cabb0d
commit
678682c093
|
@ -1788,6 +1788,11 @@
|
|||
"integrity": "sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ==",
|
||||
"dev": true
|
||||
},
|
||||
"Base64": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/Base64/-/Base64-1.1.0.tgz",
|
||||
"integrity": "sha512-qeacf8dvGpf+XAT27ESHMh7z84uRzj/ua2pQdJg483m3bEXv/kVFtDnMgvf70BQGqzbZhR9t6BmASzKvqfJf3Q=="
|
||||
},
|
||||
"abab": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/abab/-/abab-2.0.3.tgz",
|
||||
|
@ -7459,6 +7464,16 @@
|
|||
"readable-stream": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"memory-tar-create": {
|
||||
"version": "0.0.2",
|
||||
"resolved": "https://registry.npmjs.org/memory-tar-create/-/memory-tar-create-0.0.2.tgz",
|
||||
"integrity": "sha512-RCaVuAgQqD9/oDLo8c9d8yRlAjHkSjcsMmU30TCyvE0l4uXoNw48mVFirmi3acAnLV4bVn6N1nYVI9uHicD52g==",
|
||||
"requires": {
|
||||
"Base64": "^1.1.0",
|
||||
"gzip-js": "^0.3.2",
|
||||
"tarts": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"merge": {
|
||||
"version": "1.2.1",
|
||||
"resolved": "https://registry.npmjs.org/merge/-/merge-1.2.1.tgz",
|
||||
|
|
|
@ -44,13 +44,12 @@
|
|||
"do-bulma": "git+https://github.com/do-community/do-bulma.git",
|
||||
"do-vue": "git+https://github.com/do-community/do-vue.git",
|
||||
"escape-html": "^1.0.3",
|
||||
"gzip-js": "^0.3.2",
|
||||
"memory-tar-create": "0.0.2",
|
||||
"pretty-checkbox-vue": "^1.1.9",
|
||||
"prismjs": "^1.20.0",
|
||||
"qs": "^6.9.4",
|
||||
"simple-js-sha2-256": "^1.0.7",
|
||||
"string-similarity": "^4.0.1",
|
||||
"tarts": "^1.0.0",
|
||||
"vue": "^2.6.11",
|
||||
"vue-select": "^3.10.3"
|
||||
},
|
||||
|
|
|
@ -61,8 +61,7 @@ THE SOFTWARE.
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import tar from 'tarts';
|
||||
import { zip as gzip } from 'gzip-js';
|
||||
import Tar from 'memory-tar-create';
|
||||
import ClipboardJS from 'clipboard';
|
||||
import i18n from '../i18n';
|
||||
import * as Sections from './setup_sections';
|
||||
|
@ -110,43 +109,26 @@ THE SOFTWARE.
|
|||
return undefined;
|
||||
},
|
||||
tarContents() {
|
||||
const data = [];
|
||||
const data = {};
|
||||
|
||||
// Add all our config files to the tar
|
||||
for (const fileName in this.$props.data.confFiles) {
|
||||
if (!Object.prototype.hasOwnProperty.call(this.$props.data.confFiles, fileName)) continue;
|
||||
data.push({ name: fileName, content: this.$props.data.confFiles[fileName] });
|
||||
data[fileName] = { contents: this.$props.data.confFiles[fileName] };
|
||||
|
||||
// If symlinks are enabled and this is in sites-available, symlink to sites-enabled
|
||||
if (this.$props.data.global.tools.symlinkVhost.computed && fileName.startsWith('sites-available'))
|
||||
data.push({
|
||||
name: fileName.replace(/^sites-available/, 'sites-enabled'),
|
||||
typeflag: '2',
|
||||
linkname: `../${fileName}`,
|
||||
content: '',
|
||||
});
|
||||
data[fileName.replace(/^sites-available/, 'sites-enabled')] = { target: `../${fileName}` };
|
||||
}
|
||||
|
||||
return gzip(tar(data), { level: 9 });
|
||||
return new Tar(data).gz();
|
||||
},
|
||||
downloadTar() {
|
||||
// Get the config files as a compressed tar
|
||||
const contents = this.tarContents();
|
||||
|
||||
// Convert it to a blob and download
|
||||
const blob = new Blob([ Uint8Array.from(contents) ], { type: 'application/tar+gzip' });
|
||||
const link = document.createElement('a');
|
||||
link.href = window.URL.createObjectURL(blob);
|
||||
link.download = this.tarName;
|
||||
link.click();
|
||||
this.tarContents().download(this.tarName);
|
||||
},
|
||||
copyTar() {
|
||||
// Get the config files as a compressed tar
|
||||
const contents = this.tarContents();
|
||||
|
||||
// Convert it to base64 string
|
||||
const b64 = btoa(String.fromCharCode(...contents));
|
||||
return `echo '${b64}' | base64 --decode | tee ${this.$props.data.global.nginx.nginxConfigDirectory.computed}/${this.tarName} > /dev/null`;
|
||||
const path = `${this.$props.data.global.nginx.nginxConfigDirectory.computed}/${this.tarName}`;
|
||||
return this.tarContents().base64(path);
|
||||
},
|
||||
setupCopy(elm) {
|
||||
const originalText = elm.textContent;
|
||||
|
|
Loading…
Reference in New Issue