@next-core/yo 1.4.21 → 1.5.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 +3 -3
- package/src/plopfile.js +11 -1
- package/src/templates/brick/index.tsx.hbs +20 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@next-core/yo",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.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",
|
|
@@ -30,8 +30,8 @@
|
|
|
30
30
|
"@next-core/i18n": "^1.0.28",
|
|
31
31
|
"@next-core/react-element": "^1.0.16",
|
|
32
32
|
"@next-core/test-next": "^1.0.11",
|
|
33
|
-
"@next-core/theme": "^1.3.
|
|
33
|
+
"@next-core/theme": "^1.3.3",
|
|
34
34
|
"react": "0.0.0-experimental-ee8509801-20230117"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "747c5259e22e0ac1821c00532cc0158a75f28593"
|
|
37
37
|
}
|
package/src/plopfile.js
CHANGED
|
@@ -233,6 +233,14 @@ export default function (
|
|
|
233
233
|
: `${data.pkgName}.${input}`;
|
|
234
234
|
},
|
|
235
235
|
},
|
|
236
|
+
{
|
|
237
|
+
type: "confirm",
|
|
238
|
+
name: "useI18n",
|
|
239
|
+
message: "Use i18n with this brick?",
|
|
240
|
+
when(data) {
|
|
241
|
+
return data.type === "brick";
|
|
242
|
+
},
|
|
243
|
+
},
|
|
236
244
|
{
|
|
237
245
|
type: "input",
|
|
238
246
|
name: "providerName",
|
|
@@ -272,7 +280,9 @@ export default function (
|
|
|
272
280
|
type: "addMany",
|
|
273
281
|
destination: "bricks/{{pkgName}}/src/{{brickName}}",
|
|
274
282
|
base: "templates/brick",
|
|
275
|
-
templateFiles:
|
|
283
|
+
templateFiles: data.useI18n
|
|
284
|
+
? "templates/brick"
|
|
285
|
+
: "templates/brick/!(i18n.ts)",
|
|
276
286
|
},
|
|
277
287
|
{
|
|
278
288
|
type: "append",
|
|
@@ -3,11 +3,11 @@ import { createDecorators } from "@next-core/element";
|
|
|
3
3
|
import { ReactNextElement } from "@next-core/react-element";
|
|
4
4
|
import "@next-core/theme";
|
|
5
5
|
import styleText from "./styles.shadow.css";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
{{#if useI18n}}
|
|
7
|
+
import { useTranslation, initializeReactI18n } from "@next-core/i18n/react";
|
|
8
|
+
import { K, NS, locales } from "./i18n.js";
|
|
9
|
+
initializeReactI18n(NS, locales);
|
|
10
|
+
{{/if}}
|
|
11
11
|
|
|
12
12
|
const { defineElement, property } = createDecorators();
|
|
13
13
|
|
|
@@ -26,8 +26,19 @@ class {{>className}} extends ReactNextElement {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
export
|
|
30
|
-
//
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
export interface {{>className}}Props {
|
|
30
|
+
// Define props here.
|
|
31
|
+
}
|
|
32
|
+
export function {{>className}}Component(props: {{>className}}Props) {
|
|
33
|
+
{{#if useI18n}}
|
|
34
|
+
const { t } = useTranslation(NS);
|
|
35
|
+
const hello = t(K.HELLO);
|
|
36
|
+
{{/if}}
|
|
37
|
+
return <div>
|
|
38
|
+
{{#if useI18n}}
|
|
39
|
+
{hello} word!
|
|
40
|
+
{{else}}
|
|
41
|
+
It works!
|
|
42
|
+
{{/if}}
|
|
43
|
+
</div>;
|
|
33
44
|
}
|