@airfleet/generator-init 0.1.0 → 0.2.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 +8 -0
- package/generators/app/index.js +5 -0
- package/generators/block/index.js +115 -0
- package/generators/block/templates/acf/group.json.ejs +23 -0
- package/generators/block/templates/block.blade.php.ejs +8 -0
- package/generators/block/templates/composer.php.ejs +16 -0
- package/generators/block/templates/scripts/block.js.ejs +9 -0
- package/generators/block/templates/styles/_block.scss.ejs +3 -0
- package/generators/block/templates/styles/index.scss.ejs +1 -0
- package/generators/component/index.js +14 -14
- package/generators/component/templates/component.blade.php.ejs +2 -2
- package/generators/component/templates/{controller.php.ejs → composer.php.ejs} +0 -0
- package/generators/component/templates/scripts/component.js.ejs +1 -1
- package/generators/component/templates/styles/_component.scss.ejs +1 -1
- package/package.json +3 -3
- package/utils/log/boxes/infoBox.js +9 -0
- package/utils/log/themeFeature.js +0 -2
package/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# Airfleet Generator
|
|
2
2
|
|
|
3
|
+

|
|
4
|
+
[](https://gitlab.com/codersclan/tools/airfleet-generator/-/commits/main)
|
|
5
|
+
|
|
3
6
|
A Yeoman generator to scaffold common Airfleet features.
|
|
4
7
|
|
|
5
8
|
## Requirements
|
|
@@ -17,8 +20,13 @@ npm install -g @airfleet/generator-init
|
|
|
17
20
|
|
|
18
21
|
| Generator | Command | Description |
|
|
19
22
|
| --------- | ------------------------------------- | ----------------------------------------- |
|
|
23
|
+
| Block | `yo @airfleet/init:block --force` | Create a block for the Airfleet Theme |
|
|
20
24
|
| Component | `yo @airfleet/init:component --force` | Create a component for the Airfleet Theme |
|
|
21
25
|
|
|
26
|
+
## Documentation
|
|
27
|
+
|
|
28
|
+
- [Documentation](https://www.notion.so/codersclan/Airfleet-Generator-cb340bfda8354ec9a2d1ddebfac58795).
|
|
29
|
+
|
|
22
30
|
## License
|
|
23
31
|
|
|
24
32
|
© [Airfleet](https://www.airfleet.co/)
|
package/generators/app/index.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import Generator from "yeoman-generator";
|
|
3
|
+
import chalk from "chalk";
|
|
3
4
|
|
|
4
5
|
import title from "../../utils/log/title.js";
|
|
6
|
+
import infoBox from "../../utils/log/boxes/infoBox.js";
|
|
5
7
|
|
|
6
8
|
export default class extends Generator {
|
|
7
9
|
async prompting() {
|
|
8
10
|
this.log(title("Hi! Please run one of the available sub-generators."));
|
|
11
|
+
this.log(
|
|
12
|
+
infoBox(`Read the documentation at ${chalk.blue("https://bit.ly/3DyMMC5")}`)
|
|
13
|
+
);
|
|
9
14
|
}
|
|
10
15
|
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
import Generator from "yeoman-generator";
|
|
3
|
+
|
|
4
|
+
import themeFeature from "../../utils/log/themeFeature.js";
|
|
5
|
+
import nameCases from "../../utils/nameCases.js";
|
|
6
|
+
import copyTemplates from "../../utils/copyTemplates.js";
|
|
7
|
+
import appendTemplates from "../../utils/appendTemplates.js";
|
|
8
|
+
import addThemeScript from "../../utils/codemod/addThemeScript.js";
|
|
9
|
+
import requiredText from "../../utils/validation/requiredText.js";
|
|
10
|
+
import acfData from "../../utils/acfData.js";
|
|
11
|
+
|
|
12
|
+
export default class extends Generator {
|
|
13
|
+
async prompting() {
|
|
14
|
+
this.log(themeFeature("Block"));
|
|
15
|
+
|
|
16
|
+
const prompts = [
|
|
17
|
+
{
|
|
18
|
+
type: "input",
|
|
19
|
+
name: "blockName",
|
|
20
|
+
message: "What is the name of the block?",
|
|
21
|
+
validate: requiredText("Please enter a name"),
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: "input",
|
|
25
|
+
name: "blockDescription",
|
|
26
|
+
message: "How would you describe the block?",
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: "confirm",
|
|
30
|
+
name: "createBlockComposer",
|
|
31
|
+
message: "Create composer (controller)?",
|
|
32
|
+
default: true,
|
|
33
|
+
store: true,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
type: "confirm",
|
|
37
|
+
name: "createBlockStyles",
|
|
38
|
+
message: "Create SCSS stylesheet?",
|
|
39
|
+
default: true,
|
|
40
|
+
store: true,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
type: "confirm",
|
|
44
|
+
name: "createBlockScript",
|
|
45
|
+
message: "Create JavaScript file?",
|
|
46
|
+
default: false,
|
|
47
|
+
store: true,
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
type: "confirm",
|
|
51
|
+
name: "createBlockAcf",
|
|
52
|
+
message: "Create custom fields?",
|
|
53
|
+
default: false,
|
|
54
|
+
store: true,
|
|
55
|
+
},
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
this.answers = await this.prompt(prompts);
|
|
59
|
+
this.name = nameCases(this.answers.blockName);
|
|
60
|
+
this.acf = acfData({ prefix: "group_" });
|
|
61
|
+
this.data = {
|
|
62
|
+
answers: this.answers,
|
|
63
|
+
name: this.name,
|
|
64
|
+
acf: this.acf,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
writing() {
|
|
69
|
+
const templates = [
|
|
70
|
+
{
|
|
71
|
+
template: "block.blade.php.ejs",
|
|
72
|
+
destination: `theme/blocks/${this.name.slug}.blade.php`,
|
|
73
|
+
isEnabled: true,
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
template: "composer.php.ejs",
|
|
77
|
+
destination: `app/src/Blocks/${this.name.pascal}Block.php`,
|
|
78
|
+
isEnabled: this.answers.createBlockComposer,
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
template: "styles/_block.scss.ejs",
|
|
82
|
+
destination: `resources/styles/theme/blocks/_${this.name.slug}.scss`,
|
|
83
|
+
isEnabled: this.answers.createBlockStyles,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
template: "scripts/block.js.ejs",
|
|
87
|
+
destination: `resources/scripts/theme/blocks/${this.name.camel}.js`,
|
|
88
|
+
isEnabled: this.answers.createBlockScript,
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
template: "acf/group.json.ejs",
|
|
92
|
+
destination: `theme/acf-json/${this.acf.key}.json`,
|
|
93
|
+
isEnabled: this.answers.createBlockAcf,
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
const appends = [
|
|
97
|
+
{
|
|
98
|
+
template: "styles/index.scss.ejs",
|
|
99
|
+
destination: "resources/styles/theme/blocks/index.scss",
|
|
100
|
+
isEnabled: this.answers.createBlockStyles,
|
|
101
|
+
},
|
|
102
|
+
];
|
|
103
|
+
|
|
104
|
+
copyTemplates(this, templates, this.data);
|
|
105
|
+
appendTemplates(this, appends, this.data);
|
|
106
|
+
|
|
107
|
+
if (this.answers.createBlockScript) {
|
|
108
|
+
addThemeScript(this, {
|
|
109
|
+
indexPath: "resources/scripts/theme/index.js",
|
|
110
|
+
importName: this.name.pascal,
|
|
111
|
+
importPath: `./blocks/${this.name.camel}`,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"key": "<%= acf.key %>",
|
|
3
|
+
"title": "Block: <%= name.title %>",
|
|
4
|
+
"fields": [],
|
|
5
|
+
"location": [
|
|
6
|
+
[
|
|
7
|
+
{
|
|
8
|
+
"param": "block",
|
|
9
|
+
"operator": "==",
|
|
10
|
+
"value": "acf\/<%= name.slug %>"
|
|
11
|
+
}
|
|
12
|
+
]
|
|
13
|
+
],
|
|
14
|
+
"menu_order": 0,
|
|
15
|
+
"position": "normal",
|
|
16
|
+
"style": "default",
|
|
17
|
+
"label_placement": "top",
|
|
18
|
+
"instruction_placement": "label",
|
|
19
|
+
"hide_on_screen": "",
|
|
20
|
+
"active": 1,
|
|
21
|
+
"description": "",
|
|
22
|
+
"modified": <%= acf.timestamp %>
|
|
23
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
|
|
3
|
+
namespace App\Blocks;
|
|
4
|
+
|
|
5
|
+
class <%= name.pascal %>Block implements \App\Core\BlockComposer {
|
|
6
|
+
public function __construct( $context ) {
|
|
7
|
+
$this->context = $context;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public function get_context( $context ) {
|
|
11
|
+
return af_defaults(
|
|
12
|
+
[],
|
|
13
|
+
$context
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
@import '<%= name.slug %>';
|
|
@@ -16,34 +16,34 @@ export default class extends Generator {
|
|
|
16
16
|
const prompts = [
|
|
17
17
|
{
|
|
18
18
|
type: "input",
|
|
19
|
-
name: "
|
|
19
|
+
name: "componentName",
|
|
20
20
|
message: "What is the name of the component?",
|
|
21
21
|
validate: requiredText("Please enter a name"),
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
type: "confirm",
|
|
25
|
-
name: "
|
|
25
|
+
name: "createComponentComposer",
|
|
26
26
|
message: "Create composer (controller)?",
|
|
27
27
|
default: true,
|
|
28
28
|
store: true,
|
|
29
29
|
},
|
|
30
30
|
{
|
|
31
31
|
type: "confirm",
|
|
32
|
-
name: "
|
|
32
|
+
name: "createComponentStyles",
|
|
33
33
|
message: "Create SCSS stylesheet?",
|
|
34
34
|
default: true,
|
|
35
35
|
store: true,
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
type: "confirm",
|
|
39
|
-
name: "
|
|
39
|
+
name: "createComponentScript",
|
|
40
40
|
message: "Create JavaScript file?",
|
|
41
41
|
default: false,
|
|
42
42
|
store: true,
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
45
|
type: "confirm",
|
|
46
|
-
name: "
|
|
46
|
+
name: "createComponentAcf",
|
|
47
47
|
message: "Create custom fields?",
|
|
48
48
|
default: false,
|
|
49
49
|
store: true,
|
|
@@ -51,8 +51,8 @@ export default class extends Generator {
|
|
|
51
51
|
];
|
|
52
52
|
|
|
53
53
|
this.answers = await this.prompt(prompts);
|
|
54
|
-
this.name = nameCases(this.answers.
|
|
55
|
-
this.acf = acfData({ prefix: "group_" })
|
|
54
|
+
this.name = nameCases(this.answers.componentName);
|
|
55
|
+
this.acf = acfData({ prefix: "group_" });
|
|
56
56
|
this.data = {
|
|
57
57
|
answers: this.answers,
|
|
58
58
|
name: this.name,
|
|
@@ -68,38 +68,38 @@ export default class extends Generator {
|
|
|
68
68
|
isEnabled: true,
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
|
-
template: "
|
|
71
|
+
template: "composer.php.ejs",
|
|
72
72
|
destination: `app/src/Components/${this.name.pascal}Component.php`,
|
|
73
|
-
isEnabled: this.answers.
|
|
73
|
+
isEnabled: this.answers.createComponentComposer,
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
template: "styles/_component.scss.ejs",
|
|
77
77
|
destination: `resources/styles/theme/components/_${this.name.slug}.scss`,
|
|
78
|
-
isEnabled: this.answers.
|
|
78
|
+
isEnabled: this.answers.createComponentStyles,
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
81
|
template: "scripts/component.js.ejs",
|
|
82
82
|
destination: `resources/scripts/theme/components/${this.name.camel}.js`,
|
|
83
|
-
isEnabled: this.answers.
|
|
83
|
+
isEnabled: this.answers.createComponentScript,
|
|
84
84
|
},
|
|
85
85
|
{
|
|
86
86
|
template: "acf/group.json.ejs",
|
|
87
87
|
destination: `theme/acf-json/${this.acf.key}.json`,
|
|
88
|
-
isEnabled: this.answers.
|
|
88
|
+
isEnabled: this.answers.createComponentAcf,
|
|
89
89
|
},
|
|
90
90
|
];
|
|
91
91
|
const appends = [
|
|
92
92
|
{
|
|
93
93
|
template: "styles/index.scss.ejs",
|
|
94
94
|
destination: "resources/styles/theme/components/index.scss",
|
|
95
|
-
isEnabled: this.answers.
|
|
95
|
+
isEnabled: this.answers.createComponentStyles,
|
|
96
96
|
},
|
|
97
97
|
];
|
|
98
98
|
|
|
99
99
|
copyTemplates(this, templates, this.data);
|
|
100
100
|
appendTemplates(this, appends, this.data);
|
|
101
101
|
|
|
102
|
-
if (this.answers.
|
|
102
|
+
if (this.answers.createComponentScript) {
|
|
103
103
|
addThemeScript(this, {
|
|
104
104
|
indexPath: "resources/scripts/theme/index.js",
|
|
105
105
|
importName: this.name.pascal,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
<%_ if (answers.
|
|
1
|
+
<%_ if (answers.createComponentAcf) { _%>
|
|
2
2
|
{{--
|
|
3
3
|
Key: <%= acf.key %>
|
|
4
4
|
--}}
|
|
5
5
|
<% } _%>
|
|
6
|
-
<%_ if (!answers.
|
|
6
|
+
<%_ if (!answers.createComponentComposer) { _%>
|
|
7
7
|
@php
|
|
8
8
|
$class = af_value_or_default( $class, '' );
|
|
9
9
|
@endphp
|
|
File without changes
|
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.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"scripts": {},
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"airfleet",
|
|
11
11
|
"yeoman-generator"
|
|
12
12
|
],
|
|
13
|
-
"homepage": "https://www.airfleet.co
|
|
13
|
+
"homepage": "https://www.airfleet.co",
|
|
14
14
|
"author": {
|
|
15
15
|
"name": "Airfleet",
|
|
16
16
|
"email": "dev@airfleet.co",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"utils"
|
|
28
28
|
],
|
|
29
29
|
"engines": {
|
|
30
|
-
"node": ">=
|
|
30
|
+
"node": ">=12"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"boxen": "^6.2.1",
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import title from "./title.js";
|
|
2
2
|
import brandText from "./text/brandText.js";
|
|
3
|
-
import dangerText from "./text/dangerText.js";
|
|
4
3
|
import highlightText from "./text/highlightText.js";
|
|
5
4
|
import lines from "./text/lines.js";
|
|
6
5
|
import dangerBox from "./boxes/dangerBox.js";
|
|
7
|
-
import box from "./boxes/box.js";
|
|
8
6
|
|
|
9
7
|
export default function themeFeature(feature) {
|
|
10
8
|
return lines([
|