From 6811c71bd6e9936a93b8f1320d5e8df02ddc6eff Mon Sep 17 00:00:00 2001 From: "T. R. Bernstein" <137705289+trbernstein@users.noreply.github.com> Date: Tue, 30 Sep 2025 18:48:15 +0200 Subject: [PATCH] refactor: Adapt to new repository --- .github/workflows/danger.yml | 7 +- .github/workflows/lint-cocoapods.yml | 7 +- .github/workflows/swiftlint.yml | 7 +- .github/workflows/tag-publish.yml | 18 -- .github/workflows/test-spm.yml | 15 +- .swiftlint.yml | 10 +- CHANGELOG.md | 124 ++++++------- Gemfile | 2 +- Gemfile.lock | 171 ++++++------------ LICENSE | 3 +- Package.resolved | 18 +- Package.swift | 2 +- Rakefile | 4 +- Sources/Stencil/Context.swift | 9 +- Sources/Stencil/DynamicMemberLookup.swift | 6 - Sources/Stencil/Environment.swift | 6 - Sources/Stencil/Errors.swift | 6 - Sources/Stencil/Expression.swift | 6 - Sources/Stencil/Extension.swift | 6 - Sources/Stencil/FilterTag.swift | 6 - Sources/Stencil/Filters.swift | 6 - Sources/Stencil/ForTag.swift | 10 +- Sources/Stencil/IfTag.swift | 9 +- Sources/Stencil/Include.swift | 8 - Sources/Stencil/Inheritance.swift | 8 +- Sources/Stencil/KeyPath.swift | 6 - Sources/Stencil/LazyValueWrapper.swift | 6 - Sources/Stencil/Lexer.swift | 13 +- Sources/Stencil/Loader.swift | 24 +-- Sources/Stencil/Node.swift | 10 +- Sources/Stencil/NowTag.swift | 6 - Sources/Stencil/Parser.swift | 8 +- Sources/Stencil/Template.swift | 16 +- Sources/Stencil/Tokenizer.swift | 12 +- Sources/Stencil/TrimBehaviour.swift | 19 +- Sources/Stencil/Variable.swift | 6 - Stencil.podspec.json | 10 +- Tests/StencilTests/ContextSpec.swift | 6 - .../EnvironmentBaseAndChildTemplateSpec.swift | 8 +- .../EnvironmentIncludeTemplateSpec.swift | 8 +- Tests/StencilTests/EnvironmentSpec.swift | 7 - Tests/StencilTests/ExpressionSpec.swift | 8 +- Tests/StencilTests/FilterSpec.swift | 6 - Tests/StencilTests/FilterTagSpec.swift | 6 - Tests/StencilTests/ForNodeSpec.swift | 6 - Tests/StencilTests/Helpers.swift | 10 +- Tests/StencilTests/IfNodeSpec.swift | 6 - Tests/StencilTests/IncludeSpec.swift | 8 +- Tests/StencilTests/InheritanceSpec.swift | 8 +- Tests/StencilTests/LexerSpec.swift | 10 +- Tests/StencilTests/LoaderSpec.swift | 8 +- Tests/StencilTests/NodeSpec.swift | 6 - Tests/StencilTests/NowNodeSpec.swift | 6 - Tests/StencilTests/ParserSpec.swift | 6 - Tests/StencilTests/StencilSpec.swift | 6 - Tests/StencilTests/TemplateSpec.swift | 6 - Tests/StencilTests/TokenSpec.swift | 6 - Tests/StencilTests/TrimBehaviourSpec.swift | 6 - Tests/StencilTests/VariableSpec.swift | 6 - docs/_templates/sidebar_intro.html | 18 +- docs/conf.py | 2 +- docs/installation.rst | 35 +--- rakelib/check_changelog.rb | 2 +- rakelib/lint.rake | 4 +- rakelib/release.rake | 20 +- rakelib/utils.rake | 2 +- 66 files changed, 224 insertions(+), 622 deletions(-) diff --git a/.github/workflows/danger.yml b/.github/workflows/danger.yml index 322aefc..cb04915 100644 --- a/.github/workflows/danger.yml +++ b/.github/workflows/danger.yml @@ -2,7 +2,8 @@ name: Danger on: push: - branches: master + branches: + - main pull_request: jobs: @@ -10,10 +11,10 @@ jobs: name: Danger Check runs-on: ubuntu-latest steps: - - + - name: Checkout uses: actions/checkout@v3 - - + - name: Setup Ruby uses: ruby/setup-ruby@v1 with: diff --git a/.github/workflows/lint-cocoapods.yml b/.github/workflows/lint-cocoapods.yml index 60e88e7..af48011 100644 --- a/.github/workflows/lint-cocoapods.yml +++ b/.github/workflows/lint-cocoapods.yml @@ -2,7 +2,8 @@ name: Lint Cocoapods on: push: - branches: master + branches: + - main pull_request: jobs: @@ -10,10 +11,10 @@ jobs: name: Pod Lint runs-on: ubuntu-latest steps: - - + - name: Checkout uses: actions/checkout@v3 - - + - name: Setup Ruby uses: ruby/setup-ruby@v1 with: diff --git a/.github/workflows/swiftlint.yml b/.github/workflows/swiftlint.yml index 0c2d1b7..5c97893 100644 --- a/.github/workflows/swiftlint.yml +++ b/.github/workflows/swiftlint.yml @@ -2,7 +2,8 @@ name: SwiftLint on: push: - branches: master + branches: + - main pull_request: jobs: @@ -10,10 +11,10 @@ jobs: name: SwiftLint runs-on: macos-latest steps: - - + - name: Checkout uses: actions/checkout@v3 - - + - name: Setup Ruby uses: ruby/setup-ruby@v1 with: diff --git a/.github/workflows/tag-publish.yml b/.github/workflows/tag-publish.yml index 99e7d66..f6cacf9 100644 --- a/.github/workflows/tag-publish.yml +++ b/.github/workflows/tag-publish.yml @@ -7,24 +7,6 @@ on: workflow_dispatch: jobs: - cocoapods: - name: Push To CocoaPods - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v3 - - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - bundler-cache: true - - - name: Push to CocoaPods - run: bundle exec rake release:cocoapods - env: - COCOAPODS_TRUNK_TOKEN: ${{secrets.COCOAPODS_TRUNK_TOKEN}} - github: name: GitHub Release runs-on: ubuntu-latest diff --git a/.github/workflows/test-spm.yml b/.github/workflows/test-spm.yml index e647bb5..4dc5711 100644 --- a/.github/workflows/test-spm.yml +++ b/.github/workflows/test-spm.yml @@ -2,7 +2,8 @@ name: Test SPM on: push: - branches: master + branches: + - main pull_request: jobs: @@ -11,10 +12,10 @@ jobs: runs-on: ubuntu-latest container: swiftgen/swift:5.6 steps: - - + - name: Checkout uses: actions/checkout@v3 - - + - # Note: we can't use `ruby/setup-ruby` on custom docker images, so we # have to do our own caching name: Cache gems @@ -24,7 +25,7 @@ jobs: key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile.lock') }} restore-keys: | ${{ runner.os }}-gems- - - + - name: Cache SPM uses: actions/cache@v3 with: @@ -45,15 +46,15 @@ jobs: name: Test SPM macOS runs-on: macos-latest steps: - - + - name: Checkout uses: actions/checkout@v3 - - + - name: Setup Ruby uses: ruby/setup-ruby@v1 with: bundler-cache: true - - + - name: Cache SPM uses: actions/cache@v3 with: diff --git a/.swiftlint.yml b/.swiftlint.yml index 4b25ea0..72008da 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -1,4 +1,4 @@ -swiftlint_version: 0.48.0 +swiftlint_version: 0.61.0 opt_in_rules: - accessibility_label_for_image @@ -104,14 +104,6 @@ closure_body_length: conditional_returns_on_newline: if_only: true -file_header: - required_pattern: | - \/\/ - \/\/ Stencil - \/\/ Copyright © 2022 Stencil - \/\/ MIT Licence - \/\/ - indentation_width: indentation_width: 2 diff --git a/CHANGELOG.md b/CHANGELOG.md index f83e1a2..a5fe522 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ### Enhancements -- Prefer `DynamicMemberLookup` over KVC. +- Prefer `DynamicMemberLookup` over KVC. [##342](https://github.com/stencilproject/Stencil/pull/342) [@art-divin](https://github.com/art-divin) @@ -10,7 +10,7 @@ ### Bug Fixes -- Fix bug in `LazyValueWrapper`, causing it to never resolve. +- Fix bug in `LazyValueWrapper`, causing it to never resolve. [David Jennes](https://github.com/djbe) [#328](https://github.com/stencilproject/Stencil/pull/328) @@ -18,59 +18,59 @@ ### Breaking -- Drop support for Swift < 5. For Swift 4.2 support, you should use Stencil 0.14.2. +- Drop support for Swift < 5. For Swift 4.2 support, you should use Stencil 0.14.2. [David Jennes](https://github.com/djbe) [#323](https://github.com/stencilproject/Stencil/pull/323) ### Enhancements -- Added support for trimming whitespace around blocks with Jinja2 whitespace control symbols. eg `{%- if value +%}`. +- Added support for trimming whitespace around blocks with Jinja2 whitespace control symbols. eg `{%- if value +%}`. [Miguel Bejar](https://github.com/bejar37) [Yonas Kolb](https://github.com/yonaskolb) [#92](https://github.com/stencilproject/Stencil/pull/92) [#287](https://github.com/stencilproject/Stencil/pull/287) -- Added support for adding default whitespace trimming behaviour to an environment. +- Added support for adding default whitespace trimming behaviour to an environment. [Yonas Kolb](https://github.com/yonaskolb) [#287](https://github.com/stencilproject/Stencil/pull/287) -- Blocks now can be used repeatedly in the template. When block is rendered for the first time its content will be cached and it can be rendered again later using `{{ block.block_name }}`. +- Blocks now can be used repeatedly in the template. When block is rendered for the first time its content will be cached and it can be rendered again later using `{{ block.block_name }}`. [Ilya Puchka](https://github.com/ilyapuchka) [#158](https://github.com/stencilproject/Stencil/issues/158) [#182](https://github.com/stencilproject/Stencil/pull/182) -- Added `break` and `continue` tags to break or continue current loop. +- Added `break` and `continue` tags to break or continue current loop. [Ilya Puchka](https://github.com/ilyapuchka) [#175](https://github.com/stencilproject/Stencil/pull/175) -- You can now access outer loop's scope by labeling it: `{% outer: for ... %}... {% for ... %} {{ outer.counter }} {% endfor %}{% endfor %}`. +- You can now access outer loop's scope by labeling it: `{% outer: for ... %}... {% for ... %} {{ outer.counter }} {% endfor %}{% endfor %}`. [Ilya Puchka](https://github.com/ilyapuchka) [#175](https://github.com/stencilproject/Stencil/pull/175) -- Boolean expressions can now be rendered, i.e `{{ name == "John" }}` will render `true` or `false` depending on the evaluation result. +- Boolean expressions can now be rendered, i.e `{{ name == "John" }}` will render `true` or `false` depending on the evaluation result. [Ilya Puchka](https://github.com/ilyapuchka) [David Jennes](https://github.com/djbe) [#164](https://github.com/stencilproject/Stencil/pull/164) [#325](https://github.com/stencilproject/Stencil/pull/325) -- Enable dynamic member lookup using a new `DynamicMemberLookup` marker protocol. Conform your own types to this protocol to support dynamic member from with contexts. +- Enable dynamic member lookup using a new `DynamicMemberLookup` marker protocol. Conform your own types to this protocol to support dynamic member from with contexts. [Ilya Puchka](https://github.com/ilyapuchka) [#219](https://github.com/stencilproject/Stencil/issues/219) [#246](https://github.com/stencilproject/Stencil/pull/246) -- Allow providing lazily evaluated context data, using the `LazyValueWrapper` structure. +- Allow providing lazily evaluated context data, using the `LazyValueWrapper` structure. [David Jennes](https://github.com/djbe) [#324](https://github.com/stencilproject/Stencil/pull/324) ### Bug Fixes -- Fixed using `{{ block.super }}` inside nodes other than `block`. +- Fixed using `{{ block.super }}` inside nodes other than `block`. [Ilya Puchka](https://github.com/ilyapuchka) [#266](https://github.com/stencilproject/Stencil/issues/266) [#267](https://github.com/stencilproject/Stencil/pull/267) ### Internal Changes -- Updated internal maintenance scripts, and switched to GitHub actions. +- Updated internal maintenance scripts, and switched to GitHub actions. [David Jennes](https://github.com/djbe) [#321](https://github.com/stencilproject/Stencil/pull/321) -- Made the `tokens` property on a `Template` public. +- Made the `tokens` property on a `Template` public. [Stefanomondino](https://github.com/stefanomondino) [#292](https://github.com/stencilproject/Stencil/pull/292) -- Made the `Template.render(_:)` method (that accepts a `Context`) public. +- Made the `Template.render(_:)` method (that accepts a `Context`) public. [David Jennes](https://github.com/djbe) [#322](https://github.com/stencilproject/Stencil/pull/322) @@ -78,7 +78,7 @@ ### Internal Changes -- Update Spectre (0.10) and PathKit to support Xcode 13. +- Update Spectre (0.10) and PathKit to support Xcode 13. [Astromonkee](https://github.com/astromonkee) [#314](https://github.com/stencilproject/Stencil/pull/314) @@ -86,7 +86,7 @@ ### Bug Fixes -- Fix for crashing range indexes when variable length is 1. +- Fix for crashing range indexes when variable length is 1. [Łukasz Kuczborski](https://github.com/lkuczborski) [#306](https://github.com/stencilproject/Stencil/pull/306) @@ -95,35 +95,35 @@ ### Breaking -- Drop support for Swift < 4.2. For Swift 4 support, you should use Stencil 0.13.1. +- Drop support for Swift < 4.2. For Swift 4 support, you should use Stencil 0.13.1. [David Jennes](https://github.com/djbe) [#294](https://github.com/stencilproject/Stencil/pull/294) ### Enhancements - Added support for dynamic filter using `filter` filter. With that you can define a variable with a name of filter -, i.e. `myfilter = "uppercase"` and then use it to invoke this filter with `{{ string|filter:myfilter }}`. +, i.e. `myfilter = "uppercase"` and then use it to invoke this filter with `{{ string|filter:myfilter }}`. [Ilya Puchka](https://github.com/ilyapuchka) [#203](https://github.com/stencilproject/Stencil/pull/203) ### Bug Fixes -- Fixed using parenthesis in boolean expressions, they now can be used without spaces around them. +- Fixed using parenthesis in boolean expressions, they now can be used without spaces around them. [Ilya Puchka](https://github.com/ilyapuchka) [#254](https://github.com/stencilproject/Stencil/pull/254) -- Throw syntax error on empty variable tags (`{{ }}`) instead `fatalError`. +- Throw syntax error on empty variable tags (`{{ }}`) instead `fatalError`. [Ilya Puchka](https://github.com/ilyapuchka) [#263](https://github.com/stencilproject/Stencil/pull/263) ### Internal Changes -- `Token` type converted to struct to allow computing token components only once. +- `Token` type converted to struct to allow computing token components only once. [Ilya Puchka](https://github.com/ilyapuchka) [#256](https://github.com/stencilproject/Stencil/pull/256) -- Added SwiftLint to the project. +- Added SwiftLint to the project. [David Jennes](https://github.com/djbe) [#249](https://github.com/stencilproject/Stencil/pull/249) -- Updated to Swift 5. +- Updated to Swift 5. [Jungwon An](https://github.com/kawoou) [#268](https://github.com/stencilproject/Stencil/pull/268) @@ -132,7 +132,7 @@ ### Bug Fixes -- Fixed a bug in Stencil 0.13 where tags without spaces were incorrectly parsed. +- Fixed a bug in Stencil 0.13 where tags without spaces were incorrectly parsed. [David Jennes](https://github.com/djbe) [#252](https://github.com/stencilproject/Stencil/pull/252) @@ -141,46 +141,46 @@ ### Breaking -- Now requires Swift 4.1 or newer. +- Now requires Swift 4.1 or newer. [Yonas Kolb](https://github.com/yonaskolb) [#228](https://github.com/stencilproject/Stencil/pull/228) ### Enhancements -- You can now use parentheses in boolean expressions to change operator precedence. +- You can now use parentheses in boolean expressions to change operator precedence. [Ilya Puchka](https://github.com/ilyapuchka) [#165](https://github.com/stencilproject/Stencil/pull/165) -- Added method to add boolean filters with their negative counterparts. +- Added method to add boolean filters with their negative counterparts. [Ilya Puchka](https://github.com/ilyapuchka) [#160](https://github.com/stencilproject/Stencil/pull/160) -- Now you can conditionally render variables with `{{ variable if condition }}`, which is a shorthand for `{% if condition %}{{ variable }}{% endif %}`. You can also use `else` like `{{ variable1 if condition else variable2 }}`, which is a shorthand for `{% if condition %}{{ variable1 }}{% else %}{{ variable2 }}{% endif %}` +- Now you can conditionally render variables with `{{ variable if condition }}`, which is a shorthand for `{% if condition %}{{ variable }}{% endif %}`. You can also use `else` like `{{ variable1 if condition else variable2 }}`, which is a shorthand for `{% if condition %}{{ variable1 }}{% else %}{{ variable2 }}{% endif %}` [Ilya Puchka](https://github.com/ilyapuchka) [#243](https://github.com/stencilproject/Stencil/pull/243) -- Now you can access string characters by index or get string length the same was as if it was an array, i.e. `{{ 'string'.first }}`, `{{ 'string'.last }}`, `{{ 'string'.1 }}`, `{{ 'string'.count }}`. +- Now you can access string characters by index or get string length the same was as if it was an array, i.e. `{{ 'string'.first }}`, `{{ 'string'.last }}`, `{{ 'string'.1 }}`, `{{ 'string'.count }}`. [Ilya Puchka](https://github.com/ilyapuchka) [#245](https://github.com/stencilproject/Stencil/pull/245) ### Bug Fixes -- Fixed the performance issues introduced in Stencil 0.12 with the error log improvements. +- Fixed the performance issues introduced in Stencil 0.12 with the error log improvements. [Ilya Puchka](https://github.com/ilyapuchka) [#230](https://github.com/stencilproject/Stencil/pull/230) -- Now accessing undefined keys in NSObject does not cause runtime crash and instead renders empty string. +- Now accessing undefined keys in NSObject does not cause runtime crash and instead renders empty string. [Ilya Puchka](https://github.com/ilyapuchka) [#234](https://github.com/stencilproject/Stencil/pull/234) -- `for` tag: When iterating over a dictionary the keys will now always be sorted (in an ascending order) to ensure consistent output generation. +- `for` tag: When iterating over a dictionary the keys will now always be sorted (in an ascending order) to ensure consistent output generation. [David Jennes](https://github.com/djbe) [#240](https://github.com/stencilproject/Stencil/pull/240) ### Internal Changes -- Updated the codebase to use Swift 4 features. +- Updated the codebase to use Swift 4 features. [David Jennes](https://github.com/djbe) [#239](https://github.com/stencilproject/Stencil/pull/239) -- Update to Spectre 0.9.0. +- Update to Spectre 0.9.0. [Ilya Puchka](https://github.com/ilyapuchka) [#247](https://github.com/stencilproject/Stencil/pull/247) -- Optimise Scanner performance. +- Optimise Scanner performance. [Eric Thorpe](https://github.com/trametheka) [Sébastien Duperron](https://github.com/Liquidsoul) [David Jennes](https://github.com/djbe) @@ -191,7 +191,7 @@ ### Internal Changes -- Updated the PathKit dependency to 0.9.0 in CocoaPods, to be in line with SPM. +- Updated the PathKit dependency to 0.9.0 in CocoaPods, to be in line with SPM. [David Jennes](https://github.com/djbe) [#227](https://github.com/stencilproject/Stencil/pull/227) @@ -200,23 +200,23 @@ ### Enhancements -- Added an optional second parameter to the `include` tag for passing a sub context to the included file. +- Added an optional second parameter to the `include` tag for passing a sub context to the included file. [Yonas Kolb](https://github.com/yonaskolb) [#214](https://github.com/stencilproject/Stencil/pull/214) - Variables now support the subscript notation. For example, if you have a variable `key = "name"`, and an - object `item = ["name": "John"]`, then `{{ item[key] }}` will evaluate to "John". + object `item = ["name": "John"]`, then `{{ item[key] }}` will evaluate to "John". [David Jennes](https://github.com/djbe) [#215](https://github.com/stencilproject/Stencil/pull/215) -- Adds support for using spaces in filter expression. +- Adds support for using spaces in filter expression. [Ilya Puchka](https://github.com/ilyapuchka) [#178](https://github.com/stencilproject/Stencil/pull/178) -- Improvements in error reporting. +- Improvements in error reporting. [Ilya Puchka](https://github.com/ilyapuchka) [#167](https://github.com/stencilproject/Stencil/pull/167) ### Bug Fixes -- Fixed using quote as a filter parameter. +- Fixed using quote as a filter parameter. [Ilya Puchka](https://github.com/ilyapuchka) [#210](https://github.com/stencilproject/Stencil/pull/210) @@ -225,62 +225,62 @@ ### Enhancements -- Added support for resolving superclass properties for not-NSObject subclasses. +- Added support for resolving superclass properties for not-NSObject subclasses. [Ilya Puchka](https://github.com/ilyapuchka) [#152](https://github.com/stencilproject/Stencil/pull/152) - The `{% for %}` tag can now iterate over tuples, structures and classes via - their stored properties. + their stored properties. [Ilya Puchka](https://github.com/ilyapuchka) [#173](https://github.com/stencilproject/Stencil/pull/173) -- Added `split` filter. +- Added `split` filter. [Ilya Puchka](https://github.com/ilyapuchka) [#187](https://github.com/stencilproject/Stencil/pull/187) -- Allow default string filters to be applied to arrays. +- Allow default string filters to be applied to arrays. [Ilya Puchka](https://github.com/ilyapuchka) [#190](https://github.com/stencilproject/Stencil/pull/190) -- Similar filters are suggested when unknown filter is used. +- Similar filters are suggested when unknown filter is used. [Ilya Puchka](https://github.com/ilyapuchka) [#186](https://github.com/stencilproject/Stencil/pull/186) -- Added `indent` filter. +- Added `indent` filter. [Ilya Puchka](https://github.com/ilyapuchka) [#188](https://github.com/stencilproject/Stencil/pull/188) -- Allow using new lines inside tags. +- Allow using new lines inside tags. [Ilya Puchka](https://github.com/ilyapuchka) [#202](https://github.com/stencilproject/Stencil/pull/202) -- Added support for iterating arrays of tuples. +- Added support for iterating arrays of tuples. [Ilya Puchka](https://github.com/ilyapuchka) [#177](https://github.com/stencilproject/Stencil/pull/177) -- Added support for ranges in if-in expression. +- Added support for ranges in if-in expression. [Ilya Puchka](https://github.com/ilyapuchka) [#193](https://github.com/stencilproject/Stencil/pull/193) -- Added property `forloop.length` to get number of items in the loop. +- Added property `forloop.length` to get number of items in the loop. [Ilya Puchka](https://github.com/ilyapuchka) [#171](https://github.com/stencilproject/Stencil/pull/171) -- Now you can construct ranges for loops using `a...b` syntax, i.e. `for i in 1...array.count`. +- Now you can construct ranges for loops using `a...b` syntax, i.e. `for i in 1...array.count`. [Ilya Puchka](https://github.com/ilyapuchka) [#192](https://github.com/stencilproject/Stencil/pull/192) ### Bug Fixes -- Fixed rendering `{{ block.super }}` with several levels of inheritance. +- Fixed rendering `{{ block.super }}` with several levels of inheritance. [Ilya Puchka](https://github.com/ilyapuchka) [#154](https://github.com/stencilproject/Stencil/pull/154) -- Fixed checking dictionary values for nil in `default` filter. +- Fixed checking dictionary values for nil in `default` filter. [Ilya Puchka](https://github.com/ilyapuchka) [#162](https://github.com/stencilproject/Stencil/pull/162) -- Fixed comparing string variables with string literals, in Swift 4 string literals became `Substring` and thus couldn't be directly compared to strings. +- Fixed comparing string variables with string literals, in Swift 4 string literals became `Substring` and thus couldn't be directly compared to strings. [Ilya Puchka](https://github.com/ilyapuchka) [#168](https://github.com/stencilproject/Stencil/pull/168) -- Integer literals now resolve into Int values, not Float. +- Integer literals now resolve into Int values, not Float. [Ilya Puchka](https://github.com/ilyapuchka) [#181](https://github.com/stencilproject/Stencil/pull/181) -- Fixed accessing properties of optional properties via reflection. +- Fixed accessing properties of optional properties via reflection. [Ilya Puchka](https://github.com/ilyapuchka) [#204](https://github.com/stencilproject/Stencil/pull/204) -- No longer render optional values in arrays as `Optional(..)`. +- No longer render optional values in arrays as `Optional(..)`. [Ilya Puchka](https://github.com/ilyapuchka) [#205](https://github.com/stencilproject/Stencil/pull/205) -- Fixed subscription tuples by value index, i.e. `{{ tuple.0 }}`. +- Fixed subscription tuples by value index, i.e. `{{ tuple.0 }}`. [Ilya Puchka](https://github.com/ilyapuchka) [#172](https://github.com/stencilproject/Stencil/pull/172) @@ -483,10 +483,10 @@ ### Bug Fixes - Variables (`{{ variable.5 }}`) that reference an array index at an unknown - index will now resolve to `nil` instead of causing a crash. + index will now resolve to `nil` instead of causing a crash. [#72](https://github.com/stencilproject/Stencil/issues/72) -- Templates can now extend templates that extend other templates. +- Templates can now extend templates that extend other templates. [#60](https://github.com/stencilproject/Stencil/issues/60) - If comparisons will now treat 0 and below numbers as negative. diff --git a/Gemfile b/Gemfile index a51c7c8..732094a 100644 --- a/Gemfile +++ b/Gemfile @@ -4,13 +4,13 @@ source 'https://rubygems.org' # The bare minimum for building, e.g. in Homebrew group :build do + gem 'base64', '~> 0.3' gem 'rake', '~> 13.0' gem 'xcpretty', '~> 0.3' end # In addition to :build, for contributing group :development do - gem 'cocoapods', '~> 1.11' gem 'danger', '~> 8.4' gem 'rubocop', '~> 1.22' end diff --git a/Gemfile.lock b/Gemfile.lock index 2398a92..d10cb8d 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,65 +1,16 @@ GEM remote: https://rubygems.org/ specs: - CFPropertyList (3.0.5) - rexml - activesupport (6.1.6.1) - concurrent-ruby (~> 1.0, >= 1.0.2) - i18n (>= 1.6, < 2) - minitest (>= 5.1) - tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.0) - public_suffix (>= 2.0.2, < 5.0) - algoliasearch (1.27.5) - httpclient (~> 2.8, >= 2.8.3) - json (>= 1.5.1) - ast (2.4.2) - atomos (0.1.3) + addressable (2.8.7) + public_suffix (>= 2.0.2, < 7.0) + ast (2.4.3) + base64 (0.3.0) claide (1.1.0) claide-plugins (0.9.2) cork nap open4 (~> 1.3) - cocoapods (1.11.3) - addressable (~> 2.8) - claide (>= 1.0.2, < 2.0) - cocoapods-core (= 1.11.3) - cocoapods-deintegrate (>= 1.0.3, < 2.0) - cocoapods-downloader (>= 1.4.0, < 2.0) - cocoapods-plugins (>= 1.0.0, < 2.0) - cocoapods-search (>= 1.0.0, < 2.0) - cocoapods-trunk (>= 1.4.0, < 2.0) - cocoapods-try (>= 1.1.0, < 2.0) - colored2 (~> 3.1) - escape (~> 0.0.4) - fourflusher (>= 2.3.0, < 3.0) - gh_inspector (~> 1.0) - molinillo (~> 0.8.0) - nap (~> 1.0) - ruby-macho (>= 1.0, < 3.0) - xcodeproj (>= 1.21.0, < 2.0) - cocoapods-core (1.11.3) - activesupport (>= 5.0, < 7) - addressable (~> 2.8) - algoliasearch (~> 1.0) - concurrent-ruby (~> 1.1) - fuzzy_match (~> 2.0.4) - nap (~> 1.0) - netrc (~> 0.11) - public_suffix (~> 4.0) - typhoeus (~> 1.0) - cocoapods-deintegrate (1.0.5) - cocoapods-downloader (1.6.3) - cocoapods-plugins (1.0.0) - nap - cocoapods-search (1.0.1) - cocoapods-trunk (1.6.0) - nap (>= 0.8, < 2.0) - netrc (~> 0.11) - cocoapods-try (1.2.0) colored2 (3.1.2) - concurrent-ruby (1.1.10) cork (0.3.0) colored2 (~> 3.1) danger (8.6.1) @@ -75,10 +26,7 @@ GEM no_proxy_fix octokit (~> 4.7) terminal-table (>= 1, < 4) - escape (0.0.4) - ethon (0.15.0) - ffi (>= 1.15.0) - faraday (1.10.0) + faraday (1.10.4) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) @@ -91,94 +39,89 @@ GEM faraday-retry (~> 1.0) ruby2_keywords (>= 0.0.4) faraday-em_http (1.0.0) - faraday-em_synchrony (1.0.0) + faraday-em_synchrony (1.0.1) faraday-excon (1.1.0) - faraday-http-cache (2.4.0) + faraday-http-cache (2.5.1) faraday (>= 0.8) faraday-httpclient (1.0.1) - faraday-multipart (1.0.4) - multipart-post (~> 2) - faraday-net_http (1.0.1) + faraday-multipart (1.1.1) + multipart-post (~> 2.0) + faraday-net_http (1.0.2) faraday-net_http_persistent (1.2.0) faraday-patron (1.0.0) faraday-rack (1.0.0) faraday-retry (1.0.3) - ffi (1.15.5) - fourflusher (2.3.1) - fuzzy_match (2.0.4) - gh_inspector (1.1.3) - git (1.11.0) + git (1.19.1) + addressable (~> 2.8) rchardet (~> 1.8) - httpclient (2.8.3) - i18n (1.12.0) - concurrent-ruby (~> 1.0) - json (2.6.2) - kramdown (2.4.0) - rexml + json (2.15.0) + kramdown (2.5.1) + rexml (>= 3.3.9) kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) - minitest (5.16.2) - molinillo (0.8.0) - multipart-post (2.2.3) - nanaimo (0.3.0) + language_server-protocol (3.17.0.5) + lint_roller (1.1.0) + multipart-post (2.4.1) nap (1.1.0) - netrc (0.11.0) no_proxy_fix (0.1.2) octokit (4.25.1) faraday (>= 1, < 3) sawyer (~> 0.9) open4 (1.3.4) - parallel (1.22.1) - parser (3.1.2.0) + parallel (1.27.0) + parser (3.3.9.0) ast (~> 2.4.1) + racc + prism (1.5.1) public_suffix (4.0.7) + racc (1.8.1) rainbow (3.1.1) - rake (13.0.6) - rchardet (1.8.0) - regexp_parser (2.5.0) - rexml (3.2.5) - rouge (2.0.7) - rubocop (1.32.0) + rake (13.3.0) + rchardet (1.10.0) + regexp_parser (2.11.3) + rexml (3.4.4) + rouge (3.28.0) + rubocop (1.81.1) json (~> 2.3) + language_server-protocol (~> 3.17.0.2) + lint_roller (~> 1.1.0) parallel (~> 1.10) - parser (>= 3.1.0.0) + parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 1.8, < 3.0) - rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.19.1, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.47.1, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.19.1) - parser (>= 3.1.1.0) - ruby-macho (2.5.1) - ruby-progressbar (1.11.0) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.47.1) + parser (>= 3.3.7.2) + prism (~> 1.4) + ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) sawyer (0.9.2) addressable (>= 2.3.5) faraday (>= 0.17.3, < 3) - terminal-table (3.0.2) - unicode-display_width (>= 1.1.1, < 3) - typhoeus (1.4.0) - ethon (>= 0.9.0) - tzinfo (2.0.5) - concurrent-ruby (~> 1.0) - unicode-display_width (2.2.0) - xcodeproj (1.22.0) - CFPropertyList (>= 2.3.3, < 4.0) - atomos (~> 0.1.3) - claide (>= 1.0.2, < 2.0) - colored2 (~> 3.1) - nanaimo (~> 0.3.0) - rexml (~> 3.2.4) - xcpretty (0.3.0) - rouge (~> 2.0.7) - zeitwerk (2.6.0) + terminal-table (1.6.0) + unicode-display_width (3.2.0) + unicode-emoji (~> 4.1) + unicode-emoji (4.1.0) + xcpretty (0.4.1) + rouge (~> 3.28.0) PLATFORMS + aarch64-linux-gnu + aarch64-linux-musl + arm-linux-gnu + arm-linux-musl + arm64-darwin ruby + x86-linux-gnu + x86-linux-musl + x86_64-darwin + x86_64-linux-gnu + x86_64-linux-musl DEPENDENCIES - cocoapods (~> 1.11) + base64 (~> 0.3) danger (~> 8.4) octokit (~> 4.7) rake (~> 13.0) @@ -186,4 +129,4 @@ DEPENDENCIES xcpretty (~> 0.3) BUNDLED WITH - 2.2.33 + 2.7.2 diff --git a/LICENSE b/LICENSE index b3382e3..6a5da40 100644 --- a/LICENSE +++ b/LICENSE @@ -1,4 +1,5 @@ -Copyright (c) 2022, Kyle Fuller +Copyright (c) 2022, Kyle Fuller as the original author +Copyright (c) 2025, Astzweig GmbH & Co. KG All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/Package.resolved b/Package.resolved index 55495a0..66f51f6 100644 --- a/Package.resolved +++ b/Package.resolved @@ -1,15 +1,6 @@ { "object": { "pins": [ - { - "package": "PathKit", - "repositoryURL": "https://github.com/kylef/PathKit.git", - "state": { - "branch": null, - "revision": "3bfd2737b700b9a36565a8c94f4ad2b050a5e574", - "version": "1.0.1" - } - }, { "package": "Spectre", "repositoryURL": "https://github.com/kylef/Spectre.git", @@ -18,6 +9,15 @@ "revision": "26cc5e9ae0947092c7139ef7ba612e34646086c7", "version": "0.10.1" } + }, + { + "package": "swiftpm-pathkit", + "repositoryURL": "https://github.com/astzweig/swiftpm-pathkit.git", + "state": { + "branch": null, + "revision": "5d164c34f35fa7241d77357e965acde80efcb6d9", + "version": "1.5.0" + } } ] }, diff --git a/Package.swift b/Package.swift index 43d2019..5e96e9f 100644 --- a/Package.swift +++ b/Package.swift @@ -7,7 +7,7 @@ let package = Package( .library(name: "Stencil", targets: ["Stencil"]) ], dependencies: [ - .package(url: "https://github.com/kylef/PathKit.git", from: "1.0.1"), + .package(url: "https://github.com/astzweig/swiftpm-pathkit.git", from: "1.5.0"), .package(url: "https://github.com/kylef/Spectre.git", from: "0.10.1") ], targets: [ diff --git a/Rakefile b/Rakefile index 77a5748..5ba8cf8 100755 --- a/Rakefile +++ b/Rakefile @@ -34,9 +34,7 @@ namespace :files do ) docs_package = Utils.first_match_in_file('docs/installation.rst', /\.package\(url: .+ from: "(.+)"/, 1) replace("docs/installation.rst", - /\.package\(url: .+, from: "(.+)"/ => %Q(.package\(url: "https://github.com/stencilproject/Stencil.git", from: "#{version}"), - /pod 'Stencil', '.*'/ => %Q(pod 'Stencil', '~> #{version}'), - /github "stencilproject\/Stencil" ~> .*/ => %Q(github "stencilproject/Stencil" ~> #{version}) + /\.package\(url: .+, from: "(.+)"/ => %Q(.package\(url: "https://github.com/swiftstencil/swiftpm-stencil.git", from: "#{version}") ) end diff --git a/Sources/Stencil/Context.swift b/Sources/Stencil/Context.swift index 21b2a4e..7331b35 100644 --- a/Sources/Stencil/Context.swift +++ b/Sources/Stencil/Context.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - /// A container for template variables. public class Context { var dictionaries: [[String: Any?]] @@ -61,6 +55,7 @@ public class Context { /// Pop the last level off of the Context /// /// - returns: The popped level + // swiftlint:disable:next discouraged_optional_collection fileprivate func pop() -> [String: Any?]? { dictionaries.popLast() } @@ -78,7 +73,7 @@ public class Context { } /// Flatten all levels of context data into 1, merging duplicate variables - /// + /// /// - returns: All collected variables public func flatten() -> [String: Any] { var accumulator: [String: Any] = [:] diff --git a/Sources/Stencil/DynamicMemberLookup.swift b/Sources/Stencil/DynamicMemberLookup.swift index 1ae7184..be1eec8 100644 --- a/Sources/Stencil/DynamicMemberLookup.swift +++ b/Sources/Stencil/DynamicMemberLookup.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - /// Marker protocol so we can know which types support `@dynamicMemberLookup`. Add this to your own types that support /// lookup by String. public protocol DynamicMemberLookup { diff --git a/Sources/Stencil/Environment.swift b/Sources/Stencil/Environment.swift index ba0f506..e758de3 100644 --- a/Sources/Stencil/Environment.swift +++ b/Sources/Stencil/Environment.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - /// Container for environment data, such as registered extensions public struct Environment { /// The class for loading new templates diff --git a/Sources/Stencil/Errors.swift b/Sources/Stencil/Errors.swift index 5379296..423fe87 100644 --- a/Sources/Stencil/Errors.swift +++ b/Sources/Stencil/Errors.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - public class TemplateDoesNotExist: Error, CustomStringConvertible { let templateNames: [String] let loader: Loader? diff --git a/Sources/Stencil/Expression.swift b/Sources/Stencil/Expression.swift index 826c5c9..1e8ab18 100644 --- a/Sources/Stencil/Expression.swift +++ b/Sources/Stencil/Expression.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - public protocol Expression: CustomStringConvertible, Resolvable { func evaluate(context: Context) throws -> Bool } diff --git a/Sources/Stencil/Extension.swift b/Sources/Stencil/Extension.swift index 1058607..42d5431 100644 --- a/Sources/Stencil/Extension.swift +++ b/Sources/Stencil/Extension.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - /// Container for registered tags and filters open class Extension { typealias TagParser = (TokenParser, Token) throws -> NodeType diff --git a/Sources/Stencil/FilterTag.swift b/Sources/Stencil/FilterTag.swift index e424963..e623b53 100644 --- a/Sources/Stencil/FilterTag.swift +++ b/Sources/Stencil/FilterTag.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - class FilterNode: NodeType { let resolvable: Resolvable let nodes: [NodeType] diff --git a/Sources/Stencil/Filters.swift b/Sources/Stencil/Filters.swift index c7a398e..2a719e4 100644 --- a/Sources/Stencil/Filters.swift +++ b/Sources/Stencil/Filters.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - func capitalise(_ value: Any?) -> Any? { if let array = value as? [Any?] { return array.map { stringify($0).capitalized } diff --git a/Sources/Stencil/ForTag.swift b/Sources/Stencil/ForTag.swift index b7dea3c..b81fc75 100644 --- a/Sources/Stencil/ForTag.swift +++ b/Sources/Stencil/ForTag.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Foundation class ForNode: NodeType { @@ -231,7 +225,7 @@ struct LoopTerminationNode: NodeType { self.token = token } - static func parse(_ parser: TokenParser, token: Token) throws -> LoopTerminationNode { + static func parse(_ parser: TokenParser, token: Token) throws -> Self { let components = token.components guard components.count <= 2 else { @@ -241,7 +235,7 @@ struct LoopTerminationNode: NodeType { throw TemplateSyntaxError("'\(token.contents)' can be used only inside loop body") } - return LoopTerminationNode(name: components[0], label: components.count == 2 ? components[1] : nil, token: token) + return Self(name: components[0], label: components.count == 2 ? components[1] : nil, token: token) } func render(_ context: Context) throws -> String { diff --git a/Sources/Stencil/IfTag.swift b/Sources/Stencil/IfTag.swift index 56147f0..bd8e3b3 100644 --- a/Sources/Stencil/IfTag.swift +++ b/Sources/Stencil/IfTag.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - enum Operator { case infix(String, Int, InfixOperator.Type) case prefix(String, Int, PrefixOperator.Type) @@ -17,7 +11,7 @@ enum Operator { } } - static let all: [Operator] = [ + static let all: [Self] = [ .infix("in", 5, InExpression.self), .infix("or", 6, OrExpression.self), .infix("and", 7, AndExpression.self), @@ -118,6 +112,7 @@ final class IfExpressionParser { private init(components: ArraySlice, environment: Environment, token: Token) throws { var parsedComponents = Set() var bracketsBalance = 0 + // swiftlint:disable:next closure_body_length self.tokens = try zip(components.indices, components).compactMap { index, component in guard !parsedComponents.contains(index) else { return nil } diff --git a/Sources/Stencil/Include.swift b/Sources/Stencil/Include.swift index 65f2dc4..aa174ba 100644 --- a/Sources/Stencil/Include.swift +++ b/Sources/Stencil/Include.swift @@ -1,11 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - -import PathKit - class IncludeNode: NodeType { let templateName: Variable let includeContext: String? diff --git a/Sources/Stencil/Inheritance.swift b/Sources/Stencil/Inheritance.swift index 2b282c9..c4a1326 100644 --- a/Sources/Stencil/Inheritance.swift +++ b/Sources/Stencil/Inheritance.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - class BlockContext { class var contextKey: String { "block_context" } @@ -62,7 +56,7 @@ class ExtendsNode: NodeType { } let parsedNodes = try parser.parse() - guard (parsedNodes.any { $0 is ExtendsNode }) == nil else { + guard (parsedNodes.any { $0 is Self }) == nil else { throw TemplateSyntaxError("'extends' cannot appear more than once in the same template") } diff --git a/Sources/Stencil/KeyPath.swift b/Sources/Stencil/KeyPath.swift index 277eb20..98767b7 100644 --- a/Sources/Stencil/KeyPath.swift +++ b/Sources/Stencil/KeyPath.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Foundation /// A structure used to represent a template variable, and to resolve it in a given context. diff --git a/Sources/Stencil/LazyValueWrapper.swift b/Sources/Stencil/LazyValueWrapper.swift index f4d205b..ed07f04 100644 --- a/Sources/Stencil/LazyValueWrapper.swift +++ b/Sources/Stencil/LazyValueWrapper.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - /// Used to lazily set context data. Useful for example if you have some data that requires heavy calculations, and may /// not be used in every render possiblity. public final class LazyValueWrapper { diff --git a/Sources/Stencil/Lexer.swift b/Sources/Stencil/Lexer.swift index 576ff2e..b558b49 100644 --- a/Sources/Stencil/Lexer.swift +++ b/Sources/Stencil/Lexer.swift @@ -1,12 +1,10 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Foundation +// swiftlint:disable large_tuple typealias Line = (content: String, number: UInt, range: Range) +/// Location in some content (text) +public typealias ContentLocation = (content: String, lineNumber: UInt, lineOffset: Int) +// swiftlint:enable large_tuple struct Lexer { let templateName: String? @@ -257,6 +255,3 @@ extension String { return String(self[first.. Template { for path in paths { - let templatePath = try path.safeJoin(path: Path(name)) + let templatePath = try path.safeJoin(path: name) if !templatePath.exists { continue } - let content: String = try templatePath.read() + let content: String = try String(contentsOf: templatePath) return environment.templateClass.init(templateString: content, environment: environment, name: name) } @@ -68,10 +62,10 @@ public class FileSystemLoader: Loader, CustomStringConvertible { public func loadTemplate(names: [String], environment: Environment) throws -> Template { for path in paths { for templateName in names { - let templatePath = try path.safeJoin(path: Path(templateName)) + let templatePath = try path.safeJoin(path: templateName) if templatePath.exists { - let content: String = try templatePath.read() + let content: String = try String(contentsOf: templatePath) return environment.templateClass.init(templateString: content, environment: environment, name: templateName) } } @@ -108,10 +102,10 @@ public class DictionaryLoader: Loader { } extension Path { - func safeJoin(path: Path) throws -> Path { - let newPath = self + path + func safeJoin(path: String) throws -> Path { + let newPath = self / path - if !newPath.absolute().description.hasPrefix(absolute().description) { + if !newPath.string.hasPrefix(self.string) { throw SuspiciousFileOperation(basePath: self, path: newPath) } diff --git a/Sources/Stencil/Node.swift b/Sources/Stencil/Node.swift index 49c98d1..462b254 100644 --- a/Sources/Stencil/Node.swift +++ b/Sources/Stencil/Node.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Foundation /// Represents a parsed node @@ -184,6 +178,8 @@ func unwrap(_ array: [Any?]) -> [Any] { } else { return item } - } else { return item as Any } + } else { + return item as Any + } } } diff --git a/Sources/Stencil/NowTag.swift b/Sources/Stencil/NowTag.swift index 639549f..bad6627 100644 --- a/Sources/Stencil/NowTag.swift +++ b/Sources/Stencil/NowTag.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - #if !os(Linux) import Foundation diff --git a/Sources/Stencil/Parser.swift b/Sources/Stencil/Parser.swift index 3fe30ba..66e1ed5 100644 --- a/Sources/Stencil/Parser.swift +++ b/Sources/Stencil/Parser.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - /// Creates a checker that will stop parsing if it encounters a list of tags. /// Useful for example for scanning until a given "end"-node. public func until(_ tags: [String]) -> ((TokenParser, Token) -> Bool) { @@ -98,7 +92,7 @@ public class TokenParser { tokens.first?.whitespace?.leading } - /// Insert a token + /// Insert a token public func prependToken(_ token: Token) { tokens.insert(token, at: 0) if parsedTokens.last == token { diff --git a/Sources/Stencil/Template.swift b/Sources/Stencil/Template.swift index 8061962..275c065 100644 --- a/Sources/Stencil/Template.swift +++ b/Sources/Stencil/Template.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Foundation import PathKit @@ -47,13 +41,17 @@ open class Template: ExpressibleByStringLiteral { /// Create a template with a file found at the given URL @available(*, deprecated, message: "Use Environment/FileSystemLoader instead") public convenience init(URL: Foundation.URL) throws { - try self.init(path: Path(URL.path)) + guard let path = Path(url: URL) else { + throw TemplateDoesNotExist(templateNames: [URL.lastPathComponent]) + } + try self.init(path: path) } /// Create a template with a file found at the given path @available(*, deprecated, message: "Use Environment/FileSystemLoader instead") public convenience init(path: Path, environment: Environment? = nil, name: String? = nil) throws { - self.init(templateString: try path.read(), environment: environment, name: name) + let value = try String(contentsOf: path) + self.init(templateString: value, environment: environment, name: name) } // MARK: ExpressibleByStringLiteral @@ -81,8 +79,8 @@ open class Template: ExpressibleByStringLiteral { return try renderNodes(nodes, context) } - // swiftlint:disable discouraged_optional_collection /// Render the given template + // swiftlint:disable:next discouraged_optional_collection open func render(_ dictionary: [String: Any]? = nil) throws -> String { try render(Context(dictionary: dictionary ?? [:], environment: environment)) } diff --git a/Sources/Stencil/Tokenizer.swift b/Sources/Stencil/Tokenizer.swift index 103c5b6..ed0e63f 100644 --- a/Sources/Stencil/Tokenizer.swift +++ b/Sources/Stencil/Tokenizer.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Foundation extension String { @@ -83,9 +77,9 @@ public struct SourceMap: Equatable { self.location = location } - static let unknown = SourceMap() + static let unknown = Self() - public static func == (lhs: SourceMap, rhs: SourceMap) -> Bool { + public static func == (lhs: Self, rhs: Self) -> Bool { lhs.filename == rhs.filename && lhs.location == rhs.location } } @@ -100,7 +94,7 @@ public struct WhitespaceBehaviour: Equatable { let leading: Behaviour let trailing: Behaviour - public static let unspecified = WhitespaceBehaviour(leading: .unspecified, trailing: .unspecified) + public static let unspecified = Self(leading: .unspecified, trailing: .unspecified) } public class Token: Equatable { diff --git a/Sources/Stencil/TrimBehaviour.swift b/Sources/Stencil/TrimBehaviour.swift index c639593..2374347 100644 --- a/Sources/Stencil/TrimBehaviour.swift +++ b/Sources/Stencil/TrimBehaviour.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Foundation public struct TrimBehaviour: Equatable { @@ -30,13 +24,13 @@ public struct TrimBehaviour: Equatable { } /// doesn't touch newlines - public static let nothing = TrimBehaviour(leading: .nothing, trailing: .nothing) + public static let nothing = Self(leading: .nothing, trailing: .nothing) /// removes whitespace before a block and whitespace and a single newline after a block - public static let smart = TrimBehaviour(leading: .whitespace, trailing: .whitespaceAndOneNewLine) + public static let smart = Self(leading: .whitespace, trailing: .whitespaceAndOneNewLine) /// removes all whitespace and newlines before and after a block - public static let all = TrimBehaviour(leading: .whitespaceAndNewLines, trailing: .whitespaceAndNewLines) + public static let all = Self(leading: .whitespaceAndNewLines, trailing: .whitespaceAndNewLines) static func leadingRegex(trim: Trim) -> NSRegularExpression { switch trim { @@ -64,13 +58,18 @@ public struct TrimBehaviour: Equatable { } } - // swiftlint:disable force_try + // swiftlint:disable:next force_try private static let leadingWhitespaceAndNewlines = try! NSRegularExpression(pattern: "^\\s+") + // swiftlint:disable:next force_try private static let trailingWhitespaceAndNewLines = try! NSRegularExpression(pattern: "\\s+$") + // swiftlint:disable:next force_try private static let leadingWhitespaceAndOneNewLine = try! NSRegularExpression(pattern: "^[ \t]*\n") + // swiftlint:disable:next force_try private static let trailingWhitespaceAndOneNewLine = try! NSRegularExpression(pattern: "\n[ \t]*$") + // swiftlint:disable:next force_try private static let leadingWhitespace = try! NSRegularExpression(pattern: "^[ \t]*") + // swiftlint:disable:next force_try private static let trailingWhitespace = try! NSRegularExpression(pattern: "[ \t]*$") } diff --git a/Sources/Stencil/Variable.swift b/Sources/Stencil/Variable.swift index dc5b86e..c9b20d5 100644 --- a/Sources/Stencil/Variable.swift +++ b/Sources/Stencil/Variable.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Foundation typealias Number = Float diff --git a/Stencil.podspec.json b/Stencil.podspec.json index d5538d5..a44c996 100644 --- a/Stencil.podspec.json +++ b/Stencil.podspec.json @@ -2,17 +2,16 @@ "name": "Stencil", "version": "0.15.1", "summary": "Stencil is a simple and powerful template language for Swift.", - "homepage": "https://stencil.fuller.li", "license": { "type": "BSD", "file": "LICENSE" }, "authors": { - "Kyle Fuller": "kyle@fuller.li" + "Thomas Bernstein": "developer@astzweig.kg" }, - "social_media_url": "https://twitter.com/kylefuller", + "social_media_url": "https://twitter.com/trbernstein", "source": { - "git": "https://github.com/stencilproject/Stencil.git", + "git": "https://github.com/swiftstencil/swiftpm-stencil.git", "tag": "0.15.1" }, "source_files": [ @@ -23,14 +22,13 @@ "osx": "10.9", "tvos": "9.0" }, - "cocoapods_version": ">= 1.7.0", "swift_versions": [ "5.0" ], "requires_arc": true, "dependencies": { "PathKit": [ - "~> 1.0.0" + "~> 1.5.0" ] } } diff --git a/Tests/StencilTests/ContextSpec.swift b/Tests/StencilTests/ContextSpec.swift index 9c9fe5e..80b1640 100644 --- a/Tests/StencilTests/ContextSpec.swift +++ b/Tests/StencilTests/ContextSpec.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Spectre @testable import Stencil import XCTest diff --git a/Tests/StencilTests/EnvironmentBaseAndChildTemplateSpec.swift b/Tests/StencilTests/EnvironmentBaseAndChildTemplateSpec.swift index 036b986..a4ca6e1 100644 --- a/Tests/StencilTests/EnvironmentBaseAndChildTemplateSpec.swift +++ b/Tests/StencilTests/EnvironmentBaseAndChildTemplateSpec.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import PathKit import Spectre @testable import Stencil @@ -17,7 +11,7 @@ final class EnvironmentBaseAndChildTemplateTests: XCTestCase { override func setUp() { super.setUp() - let path = Path(#file as String) + ".." + "fixtures" + let path = Path(#file as String)! / ".." / "fixtures" let loader = FileSystemLoader(paths: [path]) environment = Environment(loader: loader) childTemplate = "" diff --git a/Tests/StencilTests/EnvironmentIncludeTemplateSpec.swift b/Tests/StencilTests/EnvironmentIncludeTemplateSpec.swift index 67ec956..839b057 100644 --- a/Tests/StencilTests/EnvironmentIncludeTemplateSpec.swift +++ b/Tests/StencilTests/EnvironmentIncludeTemplateSpec.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import PathKit import Spectre @testable import Stencil @@ -17,7 +11,7 @@ final class EnvironmentIncludeTemplateTests: XCTestCase { override func setUp() { super.setUp() - let path = Path(#file as String) + ".." + "fixtures" + let path = Path(#file as String)! / ".." / "fixtures" let loader = FileSystemLoader(paths: [path]) environment = Environment(loader: loader) template = "" diff --git a/Tests/StencilTests/EnvironmentSpec.swift b/Tests/StencilTests/EnvironmentSpec.swift index 70d7955..e41d58c 100644 --- a/Tests/StencilTests/EnvironmentSpec.swift +++ b/Tests/StencilTests/EnvironmentSpec.swift @@ -1,10 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - -import PathKit import Spectre @testable import Stencil import XCTest diff --git a/Tests/StencilTests/ExpressionSpec.swift b/Tests/StencilTests/ExpressionSpec.swift index d69f757..866d928 100644 --- a/Tests/StencilTests/ExpressionSpec.swift +++ b/Tests/StencilTests/ExpressionSpec.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Spectre @testable import Stencil import XCTest @@ -11,7 +5,7 @@ import XCTest final class ExpressionsTests: XCTestCase { private let parser = TokenParser(tokens: [], environment: Environment()) - private func makeExpression(_ components: [String]) -> Expression { + private func makeExpression(_ components: [String]) -> Stencil.Expression { do { let parser = try IfExpressionParser.parser( components: components, diff --git a/Tests/StencilTests/FilterSpec.swift b/Tests/StencilTests/FilterSpec.swift index 1f88eef..092c943 100644 --- a/Tests/StencilTests/FilterSpec.swift +++ b/Tests/StencilTests/FilterSpec.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Spectre @testable import Stencil import XCTest diff --git a/Tests/StencilTests/FilterTagSpec.swift b/Tests/StencilTests/FilterTagSpec.swift index 18d0d69..d73cf40 100644 --- a/Tests/StencilTests/FilterTagSpec.swift +++ b/Tests/StencilTests/FilterTagSpec.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Spectre import Stencil import XCTest diff --git a/Tests/StencilTests/ForNodeSpec.swift b/Tests/StencilTests/ForNodeSpec.swift index fb145d8..9d31b58 100644 --- a/Tests/StencilTests/ForNodeSpec.swift +++ b/Tests/StencilTests/ForNodeSpec.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Spectre @testable import Stencil import XCTest diff --git a/Tests/StencilTests/Helpers.swift b/Tests/StencilTests/Helpers.swift index bba58c4..cf6dd2e 100644 --- a/Tests/StencilTests/Helpers.swift +++ b/Tests/StencilTests/Helpers.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import PathKit import Spectre @testable import Stencil @@ -11,7 +5,7 @@ import XCTest extension Expectation { @discardableResult - func toThrow() throws -> T { + func toThrow() throws -> E { var thrownError: Error? do { @@ -21,7 +15,7 @@ extension Expectation { } if let thrownError = thrownError { - if let thrownError = thrownError as? T { + if let thrownError = thrownError as? E { return thrownError } else { throw failure("\(thrownError) is not \(T.self)") diff --git a/Tests/StencilTests/IfNodeSpec.swift b/Tests/StencilTests/IfNodeSpec.swift index ec86be7..8107b9c 100644 --- a/Tests/StencilTests/IfNodeSpec.swift +++ b/Tests/StencilTests/IfNodeSpec.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Spectre @testable import Stencil import XCTest diff --git a/Tests/StencilTests/IncludeSpec.swift b/Tests/StencilTests/IncludeSpec.swift index bb35954..7568a69 100644 --- a/Tests/StencilTests/IncludeSpec.swift +++ b/Tests/StencilTests/IncludeSpec.swift @@ -1,16 +1,10 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import PathKit import Spectre @testable import Stencil import XCTest final class IncludeTests: XCTestCase { - private let path = Path(#file as String) + ".." + "fixtures" + private let path = Path(#file as String)! / ".." / "fixtures" private lazy var loader = FileSystemLoader(paths: [path]) private lazy var environment = Environment(loader: loader) diff --git a/Tests/StencilTests/InheritanceSpec.swift b/Tests/StencilTests/InheritanceSpec.swift index a586ffd..fafa985 100644 --- a/Tests/StencilTests/InheritanceSpec.swift +++ b/Tests/StencilTests/InheritanceSpec.swift @@ -1,16 +1,10 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import PathKit import Spectre import Stencil import XCTest final class InheritanceTests: XCTestCase { - private let path = Path(#file as String) + ".." + "fixtures" + private let path = Path(#file as String)! / ".." / "fixtures" private lazy var loader = FileSystemLoader(paths: [path]) private lazy var environment = Environment(loader: loader) diff --git a/Tests/StencilTests/LexerSpec.swift b/Tests/StencilTests/LexerSpec.swift index 1ec364d..f1e5438 100644 --- a/Tests/StencilTests/LexerSpec.swift +++ b/Tests/StencilTests/LexerSpec.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import PathKit import Spectre @testable import Stencil @@ -140,8 +134,8 @@ final class LexerTests: XCTestCase { } func testPerformance() throws { - let path = Path(#file as String) + ".." + "fixtures" + "huge.html" - let content: String = try path.read() + let path = Path(#file as String)! / ".." / "fixtures" / "huge.html" + let content: String = try NSString(contentsOfFile: path.string, encoding: String.Encoding.utf8.rawValue).substring(from: 0) as String measure { let lexer = Lexer(templateString: content) diff --git a/Tests/StencilTests/LoaderSpec.swift b/Tests/StencilTests/LoaderSpec.swift index c2030bb..9433774 100644 --- a/Tests/StencilTests/LoaderSpec.swift +++ b/Tests/StencilTests/LoaderSpec.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import PathKit import Spectre import Stencil @@ -11,7 +5,7 @@ import XCTest final class TemplateLoaderTests: XCTestCase { func testFileSystemLoader() { - let path = Path(#file as String) + ".." + "fixtures" + let path = Path(#file as String)! / ".." / "fixtures" let loader = FileSystemLoader(paths: [path]) let environment = Environment(loader: loader) diff --git a/Tests/StencilTests/NodeSpec.swift b/Tests/StencilTests/NodeSpec.swift index ae356ca..c7659f6 100644 --- a/Tests/StencilTests/NodeSpec.swift +++ b/Tests/StencilTests/NodeSpec.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Spectre @testable import Stencil import XCTest diff --git a/Tests/StencilTests/NowNodeSpec.swift b/Tests/StencilTests/NowNodeSpec.swift index 32743c7..a213a32 100644 --- a/Tests/StencilTests/NowNodeSpec.swift +++ b/Tests/StencilTests/NowNodeSpec.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Spectre @testable import Stencil import XCTest diff --git a/Tests/StencilTests/ParserSpec.swift b/Tests/StencilTests/ParserSpec.swift index fb591b5..44d79d9 100644 --- a/Tests/StencilTests/ParserSpec.swift +++ b/Tests/StencilTests/ParserSpec.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Spectre @testable import Stencil import XCTest diff --git a/Tests/StencilTests/StencilSpec.swift b/Tests/StencilTests/StencilSpec.swift index daac7c3..8e01b63 100644 --- a/Tests/StencilTests/StencilSpec.swift +++ b/Tests/StencilTests/StencilSpec.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Spectre import Stencil import XCTest diff --git a/Tests/StencilTests/TemplateSpec.swift b/Tests/StencilTests/TemplateSpec.swift index aea8a01..433f1cb 100644 --- a/Tests/StencilTests/TemplateSpec.swift +++ b/Tests/StencilTests/TemplateSpec.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Spectre @testable import Stencil import XCTest diff --git a/Tests/StencilTests/TokenSpec.swift b/Tests/StencilTests/TokenSpec.swift index fa3d293..effa884 100644 --- a/Tests/StencilTests/TokenSpec.swift +++ b/Tests/StencilTests/TokenSpec.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Spectre @testable import Stencil import XCTest diff --git a/Tests/StencilTests/TrimBehaviourSpec.swift b/Tests/StencilTests/TrimBehaviourSpec.swift index 4bc879b..6c67492 100644 --- a/Tests/StencilTests/TrimBehaviourSpec.swift +++ b/Tests/StencilTests/TrimBehaviourSpec.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Spectre import Stencil import XCTest diff --git a/Tests/StencilTests/VariableSpec.swift b/Tests/StencilTests/VariableSpec.swift index 4ed538e..8155775 100644 --- a/Tests/StencilTests/VariableSpec.swift +++ b/Tests/StencilTests/VariableSpec.swift @@ -1,9 +1,3 @@ -// -// Stencil -// Copyright © 2022 Stencil -// MIT Licence -// - import Spectre @testable import Stencil import XCTest diff --git a/docs/_templates/sidebar_intro.html b/docs/_templates/sidebar_intro.html index d5bd29f..6c3be44 100644 --- a/docs/_templates/sidebar_intro.html +++ b/docs/_templates/sidebar_intro.html @@ -2,7 +2,7 @@

