@iservice-dev/is-wp-plugin-kit 1.0.0 → 1.2.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/README.md ADDED
@@ -0,0 +1,114 @@
1
+ # @iservice-dev/is-wp-plugin-kit
2
+
3
+ A toolkit for WordPress plugin development with Vite, TypeScript, and modern build tools.
4
+
5
+ ## Features
6
+
7
+ - 🚀 **Vite Integration**: Fast development with HMR support
8
+ - 📦 **TypeScript Support**: Full TypeScript configuration for WordPress plugins
9
+ - 🎨 **SCSS Processing**: Modern CSS workflow with PostCSS and Autoprefixer
10
+ - 🔍 **Linting**: Pre-configured OXLint and Stylelint rules
11
+ - 🌍 **i18n Support**: Compile `.po` files to `.mo` for WordPress localization
12
+ - 📁 **Smart Asset Handling**: Automatic processing of JS, CSS, images, and fonts
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install --save-dev @iservice-dev/is-wp-plugin-kit
18
+ ```
19
+
20
+ ## Usage
21
+
22
+ ### Initialize Your Project
23
+
24
+ Set up your WordPress plugin with default configuration files:
25
+
26
+ ```bash
27
+ npx is-wp-plugin-kit init
28
+ ```
29
+
30
+ This creates the following files in your project root:
31
+ - `.gitignore` - WordPress-specific ignore patterns
32
+ - `oxlintrc.json` - JavaScript/TypeScript linting configuration
33
+ - `stylelintrc.json` - CSS/SCSS linting configuration
34
+ - `postcss.config.cjs` - PostCSS configuration with Autoprefixer
35
+ - `tsconfig.json` - TypeScript configuration optimized for WordPress
36
+
37
+ ### Vite Configuration
38
+
39
+ In your `vite.config.js`:
40
+
41
+ ```javascript
42
+ import { defineConfig } from 'vite';
43
+ import wpPluginKit from '@iservice-dev/is-wp-plugin-kit';
44
+
45
+ export default defineConfig({
46
+ plugins: [
47
+ wpPluginKit({
48
+ entry: 'src/main.ts', // Your main entry file
49
+ outDir: 'dist', // Output directory
50
+ })
51
+ ]
52
+ });
53
+ ```
54
+
55
+ ### Compile Translation Files
56
+
57
+ Compile `.po` files to `.mo` for WordPress i18n:
58
+
59
+ ```bash
60
+ npx is-wp-plugin-kit compile-mo
61
+ ```
62
+
63
+ This automatically finds and compiles all `.po` files in your `languages/` directory.
64
+
65
+ ## What's Included
66
+
67
+ ### Vite Plugin
68
+
69
+ The plugin automatically handles:
70
+ - **Entry point compilation** (TypeScript/JavaScript)
71
+ - **SCSS processing** with PostCSS
72
+ - **Asset copying** (images, fonts, PHP files)
73
+ - **WordPress-specific optimizations**
74
+
75
+ ### Configuration Files
76
+
77
+ #### TypeScript (`tsconfig.json`)
78
+ Pre-configured for WordPress development with proper types and module resolution.
79
+
80
+ #### PostCSS (`postcss.config.cjs`)
81
+ Includes Autoprefixer for automatic vendor prefixing.
82
+
83
+ #### Linting
84
+ - **OXLint**: Fast JavaScript/TypeScript linting
85
+ - **Stylelint**: CSS/SCSS linting with modern standards
86
+
87
+ ## Project Structure
88
+
89
+ Your WordPress plugin should follow this structure:
90
+
91
+ ```
92
+ your-plugin/
93
+ ├── src/
94
+ │ ├── main.ts # Entry point
95
+ │ ├── styles/ # SCSS files
96
+ │ └── ...
97
+ ├── languages/ # Translation files (.po)
98
+ ├── dist/ # Built files (auto-generated)
99
+ ├── vite.config.js
100
+ └── package.json
101
+ ```
102
+
103
+ ## Requirements
104
+
105
+ - Node.js 18 or higher
106
+ - Vite 5.x or 6.x (peer dependency)
107
+
108
+ ## License
109
+
110
+ ISC
111
+
112
+ ## Repository
113
+
114
+ [https://github.com/iservice-dev/is-wp-plugin-kit](https://github.com/iservice-dev/is-wp-plugin-kit)
@@ -7,12 +7,24 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
7
7
  const cmd = process.argv[2];
8
8
 
9
9
  const copy = (file) => {
10
- const src = path.resolve(__dirname, "../files", file);
11
- const dest = path.resolve(
12
- process.cwd(),
13
- file.replace(/^gitignore$/, ".gitignore")
14
- );
15
- fs.copyFileSync(src, dest);
10
+ try {
11
+ const src = path.resolve(__dirname, "../files", file);
12
+ const dest = path.resolve(
13
+ process.cwd(),
14
+ file.replace(/^gitignore$/, ".gitignore")
15
+ );
16
+
17
+ if (!fs.existsSync(src)) {
18
+ console.error(`Error: Source file ${file} not found.`);
19
+ process.exit(1);
20
+ }
21
+
22
+ fs.copyFileSync(src, dest);
23
+ console.log(`✓ Copied ${file}`);
24
+ } catch (error) {
25
+ console.error(`Error copying ${file}:`, error.message);
26
+ process.exit(1);
27
+ }
16
28
  };
17
29
 
18
30
  if (cmd === "init") {
@@ -0,0 +1,5 @@
1
+ assets/dist/
2
+ node_modules/
3
+ includes/build-version.php
4
+ vendor/
5
+ .DS_Store
package/package.json CHANGED
@@ -1,21 +1,35 @@
1
1
  {
2
2
  "name": "@iservice-dev/is-wp-plugin-kit",
3
- "version": "1.0.0",
4
- "description": "",
3
+ "version": "1.2.0",
4
+ "description": "A toolkit for WordPress plugin development with Vite, TypeScript, and modern build tools",
5
+ "type": "module",
5
6
  "main": "vite/index.js",
6
7
  "files": [
7
- "vite",
8
- "files",
9
- "bin"
8
+ "vite",
9
+ "files",
10
+ "bin"
10
11
  ],
11
12
  "bin": {
12
- "is-wp-plugin-kit": "./bin/is-wp-plugin-kit.js"
13
+ "is-wp-plugin-kit": "./bin/is-wp-plugin-kit.js"
13
14
  },
14
- "dependencies": {
15
+ "dependencies": {
15
16
  "fast-glob": "^3.3.3",
16
17
  "vite-plugin-static-copy": "^3.1.3"
17
18
  },
18
- "keywords": [],
19
+ "peerDependencies": {
20
+ "vite": ">=7.0.0"
21
+ },
22
+ "keywords": [
23
+ "wordpress",
24
+ "plugin",
25
+ "vite",
26
+ "typescript",
27
+ "build-tool"
28
+ ],
19
29
  "author": "iService",
20
- "license": "ISC"
30
+ "license": "ISC",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/iservice-dev/is-wp-plugin-kit.git"
34
+ }
21
35
  }