@airfleet/generator-init 0.15.3 → 0.17.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 +1 -1
- package/generators/plugin/index.js +63 -7
- package/generators/plugin/templates/.github/workflows/create-asana-attachment.yaml +19 -0
- package/generators/plugin/templates/.github/workflows/release-plugin.yml +185 -0
- package/generators/plugin/templates/.github/workflows/test-wordpress.yml +56 -0
- package/generators/plugin/templates/.prettierignore +3 -0
- package/generators/plugin/templates/.vscode/settings.json +25 -2
- package/generators/plugin/templates/README.md.ejs +2 -1
- package/generators/plugin/templates/composer-scoped.json.ejs +5 -0
- package/generators/plugin/templates/composer-scoped.lock.ejs +56 -0
- package/generators/plugin/templates/composer.json.ejs +17 -3
- package/generators/plugin/templates/gitignore +2 -0
- package/generators/plugin/templates/inc/AjaxVariables.php.ejs +22 -0
- package/generators/plugin/templates/inc/AjaxVariablesAdmin.php.ejs +22 -0
- package/generators/plugin/templates/inc/Options/GeneralOptions.php.ejs +43 -0
- package/generators/plugin/templates/inc/Options.php.ejs +17 -0
- package/generators/plugin/templates/inc/Pages.php.ejs +35 -0
- package/generators/plugin/templates/inc/Setup.php.ejs +36 -65
- package/generators/plugin/templates/package.json.ejs +18 -16
- package/generators/plugin/templates/plugin-name.php.ejs +22 -2
- package/generators/plugin/templates/scoper.custom.php.ejs +8 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Airfleet Generator
|
|
2
2
|
|
|
3
|
-

