nixenvironment 0.0.57 → 0.0.58

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 17793840e6b6e3a03336761c63b7c46f29b67bbd
4
- data.tar.gz: 09e4429d88d903cfd89b63ae6e3c55ef25a8eeca
3
+ metadata.gz: 03341f8a783c1f14447c5048208f33bd9fcea7ed
4
+ data.tar.gz: 4e558688dacfc07a450e7656adb748df69e22e73
5
5
  SHA512:
6
- metadata.gz: d1889d5d0cf0779493217ae5547131a43cda3f932daf45dfdb23839d46e3a95b94450ef69efefe9fb2d53ea1685ee622718537aa701465aa0c2ce6a39434e36b
7
- data.tar.gz: 5687c1e693878fb6990973aec2a05f08a6334017eafcfb8c07a44df6f7f480bf2fb54e36672fc092e8db6de5ebc7dcc0cf01dacaa432177ac8b9a03dac16637b
6
+ metadata.gz: 16dea30f429879902ff63a05643b5508a515722822a39dae3ffe5e3168d4364c3b9eab5d12d7caa8b926383f16ef75bb59e163ae8c16467401b96972eed1f289
7
+ data.tar.gz: be683b4151a58d9a14820054e1f98564941d36ef1796a8191323a5731f67a7fa5e4e7e8d0e556497202f04632df2bc144c9cc97181cf00e2b1495151a52caa14
data/bin/nixenvironment CHANGED
@@ -54,6 +54,14 @@ global_option ('--resigned_entitlements_path VALUE') { |value| $resigned_entitle
54
54
  global_option ('--resigned_watchkit_extension_entitlements_path VALUE') { |value| $resigned_watchkit_extension_entitlements_path = value }
55
55
  global_option ('--resigned_widget_entitlements_path VALUE') { |value| $resigned_widget_entitlements_path = value }
56
56
 
57
+ command :init do |c|
58
+ c.syntax = 'nixenvironment init'
59
+ c.description = 'Initialize template project of selected type in the destination repository and clone it to current folder'
60
+ c.action do |args, options|
61
+ init
62
+ end
63
+ end
64
+
57
65
  command :update do |c|
58
66
  c.syntax = 'nixenvironment update'
59
67
  c.description = 'Install or update ninbas and other environment stuff'
@@ -200,6 +208,83 @@ command :clean_working_copy do |c|
200
208
  end
201
209
  end
202
210
 
211
+ def init
212
+ template_project_name = nil
213
+ template_project_url = nil
214
+ template_project_types = []
215
+
216
+ p('Select project type (put index or name):')
217
+ TEMPLATES_REPO_LIST.each_with_index do |(key, value), index|
218
+ selection_index = index + 1
219
+ selection = "#{selection_index}. #{key}"
220
+ template_project_types.push(selection)
221
+ p(selection)
222
+ end
223
+
224
+ loop do
225
+ type = ask('> ', template_project_types)
226
+ type_index = type.to_i - 1
227
+
228
+ if TEMPLATES_REPO_LIST.has_key?(type)
229
+ template_project_url = TEMPLATES_REPO_LIST[type]
230
+ break
231
+ elsif type_index >= 0 and type_index < TEMPLATES_REPO_LIST.length
232
+ template_project_url = TEMPLATES_REPO_LIST.values[type_index]
233
+ break
234
+ end
235
+ end
236
+
237
+ dest_url = ask('Destination repository url: ')
238
+ local_directory_to_clone = ask('Directory to clone into: ')
239
+
240
+ repo_name = File.basename(dest_url, '.git')
241
+ template_project_name = File.basename(template_project_url, '.git')
242
+
243
+ root_working_directory = Dir.pwd
244
+
245
+ begin
246
+ # TODO: do we need to rm_rf it every time?
247
+ FileUtils.rm_rf(ADJUSTER_WORKING_COPY_PATH)
248
+ Dir.mkdir(ADJUSTER_WORKING_COPY_PATH)
249
+ Dir.chdir(ADJUSTER_WORKING_COPY_PATH)
250
+
251
+ p('Cloning template project ...')
252
+ git_clone_success = system("git clone #{template_project_url} --recursive")
253
+ abort('Authentication failed for NIX template project! Please check your credentials and try again!') unless git_clone_success
254
+
255
+ Dir.chdir(template_project_name)
256
+ system('git fetch -t')
257
+ tags = %x[ git tag ].lines
258
+ abort('Failed to get last tag!') unless tags.length > 0
259
+
260
+ Dir.chdir('..')
261
+ FileUtils.rm_rf(ADJUSTER_TEMP_PROJECT_NAME) if Dir.exist?(ADJUSTER_TEMP_PROJECT_NAME)
262
+ FileUtils.cp_r(template_project_name, ADJUSTER_TEMP_PROJECT_NAME)
263
+ Dir.chdir(ADJUSTER_TEMP_PROJECT_NAME)
264
+
265
+ p('Checkout newest template project tag ...')
266
+ system("git checkout --orphan #{tags[-1]}")
267
+ current_branch = 'HEAD'
268
+
269
+ p("Push ... #{dest_url}")
270
+ system("git remote add #{repo_name}Remote #{dest_url}")
271
+ system("git commit -m 'Initial commit'")
272
+ git_push_success = system("git push #{repo_name}Remote #{current_branch}:refs/heads/master --force")
273
+ abort("Push failed for #{dest_url} repository! Please check the link and try again!") unless git_push_success
274
+
275
+ p("Cloning new created project from #{dest_url} to #{local_directory_to_clone} ...")
276
+ Dir.chdir(root_working_directory)
277
+ Dir.chdir(root_working_directory)
278
+ git_clone_success = system("git clone #{dest_url} --recursive #{local_directory_to_clone}")
279
+ abort("Error cloning #{dest_url}!") unless git_clone_success
280
+ rescue
281
+ p('Project initialization failed!')
282
+ raise
283
+ end
284
+
285
+ p('Project initialization complete!')
286
+ end
287
+
203
288
  def update(ninbas)
204
289
  root_working_directory = Dir.pwd
205
290
  target_directory = File.join(Dir.home, NIXENV_ROOT)
@@ -233,7 +318,7 @@ def update(ninbas)
233
318
  tags.sort_by!(&:to_i)
234
319
 
235
320
  if tags.size > 0
236
- p("Checkout newest #{repo_name} tag...")
321
+ p("Checkout newest #{repo_name} tag ...")
237
322
  system("git checkout #{tags.last}")
238
323
  else
239
324
  abort("Error checkout #{repo_name}! There is no tags!")
@@ -316,7 +401,7 @@ def working_copy_is_clean?
316
401
  source ${LAST_REVISION_FILE}
317
402
 
318
403
  if [ ${WORKING_COPY_IS_CLEAN} -eq 1 ]; then
319
- echo \"Working copy is clean. Continuing...\"
404
+ echo \"Working copy is clean. Continuing ...\"
320
405
  else
321
406
  echo \"error: working copy must not have local modifications.\" 1>&2
322
407
  echo \"You must add following files and folders to .gitignore:\"
@@ -566,7 +651,7 @@ def build(config, ipa, ndsym, icon_tagger)
566
651
  end
567
652
 
568
653
  if config == 'Release'
569
- p('IconTagger: configuration is Release. Skipping...')
654
+ p('IconTagger: configuration is Release. Skipping ...')
570
655
  else
571
656
  case icon_tagger
572
657
  when 'full'
@@ -574,9 +659,9 @@ def build(config, ipa, ndsym, icon_tagger)
574
659
  when 'short'
575
660
  tag_icon(true)
576
661
  when 'off'
577
- p('IconTagger is disabled. Skipping...')
662
+ p('IconTagger is disabled. Skipping ...')
578
663
  else
579
- p("Unknown IconTagger mode: '#{icon_tagger}'. Skipping...")
664
+ p("Unknown IconTagger mode: '#{icon_tagger}'. Skipping ...")
580
665
  end
581
666
  end
582
667
 
@@ -4,11 +4,20 @@ module Nixenvironment
4
4
 
5
5
  BUILD_SCRIPTS_PATH = File.join(Dir.home, NIXENV_ROOT, BUILD_SCRIPTS)
6
6
 
7
+ ADJUSTER_WORKING_COPY_PATH = '/tmp/NIXProjectAdjuster'
8
+ ADJUSTER_TEMP_PROJECT_NAME = 'newProj'
9
+
7
10
  UNITY_BUILDS_IOS_PATH = 'Builds/iOS'
8
11
 
9
12
  REPO_LIST = {
10
13
  BUILD_SCRIPTS => 'https://bitbucket.org/nixsolutions/ninbas.git',
11
- # 'nixipl' : 'https://bitbucket.org/nixsolutions/nixipl.git',
12
- # 'nocl' : 'https://bitbucket.org/nixsolutions/nocl.git'
14
+ # 'nixipl' => 'https://bitbucket.org/nixsolutions/nixipl.git',
15
+ # 'nocl' => 'https://bitbucket.org/nixsolutions/nocl.git'
16
+ }
17
+
18
+ TEMPLATES_REPO_LIST = {
19
+ 'objc' => 'https://bitbucket.org/nixsolutions/np.git',
20
+ 'swift' => 'https://bitbucket.org/nixsolutions/nps.git',
21
+ 'unity' => 'https://bitbucket.org/nixsolutions/nup.git'
13
22
  }
14
23
  end
@@ -1,3 +1,3 @@
1
1
  module Nixenvironment
2
- VERSION = '0.0.57'
2
+ VERSION = '0.0.58'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nixenvironment
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.57
4
+ version: 0.0.58
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-08-21 00:00:00.000000000 Z
12
+ date: 2015-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cocoapods