@varavel/vdl-plugin-sdk 0.1.1 → 0.1.2

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 (2) hide show
  1. package/bin/vdl-plugin.js +31 -12
  2. package/package.json +1 -1
package/bin/vdl-plugin.js CHANGED
@@ -6,30 +6,49 @@ import { resolve } from "node:path";
6
6
  import * as esbuild from "esbuild";
7
7
 
8
8
  const require = createRequire(import.meta.url);
9
- const command = process.argv[2];
9
+ const args = process.argv.slice(2);
10
+ const command = args[0];
11
+ const flags = new Set(args.slice(1));
12
+
13
+ const GREEN = "\x1b[32m";
14
+ const RED = "\x1b[31m";
15
+ const CYAN = "\x1b[36m";
16
+ const RESET = "\x1b[0m";
17
+
18
+ const log = {
19
+ info: (msg) => console.log(`${CYAN}[i]${RESET} ${msg}`),
20
+ ok: (msg) => console.log(`${GREEN}[✓]${RESET} ${msg}`),
21
+ error: (msg) => console.error(`${RED}[✗]${RESET} ${msg}`),
22
+ };
10
23
 
11
24
  function printHelp() {
12
- console.log(`Usage: vdl-plugin <command>
25
+ console.log(`Usage: vdl-plugin <command> [options]
13
26
 
14
27
  Commands:
15
- check Run TypeScript type checks without emitting files
16
- build Bundle the plugin from src/index.ts into dist/index.js`);
28
+ check Run TypeScript type checks without emitting files
29
+ build Bundle the plugin from src/index.ts into dist/index.js
30
+
31
+ Build options:
32
+ --no-minify Disable minification (minification is enabled by default)`);
17
33
  }
18
34
 
19
35
  function runCheck() {
20
- console.log("Running TypeScript type checks...");
36
+ log.info("Running TypeScript type checks...");
21
37
 
22
38
  try {
23
39
  const tscPath = require.resolve("typescript/bin/tsc");
24
40
  execFileSync(process.execPath, [tscPath, "--noEmit"], { stdio: "inherit" });
25
- console.log("Type checks completed successfully.");
41
+ log.ok("Type checks completed successfully.");
26
42
  } catch {
43
+ log.error("Type checks failed.");
27
44
  process.exit(1);
28
45
  }
29
46
  }
30
47
 
31
48
  function runBuild() {
32
- console.log("Building VDL plugin...");
49
+ const minify = !flags.has("--no-minify");
50
+
51
+ log.info(`Building VDL plugin${minify ? "" : " (minification disabled)"}...`);
33
52
 
34
53
  try {
35
54
  esbuild.buildSync({
@@ -39,15 +58,15 @@ function runBuild() {
39
58
  platform: "neutral",
40
59
  target: "es2015",
41
60
  bundle: true,
42
- minify: true,
61
+ minify,
43
62
  treeShaking: true,
44
63
  });
45
64
 
46
- console.log("Plugin built successfully at dist/index.js.");
65
+ log.ok("Plugin built successfully at dist/index.js.");
47
66
  } catch (error) {
48
- console.error("Failed to build the plugin.");
67
+ log.error("Failed to build the plugin.");
49
68
  if (error instanceof Error && error.message) {
50
- console.error(error.message);
69
+ log.error(error.message);
51
70
  }
52
71
  process.exit(1);
53
72
  }
@@ -59,7 +78,7 @@ if (command === "check") {
59
78
  runBuild();
60
79
  } else {
61
80
  if (command) {
62
- console.error(`Unknown command: ${command}`);
81
+ log.error(`Unknown command: ${command}`);
63
82
  }
64
83
  printHelp();
65
84
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@varavel/vdl-plugin-sdk",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "SDK to build plugins for VDL using TypeScript",
5
5
  "keywords": [
6
6
  "varavel",