Class: Konstruct::Project
- Inherits:
-
Object
- Object
- Konstruct::Project
- Defined in:
- lib/cli/project.rb
Instance Method Summary collapse
-
#create(path) ⇒ Object
2.
-
#documentation ⇒ Object
4.
-
#folders(path) ⇒ Object
1.
-
#refresh(path) ⇒ Object
3.
Instance Method Details
#create(path) ⇒ Object
-
CREATE ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/cli/project.rb', line 93 def create(path) # 2.1. INIT FUNCTIONS ---------------------------------------------------- msg = Util::Message.new() fs = Util::FS.new() git = Util::Git.new() config = fs.read_config recipe = config["recipes"] repo = config["repo"] assets = config["paths"] # 2.1. END --------------------------------------------------------------- # 2.2. HEADING ----------------------------------------------------------- msg.heading("CREATE NEW KONSTRUCT PROJECT") # 2.2. END --------------------------------------------------------------- # 2.3. IS YOUR DIRECTORY EMPTY? ------------------------------------------ fs.clear_directory(path) # 2.3. END --------------------------------------------------------------- # 2.4. INSTALL BOILERPLATE ----------------------------------------------- type = choose("What are you building?", :html, :theme, :jekyll, :angular) if type == :html recipe["html"].each do |key, val| git.install("#{path}#{val[0]}", "#{repo}#{val[1]}", val[2], val[3]) msg.success("Installed #{ key }"); end end if type == :theme recipe["html"].each do |key, val| git.install("#{path}#{val[0]}", "#{repo}#{val[1]}", val[2], val[3]) msg.success("Installed #{ key }"); end end if type == :jekyll recipe["jekyll"].each do |key, val| git.install("#{path}#{val[0]}", "#{repo}#{val[1]}", val[2], val[3]) msg.success("Installed #{ key }"); end end if type == :angular recipe["angular"].each do |key, val| git.install("#{path}#{val[0]}", "#{repo}#{val[1]}", val[2], val[3]) msg.success("Installed #{ key }"); end end # 2.4. END --------------------------------------------------------------- # 2.7. INSTALL NPM ASSETS ------------------------------------------------ msg.paragraph("Installing NPM Assets. This might take a while.") FileUtils.cd("#{path}/assets") do `npm install` end msg.success("Installed NPM Assets") # 2.7. END --------------------------------------------------------------- # 2.8. SET UP NEW GIT REPOSITORY ----------------------------------------- unless type == :theme want_git = choose("Want to initialise a git repository?", :Yes, :No) if want_git == :Yes git.init(path) has_remote = choose("Do you already have a remote git repository?", :Yes, :No) if has_remote == :Yes remote_url = ask("Remote Url:") git.remote(path, remote_url) git.add(path) msg.success("Initialised your git repo") end end end # 2.8. END --------------------------------------------------------------- # 2.9. INSTALL .konstruct ------------------------------------------------ date = Time.new date_installed = "#{ date.year }-#{ date.month }-#{ date.day }" file_data = { "konstruct_version" => Konstruct::VERSION, "date_installed" => date_installed, "type" => type, "branches" => config["branches"], "deploy" => config["deploy"], "deployments" => config["deployments"], "exclude" => config["exclude"] } File.open("#{path}/.konstruct.yml","w") do |f| f.write(file_data.to_yaml) end msg.success("Created #{path}/.konstruct.yml") # 2.9. END --------------------------------------------------------------- # 2.5. SEND BUILD DATA TO ANALYTICS -------------------------------------- # TODO # 2.5. END --------------------------------------------------------------- # 2.6. THANKS FOR INSTALLING --------------------------------------------- puts "" puts "" puts Paint[' $III7IIIIIIIIIIIIIIIIIIIIIIIIII: ', "#de544b"] puts Paint[' ZZZZZZ$7IIIIIIIIIIIIIIIIIIIIIIII ', "#de544b"] puts Paint[' ZZZZZZZZZZZZ$7IIIIIIIIIIIIIIIIII ', "#de544b"] puts Paint[' ZZZZZZZZZZZZZZZZZZZ$IIIIIIIIIIII~', "#de544b"] puts Paint[' ZZZZZZZZZZZZZZZZZZZZZZZ:,:+IIIIII', "#de544b"] puts Paint[' ZZZZZZZZZZZZZZZZZZZZZZ. :?', "#de544b"] puts Paint[' I$ZZZZZZZZZZZZZZZZZZ7 ', "#de544b"] puts Paint[' III$ZZZZZZZZZZZZZZZ~ ', "#de544b"] puts Paint[' IIIII7ZZZZZZZZZZZZ ', "#de544b"] puts Paint[' IIIIIII7ZZZZZZZZ$ ', "#de544b"] puts Paint[' IIIIIIIIIIZZZZZ: ', "#de544b"] puts Paint[' IIIIIIIIIIIIZI ', "#de544b"] puts Paint[' IIIIIIIIIIIIII ', "#de544b"] puts Paint[' IIIIIIIIIIIIIIII= ', "#de544b"] puts Paint[' IIIIIIIIIIIIIIIII7= ', "#de544b"] puts Paint[' IIIIIIIIIIIIIIIIIIII~ ', "#de544b"] puts Paint[' IIIIIIIIIIIIIIIIIIIIII= ', "#de544b"] puts Paint[' IIIIIIIIIIIIIIIIIIIIIII7~ ', "#de544b"] puts Paint[' IIIIIIIIIIIIIIIIIIIIIIIIIII.. ', "#de544b"] puts Paint[' IIIIIIIIIIIIIIIIIIIIIIIIIIII7 ', "#de544b"] puts Paint[' IIIIIIIIIIIIIIIIIIIIIIIIIIIIIII,.', "#de544b"] puts Paint[' IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII7', "#de544b"] puts "" puts "" puts Paint[" GO BUILD SOMETHING AWESOME!", "#999999"] puts "" puts Paint[" Successfully installed your #{type} site.", "#999999"] puts "" puts Paint[" You can run the developer tools with '$ konstruct watch' or '$ konstruct documentation' to get help.", "#999999"] puts "" exit(0) # 2.6. END --------------------------------------------------------------- end |
#documentation ⇒ Object
-
DOCUMENTATION +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/cli/project.rb', line 301 def documentation # 4.1. INITIALISE FUNCTIONS ---------------------------------------------- msg = Util::Message.new() # 4.1. END --------------------------------------------------------------- # 4.2. OPEN DOCUMENTATION ------------------------------------------------ msg.paragraph("Opening documentation in your default browser!") Launchy.open( "http://konstruct.github.io/" ) exit(0) # 4.2. END --------------------------------------------------------------- end |
#folders(path) ⇒ Object
-
FOLDERS +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/cli/project.rb', line 18 def folders(path) # 1.1. INIT FUNCTIONS ---------------------------------------------------- msg = Util::Message.new() fs = Util::FS.new() # 1.1. END --------------------------------------------------------------- # 1.2. HEADING ----------------------------------------------------------- msg.heading("CREATING PROJECT FOLDER STRUCTURE") # 1.2. END --------------------------------------------------------------- # 1.3. EMPTY DIRECTORY --------------------------------------------------- puts fs.clear_directory(path) # 1.3. END --------------------------------------------------------------- # 1.4. SET FOLDER STRUCTURE ---------------------------------------------- config_dir = File.('~/.konstruct') hash = YAML.load_file("#{config_dir}/config.yml") structure = hash["folders"] # 1.4. END --------------------------------------------------------------- # 1.5. CONFIRM FOLDER STRUCTURE ------------------------------------------ puts Paint["Folders location:", "999999"] puts Paint["-- #{ path }", "999999"] puts "" puts Paint["Folder structure:", "999999"] structure.each { |f| puts Paint["-- #{ f }", "999999"] } puts "" choice = choose("Do you want to install the structure above?", :yes, :no) # 1.5. END --------------------------------------------------------------- # 1.6. BUILD FOLDERS ----------------------------------------------------- if choice == :yes structure.each { |f| Dir.mkdir "#{ path }/#{ f }" } msg.success('Installed Folders') exit(0) else exit(0) end # 1.6. END --------------------------------------------------------------- end |
#refresh(path) ⇒ Object
-
END +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 |
# File 'lib/cli/project.rb', line 281 def refresh(path) # 3.1. INSTALL NPM ASSETS ------------------------------------------------ msg.paragraph("Refreshing NPM Assets. This might take a while.") FileUtils.cd("#{path}/assets") do `npm install` end msg.success("Refreshed NPM Assets") # 3.1. END --------------------------------------------------------------- end |