@next-core/yo 1.4.22 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@next-core/yo",
3
- "version": "1.4.22",
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",
@@ -33,5 +33,5 @@
33
33
  "@next-core/theme": "^1.3.3",
34
34
  "react": "0.0.0-experimental-ee8509801-20230117"
35
35
  },
36
- "gitHead": "7724d739554e66c61f64a4364a4ca81658c5dd80"
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: "templates/brick",
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
- // --- NOTE: uncomment these lines below to enable i18n for your brick ---
8
- // import { useTranslation, initializeReactI18n } from "@next-core/i18n/react";
9
- // import { K, NS, locales } from "./i18n.js";
10
- // initializeReactI18n(NS, locales);
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 function {{>className}}Component() {
30
- // const { t } = useTranslation(NS);
31
- // const hello = t(K.HELLO);
32
- return <div>It works!</div>;
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
  }