@airfleet/generator-init 0.5.1 → 0.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.
@@ -9,3 +9,4 @@
9
9
  *.css eol=lf
10
10
  *.scss eol=lf
11
11
  *.php eol=lf
12
+ *.xml eol=lf
@@ -19,7 +19,6 @@
19
19
  "type": "git",
20
20
  "url": "<%= answers.npmRepository %>"
21
21
  },
22
- "type": "module",
23
22
  "engines": {
24
23
  "node": "<%- answers.npmNodeVersion %>"
25
24
  },
@@ -109,15 +109,23 @@ 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
+ "assets/scripts/index.js",
116
+ "assets/styles/index.scss",
117
+ "inc/Setup.php.ejs",
112
118
  ".airfleet-release",
113
119
  ".editorconfig",
114
120
  ".gitattributes",
115
121
  ".gitlab-ci.yml",
122
+ ".prettierignore",
116
123
  "CHANGELOG.md",
117
124
  "composer.json.ejs",
118
125
  "index.php",
119
126
  "LICENSE.ejs",
120
127
  "package.json.ejs",
128
+ "phpcs.xml.ejs",
121
129
  "README.md.ejs",
122
130
  ];
123
131
  const templates = [
@@ -132,11 +140,6 @@ export default class extends Generator {
132
140
  destination: `${this.name.slug}.php`,
133
141
  isEnabled: true,
134
142
  },
135
- {
136
- template: "src/Plugin.php.ejs",
137
- destination: `src/${this.nameNoAirfleet.pascal}.php`,
138
- isEnabled: true,
139
- },
140
143
  ];
141
144
 
142
145
  copyTemplates(this, templates, this.data);
@@ -9,3 +9,4 @@
9
9
  *.css eol=lf
10
10
  *.scss eol=lf
11
11
  *.php eol=lf
12
+ *.xml eol=lf
@@ -3,6 +3,6 @@ stages:
3
3
 
4
4
  include:
5
5
  # Release process
6
- - project: 'codersclan/tools/gitlab-ci-templates'
6
+ - project: "codersclan/tools/gitlab-ci-templates"
7
7
  ref: main
8
- file: '/release/wp-plugin.yaml'
8
+ file: "/release/wp-plugin.yaml"
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ . "$(dirname "$0")/_/husky.sh"
3
+
4
+ npx lint-staged
@@ -0,0 +1,12 @@
1
+ node_modules
2
+ coverage
3
+ .npmrc
4
+ vendor
5
+ dist
6
+ .parcel-cache
7
+ .eslintcache
8
+ .stylelintcache
9
+ .phpcscache
10
+ .composer-cache
11
+ acf-json
12
+ CHANGELOG.md
@@ -0,0 +1,10 @@
1
+ {
2
+ "editor.codeActionsOnSave": {
3
+ "source.fixAll": true
4
+ },
5
+ "editor.formatOnSave": true,
6
+ "stylelint.validate": ["css", "scss", "postcss"],
7
+ "[php]": {
8
+ "editor.formatOnSave": false
9
+ }
10
+ }
@@ -0,0 +1 @@
1
+ /* eslint-disable unicorn/no-empty-file */
@@ -2,18 +2,37 @@
2
2
  "name": "airfleet/<%= name.slug %>",
3
3
  "type": "wordpress-plugin",
4
4
  "authors": [
5
- {
6
- "name": "Airfleet",
7
- "email": "dev@airfleet.co"
8
- }
5
+ {
6
+ "name": "Airfleet",
7
+ "email": "dev@airfleet.co"
8
+ }
9
9
  ],
10
10
  "require": {
11
- "php": "<%- answers.pluginPhpVersion %>",
12
- "composer/installers": "^2.0"
11
+ "php": "<%- answers.pluginPhpVersion %>",
12
+ "composer/installers": "^2.0"
13
+ },
14
+ "require-dev": {
15
+ "airfleet/wordpress-dev": "^1.0"
13
16
  },
14
17
  "autoload": {
15
- "psr-4": {
16
- "Airfleet\\Plugins\\": "src/"
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
  }
@@ -2,3 +2,9 @@ node_modules
2
2
  coverage
3
3
  .npmrc
4
4
  vendor
5
+ dist
6
+ .parcel-cache
7
+ .eslintcache
8
+ .stylelintcache
9
+ .phpcscache
10
+ .composer-cache
@@ -0,0 +1,43 @@
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() {
13
+ <%_ if (answers.pluginCreateOptions) { _%>
14
+ add_action( 'acf/init', [ $this, 'add_option_pages' ] );
15
+ <%_ } _%>
16
+ }
17
+ <%_ if (answers.pluginCreateOptions) {%>
18
+ /**
19
+ * Add theme options pages.
20
+ *
21
+ * @return void
22
+ */
23
+ public function add_option_pages() {
24
+ if ( ! function_exists( 'acf_add_options_page' ) ) {
25
+ return;
26
+ }
27
+ acf_add_options_page(
28
+ [
29
+ 'page_title' => __( 'Airfleet Theme Settings', 'airfleet' ),
30
+ 'menu_title' => __( 'Airfleet', 'airfleet' ),
31
+ 'menu_slug' => 'airfleet-settings',
32
+ ]
33
+ );
34
+ acf_add_options_sub_page(
35
+ [
36
+ 'page_title' => __( '<%= name.title %> Settings', '<%= name.slug %>' ),
37
+ 'menu_title' => __( '<%= nameNoAirfleet.title %>', '<%= name.slug %>' ),
38
+ 'parent_slug' => 'airfleet-settings',
39
+ ]
40
+ );
41
+ }
42
+ <% } _%>
43
+ }
@@ -3,7 +3,24 @@
3
3
  "description": "<%= answers.pluginDescription %>",
