From efc976f606ed6ad28d413584da382836b8af86cf Mon Sep 17 00:00:00 2001 From: Hamid Date: Mon, 21 Aug 2017 03:50:10 +0100 Subject: [PATCH] initial commit: rename later --- Gemfile | 6 ++++++ Gemfile.lock | 2 ++ config.rb | 2 ++ lib/codeless_cli.rb | 22 ++++++++++++++++++++++ lib/codeless_extension.rb | 28 ++++++++++++++++++++++++++++ 5 files changed, 60 insertions(+) create mode 100644 lib/codeless_cli.rb create mode 100644 lib/codeless_extension.rb diff --git a/Gemfile b/Gemfile index 229d233..8141283 100644 --- a/Gemfile +++ b/Gemfile @@ -2,6 +2,12 @@ # the following line to use 'https' source 'http://rubygems.org' +# command line interface +gem 'thor' + +# environment +gem 'dotenv' + # Core gem 'middleman', '~> 4.2.0' gem 'middleman-autoprefixer', '~> 2.7.1' diff --git a/Gemfile.lock b/Gemfile.lock index 11c48b0..09754d6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -160,6 +160,7 @@ PLATFORMS ruby DEPENDENCIES + dotenv middleman (~> 4.2.0) middleman-autoprefixer (~> 2.7.1) middleman-deploy! @@ -172,6 +173,7 @@ DEPENDENCIES oga (~> 2.8) rake slim (~> 3.0.7) + thor BUNDLED WITH 1.15.3 diff --git a/config.rb b/config.rb index fb09fc3..bed4755 100644 --- a/config.rb +++ b/config.rb @@ -1,5 +1,7 @@ +require 'dotenv/load' require 'slim' +activate :my_feature, activate :autoprefixer, browsers: ['last 2 versions', 'ie 8', 'ie 9'] activate :livereload activate :directory_indexes diff --git a/lib/codeless_cli.rb b/lib/codeless_cli.rb new file mode 100644 index 0000000..64a127d --- /dev/null +++ b/lib/codeless_cli.rb @@ -0,0 +1,22 @@ +#!/usr/bin/env ruby + +require "thor" + +class CodelessCLI < Thor + include Thor::Actions + + desc 'getInfo', 'tell us your info' + + def get_user_info + say("\n\nHello, before we continue I need some information from you...\n\n\n") + + [ 'name', 'github', 'twitter' ].each do |info| + append_to_file '.env', "\n#{info.upcase}='#{ask("\n\nWhat is your #{info}?\n", :yellow)}'" + end + + say("\n\nComplete!\n\n", :green) + end + +end + +CodelessCLI.start(ARGV) diff --git a/lib/codeless_extension.rb b/lib/codeless_extension.rb new file mode 100644 index 0000000..4210cb4 --- /dev/null +++ b/lib/codeless_extension.rb @@ -0,0 +1,28 @@ +require 'codeless_cli' + +class MyFeature < Middleman::Extension + # All the options for this extension + option :foo, false, 'Controls whether we foo' + + def initialize(app, options_hash={}, &block) + super + + puts options.foo + puts options.foo + puts options.foo + puts options.foo + puts options.foo + puts options.foo + puts options.foo + puts options.foo + puts options.foo + puts options.foo + puts options.foo + end + + def after_build(builder) + builder.thor.run './codeless_cli.rb' + end +end + +::Middleman::Extensions.register(:my_feature, MyFeature)