Skip to content

Commit

Permalink
feat: Visual studio theme pre code in beta phase v1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianjnuwu committed Jul 10, 2023
0 parents commit 899b5e1
Show file tree
Hide file tree
Showing 18 changed files with 653 additions and 0 deletions.
20 changes: 20 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"presets": [
"@babel/preset-env"
],
"env": {
"test": {
"presets": [
"@babel/env"
]
}
},
"plugins": [
"html-tag-js/jsx/jsx-to-tag.js",
"html-tag-js/jsx/syntax-parser.js",
[
"@babel/plugin-transform-runtime"
]
],
"compact": true
}
Empty file added .github/workflows/eslint.yml
Empty file.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Skipping junk files to repository
node_modules
package-lock.json
yarn.lock
dist.zip
dist
30 changes: 30 additions & 0 deletions .vscode/getNet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const { networkInterfaces } = require('os');

module.exports = async (mode = 'dev') => {
const { WiFi, Ethernet } = getIp();
const [ip] = WiFi || Ethernet;
const port = '5500';
const src = `https://${ip || '10.0.0'}:${port}`;
console.log('Server starting at: ', src);
return { ip, port };
};

function getIp() {
const nets = networkInterfaces();
const results = {}; // Or just '{}', an empty object

Object.keys(nets).forEach((name) => {
nets[name].forEach((net) => {
// Skip over non-IPv4 and internal (i.e. 127.0.0.1) addresses
// 'IPv4' is in Node <= 17, from 18 it's a number 4 or 6
const familyV4Value = typeof net.family === 'string' ? 'IPv4' : 4;
if (net.family === familyV4Value && !net.internal) {
if (!results[name]) {
results[name] = [];
}
results[name].push(net.address);
}
});
});
return results;
}
47 changes: 47 additions & 0 deletions .vscode/pack-zip.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const path = require('path');
const fs = require('fs');
const jszip = require('jszip');

const iconFile = path.join(__dirname, '../icon.png');
const pluginJSON = path.join(__dirname, '../plugin.json');
const distFolder = path.join(__dirname, '../dist');
let readmeDotMd = path.join(__dirname, '../readme.md');

if (!fs.existsSync(readmeDotMd)) {
readmeDotMd = path.join(__dirname, '../README.md');
}

// create zip file of dist folder

const zip = new jszip();

zip.file('icon.png', fs.readFileSync(iconFile));
zip.file('plugin.json', fs.readFileSync(pluginJSON));
zip.file('readme.md', fs.readFileSync(readmeDotMd));

loadFile('', distFolder);

zip
.generateNodeStream({ type: 'nodebuffer', streamFiles: true })
.pipe(fs.createWriteStream(path.join(__dirname, '../dist.zip')))
.on('finish', () => {
console.log('dist.zip written.');
});

function loadFile(root, folder) {
const distFiles = fs.readdirSync(folder);
distFiles.forEach((file) => {

const stat = fs.statSync(path.join(folder, file));

if (stat.isDirectory()) {
zip.folder(file);
loadFile(path.join(root, file), path.join(folder, file));
return;
}

if (!/LICENSE.txt/.test(file)) {
zip.file(path.join(root, file), fs.readFileSync(path.join(folder, file)));
}
});
}
27 changes: 27 additions & 0 deletions .vscode/run-webpack.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/* eslint-disable no-console */
const { spawn } = require('child_process');
const path = require('path');

const webpack = spawn('npx.cmd', ['webpack', '--mode=development', '--watch'], { cwd: path.resolve(__dirname, '../') });

webpack.on('error', (webpackError) => {
if (webpackError) {
console.error(webpackError);
process.exit(1);
}
});

webpack.stdout.on('data', (chunk) => {
const stdout = chunk.toString();
console.log(stdout);
process.send(stdout);
});

webpack.stdout.on('error', (error) => {
console.log(error);
});

webpack.stderr.on('data', (chunk) => {
const stderr = chunk.toString();
console.log(stderr);
});
16 changes: 16 additions & 0 deletions .vscode/server.crt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-----BEGIN CERTIFICATE-----
MIICfjCCAecCFGoKwe9jqvLXZUsAKK8R9rBoxQBVMA0GCSqGSIb3DQEBCwUAMH4x
CzAJBgNVBAYTAklOMRMwEQYDVQQIDApBaml0IEt1bWFyMQwwCgYDVQQHDANCU1Ax
DjAMBgNVBAoMBUZYREJHMQwwCgYDVQQLDANERVYxDTALBgNVBAMMBEFqaXQxHzAd
BgkqhkiG9w0BCQEWEG1lQGFqaXRrdW1hci5kZXYwHhcNMjIwODIxMDc0NjI1WhcN
MjMwODIxMDc0NjI1WjB+MQswCQYDVQQGEwJJTjETMBEGA1UECAwKQWppdCBLdW1h
cjEMMAoGA1UEBwwDQlNQMQ4wDAYDVQQKDAVGWERCRzEMMAoGA1UECwwDREVWMQ0w
CwYDVQQDDARBaml0MR8wHQYJKoZIhvcNAQkBFhBtZUBhaml0a3VtYXIuZGV2MIGf
MA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQClD9GyID1GNGCdsq8vshf2h/tMUzxW
mWqOoBi8ZSUrQGoZJ4vxSk5+kPkSvaZzj4zs+LnUMqIXPu1KSIXflVRXzAvh5VIE
7M0ithYYbGPSyviUWpatdLCvLCOPXZPTXc+66mY7RnCVzlBqGKOR2H4goeGWq0zG
Q+V3pAM7gLUJsQIDAQABMA0GCSqGSIb3DQEBCwUAA4GBAHpMjw8nYPtJ20jO2i6M
kJg09Hk91g63HEx4noV8WallM80exNYWJgzNI69UIRdh78QAEknJh43TSF61bVpo
i+mtBHzZLyPv4LHKNN+6eBoMxi58tbWVZXQB4awW6d1AstHY10aSygOmOUKLtGxr
lYt6v4QwWrm3j7oNCDRDwxlj
-----END CERTIFICATE-----
18 changes: 18 additions & 0 deletions .vscode/server.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,F6E1E7807FC07585

