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: 48ece62f04ee2d2361b1d912802174bd34a0e058 (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
41
42
43
44
45
# frozen_string_literal: true

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 JavaScript.'

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

  unless system('yarn install --frozen-lockfile')
    abort <<~ERROR
      Error: failed to run yarn. JavaScript compilation failed. For more information, see:
      https://gitlab.com/gitlab-org/gitlab-docs/blob/main/README.md

    ERROR
  end

  unless system('yarn bundle')
    abort <<~ERROR
      Error: failed to run yarn. JavaScript compilation failed. For more information, see:
      https://gitlab.com/gitlab-org/gitlab-docs/blob/main/README.md

    ERROR
  end

  puts 'Copying GitLab UI CSS sourcemaps...'
  root = File.expand_path('../', __dir__)
  gl_ui_src = 'node_modules/@gitlab/ui/dist'
  gl_ui_dest = 'public/frontend/shared'

  Dir.children(gl_ui_src).each do |filename|
    puts "- Copied #{gl_ui_src}/#{filename}" if filename.include?("map") && File.write("#{gl_ui_dest}/#{filename}", File.read("#{root}/#{gl_ui_src}/#{filename}"))
  end

  if ENV['ALGOLIA_SEARCH'] == "false"
    lunr_src = "node_modules/lunr/lunr.min.js"
    puts 'Copying Lunr.js...'
    puts "- Copied #{lunr_src}" if File.write('public/assets/javascripts/lunr.min.js', File.read("#{root}/#{lunr_src}"))
  end
end