swift_lib_templater 1.0.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53610ac31f230f087f76359520d4ea8914443985fe2aead8d1f8d98949e96e56
4
- data.tar.gz: 4bb1f6de2dae0779b9edc98729eadc79e10f2331339a19b8e6f391b799772ab3
3
+ metadata.gz: 5a7622f1cb0983ce55834ff250b9ed415076d574e8ace192ca23352d433838bb
4
+ data.tar.gz: 19682ab8c36390d077b35e8f7630ad800ac890da4cededc467995db07893d667
5
5
  SHA512:
6
- metadata.gz: 5a2da0f7ba336d1fb38bacf8df33bbad83b8cf506f75829d10067a0163e0279b3e8cf01bce9ae7de496b9a55365d9155e81be83788043d3e0f600b9b26236566
7
- data.tar.gz: e31af2e0872edb582bc9089f0faa7c74ad05eee27a103784fedb51abe9a6419dce3f66e50da3c83308a0aa268923ad209208c66203e57fedd6f5110459033681
6
+ metadata.gz: 11826be157b6e3de08633af652810c4f7838289c7ed69334ab25dedd51414c75905477318c77b1c84d9d11b80028c7f305d4ec9dbb7031784b4b2fb896c084a0
7
+ data.tar.gz: 42242eddc75b5dae3e7b771be75353565234ea51f0d54b2bf1f3e1fcc766ad373a3705a6ce35e5788bf8e594f4a84d1136710745cf312e0b660e131c62fedefb
@@ -4,7 +4,9 @@ require 'fileutils'
4
4
 
5
5
  require_relative 'swift_lib_templater/copy_template_command.rb'
6
6
  require_relative 'swift_lib_templater/get_framework_name_command.rb'
7
+ require_relative 'swift_lib_templater/get_template_command.rb'
7
8
  require_relative 'swift_lib_templater/rename_files_command.rb'
9
+ require_relative 'swift_lib_templater/library_template.rb'
8
10
  require_relative 'swift_lib_templater/initialize_git_repository_command.rb'
9
11
 
10
12
  def systemWithoutOutput(command)
@@ -12,15 +14,34 @@ def systemWithoutOutput(command)
12
14
  end
13
15
 
14
16
  module SwiftLibTemplater
17
+
18
+ options = {}
19
+ OptionParser.new do |opts|
20
+ opts.banner = "Usage: swift_lib_templater [options]"
21
+ opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
22
+ options[:verbose] = v
23
+ end
24
+ opts.on("-n", "--name=Name", "Project name") do |v|
25
+ options[:project_name] = v
26
+ end
27
+ opts.on("-t", "--template=TemplateName", "Template name [cli | framework]") do |v|
28
+ options[:template] = v
29
+ end
30
+ opts.on("-h", "--help", "Print this help") do
31
+ puts opts
32
+ exit
33
+ end
34
+ end.parse!
35
+
15
36
  begin
16
- puts "Framework name ?"
17
- project_name = GetFrameworkNameCommand.new.execute
37
+ template = GetTemplateCommand.new(options[:template]).execute
38
+ project_name = GetFrameworkNameCommand.new(options[:project_name]).execute
18
39
 
19
40
  project_dest = Dir.pwd
20
41
  project_folder = File.expand_path("#{project_dest}/#{project_name}")
21
42
 
22
43
  print "\nGenerating files... "
23
- CopyTemplateCommand.new(project_folder).execute
44
+ CopyTemplateCommand.new(template, project_folder).execute
24
45
  RenameFilesCommand.new(project_folder, project_name).execute
25
46
  puts "✅"
26
47
 
@@ -1,6 +1,8 @@
1
1
  module SwiftLibTemplater
2
2
  class CopyTemplateCommand
3
- def initialize(dest)
3
+
4
+ def initialize(template, dest)
5
+ @template = template
4
6
  @dest = dest
5
7
  end
6
8
 
@@ -9,7 +11,12 @@ module SwiftLibTemplater
9
11
  raise "Path #{@dest} already exists"
10
12
  end
11
13
  Dir.chdir(File.dirname(__FILE__))
