wlmaker 1.2.0 → 1.2.1
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 +49 -21
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -384,7 +384,8 @@ function widgetExists(componentsDir, tierPluralName, widgetName) {
|
|
|
384
384
|
|
|
385
385
|
// src/core/widget-templates.ts
|
|
386
386
|
function atomTemplateA(name, pascal) {
|
|
387
|
-
return `import 'package:
|
|
387
|
+
return `import 'package:design_system/design_system.dart';
|
|
388
|
+
import 'package:flutter/material.dart';
|
|
388
389
|
|
|
389
390
|
class Wl${pascal} extends StatelessWidget {
|
|
390
391
|
const Wl${pascal}({super.key});
|
|
@@ -398,7 +399,8 @@ class Wl${pascal} extends StatelessWidget {
|
|
|
398
399
|
`;
|
|
399
400
|
}
|
|
400
401
|
function atomTemplateB(name, pascal) {
|
|
401
|
-
return `import 'package:
|
|
402
|
+
return `import 'package:design_system/design_system.dart';
|
|
403
|
+
import 'package:flutter/material.dart';
|
|
402
404
|
|
|
403
405
|
enum Wl${pascal}Variant {
|
|
404
406
|
primary,
|
|
@@ -426,7 +428,8 @@ class Wl${pascal} extends StatelessWidget {
|
|
|
426
428
|
}
|
|
427
429
|
function atomTemplateC(name, pascal) {
|
|
428
430
|
return {
|
|
429
|
-
main: `import 'package:
|
|
431
|
+
main: `import 'package:design_system/design_system.dart';
|
|
432
|
+
import 'package:flutter/material.dart';
|
|
430
433
|
|
|
431
434
|
part '${name}_sizes.dart';
|
|
432
435
|
|
|
@@ -471,7 +474,8 @@ extension _Wl${pascal}SizeExt on _Wl${pascal}Size {
|
|
|
471
474
|
};
|
|
472
475
|
}
|
|
473
476
|
function moleculeTemplateA(name, pascal) {
|
|
474
|
-
return `import 'package:
|
|
477
|
+
return `import 'package:design_system/design_system.dart';
|
|
478
|
+
import 'package:flutter/material.dart';
|
|
475
479
|
|
|
476
480
|
enum Wl${pascal}Variant {
|
|
477
481
|
primary,
|
|
@@ -501,7 +505,8 @@ class _Wl${pascal}State extends State<Wl${pascal}> {
|
|
|
501
505
|
}
|
|
502
506
|
function moleculeTemplateB(name, pascal) {
|
|
503
507
|
return {
|
|
504
|
-
main: `import 'package:
|
|
508
|
+
main: `import 'package:design_system/design_system.dart';
|
|
509
|
+
import 'package:flutter/material.dart';
|
|
505
510
|
|
|
506
511
|
part '${name}_type.dart';
|
|
507
512
|
|
|
@@ -539,7 +544,8 @@ extension Wl${pascal}VariantExt on Wl${pascal}Variant {
|
|
|
539
544
|
};
|
|
540
545
|
}
|
|
541
546
|
function moleculeTemplateC(name, pascal) {
|
|
542
|
-
return `import 'package:
|
|
547
|
+
return `import 'package:design_system/design_system.dart';
|
|
548
|
+
import 'package:flutter/material.dart';
|
|
543
549
|
|
|
544
550
|
class Wl${pascal} extends StatefulWidget {
|
|
545
551
|
const Wl${pascal}({super.key});
|
|
@@ -559,7 +565,8 @@ class _Wl${pascal}State extends State<Wl${pascal}> {
|
|
|
559
565
|
}
|
|
560
566
|
function organismTemplateA(name, pascal) {
|
|
561
567
|
return {
|
|
562
|
-
main: `import 'package:
|
|
568
|
+
main: `import 'package:design_system/design_system.dart';
|
|
569
|
+
import 'package:flutter/material.dart';
|
|
563
570
|
|
|
564
571
|
part '${name}_content.dart';
|
|
565
572
|
|
|
@@ -589,7 +596,8 @@ class _Wl${pascal}Content extends StatelessWidget {
|
|
|
589
596
|
};
|
|
590
597
|
}
|
|
591
598
|
function organismTemplateB(name, pascal) {
|
|
592
|
-
return `import 'package:
|
|
599
|
+
return `import 'package:design_system/design_system.dart';
|
|
600
|
+
import 'package:flutter/material.dart';
|
|
593
601
|
|
|
594
602
|
class Wl${pascal} extends StatefulWidget {
|
|
595
603
|
const Wl${pascal}({super.key});
|
|
@@ -609,7 +617,8 @@ class _Wl${pascal}State extends State<Wl${pascal}> {
|
|
|
609
617
|
}
|
|
610
618
|
function templateA(name, pascal) {
|
|
611
619
|
return {
|
|
612
|
-
main: `import 'package:
|
|
620
|
+
main: `import 'package:design_system/design_system.dart';
|
|
621
|
+
import 'package:flutter/material.dart';
|
|
613
622
|
|
|
614
623
|
part '${name}_i18n.dart';
|
|
615
624
|
part '${name}_body.dart';
|
|
@@ -694,7 +703,8 @@ class _Wl${pascal}Skeleton extends StatelessWidget {
|
|
|
694
703
|
}
|
|
695
704
|
function templateB(name, pascal) {
|
|
696
705
|
return {
|
|
697
|
-
main: `import 'package:
|
|
706
|
+
main: `import 'package:design_system/design_system.dart';
|
|
707
|
+
import 'package:flutter/material.dart';
|
|
698
708
|
|
|
699
709
|
import 'contracts/${name}_callbacks.dart';
|
|
700
710
|
import 'contracts/${name}_config.dart';
|
|
@@ -836,7 +846,8 @@ class Wl${pascal}Data extends Equatable {
|
|
|
836
846
|
};
|
|
837
847
|
}
|
|
838
848
|
function useCaseTemplate(name, pascal, tierPlural3) {
|
|
839
|
-
return `import 'package:
|
|
849
|
+
return `import 'package:design_system/design_system.dart';
|
|
850
|
+
import 'package:widgetbook/widgetbook.dart';
|
|
840
851
|
import 'package:wl_design_system/${tierPlural3}/wl_${name}.dart';
|
|
841
852
|
|
|
842
853
|
WidgetbookUseCase wl${pascal}UseCase(BuildContext context) {
|
|
@@ -1262,18 +1273,19 @@ async function blocFlow(project) {
|
|
|
1262
1273
|
clack.outro(chalk4.red(`Error: ${error}`));
|
|
1263
1274
|
}
|
|
1264
1275
|
}
|
|
1265
|
-
async function widgetFlow(
|
|
1266
|
-
const
|
|
1276
|
+
async function widgetFlow() {
|
|
1277
|
+
const projectRoot = process.cwd();
|
|
1278
|
+
const ds = detectDesignSystem(projectRoot);
|
|
1267
1279
|
if (!ds) {
|
|
1268
1280
|
clack.outro(
|
|
1269
1281
|
chalk4.red(
|
|
1270
|
-
"No design system detected.
|
|
1282
|
+
"No design system detected. Run this command from a project with wl_design_system/ directory."
|
|
1271
1283
|
)
|
|
1272
1284
|
);
|
|
1273
1285
|
return;
|
|
1274
1286
|
}
|
|
1275
1287
|
clack.log.info(
|
|
1276
|
-
`Design system: ${chalk4.cyan(path8.relative(
|
|
1288
|
+
`Design system: ${chalk4.cyan(path8.relative(projectRoot, ds.componentsDir))}`
|
|
1277
1289
|
);
|
|
1278
1290
|
const name = await clack.text({
|
|
1279
1291
|
message: "Widget name (snake_case, without wl_ prefix)",
|
|
@@ -1322,10 +1334,22 @@ async function widgetFlow(project) {
|
|
|
1322
1334
|
genSpinner.start("Generating widget files...");
|
|
1323
1335
|
try {
|
|
1324
1336
|
await createWidget(name, tier, {
|
|
1325
|
-
projectRoot
|
|
1337
|
+
projectRoot,
|
|
1326
1338
|
pattern: selectedPattern
|
|
1327
1339
|
});
|
|
1328
1340
|
genSpinner.stop("Widget generated");
|
|
1341
|
+
if (ds.widgetbookDir) {
|
|
1342
|
+
genSpinner.start("Creating widgetbook use-case...");
|
|
1343
|
+
try {
|
|
1344
|
+
await createUseCase(name, tier, {
|
|
1345
|
+
projectRoot,
|
|
1346
|
+
buildRunner: false
|
|
1347
|
+
});
|
|
1348
|
+
genSpinner.stop("Use-case created");
|
|
1349
|
+
} catch {
|
|
1350
|
+
genSpinner.stop("Use-case skipped (may already exist)");
|
|
1351
|
+
}
|
|
1352
|
+
}
|
|
1329
1353
|
clack.outro(chalk4.green("Done!"));
|
|
1330
1354
|
} catch (error) {
|
|
1331
1355
|
genSpinner.stop("Failed");
|
|
@@ -1418,18 +1442,22 @@ async function interactiveMode() {
|
|
|
1418
1442
|
return;
|
|
1419
1443
|
}
|
|
1420
1444
|
const type = createType;
|
|
1421
|
-
const project = await resolveProject();
|
|
1422
|
-
if (!project) return;
|
|
1423
1445
|
switch (type) {
|
|
1424
|
-
case "bloc":
|
|
1446
|
+
case "bloc": {
|
|
1447
|
+
const project = await resolveProject();
|
|
1448
|
+
if (!project) return;
|
|
1425
1449
|
await blocFlow(project);
|
|
1426
1450
|
break;
|
|
1451
|
+
}
|
|
1427
1452
|
case "widget":
|
|
1428
|
-
await widgetFlow(
|
|
1453
|
+
await widgetFlow();
|
|
1429
1454
|
break;
|
|
1430
|
-
case "usecase":
|
|
1455
|
+
case "usecase": {
|
|
1456
|
+
const project = await resolveProject();
|
|
1457
|
+
if (!project) return;
|
|
1431
1458
|
await useCaseFlow(project);
|
|
1432
1459
|
break;
|
|
1460
|
+
}
|
|
1433
1461
|
}
|
|
1434
1462
|
}
|
|
1435
1463
|
|