j1-template 2022.0.16 → 2022.0.17

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
  SHA256:
3
- metadata.gz: 6747e12e42b4cbc106beb6bbef14dbc74b7e43c050d88371bcbd814d62bf76e0
4
- data.tar.gz: e4d94adc0891fc86bc5f53f702534aeb74caeca9ebf1f51d101271317b244278
3
+ metadata.gz: 800dc492d73c0a3fa1b6a4a65efad8cd448b1e2cbc304a112e0941be09e6a8ec
4
+ data.tar.gz: '07801fe24243e2721c57152f94ee02adac6e2f84e82d20ecf32664fc19d64ed3'
5
5
  SHA512:
6
- metadata.gz: 2743934801254b32fcba41d44183c5f94580f5bcf5460cc816277359fdf81127c1b47e95600b2856e8152e9db0e3c862e9d0cecffa2a7db06b9350467a0db8cc
7
- data.tar.gz: 752db1543f50ca13e4b1ce9477796b588bf1bb8447ba0e8fb47f0bf1ffba1daa4f39b40536ababd655d7cc4cf529fd615ebbb89931614bcabc4913c03d74fd2c
6
+ metadata.gz: 7f3aa7bbbc45b6121e548b7b745c30512c313b2b80b0fd79caf73eac0943ae39f30992f0aa1d0393ca811a543bc2b4e9e7b1717c58cb071106c45f55c1989526
7
+ data.tar.gz: 3c5e808cea092e42249bb03494a2a8c0366e322e4f3622052ac565b1fe4a400e14402edfb12769afb21c3afd2fc4093931069fc74e48d8d191933d80195aab50
@@ -58,10 +58,6 @@ module J1
58
58
 
59
59
  private
60
60
 
61
- def is_windows?
62
- RbConfig::CONFIG["host_os"] =~ %r!mswin|mingw|cygwin!i
63
- end
64
-
65
61
  def create_site(new_blog_path)
66
62
  create_sample_files new_blog_path
67
63
 
@@ -115,18 +111,16 @@ module J1
115
111
  J1.logger.info "GENERATE: Install bundle in Ruby gem SYSTEM folder ..."
116
112
  else
117
113
  J1.logger.info "GENERATE: Install bundle in USER gem folder ~/.gem ..."
118
- process, output = J1::Utils::Exec.run('bundle', 'config', 'set', '--local', 'path', '~/.gem')
119
- end
120
- process, output = J1::Utils::Exec.run('bundle', 'install')
121
- output.to_s.each_line do |line|
122
- J1.logger.info('BUNDLE:', line.strip) unless line.to_s.empty?
114
+ process = J1::Utils::Exec2.run('GENERATE','bundle', 'config', 'set', '--local', 'path', '~/.gem')
115
+ raise SystemExit unless process.success?
123
116
  end
117
+ process = J1::Utils::Exec2.run( 'GENERATE', 'bundle', 'install')
124
118
  raise SystemExit unless process.success?
125
119
  end
126
120
  end
127
121
 
128
122
  def patch_install(options)
129
- if is_windows?
123
+ if J1::Utils::is_windows?
130
124
  major, minor = RUBY_VERSION.split('.')
131
125
  lib_version = major + '.' + minor
132
126
  curr_path = File.expand_path(File.dirname(File.dirname(__FILE__)))
@@ -135,7 +129,7 @@ module J1
135
129
  patch_eventmachine_source_path = curr_path + '/patches/rubygems' + '/' + patch_gem_eventmachine + '/lib/' + lib_version
136
130
  patch_execjs_source_path = curr_path + '/patches/rubygems' + '/' + patch_gem_execjs + '/lib/execjs/external_runtime.rb'
137
131
 
138
- process, output = J1::Utils::Exec.run('gem', 'env', 'gempath')
132
+ process, output = J1::Utils::Exec1.run('gem', 'env', 'gempath')
139
133
  raise SystemExit unless process.success?
140
134
 
141
135
  result = output.split(';')
