Skip to content

Commit 88e8514

Browse files
committed
v1.2.5
1 parent 940a2f2 commit 88e8514

16 files changed

+3561
-2611
lines changed

.babelrc

-7
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,5 @@
22
"presets": [
33
"@babel/preset-env"
44
],
5-
"env": {
6-
"test": {
7-
"presets": [
8-
"@babel/env"
9-
]
10-
}
11-
},
125
"compact": false
136
}

.vscode/getNet.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const { networkInterfaces } = require('os');
2+
3+
module.exports = async (mode = 'dev') => {
4+
const { WiFi, Ethernet } = getIp();
5+
const [ip] = WiFi || Ethernet;
6+
const port = '5500';
7+
const src = `https://${ip || '10.0.0'}:${port}`;
8+
console.log('Server starting at: ', src);
9+
return { ip, port };
10+
};
11+
12+
function getIp() {
13+
const nets = networkInterfaces();
14+
const results = {}; // Or just '{}', an empty object
15+
16+
Object.keys(nets).forEach((name) => {
17+
nets[name].forEach((net) => {
18+
// Skip over non-IPv4 and internal (i.e. 127.0.0.1) addresses
19+
// 'IPv4' is in Node <= 17, from 18 it's a number 4 or 6
20+
const familyV4Value = typeof net.family === 'string' ? 'IPv4' : 4;
21+
if (net.family === familyV4Value && !net.internal) {
22+
if (!results[name]) {
23+
results[name] = [];
24+
}
25+
results[name].push(net.address);
26+
}
27+
});
28+
});
29+
return results;
30+
}

.vscode/run-webpack.js

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/* eslint-disable no-console */
2+
const { spawn } = require('child_process');
3+
const path = require('path');
4+
5+
const webpack = spawn('npx.cmd', ['webpack', '--mode=development', '--watch'], { cwd: path.resolve(__dirname, '../') });
6+
7+
webpack.on('error', (webpackError) => {
8+
if (webpackError) {
9+
console.error(webpackError);
10+
process.exit(1);
11+
}
12+
});
13+
14+
webpack.stdout.on('data', (chunk) => {
15+
const stdout = chunk.toString();
16+
console.log(stdout);
17+
process.send(stdout);
18+
});
19+
20+
webpack.stdout.on('error', (error) => {
21+
console.log(error);
22+
});
23+
24+
webpack.stderr.on('data', (chunk) => {
25+
const stderr = chunk.toString();
26+
console.log(stderr);
27+
});

.vscode/server.crt

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-----BEGIN CERTIFICATE-----
2+
MIICfjCCAecCFGoKwe9jqvLXZUsAKK8R9rBoxQBVMA0GCSqGSIb3DQEBCwUAMH4x
3+
CzAJBgNVBAYTAklOMRMwEQYDVQQIDApBaml0IEt1bWFyMQwwCgYDVQQHDANCU1Ax
4+
DjAMBgNVBAoMBUZYREJHMQwwCgYDVQQLDANERVYxDTALBgNVBAMMBEFqaXQxHzAd
5+
BgkqhkiG9w0BCQEWEG1lQGFqaXRrdW1hci5kZXYwHhcNMjIwODIxMDc0NjI1WhcN
6+
MjMwODIxMDc0NjI1WjB+MQswCQYDVQQGEwJJTjETMBEGA1UECAwKQWppdCBLdW1h
7+
cjEMMAoGA1UEBwwDQlNQMQ4wDAYDVQQKDAVGWERCRzEMMAoGA1UECwwDREVWMQ0w
8+
CwYDVQQDDARBaml0MR8wHQYJKoZIhvcNAQkBFhBtZUBhaml0a3VtYXIuZGV2MIGf
9+
MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQClD9GyID1GNGCdsq8vshf2h/tMUzxW
10+
mWqOoBi8ZSUrQGoZJ4vxSk5+kPkSvaZzj4zs+LnUMqIXPu1KSIXflVRXzAvh5VIE
11+
7M0ithYYbGPSyviUWpatdLCvLCOPXZPTXc+66mY7RnCVzlBqGKOR2H4goeGWq0zG
12+
Q+V3pAM7gLUJsQIDAQABMA0GCSqGSIb3DQEBCwUAA4GBAHpMjw8nYPtJ20jO2i6M
13+
kJg09Hk91g63HEx4noV8WallM80exNYWJgzNI69UIRdh78QAEknJh43TSF61bVpo
14+
i+mtBHzZLyPv4LHKNN+6eBoMxi58tbWVZXQB4awW6d1AstHY10aSygOmOUKLtGxr
15+
lYt6v4QwWrm3j7oNCDRDwxlj
16+
-----END CERTIFICATE-----

