Skip to content

Commit ccc9cb8

Browse files
committed
tested and working, created a script to build
1 parent ed154aa commit ccc9cb8

10 files changed

Lines changed: 62 additions & 7 deletions

File tree

dist/744.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/main.js.LICENSE.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

dist/vendor.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/vendor.js.LICENSE.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
"webpack-cli": "^4.10.0"
1919
},
2020
"scripts": {
21-
"build": "webpack"
21+
"build": "node ./scripts/build.js"
2222
},
2323
"resolutions": {
2424
"terser": ">=5.14.2"

plugin.json

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,17 @@
22
"id": "acode.plugin.prettier",
33
"name": "Prettier",
44
"main": "dist/main.js",
5-
"version": "1.0.2",
5+
"version": "1.0.3",
66
"readme": "readme.md",
77
"icon": "icon.png",
88
"type": "free",
9-
"files": ["src_worker_js.js", "vendor.js"],
9+
"files": [
10+
"744.js",
11+
"vendor.js"
12+
],
1013
"author": {
1114
"name": "Ajit Kumar",
1215
"email": "me@ajitkumar.dev",
1316
"github": "deadlyjack"
1417
}
15-
}
18+
}

scripts/build.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
const { exec } = require("child_process");
2+
const fs = require("fs");
3+
const path = require("path");
4+
5+
const distDir = path.resolve(__dirname, "../dist");
6+
7+
console.log("Cleaning dist directory...");
8+
9+
for (const filename of fs.readdirSync(distDir)) {
10+
if (filename.includes("vendor")) {
11+
continue;
12+
}
13+
14+
fs.unlinkSync(path.join(distDir, filename));
15+
}
16+
17+
console.log("Building with webpack...");
18+
19+
const args = process.argv.slice(2);
20+
exec(`npx webpack ${args.join(" ")}`, (error, stdout, stderr) => {
21+
if (error) {
22+
console.error(error.message);
23+
return;
24+
}
25+
if (stderr) {
26+
console.error(stderr);
27+
return;
28+
}
29+
30+
if (stdout) {
31+
console.log(stdout);
32+
}
33+
34+
console.log("Saving files info in plugin.json...");
35+
36+
const pluginJSONPath = path.resolve(__dirname, "../plugin.json");
37+
38+
const pluginInfo = JSON.parse(fs.readFileSync(pluginJSONPath));
39+
const files = [];
40+
for (const filename of fs.readdirSync(distDir)) {
41+
if (filename !== "main.js" && filename.endsWith(".js")) {
42+
files.push(filename);
43+
}
44+
}
45+
46+
pluginInfo.files = files;
47+
fs.writeFileSync(pluginJSONPath, JSON.stringify(pluginInfo, null, 2));
48+
});

src/vendor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import prettier from "prettier/standalone";
2-
import pretterParserHTML from "prettier/parser-html";
2+
import pretterParserHTML from "prettier/parser-html/";
33
import prettierParserBabel from "prettier/parser-babel";
44
import prettierParserGraphql from "prettier/parser-graphql";
55
import prettierParserAngular from "prettier/parser-angular";

src/worker.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ self.onmessage = (e) => {
22
const { id, code, cursorOptions, action, scriptUrl } = e.data;
33
if (action === "load script") {
44
importScripts(scriptUrl);
5-
console.log(self.acodePluginPrettier);
65
self.postMessage({ action: "script loaded" });
76
return;
87
}

0 commit comments

Comments
 (0)