@airfleet/generator-init 0.5.0 → 0.8.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.
Files changed (27) hide show
  1. package/generators/npm/index.js +8 -2
  2. package/generators/npm/templates/.gitattributes +1 -0
  3. package/generators/npm/templates/gitignore +3 -0
  4. package/generators/npm/templates/package.json.ejs +0 -1
  5. package/generators/plugin/index.js +18 -5
  6. package/generators/plugin/templates/.env +0 -0
  7. package/generators/plugin/templates/.gitattributes +1 -0
  8. package/generators/plugin/templates/.gitlab-ci.yml +7 -2
  9. package/generators/plugin/templates/.husky/pre-commit +4 -0
  10. package/generators/plugin/templates/.parcelrc +4 -0
  11. package/generators/plugin/templates/.prettierignore +12 -0
  12. package/generators/plugin/templates/.vscode/settings.json +10 -0
  13. package/generators/plugin/templates/assets/admin/scripts/admin.entry.js +1 -0
  14. package/generators/plugin/templates/assets/admin/styles/admin.scss +0 -0
  15. package/generators/plugin/templates/assets/frontend/fonts/.gitkeep +0 -0
  16. package/generators/plugin/templates/assets/frontend/images/.gitkeep +0 -0
  17. package/generators/plugin/templates/assets/frontend/scripts/index.entry.js +5 -0
  18. package/generators/plugin/templates/assets/frontend/styles/index.scss +0 -0
  19. package/generators/plugin/templates/composer.json.ejs +28 -9
  20. package/generators/plugin/templates/gitignore +11 -0
  21. package/generators/plugin/templates/inc/Setup.php.ejs +92 -0
  22. package/generators/plugin/templates/package.json.ejs +54 -3
  23. package/generators/plugin/templates/phpcs.xml.ejs +33 -0
  24. package/generators/plugin/templates/plugin-name.php.ejs +3 -3
  25. package/package.json +1 -1
  26. package/utils/nameCases.js +4 -1
  27. package/generators/plugin/templates/src/Plugin.php.ejs +0 -45
@@ -96,14 +96,20 @@ export default class extends Generator {
96
96
  ".airfleet-release",
97
97
  ".editorconfig",
98
98
  ".gitattributes",
99
- ".gitignore",
100
99
  ".gitlab-ci.yml",
101
100
  "CHANGELOG.md",
102
101
  "LICENSE.ejs",
103
102
  "package.json.ejs",
104
103
  "README.md.ejs",
105
104
  ];
106
- const templates = mapFilesToTemplates(files);
105
+ const templates = [
106
+ ...mapFilesToTemplates(files),
107
+ {
108
+ template: "gitignore",
109
+ destination: `.gitignore`,
110
+ isEnabled: true,
111
+ },
112
+ ];
107
113
 
108
114
  copyTemplates(this, templates, this.data);
109
115
  }
@@ -9,3 +9,4 @@
9
9
  *.css eol=lf
10
10
  *.scss eol=lf
11
11
  *.php eol=lf
12
+ *.xml eol=lf
@@ -0,0 +1,3 @@
1
+ node_modules
2
+ coverage
3
+ .npmrc
@@ -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,28 +109,41 @@ 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/admin/scripts/admin.entry.js",
116
+ "assets/admin/styles/admin.scss",
117
+ "assets/frontend/fonts/.gitkeep",
118
+ "assets/frontend/images/.gitkeep",
119
+ "assets/frontend/scripts/index.entry.js",
120
+ "assets/frontend/styles/index.scss",
121
+ "inc/Setup.php.ejs",
112
122
  ".airfleet-release",
113
123
  ".editorconfig",
124
+ ".env",
114
125
  ".gitattributes",
115
- ".gitignore",
116
126
  ".gitlab-ci.yml",
127
+ ".parcelrc",
128
+ ".prettierignore",
117
129
  "CHANGELOG.md",
118
130
  "composer.json.ejs",
119
131
  "index.php",
120
132
  "LICENSE.ejs",
121
133
  "package.json.ejs",
134
+ "phpcs.xml.ejs",
122
135
  "README.md.ejs",
123
136
  ];
124
137
  const templates = [
125
138
  ...mapFilesToTemplates(files),
126
139
  {
127
- template: "plugin-name.php.ejs",
128
- destination: `${this.name.slug}.php`,
140
+ template: "gitignore",
141
+ destination: `.gitignore`,
129
142
  isEnabled: true,
130
143
  },
131
144
  {
132
- template: "src/Plugin.php.ejs",
133
- destination: `src/${this.nameNoAirfleet.pascal}.php`,
145
+ template: "plugin-name.php.ejs",
146
+ destination: `${this.name.slug}.php`,
134
147
  isEnabled: true,
135
148
  },
136
149
  ];
