Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Init template cleanup #6144

Conversation

bitjammer
Copy link
Contributor

@bitjammer bitjammer commented Feb 10, 2023

Improve the swift package init experience using the following criteria:

  • Simplify the templates to include only the minimum necessary to get started without making assumptions.
  • Use documentation links instead of arbitrary template content to teach people about Swift.
  • Improve the "front door" experience with the help usage.

Detailed list of changes:

  • Remove the system-module template.
  • Remove the manifest template
  • Add a tool template, an executable that uses ArgumentParser
  • Remove README generation.
  • Don't generate empty directories.
  • Don't emit empty dependencies array in manifests.
  • Update library template content:
    • Remove struct definition, use a simple public function instead.
    • Include documentation links for TSPL and the Standard Library.
    • Include documentation links for XCTest in the generated test case.
  • Update executable template content
    • Use simpler top-level code instead of an @main struct.
    • Remove executable tests.
    • Put sources directly in ./Sources.
  • Clean up and align type argument help text
  • Update Usage.md documentation

rdar://98999734

Example resulting file listing

./executable
./executable/.gitignore
./executable/Package.swift
./executable/Sources
./executable/Sources/executable.swift

./tool
./tool/.gitignore
./tool/Package.swift
./tool/Sources
./tool/Sources/tool.swift

./empty
./empty/Package.swift

./library
./library/Tests
./library/Tests/libraryTests
./library/Tests/libraryTests/libraryTests.swift
./library/.gitignore
./library/Package.swift
./library/Sources
./library/Sources/library
./library/Sources/library/library.swift

Resulting command line usage

OVERVIEW: Initialize a new package

USAGE: swift package init [--type <type>] [--name <name>]

OPTIONS:
  --type <type>           Package type: (default: library)
        library           - A package with a library.
        executable        - A package with an executable.
        tool              - A package with an executable that uses
                            Swift Argument Parser. Use this template if you
                            plan to have a rich set of command-line arguments.
        empty             - An empty package with a Package.swift manifest.
  --name <name>           Provide custom package name
  --version               Show the version.
  -h, -help, --help       Show help information.

@bitjammer bitjammer requested a review from TimTr February 10, 2023 22:00
bitjammer added a commit to bitjammer/swift-package-manager that referenced this pull request Feb 10, 2023
@bitjammer
Copy link
Contributor Author

@swift-ci Please test

@bitjammer
Copy link
Contributor Author

@swift-ci Please smoke test

CHANGELOG.md Outdated Show resolved Hide resolved
bitjammer added a commit to bitjammer/swift-package-manager that referenced this pull request Feb 11, 2023
Improve the `swift package init` experience using the following criteria:

- Simplify the templates to include only the minimum necessary to get started
  without making assumptions.
- Use documentation links instead of arbitrary template content to teach people
  about Swift.
- Improve the "front door" experience with the help usage.

Detailed list of changes:

- Remove the `system-module` template.
- Remove the `manifest` template - it's emptier than `empty` and isn't
  providing a lot of value on its own. Make the `empty` template only generate
a manifest instead.
- Remove README generation.
- Don't generate empty directories.
- Don't emit empty dependencies array in manifests.
- Update `library` template content:
  - Remove struct definition, use a simple public function instead.
  - Include documentation links for TSPL and the Standard Library.
  - Include documentation links for XCTest in the generated test case.
- Update `executable` template content
  - Use simpler top-level code instead of an `@main` struct.
  - Remove executable tests.
  - Put sources directly in `./Sources`.
- Clean up and align `type` argument help text
- Update Usage.md documentation
-  Update CHANGELOG to reflect init template changes in swiftlang#6144

rdar://98999734
@bitjammer bitjammer force-pushed the acgarland/rdar-98999734-update-init-templates branch from 04ef2f3 to b574df1 Compare February 11, 2023 01:07
bitjammer added a commit to bitjammer/swift-package-manager that referenced this pull request Feb 11, 2023
Improve the `swift package init` experience using the following criteria:

- Simplify the templates to include only the minimum necessary to get started
  without making assumptions.
- Use documentation links instead of arbitrary template content to teach people
  about Swift.
