wlmaker 1.2.5 → 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 +16 -4
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -703,18 +703,21 @@ class Wl${pascal}Skeleton extends StatelessWidget {
|
|
|
703
703
|
};
|
|
704
704
|
}
|
|
705
705
|
function useCaseTemplate(name, pascal, tierPlural3, tier) {
|
|
706
|
-
const
|
|
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}()`;
|
|
707
710
|
return `import 'package:design_system/design_system.dart';
|
|
708
711
|
import 'package:flutter/material.dart';
|
|
709
712
|
import 'package:widgetbook/widgetbook.dart';
|
|
710
713
|
import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook;
|
|
711
714
|
|
|
712
715
|
@widgetbook.UseCase(
|
|
713
|
-
name: '
|
|
714
|
-
type:
|
|
716
|
+
name: '${className}',
|
|
717
|
+
type: ${className},
|
|
715
718
|
path: 'wl_design_system/${tierPlural3}/wl_${name}',
|
|
716
719
|
)
|
|
717
|
-
Widget
|
|
720
|
+
Widget useCase${className}(BuildContext context) {
|
|
718
721
|
return ${widgetCall};
|
|
719
722
|
}
|
|
720
723
|
`;
|
|
@@ -1306,6 +1309,15 @@ program.command("widget").description("Create a new widget in the design system"
|
|
|
1306
1309
|
projectRoot: options.dir,
|
|
1307
1310
|
pattern: options.pattern
|
|
1308
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
|
+
}
|
|
1309
1321
|
} catch (error) {
|
|
1310
1322
|
console.error(chalk5.red(`Error: ${error}`));
|
|
1311
1323
|
process.exit(1);
|