4
4
  "version": "<%= answers.pluginVersion %>",
5
5
  "scripts": {
6
- "build": "echo Done"
6
+ "build": "echo Done",
7
+ "base:eslint": "eslint assets/scripts --ext .js,.jsx --cache --ignore-path .gitignore",
8
+ "base:prettier": "prettier \"**/*.{js,jsx,ts,tsx,json,css,scss,xml,yaml,yml,md}\"",
9
+ "base:stylelint": "stylelint \"**/*.{css,scss}\" --cache --ignore-path .gitignore",
10
+ "lint": "run-s --continue-on-error lint:*",
11
+ "lint:prettier": "npm run base:prettier -- --check",
12
+ "lint:eslint": "npm run base:eslint",
13
+ "lint:stylelint": "npm run base:stylelint",
14
+ "lint:phpcs": "composer run lint",
15
+ "fix": "run-s fix:*",
16
+ "fix:prettier": "npm run base:prettier -- --write",
17
+ "fix:eslint": "npm run base:eslint -- --fix",
18
+ "fix:stylelint": "npm run base:stylelint -- --fix",
19
+ "fix:phpcs": "composer run fix",
20
+ "pretest": "npm run lint",
21
+ "test": "echo Testing done",
22
+ "prepare": "husky install",
23
+ "cz": "git-cz"
7
24
  },
8
25
  "private": true,
9
26
  "keywords": [
@@ -19,9 +36,42 @@
19
36
  "type": "git",
20
37
  "url": "<%= answers.pluginRepository %>"
21
38
  },
22
- "type": "module",
23
39
  "engines": {
24
40
  "node": "<%- answers.pluginNodeVersion %>"
25
41
  },
26
- "dependencies": {}
42
+ "dependencies": {},
43
+ "devDependencies": {
44
+ "@airfleet/wordpress-dev": "^0.2.0"
45
+ },
46
+ "browserslist": [
47
+ "defaults",
48
+ "not IE 11",
49
+ "not op_mini all"
50
+ ],
51
+ "prettier": "@airfleet/prettier-config-wordpress",
52
+ "stylelint": {
53
+ "extends": [
54
+ "@airfleet/stylelint-config-wordpress"
55
+ ]
56
+ },
57
+ "eslintConfig": {
58
+ "extends": [
59
+ "@airfleet/eslint-config-wordpress",
60
+ "plugin:no-jquery/all"
61
+ ]
62
+ },
63
+ "lint-staged": {
64
+ "*.{js,jsx,ts,tsx,json,css,scss,xml,yaml,yml,md}": "prettier --write",
65
+ "*.{js,jsx}": "eslint --cache --ignore-path .gitignore --fix",
66
+ "*.{css,scss}": "stylelint --cache --ignore-path .gitignore --fix",
67
+ "*.php": [
68
+ "composer run fix",
69
+ "composer run lint"
70
+ ]
71
+ },
72
+ "config": {
73
+ "commitizen": {
74
+ "path": "./node_modules/cz-conventional-changelog"
75
+ }
76
+ }
27
77
  }
@@ -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,7 +23,7 @@
23
23
 
24
24
  // Exit if accessed directly.
25
25
  if ( ! defined( 'ABSPATH' ) ) {
26
- die;
26
+ die;
27
27
  }
28
28
 
29
29
  // Plugin version.
@@ -33,8 +33,8 @@ define( '<%= name.constant %>_VERSION', '<%= answers.pluginVersion %>' );
33
33
  require_once __DIR__ . '/vendor/autoload.php';
34
34
 
35
35
  // Initialize plugin.
36
- $plugin = new \Airfleet\Plugins\<%= nameNoAirfleet.pascal %>();
37
- $plugin->initialize();
36
+ $<%= name.snake %> = new \Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Setup();
37
+ $<%= name.snake %>->initialize();
38
38
 
39
39
  /**
40
40
  * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@airfleet/generator-init",
3
3
  "description": "A Yeoman generator to scaffold common Airfleet features",
4
- "version": "0.5.1",
4
+ "version": "0.6.0",
5
5
  "scripts": {},
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -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
- }