This PR updates how nef generates PlaygroundBooks from a Swift Package. Currently, it takes the whole targets (and its dependencies) from a Package and map to .playgroundmodules to build a Swift Playground compatible; this PR changes how it works, taking only the targets necessaries (and its dependencies) from the products -libraries- defined in the Package.
It fixes bugs about including targets do not necessary to build the final library.
How is it implemented?
Using a new swift package option: dump-package; it prints parsed Package.swift as JSON. It lets us read the products and the targets section of a Package to filter extracted modules.
packageProducts <- readPackageGraph() // (helper: swift package dump-packate)
reposProducts <- repos.flatTraverse(readPackageGraph)
reposModules <- readModulesInPackage() // (helper: swift package describe)
products <- filterReposProducts(reposProducts, byPackage: packageProducts)
modules <- extractPackageModules(reposModules, inProducts: products)
return modules // These modules will be used to generate the Playground Book
Details
This PR updates how nef generates PlaygroundBooks from a Swift Package. Currently, it takes the whole
targets
(and its dependencies) from a Package and map to.playgroundmodules
to build a Swift Playground compatible; this PR changes how it works, taking only the targets necessaries (and its dependencies) from theproducts
-libraries- defined in the Package.How is it implemented?
Using a new
swift package
option: dump-package; it prints parsed Package.swift as JSON. It lets us read theproducts
and thetargets
section of a Package to filter extracted modules.You can test this
dump package
command,