- Improve the "front door" experience with the help usage.

Detailed list of changes:

- Remove the `system-module` template.
- Remove the `manifest` template - it's emptier than `empty` and isn't
  providing a lot of value on its own. Make the `empty` template only generate
a manifest instead.
- Remove README generation.
- Don't generate empty directories.
- Don't emit empty dependencies array in manifests.
- Update `library` template content:
  - Remove struct definition, use a simple public function instead.
  - Include documentation links for TSPL and the Standard Library.
  - Include documentation links for XCTest in the generated test case.
- Update `executable` template content
  - Use simpler top-level code instead of an `@main` struct.
  - Remove executable tests.
  - Put sources directly in `./Sources`.
- Clean up and align `type` argument help text
- Update Usage.md documentation
-  Update CHANGELOG to reflect init template changes in swiftlang#6144

rdar://98999734
@bitjammer bitjammer force-pushed the acgarland/rdar-98999734-update-init-templates branch from b574df1 to 079a811 Compare February 11, 2023 01:08
bitjammer added a commit to bitjammer/swift-package-manager that referenced this pull request Feb 13, 2023
Improve the `swift package init` experience using the following criteria:

- Simplify the templates to include only the minimum necessary to get started
  without making assumptions.
- Use documentation links instead of arbitrary template content to teach people
  about Swift.
- Improve the "front door" experience with the help usage.

Detailed list of changes:

- Remove the `system-module` template.
- Remove the `manifest` template - it's emptier than `empty` and isn't
  providing a lot of value on its own. Make the `empty` template only generate
a manifest instead.
- Remove README generation.
- Don't generate empty directories.
- Don't emit empty dependencies array in manifests.
- Update `library` template content:
  - Remove struct definition, use a simple public function instead.
  - Include documentation links for TSPL and the Standard Library.
  - Include documentation links for XCTest in the generated test case.
- Update `executable` template content
  - Use simpler top-level code instead of an `@main` struct.
  - Remove executable tests.
  - Put sources directly in `./Sources`.
- Clean up and align `type` argument help text
- Update Usage.md documentation
-  Update CHANGELOG to reflect init template changes in swiftlang#6144

rdar://98999734
@bitjammer bitjammer force-pushed the acgarland/rdar-98999734-update-init-templates branch from 079a811 to cc0c708 Compare February 13, 2023 21:58
@bitjammer
Copy link
Contributor Author

@swift-ci Please smoke test

bitjammer added a commit to bitjammer/swift-package-manager that referenced this pull request Feb 13, 2023
Improve the `swift package init` experience using the following criteria:

- Simplify the templates to include only the minimum necessary to get started
  without making assumptions.
- Use documentation links instead of arbitrary template content to teach people
  about Swift.
- Improve the "front door" experience with the help usage.

Detailed list of changes:

- Remove the `system-module` template.
- Remove the `manifest` template - it's emptier than `empty` and isn't
  providing a lot of value on its own. Make the `empty` template only generate
a manifest instead.
- Remove README generation.
- Don't generate empty directories.
- Don't emit empty dependencies array in manifests.
- Update `library` template content:
  - Remove struct definition, use a simple public function instead.
  - Include documentation links for TSPL and the Standard Library.
  - Include documentation links for XCTest in the generated test case.
- Update `executable` template content
  - Use simpler top-level code instead of an `@main` struct.
  - Remove executable tests.
  - Put sources directly in `./Sources`.
- Clean up and align `type` argument help text
- Update Usage.md documentation
-  Update CHANGELOG to reflect init template changes in swiftlang#6144

rdar://98999734
@bitjammer bitjammer force-pushed the acgarland/rdar-98999734-update-init-templates branch from cc0c708 to ff2ba73 Compare February 13, 2023 23:40
@bitjammer
Copy link
Contributor Author

@swift-ci Please smoke test

Improve the `swift package init` experience using the following criteria:

- Simplify the templates to include only the minimum necessary to get started
  without making assumptions.
- Use documentation links instead of template content to teach people
  about Swift.
- Improve the "front door" experience with the help usage.

Detailed list of changes:

