playwright-cli 0.1.9 → 0.1.10

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: 45b0e670209f275fe118a7bb654aaf4610f16a530632f9eff45b54f093640f22
4
- data.tar.gz: e6171e0830ecd54d4468a6eedbea1e2bf7643c5546b3078df8c4c2de0a82d26a
3
+ metadata.gz: 0eec96f8af1e1aa9529c9dd13d6e8863506caed0c87c018a9b56637f4d4dcc6f
4
+ data.tar.gz: 65997da9eb23bd3da6d1386abefee6164c63b2ad098b1bf8930e061e0ec27103
5
5
  SHA512:
6
- metadata.gz: a864c7fef3728f0de3e4f94b29ddc5d11bee82766512a1a65c19beb496b53e34094c0e8eed443b6b8c3d7760b6db79c8343b43df4d1a94b4399329fc9d0fc44c
7
- data.tar.gz: bdbb55fd95688b96f9b25670c30c69564a8137aa5eb79b2c13cde630c67736c1bc7fc9a8808c1cc542e912190266ac72785f4c649d91fe3b35ee272477a07e19
6
+ metadata.gz: 3fa3cf2d017197c3fc06db80d9a33f565e78bb438548b887882b968351e6cd790451de7788fa411c284bf4de62657aa6556e586c53f53d15e30c608e776dbbea
7
+ data.tar.gz: 32e834d0a2141ecb2698572b6b29317950e2d46b812e23a6dc4f42d649309ef6d018f5dbca6a5d7061976712d1ed04bd1fc042aa13453cd6088d8f43793654b2
data/Gemfile.lock CHANGED
@@ -1,8 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- playwright-cli (0.1.9)
4
+ playwright-cli (0.1.10)
5
5
  colorize (~> 0.1)
6
+ git (~> 1.3)
6
7
  hanami-cli (~> 0.1)
7
8
  os (~> 1.0)
8
9
 
@@ -13,6 +14,7 @@ GEM
13
14
  colorize (0.8.1)
14
15
  concurrent-ruby (1.0.5)
15
16
  diff-lcs (1.3)
17
+ git (1.3.0)
16
18
  hanami-cli (0.1.1)
17
19
  concurrent-ruby (~> 1.0)
18
20
  hanami-utils (~> 1.1)
data/README.md CHANGED
@@ -123,6 +123,9 @@ It will also give you a new file structure with an example (version) command:
123
123
  |- lib/
124
124
  | |- version.rb
125
125
  |- my-script.rb
