wlmaker 1.2.4 → 1.2.6
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/dist/cli.mjs +22 -9
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -550,9 +550,6 @@ part 'wl_${name}_i18n.dart';
|
|
|
550
550
|
part 'wl_${name}_skeleton.dart';
|
|
551
551
|
|
|
552
552
|
class Wl${pascal} extends StatelessWidget {
|
|
553
|
-
final Wl${pascal}Variant variant;
|
|
554
|
-
final Wl${pascal}I18n i18n;
|
|
555
|
-
|
|
556
553
|
factory Wl${pascal}({
|
|
557
554
|
required Wl${pascal}I18n i18n,
|
|
558
555
|
Key? key,
|
|
@@ -581,6 +578,9 @@ class Wl${pascal} extends StatelessWidget {
|
|
|
581
578
|
super.key,
|
|
582
579
|
});
|
|
583
580
|
|
|
581
|
+
final Wl${pascal}Variant variant;
|
|
582
|
+
final Wl${pascal}I18n i18n;
|
|
583
|
+
|
|
584
584
|
@override
|
|
585
585
|
Widget build(BuildContext context) {
|
|
586
586
|
final theme = context.theme;
|
|
@@ -702,19 +702,23 @@ class Wl${pascal}Skeleton extends StatelessWidget {
|
|
|
702
702
|
`
|
|
703
703
|
};
|
|
704
704
|
}
|
|
705
|
-
function useCaseTemplate(name, pascal, tierPlural3) {
|
|
705
|
+
function useCaseTemplate(name, pascal, tierPlural3, tier) {
|
|
706
|
+
const isTemplate = tier === "template";
|
|
707
|
+
const className = isTemplate ? `Wl${pascal}Template` : `Wl${pascal}`;
|
|
708
|
+
const needsI18n = tier === "organism" || tier === "template";
|
|
709
|
+
const widgetCall = needsI18n ? `const ${className}(i18n: Wl${pascal}I18n())` : `const ${className}()`;
|
|
706
710
|
return `import 'package:design_system/design_system.dart';
|
|
707
711
|
import 'package:flutter/material.dart';
|
|
708
712
|
import 'package:widgetbook/widgetbook.dart';
|
|
709
713
|
import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook;
|
|
710
714
|
|
|
711
715
|
@widgetbook.UseCase(
|
|
712
|
-
name: '
|
|
713
|
-
type:
|
|
716
|
+
name: '${className}',
|
|
717
|
+
type: ${className},
|
|
714
718
|
path: 'wl_design_system/${tierPlural3}/wl_${name}',
|
|
715
719
|
)
|
|
716
|
-
Widget
|
|
717
|
-
return
|
|
720
|
+
Widget useCase${className}(BuildContext context) {
|
|
721
|
+
return ${widgetCall};
|
|
718
722
|
}
|
|
719
723
|
`;
|
|
720
724
|
}
|
|
@@ -924,7 +928,7 @@ async function createUseCase(name, tierInput, options) {
|
|
|
924
928
|
}
|
|
925
929
|
fs7.writeFileSync(
|
|
926
930
|
useCasePath,
|
|
927
|
-
useCaseTemplate(cleanName, pascal, plural)
|
|
931
|
+
useCaseTemplate(cleanName, pascal, plural, tier)
|
|
928
932
|
);
|
|
929
933
|
console.log(
|
|
930
934
|
chalk3.green(
|
|
@@ -1305,6 +1309,15 @@ program.command("widget").description("Create a new widget in the design system"
|
|
|
1305
1309
|
projectRoot: options.dir,
|
|
1306
1310
|
pattern: options.pattern
|
|
1307
1311
|
});
|
|
1312
|
+
try {
|
|
1313
|
+
await createUseCase(name, options.tier, {
|
|
1314
|
+
projectRoot: options.dir,
|
|
1315
|
+
buildRunner: false
|
|
1316
|
+
});
|
|
1317
|
+
console.log(chalk5.green("Widgetbook use-case created"));
|
|
1318
|
+
} catch {
|
|
1319
|
+
console.log(chalk5.yellow("Use-case skipped (may already exist)"));
|
|
1320
|
+
}
|
|
1308
1321
|
} catch (error) {
|
|
1309
1322
|
console.error(chalk5.red(`Error: ${error}`));
|
|
1310
1323
|
process.exit(1);
|