rubyjs-vite 1.1.3 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/bin/rjsv +6 -2
  3. data/lib/option_parser.rb +6 -2
  4. data/lib/rjsv/cli/arguments.rb +77 -0
  5. data/lib/rjsv/cli/plugins.rb +71 -0
  6. data/lib/rjsv/cli/signals.rb +15 -0
  7. data/lib/rjsv/constants.rb +8 -0
  8. data/lib/rjsv/core/constants.rb +31 -0
  9. data/lib/rjsv/core/event.rb +24 -0
  10. data/lib/rjsv/core/files.rb +96 -0
  11. data/lib/rjsv/plugin.rb +55 -0
  12. data/lib/rjsv/translate.rb +40 -0
  13. data/lib/rjsv/version.rb +3 -0
  14. data/lib/rjsv/watch.rb +35 -0
  15. data/lib/rjsv.rb +105 -0
  16. data/plugins/scaffold/lib/init.rb +31 -0
  17. data/plugins/scaffold/lib/scaffold/cli/arguments.rb +43 -0
  18. data/plugins/scaffold/lib/scaffold/create.rb +64 -0
  19. data/plugins/scaffold/lib/scaffold/states.rb +40 -0
  20. data/plugins/scaffold/lib/scaffold/vite.rb +13 -0
  21. data/share/scaffold/element/element.js.rb +20 -0
  22. data/share/scaffold/element/init.js.rb +3 -0
  23. data/share/{template → scaffold/web}/.gitignore +2 -0
  24. data/share/{template → scaffold/web}/bin/server +1 -1
  25. data/share/scaffold/web/config/ruby2js.rb +10 -0
  26. data/share/{template → scaffold/web}/index.html +1 -1
  27. data/share/{template → scaffold/web}/package.json +6 -3
  28. data/share/scaffold/web/src/css/style.css +0 -0
  29. data/share/scaffold/web/src/js/env.js +1 -0
  30. metadata +42 -30
  31. data/app/arguments.rb +0 -67
  32. data/app/config.rb +0 -11
  33. data/app/main.rb +0 -75
  34. data/app/signals.rb +0 -4
  35. data/lib/description.rb +0 -10
  36. data/lib/ruby_js/code_join.rb +0 -153
  37. data/lib/ruby_js/constants.rb +0 -7
  38. data/lib/ruby_js/helper.rb +0 -50
  39. data/lib/ruby_js/scaffold.rb +0 -52
  40. data/lib/ruby_js/version.rb +0 -3
  41. data/lib/ruby_js.rb +0 -74
  42. data/share/template/.codejoin +0 -8
  43. data/share/template/bin/generate +0 -3
  44. data/share/template/bin/watch +0 -3
  45. /data/share/{template/src/css/style.css → scaffold/web/.env} +0 -0
  46. /data/share/{template → scaffold/web}/public/vite.svg +0 -0
  47. /data/share/{template/src/rjs/main.rjs → scaffold/web/src/rb/main.js.rb} +0 -0
