Class: Konstruct::Develop
- Inherits:
-
Object
- Object
- Konstruct::Develop
- Defined in:
- lib/cli/develop.rb
Instance Method Summary collapse
Instance Method Details
#build(strategy, path) ⇒ Object
-
BUILD +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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 88 89 90 91 92 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 |
# File 'lib/cli/develop.rb', line 60 def build(strategy, path) # 2.1. INITIALISE FUNCTIONS ---------------------------------------------- msg = Util::Message.new() fs = Util::FS.new() gulp = Util::Gulp.new() config = fs.read_project(path) type = config['type'] branch = config['branches'] # 2.1. END --------------------------------------------------------------- # 2.2. BUILD CONFIRMATION ------------------------------------------------ msg.paragraph("You are about to switch to your #{branch['staging']} branch to run gulp build tasks. Please make sure everything in your current branch is committed to avoid any conflicts and errors.") continue = choose("Are you ready to continue?", :yes, :no) if continue == :no exit 0 end # 2.2. END --------------------------------------------------------------- # 2.3. SET GULP STREAM --------------------------------------------------- if type == :html || type == :angular || type == :theme stream = "default" end if type == :jekyll stream = "jekyll" end # 2.3. END --------------------------------------------------------------- # 2.4. SWITCH REPOS ------------------------------------------------------ # 2.4.1. CHECKOUT STAGING if strategy == 'staging' msg.paragraph("Switching to: #{branch['staging']}") `git checkout #{branch['staging']}` msg.success("Switched branch") msg.paragraph("Pulling latest from: #{branch['staging']}") `git pull` msg.success("Pulled branch") msg.paragraph("Merging #{branch['dev']} into #{branch['staging']}...") `git merge #{branch['dev']}` msg.success("Merged #{branch['dev']} into #{branch['staging']}") elsif strategy == 'production' msg.paragraph("Switching to: #{branch['production']}") `git checkout #{branch['production']}` msg.success("Switched branch") msg.paragraph("Pulling latest from: #{branch['production']}") `git pull` msg.success("Pulled branch") msg.paragraph("Merging #{branch['staging']} into #{branch['production']}...") `git merge #{branch['staging']}` msg.success("Merged #{branch['staging']} into #{branch['production']}") else msg.error("You did not specify a valid build strategy") end # 2.4.1. END # 2.4. END --------------------------------------------------------------- # 2.3. GULP BUILD TASK --------------------------------------------------- msg.paragraph("Running build tasks") gulp.task('build', path, stream) msg.success("Build tasks completed") # 2.3. END --------------------------------------------------------------- # 2.2. GIT TASKS --------------------------------------------------------- # 2.2. END --------------------------------------------------------------- end |
#watch(path) ⇒ Object
-
WATCH +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
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 47 48 49 50 51 52 53 54 |
# File 'lib/cli/develop.rb', line 16 def watch(path) # 1.1. INITIALISE FUNCTIONS ---------------------------------------------- msg = Util::Message.new() fs = Util::FS.new() gulp = Util::Gulp.new() # 1.1. END --------------------------------------------------------------- # 1.2. RUN DEV TASK ------------------------------------------------------ site = fs.read_project(path) type = site['type'] if type == :html || type == :angular stream = "default" end if type == :theme stream = "silent" end if type == :jekyll stream = "jekyll" end gulp.task('default', path, stream) # 1.2. END --------------------------------------------------------------- end |