@iservice-dev/is-wp-plugin-kit 1.5.4 → 1.6.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.
@@ -0,0 +1,11 @@
1
+ import { execSync } from 'node:child_process';
2
+
3
+ export function runBuild() {
4
+ execSync('oxlint assets/src/ts', { stdio: 'inherit' });
5
+ execSync('stylelint "assets/src/scss/**/*.scss" --fix', { stdio: 'inherit' });
6
+ execSync('vite build', { stdio: 'inherit' });
7
+ execSync('is-wp-plugin-kit compile-mo', { stdio: 'inherit' });
8
+
9
+ console.log('✓ Build completed');
10
+ process.exit(0);
11
+ }
@@ -0,0 +1,10 @@
1
+ import path from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+
4
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
5
+
6
+ export function runCompileMo() {
7
+ const moScript = path.resolve(__dirname, '../../files/compile-mo.mjs');
8
+ import(moScript);
9
+ process.exit(0);
10
+ }
@@ -0,0 +1,13 @@
1
+ import { execSync } from 'node:child_process';
2
+
3
+ export function runDev() {
4
+ execSync(
5
+ 'concurrently -k ' +
6
+ '"vite" ' +
7
+ "\"chokidar 'assets/src/ts/**/*.ts' -c 'oxlint assets/src/ts'\" " +
8
+ "\"chokidar 'assets/src/scss/**/*.scss' -c 'stylelint \\\"assets/src/scss/**/*.scss\\\" --fix'\" " +
9
+ "\"chokidar 'assets/src/l10n/**/*.po' -c 'is-wp-plugin-kit compile-mo'\"",
10
+ { stdio: 'inherit' }
11
+ );
12
+ process.exit(0);
13
+ }
@@ -0,0 +1,164 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { copy } from '../utils.js';
4
+
5
+ import { createRequire } from 'module';
6
+ const require = createRequire(import.meta.url);
7
+ const selfPkg = require('../package.json');
8
+
9
+ const toolkitVersion = `^${selfPkg.version}`;
10
+
11
+ export function runInit() {
12
+ const root = process.cwd();
13
+
14
+ // ------------------------------------------
15
+ // 1) .gitignore kopieren
16
+ // ------------------------------------------
17
+ copy('gitignore');
18
+
19
+ // ------------------------------------------
20
+ // 2) stylelint config erzeugen
21
+ // ------------------------------------------
22
+ fs.writeFileSync(
23
+ path.join(root, '.stylelintrc.json'),
24
+ JSON.stringify(
25
+ {
26
+ extends: ['@iservice-dev/is-wp-plugin-kit/files/stylelintrc.json'],
27
+ },
28
+ null,
29
+ 2
30
+ )
31
+ );
32
+ console.log('✓ Created .stylelintrc.json');
33
+
34
+ // ------------------------------------------
35
+ // 3) tsconfig erzeugen
36
+ // ------------------------------------------
37
+ fs.writeFileSync(
38
+ path.join(root, 'tsconfig.json'),
39
+ JSON.stringify(
40
+ {
41
+ extends: '@iservice-dev/is-wp-plugin-kit/files/tsconfig.json',
42
+ include: ['assets/src/ts/**/*.ts'],
43
+ },
44
+ null,
45
+ 2
46
+ )
47
+ );
48
+ console.log('✓ Created tsconfig.json');
49
+
50
+ // ------------------------------------------
51
+ // 4) oxlintrc erzeugen
52
+ // ------------------------------------------
53
+ fs.writeFileSync(
54
+ path.join(root, '.oxlintrc.json'),
55
+ JSON.stringify(
56
+ {
57
+ extends: ['@iservice-dev/is-wp-plugin-kit/files/oxlintrc.json'],
58
+ },
59
+ null,
60
+ 2
61
+ )
62
+ );
63
+ console.log('✓ Created .oxlintrc.json');
64
+
65
+ // ------------------------------------------
66
+ // 5) postcss config erzeugen
67
+ // ------------------------------------------
68
+ fs.writeFileSync(
69
+ path.join(root, 'postcss.config.cjs'),
70
+ `module.exports = require("@iservice-dev/is-wp-plugin-kit/files/postcss.config.cjs");\n`
71
+ );
72
+ console.log('✓ Created postcss.config.cjs');
73
+
74
+ // ------------------------------------------
75
+ // 6) vite.config.ts erzeugen
76
+ // ------------------------------------------
77
+ fs.writeFileSync(
78
+ path.join(root, 'vite.config.ts'),
79
+ `import { wpPluginKitVite } from "@iservice-dev/is-wp-plugin-kit/vite";
80
+
81
+ export default wpPluginKitVite({
82
+ port: 5500
83
+ });
84
+ `
85
+ );
86
+ console.log('✓ Created vite.config.ts');
87
+
88
+ // ------------------------------------------
89
+ // 7) package.json erzeugen (falls nicht vorhanden)
90
+ // ------------------------------------------
91
+ const pkgPath = path.join(root, 'package.json');
92
+
93
+ if (!fs.existsSync(pkgPath)) {
94
+ const pkg = {
95
+ name: path.basename(root),
96
+ version: '1.0.0',
97
+ type: 'module',
98
+ description: 'iService WordPress Plugin',
99
+ scripts: {
100
+ dev: 'is-wp-plugin-kit dev',
101
+ build: 'is-wp-plugin-kit build',
102
+ },
103
+ devDependencies: {
104
+ '@iservice-dev/is-wp-plugin-kit': toolkitVersion,
105
+ vite: '^7.1.7',
106
+ },
107
+ };
108
+
109
+ fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
110
+ console.log('✓ Created package.json');
111
+ } else {
112
+ console.log('↺ package.json already exists – skipped');
113
+ }
114
+
115
+ // ------------------------------------------
116
+ // 8) Ordnerstruktur erzeugen
117
+ // ------------------------------------------
118
+ const dirs = [
119
+ 'assets/src/ts',
120
+ 'assets/src/scss',
121
+ 'assets/src/fonts',
122
+ 'assets/src/images',
123
+ 'assets/src/l10n',
124
+ 'assets/src/legacy/js',
125
+ 'assets/src/legacy/css',
126
+ 'assets/dist',
127
+ 'includes/lib/Admin',
128
+ 'includes/lib/Core',
129
+ 'includes/lib/Frontend',
130
+ 'languages',
131
+ ];
132
+
133
+ // Ordner die kein .gitkeep brauchen (bekommen andere Dateien)
134
+ const skipGitkeep = ['assets/src/l10n', 'includes/lib/Core'];
135
+
136
+ dirs.forEach((dir) => {
137
+ const full = path.join(root, dir);
138
+ if (!fs.existsSync(full)) {
139
+ fs.mkdirSync(full, { recursive: true });
140
+
141
+ if (!skipGitkeep.includes(dir)) {
142
+ const gitkeepPath = path.join(full, '.gitkeep');
143
+ fs.writeFileSync(gitkeepPath, '');
144
+ }
145
+ }
146
+ });
147
+
148
+ console.log('✓ Created folder structure with .gitkeep files');
149
+
150
+ // ------------------------------------------
151
+ // 9) de_DE.po Template kopieren
152
+ // ------------------------------------------
153
+ copy('de_DE.po', 'assets/src/l10n/de_DE.po');
154
+
155
+ // ------------------------------------------
156
+ // 10) PHP Template Files kopieren
157
+ // ------------------------------------------
158
+ copy('Plugin.php', 'includes/lib/Core/Plugin.php');
159
+ copy('Config.php', 'includes/lib/Core/Config.php');
160
+
161
+ // ------------------------------------------
162
+ console.log('\n🎉 Project initialized successfully!\n');
163
+ process.exit(0);
164
+ }
@@ -1,134 +1,34 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- import path from "node:path";
4
- import fs from "node:fs";
5
- import { execSync } from "node:child_process";
6
- import { fileURLToPath } from "node:url";
3
+ import { runInit } from './commands/init.js';
4
+ import { runDev } from './commands/dev.js';
5
+ import { runBuild } from './commands/build.js';
6
+ import { runCompileMo } from './commands/compile-mo.js';
7
7
 
