run method
Runs this command.
The return value is wrapped in a Future if necessary and returned by
CommandRunner.runCommand.
Implementation
@override
Future<void> run() async {
final args = argResults!.rest;
if (args.isEmpty) {
print("❌ Please provide a project name:");
print("lite create my_app --org com.example --riverpod");
return;
}
final projectName = args.first;
final useRiverpod = argResults!["riverpod"];
final org = argResults!["org"];
// 1️⃣ Run flutter create
print("🚀 Loading boosters for $projectName ...");
final result = await Process.run("flutter", [
"create",
projectName,
"--org",
org,
], runInShell: true);
if (result.exitCode != 0) {
print("❌ Flutter create failed:\n${result.stderr}");
return;
}
logStep("Flutter project $projectName created.");
// 2️⃣ Load template JSON
final templateDir = useRiverpod
? "templates/app/riverpod.json"
: "templates/app/default.json";
final templatePath = PathHelper.template(templateDir);
final template = JsonLoader.load(templatePath);
// 3️⃣ Generate additional folders/files
final projectPath = "${Directory.current.path}/$projectName";
Directory.current = Directory(projectPath);
Generator.generate(template, {"app": projectName, "org": org});
logStep("$projectName is ready with Kite scaffolding! 🪁");
/// 2️⃣ Move into project directory
Directory.current = Directory(projectPath);
/// 3️⃣ Add dependencies
await _addDependencies(useRiverpod);
/// 4️⃣ Add dev dependencies
await _addDevDependencies();
/// Open the project in VS Code
logStep("Opening project in VS Code...");
await Process.run(
"code",
[projectPath],
runInShell: true,
);
}