@airfleet/generator-init 0.17.6 → 0.18.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.
@@ -10,6 +10,7 @@ import title from "../../utils/log/title.js";
10
10
  import highlightText from "../../utils/log/text/highlightText.js";
11
11
  import lines from "../../utils/log/text/lines.js";
12
12
  import infoBox from "../../utils/log/boxes/infoBox.js";
13
+ import getViewsPrefix from "../../utils/getViewsPrefix.js";
13
14
 
14
15
  export default class extends Generator {
15
16
  async prompting() {
@@ -33,6 +34,11 @@ export default class extends Generator {
33
34
  ])
34
35
  );
35
36
 
37
+ const viewsPrefixOptions = {
38
+ none: "None",
39
+ elements: "Elements",
40
+ pluginSlug: "Use plugin short slug",
41
+ };
36
42
  const prompts = [
37
43
  {
38
44
  type: "input",
@@ -80,6 +86,14 @@ export default class extends Generator {
80
86
  validate: requiredText("Please enter the Node version"),
81
87
  default: ">=16",
82
88
  },
89
+ {
90
+ type: "list",
91
+ name: "viewsPrefix",
92
+ message:
93
+ "Views prefix?",
94
+ choices: [viewsPrefixOptions.none, viewsPrefixOptions.elements, viewsPrefixOptions.pluginSlug],
95
+ default: viewsPrefixOptions.elements,
96
+ },
83
97
  {
84
98
  type: "list",
85
99
  name: "pluginCreateOptions",
@@ -114,6 +128,7 @@ export default class extends Generator {
114
128
  .replace(/^airfleet/i, "")
115
129
  .trim();
116
130
  this.nameNoAirfleet = nameCases(nameNoAirfleet);
131
+ this.viewsPrefix = getViewsPrefix(this.answers, viewsPrefixOptions, this.nameNoAirfleet);
117
132
  this.data = {
118
133
  answers: this.answers,
119
134
  name: this.name,
@@ -124,6 +139,7 @@ export default class extends Generator {
124
139
  year: new Date().getFullYear(),
125
140
  ajaxVariables: this.ajaxVariables,
126
141
  optionsPage: this.optionsPage,
142
+ viewsPrefix: this.viewsPrefix,
127
143
  };
128
144
  }
129
145
 
@@ -145,6 +161,7 @@ export default class extends Generator {
145
161
  "assets/frontend/scripts/index.entry.js",
146
162
  "assets/frontend/styles/critical.entry.scss",
147
163
  "assets/frontend/styles/index.entry.scss",
164
+ "inc/RegisterViews.php.ejs",
148
165
  "inc/Setup.php.ejs",
149
166
  "views/parcelkeep.entry.scss",
150
167
  ".airfleet-release",
@@ -12,7 +12,7 @@
12
12
  "composer/installers": "^2.0"
13
13
  },
14
14
  "require-dev": {
15
- "airfleet/wordpress-dev": "^3.0.2",
15
+ "airfleet/wordpress-dev": "^3.0.3",
16
16
  "wpify/scoper": "2.5.4"
17
17
  },
18
18
  "autoload": {
@@ -0,0 +1,37 @@
1
+ <?php
2
+
3
+ namespace Airfleet\Plugins\<%= nameNoAirfleet.pascal %>;
4
+
5
+ use Airfleet\Plugins\<%= nameNoAirfleet.pascal %>\Vendor\Airfleet\Framework\Features\BasePluginFeature;
6
+
7
+ class RegisterViews extends BasePluginFeature {
8
+ public function initialize(): void {
9
+ add_filter(
10
+ 'airfleet/views/config',
11
+ function ( array $views ): array {
12
+ $views[] = [
13
+ 'namespace' => 'Airfleet\\Plugins\\<%= nameNoAirfleet.pascal %>\\Views',
14
+ 'path' => \<%= name.constant %>_PATH . DIRECTORY_SEPARATOR . 'views',
15
+ 'version' => \<%= name.constant %>_VERSION,
16
+ 'url' => \<%= name.constant %>_URL . '/views',
17
+ 'source' => \<%= name.constant %>_SLUG,
18
+ 'prefix' => '<%= viewsPrefix %>',
19
+ 'priority' => 10,
20
+ ];
21
+
22
+ // Register dist folder for compiled assets
23
+ $views[] = [
24
+ 'namespace' => 'Airfleet\\Plugins\\<%= nameNoAirfleet.pascal %>\\Views',
25
+ 'path' => \<%= name.constant %>_PATH . DIRECTORY_SEPARATOR . 'dist' . DIRECTORY_SEPARATOR . 'views',
26
+ 'version' => \<%= name.constant %>_VERSION,
27
+ 'url' => \<%= name.constant %>_URL . '/dist/views',
28
+ 'source' => \<%= name.constant %>_SLUG,
29
+ 'prefix' => '<%= viewsPrefix %>',
30
+ 'priority' => 10,
31
+ ];
32
+
33
+ return $views;
34
+ }
35
+ );
36
+ }
37
+ }
@@ -23,6 +23,7 @@ class Setup extends PluginFeatures {
23
23
  parent::__construct(
24
24
  [
25
25
  new Enqueue( $config ),
26
+ new RegisterViews(),
26
27
  <%_ if (optionsPage === 'framework' ) { _%>
27
28
  new Pages( $options ),
28
29
  new SettingsLink( $config ),
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.17.6",
4
+ "version": "0.18.0",
5
5
  "scripts": {},
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -0,0 +1,10 @@
1
+ export default function getViewsPrefix(answers, options, nameNoAirfleet) {
2
+ switch(answers.viewsPrefix) {
3
+ case options.none:
4
+ return '';
5
+ case options.pluginSlug:
6
+ return nameNoAirfleet.slug;
7
+ default:
8
+ return (options[answers.viewsPrefix] || answers.viewsPrefix).toLowerCase();
9
+ }
10
+ }