- Remove the `system-module` template.
- Remove the `manifest` template
- Add a new `tool` template, an executable that uses ArgumentParser
a manifest instead.
- Remove README generation.
- Don't generate empty directories.
- Don't emit empty dependencies array in manifests.
- Update `library` template content:
  - Remove struct definition, use a simple public function instead.
  - Include documentation links for TSPL and the Standard Library.
  - Include documentation links for XCTest in the generated test case.
- Update `executable` template content
  - Use simpler top-level code instead of an `@main` struct.
  - Remove executable tests.
  - Put sources directly in `./Sources`.
- Clean up and align `type` argument help text
- Update Usage.md documentation
-  Update CHANGELOG to reflect init template changes in swiftlang#6144

rdar://98999734
@bitjammer bitjammer force-pushed the acgarland/rdar-98999734-update-init-templates branch from ff2ba73 to 8748e9e Compare February 15, 2023 19:52
Copy link
Contributor

@neonichu neonichu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, Ashley.

This is looking great, we should give the forum post a couple of days to see if any interesting feedback will be provided by the community, but otherwise good to merge.

@bitjammer
Copy link
Contributor Author

@swift-ci Please smoke test

@TimTr
Copy link

TimTr commented Feb 20, 2023

Looks good - here is the forum thread since I didn't see it referenced here (may have just missed it): https://forums.swift.org/t/update-to-swift-package-init-templates/63145/8

@tomerd
Copy link
Contributor

tomerd commented Feb 21, 2023

@bitjammer @TimTr is this ready to be merged? do you feel we collected enough feedback from the community?

@TimTr
Copy link

TimTr commented Feb 21, 2023

@tomerd and @bitjammer I think we're good to merge. Post is live for a week now.

@neonichu neonichu merged commit 893ccb4 into swiftlang:main Feb 21, 2023
@bitjammer bitjammer deleted the acgarland/rdar-98999734-update-init-templates branch February 22, 2023 19:32
bitjammer added a commit to bitjammer/swift-package-manager that referenced this pull request Feb 22, 2023
Improve the `swift package init` experience using the following criteria:

- Simplify the templates to include only the minimum necessary to get started
  without making assumptions.
- Use documentation links instead of template content to teach people
  about Swift.
- Improve the "front door" experience with the help usage.

Detailed list of changes:

- Remove the `system-module` template.
- Remove the `manifest` template
- Add a new `tool` template, an executable that uses ArgumentParser
a manifest instead.
- Remove README generation.
- Don't generate empty directories.
- Don't emit empty dependencies array in manifests.
- Update `library` template content:
  - Remove struct definition, use a simple public function instead.
  - Include documentation links for TSPL and the Standard Library.
  - Include documentation links for XCTest in the generated test case.
- Update `executable` template content
  - Use simpler top-level code instead of an `@main` struct.
  - Remove executable tests.
  - Put sources directly in `./Sources`.
- Clean up and align `type` argument help text
- Update Usage.md documentation
-  Update CHANGELOG to reflect init template changes in swiftlang#6144

rdar://98999734
tomerd pushed a commit that referenced this pull request Feb 23, 2023
@glbrntt
Copy link
Contributor

glbrntt commented Mar 6, 2023

