Skip to content

Commit 3ec552e

Browse files
chore: init & local sync
0 parents  commit 3ec552e

File tree

15 files changed

+1475
-0
lines changed

15 files changed

+1475
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
yarn.lock
3+
dist.zip
4+
dist
5+
pnpm-lock.yaml

.vscode/pack-zip.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const path = require('path');
2+
const fs = require('fs');
3+
const jszip = require('jszip');
4+
5+
const iconFile = path.join(__dirname, '../icon.png');
6+
const pluginJSON = path.join(__dirname, '../plugin.json');
7+
const distFolder = path.join(__dirname, '../dist');
8+
let readmeDotMd = path.join(__dirname, '../readme.md');
9+
let changelogDotMd = path.join(__dirname, '../changelogs.md');
10+
11+
if (!fs.existsSync(readmeDotMd)) {
12+
readmeDotMd = path.join(__dirname, '../README.md');
13+
}
14+
15+
// create zip file of dist folder
16+
17+
const zip = new jszip();
18+
19+
zip.file('icon.png', fs.readFileSync(iconFile));
20+
zip.file('plugin.json', fs.readFileSync(pluginJSON));
21+
zip.file('readme.md', fs.readFileSync(readmeDotMd));
22+
zip.file('changelogs.md', fs.readFileSync(changelogDotMd));
23+
24+
loadFile('', distFolder);
25+
loadFile('dictionaries', path.join(__dirname, "../node_modules/typo-js/dictionaries"));
26+
27+
zip
28+
.generateNodeStream({ type: 'nodebuffer', streamFiles: true })
29+
.pipe(fs.createWriteStream(path.join(__dirname, '../dist.zip')))
30+
.on('finish', () => {
31+
console.log('Plugin dist.zip written.');
32+
});
33+
34+
function loadFile(root, folder) {
35+
const distFiles = fs.readdirSync(folder);
36+
distFiles.forEach((file) => {
37+
const fullPath = path.join(folder, file);
38+
const stat = fs.statSync(fullPath);
39+
40+
console.log({ fullPath, root, file, rootStruction: path.join(root, file) })
41+
if (stat.isDirectory()) {
42+
loadFile(path.join(root, file), fullPath);
43+
} else if (!/LICENSE.txt/.test(file)) {
44+
zip.file(path.join(root, file), fs.readFileSync(fullPath));
45+
}
46+
});
47+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Acode Foundation
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

changelogs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Changelogs

esbuild.config.mjs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import * as esbuild from "esbuild";
2+
import { exec } from "child_process";
3+
4+
const isServe = process.argv.includes("--serve");
5+
6+
// Function to pack the ZIP file
7+
function packZip() {
8+
exec("node .vscode/pack-zip.js", (err, stdout, stderr) => {
9+
if (err) {
10+
console.error("Error packing zip:", err);
11+
return;
12+
}
13+
console.log(stdout.trim());
14+
});
15+
}
16+
17+
// Custom plugin to pack ZIP after build or rebuild
18+
const zipPlugin = {
19+
name: "zip-plugin",
20+
setup(build) {
21+
build.onEnd(() => {
22+
packZip();
23+
});
24+
},
25+
};
26+
27+
// Base build configuration
28+
let buildConfig = {
29+
entryPoints: ["src/main.ts"],
30+
bundle: true,
31+
minify: true,
32+
logLevel: "info",
33+
color: true,
34+
outdir: "dist",
35+
plugins: [zipPlugin],
36+
};
37+
38+
// Main function to handle both serve and production builds
39+
(async function() {
40+
if (isServe) {
41+
console.log("Starting development server...");
42+
43+
// Watch and Serve Mode
44+
const ctx = await esbuild.context(buildConfig);
45+
46+
await ctx.watch();
47+
const { host, port } = await ctx.serve({
48+
servedir: ".",
49+
port: 3000,
50+
});
51+
52+
} else {
53+
console.log("Building for production...");
54+
await esbuild.build(buildConfig);
55+
console.log("Production build complete.");
56+
}
57+
})();

icon.png

22.2 KB
Loading

0 commit comments

Comments
 (0)