.vscode/server.key

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-----BEGIN RSA PRIVATE KEY-----
2+
Proc-Type: 4,ENCRYPTED
3+
DEK-Info: DES-EDE3-CBC,F6E1E7807FC07585
4+
5+
1RxeEBdxtQ0+Erd+wmDLuaHy07d81+5uqCBZ1FVkzFOReCwDHFvqT9pyo00soIBJ
6+
ECcUOQyVoV7XyQKZVna+XwQJ8WoiF7R0dVeP7q1E8whFhVD+ybnwvCHSe9Zv1DTo
7+
8R74rrAqRRKOf0aFEt2DR3sO9vdljOQY0JSTOefFisJs++FSDGSMPzyoUjyGzix+
8+
jOcbA9BjPoossVRNSNta9q7IMZRvYnF+mqbeKrlQ7dDV6BBCICJ15syzp0FFZcry
9+
7Upmstp+HtFphDr1ABaXlbSzPIzj+lYBro4vV4v/FuyGigwzYhiftTzypz0sVV2u
10+
yOSIGkQkNrg+0iaD35BuLzuZnKvlmjwBeFL0xlN0oh2yUSqveTUwiyGXhJxqjuKe
11+
lK9LEkKFtkj+BB0gwKy0aHNYM7Z3F2FfNGd/FlxxEbZMfORm03W/I3ploJLKk6kO
12+
H69Rkh+5lPsO0q89YBuqptiJH4cgKSup+yWH8LASbz+nuxLEKJTasJZJFEFxO62v
13+
gVHARgwv/V5HYqE4FF860mQs/ZiRVJfTN1HWZ4OpEHjJMuDhWLCyqxHeLMvL8nxd
14+
5qm9cGoguHWmv7JLe/R238AZhYg6eBybg+WAqOJZ2LdMQjAKFa5+oWezCAk1uLI9
15+
v12C5EBYZFI7znx2C4A+YAN7a3HAf+p6o467c1aL/8CQdb37soSpdnAKApx1uFBp
16+
TBxPrNXBOkND/bdU/w4E1lqMPg5KPFNn3gYe7YTB0fG4YqrBfpA0uswBdNHf4u4E
17+
u2Q99Fw9dIsj/BMkwFxTWM0Mb119VPyZm5nd5L4Y0GZmhND4UyVV0A==
18+
-----END RSA PRIVATE KEY-----

.vscode/settings.json

+6-1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,10 @@
44
"cert": "D:\\Dev\\server.crt", //full path of the certificate
55
"key": "D:\\Dev\\server.key", //full path of the private key
66
"passphrase": "1234"
7-
}
7+
},
8+
"cSpell.words": [
9+
"Acode",
10+
"Ajit",
11+
"deadlyjack"
12+
]
813
}

.vscode/start-dev.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/* eslint-disable no-console */
2+
const { fork, spawn } = require('child_process');
3+
const path = require('path');
4+
5+
main();
6+
7+
async function main() {
8+
let serverStarted = false;
9+
console.log('+--------------+');
10+
console.log('| Starting dev |');
11+
console.log('+--------------+');
12+
const webpack = fork(path.resolve(__dirname, './run-webpack.js'));
13+
webpack.on('message', (chunk) => {
14+
if (!serverStarted && chunk.search(/compiled\ssuccessfully/)) {
15+
startServer();
16+
serverStarted = true;
17+
}
18+
});
19+
20+
webpack.on('error', (err) => {
21+
console.log('WEBPACK ERROR', err);
22+
webpack.kill(1);
23+
process.exit(1);
24+
});
25+
}
26+
27+
async function startServer() {
28+
const server = fork(path.resolve(__dirname, './start-server.js'));
29+
server.on('error', (err) => {
30+
console.log('SERVER ERROR', err);
31+
server.kill(1);
32+
process.exit(1);
33+
});
34+
}