8
- const __dirname = path.dirname(fileURLToPath(import.meta.url));
9
8
  const cmd = process.argv[2];
10
9
 
11
- // ---------------------------
12
- // Utility: safe copy
13
- // ---------------------------
14
- const copy = (file) => {
15
- try {
16
- const src = path.resolve(__dirname, "../files", file);
17
- const dest = path.resolve(
18
- process.cwd(),
19
- file.replace(/^gitignore$/, ".gitignore")
20
- );
21
-
22
- if (!fs.existsSync(src)) {
23
- console.error(`Error: Source file ${file} not found.`);
24
- process.exit(1);
25
- }
26
-
27
- fs.copyFileSync(src, dest);
28
- console.log(`✓ Copied ${file}`);
29
- } catch (error) {
30
- console.error(`Error copying ${file}:`, error.message);
31
- process.exit(1);
32
- }
33
- };
34
-
35
- // ---------------------------
36
- // INIT
37
- // ---------------------------
38
- if (cmd === "init") {
39
- copy("gitignore");
40
- copy("oxlintrc.json");
41
- copy("stylelintrc.json");
42
- copy("postcss.config.cjs");
43
- copy("tsconfig.json");
44
-
45
- console.log("✓ Project initialized with WP Plugin Kit defaults.");
46
- process.exit(0);
47
- }
48
-
49
- // ---------------------------
50
- // compile-mo
51
- // ---------------------------
52
- if (cmd === "compile-mo") {
53
- const moScript = path.resolve(__dirname, "../files/compile-mo.mjs");
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);
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(`
10
+ switch (cmd) {
11
+ case 'init':
12
+ runInit();
13
+ break;
14
+ case 'dev':
15
+ runDev();
16
+ break;
17
+ case 'build':
18
+ runBuild();
19
+ break;
20
+ case 'compile-mo':
21
+ runCompileMo();
22
+ break;
23
+
24
+ default:
25
+ console.log(`
122
26
  is-wp-plugin-kit – available commands:
123
27
 
124
- init → Copy default config files into project
28
+ init → Setup a new plugin project
29
+ dev → Run vite + watchers
30
+ build → Production build
125
31
  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
32
  `);
33
+ }
133
34
 
134
- process.exit(0);
package/bin/utils.js ADDED
@@ -0,0 +1,30 @@
1
+ import fs from 'node:fs';
2
+ import path from 'node:path';
3
+ import { fileURLToPath } from 'node:url';
4
+
5
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
+
7
+ /**
8
+ * Safely copy a file from the files directory to the current working directory
9
+ * @param {string} file - The filename to copy
10
+ */
11
+ export function copy(file) {
12
+ try {
13
+ const src = path.resolve(__dirname, '../files', file);
14
+ const dest = path.resolve(
15
+ process.cwd(),
16
+ file.replace(/^gitignore$/, '.gitignore')
17
+ );
18
+
19
+ if (!fs.existsSync(src)) {
20
+ console.error(`Error: Source file ${file} not found.`);
21
+ process.exit(1);
22
+ }
23
+
24
+ fs.copyFileSync(src, dest);
25
+ console.log(`✓ Copied ${file}`);
26
+ } catch (error) {
27
+ console.error(`Error copying ${file}:`, error.message);
28
+ process.exit(1);
29
+ }
30
+ }
@@ -0,0 +1,11 @@
1
+ {
2
+ "printWidth": 100,
3
+ "tabWidth": 4,
4
+ "useTabs": true,
5
+ "semi": true,
6
+ "singleQuote": true,
7
+ "trailingComma": "es5",
8
+ "bracketSpacing": true,
9
+ "arrowParens": "always",
10
+ "endOfLine": "lf"
11
+ }
@@ -0,0 +1,20 @@
1
+ <?php
2
+ //TODO change namespace
3
+ namespace IS\Template\Core;
4
+
5
+ use IS\Base\Core\Abstract_Config;
6
+
7
+ final class Config extends Abstract_Config {
8
+ protected function __construct() {
9
+ //TODO change pluginName and port if general plugin
10
+ $this->pluginName = "is-template-plugin";
11
+ $this->customPrefix = "iS_";
12
+ $this->vitePort = 5500;
13
+
14
+ parent::__construct();
15
+ }
16
+ }
17
+
18
+
19
+
20
+
@@ -0,0 +1,35 @@
1
+ <?php
2
+ //TODO change namespace
3
+ namespace IS\Template\Core;
4
+
5
+ use IS\Base\Core\Updater;
6
+ use IS\Base\Core\Auto_Instantiate;
7
+
8
+ class Plugin {
9
+ private static Config $config;
10
+
11
+ public static function boot(string $file): void {
12
+
13
+ self::$config = Config::get_instance();
14
+
15
+ if (file_exists(self::$config->path . 'languages/')) {
16
+ load_plugin_textdomain(
17
+ self::$config->pluginName,
18
+ false,
19
+ dirname(plugin_basename($file)) . '/languages/'
20
+ );
21
+ }
22
+
23
+ //TODO change github repo link and plugin slug
24
+ $updater = new Updater(
25
+ 'https://github.com/iService-dev/is-template-plugin',
26
+ $file,
27
+ 'is-template-plugin'
28
+ );
29
+ $updater->init();
30
+
31
+ //TODO only needed if classes in Admin or Frontend folder
32
+ Auto_Instantiate::instantiate_classes_static(self::$config, 'Admin');
33
+ Auto_Instantiate::instantiate_classes_static(self::$config, 'Frontend');
34
+ }
35
+ }
package/files/de_DE.po ADDED
@@ -0,0 +1,8 @@
1
+ "Project-Id-Version: iService Plugin\n"
2
+ "Last-Translator: iService <support@iservice.at>\n"
3
+ "Language: de_DE\n"
4
+ "Content-Type: text/plain; charset=UTF-8\n"
5
+ "Content-Transfer-Encoding: 8bit\n"
6
+
7
+ msgid ""
8
+ msgstr ""
@@ -4,43 +4,15 @@
4
4
  "module": "ESNext",
5
5
  "lib": ["ES2022", "DOM", "DOM.Iterable"],
6
6
  "moduleResolution": "bundler",
7
+
7
8
  "allowImportingTsExtensions": true,
8
9
  "resolveJsonModule": true,
9
10
  "isolatedModules": true,
10
11
  "moduleDetection": "force",
11
- "noEmit": true,
12
- "jsx": "preserve",
13
-
14
- "allowSyntheticDefaultImports": true,
15
- "esModuleInterop": true,
16
- "forceConsistentCasingInFileNames": true,
17
- "verbatimModuleSyntax": true,
18
-
19
12
  "strict": true,
20
- "noUnusedLocals": true,
21
- "noUnusedParameters": true,
22
- "noFallthroughCasesInSwitch": true,
23
- "noUncheckedIndexedAccess": true,
24
- "noImplicitReturns": true,
25
- "exactOptionalPropertyTypes": true,
26
-
27
- "baseUrl": ".",
28
- "paths": {
29
- "@/*": ["./assets/src/*"],
30
- "@/modules/*": ["./assets/src/ts/modules/*"],
31
- "@/types/*": ["./assets/src/ts/types/*"]
32
- },
33
13
 
34
- "types": ["jquery", "node"],
35
- "skipLibCheck": true
14
+ "skipLibCheck": true,
15
+ "noEmit": true
36
16
  },
37
- "include": [
38
- "assets/src/**/*.ts",
39
- "assets/src/**/*.js",
40
- "vite.config.ts"
41
- ],
42
- "exclude": [
43
- "node_modules",
44
- "assets/dist"
45
- ]
46
- }
17
+ "include": []
18
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iservice-dev/is-wp-plugin-kit",
3
- "version": "1.5.4",
3
+ "version": "1.6.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",