Skip to content

Commit

Permalink
DSL based Migrator API and a Updated Change Model (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
Supereg authored Jan 4, 2022
1 parent f81263e commit b224604
Show file tree
Hide file tree
Showing 309 changed files with 9,984 additions and 5,426 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ jobs:
uses: Apodini/.github/.github/workflows/build-and-test.yml@main
with:
packagename: ApodiniMigrator
usexcodebuild: false
supportsmacos11: true
testdocc: false
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: Apodini/.github/.github/workflows/build-and-test.yml@main
with:
packagename: ApodiniMigrator
usexcodebuild: false
supportsmacos11: true
testdocc: false
reuse_action:
name: REUSE Compliance Check
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
.idea

# Swift Package Manager
Package.resolved
*.xcodeproj
.swiftpm
.build/
Expand Down
16 changes: 9 additions & 7 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -325,17 +325,16 @@ only_rules:
excluded: # paths to ignore during linting. Takes precedence over `included`.
- .build
- .swiftpm
- Tests
- Sources/ApodiniMigratorCompare/Change/ProviderSupport.swift
- Sources/ApodiniMigratorCompare/AnyCodableElement.swift
- Sources/RESTMigrator/Resources
- Tests/ApodiniMigratorTests/Resources

closure_body_length: # Closure bodies should not span too many lines.
- 35 # warning - default: 20
- 35 # error - default: 100

enum_case_associated_values_count: # Number of associated values in an enum case should be low
- 5 # warning - default: 5
- 5 # error - default: 6
- 8 # warning - default: 5
- 8 # error - default: 6

file_length: # Files should not span too many lines.
- 500 # warning - default: 400
Expand All @@ -351,18 +350,21 @@ function_parameter_count: # Number of function parameters should be low.

identifier_name:
excluded: # excluded names
- v1
- v2
- id
- ok
- or
- to
- at

large_tuple: # Tuples shouldn't have too many members. Create a custom type instead.
- 2 # warning - default: 2
- 2 # error - default: 3

line_length: # Lines should not span too many characters.
warning: 200 # default: 120
error: 200
warning: 150 # default: 120
error: 150
ignores_comments: true # default: false
ignores_urls: true # default: false
ignores_function_declarations: false # default: false
Expand Down
124 changes: 124 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{
"object": {
"pins": [
{
"package": "ApodiniTypeInformation",
"repositoryURL": "https://github.com/Apodini/ApodiniTypeInformation.git",
"state": {
"branch": null,
"revision": "b4e73a6f92bd0930c9f1f8a857504b85b943dd88",
"version": "0.3.0"
}
},
{
"package": "AssociatedTypeRequirementsKit",
"repositoryURL": "https://github.com/nerdsupremacist/AssociatedTypeRequirementsKit.git",
"state": {
"branch": null,
"revision": "2e4c49c21ffb2135f1c99fbfcf2119c9d24f5e8c",
"version": "0.3.2"
}
},
{
"package": "FineJSON",
"repositoryURL": "https://github.com/omochi/FineJSON.git",
"state": {
"branch": null,
"revision": "05101709243cb66d80c92e645210a3b80cf4e17f",
"version": "1.14.0"
}
},
{
"package": "MetadataSystem",
"repositoryURL": "https://github.com/Apodini/MetadataSystem.git",
"state": {
"branch": null,
"revision": "06cac46a958fdf700054f12f682b5c8f27577c9f",
"version": "0.1.1"
}
},
{
"package": "PathKit",
"repositoryURL": "https://github.com/kylef/PathKit.git",
"state": {
"branch": null,
"revision": "3bfd2737b700b9a36565a8c94f4ad2b050a5e574",
"version": "1.0.1"
}
},
{
"package": "RichJSONParser",
"repositoryURL": "https://github.com/omochi/RichJSONParser.git",
"state": {
"branch": null,
"revision": "263e2ecfe88d0500fa99e4cbc8c948529d335534",
"version": "3.0.0"
}
},
{
"package": "Runtime",
"repositoryURL": "https://github.com/wickwirew/Runtime.git",
"state": {
"branch": null,
"revision": "dad03135d7701a4e7b3a4051e75d6b37bd8e178e",
"version": "2.2.4"
}
},
{
"package": "Spectre",
"repositoryURL": "https://github.com/kylef/Spectre.git",
"state": {
"branch": null,
"revision": "26cc5e9ae0947092c7139ef7ba612e34646086c7",
"version": "0.10.1"
}
},
{
"package": "swift-argument-parser",
"repositoryURL": "https://github.com/apple/swift-argument-parser",
"state": {
"branch": null,
"revision": "83b23d940471b313427da226196661856f6ba3e0",
"version": "0.4.4"
}
},
{
"package": "swift-collections",
"repositoryURL": "https://github.com/apple/swift-collections.git",
"state": {
"branch": null,
"revision": "48254824bb4248676bf7ce56014ff57b142b77eb",
"version": "1.0.2"
}
},
{
"package": "swift-log",
"repositoryURL": "https://github.com/apple/swift-log.git",
"state": {
"branch": null,
"revision": "5d66f7ba25daf4f94100e7022febf3c75e37a6c7",
"version": "1.4.2"
}
},
{
"package": "XCTAssertCrash",
"repositoryURL": "https://github.com/norio-nomura/XCTAssertCrash.git",
"state": {
"branch": null,
"revision": "880c5241254da53f32caf77248ee3d25cb2a9630",
"version": "0.2.0"
}
},
{
"package": "Yams",
"repositoryURL": "https://github.com/jpsim/Yams.git",
"state": {
"branch": null,
"revision": "9ff1cc9327586db4e0c8f46f064b6a82ec1566fa",
"version": "4.0.6"
}
}
]
},
"version": 1
}
92 changes: 62 additions & 30 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,81 +18,113 @@ let package = Package(
.iOS(.v13)
],
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(name: "ApodiniMigratorCore", targets: ["ApodiniMigratorCore"]),
.library(name: "ApodiniMigrator", targets: ["ApodiniMigrator"]),
.library(name: "ApodiniMigratorShared", targets: ["ApodiniMigratorShared"]),
.library(name: "ApodiniMigratorCore", targets: ["ApodiniMigratorCore"]),
.library(name: "ApodiniMigratorClientSupport", targets: ["ApodiniMigratorClientSupport"]),
.library(name: "ApodiniMigratorCompare", targets: ["ApodiniMigratorCompare"]),
.library(name: "ApodiniMigrator", targets: ["ApodiniMigrator"]),
.library(name: "RESTMigrator", targets: ["RESTMigrator"]),
.executable(name: "migrator", targets: ["ApodiniMigratorCLI"])
],
dependencies: [
// Dependencies declare other packages that this package depends on.
.package(url: "https://github.com/Apodini/ApodiniTypeInformation.git", .upToNextMinor(from: "0.2.0")),
.package(url: "https://github.com/Apodini/ApodiniTypeInformation.git", .upToNextMinor(from: "0.3.0")),
.package(url: "https://github.com/kylef/PathKit.git", from: "1.0.1"),
.package(url: "https://github.com/apple/swift-argument-parser", .upToNextMinor(from: "0.4.0")),
.package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"),
.package(url: "https://github.com/omochi/FineJSON.git", from: "1.14.0"),
.package(url: "https://github.com/jpsim/Yams.git", from: "4.0.0")
.package(url: "https://github.com/jpsim/Yams.git", from: "4.0.0"),
.package(url: "https://github.com/apple/swift-collections.git", .upToNextMajor(from: "1.0.0")),

// testing runtime crashes
.package(url: "https://github.com/norio-nomura/XCTAssertCrash.git", from: "0.2.0")
],
targets: [
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
// Targets can depend on other targets in this package, and on products in packages this package depends on.
// The lowest level ApodiniMigrator package providing common API used across several targets, including
// common file extensions, encoding and decoding strategies and output formatting
.target(
name: "ApodiniMigratorCore",
name: "ApodiniMigratorShared",
dependencies: [
.target(name: "ApodiniMigratorShared"),
.product(name: "ApodiniTypeInformation", package: "ApodiniTypeInformation"),
.product(name: "PathKit", package: "PathKit"),
.product(name: "FineJSON", package: "FineJSON"),
.product(name: "Yams", package: "Yams")
]
),
.executableTarget(
name: "ApodiniMigratorCLI",

// The core ApodiniMigrator package. It provides access to the TypeInformation framework and introduces
// the generalized API document.
.target(
name: "ApodiniMigratorCore",
dependencies: [
.target(name: "ApodiniMigrator"),
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "Logging", package: "swift-log")
.target(name: "ApodiniMigratorShared"),
.product(name: "ApodiniTypeInformation", package: "ApodiniTypeInformation"),
.product(name: "Yams", package: "Yams"),
.product(name: "OrderedCollections", package: "swift-collections")
]
),

// This target provides any necessary interfaces for REST client libraries!
.target(
name: "ApodiniMigratorClientSupport",
dependencies: [
.target(name: "ApodiniMigratorCore")
]
),

// The Compare target builds upon the Core package containing the generalized MigrationGuide
// and all the necessary utilities for the comparison algorithms.
.target(
name: "ApodiniMigratorCompare",
dependencies: [
.target(name: "ApodiniMigratorClientSupport")
]
),

// The Migrator package provides the Migrator Interface. So everything which is required
// to build your own Migrator. LibraryStructure generation, Source Code generation, ...
.target(
name: "ApodiniMigrator",
dependencies: [
.target(name: "ApodiniMigratorCompare"),
.target(name: "ApodiniMigratorClientSupport"),
.product(name: "Logging", package: "swift-log")
],
resources: [
.process("Templates")
]
),

// This target packages the REST client library generator and migrator.
// Further it contain the template files for the REST client library.
.target(
name: "ApodiniMigratorShared",
name: "RESTMigrator",
dependencies: [
.product(name: "PathKit", package: "PathKit"),
.product(name: "FineJSON", package: "FineJSON"),
.product(name: "Yams", package: "Yams")
.target(name: "ApodiniMigrator"),
.target(name: "ApodiniMigratorCompare"),
.target(name: "ApodiniMigratorClientSupport"),
.product(name: "Logging", package: "swift-log")
],
resources: [
.process("Resources")
]
),

.target(
name: "ApodiniMigratorCompare",

// This target implements the command line interface of the ApodiniMigrator utility.
// It offers command to generate and migrate client libraries and a sub command
// to compare API documents.
.executableTarget(
name: "ApodiniMigratorCLI",
dependencies: [
.target(name: "ApodiniMigratorClientSupport")
.target(name: "RESTMigrator"),
.product(name: "ArgumentParser", package: "swift-argument-parser"),
.product(name: "Logging", package: "swift-log")
]
),

// The unified test target.
.testTarget(
name: "ApodiniMigratorTests",
dependencies: [
"ApodiniMigratorCore",
"ApodiniMigrator",
"RESTMigrator",
"ApodiniMigratorCompare",
"ApodiniMigratorClientSupport"
"ApodiniMigratorClientSupport",
.product(name: "XCTAssertCrash", package: "XCTAssertCrash", condition: .when(platforms: [.macOS]))
],
resources: [
.process("Resources")
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ SPDX-License-Identifier: MIT
[![Build and Test](https://github.com/Apodini/ApodiniMigrator/actions/workflows/build-and-test.yml/badge.svg)](https://github.com/Apodini/ApodiniMigrator/actions/workflows/build-and-test.yml)
[![codecov](https://codecov.io/gh/Apodini/ApodiniMigrator/branch/develop/graph/badge.svg?token=5MMKMPO5NR)](https://codecov.io/gh/Apodini/ApodiniMigrator)

`ApodiniMigrator` is a Swift package that performs several automated tasks, to migrate client applications after a Web Service publishes a new version that contains breaking changes. The tasks include automated generation of an intermediary client library that contains all required components to establish a client-server communication. Furthermore, `ApodiniMigrator` is able to automatically generate a machine-readable migration guide in either `json` or `yaml` format, that describes the changes between two subsequent Web API versions, and includes auxiliary migrating actions. By means of the migration guide, `ApodiniMigrator` can automatically migrate the intermadiary client library, ensuring therefore the compatibility with the new Web API version. It is part of [**Apodini**](https://github.com/Apodini/Apodini), a composable framework to build Web Services in using Swift.
`ApodiniMigrator` is a Swift package that performs several automated tasks, to migrate client applications after a Web Service publishes a new version that contains breaking changes. The tasks include automated generation of an intermediary client library that contains all required components to establish a client-server communication. Furthermore, `ApodiniMigrator` is able to automatically generate a machine-readable migration guide in either `json` or `yaml` format, that describes the changes between two subsequent Web API versions, and includes auxiliary migrating actions. By means of the migration guide, `ApodiniMigrator` can automatically migrate the intermediary client library, ensuring therefore the compatibility with the new Web API version. It is part of [**Apodini**](https://github.com/Apodini/Apodini), a composable framework to build Web Services in using Swift.

## Requirements

Expand Down Expand Up @@ -168,7 +168,7 @@ info org.apodini.migrator : Starting generation of the migration guide...
info org.apodini.migrator : Migration guide was generated successfully at /path/to/ApodiniMigrator/Resources/ExampleDocuments/migration_guide.json.
```

Once the migration guide has been generate, use `migrate` argument to migrate the initial library:
Once the migration guide has been generated, use `migrate` argument to migrate the initial library:

```console
$ ./migrator migrate
Expand All @@ -185,7 +185,7 @@ info org.apodini.migrator : Package QONECTIQ was migrated successfully. You can
```

## Contributing
Contributions to this projects are welcome. Please make sure to read the [contribution guidelines](https://github.com/Apodini/.github/blob/release/CONTRIBUTING.md) first.
Contributions to the projects are welcome. Please make sure to read the [contribution guidelines](https://github.com/Apodini/.github/blob/release/CONTRIBUTING.md) first.

## License
This project is licensed under the MIT License. See [License](https://github.com/Apodini/ApodiniMigrator/blob/develop/LICENSES) for more information.
Loading

0 comments on commit b224604

Please sign in to comment.