126
+ |- .git/
127
+ |- .gitignore
128
+ |- README.md
126
129
  ```
127
130
  The main differences are that a new file lib/version is required and registered
128
131
  with aliases.
@@ -247,7 +250,7 @@ uninstall existing terminal commands, only playwright commands
247
250
 
248
251
  ## Contributing
249
252
 
250
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/playwright-cli.
253
+ Bug reports and pull requests are welcome on GitHub at https://github.com/mgreg90/playwright-cli.
251
254
 
252
255
  ## License
253
256
 
@@ -0,0 +1,28 @@
1
+ # <%= script_name %>
2
+
3
+ <%= script_name %> is a [playwright-cli](https://github.com/mgreg90/playwright-cli) script.
4
+ ADD DESCRIPTION HERE
5
+
6
+ ## Installation
7
+
8
+ This script relies on the playwright-cli gem. Sharing features are still
9
+ in development for playwright, so for now, you'll need to run the following
10
+ commands to install it.
11
+
12
+ ```shell
13
+ $ gem install playwright-cli
14
+ $ mkdir -p "$HOME/.playwright/plays"
15
+ $ cd "$HOME/.playwright/plays" && git clone git@github.com:[GIT_USERNAME]/<%= script_name.downcase %>.git
16
+ $ ln -s "$HOME/.playwright/plays/<%= script_name.downcase %>/<%= script_name.downcase %>.rb" "/usr/local/bin/<%= script_name.downcase %>"
17
+ ```
18
+
19
+ In the future, expect a `$ playwright get <%= script_name.downcase %>` command to exist.
20
+
21
+ ## Usage
22
+
23
+ EXPLAIN USAGE HERE.
24
+
25
+ ## Thanks!
26
+
27
+ Thanks for checking out my script. If you're interested in ruby scripting,
28
+ consider creating a [playwright-cli](https://github.com/mgreg90/playwright-cli) script of your own!
@@ -9,7 +9,7 @@ module Playwright
9
9
  include Utils::FileManager
10
10
 
11
11
  TEMPLATE_FILE = 'new_script.erb'.freeze
12
- PATH_BIN_DIR = File.join('/', 'usr', 'local', 'bin').freeze
12
+ PATH_BIN_DIR = Pathname.new(File.join('/', 'usr', 'local', 'bin'))
13
13
  DEFAULT_COLOR = :green
14
14
 
15
15
  def self.run(name)
@@ -12,7 +12,7 @@ module Playwright
12
12
  include Utils::FileManager
13
13
 
14
14
  TEMPLATE_FILE = 'new_script.erb'.freeze
15
- PATH_BIN_DIR = File.join('/', 'usr', 'local', 'bin').freeze
15
+ PATH_BIN_DIR = Pathname.new(File.join('/', 'usr', 'local', 'bin'))
16
16
 
17
17
  def self.run(name, type)
18
18
  new(name, type).run
@@ -8,8 +8,8 @@ module Playwright
8
8
  DEFAULT_EXECUTABLE_PATH_DIR = File.join('/', 'usr', 'local', 'bin')
9
9
 
10
10
  def initialize
11
- @home_dir = DEFAULT_HOME
12
- @executable_path_dir = DEFAULT_EXECUTABLE_PATH_DIR
11
+ @home_dir = Pathname.new DEFAULT_HOME
12
+ @executable_path_dir = Pathname.new DEFAULT_EXECUTABLE_PATH_DIR
13
13
  end
14
14
 
15
15
  end
@@ -12,17 +12,20 @@ module Playwright
12
12
  EXPANDED_TEMPLATE = 'expanded_script_template.erb'
13
13
  SUBCOMMAND_TYPE = :subcommand
14
14
  SUBCOMMAND_TEMPLATE = 'version_subcommand_template.erb'
15
+ README_TYPE = :readme
16
+ README_TEMPLATE = 'script_readme_template.erb'
15
17
 
16
18
  TEMPLATE_MAP = {
17
19
  SIMPLE_TYPE => SIMPLE_TEMPLATE,
18
20
  EXPANDED_TYPE => EXPANDED_TEMPLATE,
19
- SUBCOMMAND_TYPE => SUBCOMMAND_TEMPLATE
21
+ SUBCOMMAND_TYPE => SUBCOMMAND_TEMPLATE,
22
+ README_TYPE => README_TEMPLATE
20
23
  }
21
24
 
22
25
  def initialize(name:, out_file:, type: SIMPLE_TYPE, klass_name: nil)
23
26
  @script_name = name
24
27
  @out_file = out_file
25
- @template_file = File.join(Playwright::CLI::TEMPLATES_PATH, TEMPLATE_MAP[type])
28
+ @template_file = Playwright::CLI::TEMPLATES_PATH.join TEMPLATE_MAP[type]
26
29
  @klass_name = klass_name
27
30
  end
28
31
 
@@ -18,7 +18,7 @@ module Playwright
18
18
  FALSE_RESPONSE = :n
19
19
 
20
20
  def boolean_question user_question
21
- response = question "#{user question} [yn]"
21
+ response = question "#{user_question} [yn]"
22
22
  sanitized_response = response.chomp.strip.downcase.to_sym if response && response.length > 0
23
23
  boolean_response_map[response]
24
24
  end
@@ -16,9 +16,12 @@ module Playwright
16
16
  class FileManager
17
17
  include Display
18
18
  include Ask
19
+ include OS
19
20
 
20
21
  attr_reader :script_name, :type
21
22
 
23
+ GITIGNORE = []
24
+
22
25
  def initialize script_name: nil, type: nil
23
26
  @script_name = script_name
24
27
  @type = type
@@ -32,6 +35,9 @@ module Playwright
32
35
  write_template
33
36
  create_symlink
34
37
  open_editor
38
+ git_init
39
+ create_gitignore
40
+ create_readme
35
41
  end
36
42
 
37
43
  def uninstall_script script_name
@@ -51,23 +57,23 @@ module Playwright
51
57
  private
52
58
 
53
59
  def self.playwright_parent_dir
54
- Playwright::CLI.configuration.home_dir
60
+ Pathname.new(Playwright::CLI.configuration.home_dir)
55
61
  end
56
62
 
57
63
  def self.executable_path_dir
58
- Playwright::CLI.configuration.executable_path_dir
64
+ Pathname.new(Playwright::CLI.configuration.executable_path_dir)
59
65
  end
60
66
 
61
67
  def self.dot_playwright_dir
62
- File.join playwright_parent_dir, '.playwright'
68
+ playwright_parent_dir.join '.playwright'
63
69
  end
64
70
 
65
71
  def self.plays_dir
66
- File.join dot_playwright_dir, 'plays'
72
+ dot_playwright_dir.join 'plays'
67
73
  end
68
74
 
69
75
  def self.config_file
70
- File.join dot_playwright_dir, 'config.rb'
76
+ dot_playwright_dir.join 'config.rb'
71
77
  end
72
78
 
73
79
  def self.create_file_structure
@@ -97,7 +103,7 @@ module Playwright
97
103
  # ==============================================================================
98
104
 
99
105
  def root_dir
100
- File.join self.class.plays_dir, script_name
106
+ self.class.plays_dir.join script_name
101
107
  end
102
108
 
103
109
  def root_dir_exists?
@@ -105,7 +111,7 @@ module Playwright
105
111
  end
106
112
 
107
113
  def executable_file
108
- File.join root_dir, script_name_rb
114
+ root_dir.join script_name_rb
109
115
  end
110
116
 
111
117
  def executable_file_exists?
@@ -113,7 +119,7 @@ module Playwright
113
119
  end
114
120
 
115
121
  def symlink_file
116
- File.join self.class.executable_path_dir, script_name
122
+ self.class.executable_path_dir.join script_name
117
123
  end
118
124
 
119
125
  def symlink_file_exists?
@@ -121,11 +127,11 @@ module Playwright
121
127
  end
122
128
 
123
129
  def script_lib_dir
124
- File.join root_dir, 'lib'
130
+ root_dir.join 'lib'
125
131
  end
126
132
 
127
133
  def version_subcommand_file
128
- File.join script_lib_dir, 'version.rb'
134
+ script_lib_dir.join 'version.rb'
129
135
  end
130
136
 
131
137
  # ==============================================================================
@@ -182,6 +188,28 @@ module Playwright
182
188
  end
183
189
  end
184
190
 
191
+ def git_init
192
+ git = Git.init root_dir.to_s
193
+ git.add all: true
194
+ git.commit('initial commit')
195
+ end
196
+
197
+ def create_gitignore
198
+ File.open root_dir.join(".gitignore"), "w+" do |file|
199
+ file.write GITIGNORE.join("\n")
200
+ end
201
+ end
202
+
203
+ def create_readme
204
+ FileUtils.touch root_dir.join("README.md")
205
+ new_template = Template.new(
206
+ name: script_name,
207
+ out_file: root_dir.join("README.md"),
208
+ type: Template::README_TYPE
209
+ )
210
+ new_template.render
211
+ end
212
+
185
213
  # ==============================================================================
186
214
  # DELETE METHODS
187
215
  # ==============================================================================
@@ -1,5 +1,5 @@
1
1
  module Playwright
2
2
  class CLI < Hanami::CLI
3
- VERSION = "0.1.9"
3
+ VERSION = "0.1.10"
4
4
  end
5
5
  end
@@ -1,5 +1,7 @@
1
1
  require 'hanami/cli'
2
2
  require 'colorize'
3
+ require 'git'
4
+
3
5
  require 'fileutils'
4
6
  require 'erb'
5
7
  require 'os'
@@ -11,10 +13,10 @@ require 'pry'
11
13
 
12
14
  module Playwright
13
15
  class CLI < Hanami::CLI
14
- ROOT_PATH = File.expand_path('../..', File.dirname(__FILE__))
15
- PLAYS_PATH = File.join(ROOT_PATH, 'plays')
16
- PLAYS_BIN_PATH = File.join(PLAYS_PATH, 'bin')
17
- TEMPLATES_PATH = File.join(ROOT_PATH, 'lib', 'assets', 'templates')
16
+ ROOT_PATH = Pathname.new(File.expand_path('../..', File.dirname(__FILE__)))
17
+ PLAYS_PATH = ROOT_PATH.join 'plays'
18
+ PLAYS_BIN_PATH = PLAYS_PATH.join 'bin'
19
+ TEMPLATES_PATH = ROOT_PATH.join 'lib', 'assets', 'templates'
18
20
 
19
21
  require "playwright/cli/command"
20
22
  require "playwright/cli/commands"
@@ -38,7 +38,8 @@ Gem::Specification.new do |spec|
38
38
  spec.add_development_dependency "pry-nav", "~> 0.2.4"
39
39
  spec.add_development_dependency "memfs", "~> 1.0"
40
40
 
41
- spec.add_runtime_dependency "hanami-cli", "~>0.1"
42
- spec.add_runtime_dependency "colorize", "~>0.1"
43
- spec.add_runtime_dependency "os", "~> 1.0"
41
+ spec.add_runtime_dependency "hanami-cli", "~> 0.1"
42
+ spec.add_runtime_dependency "colorize", "~> 0.1"
43
+ spec.add_runtime_dependency "os", "~> 1.0"
44
+ spec.add_runtime_dependency "git", "~> 1.3"
44
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: playwright-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.9
4
+ version: 0.1.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Gregory
@@ -136,6 +136,20 @@ dependencies:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '1.0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: git
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.3'
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.3'
139
153
  description:
140
154
  email:
141
155
  - mgregory8219@gmail.com
@@ -156,6 +170,7 @@ files:
156
170
  - bin/setup
157
171
  - exe/playwright
158
172
  - lib/assets/templates/expanded_script_template.erb
173
+ - lib/assets/templates/script_readme_template.erb
159
174
  - lib/assets/templates/simple_script_template.erb
160
175
  - lib/assets/templates/version_subcommand_template.erb
161
176
  - lib/playwright/cli.rb