12
- FileUtils.cp_r("../../lib/templates/framework", @dest)
14
+ case @template
15
+ when LibraryTemplate::FRAMEWORK
16
+ FileUtils.cp_r("../../lib/templates/framework", @dest)
17
+ when LibraryTemplate::CLI
18
+ FileUtils.cp_r("../../lib/templates/cli", @dest)
19
+ end
13
20
  end
14
21
  end
15
22
  end
@@ -1,9 +1,12 @@
1
1
  module SwiftLibTemplater
2
2
  class GetFrameworkNameCommand
3
+
4
+ def initialize(name)
5
+ @name = name
6
+ end
7
+
3
8
  def execute()
4
- name_regexp = /[A-Z][A-Za-z0-9]*/
5
- project_name = gets.chomp until project_name =~ name_regexp
6
- project_name
9
+ @name
7
10
  end
8
11
  end
9
12
  end
@@ -0,0 +1,19 @@
1
+ module SwiftLibTemplater
2
+ class GetTemplateCommand
3
+
4
+ def initialize(name)
5
+ @name = name
6
+ end
7
+
8
+ def execute()
9
+ case @name.downcase
10
+ when "cli"
11
+ return LibraryTemplate::CLI
12
+ when "framework"
13
+ return LibraryTemplate::FRAMEWORK
14
+ else
15
+ raise("unknown template")
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ module SwiftLibTemplater
2
+
3
+ module LibraryTemplate
4
+ FRAMEWORK = "FRAMEWORK"
5
+ CLI = "CLI"
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module SwiftLibTemplater
2
- VERSION = "1.0.3"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -0,0 +1,14 @@
1
+ name: CI
2
+
3
+ on: [push]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: macOS-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+
13
+ - name: Build and Test
14
+ run: swift test
@@ -0,0 +1,17 @@
1
+ .build
2
+ DerivedData
3
+ /.previous-build
4
+ xcuserdata
5
+ .DS_Store
6
+ *~
7
+ \#*
8
+ .\#*
9
+ .*.sw[nop]
10
+ *.xcscmblueprint
11
+ /default.profraw
12
+ *.xcodeproj
13
+ Utilities/Docker/*.tar.gz
14
+ .swiftpm
15
+ Package.resolved
16
+ /build
17
+ *.pyc
@@ -0,0 +1,29 @@
1
+ SHELL = /bin/bash
2
+
3
+ prefix ?= /usr/local
4
+ bindir ?= $(prefix)/bin
5
+ srcdir = Sources
6
+
7
+ REPODIR = $(shell pwd)
8
+ BUILDDIR = $(REPODIR)/.build
9
+ SOURCES = $(wildcard $(srcdir)/**/*.swift)
10
+
11
+ .DEFAULT_GOAL = all
12
+
13
+ .PHONY: all
14
+ all: xctemplate
15
+
16
+ xctemplate: $(SOURCES)
17
+ @swift build \
18
+ -c release \
19
+ --disable-sandbox \
20
+ --build-path "$(BUILDDIR)"
21
+
22
+ .PHONY: install
23
+ install: xctemplate
24
+ @install -d "$(bindir)"
25
+ @install "$(BUILDDIR)/release/xctemplate" "$(bindir)"
26
+
27
+ .PHONY: uninstall
28
+ uninstall:
29
+ @rm -rf "$(bindir)/xctemplate"
@@ -0,0 +1,33 @@
1
+ // swift-tools-version:5.2
2
+ // The swift-tools-version declares the minimum version of Swift required to build this package.
3
+
4
+ import PackageDescription
5
+
6
+ let package = Package(
7
+ name: "TEMPLATE",
8
+ platforms: [
9
+ .macOS(.v10_14),
10
+ ],
11
+ products: [
12
+ .executable(name: "TEMPLATE-CLI", targets: ["TEMPLATE-CLI"]),
13
+ .library(name: "TEMPLATE", targets: ["TEMPLATE"]),
14
+ ],
15
+ dependencies: [
16
+ .package(url: "https://github.com/apple/swift-argument-parser", from: "0.4.1")
17
+ ],
18
+ targets: [
19
+ .target(name: "TEMPLATE", dependencies: [], path: "Sources/TEMPLATE"),
20
+ .target(
21
+ name: "TEMPLATE-CLI",
22
+ dependencies: [
23
+ "TEMPLATE",
24
+ .product(name: "ArgumentParser", package: "swift-argument-parser")
25
+ ],
26
+ path: "Sources/CLI"
27
+ ),
28
+ .testTarget(
29
+ name: "TEMPLATETests",
30
+ dependencies: ["TEMPLATE"]
31
+ ),
32
+ ]
33
+ )
@@ -0,0 +1,43 @@
1
+ # xctemplate
2
+
3
+ A Xcode template manager.
4
+
5
+ ## Requirements
6
+
7
+ - Swift 5.2
8
+ - **Xcode 11.4** or later
9
+
10
+ ## Installation
11
+
12
+ ### Homebrew
13
+
14
+ Run the following command to install using Homebrew:
15
+
16
+ ```
17
+ $ brew install fabernovel/formulae/xctemplate
18
+ ```
19
+ (this will also install the `cmake` dependency)
20
+
21
+ To uninstall it:
22
+ ```
23
+ $ brew uninstall xctemplate
24
+ ```
25
+
26
+ ### Manually
27
+
28
+ Run the following commands to build and install manually:
29
+ ```
30
+ $ git clone https://github.com/faberNovel/xctemplate-cli
31
+ $ cd xctemplate-cli
32
+ $ make install
33
+ ```
34
+
35
+ ## Usage
36
+
37
+ ## Contributing
38
+
39
+ ### To test
40
+
41
+ ```
42
+ make install
43
+ ```
@@ -0,0 +1,13 @@
1
+
2
+ import Foundation
3
+ import ArgumentParser
4
+
5
+ struct TEMPLATECommand: ParsableCommand {
6
+
7
+ static let configuration = CommandConfiguration(
8
+ commandName: "TEMPLATE",
9
+ abstract: "",
10
+ subcommands: [
11
+ ]
12
+ )
13
+ }
@@ -0,0 +1,2 @@
1
+
2
+ TEMPLATECommand.main()
@@ -0,0 +1,6 @@
1
+
2
+ import Foundation
3
+
4
+ public struct TEMPLATE {
5
+
6
+ }
@@ -0,0 +1,7 @@
1
+ import XCTest
2
+
3
+ import XCTemplateTests
4
+
5
+ var tests = [XCTestCaseEntry]()
6
+ tests += XCTemplateInstallerTests.allTests()
7
+ XCTMain(tests)
@@ -0,0 +1,8 @@
1
+ import XCTest
2
+
3
+ #if !canImport(ObjectiveC)
4
+ public func allTests() -> [XCTestCaseEntry] {
5
+ return [
6
+ ]
7
+ }
8
+ #endif
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swift_lib_templater
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gaétan Zanella
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-16 00:00:00.000000000 Z
11
+ date: 2021-05-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -59,10 +59,22 @@ files:
59
59
  - lib/swift_lib_templater.rb
