This repository has been archived by the owner on Jan 25, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 70
/
parabeac.dart
126 lines (115 loc) · 3.81 KB
/
parabeac.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import 'dart:convert';
import 'dart:io';
import 'package:path/path.dart' as p;
import 'package:args/args.dart';
ArgResults argResults;
// ignore: always_declare_return_types
main(List<String> args) async {
var arguments = <String>['lib/main.dart'];
//sets up parser
//wil set the hide option for help flag to true to
//prevent the help usage from being printed twice in console
///sets up parser
final parser = ArgParser()
..addOption('out', help: 'The output path', valueHelp: 'path', abbr: 'o')
..addOption('project-name', help: 'The name of the project', abbr: 'n')
..addOption(
'config-path',
help: 'Path of the configuration file',
abbr: 'c',
defaultsTo: p.setExtension(
p.join('lib', 'configurations', 'configurations'), '.json'),
)
// '${p.setExtension(p.join('lib/configurations/', 'configurations'), '.json')}')
..addOption('fig', help: 'The ID of the figma file', abbr: 'f')
..addOption('figKey', help: 'Your personal API Key', abbr: 'k')
..addOption(
'pbdl-in',
help:
'Takes in a Parabeac Design Logic (PBDL) JSON file and exports it to a project',
)
..addOption('oauth', help: 'Figma OAuth Token')
..addOption(
'folderArchitecture',
help: 'Folder Architecture type to use.',
allowedHelp: {
'domain':
'Default Option. Generates a domain-layered folder architecture.'
},
)
..addOption(
'componentIsolation',
help: 'Component Isolation configuration to use.',
allowedHelp: {
'widgetbook': 'Default option. Use widgetbook for component isolation.',
'dashbook': 'Use dashbook for component isolation.',
'none': 'Do not use any component isolation packages.',
},
)
..addOption(
'project-type',
help: 'Type of project to generate.',
allowedHelp: {
'screens': 'Default Option. Generate a full app.',
'components': 'Generate a component package.',
'themes': 'Generate theme information.',
},
aliases: ['level'],
)
..addOption('design-system',
help: 'Design system that the project will be exported', abbr: 'd')
..addFlag('help',
help: 'Displays this help information.', abbr: 'h', negatable: false)
..addFlag(
'export-pbdl',
help: 'This flag outputs Parabeac Design Logic (PBDL) in JSON format.',
negatable: false,
)
..addFlag('exclude-styles',
help: 'If this flag is set, it will exclude output styles document');
argResults = parser.parse(args);
//Check if no args passed or only -h/--help passed
//stops the program after printing the help for both the
//main parabeac arguments and the the parabeac egg arguments
if (argResults['help']) {
print('''
Common commands:
${parser.usage}
''');
exit(0);
}
arguments.addAll(argResults.arguments);
var install = await Process.start('bash', [
'${Directory.current.path}/pb-scripts/install.sh',
]);
await stdout.addStream(install.stdout);
await stderr.addStream(install.stderr);
var exitCode = await install.exitCode;
if (exitCode != 0) {
print('install.sh finished with exit code $exitCode');
}
/// To Download and merge the plugins on the codebase
var result = await Process.start(
'bash',
[
'${Directory.current.path}/pb-scripts/merge-plugins.sh',
],
);
await for (var event in result.stdout.transform(utf8.decoder)) {
print(event);
}
await for (var event in result.stderr.transform(utf8.decoder)) {
print(event);
}
/// To run parabeac-core
var parabeaccore = await Process.start(
'dart',
arguments,
);
await for (var event in parabeaccore.stdout.transform(utf8.decoder)) {
print(event);
}
await for (var event in parabeaccore.stderr.transform(utf8.decoder)) {
print(event);
}
}