@@ -1,35 +1,35 @@
1
- # frozen_string_literal: true
2
-
3
- module J1
4
- module Commands
5
- class Help < Command
6
- class << self
7
-
8
- def init_with_program(prog)
9
- prog.command(:help) do |c|
10
- c.syntax "help [subcommand]"
11
- c.description "Show the help message, optionally for a given subcommand"
12
-
13
- c.action do |args, _|
14
- cmd = (args.first || "").to_sym
15
- if args.empty?
16
- J1.logger.info prog.to_s
17
- elsif prog.has_command? cmd
18
- J1.logger.info prog.commands[cmd].to_s
19
- else
20
- invalid_command(prog, cmd)
21
- abort
22
- end
23
- end
24
- end
25
- end
26
-
27
- def invalid_command(prog, cmd)
28
- J1.logger.error "Error:",
29
- "Hmm... we don't know what the '#{cmd}' command is."
30
- J1.logger.info "Valid commands:", prog.commands.keys.join(", ")
31
- end
32
- end
33
- end
34
- end
35
- end
1
+ # frozen_string_literal: true
2
+
3
+ module J1
4
+ module Commands
5
+ class Help < Command
6
+ class << self
7
+
8
+ def init_with_program(prog)
9
+ prog.command(:help) do |c|
10
+ c.syntax "help [subcommand]"
11
+ c.description "Show the help message, optionally for a given subcommand"
12
+
13
+ c.action do |args, _|
14
+ cmd = (args.first || "").to_sym
15
+ if args.empty?
16
+ J1.logger.info prog.to_s
17
+ elsif prog.has_command? cmd
18
+ J1.logger.info prog.commands[cmd].to_s
19
+ else
20
+ invalid_command(prog, cmd)
21
+ abort
22
+ end
23
+ end
24
+ end
25
+ end
26
+
27
+ def invalid_command(prog, cmd)
28
+ J1.logger.error "Error:",
29
+ "Hmm... we don't know what the '#{cmd}' command is."
30
+ J1.logger.info "Valid commands:", prog.commands.keys.join(", ")
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -19,19 +19,14 @@ module J1
19
19
  end
20
20
 
21
21
  def process(args, options = {})
22
- patch_install(options)
23
22
  @args = args
23
+ patch_install(options)
24
24
  end
25
25
 
26
26
  private
27
27
 
28
- def is_windows?
29
- #noinspection RubyResolve
30
- RbConfig::CONFIG["host_os"] =~ %r!mswin|mingw|cygwin!i
31
- end
32
-
33
28
  def patch_install(options)
34
- if is_windows?
29
+ if J1::Utils::is_windows?
35
30
  major, minor = RUBY_VERSION.split('.')
36
31
  lib_version = major + '.' + minor
37
32
  curr_path = File.expand_path(File.dirname(File.dirname(__FILE__)))
@@ -40,7 +35,7 @@ module J1
40
35
  patch_eventmachine_source_path = curr_path + '/patches/rubygems' + '/' + patch_gem_eventmachine + '/lib/' + lib_version
41
36
  patch_execjs_source_path = curr_path + '/patches/rubygems' + '/' + patch_gem_execjs + '/lib/execjs/external_runtime.rb'
42
37
 
43
- process, output = J1::Utils::Exec.run('gem', 'env', 'gempath')
38
+ process, output = J1::Utils::Exec1.run('gem', 'env', 'gempath')
44
39
  raise SystemExit unless process.success?
45
40
 
46
41
  result = output.split(';')
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module J1
4
+ module Commands
5
+ class Rebuild < Command
6
+ #noinspection MissingYardParamTag
7
+ class << self
8
+
9
+ def init_with_program(prog)
10
+ prog.command(:rebuild) do |c|
11
+ c.description 'Rebuild the J1 projects website'
12
+ c.syntax 'rebuild'
13
+ c.action do |args, options|
14
+ J1::Commands::Rebuild.process(args, options)
15
+ end
16
+ end
17
+ end
18
+
19
+ def process(args, options = {})
20
+ if J1::Utils::is_project?
21
+ if J1::Utils::is_project_setup?
22
+ J1.logger.info "REBUILD: Rebuild the projects website ..."
23
+ J1.logger.info "REBUILD: Be patient, this will take a while ..."
24
+ process = J1::Utils::Exec2.run('REBUILD','npm', 'run', 'rebuild')
25
+ if process.success?
26
+ J1.logger.info "REBUILD: The projects website has been rebuild successfully."
27
+ else
28
+ raise SystemExit
29
+ end
30
+ else
31
+ raise SystemExit
32
+ end
33
+ else
34
+ raise SystemExit
35
+ end
36
+ end
37
+
38
+ end
39
+ end
40
+ end
41
+ end
@@ -17,14 +17,19 @@ module J1
17
17
  end
