@iservice-dev/is-wp-plugin-kit 1.2.0 → 1.4.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.
- package/bin/is-wp-plugin-kit.js +90 -3
- package/package.json +17 -1
- package/vite/index.d.ts +3 -0
package/bin/is-wp-plugin-kit.js
CHANGED
|
@@ -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,89 @@ 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
|
+
"npm-run-all --parallel dev:vite watch:lint watch:stylelint watch:mo",
|
|
64
|
+
{ stdio: "inherit" }
|
|
65
|
+
);
|
|
66
|
+
process.exit(0);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ---------------------------
|
|
70
|
+
// Sub-tasks used by dev
|
|
71
|
+
// ---------------------------
|
|
72
|
+
|
|
73
|
+
if (cmd === "dev:vite") {
|
|
74
|
+
execSync("vite", { stdio: "inherit" });
|
|
75
|
+
process.exit(0);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (cmd === "watch:lint") {
|
|
79
|
+
execSync("chokidar 'assets/src/ts/**/*.ts' -c 'oxlint assets/src/ts'", {
|
|
80
|
+
stdio: "inherit",
|
|
81
|
+
});
|
|
82
|
+
process.exit(0);
|
|
43
83
|
}
|
|
84
|
+
|
|
85
|
+
if (cmd === "watch:stylelint") {
|
|
86
|
+
execSync(
|
|
87
|
+
"chokidar 'assets/src/scss/**/*.scss' -c 'stylelint \"assets/src/scss/**/*.scss\" --fix'",
|
|
88
|
+
{ stdio: "inherit" }
|
|
89
|
+
);
|
|
90
|
+
process.exit(0);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (cmd === "watch:mo") {
|
|
94
|
+
execSync(
|
|
95
|
+
"chokidar 'assets/src/l10n/**/*.po' -c 'is-wp-plugin-kit compile-mo'",
|
|
96
|
+
{ stdio: "inherit" }
|
|
97
|
+
);
|
|
98
|
+
process.exit(0);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// ---------------------------
|
|
102
|
+
// BUILD
|
|
103
|
+
// ---------------------------
|
|
104
|
+
if (cmd === "build") {
|
|
105
|
+
execSync("oxlint assets/src/ts", { stdio: "inherit" });
|
|
106
|
+
execSync('stylelint "assets/src/scss/**/*.scss" --fix', { stdio: "inherit" });
|
|
107
|
+
execSync("vite build", { stdio: "inherit" });
|
|
108
|
+
execSync("is-wp-plugin-kit compile-mo", { stdio: "inherit" });
|
|
109
|
+
|
|
110
|
+
console.log("✓ Build completed");
|
|
111
|
+
process.exit(0);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// ---------------------------
|
|
115
|
+
// HELP
|
|
116
|
+
// ---------------------------
|
|
117
|
+
console.log(`
|
|
118
|
+
is-wp-plugin-kit – available commands:
|
|
119
|
+
|
|
120
|
+
init → Copy default config files into project
|
|
121
|
+
compile-mo → Convert .po → .mo
|
|
122
|
+
dev → Run vite + lint/watch + mo watcher
|
|
123
|
+
build → Run full production build
|
|
124
|
+
dev:vite → Run Vite only
|
|
125
|
+
watch:lint → Watch + lint TS
|
|
126
|
+
watch:stylelint → Watch + format SCSS
|
|
127
|
+
watch:mo → Watch + compile .po files
|
|
128
|
+
`);
|
|
129
|
+
|
|
130
|
+
process.exit(0);
|
package/package.json
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@iservice-dev/is-wp-plugin-kit",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.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",
|
|
7
|
+
"exports": {
|
|
8
|
+
"./vite": {
|
|
9
|
+
"types": "./vite/index.d.ts",
|
|
10
|
+
"default": "./vite/index.js"
|
|
11
|
+
}
|
|
12
|
+
},
|
|
7
13
|
"files": [
|
|
8
14
|
"vite",
|
|
9
15
|
"files",
|
|
@@ -13,7 +19,17 @@
|
|
|
13
19
|
"is-wp-plugin-kit": "./bin/is-wp-plugin-kit.js"
|
|
14
20
|
},
|
|
15
21
|
"dependencies": {
|
|
22
|
+
"autoprefixer": "^10.4.21",
|
|
23
|
+
"chokidar-cli": "^3.0.0",
|
|
16
24
|
"fast-glob": "^3.3.3",
|
|
25
|
+
"npm-run-all": "^4.1.5",
|
|
26
|
+
"oxlint": "^1.20.0",
|
|
27
|
+
"po2mo": "^2.0.7",
|
|
28
|
+
"sass-embedded": "^1.92.0",
|
|
29
|
+
"stylelint": "^16.25.0",
|
|
30
|
+
"stylelint-config-standard-scss": "^16.0.0",
|
|
31
|
+
"stylelint-order": "^7.0.0",
|
|
32
|
+
"stylelint-scss": "^6.12.1",
|
|
17
33
|
"vite-plugin-static-copy": "^3.1.3"
|
|
18
34
|
},
|
|
19
35
|
"peerDependencies": {
|
package/vite/index.d.ts
ADDED