|
|
3
|
+
[](https://www.npmjs.com/package/@airfleet/generator-init)
|
|
4
4
|
[](https://github.com/airfleet/airfleet-generator-cli/actions/workflows/release-npm.yml)
|
|
5
5
|
|
|
6
6
|
A Yeoman generator to scaffold common Airfleet features.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import Generator from "yeoman-generator";
|
|
3
|
+
import { paramCase } from "change-case";
|
|
3
4
|
|
|
4
5
|
import nameCases from "../../utils/nameCases.js";
|
|
5
6
|
import copyTemplates from "../../utils/copyTemplates.js";
|
|
@@ -58,12 +59,6 @@ export default class extends Generator {
|
|
|
58
59
|
message: "What's the documentation URL? (Notion page)",
|
|
59
60
|
validate: requiredText("Please enter the documentation URL"),
|
|
60
61
|
},
|
|
61
|
-
{
|
|
62
|
-
type: "confirm",
|
|
63
|
-
name: "pluginCreateOptions",
|
|
64
|
-
message: "Create theme options page?",
|
|
65
|
-
default: true,
|
|
66
|
-
},
|
|
67
62
|
{
|
|
68
63
|
type: "input",
|
|
69
64
|
name: "pluginVersion",
|
|
@@ -85,10 +80,35 @@ export default class extends Generator {
|
|
|
85
80
|
validate: requiredText("Please enter the Node version"),
|
|
86
81
|
default: ">=16",
|
|
87
82
|
},
|
|
83
|
+
{
|
|
84
|
+
type: "list",
|
|
85
|
+
name: "pluginCreateOptions",
|
|
86
|
+
message: "Create options page?",
|
|
87
|
+
choices: ["No", "Framework", "ACF"],
|
|
88
|
+
default: "Framework",
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
type: "confirm",
|
|
92
|
+
name: "pluginAcfLocalJson",
|
|
93
|
+
message: "Add ACF Local JSON?",
|
|
94
|
+
default: false,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
type: "list",
|
|
98
|
+
name: "pluginAjaxVariables",
|
|
99
|
+
message: "Add AJAX variables?",
|
|
100
|
+
choices: ["No", "Frontend", "Admin", "Both"],
|
|
101
|
+
default: "No",
|
|
102
|
+
},
|
|
88
103
|
];
|
|
89
104
|
|
|
90
105
|
this.answers = await this.prompt(prompts);
|
|
91
106
|
this.name = nameCases(this.answers.pluginName);
|
|
107
|
+
this.ajaxVariables = {
|
|
108
|
+
frontend: this.answers.pluginAjaxVariables === 'Both' || this.answers.pluginAjaxVariables === 'Frontend',
|
|
109
|
+
admin: this.answers.pluginAjaxVariables === 'Both' || this.answers.pluginAjaxVariables === 'Admin',
|
|
110
|
+
};
|
|
111
|
+
this.optionsPage = paramCase(this.answers.pluginCreateOptions);
|
|
92
112
|
|
|
93
113
|
const nameNoAirfleet = this.answers.pluginName
|
|
94
114
|
.replace(/^airfleet/i, "")
|
|
@@ -102,14 +122,18 @@ export default class extends Generator {
|
|
|
102
122
|
packageName: `@airfleet/${this.nameNoAirfleet.slug}-wp-plugin`,
|
|
103
123
|
mainBranch: "main",
|
|
104
124
|
year: new Date().getFullYear(),
|
|
125
|
+
ajaxVariables: this.ajaxVariables,
|
|
126
|
+
optionsPage: this.optionsPage,
|
|
105
127
|
};
|
|
106
128
|
}
|
|
107
129
|
|
|
108
130
|
writing() {
|
|
109
131
|
const files = [
|
|
132
|
+
".github/workflows/create-asana-attachment.yaml",
|
|
133
|
+
".github/workflows/release-plugin.yml",
|
|
134
|
+
".github/workflows/test-wordpress.yml",
|
|
110
135
|
".husky/pre-commit",
|
|
111
136
|
".vscode/settings.json",
|
|
112
|
-
"acf-json/.gitkeep",
|
|
113
137
|
"assets/admin/scripts/admin.entry.js",
|
|
114
138
|
"assets/admin/styles/admin.entry.scss",
|
|
115
139
|
"assets/editor/scripts/editor.entry.js",
|
|
@@ -129,12 +153,14 @@ export default class extends Generator {
|
|
|
129
153
|
".parcelrc",
|
|
130
154
|
".prettierignore",
|
|
131
155
|
"CHANGELOG.md",
|
|
156
|
+
"composer-scoped.json.ejs",
|
|
132
157
|
"composer.json.ejs",
|
|
133
158
|
"index.php",
|
|
134
159
|
"LICENSE.ejs",
|
|
135
160
|
"package.json.ejs",
|
|
136
161
|
"phpcs.xml.ejs",
|
|
137
162
|
"README.md.ejs",
|
|
163
|
+
"scoper.custom.php.ejs",
|
|
138
164
|
];
|
|
139
165
|
const templates = [
|
|
140
166
|
...mapFilesToTemplates(files),
|
|
@@ -153,6 +179,36 @@ export default class extends Generator {
|
|
|
153
179
|
destination: `${this.name.slug}.php`,
|
|
154
180
|
isEnabled: true,
|
|
155
181
|
},
|
|
182
|
+
{
|
|
183
|
+
template: "inc/AjaxVariables.php.ejs",
|
|
184
|
+
destination: `inc/AjaxVariables.php`,
|
|
185
|
+
isEnabled: this.ajaxVariables.frontend,
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
template: "inc/AjaxVariablesAdmin.php.ejs",
|
|
189
|
+
destination: `inc/AjaxVariablesAdmin.php`,
|
|
190
|
+
isEnabled: this.ajaxVariables.admin,
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
template: "inc/Options.php.ejs",
|
|
194
|
+
destination: `inc/Options.php`,
|
|
195
|
+
isEnabled: this.optionsPage === 'framework',
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
template: "inc/Options/GeneralOptions.php.ejs",
|
|
199
|
+
destination: `inc/Options/GeneralOptions.php`,
|
|
200
|
+
isEnabled: this.optionsPage === 'framework',
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
template: "inc/Pages.php.ejs",
|
|
204
|
+
destination: `inc/Pages.php`,
|
|
205
|
+
isEnabled: this.optionsPage === 'framework',
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
template: "acf-json/.gitkeep",
|
|
209
|
+
destination: `acf-json/.gitkeep`,
|
|
210
|
+
isEnabled: this.answers.pluginAcfLocalJson,
|
|
211
|
+
},
|
|
156
212
|
];
|
|
157
213
|
|
|
158
214
|
copyTemplates(this, templates, this.data);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: ✍️ Asana Create PR Attachment
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
types: [opened, reopened]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
create-asana-attachment-job:
|
|
9
|
+
runs-on: ubuntu-latest
|
|
10
|
+
timeout-minutes: 1
|
|
11
|
+
name: Create pull request attachments on Asana tasks
|
|
12
|
+
steps:
|
|
13
|
+
- name: Create pull request attachments
|
|
14
|
+
uses: Asana/create-app-attachment-github-action@latest
|
|
15
|
+
id: postAttachment
|
|
16
|
+
with:
|
|
17
|
+
asana-secret: ${{ secrets.ASANA_SECRET }}
|
|
18
|
+
- name: Log output status
|
|
19
|
+
run: echo "Status is ${{ steps.postAttachment.outputs.status }}"
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
name: 📦 Release (Plugin)
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["main"]
|
|
6
|
+
workflow_dispatch:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
release:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- name: 🚚 Get latest code
|
|
14
|
+
uses: actions/checkout@v3
|
|
15
|
+
|
|
16
|
+
- name: ⚙️ Setup PHP
|
|
17
|
+
uses: shivammathur/setup-php@v2
|
|
18
|
+
with:
|
|
19
|
+
php-version: "8.1"
|
|
20
|
+
ini-values: short_open_tag=1
|
|
21
|
+
env:
|
|
22
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
23
|
+
|
|
24
|
+
- name: ⚙️ Setup Node
|
|
25
|
+
uses: actions/setup-node@v3
|
|
26
|
+
with:
|
|
27
|
+
node-version: 16
|
|
28
|
+
cache: "npm"
|
|
29
|
+
|
|
30
|
+
- name: ⚙️ Get Composer cache directory
|
|
31
|
+
id: composer-cache
|
|
32
|
+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
|
33
|
+
|
|
34
|
+
- name: ⚙️ Cache Composer dependencies
|
|
35
|
+
uses: actions/cache@v3
|
|
36
|
+
with:
|
|
37
|
+
path: ${{ steps.composer-cache.outputs.dir }}
|
|
38
|
+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
|
39
|
+
restore-keys: ${{ runner.os }}-composer-
|
|
40
|
+
|
|
41
|
+
- name: 🔨 Increase composer timeout
|
|
42
|
+
run: composer --global config process-timeout 1500
|
|
43
|
+
|
|
44
|
+
- name: 🔨 Composer install (with dev dependencies)
|
|
45
|
+
run: composer install --prefer-dist --no-ansi --no-interaction --no-progress --optimize-autoloader
|
|
46
|
+
|
|
47
|
+
- name: 🔨 npm install
|
|
48
|
+
run: npm ci
|
|
49
|
+
|
|
50
|
+
- name: 🔬 Test
|
|
51
|
+
run: npm test
|
|
52
|
+
|
|
53
|
+
- name: 🔨 Composer install (without dev dependencies)
|
|
54
|
+
run: composer install --prefer-dist --no-ansi --no-interaction --no-progress --no-dev --optimize-autoloader
|
|
55
|
+
|
|
56
|
+
- name: 🔨 Install release dependencies
|
|
57
|
+
run: npm install -g release-it@^15 @release-it/keep-a-changelog@^3
|
|
58
|
+
|
|
59
|
+
- name: 🔨 Additional release dependencies
|
|
60
|
+
run: |
|
|
61
|
+
npm install -g @release-it/bumper@^4 json
|
|
62
|
+
sudo apt-get install jo
|
|
63
|
+
|
|
64
|
+
- name: 🔨 Config git
|
|
65
|
+
run: |
|
|
66
|
+
git config user.name "${GITHUB_ACTOR}"
|
|
67
|
+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
|
|
68
|
+
|
|
69
|
+
- name: 🔧 Get plugin name
|
|
70
|
+
id: plugin
|
|
71
|
+
# For a better understanding of how the name is generated
|
|
72
|
+
# see https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables
|
|
73
|
+
# see https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html
|
|
74
|
+
# basically we start with "airfleet/airfleet-analytics-plugin" and end up with "airfleet-analytics"
|
|
75
|
+
run: |
|
|
76
|
+
NAME=${GITHUB_REPOSITORY#*/}
|
|
77
|
+
NAME=${NAME%-plugin}
|
|
78
|
+
echo "Plugin name: ${NAME}"
|
|
79
|
+
echo "::set-output name=PLUGIN_NAME::$NAME"
|
|
80
|
+
|
|
81
|
+
- name: 🔧 Get changelog
|
|
82
|
+
id: changelog
|
|
83
|
+
run: |
|
|
84
|
+
echo "$(sed '/## \[Unreleased\]/,/## \[/!d' CHANGELOG.md | sed '1d;$d')" > $RUNNER_TEMP/latest_changelog.txt
|
|
85
|
+
cat $RUNNER_TEMP/latest_changelog.txt
|
|
86
|
+
|
|
87
|
+
- name: 📦 Release
|
|
88
|
+
run:
|
|
89
|
+
export PLUGIN="${{ steps.plugin.outputs.PLUGIN_NAME }}" && npx release-it $(cat .airfleet-release)
|
|
90
|
+
-VV
|
|
91
|
+
--ci
|
|
92
|
+
--hooks.before:release='echo Building $PLUGIN'
|
|
93
|
+
--hooks.before:release='npm run build --if-present'
|
|
94
|
+
--hooks.before:release='mkdir -p $RUNNER_TEMP/.release-dist/$PLUGIN/'
|
|
95
|
+
--hooks.before:release='rsync -a . $RUNNER_TEMP/.release-dist/$PLUGIN/'
|
|
96
|
+
--hooks.before:release='cd $RUNNER_TEMP/.release-dist && du -hs $PLUGIN'
|
|
97
|
+
--hooks.before:release='rm -rf $RUNNER_TEMP/.release-dist/$PLUGIN/.git/'
|
|
98
|
+
--hooks.before:release='rm -rf $RUNNER_TEMP/.release-dist/$PLUGIN/node_modules/'
|
|
99
|
+
--hooks.before:release='rm -rf $RUNNER_TEMP/.release-dist/$PLUGIN/.parcel-cache/'
|
|
100
|
+
--hooks.before:release='cd $RUNNER_TEMP/.release-dist && du -hs $PLUGIN'
|
|
101
|
+
--hooks.before:release='cd $RUNNER_TEMP/.release-dist && ls -la'
|
|
102
|
+
--hooks.before:release='cd $RUNNER_TEMP/.release-dist/$PLUGIN/ && ls -la'
|
|
103
|
+
--hooks.before:release='cd $RUNNER_TEMP/.release-dist && zip -rq $PLUGIN.zip $PLUGIN'
|
|
104
|
+
--hooks.before:release='cd $RUNNER_TEMP/.release-dist && du -hs $PLUGIN.zip'
|
|
105
|
+
--hooks.before:release='rm -rf $RUNNER_TEMP/.release-dist/$PLUGIN/'
|
|
106
|
+
--hooks.before:release='cd $RUNNER_TEMP/.release-dist && ls -la'
|
|
107
|
+
--hooks.before:release='cp -R $RUNNER_TEMP/.release-dist dist/.release-dist'
|
|
108
|
+
--git.pushArgs='--follow-tags'
|
|
109
|
+
--git.pushArgs='-o ci.skip'
|
|
110
|
+
--no-npm.publish
|
|
111
|
+
--github.release
|
|
112
|
+
--github.assets='dist/.release-dist/**/*'
|
|
113
|
+
--plugins.@release-it/keep-a-changelog.filename=CHANGELOG.md
|
|
114
|
+
--no-plugins.@release-it/keep-a-changelog.strictLatest
|
|
115
|
+
--plugins.@release-it/keep-a-changelog.addUnreleased
|
|
116
|
+
--plugins.@release-it/keep-a-changelog.addVersionUrl
|
|
117
|
+
--plugins.@release-it/keep-a-changelog.head=main
|
|
118
|
+
--plugins.@release-it/bumper.out.file=*.php
|
|
119
|
+
--plugins.@release-it/bumper.out.type=text/php
|
|
120
|
+
env:
|
|
121
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
122
|
+
|
|
123
|
+
- name: ⚒️ Build plugin.json
|
|
124
|
+
run: |
|
|
125
|
+
PLUGIN="${{ steps.plugin.outputs.PLUGIN_NAME }}"
|
|
126
|
+
NAME="$(grep 'Plugin Name' $PLUGIN.php | sed 's/\*//; s/Plugin Name://; s/^[ t]*//')"
|
|
127
|
+
DESCRIPTION="$(cat package.json | json description)"
|
|
128
|
+
SLUG="$PLUGIN/$PLUGIN.php"
|
|
129
|
+
VERSION="$(cat package.json | json version)"
|
|
130
|
+
DATE="$(date -u +%FT%TZ)"
|
|
131
|
+
CHANGELOG="$(cat $RUNNER_TEMP/latest_changelog.txt)"
|
|
132
|
+
VERSIONS="[$(jo version="$VERSION" date="$DATE" changelog="$CHANGELOG" )]"
|
|
133
|
+
echo "Plugin: $PLUGIN"
|
|
134
|
+
echo "Name: $NAME"
|
|
135
|
+
echo "Description: $DESCRIPTION"
|
|
136
|
+
echo "Slug: $SLUG"
|
|
137
|
+
echo "Version: $VERSION"
|
|
138
|
+
echo "Date: $DATE"
|
|
139
|
+
echo "Changelog: $CHANGELOG"
|
|
140
|
+
echo "Versions: $VERSIONS"
|
|
141
|
+
jo -p name="$NAME" description="$DESCRIPTION" slug="$SLUG" versions="$VERSIONS" > $RUNNER_TEMP/plugin.json
|
|
142
|
+
cat $RUNNER_TEMP/plugin.json
|
|
143
|
+
|
|
144
|
+
- name: ⚙️ Configure AWS Credentials
|
|
145
|
+
uses: aws-actions/configure-aws-credentials@v1
|
|
146
|
+
with:
|
|
147
|
+
aws-region: ${{ secrets.AWS_DEFAULT_REGION }}
|
|
148
|
+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
|
149
|
+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
150
|
+
|
|
151
|
+
- name: 🚀 Upload plugin zip file to AWS
|
|
152
|
+
run: |
|
|
153
|
+
PLUGIN="${{ steps.plugin.outputs.PLUGIN_NAME }}"
|
|
154
|
+
BUCKET="${{ secrets.AWS_S3_BUCKET }}"
|
|
155
|
+
FILENAME="$PLUGIN.$(cat $RUNNER_TEMP/plugin.json | json versions.0.version).zip"
|
|
156
|
+
aws s3 cp $RUNNER_TEMP/.release-dist/$PLUGIN.zip s3://$BUCKET/$PLUGIN/$FILENAME
|
|
157
|
+
|
|
158
|
+
- name: 📥 Download plugins list from AWS
|
|
159
|
+
run: |
|
|
160
|
+
BUCKET="${{ secrets.AWS_S3_BUCKET }}"
|
|
161
|
+
aws s3 cp s3://$BUCKET/plugins.json $RUNNER_TEMP/plugins.json
|
|
162
|
+
echo "Current plugins.json from S3"
|
|
163
|
+
cat $RUNNER_TEMP/plugins.json | json
|
|
164
|
+
|
|
165
|
+
- name: ⚒️ Build new plugins list
|
|
166
|
+
# Reference https://trentm.com/json/
|
|
167
|
+
run: |
|
|
168
|
+
NL=$'\n'
|
|
169
|
+
PLUGIN_SLUG=$(cat $RUNNER_TEMP/plugin.json | json slug)
|
|
170
|
+
echo "Plugin slug: $PLUGIN_SLUG"
|
|
171
|
+
PLUGIN_VERSIONS=$(echo "$(cat $RUNNER_TEMP/plugin.json | json versions)${NL}$(cat $RUNNER_TEMP/plugins.json | json plugins | json -c "this.slug === '$PLUGIN_SLUG'" | json 0.versions)" | json --group)
|
|
172
|
+
echo "Plugin versions:"
|
|
173
|
+
echo $PLUGIN_VERSIONS | json
|
|
174
|
+
PLUGIN_UPDATED=$(echo "$(cat $RUNNER_TEMP/plugins.json | json plugins | json -c "this.slug === '$PLUGIN_SLUG'" | json 0)${NL}$(cat $RUNNER_TEMP/plugin.json | json)" | json --merge | json -e "this.versions = $PLUGIN_VERSIONS" | json)
|
|
175
|
+
echo "Plugin updated:"
|
|
176
|
+
echo $PLUGIN_UPDATED | json
|
|
177
|
+
PLUGINS_LIST_UPDATED=$(echo "$(cat $RUNNER_TEMP/plugins.json | json plugins | json -c "this.slug !== '$PLUGIN_SLUG'")${NL}$(echo $(echo $PLUGIN_UPDATED) | json --group)" | json --group)
|
|
178
|
+
echo "Plugins list updated:"
|
|
179
|
+
echo $PLUGINS_LIST_UPDATED | json
|
|
180
|
+
cat $RUNNER_TEMP/plugins.json | json -e "this.plugins = $PLUGINS_LIST_UPDATED" | json > $RUNNER_TEMP/plugins_updated.json
|
|
181
|
+
|
|
182
|
+
- name: 🚀 Upload updated plugins list to AWS
|
|
183
|
+
run: |
|
|
184
|
+
BUCKET="${{ secrets.AWS_S3_BUCKET }}"
|
|
185
|
+
aws s3 cp $RUNNER_TEMP/plugins_updated.json s3://$BUCKET/plugins.json
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
name: 🧪 Test
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: ["staging", "development"]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: ["main", "staging", "development"]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
steps:
|
|
15
|
+
- name: 🚚 Get latest code
|
|
16
|
+
uses: actions/checkout@v3
|
|
17
|
+
|
|
18
|
+
- name: ⚙️ Setup PHP
|
|
19
|
+
uses: shivammathur/setup-php@v2
|
|
20
|
+
with:
|
|
21
|
+
php-version: "8.1"
|
|
22
|
+
ini-values: short_open_tag=1
|
|
23
|
+
env:
|
|
24
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
25
|
+
|
|
26
|
+
- name: ⚙️ Setup Node
|
|
27
|
+
uses: actions/setup-node@v3
|
|
28
|
+
with:
|
|
29
|
+
node-version: 16
|
|
30
|
+
cache: "npm"
|
|
31
|
+
|
|
32
|
+
- name: ⚙️ Get Composer cache directory
|
|
33
|
+
id: composer-cache
|
|
34
|
+
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
|
35
|
+
|
|
36
|
+
- name: ⚙️ Cache Composer dependencies
|
|
37
|
+
uses: actions/cache@v3
|
|
38
|
+
with:
|
|
39
|
+
path: ${{ steps.composer-cache.outputs.dir }}
|
|
40
|
+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
|
41
|
+
restore-keys: ${{ runner.os }}-composer-
|
|
42
|
+
|
|
43
|
+
- name: 🔨 Increase composer timeout
|
|
44
|
+
run: composer --global config process-timeout 1500
|
|
45
|
+
|
|
46
|
+
- name: 🔨 Composer install
|
|
47
|
+
run: composer install --prefer-dist --no-ansi --no-interaction --no-progress --optimize-autoloader
|
|
48
|
+
|
|
49
|
+
- name: 🔨 npm install
|
|
50
|
+
run: npm ci
|
|
51
|
+
|
|
52
|
+
- name: 🔬 Test
|
|
53
|
+
run: npm test
|
|
54
|
+
|
|
55
|
+
- name: 📦 Build
|
|
56
|
+
run: npm run build --if-present
|
|
@@ -1,10 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"editor.codeActionsOnSave": {
|
|
3
|
-
"source.fixAll": true
|
|
3
|
+
"source.fixAll": true,
|
|
4
|
+
"source.fixAll.eslint": true
|
|
4
5
|
},
|
|
5
6
|
"editor.formatOnSave": true,
|
|
6
7
|
"stylelint.validate": ["css", "scss", "postcss"],
|
|
8
|
+
"phpSniffer.autoDetect": true,
|
|
7
9
|
"[php]": {
|
|
8
|
-
"editor.
|
|
10
|
+
"editor.defaultFormatter": "wongjn.php-sniffer"
|
|
11
|
+
},
|
|
12
|
+
"[javascript]": {
|
|
13
|
+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
|
14
|
+
},
|
|
15
|
+
"[javascriptreact]": {
|
|
16
|
+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
|
17
|
+
},
|
|
18
|
+
"[typescript]": {
|
|
19
|
+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
|
20
|
+
},
|
|
21
|
+
"[typescriptreact]": {
|
|
22
|
+
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
|
|
23
|
+
},
|
|
24
|
+
"[postcss]": {
|
|
25
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
26
|
+
},
|
|
27
|
+
"[scss]": {
|
|
28
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
29
|
+
},
|
|
30
|
+
"[css]": {
|
|
31
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode"
|
|
9
32
|
}
|
|
10
33
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# <%= name.title %> WordPress Plugin
|
|
2
2
|
|
|
3
|
-
[](<%= repositoryBase %>/actions/workflows/test-wordpress.yml)
|
|
4
|
+
[](<%= repositoryBase %>/actions/workflows/release-plugin.yml)
|
|
4
5
|
|
|
5
6
|
<%= answers.pluginDescription %>
|
|
6
7
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_readme": [
|
|
3
|
+
"This file locks the dependencies of your project to a known state",
|
|
4
|
+
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
|
5
|
+
"This file is @generated automatically"
|
|
6
|
+
],
|
|
7
|
+
"content-hash": "73f083775f13a46ceb1fe9e556b8e1c5",
|
|
8
|
+
"packages": [
|
|
9
|
+
{
|
|
10
|
+
"name": "airfleet/wordpress-framework",
|
|
11
|
+
"version": "0.3.0",
|
|
12
|
+
"source": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "https://github.com/airfleet/airfleet-wordpress-framework-php.git",
|
|
15
|
+
"reference": "063b33c80a313f046dd4eaba265b5cff173554a4"
|
|
16
|
+
},
|
|
17
|
+
"dist": {
|
|
18
|
+
"type": "zip",
|
|
19
|
+
"url": "https://api.github.com/repos/airfleet/airfleet-wordpress-framework-php/zipball/063b33c80a313f046dd4eaba265b5cff173554a4",
|
|
20
|
+
"reference": "063b33c80a313f046dd4eaba265b5cff173554a4",
|
|
21
|
+
"shasum": ""
|
|
22
|
+
},
|
|
23
|
+
"require": {
|
|
24
|
+
"php": ">=8.0"
|
|
25
|
+
},
|
|
26
|
+
"type": "library",
|
|
27
|
+
"autoload": {
|
|
28
|
+
"psr-4": {
|
|
29
|
+
"Airfleet\\Framework\\": "inc/"
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
"notification-url": "https://packagist.org/downloads/",
|
|
33
|
+
"authors": [
|
|
34
|
+
{
|
|
35
|
+
"name": "Airfleet",
|
|
36
|
+
"email": "dev@airfleet.co"
|
|
37
|
+
}
|
|
38
|
+
],
|
|
39
|
+
"description": "Airfleet framework for WordPress",
|
|
40
|
+
"support": {
|
|
41
|
+
"issues": "https://github.com/airfleet/airfleet-wordpress-framework-php/issues",
|
|
42
|
+
"source": "https://github.com/airfleet/airfleet-wordpress-framework-php/tree/0.3.0"
|
|
43
|
+
},
|
|
44
|
+
"time": "2023-04-13T13:58:54+00:00"
|
|
45
|
+
}
|
|
46
|
+
],
|
|
47
|
+
"packages-dev": [],
|
|
48
|
+
"aliases": [],
|
|
49
|
+
"minimum-stability": "stable",
|
|
50
|
+
"stability-flags": [],
|
|
51
|
+
"prefer-stable": false,
|
|
52
|
+
"prefer-lowest": false,
|
|
53
|
+
"platform": [],
|
|
54
|
+
"platform-dev": [],
|
|
55
|
+
"plugin-api-version": "2.3.0"
|
|
56
|
+
}
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"composer/installers": "^2.0"
|
|
13
13
|
},
|
|
14
14
|
"require-dev": {
|
|
15
|
-
"airfleet/wordpress-dev": "^
|
|
15
|
+
"airfleet/wordpress-dev": "^3.0.1",
|
|
16
|
+
"wpify/scoper": "2.5.4"
|
|
16
17
|
},
|
|
17
18
|
"autoload": {
|
|
18
19
|
"psr-4": {
|
|
@@ -32,7 +33,20 @@
|
|
|
32
33
|
"config": {
|
|
33
34
|
"allow-plugins": {
|
|
34
35
|
"composer/installers": true,
|
|
35
|
-
"dealerdirect/phpcodesniffer-composer-installer": true
|
|
36
|
+
"dealerdirect/phpcodesniffer-composer-installer": true,
|
|
37
|
+
"wpify/scoper": true
|
|
36
38
|
}
|
|
37
|
-
}
|
|
39
|
+
},
|
|
40
|
+
"extra": {
|
|
41
|
+
"wpify-scoper": {
|
|
42
|
+
"prefix": "Airfleet\\Plugins\\<%= nameNoAirfleet.pascal %>\\Vendor",
|
|
43
|
+
"folder": "vendor-scoped",
|
|
44
|
+
"globals": [
|
|
45
|
+
"wordpress"
|
|
46
|
+
],
|
|
47
|
+
"composerjson": "composer-scoped.json",
|
|
48
|
+
"composerlock": "composer-scoped.lock"
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
"minimum-stability": "dev"
|
|
38
52
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Airfleet\Plugins\<%= nameNoAirfleet.pascal %>;
|
|
4
|
+
|
|
5
|
+
use Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Vendor\Airfleet\Framework\Assets\FrontendVariables;
|
|
6
|
+
|
|
7
|
+
class AjaxVariables extends FrontendVariables {
|
|
8
|
+
public function __construct() {
|
|
9
|
+
parent::__construct(
|
|
10
|
+
[
|
|
11
|
+
'slug' => \<%= name.constant %>_SLUG,
|
|
12
|
+
'name' => '_<%= name.camel %>',
|
|
13
|
+
'variables' => function (): array {
|
|
14
|
+
return [
|
|
15
|
+
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
|
|
16
|
+
'ajaxNonce' => wp_create_nonce( '<%= name.camel %>Nonce' ),
|
|
17
|
+
];
|
|
18
|
+
},
|
|
19
|
+
]
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Airfleet\Plugins\<%= nameNoAirfleet.pascal %>;
|
|
4
|
+
|
|
5
|
+
use Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Vendor\Airfleet\Framework\Assets\AdminVariables;
|
|
6
|
+
|
|
7
|
+
class AjaxVariablesAdmin extends AdminVariables {
|
|
8
|
+
public function __construct() {
|
|
9
|
+
parent::__construct(
|
|
10
|
+
[
|
|
11
|
+
'slug' => \<%= name.constant %>_SLUG,
|
|
12
|
+
'name' => '_<%= name.camel %>',
|
|
13
|
+
'variables' => function (): array {
|
|
14
|
+
return [
|
|
15
|
+
'ajaxUrl' => admin_url( 'admin-ajax.php' ),
|
|
16
|
+
'ajaxNonce' => wp_create_nonce( '<%= name.camel %>Nonce' ),
|
|
17
|
+
];
|
|
18
|
+
},
|
|
19
|
+
]
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Options;
|
|
4
|
+
|
|
5
|
+
use Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Vendor\Airfleet\Framework\Options\Group;
|
|
6
|
+
use Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Vendor\Airfleet\Framework\Options\Wizard;
|
|
7
|
+
|
|
8
|
+
class GeneralOptions extends Group {
|
|
9
|
+
private const IS_ENABLED = 'is_enabled';
|
|
10
|
+
|
|
11
|
+
// phpcs:ignore NeutronStandard.Functions.LongFunction.LongFunction
|
|
12
|
+
public function __construct() {
|
|
13
|
+
parent::__construct(
|
|
14
|
+
'<%= name.snake %>_general_group',
|
|
15
|
+
'<%= name.snake %>_general',
|
|
16
|
+
Wizard::create_sections(
|
|
17
|
+
[
|
|
18
|
+
'<%= name.snake %>_general_settings' => [
|
|
19
|
+
'title' => __( 'General Settings', 'airfleet' ),
|
|
20
|
+
'description' => __( 'General settings for <%= name.title %>.', 'airfleet' ),
|
|
21
|
+
'fields' => [
|
|
22
|
+
self::IS_ENABLED => [
|
|
23
|
+
'type' => 'checkbox',
|
|
24
|
+
'title' => __( '<%= name.title %> enabled?', 'airfleet' ),
|
|
25
|
+
'label' => __( 'Enable <%= name.title %>', 'airfleet' ),
|
|
26
|
+
'default' => false,
|
|
27
|
+
],
|
|
28
|
+
],
|
|
29
|
+
],
|
|
30
|
+
]
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Check if the functionality is enabled.
|
|
37
|
+
*
|
|
38
|
+
* @return boolean
|
|
39
|
+
*/
|
|
40
|
+
public function is_enabled(): bool {
|
|
41
|
+
return $this->value( self::IS_ENABLED );
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Airfleet\Plugins\<%= nameNoAirfleet.pascal %>;
|
|
4
|
+
|
|
5
|
+
use Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Options\GeneralOptions;
|
|
6
|
+
|
|
7
|
+
class Options {
|
|
8
|
+
protected GeneralOptions $general;
|
|
9
|
+
|
|
10
|
+
public function __construct() {
|
|
11
|
+
$this->general = new GeneralOptions( $this );
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public function general(): GeneralOptions {
|
|
15
|
+
return $this->general;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace Airfleet\Plugins\<%= nameNoAirfleet.pascal %>;
|
|
4
|
+
|
|
5
|
+
use Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Vendor\Airfleet\Framework\Features\BasePluginFeature;
|
|
6
|
+
use Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Vendor\Airfleet\Framework\Options\Pages\MenuTabsPage;
|
|
7
|
+
use Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Vendor\Airfleet\Framework\Options\Tabs\OptionsTab;
|
|
8
|
+
use Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Options;
|
|
9
|
+
|
|
10
|
+
class Pages extends BasePluginFeature {
|
|
11
|
+
protected MenuTabsPage $page;
|
|
12
|
+
|
|
13
|
+
public function __construct( Options $options ) {
|
|
14
|
+
$this->page = new MenuTabsPage(
|
|
15
|
+
[
|
|
16
|
+
'slug' => \<%= name.constant %>_SLUG,
|
|
17
|
+
'title' => \<%= name.constant %>_TITLE_SHORT,
|
|
18
|
+
'class' => '<%= name.slug %>-page',
|
|
19
|
+
'tabs' => [
|
|
20
|
+
new OptionsTab(
|
|
21
|
+
'general',
|
|
22
|
+
__( 'General', 'airfleet' ),
|
|
23
|
+
$options->general(),
|
|
24
|
+
'<%= name.snake %>_general_page'
|
|
25
|
+
),
|
|
26
|
+
],
|
|
27
|
+
],
|
|
28
|
+
'airfleet'
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public function initialize(): void {
|
|
33
|
+
$this->page->initialize();
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -2,72 +2,43 @@
|
|
|
2
2
|
|
|
3
3
|
namespace Airfleet\Plugins\<%= nameNoAirfleet.pascal %>;
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
use Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Vendor\Airfleet\Framework\Assets\Enqueue;
|
|
6
|
+
use Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Vendor\Airfleet\Framework\Features\PluginFeatures;
|
|
7
|
+
<%_ if (optionsPage === 'framework' ) { _%>
|
|
8
|
+
use Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Vendor\Airfleet\Framework\Plugin\SettingsLink;
|
|
9
|
+
<%_ } _%>
|
|
10
|
+
<%_ if (optionsPage === 'acf' ) { _%>
|
|
11
|
+
use Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Vendor\Airfleet\Framework\Plugin\AcfAirfleetOptionsSubPage;
|
|
12
|
+
use Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Vendor\Airfleet\Framework\Plugin\AcfSettingsLink;
|
|
13
|
+
<%_ } _%>
|
|
14
|
+
<%_ if (answers.pluginAcfLocalJson) { _%>
|
|
15
|
+
use Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Vendor\Airfleet\Framework\Acf\LocalJson;
|
|
16
|
+
<%_ } _%>
|
|
6
17
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
*/
|
|
12
|
-
public function initialize(): void {
|
|
13
|
-
$this->show_admin_notice_if_missing_framework();
|
|
14
|
-
add_action(
|
|
15
|
-
'airfleet/init',
|
|
16
|
-
function () {
|
|
17
|
-
$this->plugin_basic_setup();
|
|
18
|
-
}
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Basic setup for the plugin. Enqueue assets and add options page
|
|
24
|
-
*
|
|
25
|
-
* @return void
|
|
26
|
-
*/
|
|
27
|
-
public function plugin_basic_setup(): void {
|
|
28
|
-
$plugin = new \Airfleet\Plugin(
|
|
29
|
-
[
|
|
30
|
-
'slug' => '<%= name.slug %>',
|
|
31
|
-
'title' => '<%= name.title %>',
|
|
32
|
-
'short_title' => '<%= nameNoAirfleet.title %>',
|
|
33
|
-
'url' => \<%= name.constant %>_URL,
|
|
34
|
-
'path' => \<%= name.constant %>_PATH,
|
|
35
|
-
'version' => \<%= name.constant %>_VERSION,
|
|
36
|
-
'namespace' => 'Airfleet\\Plugins\\<%= nameNoAirfleet.pascal %>',
|
|
37
|
-
]
|
|
38
|
-
);
|
|
39
|
-
$plugin->setup_acf_json();
|
|
40
|
-
$plugin->enqueue();
|
|
41
|
-
$plugin->enqueue_critical();
|
|
42
|
-
$plugin->enqueue_admin();
|
|
43
|
-
$plugin->enqueue_editor();
|
|
44
|
-
<%_ if (answers.pluginCreateOptions) { _%>
|
|
45
|
-
$plugin->add_options_page();
|
|
18
|
+
class Setup extends PluginFeatures {
|
|
19
|
+
public function __construct( array $config ) {
|
|
20
|
+
<%_ if (optionsPage === 'framework' ) { _%>
|
|
21
|
+
$options = new Options();
|
|
46
22
|
<%_ } _%>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
<p>Please install the Airfleet Framework to enable the Airfleet plugins.</p>
|
|
68
|
-
</div>
|
|
69
|
-
<?php
|
|
70
|
-
}
|
|
71
|
-
);
|
|
23
|
+
$this->features = [
|
|
24
|
+
new Enqueue( $config ),
|
|
25
|
+
<%_ if (optionsPage === 'framework' ) { _%>
|
|
26
|
+
new Pages( $options ),
|
|
27
|
+
new SettingsLink( $config ),
|
|
28
|
+
<%_ } _%>
|
|
29
|
+
<%_ if (optionsPage === 'acf' ) { _%>
|
|
30
|
+
new AcfAirfleetOptionsSubPage( $config ),
|
|
31
|
+
new AcfSettingsLink( $config ),
|
|
32
|
+
<%_ } _%>
|
|
33
|
+
<%_ if (ajaxVariables.frontend) { _%>
|
|
34
|
+
new AjaxVariables(),
|
|
35
|
+
<%_ } _%>
|
|
36
|
+
<%_ if (ajaxVariables.admin) { _%>
|
|
37
|
+
new AjaxVariablesAdmin(),
|
|
38
|
+
<%_ } _%>
|
|
39
|
+
<%_ if (answers.pluginAcfLocalJson) { _%>
|
|
40
|
+
new LocalJson( $config['path'] . 'acf-json' ),
|
|
41
|
+
<%_ } _%>
|
|
42
|
+
];
|
|
72
43
|
}
|
|
73
44
|
}
|
|
@@ -3,10 +3,11 @@
|
|
|
3
3
|
"description": "<%= answers.pluginDescription %>",
|
|
4
4
|
"version": "<%= answers.pluginVersion %>",
|
|
5
5
|
"scripts": {
|
|
6
|
-
"build": "dotenv -- parcel build --log-level verbose \"./!(dist)/**/*.entry.{js,scss}\"",
|
|
7
|
-
"start": "dotenv -- parcel serve --hmr-port 1236 --port 1234 --log-level verbose \"./!(dist)/**/*.entry.{js,scss}\"",
|
|
6
|
+
"build": "dotenv -- parcel build --no-source-maps --log-level verbose \"./!(dist)/**/*.entry.{js,css,scss}\"",
|
|
7
|
+
"start": "dotenv -- parcel serve --hmr-port 1236 --port 1234 --log-level verbose \"./!(dist)/**/*.entry.{js,css,scss}\"",
|
|
8
|
+
"watch": "dotenv -- parcel watch --no-hmr --log-level verbose \"./!(dist)/**/*.entry.{js,css,scss}\"",
|
|
8
9
|
"base:eslint": "eslint \"**/*.js\" --cache --ignore-path .gitignore",
|
|
9
|
-
"base:prettier": "prettier \"**/*.{
|
|
10
|
+
"base:prettier": "prettier \"**/*.{css,scss}\"",
|
|
10
11
|
"base:stylelint": "stylelint \"**/*.{css,scss}\" --cache --ignore-path .gitignore --allow-empty-input",
|
|
11
12
|
"lint": "run-s --continue-on-error lint:*",
|
|
12
13
|
"lint:prettier": "npm run base:prettier -- --check",
|
|
@@ -20,8 +21,7 @@
|
|
|
20
21
|
"fix:phpcs": "composer run fix",
|
|
21
22
|
"pretest": "npm run lint",
|
|
22
23
|
"test": "echo Testing done",
|
|
23
|
-
"prepare": "husky install"
|
|
24
|
-
"cz": "git-cz"
|
|
24
|
+
"prepare": "husky install"
|
|
25
25
|
},
|
|
26
26
|
"private": true,
|
|
27
27
|
"keywords": [
|
|
@@ -42,12 +42,17 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"@airfleet/wordpress-dev": "^
|
|
45
|
+
"@airfleet/wordpress-dev": "^2.1.2"
|
|
46
46
|
},
|
|
47
47
|
"browserslist": [
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
"defaults",
|
|
49
|
+
"not dead",
|
|
50
|
+
"not op_mini all",
|
|
51
|
+
"not op_mob > 0",
|
|
52
|
+
"not opera > 0",
|
|
53
|
+
"not kaios > 0",
|
|
54
|
+
"not and_qq > 0",
|
|
55
|
+
"not and_uc > 0"
|
|
51
56
|
],
|
|
52
57
|
"prettier": "@airfleet/prettier-config-wordpress",
|
|
53
58
|
"stylelint": {
|
|
@@ -62,17 +67,14 @@
|
|
|
62
67
|
]
|
|
63
68
|
},
|
|
64
69
|
"lint-staged": {
|
|
65
|
-
"*.{js,jsx,ts,tsx,json,css,scss,xml,yaml,yml,md}": "prettier --write",
|
|
66
70
|
"*.{js,jsx}": "eslint --cache --ignore-path .gitignore --fix",
|
|
67
|
-
"*.{css,scss}":
|
|
71
|
+
"*.{css,scss}": [
|
|
72
|
+
"prettier --write",
|
|
73
|
+
"stylelint --cache --ignore-path .gitignore --fix"
|
|
74
|
+
],
|
|
68
75
|
"*.php": [
|
|
69
76
|
"composer run fix",
|
|
70
77
|
"composer run lint"
|
|
71
78
|
]
|
|
72
|
-
},
|
|
73
|
-
"config": {
|
|
74
|
-
"commitizen": {
|
|
75
|
-
"path": "./node_modules/cz-conventional-changelog"
|
|
76
|
-
}
|
|
77
79
|
}
|
|
78
80
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
<?php
|
|
2
|
-
|
|
3
2
|
/**
|
|
4
3
|
* <%= name.title %>
|
|
5
4
|
*
|
|
@@ -28,14 +27,35 @@ if ( ! defined( 'ABSPATH' ) ) {
|
|
|
28
27
|
|
|
29
28
|
// Plugin constants.
|
|
30
29
|
define( '<%= name.constant %>_VERSION', '<%= answers.pluginVersion %>' );
|
|
30
|
+
define( '<%= name.constant %>_SLUG', '<%= name.slug %>' );
|
|
31
|
+
define( '<%= name.constant %>_SLUG_SHORT', '<%= nameNoAirfleet.slug %>' );
|
|
32
|
+
define( '<%= name.constant %>_TITLE', '<%= name.title %>' );
|
|
33
|
+
define( '<%= name.constant %>_TITLE_SHORT', '<%= nameNoAirfleet.title %>' );
|
|
31
34
|
define( '<%= name.constant %>_PATH', plugin_dir_path( __FILE__ ) );
|
|
32
35
|
define( '<%= name.constant %>_URL', plugin_dir_url( __FILE__ ) );
|
|
36
|
+
define( '<%= name.constant %>_FILE', __FILE__ );
|
|
37
|
+
define( '<%= name.constant %>_DIR', __DIR__ );
|
|
38
|
+
define( '<%= name.constant %>_IMAGES_OPTIONS_URL', <%= name.constant %>_URL . '/assets/admin/images/options' );
|
|
33
39
|
|
|
34
40
|
// Autoload classes.
|
|
35
41
|
require_once __DIR__ . '/vendor/autoload.php';
|
|
42
|
+
require_once __DIR__ . '/vendor-scoped/scoper-autoload.php';
|
|
36
43
|
|
|
37
44
|
// Initialize plugin.
|
|
38
|
-
$<%= name.snake %> = new \Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Setup(
|
|
45
|
+
$<%= name.snake %> = new \Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Setup(
|
|
46
|
+
[
|
|
47
|
+
'slug' => \<%= name.constant %>_SLUG,
|
|
48
|
+
'short_slug' => \<%= name.constant %>_SLUG_SHORT,
|
|
49
|
+
'title' => \<%= name.constant %>_TITLE,
|
|
50
|
+
'short_title' => \<%= name.constant %>_TITLE_SHORT,
|
|
51
|
+
'url' => \<%= name.constant %>_URL,
|
|
52
|
+
'path' => \<%= name.constant %>_PATH,
|
|
53
|
+
'version' => \<%= name.constant %>_VERSION,
|
|
54
|
+
]
|
|
55
|
+
);
|
|
56
|
+
register_activation_hook( __FILE__, [ $<%= name.snake %>, 'on_activation' ] );
|
|
57
|
+
register_deactivation_hook( __FILE__, [ $<%= name.snake %>, 'on_deactivation' ] );
|
|
58
|
+
register_uninstall_hook( __FILE__, [ '\Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Setup', 'uninstall' ] );
|
|
39
59
|
$<%= name.snake %>->initialize();
|
|
40
60
|
|
|
41
61
|
/**
|