runa 0.2.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 260b2cf570fb222aa1a71e6bd9eb44bd08194b878f11c9f58a80267e8fd49a58
4
- data.tar.gz: 9c8ed4bc10a3013ea7d04bacdbb3eb039dc6503f6d2b3e58226ee698b11d36bd
3
+ metadata.gz: a522391930171e4e77161f28e2291cf2be945d88338ccfed28c7870e74a5ddf7
4
+ data.tar.gz: b2c43a43fa11ac1a7945a3930e52c1773d2947955bc9acd519dc8bde01f8974e
5
5
  SHA512:
6
- metadata.gz: ff244c05be35715fa140c7b9f5e800e295d07ac33c57cffe19ee9fd6f485bda88118dffedbfb4b9ed8d90e6a33c931331a40dd8449b2baa5dd3a5e7b89ac6971
7
- data.tar.gz: 81ffcabaa804a8654966790ce260aabe41ee044587bdc33e10184062dfa0ed5063ebb2911e065afb3af2645e2071921eba533f28c63fa64ba98227f7c703eaef
6
+ metadata.gz: cb319f1f1c8053dce8f794fc793e3f0f7b23a56aacd94bf9bf1b0a66a267c3c723b54b719f09d81f2b5ddd59b4482dfac87cb37117e17d8e6f78171673e8e243
7
+ data.tar.gz: d36be1c15076965e1a75dd485244f4d29f8692ac1b8fe25be57c70e8f4fda32c3c621893c37ddeb9934ec774159d225680b1688f9957d3e5660b1ed6e3f70c67
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [0.3.0] - 2023-06-13
2
+ - Rename release command to generate(gen)
3
+ - Support Mac/Linux/WSL
4
+
1
5
  ## [0.2.0] - 2023-05-29
2
6
  - Add subcommand release
3
7
 
data/Gemfile CHANGED
@@ -10,3 +10,5 @@ gem "rake", "~> 13.0"
10
10
  gem "test-unit", "~> 3.0"
11
11
 
12
12
  gem "standard", "~> 1.3"
13
+
14
+ gem "os", "~> 1.1"
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- runa (0.1.0)
4
+ runa (0.3.0)
5
+ os
5
6
  thor
6
7
 
7
8
  GEM
@@ -11,6 +12,7 @@ GEM
11
12
  json (2.6.3)
12
13
  language_server-protocol (3.17.0.3)
13
14
  lint_roller (1.0.0)
15
+ os (1.1.4)
14
16
  parallel (1.23.0)
15
17
  parser (3.2.2.1)
16
18
  ast (~> 2.4.1)
@@ -53,8 +55,10 @@ GEM
53
55
 
54
56
  PLATFORMS
55
57
  x64-mingw-ucrt
58
+ x86_64-linux
56
59
 
57
60
  DEPENDENCIES
61
+ os (~> 1.1)
58
62
  rake (~> 13.0)
59
63
  runa!
60
64
  standard (~> 1.3)
data/README.md CHANGED
@@ -10,22 +10,65 @@ $ gem install runa
10
10
 
11
11
  ## Usage
12
12
 
13
- Create a new application.
13
+ ### Create a new application
14
14
 
15
15
  ```
16
16
  $ runa new runa_app
17
+ Created 'runa_app' application.
17
18
  $ cd runa_app
18
19
  ```
19
20
 
21
+ ### Add gems
20
22
  If you need a gem, Write it in the `Gemfile`.
21
23
 
22
24
  ```
23
25
  $ code Gemfile
24
26
  $ runa install
27
+ .
28
+ .
29
+ Generate '.runa/runa_load_path.rb'
25
30
  ```
26
31
 
27
- Run application.
32
+ Or use gem_add command.
33
+
34
+ ```
35
+ $ runa gem_add launchy
36
+ .
37
+ .
38
+ Generate '.runa/runa_load_path.rb'
39
+ ```
40
+
41
+ ### Run application
28
42
 
29
43
  ```
30
44
  $ runa run
45
+ Hello, World!
46
+ ```
47
+
48
+ ### Deploy scripts for production execution
49
+
50
+ Mac/Linux/WSL
51
+
52
+ ```
53
+ $ runa deploy
54
+ Generate '.runa/runa_app'
55
+ '.runa/runa_app' is the script to run. Copy it to any location and use it.
56
+
57
+ $ chmod +x .runa/runa_app
58
+ $ cp .runa/runa_app path/to/bin
59
+ $ runa_app
60
+ Hello, World!
61
+ ```
62
+
63
+ Windows
64
+
65
+ ```
66
+ PS> runa deploy
67
+ Generate '.runa/runa_load_path.rb'
68
+ Generate '.runa/runa_app.bat'
69
+ '.runa/runa_app.bat' is the script to run. Copy it to any location and use it.
70
+
71
+ PS> cp .runa\runa_app.bat path\to\bin
72
+ PS> runa_app
73
+ Hello, world!
31
74
  ```
data/exe/runa CHANGED
@@ -3,6 +3,7 @@
3
3
  require "runa"
4
4
  require "thor"
5
5
  require "fileutils"
6
+ require "os"
6
7
 
7
8
  class RunaCli < Thor