.vscode/start-server.js

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/* eslint-disable import/no-extraneous-dependencies */
2+
const fs = require('fs');
3+
const path = require('path');
4+
const liveServer = require('live-server');
5+
const getNet = require('./getNet');
6+
7+
const serverCrt = path.resolve(__dirname, 'server.crt');
8+
const serverKey = path.resolve(__dirname, 'server.key');
9+
10+
main();
11+
12+
async function main() {
13+
const { ip: host, port } = await getNet('dev');
14+
process.cwd = () => __dirname;
15+
liveServer.start({
16+
open: false,
17+
port,
18+
host,
19+
cors: true,
20+
root: '../',
21+
ignore: 'node_modules,platforms,plugins',
22+
file: 'index.html',
23+
https: {
24+
cert: fs.readFileSync(serverCrt),
25+
key: fs.readFileSync(serverKey),
26+
passphrase: '1234',
27+
},
28+
middleware: [(req, res, next) => {
29+
const url = req.originalUrl;
30+
const www = '../platforms/android/app/src/main/assets/www/';
31+
32+
if (url === '/cordova.js') {
33+
const file = path.resolve(__dirname, www, 'cordova.js');
34+
sendFile(res, file);
35+
return;
36+
}
37+
38+
if (url === '/cordova_plugins.js') {
39+
const file = path.resolve(__dirname, www, 'cordova_plugins.js');
40+
sendFile(res, file);
41+
return;
42+
}
43+
44+
next();
45+
}],
46+
});
47+
48+
process.send('OK');
49+
}
50+
51+
function sendFile(res, filePath) {
52+
if (fs.existsSync(filePath)) {
53+
const stat = fs.statSync(filePath);
54+
55+
res.writeHead(200, {
56+
'Content-Type': 'application/javascript',
57+
'Content-Length': stat.size,
58+
});
59+
60+
const readStream = fs.createReadStream(filePath);
61+
readStream.pipe(res);
62+
return;
63+
}
64+
65+
res.writeHead(404, { 'Content-Type': 'text/plain' });
66+
res.end(`ERROR cannot get ${filePath}`);
67+
}

dist.zip

-39.7 KB
Binary file not shown.

dist/main.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

icon.png

-39.9 KB
Loading

package.json

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
{
22
"name": "acode-plugin-snippets",
3-
"version": "1.2.2",
3+
"version": "1.2.5",
44
"description": "Snippets plugin for Acode",
55
"main": "dist/main.js",
66
"repository": "https://github.com/deadlyjack/acode-plugin-snippets.git",
77
"author": "Ajit <[email protected]>",
88
"license": "MIT",
99
"dependencies": {
10-
"@deadlyjack/ajax": "^1.2.3",
11-
"jszip": "^3.10.1"
10+
"@deadlyjack/ajax": "^1.2.3"
1211
},
1312
"devDependencies": {
14-
"@babel/cli": "^7.18.10",
1513
"@babel/core": "^7.18.13",
1614
"@babel/preset-env": "^7.18.10",
17-
"babel-loader": "^8.2.5",
15+
"babel-loader": "^9.1.2",
16+
"jszip": "^3.10.1",
17+
"live-server": "^1.2.2",
1818
"raw-loader": "^4.0.2",
1919
"webpack": "^5.76.0",
20-
"webpack-cli": "^4.10.0"
20+
"webpack-cli": "^5.1.4"
2121
},
2222
"scripts": {
2323
"build": "webpack",
24+
"start-dev": "node .vscode/start-dev",
2425
"build-release": "webpack --mode production"
2526
},
26-
"browserslist": [
27-
"> 0.25%, not dead"
28-
]
29-
}
27+
"browserslist": "cover 100%,not android < 5"
28+
}

plugin.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"id": "acode.plugin.snippets",
33
"name": "Snippets",
44
"main": "dist/main.js",
5-
"version": "1.2.3",
5+
"version": "1.2.5",
66
"readme": "readme.md",
77
"icon": "icon.png",
88
"files": [
@@ -65,4 +65,4 @@
6565
"email": "[email protected]",
6666
"github": "deadlyjack"
6767
}
68-
}
68+
}

0 commit comments

Comments
 (0)