File without changes
@@ -9,3 +9,4 @@
9
9
  *.css eol=lf
10
10
  *.scss eol=lf
11
11
  *.php eol=lf
12
+ *.xml eol=lf
@@ -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: 'codersclan/tools/gitlab-ci-templates'
11
+ - project: "codersclan/tools/gitlab-ci-templates"
7
12
  ref: main
8
- file: '/release/wp-plugin.yaml'
13
+ 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,4 @@
1
+ {
2
+ "extends": "@parcel/config-default",
3
+ "reporters": ["...", "parcel-reporter-bundle-manifest"]
4
+ }
@@ -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
+ import "../styles/admin.scss";
@@ -0,0 +1,5 @@
1
+ import "../styles/index.scss";
2
+
3
+ if (module.hot) {
4
+ module.hot.accept();
5
+ }
@@ -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
  }
@@ -0,0 +1,11 @@
1
+ node_modules
2
+ coverage
3
+ .npmrc
4
+ vendor
5
+ dist
6
+ .parcel-cache
7
+ .eslintcache
8
+ .stylelintcache
9
+ .phpcscache
10
+ .composer-cache
11
+ .env
@@ -0,0 +1,92 @@
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
+ $this->add_option_pages();
15
+ <%_ } _%>
16
+ $this->enqueue();
17
+ }
18
+
19
+ /**
20
+ * Enqueue the scripts and styles.
21
+ *
22
+ * @return void
23
+ */
24
+ public function enqueue() {
25
+ $version = <%= name.constant %>_VERSION;
26
+
27
+ add_action(
28
+ 'wp_enqueue_scripts',
29
+ function () use ( $version ) {
30
+ wp_enqueue_style(
31
+ '<%= name.slug %>-styles',
32
+ plugins_url( '/dist/frontend/scripts/index.entry.css', __DIR__ ),
33
+ [],
34
+ $version
35
+ );
36
+ wp_enqueue_script(
37
+ '<%= name.slug %>-scripts',
38
+ plugins_url( '/dist/frontend/scripts/index.entry.js', __DIR__ ),
39
+ [],
40
+ $version,
41
+ true
42
+ );
43
+ }
44
+ );
45
+ add_action(
46
+ 'admin_enqueue_scripts',
47
+ function () use ( $version ) {
48
+ wp_enqueue_style(
49
+ '<%= name.slug %>-admin-styles',
50
+ plugins_url( '/dist/admin/scripts/admin.entry.css', __DIR__ ),
51
+ [],
52
+ $version
53
+ );
54
+ wp_enqueue_script(
55
+ '<%= name.slug %>-admin-scripts',
56
+ plugins_url( '/dist/admin/scripts/admin.entry.js', __DIR__ ),
57
+ [],
58
+ $version,
59
+ true
60
+ );
61
+ }
62
+ );
63
+ }
64
+ <%_ if (answers.pluginCreateOptions) {%>
65
+ /**
66
+ * Add theme options pages.
67
+ *
68
+ * @return void
69
+ */
70
+ public function add_option_pages() {
71
+ add_action(
72
+ 'acf/init',
73
+ function () {
74
+ \acf_add_options_page(
75
+ [
76
+ 'page_title' => __( 'Airfleet Theme Settings', 'airfleet' ),
77
+ 'menu_title' => __( 'Airfleet', 'airfleet' ),
78
+ 'menu_slug' => 'airfleet-settings',
79
+ ]
80
+ );
81
+ \acf_add_options_sub_page(
82
+ [
83
+ 'page_title' => __( '<%= name.title %> Settings', '<%= name.slug %>' ),
84
+ 'menu_title' => __( '<%= nameNoAirfleet.title %>', '<%= name.slug %>' ),
85
+ 'parent_slug' => 'airfleet-settings',
86
+ ]
87
+ );
88
+ }
89
+ );
90
+ }
91
+ <% } _%>
92
+ }
@@ -3,7 +3,25 @@
3
3
  "description": "<%= answers.pluginDescription %>",
4
4
  "version": "<%= answers.pluginVersion %>",
5
5
  "scripts": {
6
- "build": "echo Done"
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,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.0",
4
+ "version": "0.8.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
- }