@iservice-dev/is-wp-plugin-kit 1.3.0 → 1.5.0

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.
@@ -1,11 +1,16 @@
1
1
  #!/usr/bin/env node
2
+
2
3
  import path from "node:path";
3
4
  import fs from "node:fs";
5
+ import { execSync } from "node:child_process";
4
6
  import { fileURLToPath } from "node:url";
5
7
 
6
8
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
9
  const cmd = process.argv[2];
8
10
 
11
+ // ---------------------------
12
+ // Utility: safe copy
13
+ // ---------------------------
9
14
  const copy = (file) => {
10
15
  try {
11
16
  const src = path.resolve(__dirname, "../files", file);
@@ -13,12 +18,12 @@ const copy = (file) => {
13
18
  process.cwd(),
14
19
  file.replace(/^gitignore$/, ".gitignore")
15
20
  );
16
-
21
+
17
22
  if (!fs.existsSync(src)) {
18
23
  console.error(`Error: Source file ${file} not found.`);
19
24
  process.exit(1);
20
25
  }
21
-
26
+
22
27
  fs.copyFileSync(src, dest);
23
28
  console.log(`✓ Copied ${file}`);
24
29
  } catch (error) {
@@ -27,6 +32,9 @@ const copy = (file) => {
27
32
  }
28
33
  };
29
34
 
35
+ // ---------------------------
36
+ // INIT
37
+ // ---------------------------
30
38
  if (cmd === "init") {
31
39
  copy("gitignore");
32
40
  copy("oxlintrc.json");
@@ -34,10 +42,93 @@ if (cmd === "init") {
34
42
  copy("postcss.config.cjs");
35
43
  copy("tsconfig.json");
36
44
 
37
- console.log("Project initialized with WP Plugin Kit defaults.");
45
+ console.log("Project initialized with WP Plugin Kit defaults.");
46
+ process.exit(0);
38
47
  }
39
48
 
49
+ // ---------------------------
50
+ // compile-mo
51
+ // ---------------------------
40
52
  if (cmd === "compile-mo") {
41
53
  const moScript = path.resolve(__dirname, "../files/compile-mo.mjs");
42
54
  import(moScript);
55
+ process.exit(0);
56
+ }
57
+
58
+ // ---------------------------
59
+ // DEV (vite + watchers + mo)
60
+ // ---------------------------
61
+ if (cmd === "dev") {
62
+ execSync(
63
+ "concurrently -k " +
64
+ '"vite" ' +
65
+ "\"chokidar 'assets/src/ts/**/*.ts' -c 'oxlint assets/src/ts'\" " +
66
+ "\"chokidar 'assets/src/scss/**/*.scss' -c 'stylelint \\\"assets/src/scss/**/*.scss\\\" --fix'\" " +
67
+ "\"chokidar 'assets/src/l10n/**/*.po' -c 'is-wp-plugin-kit compile-mo'\"",
68
+ { stdio: "inherit" }
69
+ );
70
+ process.exit(0);
71
+ }
72
+
73
+ // ---------------------------
74
+ // Sub-tasks used by dev
75
+ // ---------------------------
76
+
77
+ if (cmd === "dev:vite") {
78
+ execSync("vite", { stdio: "inherit" });
79
+ process.exit(0);
80
+ }
81
+
82
+ if (cmd === "watch:lint") {
83
+ execSync("chokidar 'assets/src/ts/**/*.ts' -c 'oxlint assets/src/ts'", {
84
+ stdio: "inherit",
85
+ });
86
+ process.exit(0);
43
87
  }
88
+
89
+ if (cmd === "watch:stylelint") {
90
+ execSync(
91
+ "chokidar 'assets/src/scss/**/*.scss' -c 'stylelint \"assets/src/scss/**/*.scss\" --fix'",
92
+ { stdio: "inherit" }
93
+ );
94
+ process.exit(0);
95
+ }
96
+
97
+ if (cmd === "watch:mo") {
98
+ execSync(
99
+ "chokidar 'assets/src/l10n/**/*.po' -c 'is-wp-plugin-kit compile-mo'",
100
+ { stdio: "inherit" }
101
+ );
102
+ process.exit(0);
103
+ }
104
+
105
+ // ---------------------------
106
+ // BUILD
107
+ // ---------------------------
108
+ if (cmd === "build") {
109
+ execSync("oxlint assets/src/ts", { stdio: "inherit" });
110
+ execSync('stylelint "assets/src/scss/**/*.scss" --fix', { stdio: "inherit" });
111
+ execSync("vite build", { stdio: "inherit" });
112
+ execSync("is-wp-plugin-kit compile-mo", { stdio: "inherit" });
113
+
114
+ console.log("✓ Build completed");
115
+ process.exit(0);
116
+ }
117
+
118
+ // ---------------------------
119
+ // HELP
120
+ // ---------------------------
121
+ console.log(`
122
+ is-wp-plugin-kit – available commands:
123
+
124
+ init → Copy default config files into project
125
+ compile-mo → Convert .po → .mo
126
+ dev → Run vite + lint/watch + mo watcher
127
+ build → Run full production build
128
+ dev:vite → Run Vite only
129
+ watch:lint → Watch + lint TS
130
+ watch:stylelint → Watch + format SCSS
131
+ watch:mo → Watch + compile .po files
132
+ `);
133
+
134
+ process.exit(0);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iservice-dev/is-wp-plugin-kit",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "A toolkit for WordPress plugin development with Vite, TypeScript, and modern build tools",
5
5
  "type": "module",
6
6
  "main": "vite/index.js",
@@ -19,8 +19,20 @@
19
19
  "is-wp-plugin-kit": "./bin/is-wp-plugin-kit.js"
20
20
  },
21
21
  "dependencies": {
22
+ "@types/jquery": "^3.5.33",
23
+ "@types/node": "^24.3.0",
24
+ "autoprefixer": "^10.4.21",
25
+ "chokidar-cli": "^3.0.0",
22
26
  "fast-glob": "^3.3.3",
23
- "vite-plugin-static-copy": "^3.1.3"
27
+ "oxlint": "^1.20.0",
28
+ "po2mo": "^2.0.7",
29
+ "sass-embedded": "^1.92.0",
30
+ "stylelint": "^16.25.0",
31
+ "stylelint-config-standard-scss": "^16.0.0",
32
+ "stylelint-order": "^7.0.0",
33
+ "stylelint-scss": "^6.12.1",
34
+ "vite-plugin-static-copy": "^3.1.3",
35
+ "concurrently": "^8.2.2"
24
36
  },
25
37
  "peerDependencies": {
26
38
  "vite": ">=7.0.0"