itcss_cli 0.1.13 → 0.1.14
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.
- checksums.yaml +4 -4
- data/bin/itcss +1 -1
- data/data/inuit_modules.yml +175 -0
- data/lib/itcss_cli/version.rb +1 -1
- data/lib/itcss_cli.rb +238 -91
- data/templates/itcss_application.erb +1 -1
- data/templates/itcss_config.erb +13 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f1fef50c237c9bcb8cf2e46cdfa18407e06350b
|
4
|
+
data.tar.gz: 4be3aded03c8d0679a02a555c0d5edddb7d61954
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93a8938b89b6a01db70803ffd2061c6e28ad6c661e77dbb7c1c17997133099d65799d49c144a70203f70f417ceeed564dca49f3fcbbd1e3edcd6bf986204929c
|
7
|
+
data.tar.gz: 146dde6939c1d8bb9a5194eefc1cafdbd8aa04630ea3c43b413a245d392b271070cccc161f063f5df8ec7e9d909fbdd106938b146126d5e62f350c48d45ab181
|
data/bin/itcss
CHANGED
@@ -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: ---
|
data/lib/itcss_cli/version.rb
CHANGED
data/lib/itcss_cli.rb
CHANGED
@@ -5,136 +5,152 @@ require 'colorize'
|
|
5
5
|
require 'yaml'
|
6
6
|
|
7
7
|
module ItcssCli
|
8
|
-
class
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
abort
|
47
|
-
elsif ITCSS_DIR.nil? || ITCSS_BASE_FILE.nil?
|
48
|
-
puts "Something is wrong with your itcss.yml file. Please delete it and run `itcss init` again.".red
|
49
|
-
abort
|
50
|
-
elsif ITCSS_DIR == 'TODO' || ITCSS_BASE_FILE == 'TODO'
|
51
|
-
puts "You haven't done the itcss_cli's configuration. You must provide your directories settings in itcss.yml.".yellow
|
52
|
-
abort
|
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 itcss_cli 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 update | u | Updates the imports file using the files inside ITCSS structure.",
|
36
|
+
"itcss help | h, -h | Shows all available itcss commands and it's functions.",
|
37
|
+
"itcss version | v, -v | Shows itcss_cli gem version installed."
|
38
|
+
]
|
39
|
+
|
40
|
+
if File.exist?(@ITCSS_CONFIG_FILE)
|
41
|
+
@ITCSS_CONFIG = YAML.load_file(@ITCSS_CONFIG_FILE)
|
42
|
+
@ITCSS_DIR ||= @ITCSS_CONFIG['stylesheets_directory']
|
43
|
+
@ITCSS_BASE_FILE ||= @ITCSS_CONFIG['stylesheets_import_file']
|
44
|
+
else
|
45
|
+
@ITCSS_CONFIG = nil
|
53
46
|
end
|
47
|
+
|
48
|
+
if File.exist?(@ITCSS_CONFIG_FILE) && @ITCSS_CONFIG['package_manager']
|
49
|
+
@ITCSS_PACKAGE_MANAGER ||= @ITCSS_CONFIG['package_manager']
|
50
|
+
@INUIT_MODULES ||= @ITCSS_CONFIG['inuit_modules']
|
51
|
+
else
|
52
|
+
@ITCSS_PACKAGE_MANAGER = nil
|
53
|
+
end
|
54
|
+
|
55
|
+
@INUIT_AVAILABLE_MODULES_FILE = relative_file_path "../data/inuit_modules.yml"
|
56
|
+
@INUIT_AVAILABLE_MODULES = YAML.load_file(@INUIT_AVAILABLE_MODULES_FILE)
|
54
57
|
end
|
55
58
|
|
59
|
+
# ITCSS
|
56
60
|
def command_parser
|
61
|
+
# Not a valid command
|
62
|
+
unless @ITCSS_COMMANDS.include? ARGV[0]
|
63
|
+
not_a_valid_command
|
64
|
+
end
|
65
|
+
|
57
66
|
# $ itcss init
|
58
|
-
if ARGV[0]
|
59
|
-
|
67
|
+
if 'init' == ARGV[0]
|
68
|
+
itcss_init
|
60
69
|
|
61
70
|
|
62
71
|
# $ itcss install example
|
63
|
-
elsif
|
64
|
-
|
65
|
-
|
66
|
-
|
72
|
+
elsif 'install' == ARGV[0]
|
73
|
+
itcss_init_checker
|
74
|
+
itcss_install(ARGV[1])
|
67
75
|
|
68
|
-
# $ itcss new components buttons
|
69
|
-
elsif ARGV[0] == 'new' && ARGV[1] && ARGV[2]
|
70
|
-
init_checker
|
71
76
|
|
72
|
-
|
73
|
-
|
74
|
-
|
77
|
+
# $ itcss new||n [module] [filename]
|
78
|
+
elsif ['new', 'n'].include? ARGV[0]
|
79
|
+
if find_valid_module ARGV[1]
|
80
|
+
if ARGV[2]
|
81
|
+
itcss_init_checker
|
82
|
+
itcss_new_module(find_valid_module(ARGV[1]), ARGV[2])
|
83
|
+
else
|
84
|
+
not_a_valid_command
|
85
|
+
end
|
75
86
|
else
|
76
|
-
|
77
|
-
abort
|
87
|
+
not_a_valid_command
|
78
88
|
end
|
79
89
|
|
90
|
+
# $ itcss inuit||i [module] [filename]
|
91
|
+
elsif 'inuit' == ARGV[0]
|
92
|
+
inuit_command_parser
|
93
|
+
|
80
94
|
|
81
95
|
# $ itcss help
|
82
|
-
elsif
|
96
|
+
elsif ['help', '-h', 'h'].include? ARGV[0]
|
83
97
|
itcss_help
|
84
98
|
|
85
99
|
|
86
100
|
# $ itcss version
|
87
|
-
elsif
|
101
|
+
elsif ['version', '-v', 'v'].include? ARGV[0]
|
88
102
|
itcss_version
|
89
103
|
end
|
90
104
|
|
105
|
+
|
91
106
|
# $ itcss update
|
92
|
-
if
|
93
|
-
|
94
|
-
|
107
|
+
if ['install', 'new', 'n', 'inuit', 'update', 'u'].include? ARGV[0]
|
108
|
+
itcss_init_checker
|
109
|
+
itcss_update_import_file
|
95
110
|
end
|
96
111
|
end
|
97
112
|
|
98
|
-
def
|
99
|
-
unless File.exist?(ITCSS_CONFIG_FILE)
|
100
|
-
File.open ITCSS_CONFIG_TEMPLATE do |io|
|
113
|
+
def itcss_init
|
114
|
+
unless File.exist?(@ITCSS_CONFIG_FILE)
|
115
|
+
File.open @ITCSS_CONFIG_TEMPLATE do |io|
|
101
116
|
template = ERB.new io.read
|
117
|
+
first_init = true
|
102
118
|
|
103
|
-
File.open ITCSS_CONFIG_FILE, "w+" do |out|
|
119
|
+
File.open @ITCSS_CONFIG_FILE, "w+" do |out|
|
104
120
|
out.puts template.result binding
|
105
121
|
end
|
106
122
|
end
|
107
|
-
puts "create #{ITCSS_CONFIG_FILE}".green
|
123
|
+
puts "create #{@ITCSS_CONFIG_FILE}".green
|
108
124
|
puts "Well done! Please do your own configurations in itcss.yml.".yellow
|
109
125
|
else
|
110
|
-
puts "#{ITCSS_CONFIG_FILE} already exists.".red
|
126
|
+
puts "#{@ITCSS_CONFIG_FILE} already exists.".red
|
111
127
|
abort
|
112
128
|
end
|
113
129
|
end
|
114
130
|
|
115
|
-
def
|
116
|
-
File.open ITCSS_MODULE_TEMPLATE do |io|
|
131
|
+
def itcss_install(filename)
|
132
|
+
File.open @ITCSS_MODULE_TEMPLATE do |io|
|
117
133
|
template = ERB.new io.read
|
118
134
|
|
119
|
-
ITCSS_MODULES.each do |file|
|
120
|
-
|
135
|
+
@ITCSS_MODULES.each do |file|
|
136
|
+
itcss_new_file(file, filename, template)
|
121
137
|
end
|
122
138
|
end
|
123
139
|
end
|
124
140
|
|
125
|
-
def
|
126
|
-
File.open ITCSS_MODULE_TEMPLATE do |io|
|
141
|
+
def itcss_new_module(type, file)
|
142
|
+
File.open @ITCSS_MODULE_TEMPLATE do |io|
|
127
143
|
template = ERB.new io.read
|
128
|
-
|
144
|
+
itcss_new_file(type, file, template)
|
129
145
|
end
|
130
146
|
end
|
131
147
|
|
132
|
-
def
|
133
|
-
FileUtils.mkdir_p ITCSS_DIR
|
134
|
-
FileUtils.mkdir_p "#{ITCSS_DIR}/#{type}"
|
135
|
-
FileUtils.chmod "u=wrx,go=rx", ITCSS_DIR
|
148
|
+
def itcss_new_file(type, file, template)
|
149
|
+
FileUtils.mkdir_p @ITCSS_DIR
|
150
|
+
FileUtils.mkdir_p "#{@ITCSS_DIR}/#{type}"
|
151
|
+
FileUtils.chmod "u=wrx,go=rx", @ITCSS_DIR
|
136
152
|
|
137
|
-
file_path = "#{ITCSS_DIR}/#{type}/_#{type}.#{file}.sass"
|
153
|
+
file_path = "#{@ITCSS_DIR}/#{type}/_#{type}.#{file}.sass"
|
138
154
|
unless File.exist?(file_path)
|
139
155
|
contents = "##{type}.#{file}"
|
140
156
|
File.open file_path, "w+" do |out|
|
@@ -147,18 +163,20 @@ module ItcssCli
|
|
147
163
|
end
|
148
164
|
end
|
149
165
|
|
150
|
-
def
|
151
|
-
FileUtils.mkdir_p ITCSS_DIR
|
166
|
+
def itcss_update_import_file
|
167
|
+
FileUtils.mkdir_p @ITCSS_DIR
|
152
168
|
|
153
169
|
itcss_files_to_import = {}
|
154
|
-
ITCSS_MODULES.each do |current_module|
|
155
|
-
|
156
|
-
|
170
|
+
@ITCSS_MODULES.each do |current_module|
|
171
|
+
itcss_files_to_import[current_module] = inuit_find_modules(current_module)
|
172
|
+
|
173
|
+
itcss_module_files = Dir[ File.join("#{@ITCSS_DIR}/#{current_module}/", '**', '*') ].reject { |p| File.directory? p }
|
174
|
+
itcss_files_to_import[current_module] += itcss_module_files.map{|s| s.gsub("#{@ITCSS_DIR}/", '')}
|
157
175
|
end
|
158
176
|
|
159
|
-
file_path = "#{ITCSS_DIR}/#{ITCSS_BASE_FILE}.sass"
|
160
|
-
contents = "#{ITCSS_BASE_FILE}.sass"
|
161
|
-
File.open ITCSS_APP_TEMPLATE do |io|
|
177
|
+
file_path = "#{@ITCSS_DIR}/#{@ITCSS_BASE_FILE}.sass"
|
178
|
+
contents = "#{@ITCSS_BASE_FILE}.sass"
|
179
|
+
File.open @ITCSS_APP_TEMPLATE do |io|
|
162
180
|
template = ERB.new io.read
|
163
181
|
|
164
182
|
File.open file_path, "w+" do |out|
|
@@ -171,12 +189,141 @@ module ItcssCli
|
|
171
189
|
|
172
190
|
def itcss_help
|
173
191
|
puts "itcss_cli available commmands:".yellow
|
174
|
-
puts
|
192
|
+
puts @ITCSS_COMMANDS_DESCRIPTION.map{|s| s.prepend(" ")}
|
175
193
|
end
|
176
194
|
|
177
195
|
def itcss_version
|
178
196
|
puts VERSION
|
179
197
|
end
|
180
198
|
|
199
|
+
# Helper Methods
|
200
|
+
def itcss_init_checker
|
201
|
+
if @ITCSS_CONFIG.nil?
|
202
|
+
puts "There's no #{@ITCSS_CONFIG_FILE} created yet. Run `itcss init` to create it.".red
|
203
|
+
abort
|
204
|
+
elsif @ITCSS_DIR.nil? || @ITCSS_BASE_FILE.nil?
|
205
|
+
puts "Something is wrong with your itcss.yml file. Please delete it and run `itcss init` again.".red
|
206
|
+
abort
|
207
|
+
elsif @ITCSS_DIR == 'path/to/itcss/root' || @ITCSS_BASE_FILE == 'yourapplication'
|
208
|
+
puts "You haven't done the itcss_cli's configuration. You must provide your directories settings in itcss.yml.".yellow
|
209
|
+
abort
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
def relative_file_path(filename)
|
214
|
+
File.expand_path(File.join(File.dirname(__FILE__), filename))
|
215
|
+
end
|
216
|
+
|
217
|
+
def current_full_command
|
218
|
+
"`itcss #{ARGV.join(' ')}`"
|
219
|
+
end
|
220
|
+
|
221
|
+
def not_a_valid_command
|
222
|
+
puts "#{current_full_command} is not a valid command. Check out the available commands:".red
|
223
|
+
if 'inuit' == ARGV[0]
|
224
|
+
inuit_help
|
225
|
+
else
|
226
|
+
itcss_help
|
227
|
+
end
|
228
|
+
abort
|
229
|
+
end
|
230
|
+
|
231
|
+
def find_valid_module(arg)
|
232
|
+
occur = @ITCSS_MODULES.each_index.select{|i| @ITCSS_MODULES[i].include? arg}
|
233
|
+
if occur.size == 1
|
234
|
+
return @ITCSS_MODULES[occur[0]]
|
235
|
+
else
|
236
|
+
puts "'#{arg}' is not an ITCSS module. Try #{@ITCSS_MODULES.join(', ')}.".red
|
237
|
+
abort
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
# INUIT
|
242
|
+
def inuit_command_parser
|
243
|
+
if @ITCSS_PACKAGE_MANAGER.nil?
|
244
|
+
puts "You didn't choose a package manager. Please do it in itcss.yml".red
|
245
|
+
abort
|
246
|
+
end
|
247
|
+
|
248
|
+
# $ itcss inuit new [inuit module]
|
249
|
+
if ['new', 'n'].include? ARGV[1]
|
250
|
+
if ARGV[2] && inuit_find_valid_module(ARGV[2])
|
251
|
+
itcss_init_checker
|
252
|
+
inuit_module_name_frags = ARGV[2].split('.')
|
253
|
+
inuit_new_module(inuit_module_name_frags[0], inuit_module_name_frags[1], inuit_find_valid_module(ARGV[2]))
|
254
|
+
else
|
255
|
+
not_a_valid_command
|
256
|
+
end
|
257
|
+
|
258
|
+
# $ itcss inuit help
|
259
|
+
elsif ['help', 'h', '-h'].include? ARGV[1]
|
260
|
+
inuit_help
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
def inuit_new_module(c_module, file, module_object)
|
265
|
+
if file
|
266
|
+
current_module_name = inuit_module_fullname(c_module, file)
|
267
|
+
config_file = @ITCSS_CONFIG_FILE
|
268
|
+
current_config = YAML.load_file(config_file)
|
269
|
+
current_config['inuit_modules'] << current_module_name
|
270
|
+
|
271
|
+
unless current_config['inuit_modules'].uniq.length == current_config['inuit_modules'].length
|
272
|
+
puts "#{current_module_name} is already added to #{@ITCSS_CONFIG_FILE}.".yellow
|
273
|
+
abort
|
274
|
+
end
|
275
|
+
|
276
|
+
current_config['inuit_modules'].uniq!
|
277
|
+
|
278
|
+
File.open @ITCSS_CONFIG_TEMPLATE do |io|
|
279
|
+
template = ERB.new io.read
|
280
|
+
content = current_config.to_yaml
|
281
|
+
first_init = nil
|
282
|
+
|
283
|
+
File.open @ITCSS_CONFIG_FILE, "w+" do |out|
|
284
|
+
out.puts template.result binding
|
285
|
+
end
|
286
|
+
end
|
287
|
+
|
288
|
+
puts "using #{@ITCSS_PACKAGE_MANAGER} to install inuit '#{current_module_name}' dependency...".green
|
289
|
+
sleep(2)
|
290
|
+
output = `#{@ITCSS_PACKAGE_MANAGER} install --save #{module_object['slug']}`
|
291
|
+
puts output
|
292
|
+
|
293
|
+
puts "update #{@ITCSS_CONFIG_FILE}. [added #{current_module_name}]".blue
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
297
|
+
def inuit_help
|
298
|
+
puts "itcss inuit available commmands:".yellow
|
299
|
+
puts " COMMAND | #{@ITCSS_PACKAGE_MANAGER.upcase} EQUIVALENT"
|
300
|
+
puts @INUIT_AVAILABLE_MODULES.map { |e| " itcss inuit new #{e[0]}"+" "*(26-e[0].size)+"| "+e[1]['slug'] }
|
301
|
+
puts "You can check all of these repositories at https://github.com/inuitcss/[inuit module].".yellow
|
302
|
+
abort
|
303
|
+
end
|
304
|
+
|
305
|
+
# Inuit Helper Methods
|
306
|
+
def inuit_find_modules(current_module)
|
307
|
+
current_config = YAML.load_file(@ITCSS_CONFIG_FILE)
|
308
|
+
current_inuit_modules = current_config["inuit_modules"].select{ |p| p.include? current_module }
|
309
|
+
current_inuit_modules.map{ |p| inuit_imports_path p }
|
310
|
+
end
|
311
|
+
|
312
|
+
def inuit_find_valid_module(c_module)
|
313
|
+
valid_module = @INUIT_AVAILABLE_MODULES[c_module]
|
314
|
+
unless valid_module.nil?
|
315
|
+
valid_module
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|
319
|
+
def inuit_module_fullname(c_module, filename)
|
320
|
+
"#{c_module}.#{filename}"
|
321
|
+
end
|
322
|
+
|
323
|
+
def inuit_imports_path(filename)
|
324
|
+
frags = filename.split(".")
|
325
|
+
"inuit-#{frags[1]}/#{filename}"
|
326
|
+
end
|
327
|
+
|
181
328
|
end
|
182
329
|
end
|
@@ -4,7 +4,7 @@
|
|
4
4
|
<%= "// " + contents %>
|
5
5
|
<%= "// " + "=" * 40 %>
|
6
6
|
|
7
|
-
<% ITCSS_FILES.each_with_index do |value, index| %>
|
7
|
+
<% @ITCSS_FILES.each_with_index do |value, index| %>
|
8
8
|
// [<%= index %>] <%= value[0].slice(0,1).capitalize + value[0].slice(1..-1) + " " + "-" * (15-value[0].length) + " " + value[1] %><% end %>
|
9
9
|
|
10
10
|
// ↓ ITCSS_CLI FILE IMPORTING ↓
|
data/templates/itcss_config.erb
CHANGED
@@ -2,8 +2,17 @@
|
|
2
2
|
<%= "# #itcss.yml" %>
|
3
3
|
<%= "# " + "=" * 40 %>
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
<%= content %>
|
6
|
+
<% unless first_init.nil? %># Root folder where the ITCSS file structure should be builded.
|
7
|
+
stylesheets_directory: path/to/itcss/root
|
7
8
|
|
8
|
-
#
|
9
|
-
stylesheets_import_file:
|
9
|
+
# Base sass file (all ITCSS modules will be imported in it).
|
10
|
+
stylesheets_import_file: yourapplication
|
11
|
+
|
12
|
+
# Uncomment to enable inuit modules importing. [ bower or npm ]
|
13
|
+
# package_manager: bower
|
14
|
+
|
15
|
+
# inuit_modules:
|
16
|
+
# - tools.functions
|
17
|
+
# - settings.defaults
|
18
|
+
# - base.page<% end %>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: itcss_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kande Bonfim
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- bin/console
|
70
70
|
- bin/itcss
|
71
71
|
- bin/setup
|
72
|
+
- data/inuit_modules.yml
|
72
73
|
- itcss_cli.gemspec
|
73
74
|
- lib/itcss_cli.rb
|
74
75
|
- lib/itcss_cli/version.rb
|