@iservice-dev/is-wp-plugin-kit 1.6.10 → 1.7.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.
- package/bin/commands/compile-mo.js +12 -3
- package/bin/commands/init.js +194 -21
- package/bin/is-wp-plugin-kit.js +0 -0
- package/files/Config.php +2 -4
- package/files/Plugin.php +4 -6
- package/files/deploy.yml +152 -0
- package/files/plugin-root-standalone.php +61 -0
- package/files/plugin-root.php +78 -0
- package/package.json +1 -1
|
@@ -1,10 +1,19 @@
|
|
|
1
|
+
import { execFileSync } from 'node:child_process';
|
|
1
2
|
import path from 'node:path';
|
|
2
3
|
import { fileURLToPath } from 'node:url';
|
|
3
4
|
|
|
4
5
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
5
6
|
|
|
6
7
|
export function runCompileMo() {
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
const scriptPath = path.resolve(__dirname, '../../files/compile-mo.mjs');
|
|
9
|
+
|
|
10
|
+
try {
|
|
11
|
+
execFileSync('node', [scriptPath], {
|
|
12
|
+
stdio: 'inherit',
|
|
13
|
+
cwd: process.cwd()
|
|
14
|
+
});
|
|
15
|
+
} catch (err) {
|
|
16
|
+
console.error('❌ Error compiling .po files:', err.message);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
10
19
|
}
|
package/bin/commands/init.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import readline from 'node:readline';
|
|
4
5
|
import { copy } from '../utils.js';
|
|
5
6
|
|
|
6
7
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
@@ -10,17 +11,115 @@ const require = createRequire(import.meta.url);
|
|
|
10
11
|
const selfPkg = require('../../package.json');
|
|
11
12
|
|
|
12
13
|
const toolkitVersion = `^${selfPkg.version}`;
|
|
14
|
+
const defaultWpVersion = '6.5';
|
|
15
|
+
const defaultPhpVersion = '8.3';
|
|
16
|
+
const defaultBaseVersion = '1.0.16';
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
function prompt(question) {
|
|
19
|
+
const rl = readline.createInterface({
|
|
20
|
+
input: process.stdin,
|
|
21
|
+
output: process.stdout,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
return new Promise((resolve) => {
|
|
25
|
+
rl.question(question, (answer) => {
|
|
26
|
+
rl.close();
|
|
27
|
+
resolve(answer);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function isValidVersion(version) {
|
|
33
|
+
return /^\d+(\.\d+){0,2}$/.test(version);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
async function promptVersion(question, defaultValue) {
|
|
37
|
+
while (true) {
|
|
38
|
+
const answer = await prompt(question);
|
|
39
|
+
const version = answer || defaultValue;
|
|
40
|
+
|
|
41
|
+
if (isValidVersion(version)) {
|
|
42
|
+
return version;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
console.error(`❌ Invalid version format: "${version}". Use format like: 1.0.0, 6.5, or 8.3`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function runInit() {
|
|
15
50
|
const root = process.cwd();
|
|
51
|
+
const folderName = path.basename(root);
|
|
52
|
+
|
|
53
|
+
// ------------------------------------------
|
|
54
|
+
// Prompts for plugin configuration
|
|
55
|
+
// ------------------------------------------
|
|
56
|
+
console.log('\n🚀 is-wp-plugin-kit initialization\n');
|
|
57
|
+
|
|
58
|
+
const pluginName = await prompt(`Plugin Name (e.g., My Awesome Plugin): `);
|
|
59
|
+
if (!pluginName) {
|
|
60
|
+
console.error('❌ Plugin Name is required!');
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const pluginDescr = await prompt('Plugin Description (optional): ');
|
|
65
|
+
|
|
66
|
+
const pluginSlug =
|
|
67
|
+
(await prompt(
|
|
68
|
+
`Plugin Slug (default: ${folderName.toLowerCase().replace(/\s+/g, '-')}): `
|
|
69
|
+
)) || folderName.toLowerCase().replace(/\s+/g, '-');
|
|
70
|
+
|
|
71
|
+
const pluginTypeInput = await prompt(
|
|
72
|
+
'Plugin Type - [1] General (requires IS Base) or [2] Standalone (default: 1): '
|
|
73
|
+
);
|
|
74
|
+
const pluginType = pluginTypeInput === '2' ? 'standalone' : 'general';
|
|
75
|
+
|
|
76
|
+
const namespace = await prompt('Namespace (e.g., IS\\MyPlugin): ');
|
|
77
|
+
if (!namespace) {
|
|
78
|
+
console.error('❌ Namespace is required!');
|
|
79
|
+
process.exit(1);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const githubRepo = await prompt('GitHub Repository URL (e.g., https://github.com/user/repo): ');
|
|
83
|
+
if (!githubRepo) {
|
|
84
|
+
console.error('❌ GitHub Repository URL is required!');
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const textDomain = (await prompt(`Text Domain (default: ${pluginSlug}): `)) || pluginSlug;
|
|
89
|
+
const vitePort = (await prompt('Vite Dev Port (default: 5500): ')) || '5500';
|
|
90
|
+
|
|
91
|
+
// Read correct template based on plugin type
|
|
92
|
+
const pluginRootTemplateFile = pluginType === 'standalone' ? 'plugin-root-standalone.php' : 'plugin-root.php';
|
|
93
|
+
const pluginRootTemplate = fs.readFileSync(
|
|
94
|
+
path.join(__dirname, '../../files', pluginRootTemplateFile),
|
|
95
|
+
'utf-8'
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const requiredWpVersion = await promptVersion(
|
|
99
|
+
`Required WordPress version (default: ${defaultWpVersion}): `,
|
|
100
|
+
defaultWpVersion
|
|
101
|
+
);
|
|
102
|
+
const requiredPhpVersion = await promptVersion(
|
|
103
|
+
`Required PHP version (default: ${defaultPhpVersion}): `,
|
|
104
|
+
defaultPhpVersion
|
|
105
|
+
);
|
|
106
|
+
const requiredBaseVersion =
|
|
107
|
+
pluginType === 'general'
|
|
108
|
+
? await promptVersion(
|
|
109
|
+
`Required IS Base Plugin version (default: ${defaultBaseVersion}): `,
|
|
110
|
+
defaultBaseVersion
|
|
111
|
+
)
|
|
112
|
+
: null;
|
|
113
|
+
|
|
114
|
+
console.log('\n');
|
|
16
115
|
|
|
17
116
|
// ------------------------------------------
|
|
18
|
-
// 1) .gitignore
|
|
117
|
+
// 1) copy .gitignore
|
|
19
118
|
// ------------------------------------------
|
|
20
119
|
copy('gitignore');
|
|
21
120
|
|
|
22
121
|
// ------------------------------------------
|
|
23
|
-
// 2) stylelint config
|
|
122
|
+
// 2) create stylelint config
|
|
24
123
|
// ------------------------------------------
|
|
25
124
|
fs.writeFileSync(
|
|
26
125
|
path.join(root, '.stylelintrc.json'),
|
|
@@ -35,7 +134,7 @@ export function runInit() {
|
|
|
35
134
|
console.log('✓ Created .stylelintrc.json');
|
|
36
135
|
|
|
37
136
|
// ------------------------------------------
|
|
38
|
-
// 3) tsconfig
|
|
137
|
+
// 3) create tsconfig
|
|
39
138
|
// ------------------------------------------
|
|
40
139
|
fs.writeFileSync(
|
|
41
140
|
path.join(root, 'tsconfig.json'),
|
|
@@ -51,7 +150,7 @@ export function runInit() {
|
|
|
51
150
|
console.log('✓ Created tsconfig.json');
|
|
52
151
|
|
|
53
152
|
// ------------------------------------------
|
|
54
|
-
// 4) oxlintrc
|
|
153
|
+
// 4) create oxlintrc
|
|
55
154
|
// ------------------------------------------
|
|
56
155
|
fs.writeFileSync(
|
|
57
156
|
path.join(root, '.oxlintrc.json'),
|
|
@@ -66,7 +165,7 @@ export function runInit() {
|
|
|
66
165
|
console.log('✓ Created .oxlintrc.json');
|
|
67
166
|
|
|
68
167
|
// ------------------------------------------
|
|
69
|
-
// 5) postcss config
|
|
168
|
+
// 5) create postcss config
|
|
70
169
|
// ------------------------------------------
|
|
71
170
|
fs.writeFileSync(
|
|
72
171
|
path.join(root, 'postcss.config.cjs'),
|
|
@@ -75,27 +174,27 @@ export function runInit() {
|
|
|
75
174
|
console.log('✓ Created postcss.config.cjs');
|
|
76
175
|
|
|
77
176
|
// ------------------------------------------
|
|
78
|
-
// 6) vite.config.ts
|
|
177
|
+
// 6) create vite.config.ts
|
|
79
178
|
// ------------------------------------------
|
|
80
179
|
fs.writeFileSync(
|
|
81
180
|
path.join(root, 'vite.config.ts'),
|
|
82
|
-
`
|
|
83
|
-
|
|
84
|
-
export default wpPluginKitVite({
|
|
85
|
-
|
|
86
|
-
});
|
|
87
|
-
`
|
|
181
|
+
`
|
|
182
|
+
import { wpPluginKitVite } from "@iservice-dev/is-wp-plugin-kit/vite";
|
|
183
|
+
export default wpPluginKitVite({
|
|
184
|
+
port: ${vitePort}
|
|
185
|
+
});
|
|
186
|
+
`
|
|
88
187
|
);
|
|
89
188
|
console.log('✓ Created vite.config.ts');
|
|
90
189
|
|
|
91
190
|
// ------------------------------------------
|
|
92
|
-
// 7) package.json
|
|
191
|
+
// 7) create package.json
|
|
93
192
|
// ------------------------------------------
|
|
94
193
|
const pkgPath = path.join(root, 'package.json');
|
|
95
194
|
|
|
96
195
|
if (!fs.existsSync(pkgPath)) {
|
|
97
196
|
const pkg = {
|
|
98
|
-
name:
|
|
197
|
+
name: pluginSlug,
|
|
99
198
|
version: '1.0.0',
|
|
100
199
|
type: 'module',
|
|
101
200
|
description: 'iService WordPress Plugin',
|
|
@@ -116,7 +215,7 @@ export default wpPluginKitVite({
|
|
|
116
215
|
}
|
|
117
216
|
|
|
118
217
|
// ------------------------------------------
|
|
119
|
-
// 8)
|
|
218
|
+
// 8) create folder structure
|
|
120
219
|
// ------------------------------------------
|
|
121
220
|
const dirs = [
|
|
122
221
|
'assets/src/ts',
|
|
@@ -131,7 +230,6 @@ export default wpPluginKitVite({
|
|
|
131
230
|
'includes/lib/Frontend',
|
|
132
231
|
];
|
|
133
232
|
|
|
134
|
-
// Ordner die kein .gitkeep brauchen (bekommen andere Dateien)
|
|
135
233
|
const skipGitkeep = ['assets/src/l10n', 'includes/lib/Core'];
|
|
136
234
|
|
|
137
235
|
dirs.forEach((dir) => {
|
|
@@ -149,17 +247,92 @@ export default wpPluginKitVite({
|
|
|
149
247
|
console.log('✓ Created folder structure with .gitkeep files');
|
|
150
248
|
|
|
151
249
|
// ------------------------------------------
|
|
152
|
-
// 9) de_DE.po
|
|
250
|
+
// 9) copy de_DE.po template
|
|
153
251
|
// ------------------------------------------
|
|
154
252
|
copy('de_DE.po', 'assets/src/l10n/de_DE.po');
|
|
155
253
|
|
|
156
254
|
// ------------------------------------------
|
|
157
|
-
// 10)
|
|
255
|
+
// 10) create GitHub Actions workflow
|
|
256
|
+
// ------------------------------------------
|
|
257
|
+
const workflowDir = path.join(root, '.github/workflows');
|
|
258
|
+
if (!fs.existsSync(workflowDir)) {
|
|
259
|
+
fs.mkdirSync(workflowDir, { recursive: true });
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
const deployYmlTemplate = fs.readFileSync(
|
|
263
|
+
path.join(__dirname, '../../files/deploy.yml'),
|
|
264
|
+
'utf-8'
|
|
265
|
+
);
|
|
266
|
+
|
|
267
|
+
const deployYmlContent = deployYmlTemplate.replace(/\[plugin-placehoder\]/g, pluginSlug);
|
|
268
|
+
|
|
269
|
+
fs.writeFileSync(path.join(workflowDir, 'deploy.yml'), deployYmlContent);
|
|
270
|
+
console.log('✓ Created .github/workflows/deploy.yml');
|
|
271
|
+
|
|
272
|
+
// ------------------------------------------
|
|
273
|
+
// 11) create and customize PHP template files
|
|
158
274
|
// ------------------------------------------
|
|
159
|
-
|
|
160
|
-
|
|
275
|
+
|
|
276
|
+
const pluginRootFile = `${pluginSlug}.php`;
|
|
277
|
+
|
|
278
|
+
const namespaceParts = namespace.split('\\').filter(Boolean);
|
|
279
|
+
const namespaceFirst = namespaceParts[0] || 'IS';
|
|
280
|
+
const namespaceSecond = namespaceParts[1] || 'Plugin';
|
|
281
|
+
|
|
282
|
+
const pluginRootContent = pluginRootTemplate
|
|
283
|
+
.replace(/\[Plugin Name Placeholder\]/g, `${pluginName}`)
|
|
284
|
+
.replace(/\[Plugin Description Placeholder\]/g, `${pluginDescr || '-'}`)
|
|
285
|
+
.replace(/\[text-domain-placeholder\]/g, `${textDomain}`)
|
|
286
|
+
.replace(/plugin_slug_placeholder/g, pluginSlug.replace(/-/g, '_'))
|
|
287
|
+
.replace(/\[NamespacePlaceholder\]/g, namespaceSecond)
|
|
288
|
+
.replace(/\\NamespacePlaceholder\\/g, `\\${namespace}\\`)
|
|
289
|
+
.replace(/define\('PLUGIN_TYPE', 'general'\);/g, `define('PLUGIN_TYPE', '${pluginType}');`)
|
|
290
|
+
.replace(/\[base-version-placeholder\]/g, `${requiredBaseVersion}`)
|
|
291
|
+
.replace(/\[wp-version-placeholder\]/g, `${requiredWpVersion}`)
|
|
292
|
+
.replace(/\[php-version-placeholder\]/g, `${requiredPhpVersion}`);
|
|
293
|
+
|
|
294
|
+
fs.writeFileSync(path.join(root, pluginRootFile), pluginRootContent);
|
|
295
|
+
console.log(`✓ Created ${pluginRootFile}`);
|
|
296
|
+
|
|
297
|
+
if (pluginType === 'general') {
|
|
298
|
+
// Plugin.php
|
|
299
|
+
const pluginPhpTemplate = fs.readFileSync(
|
|
300
|
+
path.join(__dirname, '../../files/Plugin.php'),
|
|
301
|
+
'utf-8'
|
|
302
|
+
);
|
|
303
|
+
|
|
304
|
+
const pluginPhpContent = pluginPhpTemplate
|
|
305
|
+
.replace(/NamespacePlaceholder/g, `${namespace}`)
|
|
306
|
+
.replace(/'\[github-repo-placeholder\]'/g, `'${githubRepo}'`)
|
|
307
|
+
.replace(/'\[plugin-slug-placeholder\]'/g, `'${pluginSlug}'`)
|
|
308
|
+
|
|
309
|
+
fs.writeFileSync(path.join(root, 'includes/lib/Core/Plugin.php'), pluginPhpContent);
|
|
310
|
+
console.log('✓ Created includes/lib/Core/Plugin.php');
|
|
311
|
+
|
|
312
|
+
// Config.php
|
|
313
|
+
const configPhpTemplate = fs.readFileSync(
|
|
314
|
+
path.join(__dirname, '../../files/Config.php'),
|
|
315
|
+
'utf-8'
|
|
316
|
+
);
|
|
317
|
+
|
|
318
|
+
const configPhpContent = configPhpTemplate
|
|
319
|
+
.replace(/NamespacePlaceholder/g, `${namespace}`)
|
|
320
|
+
.replace(/\[plugin-slug-placeholder\]/g, `${pluginSlug}`)
|
|
321
|
+
.replace(/\$this->vitePort = 5500;/g, `$this->vitePort = ${vitePort};`)
|
|
322
|
+
|
|
323
|
+
fs.writeFileSync(path.join(root, 'includes/lib/Core/Config.php'), configPhpContent);
|
|
324
|
+
console.log('✓ Created includes/lib/Core/Config.php');
|
|
325
|
+
} else {
|
|
326
|
+
console.log('↺ Plugin.php and Config.php skipped (standalone plugin - add your own code)');
|
|
327
|
+
}
|
|
161
328
|
|
|
162
329
|
// ------------------------------------------
|
|
163
330
|
console.log('\n🎉 Project initialized successfully!\n');
|
|
331
|
+
console.log(`Plugin: ${pluginName}`);
|
|
332
|
+
console.log(`Type: ${pluginType}`);
|
|
333
|
+
console.log(`Slug: ${pluginSlug}`);
|
|
334
|
+
console.log(`Namespace: ${namespace}`);
|
|
335
|
+
console.log(`Text Domain: ${textDomain}`);
|
|
336
|
+
console.log(`Vite Port: ${vitePort}\n`);
|
|
164
337
|
process.exit(0);
|
|
165
338
|
}
|
package/bin/is-wp-plugin-kit.js
CHANGED
|
File without changes
|
package/files/Config.php
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
<?php
|
|
2
|
-
|
|
3
|
-
namespace IS\Template\Core;
|
|
2
|
+
namespace NamespacePlaceholder\Core;
|
|
4
3
|
|
|
5
4
|
use IS\Base\Core\Abstract_Config;
|
|
6
5
|
|
|
7
6
|
final class Config extends Abstract_Config {
|
|
8
7
|
protected function __construct() {
|
|
9
|
-
|
|
10
|
-
$this->pluginName = "is-template-plugin";
|
|
8
|
+
$this->pluginName = "[plugin-slug-placeholder]";
|
|
11
9
|
$this->customPrefix = "iS_";
|
|
12
10
|
$this->vitePort = 5500;
|
|
13
11
|
|
package/files/Plugin.php
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
<?php
|
|
2
|
-
|
|
3
|
-
namespace IS\Template\Core;
|
|
2
|
+
namespace NamespacePlaceholder\Core;
|
|
4
3
|
|
|
5
4
|
use IS\Base\Core\Updater;
|
|
6
5
|
use IS\Base\Core\Auto_Instantiate;
|
|
@@ -20,15 +19,14 @@ class Plugin {
|
|
|
20
19
|
);
|
|
21
20
|
}
|
|
22
21
|
|
|
23
|
-
//TODO change github repo link and plugin slug
|
|
24
22
|
$updater = new Updater(
|
|
25
|
-
'
|
|
23
|
+
'[github-repo-placeholder]',
|
|
26
24
|
$file,
|
|
27
|
-
'
|
|
25
|
+
'[plugin-slug-placeholder]'
|
|
28
26
|
);
|
|
29
27
|
$updater->init();
|
|
30
28
|
|
|
31
|
-
//TODO only needed if classes in Admin or Frontend folder
|
|
29
|
+
//TODO: Check if needed - only needed if classes in Admin or Frontend folder
|
|
32
30
|
Auto_Instantiate::instantiate_classes_static(self::$config, 'Admin');
|
|
33
31
|
Auto_Instantiate::instantiate_classes_static(self::$config, 'Frontend');
|
|
34
32
|
}
|
package/files/deploy.yml
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
name: Build & Release WordPress Plugin
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- name: Checkout
|
|
14
|
+
uses: actions/checkout@v4
|
|
15
|
+
with:
|
|
16
|
+
fetch-depth: 0
|
|
17
|
+
fetch-tags: true
|
|
18
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
19
|
+
|
|
20
|
+
- name: Setup Node.js
|
|
21
|
+
uses: actions/setup-node@v4
|
|
22
|
+
with:
|
|
23
|
+
node-version: "20"
|
|
24
|
+
cache: "npm"
|
|
25
|
+
|
|
26
|
+
- name: Install Node dependencies
|
|
27
|
+
run: npm ci
|
|
28
|
+
|
|
29
|
+
- name: Build assets
|
|
30
|
+
run: npm run build
|
|
31
|
+
|
|
32
|
+
- name: Check for composer.json
|
|
33
|
+
id: check_composer
|
|
34
|
+
run: |
|
|
35
|
+
if [ -f "composer.json" ]; then
|
|
36
|
+
echo "exists=true" >> $GITHUB_OUTPUT
|
|
37
|
+
else
|
|
38
|
+
echo "exists=false" >> $GITHUB_OUTPUT
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
- name: Composer
|
|
42
|
+
if: steps.check_composer.outputs.exists == 'true'
|
|
43
|
+
uses: php-actions/composer@v6
|
|
44
|
+
with:
|
|
45
|
+
php_version: "8.2"
|
|
46
|
+
args: --no-dev --prefer-dist --optimize-autoloader
|
|
47
|
+
|
|
48
|
+
- name: Determine new version
|
|
49
|
+
id: version
|
|
50
|
+
run: |
|
|
51
|
+
COMMIT_MSG=$(git log -1 --pretty=%B)
|
|
52
|
+
|
|
53
|
+
if [[ $COMMIT_MSG == *"[skip release]"* ]]; then
|
|
54
|
+
echo "skip=true" >> $GITHUB_OUTPUT
|
|
55
|
+
echo "Skipping release due to [skip release] in commit message"
|
|
56
|
+
exit 0
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
|
|
60
|
+
LATEST_VERSION=${LATEST_TAG#v}
|
|
61
|
+
|
|
62
|
+
echo "Latest version: $LATEST_VERSION"
|
|
63
|
+
echo "Commit message: $COMMIT_MSG"
|
|
64
|
+
|
|
65
|
+
IFS='.' read -r -a VERSION_PARTS <<< "$LATEST_VERSION"
|
|
66
|
+
MAJOR=${VERSION_PARTS[0]:-0}
|
|
67
|
+
MINOR=${VERSION_PARTS[1]:-0}
|
|
68
|
+
PATCH=${VERSION_PARTS[2]:-0}
|
|
69
|
+
|
|
70
|
+
if [[ $COMMIT_MSG == *"[major]"* ]]; then
|
|
71
|
+
NEW_VERSION="$((MAJOR + 1)).0.0"
|
|
72
|
+
BUMP_TYPE="major"
|
|
73
|
+
elif [[ $COMMIT_MSG == *"[minor]"* ]]; then
|
|
74
|
+
NEW_VERSION="$MAJOR.$((MINOR + 1)).0"
|
|
75
|
+
BUMP_TYPE="minor"
|
|
76
|
+
else
|
|
77
|
+
NEW_VERSION="$MAJOR.$MINOR.$((PATCH + 1))"
|
|
78
|
+
BUMP_TYPE="patch"
|
|
79
|
+
fi
|
|
80
|
+
|
|
81
|
+
NEW_TAG="v$NEW_VERSION"
|
|
82
|
+
|
|
83
|
+
echo "Version bump: $LATEST_VERSION → $NEW_VERSION ($BUMP_TYPE)"
|
|
84
|
+
|
|
85
|
+
if git rev-parse "$NEW_TAG" >/dev/null 2>&1; then
|
|
86
|
+
echo "Error: Tag $NEW_TAG already exists!"
|
|
87
|
+
exit 1
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
echo "skip=false" >> $GITHUB_OUTPUT
|
|
91
|
+
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
|
|
92
|
+
echo "tag=$NEW_TAG" >> $GITHUB_OUTPUT
|
|
93
|
+
echo "bump_type=$BUMP_TYPE" >> $GITHUB_OUTPUT
|
|
94
|
+
|
|
95
|
+
- name: Update plugin version and commit
|
|
96
|
+
if: steps.version.outputs.skip == 'false'
|
|
97
|
+
run: |
|
|
98
|
+
NEW_VERSION="${{ steps.version.outputs.version }}"
|
|
99
|
+
sed -i "s/Version: .*/Version: $NEW_VERSION/" [plugin-placehoder].php
|
|
100
|
+
echo "Updated plugin version to $NEW_VERSION"
|
|
101
|
+
|
|
102
|
+
git config user.name "github-actions[bot]"
|
|
103
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
104
|
+
|
|
105
|
+
git add [plugin-placehoder].php
|
|
106
|
+
git commit -m "Bump version to $NEW_VERSION [skip ci]" || echo "No changes to commit"
|
|
107
|
+
git push origin HEAD:main
|
|
108
|
+
|
|
109
|
+
- name: Create and push tag
|
|
110
|
+
if: steps.version.outputs.skip == 'false'
|
|
111
|
+
run: |
|
|
112
|
+
git tag -a "${{ steps.version.outputs.tag }}" -m "Release ${{ steps.version.outputs.version }} (${{ steps.version.outputs.bump_type }})"
|
|
113
|
+
git push origin "${{ steps.version.outputs.tag }}"
|
|
114
|
+
|
|
115
|
+
- name: Prepare package
|
|
116
|
+
if: steps.version.outputs.skip == 'false'
|
|
117
|
+
run: |
|
|
118
|
+
mkdir -p package/[plugin-placehoder]
|
|
119
|
+
cp [plugin-placehoder].php package/[plugin-placehoder]/
|
|
120
|
+
cp -r includes package/[plugin-placehoder]/ || true
|
|
121
|
+
mkdir -p package/[plugin-placehoder]/assets
|
|
122
|
+
cp -r assets/dist package/[plugin-placehoder]/assets/ || true
|
|
123
|
+
|
|
124
|
+
# Only copy vendor directory if it exists
|
|
125
|
+
if [ -d "vendor" ]; then
|
|
126
|
+
cp -r vendor package/[plugin-placehoder]/
|
|
127
|
+
fi
|
|
128
|
+
|
|
129
|
+
- name: Create plugin zip
|
|
130
|
+
if: steps.version.outputs.skip == 'false'
|
|
131
|
+
run: |
|
|
132
|
+
cd package
|
|
133
|
+
zip -r [plugin-placehoder]-${{ steps.version.outputs.version }}.zip [plugin-placehoder]
|
|
134
|
+
|
|
135
|
+
- name: Create GitHub Release
|
|
136
|
+
if: steps.version.outputs.skip == 'false'
|
|
137
|
+
uses: softprops/action-gh-release@v2
|
|
138
|
+
with:
|
|
139
|
+
tag_name: ${{ steps.version.outputs.tag }}
|
|
140
|
+
name: "${{ steps.version.outputs.version }}"
|
|
141
|
+
files: package/[plugin-placehoder]-${{ steps.version.outputs.version }}.zip
|
|
142
|
+
generate_release_notes: true
|
|
143
|
+
make_latest: true
|
|
144
|
+
env:
|
|
145
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
146
|
+
|
|
147
|
+
- name: Success message
|
|
148
|
+
if: steps.version.outputs.skip == 'false'
|
|
149
|
+
run: |
|
|
150
|
+
echo "✅ Successfully released version ${{ steps.version.outputs.version }}"
|
|
151
|
+
echo "📦 Plugin zip: [plugin-placehoder]-${{ steps.version.outputs.version }}.zip"
|
|
152
|
+
echo "🏷️ Tag: ${{ steps.version.outputs.tag }}"
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Plugin Name: [Plugin Name Placeholder]
|
|
4
|
+
* Description: [Plugin Description Placeholder]
|
|
5
|
+
* Version: 0.0.1
|
|
6
|
+
* Author: iService
|
|
7
|
+
* Requires at least: [wp-version-placeholder]
|
|
8
|
+
* Requires PHP: [php-version-placeholder]
|
|
9
|
+
* Author URI: https://iservice.at
|
|
10
|
+
* Text Domain: [text-domain-placeholder]
|
|
11
|
+
* Domain Path: /languages
|
|
12
|
+
* Update URI: false
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
if (!defined('ABSPATH'))
|
|
16
|
+
exit;
|
|
17
|
+
|
|
18
|
+
const REQUIRED_WP_VERSION = '[wp-version-placeholder]';
|
|
19
|
+
const REQUIRED_PHP_VERSION = '[php-version-placeholder]';
|
|
20
|
+
|
|
21
|
+
// WordPress version check
|
|
22
|
+
global $wp_version;
|
|
23
|
+
if (version_compare($wp_version, REQUIRED_WP_VERSION, '<')) {
|
|
24
|
+
add_action('admin_notices', function () {
|
|
25
|
+
echo '<div class="notice notice-error"><p>';
|
|
26
|
+
printf(
|
|
27
|
+
esc_html__(
|
|
28
|
+
'%1$s requires WordPress version %2$s or higher. Please update WordPress.',
|
|
29
|
+
'[text-domain-placeholder]'
|
|
30
|
+
),
|
|
31
|
+
esc_html('[Plugin Name Placeholder]'),
|
|
32
|
+
esc_html(REQUIRED_WP_VERSION)
|
|
33
|
+
);
|
|
34
|
+
echo '</p></div>';
|
|
35
|
+
});
|
|
36
|
+
add_action('admin_init', function () {
|
|
37
|
+
deactivate_plugins(plugin_basename(__FILE__));
|
|
38
|
+
});
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// PHP version check
|
|
43
|
+
if (version_compare(PHP_VERSION, REQUIRED_PHP_VERSION, '<')) {
|
|
44
|
+
add_action('admin_notices', function () {
|
|
45
|
+
echo '<div class="notice notice-error"><p>';
|
|
46
|
+
printf(
|
|
47
|
+
esc_html__(
|
|
48
|
+
'%1$s requires PHP version %2$s or higher. You are running PHP %3$s.',
|
|
49
|
+
'[text-domain-placeholder]'
|
|
50
|
+
),
|
|
51
|
+
esc_html('[Plugin Name Placeholder]'),
|
|
52
|
+
esc_html(REQUIRED_PHP_VERSION),
|
|
53
|
+
esc_html(PHP_VERSION)
|
|
54
|
+
);
|
|
55
|
+
echo '</p></div>';
|
|
56
|
+
});
|
|
57
|
+
add_action('admin_init', function () {
|
|
58
|
+
deactivate_plugins(plugin_basename(__FILE__));
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Plugin Name: [Plugin Name Placeholder]
|
|
4
|
+
* Description: [Plugin Description Placeholder]
|
|
5
|
+
* Version: 0.0.1
|
|
6
|
+
* Author: iService
|
|
7
|
+
* Requires at least: [wp-version-placeholder]
|
|
8
|
+
* Requires PHP: [php-version-placeholder]
|
|
9
|
+
* Author URI: https://iservice.at
|
|
10
|
+
* Text Domain: [text-domain-placeholder]
|
|
11
|
+
* Domain Path: /languages
|
|
12
|
+
* Update URI: false
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
if (!defined('ABSPATH'))
|
|
16
|
+
exit;
|
|
17
|
+
|
|
18
|
+
define('PLUGIN_TYPE', 'general');
|
|
19
|
+
|
|
20
|
+
const REQUIRED_BASE_VERSION = '[base-version-placeholder]';
|
|
21
|
+
// Note: These values should match the plugin header above
|
|
22
|
+
const REQUIRED_WP_VERSION = '[wp-version-placeholder]';
|
|
23
|
+
const REQUIRED_PHP_VERSION = '[php-version-placeholder]';
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
function plugin_slug_placeholder_bootstrap() {
|
|
27
|
+
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
|
|
28
|
+
require __DIR__ . '/vendor/autoload.php';
|
|
29
|
+
}
|
|
30
|
+
require_once plugin_dir_path(__FILE__) . 'includes/autoloader.php';
|
|
31
|
+
new \IS\Autoloader(
|
|
32
|
+
'[NamespacePlaceholder]',
|
|
33
|
+
plugin_dir_path(__FILE__) . 'includes/lib'
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
\NamespacePlaceholder\Core\Plugin::boot(__FILE__);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
add_action('plugins_loaded', function () {
|
|
40
|
+
|
|
41
|
+
if (!did_action('is/base/loaded')) {
|
|
42
|
+
add_action('admin_notices', function () {
|
|
43
|
+
echo '<div class="notice notice-error"><p>';
|
|
44
|
+
printf(
|
|
45
|
+
esc_html__(
|
|
46
|
+
'%s requires IS Base Plugin to be installed and activated.',
|
|
47
|
+
'[text-domain-placeholder]'
|
|
48
|
+
),
|
|
49
|
+
esc_html('[Plugin Name Placeholder]')
|
|
50
|
+
);
|
|
51
|
+
echo '</p></div>';
|
|
52
|
+
});
|
|
53
|
+
add_action('admin_init', function () {
|
|
54
|
+
deactivate_plugins(plugin_basename(__FILE__));
|
|
55
|
+
});
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (!\IS\Base\Core\Plugin_Requirements::check_base_version(
|
|
60
|
+
REQUIRED_BASE_VERSION,
|
|
61
|
+
'[Plugin Name Placeholder]',
|
|
62
|
+
__FILE__
|
|
63
|
+
)) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if(!IS\Base\Core\Plugin_Requirements::check(
|
|
68
|
+
'[Plugin Name Placeholder]',
|
|
69
|
+
REQUIRED_WP_VERSION,
|
|
70
|
+
REQUIRED_PHP_VERSION,
|
|
71
|
+
__FILE__
|
|
72
|
+
)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
plugin_slug_placeholder_bootstrap();
|
|
77
|
+
}, 20);
|
|
78
|
+
|
package/package.json
CHANGED