60
60
  - lib/swift_lib_templater/copy_template_command.rb
61
61
  - lib/swift_lib_templater/get_framework_name_command.rb
62
+ - lib/swift_lib_templater/get_template_command.rb
62
63
  - lib/swift_lib_templater/initialize_git_repository_command.rb
64
+ - lib/swift_lib_templater/library_template.rb
63
65
  - lib/swift_lib_templater/open_projet_command.rb
64
66
  - lib/swift_lib_templater/rename_files_command.rb
65
67
  - lib/swift_lib_templater/version.rb
68
+ - lib/templates/cli/.github/workflows/ci.yml
69
+ - lib/templates/cli/.gitignore
70
+ - lib/templates/cli/Makefile
71
+ - lib/templates/cli/Package.swift
72
+ - lib/templates/cli/README.md
73
+ - lib/templates/cli/Sources/CLI/Commands/TEMPLATECommand.swift
74
+ - lib/templates/cli/Sources/CLI/main.swift
75
+ - lib/templates/cli/Sources/TEMPLATE/TEMPLATE.swift
76
+ - lib/templates/cli/Tests/LinuxMain.swift
77
+ - lib/templates/cli/Tests/TEMPLATETests/TEMPLATETestManifests.swift
66
78
  - lib/templates/framework/.github/workflows/ci.yml
67
79
  - lib/templates/framework/.gitignore
68
80
  - lib/templates/framework/CHANGELOG.md