18
18
 
19
19
  def process(args, options = {})
20
- J1.logger.info "RESET: Reset the project to factory state ..."
21
- J1.logger.info "RESET: Be patient, this will take a while ..."
22
- process, output = J1::Utils::Exec.run('npm', 'run', 'reset')
23
- output.to_s.each_line do |line|
24
- J1.logger.info('RESET:', line.strip) unless line.to_s.empty?
25
- end
26
- if process.success?
27
- J1.logger.info "RESET: The project reset finished successfully."
20
+ if J1::Utils::is_project?
21
+ if J1::Utils::is_project_setup?
22
+ J1.logger.info "RESET: Reset the project to factory state ..."
23
+ J1.logger.info "RESET: Be patient, this will take a while ..."
24
+ process = J1::Utils::Exec2.run('RESET','npm', 'run', 'reset')
25
+ if process.success?
26
+ J1.logger.info "RESET: The project reset finished successfully."
27
+ else
28
+ raise SystemExit
29
+ end
30
+ else
31
+ raise SystemExit
32
+ end
28
33
  else
29
34
  raise SystemExit
30
35
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # require "futils"
2
3
 
3
4
  module J1
4
5
  module Commands
@@ -22,7 +23,8 @@ module J1
22
23
  def process(args, options = {})
23
24
  @args = args
24
25
  path = File.expand_path(Dir.getwd)
25
- if is_project?
26
+
27
+ if J1::Utils::is_project?
26
28
  bundle_install(path, options)
27
29
  if options['skip-patches']
28
30
  J1.logger.info "SETUP: Install build-in patches skipped ..."
@@ -31,52 +33,42 @@ module J1
31
33
  end
32
34
  J1.logger.info "SETUP: Initialize the project ..."
33
35
  J1.logger.info "SETUP: Be patient, this will take a while ..."
34
- process, output = J1::Utils::Exec.run('npm', 'run', 'setup')
35
- output.to_s.each_line do |line|
36
- J1.logger.info('SETUP:', line.strip) unless line.to_s.empty?
37
- end
36
+ # process, output = J1::Utils::Exec.run('npm', 'run', 'setup')
37
+ # output.to_s.each_line do |line|
38
+ # J1.logger.info('SETUP:', line.strip) unless line.to_s.empty?
39
+ # end
40
+ process = J1::Utils::Exec2.run('SETUP','npm', 'run', 'setup')
38
41
  if process.success?
39
42
  J1.logger.info "SETUP: Initializing the project finished successfully."
40
43
  J1.logger.info "SETUP: To open your site, run: j1 site"
41
44
  else
42
45
  raise SystemExit
43
- end
46
+ end
47
+ else
48
+ raise SystemExit
44
49
  end
45
50
  end
46
51
 
47
52
  private
48
53
 
49
- def is_project?
50
- path = File.expand_path(File.dirname(File.dirname(__FILE__)))
51
- J1.logger.info "Check consistency of the project ..."
52
- return true
53
- end
54
-
55
- def is_windows?
56
- #noinspection RubyResolve
57
- RbConfig::CONFIG["host_os"] =~ %r!mswin|mingw|cygwin!i
58
- end
59
-
60
54
  def bundle_install(path, options)
61
55
  J1::External.require_with_graceful_fail 'bundler'
62
- J1.logger.info "Running bundle install in #{path} ..."
56
+ J1.logger.info "SETUP: Running bundle install in #{path} ..."
63
57
  Dir.chdir(path) do
64
58
  if options['system']
