Welcome to mirror list, hosted at ThFree Co, Russian Federation.

frontend.rb « commands - gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 9c145deef723035eb982c237d8c902b96f60e167 (plain)
1
2
3
4
5
6
7
8
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
usage       'frontend [options]'
aliases     :ds, :stuff
summary     'uses nanoc cli to execute frontend related tasks'
description 'This command is used by the Nanoc CLI to bundle the JavaScript.'

flag   :h, :help, 'show help for this command' do |value, cmd|
  puts cmd.help
  exit 0
end
run do |opts, args, cmd|

  puts '--------------------------------'

  if check_requirements?
    puts 'Compiling JavaScript...'

    system('yarn install --frozen-lockfile')

    system('yarn bundle')
  end
end

def check_requirements?
  puts 'Checking requirements...'

  has_requirements = command_exists?('node') && command_exists?('yarn')

  unless has_requirements
    puts 'Your system may be missing some requirements.'
    puts 'Please refer to the installation instructions for more details:'
    puts 'https://gitlab.com/gitlab-org/gitlab-docs/blob/master/README.md'
  end
  has_requirements
end

def command_exists?(command)
  exists = system("which #{command} > /dev/null 2>&1")
  puts "🚨 #{command} is not installed!" unless exists
  exists
end