@airfleet/generator-init 0.5.1 → 0.9.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/generators/npm/templates/.gitattributes +1 -0
- package/generators/npm/templates/package.json.ejs +0 -1
- package/generators/plugin/index.js +15 -5
- package/generators/plugin/templates/.env +0 -0
- package/generators/plugin/templates/.gitattributes +1 -0
- package/generators/plugin/templates/.gitlab-ci.yml +7 -2
- package/generators/plugin/templates/.husky/pre-commit +4 -0
- package/generators/plugin/templates/.parcelrc +4 -0
- package/generators/plugin/templates/.prettierignore +12 -0
- package/generators/plugin/templates/.vscode/settings.json +10 -0
- package/generators/plugin/templates/acf-json/.gitkeep +0 -0
- package/generators/plugin/templates/assets/admin/scripts/admin.entry.js +1 -0
- package/generators/plugin/templates/assets/admin/styles/admin.scss +0 -0
- package/generators/plugin/templates/assets/frontend/fonts/.gitkeep +0 -0
- package/generators/plugin/templates/assets/frontend/images/.gitkeep +0 -0
- package/generators/plugin/templates/assets/frontend/scripts/index.entry.js +5 -0
- package/generators/plugin/templates/assets/frontend/styles/index.scss +0 -0
- package/generators/plugin/templates/composer.json.ejs +28 -9
- package/generators/plugin/templates/gitignore +7 -0
- package/generators/plugin/templates/inc/Setup.php.ejs +60 -0
- package/generators/plugin/templates/package.json.ejs +54 -3
- package/generators/plugin/templates/phpcs.xml.ejs +33 -0
- package/generators/plugin/templates/plugin-name.php.ejs +5 -3
- package/package.json +1 -1
- package/utils/nameCases.js +4 -1
- package/generators/plugin/templates/src/Plugin.php.ejs +0 -45
|
@@ -109,15 +109,30 @@ export default class extends Generator {
|
|
|
109
109
|
|
|
110
110
|
writing() {
|
|
111
111
|
const files = [
|
|
112
|
+
".husky/.gitignore",
|
|
113
|
+
".husky/pre-commit",
|
|
114
|
+
".vscode/settings.json",
|
|
115
|
+
"acf-json/.gitkeep",
|
|
116
|
+
"assets/admin/scripts/admin.entry.js",
|
|
117
|
+
"assets/admin/styles/admin.scss",
|
|
118
|
+
"assets/frontend/fonts/.gitkeep",
|
|
119
|
+
"assets/frontend/images/.gitkeep",
|
|
120
|
+
"assets/frontend/scripts/index.entry.js",
|
|
121
|
+
"assets/frontend/styles/index.scss",
|
|
122
|
+
"inc/Setup.php.ejs",
|
|
112
123
|
".airfleet-release",
|
|
113
124
|
".editorconfig",
|
|
125
|
+
".env",
|
|
114
126
|
".gitattributes",
|
|
115
127
|
".gitlab-ci.yml",
|
|
128
|
+
".parcelrc",
|
|
129
|
+
".prettierignore",
|
|
116
130
|
"CHANGELOG.md",
|
|
117
131
|
"composer.json.ejs",
|
|
118
132
|
"index.php",
|
|
119
133
|
"LICENSE.ejs",
|
|
120
134
|
"package.json.ejs",
|
|
135
|
+
"phpcs.xml.ejs",
|
|
121
136
|
"README.md.ejs",
|
|
122
137
|
];
|
|
123
138
|
const templates = [
|
|
@@ -132,11 +147,6 @@ export default class extends Generator {
|
|
|
132
147
|
destination: `${this.name.slug}.php`,
|
|
133
148
|
isEnabled: true,
|
|
134
149
|
},
|
|
135
|
-
{
|
|
136
|
-
template: "src/Plugin.php.ejs",
|
|
137
|
-
destination: `src/${this.nameNoAirfleet.pascal}.php`,
|
|
138
|
-
isEnabled: true,
|
|
139
|
-
},
|
|
140
150
|
];
|
|
141
151
|
|
|
142
152
|
copyTemplates(this, templates, this.data);
|
|
File without changes
|
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
stages:
|
|
2
|
+
- test
|
|
2
3
|
- release
|
|
3
4
|
|
|
4
5
|
include:
|
|
6
|
+
# Test
|
|
7
|
+
- project: "codersclan/tools/gitlab-ci-templates"
|
|
8
|
+
ref: main
|
|
9
|
+
file: "/test/wordpress.yaml"
|
|
5
10
|
# Release process
|
|
6
|
-
- project:
|
|
11
|
+
- project: "codersclan/tools/gitlab-ci-templates"
|
|
7
12
|
ref: main
|
|
8
|
-
file:
|
|
13
|
+
file: "/release/wp-plugin.yaml"
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "../styles/admin.scss";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -2,18 +2,37 @@
|
|
|
2
2
|
"name": "airfleet/<%= name.slug %>",
|
|
3
3
|
"type": "wordpress-plugin",
|
|
4
4
|
"authors": [
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
{
|
|
6
|
+
"name": "Airfleet",
|
|
7
|
+
"email": "dev@airfleet.co"
|
|
8
|
+
}
|
|
9
9
|
],
|
|
10
10
|
"require": {
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
"php": "<%- answers.pluginPhpVersion %>",
|
|
12
|
+
"composer/installers": "^2.0"
|
|
13
|
+
},
|
|
14
|
+
"require-dev": {
|
|
15
|
+
"airfleet/wordpress-dev": "^2.0"
|
|
13
16
|
},
|
|
14
17
|
"autoload": {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
"psr-4": {
|
|
19
|
+
"Airfleet\\Plugins\\<%= nameNoAirfleet.pascal %>\\": "inc/"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"lint": "phpcs",
|
|
24
|
+
"fix": "phpcbf",
|
|
25
|
+
"install-codestandards": [
|
|
26
|
+
"Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run"
|
|
27
|
+
],
|
|
28
|
+
"post-install-cmd": [
|
|
29
|
+
"@install-codestandards"
|
|
30
|
+
]
|
|
31
|
+
},
|
|
32
|
+
"config": {
|
|
33
|
+
"allow-plugins": {
|
|
34
|
+
"composer/installers": true,
|
|
35
|
+
"dealerdirect/phpcodesniffer-composer-installer": true
|
|
36
|
+
}
|
|
18
37
|
}
|
|
19
38
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Airfleet\Plugins\<%= nameNoAirfleet.pascal %>;
|
|
4
|
+
|
|
5
|
+
class Setup {
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Setup the plugin.
|
|
9
|
+
*
|
|
10
|
+
* @return void
|
|
11
|
+
*/
|
|
12
|
+
public function initialize(): void {
|
|
13
|
+
$this->show_admin_notice_if_missing_framework();
|
|
14
|
+
add_action(
|
|
15
|
+
'airfleet/init',
|
|
16
|
+
function () {
|
|
17
|
+
$plugin = new \Airfleet\Plugin(
|
|
18
|
+
[
|
|
19
|
+
'slug' => '<%= name.slug %>',
|
|
20
|
+
'title' => '<%= name.title %>',
|
|
21
|
+
'short_title' => '<%= nameNoAirfleet.title %>',
|
|
22
|
+
'url' => \<%= name.constant %>_URL,
|
|
23
|
+
'path' => \<%= name.constant %>_PATH,
|
|
24
|
+
'version' => \<%= name.constant %>_VERSION,
|
|
25
|
+
]
|
|
26
|
+
);
|
|
27
|
+
$plugin->setup_acf_json();
|
|
28
|
+
$plugin->enqueue();
|
|
29
|
+
$plugin->enqueue_admin();
|
|
30
|
+
<%_ if (answers.pluginCreateOptions) { _%>
|
|
31
|
+
$plugin->add_options_page();
|
|
32
|
+
<%_ } _%>
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Show and admin notification if the Airfleet Framework plugin is not enabled.
|
|
39
|
+
*
|
|
40
|
+
* @return void
|
|
41
|
+
*/
|
|
42
|
+
public function show_admin_notice_if_missing_framework(): void {
|
|
43
|
+
add_action(
|
|
44
|
+
'admin_notices',
|
|
45
|
+
function () {
|
|
46
|
+
global $airfleet_framework_missing_notice;
|
|
47
|
+
|
|
48
|
+
if ( $airfleet_framework_missing_notice || defined( 'AIRFLEET_FRAMEWORK_VERSION' ) ) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
$airfleet_framework_missing_notice = true;
|
|
52
|
+
?>
|
|
53
|
+
<div class="notice notice-error">
|
|
54
|
+
<p>Please install the Airfleet Framework to enable the Airfleet plugins.</p>
|
|
55
|
+
</div>
|
|
56
|
+
<?php
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -3,7 +3,25 @@
|
|
|
3
3
|
"description": "<%= answers.pluginDescription %>",
|
|
4
4
|
"version": "<%= answers.pluginVersion %>",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "
|
|
6
|
+
"build": "dotenv -- parcel build --log-level verbose ./assets/**/*.entry.js",
|
|
7
|
+
"start": "dotenv -- parcel serve --hmr-port 1236 --port 1234 --log-level verbose ./assets/**/*.entry.js",
|
|
8
|
+
"base:eslint": "eslint assets --ext .js,.jsx --cache --ignore-path .gitignore",
|
|
9
|
+
"base:prettier": "prettier \"**/*.{js,jsx,ts,tsx,json,css,scss,xml,yaml,yml,md}\"",
|
|
10
|
+
"base:stylelint": "stylelint \"**/*.{css,scss}\" --cache --ignore-path .gitignore",
|
|
11
|
+
"lint": "run-s --continue-on-error lint:*",
|
|
12
|
+
"lint:prettier": "npm run base:prettier -- --check",
|
|
13
|
+
"lint:eslint": "npm run base:eslint",
|
|
14
|
+
"lint:stylelint": "npm run base:stylelint",
|
|
15
|
+
"lint:phpcs": "composer run lint",
|
|
16
|
+
"fix": "run-s fix:*",
|
|
17
|
+
"fix:prettier": "npm run base:prettier -- --write",
|
|
18
|
+
"fix:eslint": "npm run base:eslint -- --fix",
|
|
19
|
+
"fix:stylelint": "npm run base:stylelint -- --fix",
|
|
20
|
+
"fix:phpcs": "composer run fix",
|
|
21
|
+
"pretest": "npm run lint",
|
|
22
|
+
"test": "echo Testing done",
|
|
23
|
+
"prepare": "husky install",
|
|
24
|
+
"cz": "git-cz"
|
|
7
25
|
},
|
|
8
26
|
"private": true,
|
|
9
27
|
"keywords": [
|
|
@@ -19,9 +37,42 @@
|
|
|
19
37
|
"type": "git",
|
|
20
38
|
"url": "<%= answers.pluginRepository %>"
|
|
21
39
|
},
|
|
22
|
-
"type": "module",
|
|
23
40
|
"engines": {
|
|
24
41
|
"node": "<%- answers.pluginNodeVersion %>"
|
|
25
42
|
},
|
|
26
|
-
"dependencies": {}
|
|
43
|
+
"dependencies": {},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@airfleet/wordpress-dev": "^0.3.1"
|
|
46
|
+
},
|
|
47
|
+
"browserslist": [
|
|
48
|
+
"defaults",
|
|
49
|
+
"not IE 11",
|
|
50
|
+
"not op_mini all"
|
|
51
|
+
],
|
|
52
|
+
"prettier": "@airfleet/prettier-config-wordpress",
|
|
53
|
+
"stylelint": {
|
|
54
|
+
"extends": [
|
|
55
|
+
"@airfleet/stylelint-config-wordpress"
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
"eslintConfig": {
|
|
59
|
+
"extends": [
|
|
60
|
+
"@airfleet/eslint-config-wordpress",
|
|
61
|
+
"plugin:no-jquery/all"
|
|
62
|
+
]
|
|
63
|
+
},
|
|
64
|
+
"lint-staged": {
|
|
65
|
+
"*.{js,jsx,ts,tsx,json,css,scss,xml,yaml,yml,md}": "prettier --write",
|
|
66
|
+
"*.{js,jsx}": "eslint --cache --ignore-path .gitignore --fix",
|
|
67
|
+
"*.{css,scss}": "stylelint --cache --ignore-path .gitignore --fix",
|
|
68
|
+
"*.php": [
|
|
69
|
+
"composer run fix",
|
|
70
|
+
"composer run lint"
|
|
71
|
+
]
|
|
72
|
+
},
|
|
73
|
+
"config": {
|
|
74
|
+
"commitizen": {
|
|
75
|
+
"path": "./node_modules/cz-conventional-changelog"
|
|
76
|
+
}
|
|
77
|
+
}
|
|
27
78
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<?xml version="1.0" ?>
|
|
2
|
+
<ruleset
|
|
3
|
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
|
4
|
+
xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/squizlabs/PHP_CodeSniffer/master/phpcs.xsd"
|
|
5
|
+
>
|
|
6
|
+
|
|
7
|
+
<!--
|
|
8
|
+
#############################################################################
|
|
9
|
+
COMMAND LINE ARGUMENTS
|
|
10
|
+
https://github.com/squizlabs/PHP_CodeSniffer/wiki/Annotated-ruleset.xml
|
|
11
|
+
#############################################################################
|
|
12
|
+
-->
|
|
13
|
+
|
|
14
|
+
<!-- Set cache file -->
|
|
15
|
+
<arg name="cache" value=".phpcscache" />
|
|
16
|
+
|
|
17
|
+
<!-- Check all files in this directory and the directories below it. -->
|
|
18
|
+
<file>.</file>
|
|
19
|
+
|
|
20
|
+
<!-- Airfleet config -->
|
|
21
|
+
<rule ref="Airfleet" />
|
|
22
|
+
|
|
23
|
+
<!-- Custom i18n text domain -->
|
|
24
|
+
<rule ref="WordPress.WP.I18n">
|
|
25
|
+
<properties>
|
|
26
|
+
<property name="text_domain" type="array">
|
|
27
|
+
<element value="airfleet" />
|
|
28
|
+
<element value="<%= name.slug %>" />
|
|
29
|
+
</property>
|
|
30
|
+
</properties>
|
|
31
|
+
</rule>
|
|
32
|
+
|
|
33
|
+
</ruleset>
|
|
@@ -23,18 +23,20 @@
|
|
|
23
23
|
|
|
24
24
|
// Exit if accessed directly.
|
|
25
25
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
26
|
-
|
|
26
|
+
die;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// Plugin version.
|
|
30
30
|
define( '<%= name.constant %>_VERSION', '<%= answers.pluginVersion %>' );
|
|
31
|
+
define( '<%= name.constant %>_PATH', plugin_dir_path( __FILE__ ) );
|
|
32
|
+
define( '<%= name.constant %>_URL', plugin_dir_url( __FILE__ ) );
|
|
31
33
|
|
|
32
34
|
// Autoload classes.
|
|
33
35
|
require_once __DIR__ . '/vendor/autoload.php';
|
|
34
36
|
|
|
35
37
|
// Initialize plugin.
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
$<%= name.snake %> = new \Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Setup();
|
|
39
|
+
$<%= name.snake %>->initialize();
|
|
38
40
|
|
|
39
41
|
/**
|
|
40
42
|
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
package/package.json
CHANGED
package/utils/nameCases.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { camelCase, constantCase, noCase, paramCase, pascalCase } from "change-case";
|
|
1
|
+
import { camelCase, constantCase, noCase, paramCase, pascalCase, snakeCase } from "change-case";
|
|
2
2
|
import { titleCase } from "title-case";
|
|
3
3
|
|
|
4
4
|
export default function nameCases(name) {
|
|
@@ -24,6 +24,9 @@ export default function nameCases(name) {
|
|
|
24
24
|
// "TEST_STRING"
|
|
25
25
|
constant: constantCase(name),
|
|
26
26
|
|
|
27
|
+
// "test_string"
|
|
28
|
+
snake: snakeCase(name),
|
|
29
|
+
|
|
27
30
|
// For more utilities see https://github.com/blakeembrey/change-case
|
|
28
31
|
};
|
|
29
32
|
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
|
|
3
|
-
namespace Airfleet\Plugins;
|
|
4
|
-
|
|
5
|
-
class <%= nameNoAirfleet.pascal %>
|
|
6
|
-
{
|
|
7
|
-
/**
|
|
8
|
-
* Setup the plugin.
|
|
9
|
-
*
|
|
10
|
-
* @return void
|
|
11
|
-
*/
|
|
12
|
-
public function initialize()
|
|
13
|
-
{
|
|
14
|
-
<%_ if (answers.pluginCreateOptions) { _%>
|
|
15
|
-
add_action( 'acf/init', array( $this,'add_option_pages' ) );
|
|
16
|
-
<%_ } _%>
|
|
17
|
-
}
|
|
18
|
-
<%_ if (answers.pluginCreateOptions) {%>
|
|
19
|
-
/**
|
|
20
|
-
* Add theme options pages.
|
|
21
|
-
*
|
|
22
|
-
* @return void
|
|
23
|
-
*/
|
|
24
|
-
public function add_option_pages()
|
|
25
|
-
{
|
|
26
|
-
if ( ! function_exists( 'acf_add_options_page' ) ) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
acf_add_options_page(
|
|
30
|
-
array(
|
|
31
|
-
'page_title' => __( 'Airfleet Theme Settings', 'airfleet' ),
|
|
32
|
-
'menu_title' => __( 'Airfleet', 'airfleet' ),
|
|
33
|
-
'menu_slug' => 'airfleet-settings',
|
|
34
|
-
)
|
|
35
|
-
);
|
|
36
|
-
acf_add_options_sub_page(
|
|
37
|
-
array(
|
|
38
|
-
'page_title' => __( '<%= name.title %> Settings', '<%= name.slug %>' ),
|
|
39
|
-
'menu_title' => __( '<%= nameNoAirfleet.title %>', '<%= name.slug %>' ),
|
|
40
|
-
'parent_slug' => 'airfleet-settings',
|
|
41
|
-
)
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
<% } _%>
|
|
45
|
-
}
|