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 +4 -4
- data/lib/swift_lib_templater.rb +24 -3
- data/lib/swift_lib_templater/copy_template_command.rb +9 -2
- data/lib/swift_lib_templater/get_framework_name_command.rb +6 -3
- data/lib/swift_lib_templater/get_template_command.rb +19 -0
- data/lib/swift_lib_templater/library_template.rb +7 -0
- data/lib/swift_lib_templater/version.rb +1 -1
- data/lib/templates/cli/.github/workflows/ci.yml +14 -0
- data/lib/templates/cli/.gitignore +17 -0
- data/lib/templates/cli/Makefile +29 -0
- data/lib/templates/cli/Package.swift +33 -0
- data/lib/templates/cli/README.md +43 -0
- data/lib/templates/cli/Sources/CLI/Commands/TEMPLATECommand.swift +13 -0
- data/lib/templates/cli/Sources/CLI/main.swift +2 -0
- data/lib/templates/cli/Sources/TEMPLATE/TEMPLATE.swift +6 -0
- data/lib/templates/cli/Tests/LinuxMain.swift +7 -0
- data/lib/templates/cli/Tests/TEMPLATETests/TEMPLATETestManifests.swift +8 -0
- metadata +14 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a7622f1cb0983ce55834ff250b9ed415076d574e8ace192ca23352d433838bb
|
4
|
+
data.tar.gz: 19682ab8c36390d077b35e8f7630ad800ac890da4cededc467995db07893d667
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11826be157b6e3de08633af652810c4f7838289c7ed69334ab25dedd51414c75905477318c77b1c84d9d11b80028c7f305d4ec9dbb7031784b4b2fb896c084a0
|
7
|
+
data.tar.gz: 42242eddc75b5dae3e7b771be75353565234ea51f0d54b2bf1f3e1fcc766ad373a3705a6ce35e5788bf8e594f4a84d1136710745cf312e0b660e131c62fedefb
|
data/lib/swift_lib_templater.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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,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
|
+
```
|
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
|
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:
|
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
|