@@ -12,22 +12,8 @@ - -

Other Projects

- -

More Kyle Fuller projects:

- diff --git a/docs/conf.py b/docs/conf.py index c4fc7a5..5baf273 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -50,7 +50,7 @@ master_doc = 'index' # General information about the project. project = 'Stencil' -copyright = '2022, Kyle Fuller' +copyright = [ '2022, Kyle Fuller', '2025, Astzweig GmbH & Co. KG' ] author = 'Kyle Fuller' # The version info for the project you're documenting, acts as replacement for diff --git a/docs/installation.rst b/docs/installation.rst index 527b135..c0f917a 100644 --- a/docs/installation.rst +++ b/docs/installation.rst @@ -14,39 +14,6 @@ dependencies inside ``Package.swift``. let package = Package( name: "MyApplication", dependencies: [ - .package(url: "https://github.com/stencilproject/Stencil.git", from: "0.15.1"), + .package(url: "https://github.com/swiftstencil/swiftpm-stencil.git", from: "0.15.1"), ] ) - -CocoaPods ---------- - -If you're using CocoaPods, you can add Stencil to your ``Podfile`` and then run -``pod install``. - -.. code-block:: ruby - - pod 'Stencil', '~> 0.15.1' - -Carthage --------- - -.. note:: Use at your own risk. We don't offer support for Carthage and instead recommend you use Swift Package Manager. - -1) Add ``Stencil`` to your ``Cartfile``: - - .. code-block:: text - - github "stencilproject/Stencil" ~> 0.15.1 - -2) Checkout your dependencies, generate the Stencil Xcode project, and then use Carthage to build Stencil: - - .. code-block:: shell - - $ carthage update - $ (cd Carthage/Checkouts/Stencil && swift package generate-xcodeproj) - $ carthage build - -3) Follow the Carthage steps to add the built frameworks to your project. - -To learn more about this approach see `Using Swift Package Manager with Carthage `_. diff --git a/rakelib/check_changelog.rb b/rakelib/check_changelog.rb index b70d588..af664ed 100644 --- a/rakelib/check_changelog.rb +++ b/rakelib/check_changelog.rb @@ -42,7 +42,7 @@ def check_changelog # Now, check that links [#nn](.../nn) have matching numbers in link title & URL wrong_links = line.scan(links).reject do |m| - slug = m[0] || "stencilproject/#{current_repo}" + slug = m[0] || "stencilproject/Stencil" (slug == m[2]) && (m[1] == m[4]) end all_warnings.concat Array(wrong_links.map do |m| diff --git a/rakelib/lint.rake b/rakelib/lint.rake index 7aac215..10a6058 100644 --- a/rakelib/lint.rake +++ b/rakelib/lint.rake @@ -5,9 +5,9 @@ namespace :lint do SWIFTLINT = 'rakelib/lint.sh' - SWIFTLINT_VERSION = '0.48.0' + SWIFTLINT_VERSION = '0.61.0' - task :install do |task| + task :install do |task| next if check_version if OS.mac? diff --git a/rakelib/release.rake b/rakelib/release.rake index 8e34801..c227576 100644 --- a/rakelib/release.rake +++ b/rakelib/release.rake @@ -7,7 +7,7 @@ require 'json' namespace :release do desc 'Create a new release' - task :new => [:check_versions, :check_tag_and_ask_to_release, 'spm:test', :github, :cocoapods] + task :new => [:check_versions, :check_tag_and_ask_to_release, 'spm:test', :github] desc 'Check if all versions from the podspecs and CHANGELOG match' task :check_versions do @@ -15,7 +15,7 @@ namespace :release do Utils.table_header('Check', 'Status') - # Check if bundler is installed first, as we'll need it for the cocoapods task (and we prefer to fail early) + # Check if bundler is installed first (we prefer to fail early) `which bundler` results << Utils.table_result( $CHILD_STATUS.success?, @@ -40,18 +40,14 @@ namespace :release do # Check docs installation docs_package = Utils.first_match_in_file('docs/installation.rst', /\.package\(url: .+ from: "(.+)"/, 1) - docs_cocoapods = Utils.first_match_in_file('docs/installation.rst', /pod 'Stencil', '~> (.+)'/, 1) - docs_carthage = Utils.first_match_in_file('docs/installation.rst', /github ".+\/Stencil" ~> (.+)/, 1) results << Utils.table_result(docs_package == v, 'Docs, package updated', 'Update the package version in docs/installation.rst') - results << Utils.table_result(docs_cocoapods == v, 'Docs, cocoapods updated', 'Update the cocoapods version in docs/installation.rst') - results << Utils.table_result(docs_carthage == v, 'Docs, carthage updated', 'Update the carthage version in docs/installation.rst') # Check if entry present in CHANGELOG changelog_entry = Utils.first_match_in_file('CHANGELOG.md', /^## #{Regexp.quote(v)}$/) results << Utils.table_result(changelog_entry, 'CHANGELOG, Entry added', "Add an entry for #{v} in CHANGELOG.md") changelog_has_stable = system("grep -qi '^## Master' CHANGELOG.md") - results << Utils.table_result(!changelog_has_stable, 'CHANGELOG, No master', 'Remove section for master branch in CHANGELOG') + results << Utils.table_result(!changelog_has_stable, 'CHANGELOG, No master', 'Remove section for main branch in CHANGELOG') exit 1 unless results.all? end @@ -82,16 +78,10 @@ namespace :release do tag = Utils.top_changelog_version body = Utils.top_changelog_entry - raise 'Must be a valid version' if tag == 'Master' + raise 'Must be a valid version' if tag == 'main' repo_name = File.basename(`git remote get-url origin`.chomp, '.git').freeze puts "Pushing release notes for tag #{tag}" - client.create_release("stencilproject/#{repo_name}", tag, name: tag, body: body) - end - - desc "pod trunk push #{POD_NAME} to CocoaPods" - task :cocoapods do - Utils.print_header 'Pushing pod to CocoaPods Trunk' - sh "bundle exec pod trunk push #{POD_NAME}.podspec.json" + client.create_release("swiftstencil/#{repo_name}", tag, name: tag, body: body) end end diff --git a/rakelib/utils.rake b/rakelib/utils.rake index aba8a06..2992b25 100644 --- a/rakelib/utils.rake +++ b/rakelib/utils.rake @@ -55,7 +55,7 @@ class Utils def self.spm_own_version(dep) dependencies = JSON.load(File.new('Package.resolved'))['object']['pins'] dependencies.find { |d| d['package'] == dep }['state']['version'] - end + end def self.spm_resolved_version(dep) dependencies = JSON.load(File.new('Package.resolved'))['object']['pins']