1RxeEBdxtQ0+Erd+wmDLuaHy07d81+5uqCBZ1FVkzFOReCwDHFvqT9pyo00soIBJ
ECcUOQyVoV7XyQKZVna+XwQJ8WoiF7R0dVeP7q1E8whFhVD+ybnwvCHSe9Zv1DTo
8R74rrAqRRKOf0aFEt2DR3sO9vdljOQY0JSTOefFisJs++FSDGSMPzyoUjyGzix+
jOcbA9BjPoossVRNSNta9q7IMZRvYnF+mqbeKrlQ7dDV6BBCICJ15syzp0FFZcry
7Upmstp+HtFphDr1ABaXlbSzPIzj+lYBro4vV4v/FuyGigwzYhiftTzypz0sVV2u
yOSIGkQkNrg+0iaD35BuLzuZnKvlmjwBeFL0xlN0oh2yUSqveTUwiyGXhJxqjuKe
lK9LEkKFtkj+BB0gwKy0aHNYM7Z3F2FfNGd/FlxxEbZMfORm03W/I3ploJLKk6kO
H69Rkh+5lPsO0q89YBuqptiJH4cgKSup+yWH8LASbz+nuxLEKJTasJZJFEFxO62v
gVHARgwv/V5HYqE4FF860mQs/ZiRVJfTN1HWZ4OpEHjJMuDhWLCyqxHeLMvL8nxd
5qm9cGoguHWmv7JLe/R238AZhYg6eBybg+WAqOJZ2LdMQjAKFa5+oWezCAk1uLI9
v12C5EBYZFI7znx2C4A+YAN7a3HAf+p6o467c1aL/8CQdb37soSpdnAKApx1uFBp
TBxPrNXBOkND/bdU/w4E1lqMPg5KPFNn3gYe7YTB0fG4YqrBfpA0uswBdNHf4u4E
u2Q99Fw9dIsj/BMkwFxTWM0Mb119VPyZm5nd5L4Y0GZmhND4UyVV0A==
-----END RSA PRIVATE KEY-----
34 changes: 34 additions & 0 deletions .vscode/start-dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/* eslint-disable no-console */
const { fork, spawn } = require('child_process');
const path = require('path');

main();

async function main() {
let serverStarted = false;
console.log('+--------------+');
console.log('| Starting dev |');
console.log('+--------------+');
const webpack = fork(path.resolve(__dirname, './run-webpack.js'));
webpack.on('message', (chunk) => {
if (!serverStarted && chunk.search(/compiled\ssuccessfully/)) {
startServer();
serverStarted = true;
}
});

webpack.on('error', (err) => {
console.log('WEBPACK ERROR', err);
webpack.kill(1);
process.exit(1);
});
}

async function startServer() {
const server = fork(path.resolve(__dirname, './start-server.js'));
server.on('error', (err) => {
console.log('SERVER ERROR', err);
server.kill(1);
process.exit(1);
});
}
67 changes: 67 additions & 0 deletions .vscode/start-server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/* eslint-disable import/no-extraneous-dependencies */
const fs = require('fs');
const path = require('path');
const liveServer = require('live-server');
const getNet = require('./getNet');

const serverCrt = path.resolve(__dirname, 'server.crt');
const serverKey = path.resolve(__dirname, 'server.key');

main();

async function main() {
const { ip: host, port } = await getNet('dev');
process.cwd = () => __dirname;
liveServer.start({
open: false,
port,
host,
cors: true,
root: '../',
ignore: 'node_modules,platforms,plugins',
file: 'index.html',
https: {
cert: fs.readFileSync(serverCrt),
key: fs.readFileSync(serverKey),
passphrase: '1234',
},
middleware: [(req, res, next) => {
const url = req.originalUrl;
const www = '../platforms/android/app/src/main/assets/www/';

if (url === '/cordova.js') {
const file = path.resolve(__dirname, www, 'cordova.js');
sendFile(res, file);
return;
}

if (url === '/cordova_plugins.js') {
const file = path.resolve(__dirname, www, 'cordova_plugins.js');
sendFile(res, file);
return;
}

next();
}],
});

process.send('OK');
}

function sendFile(res, filePath) {
if (fs.existsSync(filePath)) {
const stat = fs.statSync(filePath);

res.writeHead(200, {
'Content-Type': 'application/javascript',
'Content-Length': stat.size,
});

const readStream = fs.createReadStream(filePath);
readStream.pipe(res);
return;
}

res.writeHead(404, { 'Content-Type': 'text/plain' });
res.end(`ERROR cannot get ${filePath}`);
}
Loading

0 comments on commit 899b5e1

Please sign in to comment.