Missed this when it was posted in the forums but I think some of the changes are a bit of a miss-step here. Responded in the forums (https://forums.swift.org/t/update-to-swift-package-init-templates/63145)

cc @FranzBusch

Lukasa added a commit to Lukasa/swift-nio that referenced this pull request Mar 13, 2023
Motivation:

SwiftPM has changed its default layout for packages in
swiftlang/swift-package-manager#6144. This breaks our CI, which assumes the
prior layout. We should work around this.

Modifications:

Enhance the code to tolerate both layouts.

Result:

Integration tests run on all platforms
Lukasa added a commit to Lukasa/swift-nio that referenced this pull request Mar 13, 2023
Motivation:

SwiftPM has changed its default layout for packages in
swiftlang/swift-package-manager#6144. This breaks our CI, which assumes the
prior layout. We should work around this.

Modifications:

Enhance the code to tolerate both layouts.

Result:

Integration tests run on all platforms
glbrntt pushed a commit to apple/swift-nio that referenced this pull request Mar 13, 2023
Motivation:

SwiftPM has changed its default layout for packages in
swiftlang/swift-package-manager#6144. This breaks our CI, which assumes the
prior layout. We should work around this.

Modifications:

Enhance the code to tolerate both layouts.

Result:

Integration tests run on all platforms
bitjammer added a commit to bitjammer/swift-package-manager that referenced this pull request Mar 16, 2023
After getting some feedback about the added `path` argument for executable
packages generated with `swift package init` (swiftlang#6144), this change allows a
target's sources to occupy the entire sources directory when there is only one
target in the package. All package types can benefit from this.

When there is more than one target in a package, the existing requirements for
target sources still apply.

This change should be compatible with existing layouts as well. If there is
only a single target in a package, then sources can of course continue to exist
in `./Sources/<target>`.

Amend the `executable` template's generated manifest to not include the `path`
argument anymore.

rdar://106829666
bitjammer added a commit to bitjammer/swift-package-manager that referenced this pull request Mar 16, 2023
After getting some feedback about the added `path` argument for executable
packages generated with `swift package init` (swiftlang#6144), this change allows a
target's sources to occupy the entire sources directory when there is only one
target in the package. All package types can benefit from this.

When there is more than one target in a package, the existing requirements for
target sources still apply.

This change should be compatible with existing layouts as well. If there is
only a single target in a package, then sources can of course continue to exist
in `./Sources/<target>`.

Amend the `executable` template's generated manifest to not include the `path`
argument anymore.

rdar://106829666
bitjammer added a commit to bitjammer/swift-package-manager that referenced this pull request Mar 16, 2023
After getting some feedback about the added `path` argument for executable
packages generated with `swift package init` (swiftlang#6144), this change allows a
target's sources to occupy the entire sources directory when there is only one
target in the package. All package types can benefit from this.

When there is more than one target in a package, the existing requirements for
target sources still apply.

This change should be compatible with existing layouts as well. If there is
only a single target in a package, then sources can of course continue to exist
in `./Sources/<target>`.

Amend the `executable` template's generated manifest to not include the `path`
argument anymore.

rdar://106829666
bitjammer added a commit to bitjammer/swift-package-manager that referenced this pull request Mar 16, 2023
After getting some feedback about the added `path` argument for executable
packages generated with `swift package init` (swiftlang#6144), this change allows a
target's sources to occupy the entire sources directory when there is only one
target in the package. All package types can benefit from this.

When there is more than one target in a package, the existing requirements for
target sources still apply.

This change should be compatible with existing layouts as well. If there is
only a single target in a package, then sources can of course continue to exist
in `./Sources/<target>`.

Amend the `executable` template's generated manifest to not include the `path`
argument anymore.

rdar://106829666
bitjammer added a commit to bitjammer/swift-package-manager that referenced this pull request Mar 17, 2023
After getting some feedback about the added `path` argument for executable
packages generated with `swift package init` (swiftlang#6144), this change allows a
target's sources to occupy the entire sources directory when there is only one
target in the package. All package types can benefit from this.

When there is more than one target in a package, the existing requirements for
target sources still apply.

This change should be compatible with existing layouts as well. If there is
only a single target in a package, then sources can of course continue to exist
in `./Sources/<target>`.

Amend the `executable` template's generated manifest to not include the `path`
argument anymore.

rdar://106829666
bitjammer added a commit to bitjammer/swift-package-manager that referenced this pull request Mar 20, 2023
After getting some feedback about the added `path` argument for executable
packages generated with `swift package init` (swiftlang#6144), this change allows a
target's sources to occupy the entire "predefined sources directory" (e.g.
`Sources`, `Tests`, or `Plugins`) when there is only one target of a specific
kind occupying one of those directories in the package. All package types can
benefit from this.

For example, if there is only one library target and one test target, one can
put sources directly in `./Sources` and `./Tests`. Adding another library means
that one has to put the sources for TargetA in `./Sources/TargetA` and the
sources for TargetB in `./Sources/TargetB`, and so on.

When there is more than one target of a type in a package, the existing
requirements for target sources still apply.

This change should be compatible with existing layouts as well. If there is
only a single target in a package, then sources can of course continue to exist
exclusively in `./Sources/<target>`, or `./Tests/<testTarget>`, etc.

Amend the `executable` and `tool` template's generated manifest to not include
the `path` argument anymore as it is no longer needed.

With this change, the `library` template type can also put its sources and tests
directly in the `./Sources` and `./Tests` directories respectively.

All of the above only takes place when the tools version is set to 5.9 or
higher in the manifest.

rdar://106829666
bitjammer added a commit to bitjammer/swift-package-manager that referenced this pull request Mar 20, 2023
After getting some feedback about the added `path` argument for executable
packages generated with `swift package init` (swiftlang#6144), this change allows a
target's sources to occupy the entire "predefined sources directory" (e.g.
`Sources`, `Tests`, or `Plugins`) when there is only one target of a specific
kind occupying one of those directories in the package. All package types can
benefit from this.

For example, if there is only one library target and one test target, one can
put sources directly in `./Sources` and `./Tests`. Adding another library means
that one has to put the sources for TargetA in `./Sources/TargetA` and the
sources for TargetB in `./Sources/TargetB`, and so on.

When there is more than one target of a type in a package, the existing
requirements for target sources still apply.

This change should be compatible with existing layouts as well. If there is
only a single target in a package, then sources can of course continue to exist
exclusively in `./Sources/<target>`, or `./Tests/<testTarget>`, etc.

Amend the `executable` and `tool` template's generated manifest to not include
the `path` argument anymore as it is no longer needed.

With this change, the `library` template type can also put its sources and tests
directly in the `./Sources` and `./Tests` directories respectively.

All of the above only takes place when the tools version is set to 5.9 or
higher in the manifest.

rdar://106829666
bitjammer added a commit to bitjammer/swift-package-manager that referenced this pull request Mar 20, 2023
After getting some feedback about the added `path` argument for executable
packages generated with `swift package init` (swiftlang#6144), this change allows a
target's sources to occupy the entire "predefined sources directory" (e.g.
`Sources`, `Tests`, or `Plugins`) when there is only one target of a specific
kind occupying one of those directories in the package. All package types can
benefit from this.

For example, if there is only one library target and one test target, one can
put sources directly in `./Sources` and `./Tests`. Adding another library means
that one has to put the sources for TargetA in `./Sources/TargetA` and the
sources for TargetB in `./Sources/TargetB`, and so on.

When there is more than one target of a type in a package, the existing
requirements for target sources still apply.

This change should be compatible with existing layouts as well. If there is
only a single target in a package, then sources can of course continue to exist
exclusively in `./Sources/<target>`, or `./Tests/<testTarget>`, etc.

Amend the `executable` and `tool` template's generated manifest to not include
the `path` argument anymore as it is no longer needed.

With this change, the `library` template type can also put its sources and tests
directly in the `./Sources` and `./Tests` directories respectively.

All of the above only takes place when the tools version is set to 5.9 or
higher in the manifest.

rdar://106829666
bitjammer added a commit that referenced this pull request Mar 21, 2023
…6294)

After getting some feedback about the added `path` argument for executable
packages generated with `swift package init` (#6144), this change allows a
target's sources to occupy the entire "predefined sources directory" (e.g.
`Sources`, `Tests`, or `Plugins`) when there is only one target of a specific
kind occupying one of those directories in the package. All package types can
benefit from this.

For example, if there is only one library target and one test target, one can
put sources directly in `./Sources` and `./Tests`. Adding another library means
that one has to put the sources for TargetA in `./Sources/TargetA` and the
sources for TargetB in `./Sources/TargetB`, and so on.

When there is more than one target of a type in a package, the existing
requirements for target sources still apply.

This change should be compatible with existing layouts as well. If there is
only a single target in a package, then sources can of course continue to exist
exclusively in `./Sources/<target>`, or `./Tests/<testTarget>`, etc.

Amend the `executable` and `tool` template's generated manifest to not include
the `path` argument anymore as it is no longer needed.

With this change, the `library` template type can also put its sources and tests
directly in the `./Sources` and `./Tests` directories respectively.

All of the above only takes place when the tools version is set to 5.9 or
higher in the manifest.

rdar://106829666
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants