hubbe-sdk 1.2.0

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 (36) hide show
  1. package/bin/.token +1 -0
  2. package/bin/build.js +94 -0
  3. package/bin/defaultHtml.html +23 -0
  4. package/bin/defaultJs.js +49 -0
  5. package/bin/deploy.js +130 -0
  6. package/bin/deployTs.js +157 -0
  7. package/bin/fetch.js +118 -0
  8. package/bin/htmlu.js +116 -0
  9. package/bin/index.js +77 -0
  10. package/bin/react-template/html/eslint.config.js +28 -0
  11. package/bin/react-template/html/index.html +7 -0
  12. package/bin/react-template/html/package.json +34 -0
  13. package/bin/react-template/html/postcss.config.js +6 -0
  14. package/bin/react-template/html/src/App.tsx +33 -0
  15. package/bin/react-template/html/src/hooks/index.ts +3 -0
  16. package/bin/react-template/html/src/hooks/useDraggable.ts +69 -0
  17. package/bin/react-template/html/src/hooks/useMessageEvent.ts +120 -0
  18. package/bin/react-template/html/src/hooks/useUserContext.ts +24 -0
  19. package/bin/react-template/html/src/index.css +5 -0
  20. package/bin/react-template/html/src/main.tsx +10 -0
  21. package/bin/react-template/html/src/vite-env.d.ts +1 -0
  22. package/bin/react-template/html/tailwind.config.js +12 -0
  23. package/bin/react-template/html/tsconfig.app.json +24 -0
  24. package/bin/react-template/html/tsconfig.json +7 -0
  25. package/bin/react-template/html/tsconfig.node.json +22 -0
  26. package/bin/react-template/html/vite.config.ts +10 -0
  27. package/bin/react-template/room/global.d.ts +4222 -0
  28. package/bin/react-template/room/room.ts +36 -0
  29. package/bin/react-template/room/tsconfig.json +9 -0
  30. package/bin/react.js +60 -0
  31. package/bin/rollup.js +67 -0
  32. package/bin/rollupTs.js +72 -0
  33. package/bin/script.js +131 -0
  34. package/bin/tsconfig_template.json +9 -0
  35. package/bin/utils.js +35 -0
  36. package/package.json +57 -0
package/bin/.token ADDED
@@ -0,0 +1 @@
1
+ s
package/bin/build.js ADDED
@@ -0,0 +1,94 @@
1
+ const { execSync } = require('child_process');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const archiver = require('archiver');
5
+
6
+ class Script {
7
+ constructor(name) {
8
+ this.name = name;
9
+ this.directory = process.cwd() + '/' + name + '/' + 'html/';
10
+ this.exec();
11
+ }
12
+
13
+ exec() {
14
+ try {
15
+ execSync('npm run build', { cwd: this.directory, stdio: 'inherit' });
16
+
17
+ // Caminho da pasta "assets"
18
+ const assetsDir = path.join(this.directory, 'dist/assets');
19
+ if (!fs.existsSync(assetsDir)) {
20
+ throw new Error('Pasta assets não encontrada.');
21
+ }
22
+
23
+ // Alterar todas as variáveis "const", "let" para "var" em arquivos .js
24
+ // Adiciona todo o conteudo do js para dentro de uma funcao, para evitar conflitos de variaveis
25
+ const jsFiles = fs.readdirSync(assetsDir).filter(file => file.endsWith('.js'));
26
+ jsFiles.forEach(file => {
27
+ const filePath = path.join(assetsDir, file);
28
+ let content = fs.readFileSync(filePath, 'utf-8');
29
+ content = content.replace(/\bconst\b/g, 'var').replace(/\blet\b/g, 'var');
30
+ content = `(function() {${content}})();`;
31
+ fs.writeFileSync(filePath, content, 'utf-8');
32
+ });
33
+
34
+ // Recriar o index.html
35
+ const indexPath = path.join(this.directory, 'dist/index.html');
36
+
37
+ const cssFile = fs.readdirSync(assetsDir).find(file => file.endsWith('.css'));
38
+ const jsFile = fs.readdirSync(assetsDir).find(file => file.endsWith('.js'));
39
+
40
+ const newIndexContent = `
41
+ <!doctype html>
42
+ <html lang="en">
43
+ <head>
44
+ </head>
45
+ <body>
46
+ <style>
47
+ #root_${this.name} {
48
+ position: absolute;
49
+ }
50
+ </style>
51
+ <div id="root_${this.name}"></div>
52
+ <script src="https://cdn.hubbe.biz/scripts/${this.name}/assets/${jsFile}?v=%dataScript%"></script>
53
+ <link rel="stylesheet" href="https://cdn.hubbe.biz/scripts/${this.name}/assets/${cssFile}?v=%dataScript%" />
54
+ </body>
55
+ </html>
56
+ `;
57
+
58
+ fs.writeFileSync(indexPath, newIndexContent, 'utf-8');
59
+
60
+ // Criar o arquivo zip com a pasta assets e o index.html
61
+ const outputZipPath = path.join(process.cwd() + '/' + this.name, `${this.name + "_html"}.zip`);
62
+ console.log('Criando arquivo zip...');
63
+
64
+ const output = fs.createWriteStream(outputZipPath);
65
+ const archive = archiver('zip', {
66
+ zlib: { level: 9 }
67
+ });
68
+
69
+ output.on('close', () => {
70
+ console.log(`Arquivo zip criado com sucesso: ${outputZipPath} (${archive.pointer()} bytes)`);
71
+ });
72
+
73
+ archive.on('error', (err) => {
74
+ throw err;
75
+ });
76
+
77
+ archive.pipe(output);
78
+
79
+ // Adicionar a pasta assets ao zip
80
+ archive.directory(assetsDir, 'assets');
81
+
82
+ // Adicionar o index.html ao zip
83
+ archive.file(indexPath, { name: 'index.html' });
84
+
85
+ archive.finalize();
86
+
87
+ console.log('Build concluído.');
88
+ } catch (error) {
89
+ console.error('Erro durante a execução:', error.message);
90
+ }
91
+ }
92
+ }
93
+
94
+ module.exports = Script;
@@ -0,0 +1,23 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+
6
+ <link rel="stylesheet" href="https://cdn.hubbe.biz/scripts/%folderName%/style.css?v=%dataScript%">
7
+ </head>
8
+ <body>
9
+
10
+ <style>
11
+ .folderName-container {
12
+ display: none;
13
+ position: absolute;
14
+ }
15
+ </style>
16
+
17
+ <div class="%folderName%-container">
18
+
19
+ </div>
20
+
21
+ <script type="text/javascript" src="https://cdn.hubbe.biz/scripts/%folderName%/script.js?v=%dataScript%"></script>
22
+ </body>
23
+ </html>
@@ -0,0 +1,49 @@
1
+ (async () => {
2
+ const sendMessageToRoom = (eventName, data = "") => {
3
+ window.sendScriptMessage(eventName, data);
4
+ };
5
+
6
+ class Handler {
7
+ events = new Map();
8
+ scriptName = '';
9
+
10
+ constructor(scriptName) {
11
+ this.scriptName = scriptName;
12
+ }
13
+
14
+ on = (eventName, callback) => {
15
+ this.events.set(eventName, callback);
16
+ };
17
+
18
+ off = (eventName) => {
19
+ this.events.delete(eventName);
20
+ };
21
+
22
+ emit = event => {
23
+ const eventData = event.detail;
24
+
25
+ if (!eventData) return;
26
+
27
+ const value = eventData.data;
28
+ const exec = this.events.get(eventData.name);
29
+ let data = value;
30
+
31
+ if (data !== '' && data.startsWith('{') && data.endsWith('}') || data.startsWith('[') && data.endsWith(']')) {
32
+ try {
33
+ data = JSON.parse(data);
34
+ } catch (e) {
35
+ return;
36
+ }
37
+ }
38
+
39
+ if (exec) {
40
+ exec(data);
41
+ }
42
+ };
43
+ }
44
+
45
+ const handler = new Handler('%folderName%');
46
+
47
+ sendMessageToRoom('%folderName%-ready');
48
+
49
+ })();
package/bin/deploy.js ADDED
@@ -0,0 +1,130 @@
1
+ const { rollup } = require('rollup');
2
+ const terser = require('@rollup/plugin-terser');
3
+ const { existsSync, readFileSync, createWriteStream, unlinkSync } = require('fs');
4
+ const { join } = require('path');
5
+ const { Signale } = require('signale');
6
+ const axios = require('axios');
7
+ const FormData = require('form-data');
8
+ const archiver = require('archiver');
9
+
10
+ class Script {
11
+ constructor(name, production = false) {
12
+ this.name = name;
13
+ this.production = production;
14
+ this.url = 'https://hubbe.biz';
15
+ this.directory = process.cwd();
16
+ this.config = this.getFile(this.directory + `/${name}`, 'config.json');
17
+ this.token = this.getFile(__dirname, '.token', true);
18
+ this.exec();
19
+ }
20
+
21
+
22
+ exec() {
23
+ const signale = new Signale();
24
+
25
+ this.createZipHtml()
26
+ .then(this.getScript.bind(this))
27
+ .then(this.deploy.bind(this))
28
+ .then(() => unlinkSync(this.directory + `/${this.name}/` + `${this.name}.zip`))
29
+ .then(() => signale.success('Project Deployed!'))
30
+ .catch(err => signale.error(`Deploy Failed! ${err}`));
31
+ }
32
+
33
+ deploy(script) {
34
+ const roomid = this.config.roomid;
35
+ const url = `${this.url}/scriptApiDeploy?roomid=${roomid}`;
36
+
37
+ // Create a new form instance
38
+ const form = new FormData();
39
+
40
+ const zip = readFileSync(this.directory + `/${this.name}/` + `${this.name}.zip`);
41
+
42
+ form.append("html", zip, `${this.name}.zip`);
43
+ form.append("code", script);
44
+ form.append("name", this.name);
45
+
46
+ const options = {
47
+ method: 'POST',
48
+ headers: { ...form.getHeaders(), 'token': this.token },
49
+ data: form,
50
+ url,
51
+ }
52
+
53
+ return axios(options);
54
+ }
55
+
56
+ async createZipHtml() {
57
+ const output = createWriteStream(this.directory + `/${this.name}/` + `${this.name}.zip`);
58
+ const archive = archiver('zip');
59
+
60
+ archive.on('error', function (err) {
61
+ throw err;
62
+ });
63
+
64
+ archive.pipe(output);
65
+
66
+ // append files from a sub-directory, putting its contents at the root of archive
67
+ archive.directory(this.directory + `/${this.name}` + "/html", false);
68
+
69
+ return archive.finalize();
70
+ }
71
+
72
+ async getScript() {
73
+ const file = join(this.directory + `/${this.name}`, 'room.js');
74
+ const input = await rollup({ input: file });
75
+ const config = this.getOutputConfig();
76
+ const output = await input.generate(config);
77
+ const script = output?.output[0];
78
+
79
+ if (!script) {
80
+ const err = new Error('Failed to generate script!');
81
+ throw err;
82
+ }
83
+
84
+ return script.code;
85
+
86
+ // const minified = UglifyJS.minify(script.code).code;
87
+
88
+ // if (minified.error) {
89
+ // const err = new Error('Error during minification: \n' + minified.error);
90
+ // throw err;
91
+ // }
92
+
93
+ // return minified;
94
+ }
95
+
96
+ getOutputConfig() {
97
+ const config = {
98
+ format: 'cjs',
99
+ file: `room-${this.config.roomid}.js`
100
+ }
101
+
102
+ if (this.production) {
103
+ const options = {
104
+ toplevel: false,
105
+ mangle: false,
106
+ compress: false
107
+ }
108
+ config.plugins = [terser(options)]
109
+ }
110
+
111
+ return config;
112
+ }
113
+
114
+ getFile(directory, file, read) {
115
+ const dir = join(directory, file);
116
+
117
+ if (!existsSync(dir)) {
118
+ const err = new Error(`Missing ${file}!`);
119
+ throw err;
120
+ }
121
+
122
+ if (!read) {
123
+ return require(dir);
124
+ }
125
+
126
+ return readFileSync(dir, 'utf-8');
127
+ }
128
+ }
129
+
130
+ module.exports = Script;
@@ -0,0 +1,157 @@
1
+ const { rollup } = require('rollup');
2
+ const terser = require('@rollup/plugin-terser');
3
+ const { existsSync, readFileSync, createWriteStream, unlinkSync } = require('fs');
4
+ const { join } = require('path');
5
+ const { Signale } = require('signale');
6
+ const axios = require('axios');
7
+ const FormData = require('form-data');
8
+ const archiver = require('archiver');
9
+ const UglifyJS = require('uglify-js');
10
+ const typescript = require("@rollup/plugin-typescript");
11
+
12
+ class Script {
13
+ constructor(name, production = false) {
14
+ this.name = name;
15
+ this.production = production;
16
+ this.url = 'https://hubbe.biz';
17
+ this.directory = process.cwd();
18
+ this.config = this.getFile(this.directory + `/${name}`, 'config.json');
19
+ this.token = this.getFile(__dirname, '.token', true);
20
+ this.exec();
21
+ }
22
+
23
+ exec() {
24
+ const signale = new Signale();
25
+
26
+ this.createZipHtml()
27
+ .then(this.getScript.bind(this))
28
+ .then(this.deploy.bind(this))
29
+ .then(() => unlinkSync(this.directory + `/${this.name}/` + `${this.name}.zip`))
30
+ .then(() => signale.success('Project Deployed!'))
31
+ .catch(err => signale.error(`Deploy Failed! ${err}`));
32
+ }
33
+
34
+ deploy(script) {
35
+ const roomid = this.config.roomid;
36
+ const url = `${this.url}/scriptApiDeploy?roomid=${roomid}`;
37
+
38
+ const form = new FormData();
39
+
40
+ const zip = readFileSync(this.directory + `/${this.name}/` + `${this.name}.zip`);
41
+
42
+ form.append("html", zip, `${this.name}.zip`);
43
+ form.append("code", script);
44
+ form.append("name", this.name);
45
+
46
+ const options = {
47
+ method: 'POST',
48
+ headers: { ...form.getHeaders(), 'token': this.token },
49
+ data: form,
50
+ url,
51
+ }
52
+
53
+ return axios(options);
54
+ }
55
+
56
+ async createZipHtml() {
57
+ const output = createWriteStream(this.directory + `/${this.name}/` + `${this.name}.zip`);
58
+ const archive = archiver('zip');
59
+
60
+ archive.on('error', function (err) {
61
+ throw err;
62
+ });
63
+
64
+ archive.pipe(output);
65
+
66
+ archive.directory(this.directory + `/${this.name}` + "/html", false);
67
+
68
+ return archive.finalize();
69
+ }
70
+
71
+ async getScript() {
72
+ let file = join(this.directory + `/${this.name}`, 'room.ts');
73
+ let tsconfigPath = join(this.directory + `/${this.name}`, 'tsconfig.json');
74
+
75
+ if (!existsSync(file)) {
76
+ file = join(this.directory + `/${this.name}`, '/room', 'room.ts');
77
+ tsconfigPath = join(this.directory + `/${this.name}`, '/room', 'tsconfig.json');
78
+ }
79
+
80
+ if (!existsSync(file)) {
81
+ const err = new Error('Missing room.ts!');
82
+ throw err;
83
+ }
84
+
85
+ if (!existsSync(tsconfigPath)) {
86
+ const err = new Error('Missing tsconfig.json!');
87
+ throw err;
88
+ }
89
+
90
+
91
+ const bundle = await rollup({
92
+ input: file,
93
+ plugins: [
94
+ typescript({
95
+ tsconfig: tsconfigPath,
96
+ }),
97
+ terser(),
98
+ ],
99
+ }).catch(err => {
100
+ throw `Bundle failed: ${err}`;
101
+ });
102
+
103
+ const { output } = await bundle.generate({
104
+ format: "cjs"
105
+ });
106
+
107
+ const script = output[0];
108
+
109
+ if (!script) {
110
+ const err = new Error('Failed to generate script!');
111
+ throw err;
112
+ }
113
+
114
+ script.code = script.code
115
+ .replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm, '')
116
+ .replace(/(\r\n|\n|\r)/gm, '')
117
+ .replace(/(\s\s\s+)/gm, '')
118
+ .replace(/(\s\s+)/gm, '');
119
+
120
+ return script.code;
121
+ }
122
+
123
+ getOutputConfig() {
124
+ const config = {
125
+ format: 'cjs',
126
+ file: `room-${this.config.roomid}.js`
127
+ }
128
+
129
+ if (this.production) {
130
+ const options = {
131
+ toplevel: false,
132
+ mangle: false,
133
+ compress: false
134
+ }
135
+ config.plugins = [terser(options)]
136
+ }
137
+
138
+ return config;
139
+ }
140
+
141
+ getFile(directory, file, read) {
142
+ const dir = join(directory, file);
143
+
144
+ if (!existsSync(dir)) {
145
+ const err = new Error(`Missing ${file}!`);
146
+ throw err;
147
+ }
148
+
149
+ if (!read) {
150
+ return require(dir);
151
+ }
152
+
153
+ return readFileSync(dir, 'utf-8');
154
+ }
155
+ }
156
+
157
+ module.exports = Script;
package/bin/fetch.js ADDED
@@ -0,0 +1,118 @@
1
+ const {rollup} = require('rollup');
2
+ const terser = require('@rollup/plugin-terser');
3
+ const {existsSync, readFileSync, createWriteStream, unlinkSync} = require('fs');
4
+ const {join} = require('path');
5
+ const {Signale} = require('signale');
6
+ const axios = require('axios');
7
+ const FormData = require('form-data');
8
+ const archiver = require('archiver');
9
+
10
+ class Script {
11
+ constructor(name, production = false) {
12
+ this.name = name;
13
+ this.production = production;
14
+ this.url = 'https://hubbe.biz';
15
+ this.directory = process.cwd();
16
+ this.config = this.getFile(this.directory + `/${name}`, 'config.json');
17
+ this.token = this.getFile(__dirname, '.token', true);
18
+ this.exec();
19
+ }
20
+
21
+ exec() {
22
+ const signale = new Signale();
23
+
24
+ this.fetch()
25
+ .then(() => this.createZip())
26
+ .then(() => this.getScript())
27
+ .then(script => {
28
+ // to do
29
+ })
30
+ .then(() => signale.success('Project Deployed!'))
31
+ .catch(err => signale.error(`Deploy Failed! ${err}`));
32
+ }
33
+
34
+ fetch() {
35
+ const roomid = this.config.roomid;
36
+ const url = `${this.url}/scriptApi?roomid=${roomid}`;
37
+
38
+ const options = {
39
+ method: 'GET',
40
+ headers: {'token': this.token},
41
+ url,
42
+ };
43
+
44
+ return axios(options);
45
+ }
46
+
47
+ async createZip() {
48
+ const output = createWriteStream(this.directory + `/${this.name}/` + `${this.name}.zip`);
49
+ const archive = archiver('zip');
50
+
51
+ archive.on('error', function (err) {
52
+ throw err;
53
+ });
54
+
55
+ archive.pipe(output);
56
+
57
+ // append files from a sub-directory, putting its contents at the root of archive
58
+ archive.directory(this.directory + `/${this.name}` + "/html", false);
59
+
60
+ return archive.finalize();
61
+ }
62
+
63
+ async getScript() {
64
+ const file = join(this.directory + `/${this.name}`, 'room.js');
65
+ const input = await rollup({input: file});
66
+ const config = this.getOutputConfig();
67
+ const output = await input.generate(config);
68
+ const script = output?.output[0];
69
+
70
+ if (!script) {
71
+ const err = new Error('Failed to generate script!');
72
+ throw err;
73
+ }
74
+
75
+ script.code = script.code
76
+ .replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm, '')
77
+ .replace(/(\r\n|\n|\r)/gm, '')
78
+ .replace(/(\s\s\s+)/gm, '')
79
+ .replace(/(\s\s+)/gm, '');// Remove comments, line breaks and multiple spaces
80
+
81
+ return script.code;
82
+ }
83
+
84
+ getOutputConfig() {
85
+ const config = {
86
+ format: 'cjs',
87
+ file: `room-${this.config.roomid}.js`
88
+ };
89
+
90
+ if (this.production) {
91
+ const options = {
92
+ toplevel: false,
93
+ mangle: false,
94
+ compress: false
95
+ };
96
+ config.plugins = [terser(options)];
97
+ }
98
+
99
+ return config;
100
+ }
101
+
102
+ getFile(directory, file, read) {
103
+ const dir = join(directory, file);
104
+
105
+ if (!existsSync(dir)) {
106
+ const err = new Error(`Missing ${file}!`);
107
+ throw err;
108
+ }
109
+
110
+ if (!read) {
111
+ return require(dir);
112
+ }
113
+
114
+ return readFileSync(dir, 'utf-8');
115
+ }
116
+ }
117
+
118
+ module.exports = Script;
package/bin/htmlu.js ADDED
@@ -0,0 +1,116 @@
1
+ const {existsSync, readFileSync, writeFileSync, unlinkSync, unlink} = require('fs');
2
+ const {join} = require('path');
3
+ const {Signale} = require('signale');
4
+ const cheerio = require('cheerio');
5
+ const SFTPClient = require('ssh2-sftp-client');
6
+ const UglifyJS = require('uglify-js');
7
+
8
+ class HtmlUploader {
9
+ constructor(name, production = false) {
10
+ this.name = name;
11
+ this.production = production;
12
+ this.url = 'https://hubbe.biz';
13
+ this.directory = process.cwd();
14
+ this.directoryFolder = this.directory + `/${this.name}` + "/html";
15
+ this.token = this.getFile(__dirname, '.token', true);
16
+ this.exec();
17
+ }
18
+
19
+ exec() {
20
+ const signale = new Signale();
21
+ const code = this.getFile(this.directoryFolder, 'index.html', true);
22
+ const html = this.parseHtml(code);
23
+
24
+ this.genTemporaryFiles(html);
25
+ this.deploy()
26
+ .then(() => signale.success('Web Files Uploaded!'))
27
+ .catch(err => signale.error(`Upload Failed! ${err}`));
28
+ }
29
+
30
+ parseHtml(document) {
31
+ const $ = cheerio.load(document);
32
+
33
+ const htmlContent = $('body').html()
34
+ return `<body>${htmlContent}</body>`;
35
+ }
36
+
37
+ genTemporaryFiles(text) {
38
+ writeFileSync(this.directoryFolder + '/temp.html', text);
39
+
40
+ if (this.production) {
41
+ const code = this.getFile(this.directoryFolder, 'script.js', true);
42
+ const minified = UglifyJS.minify(code);
43
+
44
+ if (minified.error) {
45
+ throw new Error('Erro durante a minificação: \n' + minified.error);
46
+ } else {
47
+ writeFileSync(this.directoryFolder + '/temp.js', minified.code);
48
+ }
49
+ }
50
+
51
+ return true
52
+ }
53
+
54
+ deleteTemporaryFiles() {
55
+ try {
56
+ unlinkSync(this.directoryFolder + '/temp.html');
57
+
58
+ if (this.production) {
59
+ unlinkSync(this.directoryFolder + '/temp.js');
60
+ }
61
+ } catch (e) {
62
+ const signale = new Signale();
63
+ signale.error('Failed on try delete temporary file!');
64
+ }
65
+ }
66
+
67
+ async deploy() {
68
+ const sftp = new SFTPClient();
69
+ const jsFile = this.production ? '/temp.js' : '/script.js';
70
+ const config = {
71
+ host: process.env.CDN_IP,
72
+ port: process.env.PORT,
73
+ username: process.env.USER,
74
+ password: process.env.PASSWORD
75
+ }
76
+
77
+ await sftp.connect(config)
78
+
79
+ const remoteDir = `/var/www/html/${this.config.folder}`
80
+ const existsDir = await sftp.exists(remoteDir)
81
+
82
+ if (!existsDir) {
83
+ await sftp.mkdir(remoteDir, true);
84
+ }
85
+
86
+ await sftp.put(this.directoryFolder + '/temp.html', `${remoteDir}/index.html`);
87
+
88
+ if (existsSync(this.directoryFolder + '/style.css')) {
89
+ await sftp.put(this.directoryFolder + '/style.css', `${remoteDir}/style.css`);
90
+ }
91
+
92
+ if (existsSync(this.directoryFolder + jsFile)) {
93
+ await sftp.put(this.directoryFolder + jsFile, `${remoteDir}/script.js`);
94
+ }
95
+
96
+ this.deleteTemporaryFiles();
97
+ return sftp.end();
98
+ }
99
+
100
+ getFile(directory, file, read) {
101
+ const dir = join(directory, file);
102
+
103
+ if (!existsSync(dir)) {
104
+ const err = new Error(`Missing ${file}!`);
105
+ throw err;
106
+ }
107
+
108
+ if (!read) {
109
+ return require(dir);
110
+ }
111
+
112
+ return readFileSync(dir, 'utf-8');
113
+ }
114
+ }
115
+
116
+ module.exports = HtmlUploader