8
9
  def self.exit_on_failure?
@@ -19,20 +20,31 @@ class RunaCli < Thor
19
20
 
20
21
  FileUtils.mkdir_p(name)
21
22
  Dir.chdir(name) do
23
+ FileUtils.mkdir_p(RUNA_DIR)
24
+ File.write("#{RUNA_DIR}/.gitkeep", "")
22
25
  FileUtils.mkdir_p(".bundle")
23
26
  File.write(".bundle/config", "---\nBUNDLE_PATH: \"vendor/bundle\"\n")
24
27
  FileUtils.mkdir_p("lib/#{name}")
25
28
  File.write("lib/#{name}.rb", "require \"#{name}/lib\"\n")
26
29
  File.write("lib/#{name}/lib.rb", "module #{module_name}\nend\n")
27
- File.write(".gitignore", "/vendor/\n/.runa/\n")
30
+ File.write(".gitignore", "/vendor/\n/.runa/*\n!/.runa/.gitkeep\n")
28
31
  File.write("Gemfile", "# frozen_string_literal: true\n\nsource \"https://rubygems.org\"\n\n# gem \"rails\"\n")
29
32
  File.write("main.rb", "require \"#{name}\"\n\nputs \"Hello, world!\"")
30
33
  end
34
+
35
+ puts "Created '#{name}' application."
36
+ end
37
+
38
+ desc "gem_add", "Add gems"
39
+ def gem_add(*gems)
40
+ system("bundle add #{gems.join(" ")}")
41
+ deploy_load_path_script
31
42
  end
32
43
 
33
44
  desc "install", "Install gems"
34
45
  def install
35
46
  system("bundle install")
47
+ deploy_load_path_script
36
48
  end
37
49
 
38
50
  desc "run [ARGS]", "Run application with arguments"
@@ -41,33 +53,47 @@ class RunaCli < Thor
41
53
  end
42
54
  map "run" => "run_command"
43
55
 
44
- desc "release", "Release scripts for production execution"
45
- def release
56
+ desc "deploy", "Deploy scripts for production execution"
57
+ def deploy
46
58
  root_dir = File.expand_path(".")
47
- release_script_name = File.basename(root_dir)
48
- FileUtils.mkdir_p(RUNA_DIR)
49
- Dir.chdir(RUNA_DIR) do
50
- File.write("runa_load_path.rb", load_path_script)
51
- path = "#{release_script_name}.bat"
52
- File.write(path, release_script(root_dir))
53
- puts "'#{File.join(root_dir, RUNA_DIR, path)}' generated. It can be copied to any location."
54
- end
59
+ deploy_script_name = File.basename(root_dir)
60
+ deploy_load_path_script
61
+ path = File.join(RUNA_DIR, deploy_script_name)
62
+ path += ".bat" if OS.windows?
63
+ File.write(path, deploy_script(root_dir))
64
+ puts "Generate '#{path}'\n'#{path}' is the script to run. Copy it to any location and use it."
55
65
  end
56
66
 
57
67
  private
58
68
 
59
69
  RUNA_DIR = ".runa"
60
70
 
61
- def release_script(root_dir)
62
- # TODO: Linux
63
- lib_dir = File.join(root_dir, "lib").tr("/", "\\")
64
- runa_dir = File.join(root_dir, RUNA_DIR).tr("/", "\\")
65
- main_rb = File.join(root_dir, "main.rb").tr("/", "\\")
71
+ def deploy_script(root_dir)
72
+ lib_dir = File.join(root_dir, "lib")
73
+ runa_dir = File.join(root_dir, RUNA_DIR)
74
+ main_rb = File.join(root_dir, "main.rb")
75
+
76
+ if OS.windows?
77
+ lib_dir = lib_dir.tr("/", "\\")
78
+ runa_dir = runa_dir.tr("/", "\\")
79
+ main_rb = main_rb.tr("/", "\\")
80
+
81
+ <<~EOS
82
+ @ECHO OFF
83
+ @ruby -I"#{lib_dir}" -I"#{runa_dir}" -rruna_load_path #{main_rb} %*
84
+ EOS
85
+ else
86
+ <<~EOS
87
+ #!/bin/sh
88
+ ruby -I"#{lib_dir}" -I"#{runa_dir}" -rruna_load_path #{main_rb} $@
89
+ EOS
90
+ end
91
+ end
66
92
 
67
- <<~EOS
68
- @ECHO OFF
69
- @ruby -I"#{lib_dir}" -I"#{runa_dir}" -rruna_load_path #{main_rb} %*"
70
- EOS
93
+ def deploy_load_path_script
94
+ path = "#{RUNA_DIR}/runa_load_path.rb"
95
+ File.write(path, load_path_script)
96
+ puts "Generate '#{path}'"
71
97
  end
72
98
 
73
99
  def load_path_script
data/lib/runa/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Runa
4
- VERSION = "0.2.0"
4
+ VERSION = "0.4.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: runa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ongaeshi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-05-28 00:00:00.000000000 Z
11
+ date: 2023-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -24,6 +24,20 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: os
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  description: Runa is a command line interface for easily creating Ruby applications.
28
42
  email:
29
43
  - ongaeshi0621@gmail.com