Improve package command, build logic
* Fix typo in README. * Implement cloning when building, fixing all builds being dirty. * Add --rm option to package command to remove file after publishing, assuming that --publish is provided.
This commit is contained in:
@@ -22,6 +22,7 @@ class PackageBuildCommand extends BaseCommand
|
||||
->setAliases([ "package" ])
|
||||
->setDescription("Package the library into a zipball, or publish directly")
|
||||
->addOption("publish", null, InputOption::VALUE_REQUIRED, "Publish to registry immediately after building")
|
||||
->addOption("rm", null, InputOption::VALUE_NONE, "With --publish: remove the .zip after publishing")
|
||||
->addOption("dirty", null, InputOption::VALUE_NONE, "Build directly from source without cloning")
|
||||
->addOption("force", null, InputOption::VALUE_NONE, "Build even if the output file already exists")
|
||||
;
|
||||
@@ -35,10 +36,10 @@ class PackageBuildCommand extends BaseCommand
|
||||
|
||||
$project = ProjectInfo::read();
|
||||
|
||||
if ($registry && file_exists($project->filename)) {
|
||||
if ($registry && file_exists($project->filename) && !$input->getOption("force")) {
|
||||
$output->writeln("<fg=black;bg=yellow>Package file already exists. Pass --force to rebuild it.</>");
|
||||
} else {
|
||||
$builder->build($project, $input->getOption("force"));
|
||||
$builder->build($project, $input->getOption("dirty"), $input->getOption("force"));
|
||||
}
|
||||
|
||||
if ($registry) {
|
||||
@@ -55,8 +56,8 @@ class PackageBuildCommand extends BaseCommand
|
||||
$output->writeln([
|
||||
"Missing registry to publish to. Please specify the registry like this:",
|
||||
"",
|
||||
" <info>gitea:<server></> - to publish to <info>server</> as the default user",
|
||||
" <info>gitea:<server>/<owner></> - to publish to <info>server</> as <info>owner</>",
|
||||
" <info>gitea:{server}</> - to publish to <info>server</> as the default user",
|
||||
" <info>gitea:{server}:{owner}</> - to publish to <info>server</> as <info>owner</>",
|
||||
""
|
||||
]);
|
||||
return self::INVALID;
|
||||
@@ -64,6 +65,11 @@ class PackageBuildCommand extends BaseCommand
|
||||
|
||||
$publisher->publish($project, $registry);
|
||||
|
||||
if ($input->getOption("rm")) {
|
||||
$output->writeln("Unlinking <comment>".$project->filename."</>");
|
||||
unlink($project->filename);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user