wlmaker 1.2.5 → 1.2.7

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.
Files changed (2) hide show
  1. package/dist/cli.mjs +21 -4
  2. package/package.json +1 -1
package/dist/cli.mjs CHANGED
@@ -378,6 +378,11 @@ function widgetExists(componentsDir, tierPluralName, widgetName) {
378
378
  if (fs5.existsSync(flatFile)) return true;
379
379
  const subDir = path5.join(tierDir, widgetName);
380
380
  if (fs5.existsSync(subDir)) return true;
381
+ const bareName = widgetName.startsWith("wl_") ? widgetName.slice(3) : widgetName;
382
+ if (bareName !== widgetName) {
383
+ const bareSubDir = path5.join(tierDir, bareName);
384
+ if (fs5.existsSync(bareSubDir)) return true;
385
+ }
381
386
  return false;
382
387
  }
383
388
 
@@ -703,18 +708,21 @@ class Wl${pascal}Skeleton extends StatelessWidget {
703
708
  };
704
709
  }
705
710
  function useCaseTemplate(name, pascal, tierPlural3, tier) {
706
- const widgetCall = tier === "organism" || tier === "template" ? `const Wl${pascal}(i18n: Wl${pascal}I18n())` : `const Wl${pascal}()`;
711
+ const isTemplate = tier === "template";
712
+ const className = isTemplate ? `Wl${pascal}Template` : `Wl${pascal}`;
713
+ const needsI18n = tier === "organism" || tier === "template";
714
+ const widgetCall = needsI18n ? `const ${className}(i18n: Wl${pascal}I18n())` : `const ${className}()`;
707
715
  return `import 'package:design_system/design_system.dart';
708
716
  import 'package:flutter/material.dart';
709
717
  import 'package:widgetbook/widgetbook.dart';
710
718
  import 'package:widgetbook_annotation/widgetbook_annotation.dart' as widgetbook;
711
719
 
712
720
  @widgetbook.UseCase(
713
- name: 'Wl${pascal}',
714
- type: Wl${pascal},
721
+ name: '${className}',
722
+ type: ${className},
715
723
  path: 'wl_design_system/${tierPlural3}/wl_${name}',
716
724
  )
717
- Widget useCaseWl${pascal}(BuildContext context) {
725
+ Widget useCase${className}(BuildContext context) {
718
726
  return ${widgetCall};
719
727
  }
720
728
  `;
@@ -1306,6 +1314,15 @@ program.command("widget").description("Create a new widget in the design system"
1306
1314
  projectRoot: options.dir,
1307
1315
  pattern: options.pattern
1308
1316
  });
1317
+ try {
1318
+ await createUseCase(name, options.tier, {
1319
+ projectRoot: options.dir,
1320
+ buildRunner: false
1321
+ });
1322
+ console.log(chalk5.green("Widgetbook use-case created"));
1323
+ } catch {
1324
+ console.log(chalk5.yellow("Use-case skipped (may already exist)"));
1325
+ }
1309
1326
  } catch (error) {
1310
1327
  console.error(chalk5.red(`Error: ${error}`));
1311
1328
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wlmaker",
3
- "version": "1.2.5",
3
+ "version": "1.2.7",
4
4
  "description": "Create Flutter BLoCs with Freezed sealed classes from the terminal",
5
5
  "keywords": [
6
6
  "flutter",