|
123 | 123 | config_repo = $stdin.gets.chomp |
124 | 124 | File.open(DEV_ENV_CONTEXT_FILE, 'w+') { |file| file.write(config_repo) } |
125 | 125 | end |
126 | | - |
| 126 | + |
| 127 | + config_repo = File.read(DEV_ENV_CONTEXT_FILE) |
127 | 128 | # Check if dev-env-config exists, and if so pull the dev-env configuration. Otherwise clone it. |
128 | 129 | if Dir.exist?(DEV_ENV_CONFIG_DIR) |
129 | 130 | new_project = false |
130 | | - command_successful = run_command("git -C #{root_loc}/dev-env-config pull") |
| 131 | + if config_repo == "local" |
| 132 | + command_successful = 0 |
| 133 | + else |
| 134 | + command_successful = run_command("git -C #{root_loc}/dev-env-config pull") |
| 135 | + end |
131 | 136 | else |
132 | 137 | new_project = true |
133 | | - config_repo = File.read(DEV_ENV_CONTEXT_FILE) |
134 | 138 | parsed_repo, delimiter, ref = config_repo.rpartition('#') |
135 | 139 | # If they didn't specify a #ref, rpartition returns "", "", wholestring |
136 | 140 | parsed_repo = ref if delimiter.empty? |
137 | | - command_successful = run_command("git clone #{parsed_repo} #{root_loc}/dev-env-config") |
138 | | - if command_successful.zero? && !delimiter.empty? |
139 | | - command_successful = run_command("git -C #{root_loc}/dev-env-config checkout #{ref}") |
| 141 | + if config_repo == "local" |
| 142 | + puts colorize_lightblue("Initializing local config repository.") |
| 143 | + run_command("mkdir #{DEV_ENV_CONFIG_DIR}") |
| 144 | + # Create a configuration.yml with an empty services array |
| 145 | + File.open("#{DEV_ENV_CONFIG_DIR}/configuration.yml", 'w') do |file| |
| 146 | + file.write("---\nservices: {}\n") |
| 147 | + end |
| 148 | + puts colorize_green("You can start adding apps to #{DEV_ENV_CONFIG_DIR}/configuration.yml") |
| 149 | + exit 1 |
| 150 | + else |
| 151 | + command_successful = run_command("git clone #{parsed_repo} #{DEV_ENV_CONFIG_DIR}") |
| 152 | + if command_successful.zero? && !delimiter.empty? |
| 153 | + command_successful = run_command("git -C #{DEV_ENV_CONFIG_DIR} checkout #{ref}") |
| 154 | + end |
140 | 155 | end |
141 | 156 | end |
142 | 157 |
|
|
0 commit comments