65
- J1.logger.info "Install bundle in Ruby gem SYSTEM folder ..."
59
+ J1.logger.info "SETUP: Install bundle in Ruby gem SYSTEM folder ..."
66
60
  else
67
- J1.logger.info "Install bundle in USER gem folder ~/.gem ..."
68
- process, output = J1::Utils::Exec.run('bundle', 'config', 'set', '--local', 'path', '~/.gem')
69
- end
70
- process, output = J1::Utils::Exec.run('bundle', 'install')
71
- output.to_s.each_line do |line|
72
- J1.logger.info('Bundler:', line.strip) unless line.to_s.empty?
61
+ J1.logger.info "SETUP: Install bundle in USER gem folder ~/.gem ..."
62
+ process = J1::Utils::Exec2.run('SETUP','bundle', 'config', 'set', '--local', 'path', '~/.gem')
63
+ raise SystemExit unless process.success?
73
64
  end
65
+ process = J1::Utils::Exec2.run('SETUP','bundle', 'install')
74
66
  raise SystemExit unless process.success?
75
67
  end
76
68
  end
77
69
 
78
70
  def patch_install(options)
79
- if is_windows?
71
+ if J1::Utils::is_windows?
80
72
  major, minor = RUBY_VERSION.split('.')
81
73
  lib_version = major + '.' + minor
82
74
  curr_path = File.expand_path(File.dirname(File.dirname(__FILE__)))
@@ -85,7 +77,7 @@ module J1
85
77
  patch_eventmachine_source_path = curr_path + '/patches/rubygems' + '/' + patch_gem_eventmachine + '/lib/' + lib_version
86
78
  patch_execjs_source_path = curr_path + '/patches/rubygems' + '/' + patch_gem_execjs + '/lib/execjs/external_runtime.rb'
87
79
 
88
- process, output = J1::Utils::Exec.run('gem', 'env', 'gempath')
80
+ process, output = J1::Utils::Exec1.run('gem', 'env', 'gempath')
89
81
  raise SystemExit unless process.success?
90
82
 
91
83
  result = output.split(';')
@@ -93,12 +85,12 @@ module J1
93
85
  system_path = result[1]
94
86
 
95
87
  if options['system']
96
- J1.logger.info "Install patches in SYSTEM folder ..."
97
- J1.logger.info "Install patches on path #{system_path} ..."
88
+ J1.logger.info "SETUP: Install patches in SYSTEM folder ..."
89
+ J1.logger.info "SETUP: Install patches on path #{system_path} ..."
98
90
  dest = system_path + '/gems/' + patch_gem_eventmachine + '/lib'
99
91
  else
100
- J1.logger.info "Install patches in USER gem folder ~/.gem ..."
101
- J1.logger.info "Install patches on path #{user_path} ..."
92
+ J1.logger.info "SETUP: Install patches in USER gem folder ~/.gem ..."
93
+ J1.logger.info "SETUP: Install patches on path #{user_path} ..."
102
94
  dest = user_path + '/gems/' + patch_gem_eventmachine + '/lib'
103
95
  end
104
96
  src = patch_eventmachine_source_path
@@ -114,7 +106,7 @@ module J1
114
106
  if Dir.exist?(dest)
115
107
  FileUtils.cp(src, dest)
116
108
  else
117
- J1.logger.info "Skipped install patches for execjs-2.7.0 ..."
109
+ J1.logger.info "SETUP: Skipped install patches for execjs-2.7.0 ..."
118
110
  end
119
111
  end
120
112
 
@@ -17,8 +17,16 @@ module J1
17
17
  end
18
18
 
19
19
  def process(args, options = {})
20
- J1.logger.info "SITE: Starting up your site ..."
21
- J1::Utils::ExecUntilTrap.run('SITE','npm', 'run', 'j1-site')
20
+ if J1::Utils::is_project?
21
+ if J1::Utils::is_project_setup?
22
+ J1.logger.info "SITE: Starting up your site ..."
23
+ process = J1::Utils::Exec2.run('SITE','npm', 'run', 'j1-site')
24
+ else
25
+ raise SystemExit
26
+ end
27
+ else
28
+ raise SystemExit
29
+ end
22
30
  end
