This repository was archived by the owner on Jun 1, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
197 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2.5.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# NOTE: These are development-only dependencies | ||
source "https://rubygems.org" | ||
|
||
ruby '2.5.1' | ||
|
||
# None of these can actually be used in a development copy of dev | ||
# They are all for CI and tests | ||
# `dev` uses no gems | ||
|
||
gem 'rake' | ||
gem 'byebug' | ||
|
||
group :test do | ||
gem 'session' | ||
gem 'mocha', require: false | ||
gem 'minitest', '>= 5.0.0', require: false | ||
gem 'minitest-reporters', require: false | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
GEM | ||
remote: https://rubygems.org/ | ||
specs: | ||
ansi (1.5.0) | ||
builder (3.2.3) | ||
byebug (8.2.2) | ||
metaclass (0.0.4) | ||
minitest (5.11.3) | ||
minitest-reporters (1.3.5) | ||
ansi | ||
builder | ||
minitest (>= 5.0) | ||
ruby-progressbar | ||
mocha (1.7.0) | ||
metaclass (~> 0.0.1) | ||
rake (12.1.0) | ||
ruby-progressbar (1.10.0) | ||
session (3.2.0) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
byebug | ||
minitest (>= 5.0.0) | ||
minitest-reporters | ||
mocha | ||
rake | ||
session | ||
|
||
RUBY VERSION | ||
ruby 2.3.7p456 | ||
|
||
BUNDLED WITH | ||
1.16.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require_relative 'bin/support/load_shopify' | ||
require 'rake/testtask' | ||
|
||
Rake::TestTask.new do |t| | ||
t.libs += %w(test) | ||
t.test_files = FileList['test/**/*_test.rb'] | ||
t.verbose = false | ||
t.warning = false | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,13 +18,12 @@ def call(args, _name) | |
end | ||
|
||
def embedded_app | ||
CLI::UI::Frame.open('Cloning embeddedapp...') do | ||
CLI::UI::Frame.open('Cloning embedded app...') do | ||
git_progress('clone', '--single-branch', '[email protected]:shopify/webgen-embeddedapp.git', @name) | ||
end | ||
api_key = CLI::UI.ask('What is your Shopify API Key') | ||
api_secret = CLI::UI.ask('What is your Shopify API Secret') | ||
File.write(File.join(@name, '.env'), | ||
"SHOPIFY_API_KEY=#{api_key}\nSHOPIFY_API_SECRET_KEY=#{api_secret}") | ||
write_env_file(api_key, api_secret) | ||
|
||
CLI::UI::Frame.open('Installing dependencies...') do | ||
yarn | ||
|
@@ -41,6 +40,11 @@ def self.help | |
"Bootstrap an app.\nUsage: {{command:#{ShopifyCli::TOOL_NAME} create <apptype> <appname>}}" | ||
end | ||
|
||
def write_env_file(api_key, api_secret) | ||
File.write(File.join(@name, '.env'), | ||
"SHOPIFY_API_KEY=#{api_key}\nSHOPIFY_API_SECRET_KEY=#{api_secret}") | ||
end | ||
|
||
def git_progress(*git_command) | ||
CLI::UI::Progress.progress do |bar| | ||
success = CLI::Kit::System.system('git', *git_command, '--progress') do |_out, err| | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
module Minitest | ||
class Test | ||
def capture_io(&block) | ||
cap = CLI::UI::StdoutRouter::Capture.new(with_frame_inset: true, &block) | ||
cap.run | ||
[cap.stdout, cap.stderr] | ||
end | ||
|
||
def to_s # :nodoc: | ||
if passed? && !skipped? | ||
return location | ||
end | ||
failures.flat_map do |failure| | ||
[ | ||
"#{failure.result_label}:", | ||
"#{location}:", | ||
failure.message.force_encoding(Encoding::UTF_8), | ||
] | ||
end.join("\n") | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
require 'test_helper' | ||
|
||
module ShopifyCli | ||
module Tasks | ||
class CreateTest < MiniTest::Test | ||
def setup | ||
@command = ShopifyCli::Commands::Create.new | ||
end | ||
|
||
def test_prints_help_with_no_name_argument | ||
io = capture_io do | ||
@command.call([], nil) | ||
end | ||
|
||
assert_match(CLI::UI.fmt(ShopifyCli::Commands::Create.help), io.join) | ||
end | ||
|
||
def test_exists_with_not_implemented_choice | ||
CLI::UI::Prompt.expects(:ask).returns(false) | ||
io = capture_io do | ||
@command.call(['test-app'], nil) | ||
end | ||
|
||
assert_match('not yet implemented', io.join) | ||
end | ||
|
||
def test_embedded_app_creation | ||
CLI::UI::Prompt.expects(:ask).returns('embedded_app') | ||
@command.expects(:git_progress).with( | ||
'clone', '--single-branch', '[email protected]:shopify/webgen-embeddedapp.git', 'test-app' | ||
) | ||
CLI::UI.expects(:ask).twice.returns('apikey', 'apisecret') | ||
@command.expects(:write_env_file) | ||
@command.expects(:yarn) | ||
io = capture_io do | ||
@command.call(['test-app'], nil) | ||
end | ||
output = io.join | ||
|
||
assert_match('Cloning embedded app...', output) | ||
assert_match('Installing dependencies...', output) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
require 'test_helper' | ||
|
||
module ShopifyCli | ||
module Tasks | ||
class HelpTest < MiniTest::Test | ||
def setup | ||
@command = ShopifyCli::Commands::Help.new | ||
end | ||
|
||
def test_default_behavior_lists_tasks | ||
io = capture_io do | ||
@command.call([], nil) | ||
end | ||
output = io.join | ||
|
||
assert_match('Available commands', output) | ||
assert_match(/Usage: .*shopify/, output) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
require 'test_helper' | ||
|
||
module ShopifyCli | ||
module Tasks | ||
class TaskTest < MiniTest::Test | ||
def setup | ||
@command = ShopifyCli::Commands::Help.new | ||
end | ||
|
||
def test_non_existant | ||
io = capture_io do | ||
@command.call(%w(foobar), nil) | ||
end | ||
|
||
assert_match(/Available commands/, io.join) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
begin | ||
addpath = lambda do |p| | ||
path = File.expand_path("../../#{p}", __FILE__) | ||
$LOAD_PATH.unshift(path) unless $LOAD_PATH.include?(path) | ||
end | ||
addpath.call("lib") | ||
addpath.call("vendor/lib") | ||
end | ||
|
||
require 'rubygems' | ||
require 'bundler/setup' | ||
require 'shopify-cli' | ||
require 'byebug' | ||
|
||
require 'minitest/autorun' | ||
require 'minitest/reporters' | ||
require_relative 'minitest_ext' | ||
|
||
require 'mocha/minitest' |