itcsscli 0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 632bbc0d67e2aef004c597cb298d6c51efa9fff3
4
+ data.tar.gz: 580ac3d24e0105268cc97af103c46229f3ac65cb
5
+ SHA512:
6
+ metadata.gz: 29234c47d3b6d842ccc2e8caf3db5fff3316697831f9391d68b92548ca15db986e8e7a364d25503c35f33f6b63ff06bbd845d41862d7a1e7c78ae920696f9218
7
+ data.tar.gz: 346bddcc0b8b19868f058ec0df54d952ffe66534d9c1e6f07c5c9dbbc81e29781f545a86d7696f1df252b4445e76cdfd2bc29bedc72ca13f18c47fbe110e635b
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at kandebonfim@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in itcsscli.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Kande Bonfim
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,155 @@
1
+ ## Installation
2
+
3
+ Add this line to your application's Gemfile:
4
+
5
+ ```ruby
6
+ gem 'itcss_cli'
7
+ ```
8
+
9
+ And then execute:
10
+
11
+ ```{r, engine='bash'}
12
+ $ bundle
13
+ ```
14
+
15
+ Or install it yourself as:
16
+
17
+ ```{r, engine='bash'}
18
+ $ gem install itcss_cli
19
+ ```
20
+
21
+ ## Usage
22
+
23
+ First, you'll need to set up ITCSS by running:
24
+
25
+ ```{r, engine='bash'}
26
+ $ itcss init
27
+ ```
28
+
29
+ Now go to `itcss.yml` and do your itcss_cli config:
30
+
31
+ ```yml
32
+ # Root folder where the ITCSS file structure should be builded.
33
+ stylesheets_directory: source/stylesheets
34
+
35
+ # Base sass file (all ITCSS modules will be imported in it).
36
+ stylesheets_import_file: application
37
+
38
+ # Uncomment to enable inuit modules importing. [ bower or npm ]
39
+ # package_manager: bower
40
+
41
+ # inuit_modules:
42
+ # - tools.functions
43
+ # - settings.defaults
44
+ # - base.page
45
+ ```
46
+
47
+ Go ahead and grow your ITCSS structure:
48
+ ```{r, engine='bash'}
49
+ $ itcss new component modals
50
+ create source/stylesheets/components/_components.modals.sass
51
+ update source/stylesheets/application.sass
52
+
53
+ $ itcss new trumps helpers
54
+ create source/stylesheets/trumps/_trumps.helpers.sass
55
+ update source/stylesheets/application.sass
56
+ ```
57
+
58
+ ## Inuitcss Commands
59
+
60
+ You can install and automatically import inuit modules via cli:
61
+
62
+ ```{r, engine='bash'}
63
+ $ itcss inuit new settings.defaults
64
+ using bower to install inuit 'settings.defaults' dependency...
65
+ bower inuit-defaults#~0.2.3 install inuit-defaults#0.2.3
66
+
67
+ inuit-defaults#0.2.3 bower_components/inuit-defaults
68
+ update itcss.yml. [added settings.defaults]
69
+ update source/stylesheets/application.sass
70
+ ```
71
+
72
+ Result at `application.sass`:
73
+ ```sass
74
+ ...
75
+ // [1] Settings
76
+ @import "inuit-defaults/settings.defaults"
77
+ ...
78
+ ```
79
+
80
+ ## Creating a full ITCSS structure
81
+
82
+ ```{r, engine='bash'}
83
+ $ itcss install example
84
+ create source/stylesheets/settings/_settings.example.sass
85
+ create source/stylesheets/tools/_tools.example.sass
86
+ create source/stylesheets/generic/_generic.example.sass
87
+ create source/stylesheets/base/_base.example.sass
88
+ create source/stylesheets/objects/_objects.example.sass
89
+ create source/stylesheets/components/_components.example.sass
90
+ create source/stylesheets/trumps/_trumps.example.sass
91
+ update source/stylesheets/application.css.sass
92
+ ```
93
+
94
+ If you open the ITCSS's base file now, you'll see that all ITCSS modules are automatically imported into it:
95
+ ```sass
96
+ @charset "utf-8"
97
+
98
+ // ========================================
99
+ // application.css.sass
100
+ // ========================================
101
+
102
+
103
+ // [0] Requirements --- Vendor libraries
104
+ // [1] Settings ------- Sass vars, etc.
105
+ // [2] Tools ---------- Functions and mixins.
106
+ // [3] Generic -------- Generic, high-level styling, like resets, etc.
107
+ // [4] Base ----------- Unclasses HTML elements (e.g. `h2`, `ul`).
108
+ // [5] Objects -------- Objects and abstractions.
109
+ // [6] Components ----- Your designed UI elements (inuitcss includes none of these).
110
+ // [7] Trumps --------- Overrides and helper classes.
111
+
112
+ // ↓ ITCSS_CLI FILE IMPORTING ↓
113
+
114
+ // [0] Settings
115
+ @import "settings/_settings.example.sass"
116
+
117
+
118
+ // [1] Tools
119
+ @import "tools/_tools.example.sass"
120
+
121
+
122
+ // [2] Generic
123
+ @import "generic/_generic.example.sass"
124
+
125
+
126
+ // [3] Base
127
+ @import "base/_base.example.sass"
128
+
129
+
130
+ // [4] Objects
131
+ @import "objects/_objects.example.sass"
132
+
133
+
134
+ // [5] Components
135
+ @import "components/_components.example.sass"
136
+
137
+
138
+ // [6] Trumps
139
+ @import "trumps/_trumps.example.sass"
140
+
141
+
142
+ // ↑ ITCSS_CLI FILE IMPORTING ↑
143
+ ```
144
+
145
+ ---
146
+
147
+ # Contributing
148
+
149
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/itcss_cli. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
150
+
151
+
152
+ ## License
153
+
154
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
155
+
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "itcsscli"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'itcsscli'
4
+
5
+ init = Itcsscli::Core.new
6
+ init.command_parser
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,175 @@
1
+ settings.defaults:
2
+ name: settings.defaults
3
+ slug: inuit-defaults
4
+ repo: github.com/inuitcss/settings.defaults
5
+ desc: inuitcss’ default settings
6
+ settings.responsive:
7
+ name: settings.responsive
8
+ slug: inuit-responsive-settings
9
+ repo: github.com/inuitcss/settings.responsive
10
+ desc: ---
11
+ tools.functions:
12
+ name: tools.functions
13
+ slug: inuit-functions
14
+ repo: github.com/inuitcss/tools.functions
15
+ desc: inuitcss’ default functions
16
+ tools.mixins:
17
+ name: tools.mixins
18
+ slug: inuit-mixins
19
+ repo: github.com/inuitcss/tools.mixins
20
+ desc: inuitcss’ default mixins
21
+ tools.responsive:
22
+ name: tools.responsive
23
+ slug: inuit-responsive-tools
24
+ repo: github.com/inuitcss/tools.responsive
25
+ desc: ---
26
+ tools.widths:
27
+ name: tools.widths
28
+ slug: inuit-tools-widths
29
+ repo: github.com/inuitcss/tools.widths
30
+ desc: inuitcss width classes generator
31
+ generic.box-sizing:
32
+ name: generic.box-sizing
33
+ slug: inuit-box-sizing
34
+ repo: github.com/inuitcss/generic.box-sizing
35
+ desc: Global box-sizing options.
36
+ generic.normalize:
37
+ name: generic.normalize
38
+ slug: inuit-normalize
39
+ repo: github.com/inuitcss/generic.normalize
40
+ desc: "@necolas’ normalize.css."
41
+ generic.reset:
42
+ name: generic.reset
43
+ slug: inuit-reset
44
+ repo: github.com/inuitcss/generic.reset
45
+ desc: Basic reset to complement normalize.css.
46
+ generic.shared:
47
+ name: generic.shared
48
+ slug: inuit-shared
49
+ repo: github.com/inuitcss/generic.shared
50
+ desc: High-level styling across shared rulesets
51
+ base.headings:
52
+ name: base.headings
53
+ slug: inuit-headings
54
+ repo: github.com/inuitcss/base.headings
55
+ desc: Base-level heading styles.
56
+ base.images:
57
+ name: base.images
58
+ slug: inuit-images
59
+ repo: github.com/inuitcss/base.images
60
+ desc: Simple image styles
61
+ base.lists:
62
+ name: base.lists
63
+ slug: inuit-lists
64
+ repo: github.com/inuitcss/base.lists
65
+ desc: Simple list styles
66
+ base.page:
67
+ name: base.page
68
+ slug: inuit-page
69
+ repo: github.com/inuitcss/base.page
70
+ desc: Base page-level styling.
71
+ base.paragraphs:
72
+ name: base.paragraphs
73
+ slug: inuit-paragraphs
74
+ repo: github.com/inuitcss/base.paragraphs
75
+ desc: Simple paragraph styles
76
+ objects.block:
77
+ name: objects.block
78
+ slug: inuit-block
79
+ repo: github.com/inuitcss/objects.block
80
+ desc: Stack an image above some text content.
81
+ objects.box:
82
+ name: objects.box
83
+ slug: inuit-box
84
+ repo: github.com/inuitcss/objects.box
85
+ desc: Simple object to make boxed-off content.
86
+ objects.buttons:
87
+ name: objects.buttons
88
+ slug: inuit-buttons
89
+ repo: github.com/inuitcss/objects.buttons
90
+ desc: Simple, extensible button objects
91
+ objects.flag:
92
+ name: objects.flag
93
+ slug: inuit-flag
94
+ repo: github.com/inuitcss/objects.flag
95
+ desc: The flag object
96
+ objects.layout:
97
+ name: objects.layout
98
+ slug: inuit-layout
99
+ repo: github.com/inuitcss/objects.layout
100
+ desc: inuitcss’ answer to the traditional grid system
101
+ objects.list-bare:
102
+ name: objects.list-bare
103
+ slug: inuit-list-bare
104
+ repo: github.com/inuitcss/objects.list-bare
105
+ desc: A simple object to remove bullets and indents from lists
106
+ objects.list-block:
107
+ name: objects.list-block
108
+ slug: inuit-list-block
109
+ repo: github.com/inuitcss/objects.list-block
110
+ desc: A simple, blocky list object.
111
+ objects.list-inline:
112
+ name: objects.list-inline
113
+ slug: inuit-list-inline
114
+ repo: github.com/inuitcss/objects.list-inline
115
+ desc: displays a list as one horizontal row.
116
+ objects.list-ui:
117
+ name: objects.list-ui
118
+ slug: inuit-list-ui
119
+ repo: github.com/inuitcss/objects.list-ui
120
+ desc: A simple, keyline-delimited blocky list object.
121
+ objects.media:
122
+ name: objects.media
123
+ slug: inuit-media
124
+ repo: github.com/inuitcss/objects.media
125
+ desc: "@stubbornella’s media object"
126
+ objects.pack:
127
+ name: objects.pack
128
+ slug: inuit-pack
129
+ repo: github.com/inuitcss/objects.pack
130
+ desc: Cause items to pack up to automatically fill their parent.
131
+ objects.tables:
132
+ name: objects.tables
133
+ slug: inuit-tables
134
+ repo: github.com/inuitcss/objects.tables
135
+ desc: Basic table styles.
136
+ objects.tabs:
137
+ name: objects.tabs
138
+ slug: inuit-tabs
139
+ repo: github.com/inuitcss/objects.tabs
140
+ desc: Simple tabs abstraction.
141
+ trumps.clearfix:
142
+ name: trumps.clearfix
143
+ slug: inuit-clearfix
144
+ repo: github.com/inuitcss/trumps.clearfix
145
+ desc: Simple clearfix helper
146
+ trumps.headings:
147
+ name: trumps.headings
148
+ slug: inuit-headings-trumps
149
+ repo: github.com/inuitcss/trumps.headings
150
+ desc: ---
151
+ trumps.print:
152
+ name: trumps.print
153
+ slug: inuit-print
154
+ repo: github.com/inuitcss/trumps.print
155
+ desc: Very basic reset-like module for print styles.
156
+ trumps.spacing:
157
+ name: trumps.spacing
158
+ slug: inuit-spacing
159
+ repo: github.com/inuitcss/trumps.spacing
160
+ desc: Spacing helper classes
161
+ trumps.spacing-responsive:
162
+ name: trumps.spacing-responsive
163
+ slug: inuit-spacing-responsive
164
+ repo: github.com/inuitcss/trumps.spacing-responsive
165
+ desc: ---
166
+ trumps.widths:
167
+ name: trumps.widths
168
+ slug: inuit-widths
169
+ repo: github.com/inuitcss/trumps.widths
170
+ desc: A series of helper classes for dealing with widths
171
+ trumps.widths-responsive:
172
+ name: trumps.widths-responsive
173
+ slug: inuit-widths-responsive
174
+ repo: github.com/inuitcss/trumps.widths-responsive
175
+ desc: ---
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'itcsscli/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "itcsscli"
8
+ spec.version = Itcsscli::VERSION
9
+ spec.authors = ["Kande Bonfim"]
10
+ spec.email = ["kandebonfim@gmail.com"]
11
+
12
+ spec.summary = %q{Manage you CSS with ITCSS from command line.}
13
+ spec.homepage = "https://github.com/kandebonfim/itcsscli"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "bin"
18
+ spec.executables = ["itcss"]
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.11"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+
24
+ spec.add_runtime_dependency "colorize", "~> 0.7.7"
25
+ end
@@ -0,0 +1,368 @@
1
+ require "itcsscli/version"
2
+ require "erb"
3
+ require 'fileutils'
4
+ require 'colorize'
5
+ require 'yaml'
6
+
7
+ module Itcsscli
8
+ class Core
9
+
10
+ def initialize
11
+ @ITCSS_CONFIG_FILE = 'itcss.yml'
12
+ @ITCSS_CONFIG_TEMPLATE = relative_file_path "../templates/itcss_config.erb"
13
+ @ITCSS_MODULE_TEMPLATE = relative_file_path "../templates/itcss_module.erb"
14
+ @ITCSS_APP_TEMPLATE = relative_file_path "../templates/itcss_application.erb"
15
+ @ITCSS_MODULES = ["requirements", "settings", "tools", "generic", "base", "objects", "components", "trumps"]
16
+ @ITCSS_FILES = {
17
+ "requirements" => "Vendor libraries",
18
+ "settings" => "Sass vars, etc.",
19
+ "tools" => "Functions and mixins.",
20
+ "generic" => "Generic, high-level styling, like resets, etc.",
21
+ "base" => "Unclasses HTML elements (e.g. `h2`, `ul`).",
22
+ "objects" => "Objects and abstractions.",
23
+ "components" => "Your designed UI elements (inuitcss includes none of these).",
24
+ "trumps" => "Overrides and helper classes."
25
+ }
26
+
27
+ @ITCSS_COMMANDS = ['init', 'install', 'new', 'n', 'inuit', 'update', 'u', 'help', 'h', '-h', 'version', 'v', '-v']
28
+
29
+ @ITCSS_COMMANDS_DESCRIPTION = [
30
+ " COMMAND ALIAS FUNCTION ",
31
+ "itcss init | | Initiates itcsscli configuration with a itcss.yml file. [start here]",
32
+ "itcss install [filenames] | | Creates an example of ITCSS structure in path specified in itcss.yml.",
33
+ "itcss new [module] [filename] | n | Creates a new ITCSS module and automatically import it into imports file.",
34
+ "itcss inuit new [inuit module] |inuit n| Add specified inuit module as an itcss dependency.",
35
+ "itcss inuit help |inuit h| Add specified inuit module as an itcss dependency.",
36
+ "itcss update | u | Updates the imports file using the files inside ITCSS structure.",
37
+ "itcss help | h, -h | Shows all available itcss commands and it's functions.",
38
+ "itcss version | v, -v | Shows itcsscli gem version installed."
39
+ ]
40
+
41
+ if File.exist?(@ITCSS_CONFIG_FILE)
42
+ @ITCSS_CONFIG = YAML.load_file(@ITCSS_CONFIG_FILE)
43
+ @ITCSS_DIR ||= @ITCSS_CONFIG['stylesheets_directory']
44
+ @ITCSS_BASE_FILE ||= @ITCSS_CONFIG['stylesheets_import_file']
45
+ else
46
+ @ITCSS_CONFIG = nil
47
+ end
48
+
49
+ if File.exist?(@ITCSS_CONFIG_FILE) && @ITCSS_CONFIG['package_manager']
50
+ @ITCSS_PACKAGE_MANAGER ||= @ITCSS_CONFIG['package_manager']
51
+ @INUIT_MODULES ||= @ITCSS_CONFIG['inuit_modules']
52
+ else
53
+ @ITCSS_PACKAGE_MANAGER = nil
54
+ end
55
+
56
+ @INUIT_AVAILABLE_MODULES_FILE = relative_file_path "../data/inuit_modules.yml"
57
+ @INUIT_AVAILABLE_MODULES = YAML.load_file(@INUIT_AVAILABLE_MODULES_FILE)
58
+ end
59
+
60
+ # ITCSS
61
+ def command_parser
62
+ # Not a valid command
63
+ unless @ITCSS_COMMANDS.include? ARGV[0]
64
+ not_a_valid_command
65
+ end
66
+
67
+ # $ itcss init
68
+ if 'init' == ARGV[0]
69
+ itcss_init
70
+
71
+
72
+ # $ itcss install example
73
+ elsif 'install' == ARGV[0]
74
+ itcss_init_checker
75
+ itcss_install(ARGV[1])
76
+
77
+
78
+ # $ itcss new||n [module] [filename]
79
+ elsif ['new', 'n'].include? ARGV[0]
80
+ if find_valid_module ARGV[1]
81
+ if ARGV[2]
82
+ itcss_init_checker
83
+ itcss_new_module(find_valid_module(ARGV[1]), ARGV[2])
84
+ else
85
+ not_a_valid_command
86
+ end
87
+ else
88
+ not_a_valid_command
89
+ end
90
+
91
+ # $ itcss inuit||i [module] [filename]
92
+ elsif 'inuit' == ARGV[0]
93
+ inuit_command_parser
94
+
95
+
96
+ # $ itcss help
97
+ elsif ['help', '-h', 'h'].include? ARGV[0]
98
+ itcss_help
99
+
100
+
101
+ # $ itcss version
102
+ elsif ['version', '-v', 'v'].include? ARGV[0]
103
+ itcss_version
104
+ end
105
+
106
+
107
+ # $ itcss update
108
+ if ['install', 'new', 'n', 'inuit', 'update', 'u'].include? ARGV[0]
109
+ itcss_init_checker
110
+ itcss_update_import_file
111
+ end
112
+ end
113
+
114
+ def itcss_init
115
+ if File.exist?(@ITCSS_CONFIG_FILE)
116
+ puts "There is already a itcss.yml created.".yellow
117
+ puts "Do you want to override it? [ y / n ]"
118
+ user_override_itcss_yml = STDIN.gets.chomp
119
+ unless user_override_itcss_yml == 'y'
120
+ abort
121
+ end
122
+ end
123
+
124
+ init_config = {}
125
+
126
+ puts "Well done! Let's configure your itcss.yml:".yellow
127
+
128
+ puts "Provide the root folder name where the ITCSS file structure should be built:"
129
+ user_itcss_dir = STDIN.gets.chomp
130
+ init_config['stylesheets_directory'] = user_itcss_dir
131
+
132
+ puts "What is the name of your base sass file (all ITCSS modules will be imported into it):"
133
+ user_itcss_base_file = STDIN.gets.chomp
134
+ init_config['stylesheets_import_file'] = user_itcss_base_file
135
+
136
+ puts "Are you using a package manager? [ y / n ]"
137
+ user_itcss_package_manager = STDIN.gets.chomp
138
+ if user_itcss_package_manager == 'y'
139
+ user_package_manager = true
140
+ end
141
+
142
+ if user_package_manager == true
143
+ puts "Choose your package manager [ bower / npm ]:"
144
+ user_package_manager = STDIN.gets.chomp
145
+
146
+ unless ['bower', 'npm'].include? user_package_manager
147
+ puts "#{user_package_manager} is not a valid package manager".red
148
+ abort
149
+ end
150
+
151
+ init_config['package_manager'] = user_package_manager
152
+ end
153
+
154
+ File.open @ITCSS_CONFIG_TEMPLATE do |io|
155
+ template = ERB.new io.read
156
+ content = init_config.to_yaml
157
+
158
+ File.open @ITCSS_CONFIG_FILE, "w+" do |out|
159
+ out.puts template.result binding
160
+ end
161
+ end
162
+ puts "#{@ITCSS_CONFIG_FILE} successfully created!".green
163
+ end
164
+
165
+ def itcss_install(filename)
166
+ File.open @ITCSS_MODULE_TEMPLATE do |io|
167
+ template = ERB.new io.read
168
+
169
+ @ITCSS_MODULES.each do |file|
170
+ itcss_new_file(file, filename, template)
171
+ end
172
+ end
173
+ end
174
+
175
+ def itcss_new_module(type, file)
176
+ File.open @ITCSS_MODULE_TEMPLATE do |io|
177
+ template = ERB.new io.read
178
+ itcss_new_file(type, file, template)
179
+ end
180
+ end
181
+
182
+ def itcss_new_file(type, file, template)
183
+ FileUtils.mkdir_p @ITCSS_DIR
184
+ FileUtils.mkdir_p "#{@ITCSS_DIR}/#{type}"
185
+ FileUtils.chmod "u=wrx,go=rx", @ITCSS_DIR
186
+
187
+ file_path = "#{@ITCSS_DIR}/#{type}/_#{type}.#{file}.sass"
188
+ unless File.exist?(file_path)
189
+ contents = "##{type}.#{file}"
190
+ File.open file_path, "w+" do |out|
191
+ out.puts template.result binding
192
+ end
193
+ puts "create #{file_path}".green
194
+ else
195
+ puts "#{file_path} is already created. Please delete it if you want it to be rewritten.".red
196
+ abort
197
+ end
198
+ end
199
+
200
+ def itcss_update_import_file
201
+ FileUtils.mkdir_p @ITCSS_DIR
202
+
203
+ itcss_files_to_import = {}
204
+ @ITCSS_MODULES.each do |current_module|
205
+ itcss_files_to_import[current_module] = []
206
+
207
+ if @INUIT_MODULES
208
+ itcss_files_to_import[current_module] += inuit_find_modules(current_module)
209
+ end
210
+
211
+ itcss_module_files = Dir[ File.join("#{@ITCSS_DIR}/#{current_module}/", '**', '*') ].reject { |p| File.directory? p }
212
+ itcss_files_to_import[current_module] += itcss_module_files.map{|s| s.gsub("#{@ITCSS_DIR}/", '')}
213
+ end
214
+
215
+ file_path = "#{@ITCSS_DIR}/#{@ITCSS_BASE_FILE}.sass"
216
+ contents = "#{@ITCSS_BASE_FILE}.sass"
217
+ File.open @ITCSS_APP_TEMPLATE do |io|
218
+ template = ERB.new io.read
219
+
220
+ File.open file_path, "w+" do |out|
221
+ out.puts template.result binding
222
+ end
223
+ end
224
+
225
+ puts "update #{file_path}".blue
226
+ end
227
+
228
+ def itcss_help
229
+ puts "itcsscli available commmands:".yellow
230
+ puts @ITCSS_COMMANDS_DESCRIPTION.map{|s| s.prepend(" ")}
231
+ end
232
+
233
+ def itcss_version
234
+ puts VERSION
235
+ end
236
+
237
+ # Helper Methods
238
+ def itcss_init_checker
239
+ if @ITCSS_CONFIG.nil?
240
+ puts "There's no #{@ITCSS_CONFIG_FILE} created yet. Run `itcss init` to create it.".red
241
+ abort
242
+ elsif @ITCSS_DIR.nil? || @ITCSS_BASE_FILE.nil?
243
+ puts "Something is wrong with your itcss.yml file. Please run `itcss init` again to override it.".red
244
+ abort
245
+ end
246
+ end
247
+
248
+ def relative_file_path(filename)
249
+ File.expand_path(File.join(File.dirname(__FILE__), filename))
250
+ end
251
+
252
+ def current_full_command
253
+ "`itcss #{ARGV.join(' ')}`"
254
+ end
255
+
256
+ def not_a_valid_command
257
+ puts "#{current_full_command} is not a valid command. Check out the available commands:".red
258
+ if 'inuit' == ARGV[0]
259
+ inuit_help
260
+ else
261
+ itcss_help
262
+ end
263
+ abort
264
+ end
265
+
266
+ def find_valid_module(arg)
267
+ occur = @ITCSS_MODULES.each_index.select{|i| @ITCSS_MODULES[i].include? arg}
268
+ if occur.size == 1
269
+ return @ITCSS_MODULES[occur[0]]
270
+ else
271
+ puts "'#{arg}' is not an ITCSS module. Try #{@ITCSS_MODULES.join(', ')}.".red
272
+ abort
273
+ end
274
+ end
275
+
276
+ # INUIT
277
+ def inuit_command_parser
278
+ if @ITCSS_PACKAGE_MANAGER.nil?
279
+ puts "You didn't choose a package manager. Please do it in itcss.yml".red
280
+ abort
281
+ end
282
+
283
+ # $ itcss inuit new [inuit module]
284
+ if ['new', 'n'].include? ARGV[1]
285
+ if ARGV[2] && inuit_find_valid_module(ARGV[2])
286
+ itcss_init_checker
287
+ inuit_module_name_frags = ARGV[2].split('.')
288
+ inuit_new_module(inuit_module_name_frags[0], inuit_module_name_frags[1], inuit_find_valid_module(ARGV[2]))
289
+ else
290
+ not_a_valid_command
291
+ end
292
+
293
+ # $ itcss inuit help
294
+ elsif ['help', 'h', '-h'].include? ARGV[1]
295
+ inuit_help
296
+ end
297
+ end
298
+
299
+ def inuit_new_module(c_module, file, module_object)
300
+ if file
301
+ current_module_name = inuit_module_fullname(c_module, file)
302
+ config_file = @ITCSS_CONFIG_FILE
303
+ current_config = YAML.load_file(config_file)
304
+
305
+ if current_config['inuit_modules'].nil?
306
+ current_config['inuit_modules'] = []
307
+ end
308
+
309
+ current_config['inuit_modules'] << current_module_name
310
+
311
+ unless current_config['inuit_modules'].uniq.length == current_config['inuit_modules'].length
312
+ puts "#{current_module_name} is already added to #{@ITCSS_CONFIG_FILE}.".yellow
313
+ abort
314
+ end
315
+
316
+ current_config['inuit_modules'].uniq!
317
+
318
+ File.open @ITCSS_CONFIG_TEMPLATE do |io|
319
+ template = ERB.new io.read
320
+ content = current_config.to_yaml
321
+
322
+ File.open @ITCSS_CONFIG_FILE, "w+" do |out|
323
+ out.puts template.result binding
324
+ end
325
+ end
326
+
327
+ puts "using #{@ITCSS_PACKAGE_MANAGER} to install inuit '#{current_module_name}' dependency...".green
328
+ sleep(2)
329
+ output = `#{@ITCSS_PACKAGE_MANAGER} install --save #{module_object['slug']}`
330
+ puts output
331
+
332
+ puts "update #{@ITCSS_CONFIG_FILE}. [added #{current_module_name}]".blue
333
+ end
334
+ end
335
+
336
+ def inuit_help
337
+ puts "itcss inuit available commmands:".yellow
338
+ puts " COMMAND | #{@ITCSS_PACKAGE_MANAGER.upcase} EQUIVALENT"
339
+ puts @INUIT_AVAILABLE_MODULES.map { |e| " itcss inuit new #{e[0]}"+" "*(26-e[0].size)+"| "+e[1]['slug'] }
340
+ puts "You can check all of these repositories at https://github.com/inuitcss/[inuit module].".yellow
341
+ abort
342
+ end
343
+
344
+ # Inuit Helper Methods
345
+ def inuit_find_modules(current_module)
346
+ current_config = YAML.load_file(@ITCSS_CONFIG_FILE)
347
+ current_inuit_modules = current_config["inuit_modules"].select{ |p| p.include? current_module }
348
+ current_inuit_modules.map{ |p| inuit_imports_path p }
349
+ end
350
+
351
+ def inuit_find_valid_module(c_module)
352
+ valid_module = @INUIT_AVAILABLE_MODULES[c_module]
353
+ unless valid_module.nil?
354
+ valid_module
355
+ end
356
+ end
357
+
358
+ def inuit_module_fullname(c_module, filename)
359
+ "#{c_module}.#{filename}"
360
+ end
361
+
362
+ def inuit_imports_path(filename)
363
+ frags = filename.split(".")
364
+ "inuit-#{frags[1]}/#{filename}"
365
+ end
366
+
367
+ end
368
+ end
@@ -0,0 +1,3 @@
1
+ module Itcsscli
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,14 @@
1
+ @charset "utf-8"
2
+
3
+ <%= "// " + "=" * 40 %>
4
+ <%= "// " + contents %>
5
+ <%= "// This file is automatically updated by itcsscli." %>
6
+ <%= "// " + "=" * 40 %>
7
+
8
+ <% @ITCSS_FILES.each_with_index do |value, index| %>
9
+ // [<%= index %>] <%= value[0].slice(0,1).capitalize + value[0].slice(1..-1) + " " + "-" * (15-value[0].length) + " " + value[1] %><% end %>
10
+
11
+ <% itcss_files_to_import.each_with_index do |value, index| if value[1].length > 0 %>
12
+ // [<%= index %>] <%= value[0].slice(0,1).capitalize + value[0].slice(1..-1) %>
13
+ <% value[1].each do |file_path| %>@import "<%= file_path %>"
14
+ <% end %><% end end %>
@@ -0,0 +1,5 @@
1
+ <%= "# " + "=" * 40 %>
2
+ <%= "# #itcss.yml" %>
3
+ <%= "# This file is automatically updated by itcsscli." %>
4
+ <%= "# " + "=" * 40 %>
5
+ <% unless content.nil? %><%= content %><% end %>
@@ -0,0 +1,3 @@
1
+ <%= "// " + "=" * 40 %>
2
+ <%= "// " + contents %>
3
+ <%= "// " + "=" * 40 %>
metadata ADDED
@@ -0,0 +1,103 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: itcsscli
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Kande Bonfim
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-04-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: colorize
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.7.7
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.7.7
55
+ description:
56
+ email:
57
+ - kandebonfim@gmail.com
58
+ executables:
59
+ - itcss
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".gitignore"
64
+ - CODE_OF_CONDUCT.md
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/itcss
71
+ - bin/setup
72
+ - data/inuit_modules.yml
73
+ - itcsscli.gemspec
74
+ - lib/itcsscli.rb
75
+ - lib/itcsscli/version.rb
76
+ - templates/itcss_application.erb
77
+ - templates/itcss_config.erb
78
+ - templates/itcss_module.erb
79
+ homepage: https://github.com/kandebonfim/itcsscli
80
+ licenses:
81
+ - MIT
82
+ metadata: {}
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.5.1
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: Manage you CSS with ITCSS from command line.
103
+ test_files: []