A tool to generate Package.swift
files using a custom DSL allowing version alignment of dependencies across packages.
PackageGenerator
uses ArgumentParser and Stencil.
The command generate-package
requires the following arguments:
path
: Path to the folder containing the packages.template-path
: Path to the Stencil template.dependencies-path
: Path to theRemoteDependencies.json
file.
RemoteDependencies.json
should contain the list of remote dependencies used by your packages. E.g.
{
"dependencies": [
{
"name": "Alamofire",
"url": "https://github.com/Alamofire/Alamofire",
"version": "5.6.1"
},
{
"name": "ViewInspector",
"url": "https://github.com/nalexn/ViewInspector",
"version": "0.9.2"
}
]
}
Packages should be contained in respective folders inside a packages folder and provide a <package_name>.json
spec. E.g.
{
"name": "Example",
"products": [
{
"name": "Example",
"productType": "library",
"targets": [
"ExampleTarget"
]
}
],
"localDependencies": [
{
"name": "ExampleLocalDependency",
"path": "../LocalDependencies"
}
],
"remoteDependencies": [
{
"name": "Alamofire"
},
{
"name": "ViewInspector",
"version": "1.2.3"
},
],
"targets": [
{
"name": "ExampleTarget",
"targetType": "target",
"dependencies": [
{
"name": "Alamofire"
}
],
"sourcesPath": "Framework/Sources",
"resourcesPath": "Resources"
},
{
"name": "ExampleTargetTests",
"targetType": "testTarget",
"dependencies": [
{
"name": "ExampleTarget",
"isTarget": true
},
{
"name": "ViewInspector"
}
],
"sourcesPath": "Tests/Sources",
"resourcesPath": "Resources"
}
]
}
Note that
PackageGenerator
will automatically retrieveurl
&version
values forremoteDependencies
from theRemoteDependencies.json
file. If you need to override those values, you can set them in the package spec.
We provide a default Stencil template that PackageGenerator
can work with.
The command generate-packages
allows you to generate Package.swift files from a given folder of packages.
It takes the same arguments as generate-package
along with packages-folder-path
. PackageGenerator
will loop though subfolders and generate Package.swift files from JSON specs.
Ideally, you want to generate a PackageGenerator
executable and automate tasks both locally and on CI.
In the PackageGenerator
scheme, enable 'Use custom working directory' and set the value to the folder containing the PackageGenerator
package.
The scheme has arguments set to showcase the creation of a Package.swift
file using some provided files.
When running the default scheme you should see a Package.swift
file being generated in the Packages/Example/
folder.
This repository contains shared documents that are used for all of the open source projects provided by Just Eat Takeaway.com.
- LICENSE contains a reference copy of the Apache 2.0 license that applies all Just Eat Takeaway.com projects. Note: this license needs to be included directly in each project.
- CODE_OF_CONDUCT.md describes the Code of Conduct that applies to all contributors to our projects.