[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, rootProject: Project,
subProjects: Collection<KotlinCompilationNpmResolution>, subProjects: Collection<KotlinCompilationNpmResolution>,
skipExecution: Boolean, skipExecution: Boolean,
vararg cliArgs: String cliArgs: List<String>
) )
fun resolveDependency( fun resolveDependency(
@@ -39,12 +39,12 @@ class Yarn : NpmApi {
rootProject: Project, rootProject: Project,
subProjects: Collection<KotlinCompilationNpmResolution>, subProjects: Collection<KotlinCompilationNpmResolution>,
skipExecution: Boolean, skipExecution: Boolean,
vararg cliArgs: String cliArgs: List<String>
) = getDelegate(rootProject.project) ) = getDelegate(rootProject.project)
.resolveRootProject( .resolveRootProject(
rootProject, rootProject,
subProjects, subProjects,
skipExecution, skipExecution,
*cliArgs cliArgs
) )
} }
@@ -26,7 +26,7 @@ abstract class YarnBasics : NpmApi {
project: Project, project: Project,
dir: File, dir: File,
description: String, description: String,
vararg args: String args: List<String>
) { ) {
val nodeJs = NodeJsRootPlugin.apply(project) val nodeJs = NodeJsRootPlugin.apply(project)
val yarnPlugin = YarnPlugin.apply(project) val yarnPlugin = YarnPlugin.apply(project)
@@ -17,7 +17,12 @@ class YarnSimple : YarnBasics() {
val project = resolvedNpmProject.project val project = resolvedNpmProject.project
PackageJsonUpToDateCheck(resolvedNpmProject.npmProject).updateIfNeeded { 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) yarnLockReadTransitiveDependencies(resolvedNpmProject.npmProject.dir, resolvedNpmProject.externalNpmDependencies)
} }
} }
@@ -26,6 +31,6 @@ class YarnSimple : YarnBasics() {
rootProject: Project, rootProject: Project,
subProjects: Collection<KotlinCompilationNpmResolution>, subProjects: Collection<KotlinCompilationNpmResolution>,
skipExecution: Boolean, skipExecution: Boolean,
vararg cliArgs: String cliArgs: List<String>
) = Unit ) = Unit
} }
@@ -20,23 +20,34 @@ class YarnWorkspaces : YarnBasics() {
rootProject: Project, rootProject: Project,
subProjects: Collection<KotlinCompilationNpmResolution>, subProjects: Collection<KotlinCompilationNpmResolution>,
skipExecution: Boolean, skipExecution: Boolean,
vararg cliArgs: String cliArgs: List<String>
) { ) {
check(rootProject == rootProject.rootProject) check(rootProject == rootProject.rootProject)
if (!skipExecution) setup(rootProject) if (!skipExecution) setup(rootProject)
return resolveWorkspaces(rootProject, subProjects, skipExecution) return resolveWorkspaces(
rootProject,
subProjects,
skipExecution,
cliArgs
)
} }
private fun resolveWorkspaces( private fun resolveWorkspaces(
rootProject: Project, rootProject: Project,
npmProjects: Collection<KotlinCompilationNpmResolution>, npmProjects: Collection<KotlinCompilationNpmResolution>,
skipExecution: Boolean skipExecution: Boolean,
cliArgs: List<String>
) { ) {
val nodeJsWorldDir = NodeJsRootPlugin.apply(rootProject).rootPackageDir val nodeJsWorldDir = NodeJsRootPlugin.apply(rootProject).rootPackageDir
if (!skipExecution) { if (!skipExecution) {
saveRootProjectWorkspacesPackageJson(rootProject, npmProjects, nodeJsWorldDir) saveRootProjectWorkspacesPackageJson(rootProject, npmProjects, nodeJsWorldDir)
yarnExec(rootProject, nodeJsWorldDir, NpmApi.resolveOperationDescription("yarn")) yarnExec(
rootProject,
nodeJsWorldDir,
NpmApi.resolveOperationDescription("yarn"),
cliArgs
)
} }
yarnLockReadTransitiveDependencies(nodeJsWorldDir, npmProjects.flatMap { it.externalNpmDependencies }) yarnLockReadTransitiveDependencies(nodeJsWorldDir, npmProjects.flatMap { it.externalNpmDependencies })
@@ -51,7 +62,8 @@ class YarnWorkspaces : YarnBasics() {
rootPackageJson.private = true rootPackageJson.private = true
val npmProjectWorkspaces = npmProjects.map { it.npmProject.dir.relativeTo(nodeJsWorldDir).path } 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.workspaces = npmProjectWorkspaces + importedProjectWorkspaces
rootPackageJson.saveTo( rootPackageJson.saveTo(