[Gradle, JS] KT-36784 Provide args for kotlinNpmInstall

#KT-32466 fixed
#KT-36784 fixed
#KT-36864 fixed
This commit is contained in:
Ilya Goncharov
2020-04-01 12:38:20 +03:00
parent fe40056abe
commit c11c3dffe7
5 changed files with 28 additions and 11 deletions
@@ -21,7 +21,7 @@ interface NpmApi {
rootProject: Project,
subProjects: Collection<KotlinCompilationNpmResolution>,
skipExecution: Boolean,
vararg cliArgs: String
cliArgs: List<String>
)
fun resolveDependency(
@@ -39,12 +39,12 @@ class Yarn : NpmApi {
rootProject: Project,
subProjects: Collection<KotlinCompilationNpmResolution>,
skipExecution: Boolean,
vararg cliArgs: String
cliArgs: List<String>
) = getDelegate(rootProject.project)
.resolveRootProject(
rootProject,
subProjects,
skipExecution,
*cliArgs
cliArgs
)
}
@@ -26,7 +26,7 @@ abstract class YarnBasics : NpmApi {
project: Project,
dir: File,
description: String,
vararg args: String
args: List<String>
) {
val nodeJs = NodeJsRootPlugin.apply(project)
val yarnPlugin = YarnPlugin.apply(project)
@@ -17,7 +17,12 @@ class YarnSimple : YarnBasics() {
val project = resolvedNpmProject.project
PackageJsonUpToDateCheck(resolvedNpmProject.npmProject).updateIfNeeded {
yarnExec(project, resolvedNpmProject.npmProject.dir, NpmApi.resolveOperationDescription("yarn for ${project.path}"))
yarnExec(
project,
resolvedNpmProject.npmProject.dir,
NpmApi.resolveOperationDescription("yarn for ${project.path}"),
emptyList()
)
yarnLockReadTransitiveDependencies(resolvedNpmProject.npmProject.dir, resolvedNpmProject.externalNpmDependencies)
}
}
@@ -26,6 +31,6 @@ class YarnSimple : YarnBasics() {
rootProject: Project,
subProjects: Collection<KotlinCompilationNpmResolution>,
skipExecution: Boolean,
vararg cliArgs: String
cliArgs: List<String>
) = Unit
}
@@ -20,23 +20,34 @@ class YarnWorkspaces : YarnBasics() {
rootProject: Project,
subProjects: Collection<KotlinCompilationNpmResolution>,
skipExecution: Boolean,
vararg cliArgs: String
cliArgs: List<String>
) {
check(rootProject == rootProject.rootProject)
if (!skipExecution) setup(rootProject)
return resolveWorkspaces(rootProject, subProjects, skipExecution)
return resolveWorkspaces(
rootProject,
subProjects,
skipExecution,
cliArgs
)
}
private fun resolveWorkspaces(
rootProject: Project,
npmProjects: Collection<KotlinCompilationNpmResolution>,
skipExecution: Boolean
skipExecution: Boolean,
cliArgs: List<String>
) {
val nodeJsWorldDir = NodeJsRootPlugin.apply(rootProject).rootPackageDir
if (!skipExecution) {
saveRootProjectWorkspacesPackageJson(rootProject, npmProjects, nodeJsWorldDir)
yarnExec(rootProject, nodeJsWorldDir, NpmApi.resolveOperationDescription("yarn"))
yarnExec(
rootProject,
nodeJsWorldDir,
NpmApi.resolveOperationDescription("yarn"),
cliArgs
)
}
yarnLockReadTransitiveDependencies(nodeJsWorldDir, npmProjects.flatMap { it.externalNpmDependencies })
@@ -51,7 +62,8 @@ class YarnWorkspaces : YarnBasics() {
rootPackageJson.private = true
val npmProjectWorkspaces = npmProjects.map { it.npmProject.dir.relativeTo(nodeJsWorldDir).path }
val importedProjectWorkspaces = YarnImportedPackagesVersionResolver(rootProject, npmProjects, nodeJsWorldDir).resolveAndUpdatePackages()
val importedProjectWorkspaces =
YarnImportedPackagesVersionResolver(rootProject, npmProjects, nodeJsWorldDir).resolveAndUpdatePackages()
rootPackageJson.workspaces = npmProjectWorkspaces + importedProjectWorkspaces
rootPackageJson.saveTo(