23
31
 
24
32
  end
@@ -2,7 +2,7 @@ require "open3"
2
2
 
3
3
  module J1
4
4
  module Utils
5
- module Exec
5
+ module Exec1
6
6
  extend self
7
7
 
8
8
  # Runs a program in a sub-shell.
@@ -2,16 +2,18 @@ require "open3"
2
2
 
3
3
  module J1
4
4
  module Utils
5
- module ExecUntilTrap
5
+ module Exec2
6
6
  extend self
7
7
 
8
- # Runs a program in a sub-shell and exits on Ctrl+C.
8
+ # Runs a program in a sub-shell.
9
9
  #
10
- # title - Trailing line title for the output on stdout
11
- # *args - a list of strings containing the program name and (followed by) arguments
10
+ # *args - a list of strings containing the program name and arguments
12
11
  #
12
+ # Returns a Process::Status and a String of output in an array in
13
+ # that order.
13
14
  def run(title, *args)
14
- Open3.popen3(*args) do |stdin, stdout, stderr|
15
+ # title = 'TITLE'
16
+ Open3.popen3(*args) do |stdin, stdout, stderr, status|
15
17
  trap('INT') {
16
18
  puts "#{title}: Received Ctrl-C to stop"
17
19
  raise SystemExit
@@ -19,10 +21,11 @@ module J1
19
21
  stdout.each_line do |line|
20
22
  puts "#{title}: #{line}"
21
23
  end
24
+ [stdin, stdout, stderr].each(&:close)
25
+ status.value
22
26
  end
23
- [stdin, stdout, stderr].each(&:close)
24
27
  end
25
28
 
26
29
  end
27
30
  end
28
- end
31
+ end
data/lib/j1/utils.rb CHANGED
@@ -4,8 +4,8 @@ module J1
4
4
  module Utils
5
5
  extend self
6
6
  autoload :Ansi, "j1/utils/ansi"
7
- autoload :Exec, "j1/utils/exec"
8
- autoload :ExecUntilTrap, "j1/utils/exec_until_trap"
7
+ autoload :Exec1, "j1/utils/exec1"
8
+ autoload :Exec2, "j1/utils/exec2"
9
9
  autoload :Platforms, "j1/utils/platforms"
10
10
  autoload :WinTZ, "j1/utils/win_tz"
11
11
 
@@ -32,11 +32,8 @@ module J1
32
32
  exit
33
33
  end
34
34
  end
35
-
36
35
  end
37
36
 
38
-
39
-
40
37
  # Constants for use in #slugify
41
38
  SLUGIFY_MODES = %w(raw default pretty ascii).freeze
42
39
  SLUGIFY_RAW_REGEXP = Regexp.new('\\s+').freeze
@@ -44,6 +41,32 @@ module J1
44
41
  SLUGIFY_PRETTY_REGEXP = Regexp.new("[^[:alnum:]._~!$&'()+,;=@]+").freeze
45
42
  SLUGIFY_ASCII_REGEXP = Regexp.new("[^[A-Za-z0-9]]+").freeze
46
43
 
44
+ def is_project?
45
+ path = File.expand_path(Dir.pwd)
46
+ puts "Check consistency of the J1 project ..."
47
+ if File.exist?(path + '/package.json') && File.exist?(path + '/_config.yml')
48
+ return true
49
+ else
50
+ puts "\e[31m" + "FATAL: Path #{path} seems not a J1 project folder" + "\e[0m"
51
+ end
52
+ end
53
+
54
+ def is_project_setup?
55
+ path = File.expand_path(Dir.pwd)
56
+ puts "Check setup state of the J1 project ..."
57
+ if File.exist?(path + '/package-lock.json') && File.exist?(path + '/Gemfile.lock')
58
+ return true
59
+ else
60
+ puts "\e[31m" + "FATAL: Project in path #{path} seems not initialized" + "\e[0m"
61
+ puts "INFO: Consider to run 'j1 setup' in order to prepare the project for first use"
62
+ end
63
+ end
64
+
65
+ def is_windows?
66
+ #noinspection RubyResolve
67
+ RbConfig::CONFIG["host_os"] =~ %r!mswin|mingw|cygwin!i
68
+ end
69
+
47
70
  # Takes an indented string and removes the preceding spaces on each line
48
71
 
49
72
  def strip_heredoc(str)
data/lib/j1/version.rb CHANGED
@@ -1,3 +1,3 @@
1
- module J1
2
- VERSION = '2022.0.16'
3
- end
1
+ module J1
2
+ VERSION = '2022.0.17'
3
+ end
@@ -53,7 +53,7 @@ gem 'jekyll', '~> 4.2'
53
53
 
54
54
  # Theme Rubies, default: J1 Template (NOT used for the development system)
55
55
  #
56
- gem 'j1-template', '~> 2022.0.16'
56
+ gem 'j1-template', '~> 2022.0.17'
57
57
 
58
58
  # ------------------------------------------------------------------------------
59
59
  # PRODUCTION: Gem needed for the Jekyll and J1 prod environment
@@ -53,7 +53,7 @@ environment: development
53
53
  # ------------------------------------------------------------------------------
54
54
  # Sets the build version of J1 Template Gem
55
55
  #
56
- version: 2022.0.16
56
+ version: 2022.0.17
57
57
 
58
58
  # version
59
59
  # ------------------------------------------------------------------------------
@@ -437,7 +437,7 @@ end::tables[]
437
437
  // -----------------------------------------------------------------------------
438
438
  tag::products[]
439
439
  :j1--license: MIT License
440
- :j1--version: 2022.0.16
440
+ :j1--version: 2022.0.17
441
441
  :j1--site-name: Jekyll One
442
442
  end::products[]
443
443
 
@@ -364,6 +364,6 @@ end
364
364
 
365
365
  module Jekyll
366
366
  module J1LunrSearch
367
- VERSION = '2022.0.16'
367
+ VERSION = '2022.0.17'
368
368
  end
369
369
  end
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": true,
3
3
  "name": "j1_starter",
4
- "version": "2022.0.16",
4
+ "version": "2022.0.17",
5
5
  "description": "J1 Template Starter Web",
6
6
  "homepage": "https://your.site",
7
7
  "author": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": true,
3
3
  "name": "utls",
4
- "version": "2022.0.16",
4
+ "version": "2022.0.17",
5
5
  "description": "J1 Template Utility Server",
6
6
  "homepage": "https://jekyll.one",
7
7
  "author": {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": true,
3
3
  "name": "utls",
4
- "version": "2022.0.16",
4
+ "version": "2022.0.17",
5
5
  "description": "J1 Template Utility Server",
6
6
  "homepage": "https://jekyll.one",
7
7
  "author": {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: j1-template
3
3
  version: !ruby/object:Gem::Version
4
- version: 2022.0.16
4
+ version: 2022.0.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - juergen_jekyll_one
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-09 00:00:00.000000000 Z
11
+ date: 2022-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -1457,6 +1457,7 @@ files:
1457
1457
  - lib/j1/commands/generate.rb
1458
1458
  - lib/j1/commands/help.rb
1459
1459
  - lib/j1/commands/patch.rb
1460
+ - lib/j1/commands/rebuild.rb
1460
1461
  - lib/j1/commands/reset.rb
1461
1462
  - lib/j1/commands/setup.rb
1462
1463
  - lib/j1/commands/site.rb
@@ -1470,8 +1471,8 @@ files:
1470
1471
  - lib/j1/patches/rubygems/execjs-2.7.0/lib/execjs/external_runtime.rb
1471
1472
  - lib/j1/utils.rb
1472
1473
  - lib/j1/utils/ansi.rb
1473
- - lib/j1/utils/exec.rb
1474
- - lib/j1/utils/exec_until_trap.rb
1474
+ - lib/j1/utils/exec1.rb
1475
+ - lib/j1/utils/exec2.rb
1475
1476
  - lib/j1/utils/platforms.rb
1476
1477
  - lib/j1/utils/win_tz.rb
1477
1478
  - lib/j1/version.rb