mirror of
https://github.com/apple/pkl.git
synced 2026-07-14 00:52:39 +02:00
Breaking: rename some CLI classes for consistency (#169)
CliDownloadPackageCommand -> CliPackageDownloader (consistent with CliProjectPackager/CliProjectResolver) CliAbstractProjectCommand -> CliProjectCommand (consistent with CliCommand)
This commit is contained in:
+1
-1
@@ -21,7 +21,7 @@ import org.pkl.commons.cli.CliException
|
|||||||
import org.pkl.core.packages.PackageResolver
|
import org.pkl.core.packages.PackageResolver
|
||||||
import org.pkl.core.packages.PackageUri
|
import org.pkl.core.packages.PackageUri
|
||||||
|
|
||||||
class CliDownloadPackageCommand(
|
class CliPackageDownloader(
|
||||||
baseOptions: CliBaseOptions,
|
baseOptions: CliBaseOptions,
|
||||||
private val packageUris: List<PackageUri>,
|
private val packageUris: List<PackageUri>,
|
||||||
private val noTransitive: Boolean
|
private val noTransitive: Boolean
|
||||||
+2
-4
@@ -23,10 +23,8 @@ import org.pkl.commons.cli.CliCommand
|
|||||||
import org.pkl.commons.cli.CliException
|
import org.pkl.commons.cli.CliException
|
||||||
import org.pkl.core.module.ProjectDependenciesManager.PKL_PROJECT_FILENAME
|
import org.pkl.core.module.ProjectDependenciesManager.PKL_PROJECT_FILENAME
|
||||||
|
|
||||||
abstract class CliAbstractProjectCommand(
|
abstract class CliProjectCommand(cliOptions: CliBaseOptions, private val projectDirs: List<Path>) :
|
||||||
cliOptions: CliBaseOptions,
|
CliCommand(cliOptions) {
|
||||||
private val projectDirs: List<Path>
|
|
||||||
) : CliCommand(cliOptions) {
|
|
||||||
|
|
||||||
protected val normalizedProjectFiles: List<Path> by lazy {
|
protected val normalizedProjectFiles: List<Path> by lazy {
|
||||||
if (projectDirs.isEmpty()) {
|
if (projectDirs.isEmpty()) {
|
||||||
@@ -33,7 +33,7 @@ class CliProjectPackager(
|
|||||||
private val skipPublishCheck: Boolean,
|
private val skipPublishCheck: Boolean,
|
||||||
private val consoleWriter: Writer = System.out.writer(),
|
private val consoleWriter: Writer = System.out.writer(),
|
||||||
private val errWriter: Writer = System.err.writer()
|
private val errWriter: Writer = System.err.writer()
|
||||||
) : CliAbstractProjectCommand(baseOptions, projectDirs) {
|
) : CliProjectCommand(baseOptions, projectDirs) {
|
||||||
|
|
||||||
private fun runApiTests(project: Project) {
|
private fun runApiTests(project: Project) {
|
||||||
val apiTests = project.`package`!!.apiTests
|
val apiTests = project.`package`!!.apiTests
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class CliProjectResolver(
|
|||||||
projectDirs: List<Path>,
|
projectDirs: List<Path>,
|
||||||
private val consoleWriter: Writer = System.out.writer(),
|
private val consoleWriter: Writer = System.out.writer(),
|
||||||
private val errWriter: Writer = System.err.writer()
|
private val errWriter: Writer = System.err.writer()
|
||||||
) : CliAbstractProjectCommand(baseOptions, projectDirs) {
|
) : CliProjectCommand(baseOptions, projectDirs) {
|
||||||
override fun doRun() {
|
override fun doRun() {
|
||||||
for (projectFile in normalizedProjectFiles) {
|
for (projectFile in normalizedProjectFiles) {
|
||||||
val project = loadProject(projectFile)
|
val project = loadProject(projectFile)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import com.github.ajalt.clikt.parameters.arguments.multiple
|
|||||||
import com.github.ajalt.clikt.parameters.groups.provideDelegate
|
import com.github.ajalt.clikt.parameters.groups.provideDelegate
|
||||||
import com.github.ajalt.clikt.parameters.options.flag
|
import com.github.ajalt.clikt.parameters.options.flag
|
||||||
import com.github.ajalt.clikt.parameters.options.option
|
import com.github.ajalt.clikt.parameters.options.option
|
||||||
import org.pkl.cli.CliDownloadPackageCommand
|
import org.pkl.cli.CliPackageDownloader
|
||||||
import org.pkl.commons.cli.commands.BaseCommand
|
import org.pkl.commons.cli.commands.BaseCommand
|
||||||
import org.pkl.commons.cli.commands.ProjectOptions
|
import org.pkl.commons.cli.commands.ProjectOptions
|
||||||
import org.pkl.commons.cli.commands.single
|
import org.pkl.commons.cli.commands.single
|
||||||
@@ -62,7 +62,7 @@ class DownloadPackageCommand(helpLink: String) :
|
|||||||
.flag()
|
.flag()
|
||||||
|
|
||||||
override fun run() {
|
override fun run() {
|
||||||
CliDownloadPackageCommand(
|
CliPackageDownloader(
|
||||||
baseOptions.baseOptions(emptyList(), projectOptions),
|
baseOptions.baseOptions(emptyList(), projectOptions),
|
||||||
packageUris,
|
packageUris,
|
||||||
noTransitive
|
noTransitive
|
||||||
|
|||||||
+9
-9
@@ -26,7 +26,7 @@ import org.pkl.commons.test.FileTestUtils
|
|||||||
import org.pkl.commons.test.PackageServer
|
import org.pkl.commons.test.PackageServer
|
||||||
import org.pkl.core.packages.PackageUri
|
import org.pkl.core.packages.PackageUri
|
||||||
|
|
||||||
class CliDownloadPackageCommandTest {
|
class CliPackageDownloaderTest {
|
||||||
companion object {
|
companion object {
|
||||||
@BeforeAll
|
@BeforeAll
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
@@ -38,7 +38,7 @@ class CliDownloadPackageCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
fun `download packages`(@TempDir tempDir: Path) {
|
fun `download packages`(@TempDir tempDir: Path) {
|
||||||
val cmd =
|
val cmd =
|
||||||
CliDownloadPackageCommand(
|
CliPackageDownloader(
|
||||||
baseOptions =
|
baseOptions =
|
||||||
CliBaseOptions(
|
CliBaseOptions(
|
||||||
moduleCacheDir = tempDir,
|
moduleCacheDir = tempDir,
|
||||||
@@ -76,7 +76,7 @@ class CliDownloadPackageCommandTest {
|
|||||||
)
|
)
|
||||||
|
|
||||||
val cmd =
|
val cmd =
|
||||||
CliDownloadPackageCommand(
|
CliPackageDownloader(
|
||||||
baseOptions =
|
baseOptions =
|
||||||
CliBaseOptions(
|
CliBaseOptions(
|
||||||
workingDir = tempDir,
|
workingDir = tempDir,
|
||||||
@@ -95,7 +95,7 @@ class CliDownloadPackageCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
fun `download package while specifying checksum`(@TempDir tempDir: Path) {
|
fun `download package while specifying checksum`(@TempDir tempDir: Path) {
|
||||||
val cmd =
|
val cmd =
|
||||||
CliDownloadPackageCommand(
|
CliPackageDownloader(
|
||||||
baseOptions =
|
baseOptions =
|
||||||
CliBaseOptions(
|
CliBaseOptions(
|
||||||
moduleCacheDir = tempDir,
|
moduleCacheDir = tempDir,
|
||||||
@@ -117,7 +117,7 @@ class CliDownloadPackageCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
fun `download package with invalid checksum`(@TempDir tempDir: Path) {
|
fun `download package with invalid checksum`(@TempDir tempDir: Path) {
|
||||||
val cmd =
|
val cmd =
|
||||||
CliDownloadPackageCommand(
|
CliPackageDownloader(
|
||||||
baseOptions =
|
baseOptions =
|
||||||
CliBaseOptions(
|
CliBaseOptions(
|
||||||
moduleCacheDir = tempDir,
|
moduleCacheDir = tempDir,
|
||||||
@@ -145,7 +145,7 @@ class CliDownloadPackageCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
fun `disabling caching is an error`(@TempDir tempDir: Path) {
|
fun `disabling caching is an error`(@TempDir tempDir: Path) {
|
||||||
val cmd =
|
val cmd =
|
||||||
CliDownloadPackageCommand(
|
CliPackageDownloader(
|
||||||
baseOptions = CliBaseOptions(workingDir = tempDir, noCache = true),
|
baseOptions = CliBaseOptions(workingDir = tempDir, noCache = true),
|
||||||
packageUris = listOf(PackageUri("package://localhost:12110/birds@0.5.0")),
|
packageUris = listOf(PackageUri("package://localhost:12110/birds@0.5.0")),
|
||||||
noTransitive = true
|
noTransitive = true
|
||||||
@@ -157,7 +157,7 @@ class CliDownloadPackageCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
fun `download packages with bad checksum`(@TempDir tempDir: Path) {
|
fun `download packages with bad checksum`(@TempDir tempDir: Path) {
|
||||||
val cmd =
|
val cmd =
|
||||||
CliDownloadPackageCommand(
|
CliPackageDownloader(
|
||||||
baseOptions =
|
baseOptions =
|
||||||
CliBaseOptions(
|
CliBaseOptions(
|
||||||
moduleCacheDir = tempDir,
|
moduleCacheDir = tempDir,
|
||||||
@@ -175,7 +175,7 @@ class CliDownloadPackageCommandTest {
|
|||||||
@Test
|
@Test
|
||||||
fun `download multiple failing packages`(@TempDir tempDir: Path) {
|
fun `download multiple failing packages`(@TempDir tempDir: Path) {
|
||||||
val cmd =
|
val cmd =
|
||||||
CliDownloadPackageCommand(
|
CliPackageDownloader(
|
||||||
baseOptions =
|
baseOptions =
|
||||||
CliBaseOptions(
|
CliBaseOptions(
|
||||||
moduleCacheDir = tempDir,
|
moduleCacheDir = tempDir,
|
||||||
@@ -211,7 +211,7 @@ class CliDownloadPackageCommandTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun `download package, including transitive dependencies`(@TempDir tempDir: Path) {
|
fun `download package, including transitive dependencies`(@TempDir tempDir: Path) {
|
||||||
CliDownloadPackageCommand(
|
CliPackageDownloader(
|
||||||
baseOptions =
|
baseOptions =
|
||||||
CliBaseOptions(
|
CliBaseOptions(
|
||||||
moduleCacheDir = tempDir,
|
moduleCacheDir = tempDir,
|
||||||
Reference in New Issue
Block a user