@next-core/yo 1.2.7 → 1.3.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-core/yo",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Generator for next v3",
|
|
5
5
|
"homepage": "https://github.com/easyops-cn/next-core/tree/v3/packages/yo",
|
|
6
6
|
"license": "GPL-3.0",
|
|
@@ -24,14 +24,14 @@
|
|
|
24
24
|
"plop": "^3.1.2"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@next-core/build-next-bricks": "^1.
|
|
27
|
+
"@next-core/build-next-bricks": "^1.12.0",
|
|
28
28
|
"@next-core/build-next-libs": "^1.0.5",
|
|
29
|
-
"@next-core/element": "^1.0
|
|
29
|
+
"@next-core/element": "^1.1.0",
|
|
30
30
|
"@next-core/i18n": "^1.0.21",
|
|
31
|
-
"@next-core/react-element": "^1.0.
|
|
31
|
+
"@next-core/react-element": "^1.0.8",
|
|
32
32
|
"@next-core/test-next": "^1.0.6",
|
|
33
33
|
"@next-core/theme": "^1.1.1",
|
|
34
34
|
"react": "0.0.0-experimental-ee8509801-20230117"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "fbd30ceaf3abd9c99c5dc2085a81413c68e367e0"
|
|
37
37
|
}
|
package/src/plopfile.js
CHANGED
|
@@ -7,6 +7,7 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
7
7
|
|
|
8
8
|
const validPkgName = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
|
|
9
9
|
const validBrickName = /^[a-z][a-z0-9]*(-[a-z0-9]+)+$/;
|
|
10
|
+
const validPartialBrickName = validPkgName;
|
|
10
11
|
|
|
11
12
|
const rootDir = process.cwd();
|
|
12
13
|
const bricksDir = path.join(rootDir, "bricks");
|
|
@@ -64,6 +65,25 @@ export default function (
|
|
|
64
65
|
"libDevDependencies",
|
|
65
66
|
getObjectPartialInPackageJson(libDevDependencies)
|
|
66
67
|
);
|
|
68
|
+
plop.setHelper("getTagName", (brickType, pkgName, brickName, lastNameOnly) =>
|
|
69
|
+
brickType === "common"
|
|
70
|
+
? `eo-${brickName}`
|
|
71
|
+
: lastNameOnly
|
|
72
|
+
? brickName
|
|
73
|
+
: `${pkgName}.${brickName}`
|
|
74
|
+
);
|
|
75
|
+
plop.setPartial(
|
|
76
|
+
"tagName",
|
|
77
|
+
"{{getTagName brickType pkgName brickName false}}"
|
|
78
|
+
);
|
|
79
|
+
plop.setPartial(
|
|
80
|
+
"lastTagName",
|
|
81
|
+
"{{getTagName brickType pkgName brickName true}}"
|
|
82
|
+
);
|
|
83
|
+
plop.setPartial(
|
|
84
|
+
"className",
|
|
85
|
+
"{{pascalCase (getTagName brickType pkgName brickName true)}}"
|
|
86
|
+
);
|
|
67
87
|
|
|
68
88
|
// create your generators here
|
|
69
89
|
plop.setGenerator("basics", {
|
|
@@ -153,6 +173,24 @@ export default function (
|
|
|
153
173
|
return true;
|
|
154
174
|
},
|
|
155
175
|
},
|
|
176
|
+
{
|
|
177
|
+
type: "list",
|
|
178
|
+
name: "brickType",
|
|
179
|
+
message: "Select your brick type:",
|
|
180
|
+
when(data) {
|
|
181
|
+
return data.type === "brick";
|
|
182
|
+
},
|
|
183
|
+
choices: [
|
|
184
|
+
{
|
|
185
|
+
name: "Business-specific brick (starts with namespace)",
|
|
186
|
+
value: "specific",
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: "Common brick (starts with `eo-`, no namespace)",
|
|
190
|
+
value: "common",
|
|
191
|
+
},
|
|
192
|
+
],
|
|
193
|
+
},
|
|
156
194
|
{
|
|
157
195
|
type: "input",
|
|
158
196
|
name: "brickName",
|
|
@@ -161,7 +199,13 @@ export default function (
|
|
|
161
199
|
return data.type === "brick";
|
|
162
200
|
},
|
|
163
201
|
validate(value, data) {
|
|
164
|
-
if (
|
|
202
|
+
if (
|
|
203
|
+
!(
|
|
204
|
+
data.brickType === "common"
|
|
205
|
+
? validPartialBrickName
|
|
206
|
+
: validBrickName
|
|
207
|
+
).test(value)
|
|
208
|
+
) {
|
|
165
209
|
return "Please enter a lower-kebab-case brick name.";
|
|
166
210
|
}
|
|
167
211
|
|
|
@@ -171,6 +215,12 @@ export default function (
|
|
|
171
215
|
|
|
172
216
|
return true;
|
|
173
217
|
},
|
|
218
|
+
transformer(input, data) {
|
|
219
|
+
if (data.brickType === "common") {
|
|
220
|
+
return `eo-${input}`;
|
|
221
|
+
}
|
|
222
|
+
return input;
|
|
223
|
+
},
|
|
174
224
|
},
|
|
175
225
|
{
|
|
176
226
|
type: "input",
|
|
@@ -218,7 +268,7 @@ export default function (
|
|
|
218
268
|
},
|
|
219
269
|
{
|
|
220
270
|
type: "add",
|
|
221
|
-
path: "bricks/{{pkgName}}/docs/{{
|
|
271
|
+
path: "bricks/{{pkgName}}/docs/{{>lastTagName}}.md",
|
|
222
272
|
templateFile: "templates/brick.md.hbs",
|
|
223
273
|
},
|
|
224
274
|
];
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { describe, test, expect, jest } from "@jest/globals";
|
|
2
2
|
import { act } from "react-dom/test-utils";
|
|
3
3
|
import "./";
|
|
4
|
-
import { {{
|
|
4
|
+
import { {{>className}} } from "./index.js";
|
|
5
5
|
|
|
6
6
|
jest.mock("@next-core/theme", () => ({}));
|
|
7
7
|
|
|
8
|
-
describe("{{
|
|
8
|
+
describe("{{>tagName}}", () => {
|
|
9
9
|
test("basic usage", async () => {
|
|
10
|
-
const element = document.createElement("{{
|
|
10
|
+
const element = document.createElement("{{>tagName}}") as {{>className}};
|
|
11
11
|
|
|
12
12
|
expect(element.shadowRoot).toBeFalsy();
|
|
13
13
|
|
|
@@ -12,21 +12,21 @@ import styleText from "./styles.shadow.css";
|
|
|
12
12
|
const { defineElement, property } = createDecorators();
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
|
-
* 构件 {{
|
|
15
|
+
* 构件 `{{>tagName}}`
|
|
16
16
|
*/
|
|
17
17
|
export
|
|
18
|
-
@defineElement("{{
|
|
18
|
+
@defineElement("{{>tagName}}", {
|
|
19
19
|
styleTexts: [styleText],
|
|
20
20
|
})
|
|
21
|
-
class {{
|
|
21
|
+
class {{>className}} extends ReactNextElement {
|
|
22
22
|
render() {
|
|
23
23
|
return (
|
|
24
|
-
<{{
|
|
24
|
+
<{{>className}}Component />
|
|
25
25
|
);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export function {{
|
|
29
|
+
export function {{>className}}Component() {
|
|
30
30
|
// const { t } = useTranslation(NS);
|
|
31
31
|
// const hello = t(K.HELLO);
|
|
32
32
|
return <div>It works!</div>;
|