@@ -1,50 +0,0 @@
1
- module RubyJS
2
- module Helper
3
- require 'fileutils'
4
-
5
- def self.open path
6
- result = ""
7
-
8
- if File.exist? path
9
- File.open path do |f|
10
- result = f.read
11
- end
12
- end
13
-
14
- result
15
- end
16
-
17
- def self.write path_o, content
18
- path_od = File.dirname(path_o)
19
- create_dir(path_od)
20
-
21
- file = File.new(path_o, "w+")
22
- file.write content
23
- file.close
24
- end
25
-
26
- def self.free path_fro
27
- # File
28
- File.delete(path_fro) if File.exist? path_fro
29
- # Dir
30
- path_dro = File.dirname(path_fro)
31
- Dir.delete(path_dro) if Dir.empty? path_dro
32
- end
33
-
34
- def self.event_p event, path_f = ""
35
- "#{Time.now.strftime("%l:%M:%S %p").lstrip} [#{Constants::APP_NAME}] #{event} #{path_f}"
36
- end
37
-
38
- def self.absolute_path path_f, path_options, prefix
39
- path_ffr = path_f.sub("#{Dir.pwd}/", '').sub(path_options[:path_s], '').sub(Constants::FILE_TYPE, prefix)
40
- path_ffa = File.join(path_options[:path_o], path_ffr)
41
- path_ffa
42
- end
43
-
44
- def self.create_dir path
45
- unless Dir.exist? path
46
- FileUtils.mkdir_p path
47
- end
48
- end
49
- end
50
- end
@@ -1,52 +0,0 @@
1
- module RubyJS
2
- module Scaffold
3
- require "json_parser"
4
-
5
- def self.create project
6
- path_as = File.expand_path("./share/template", ROOT)
7
- path_ao = File.join(Dir.pwd, project)
8
-
9
- puts "Scaffolding project in #{path_ao}..."
10
- files = Dir.glob("#{path_as}/**/*", File::FNM_DOTMATCH).select { |f| File.file?(f) }
11
- files.each do |pas|
12
- pao = pas.sub(path_as, path_ao)
13
- FileUtils.mkdir_p(File.dirname(pao))
14
- FileUtils.cp(pas, pao)
15
- end
16
-
17
- json_oc = JsonParser.new File.join(path_ao, "package.json")
18
- json_oc.parse :name, project.downcase
19
-
20
- json_cj = JsonParser.new File.join(path_ao, ".codejoin")
21
- json_cj.parse :name, project.downcase
22
-
23
- change_name_f(path_ao)
24
- install_vite(project, path_ao)
25
- end
26
-
27
- def self.change_name_f path_ao
28
- paths_bin_ao = Dir.glob("#{path_ao}/bin/*")
29
- paths_bin_ao.each do |p|
30
- content = Helper.open(p)
31
- content_ch = content.sub("APP_NAME", Constants::APP_NAME)
32
- Helper.write(p, content_ch)
33
- end
34
- end
35
-
36
- def self.install_vite project, path_ao
37
- is_done = system("cd #{path_ao} && npm install -D vite")
38
- if is_done
39
- puts "\nDone. Now run:\n\n cd #{project}\n bin/server\n\n"
40
- else
41
- wspaces = ' '*2
42
- puts "\nThe Vite library installation encountered an issue.\n" +
43
- "NodeJS is probably not installed on your machine.\n" +
44
- "Please rerun the Vite installation after installing NodeJS.\n" +
45
- "Use these instructions:\n\n" +
46
- "#{wspaces}cd #{project}\n" +
47
- "#{wspaces}npm install -D vite\n" +
48
- "#{wspaces}bin/server"
49
- end
50
- end
51
- end
52
- end
@@ -1,3 +0,0 @@
1
- module RubyJS
2
- VERSION = "1.1.3"
3
- end
data/lib/ruby_js.rb DELETED
@@ -1,74 +0,0 @@
1
- require 'ruby2js'
2
- require "ruby2js/filter/esm"
3
- require "listen"
4
- require "option_parser"
5
-
6
- module RubyJS
7
- require "ruby_js/version"
8
- require "ruby_js/helper"
9
- require "ruby_js/constants"
10
- require "ruby_js/scaffold"
11
- require "ruby_js/code_join"
12
-
13
- def self.watch path, ignore = ""
14
- listener = Listen.to(path, only: /\.#{Constants::FILE_TYPE}$/, ignore: /#{ignore}/) do |modified, added, removed|
15
- yield modified, added, removed
16
- end
17
- listener.start
18
- sleep
19
- end
20
-
21
- def self.compile path_f, options
22
- path_o = Helper.absolute_path(path_f,
23
- { path_s: options[:path_s], path_o: options[:path_o] }, options[:type_o])
24
-
25
- begin
26
- content_rb = Helper.open(path_f)
27
- content_js = Ruby2JS.convert(content_rb, eslevel: options[:eslevel]
28
- ) unless content_rb.empty?
29
-
30
- path_write = Helper.write(path_o, content_js)
31
- puts Helper.event_p("compiled", path_o)
32
- rescue => exception
33
- # p exception.inspect
34
- puts Helper.event_p("error", "#{path_o} #{exception}")
35
- end
36
- end
37
-
38
- def self.generate_cj path_s, path_g
39
- path_hfd = path_s
40
- unless File.exist?(File.join(path_s, CodeJoin::FILE_HN))
41
- path_hfd = Dir.pwd
42
- end
43
-
44
- code_join = CodeJoin.new path_hfd
45
- get_files(path_s).each do |path_f|
46
- unless path_f.index(/#{code_join.get_ignore_r}/)
47
- code_join.add_file(path_f)
48
- end
49
- end
50
-
51
- content_join = code_join.to_s
52
-
53
- name_f = "#{code_join.json_cj.parse(:name).downcase.gsub(' ', '_')}_" +
54
- "#{Time.now.strftime("%ya%m%d")}.#{Constants::FILE_TYPE}"
55
- path_w = path_g.empty? ? path_s : path_g
56
- path_f = File.join(path_w, name_f)
57
- RubyJS::Helper.write(path_f, content_join)
58
- puts Helper.event_p("generated", path_f)
59
-
60
- return code_join
61
- end
62
-
63
- def self.free path_f, options
64
- path_o = Helper.absolute_path path_f, options, options[:type_o]
65
- Helper.free path_o
66
-
67
- puts Helper.event_p("deleted", path_o)
68
- end
69
-
70
- def self.get_files(path_s)
71
- path = "#{path_s}/**/*.#{Constants::FILE_TYPE}"
72
- Dir.glob(path)
73
- end
74
- end
@@ -1,8 +0,0 @@
1
- {
2
- "name": "project",
3
- "ignore": [
4
- "FILE_N_.*.rjs",
5
- "test.rjs",
6
- "main.rjs"
7
- ]
8
- }
@@ -1,3 +0,0 @@
1
- #!/bin/bash
2
-
3
- APP_NAME -g -s src/rjs -o src/.js
@@ -1,3 +0,0 @@
1
- #!/bin/bash
2
-
3
- APP_NAME -c -w -s src/rjs -o src/.js
File without changes