jsg 0.1.0 → 0.1.1

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: 17be1d2e6749531713121d32c6a693369be433ad4b089b3a24680432c5fa7b58
4
- data.tar.gz: 5cf7794b2fdcf5bbfa66776bf5295059a5a535b1f191a632f024a859bf72e384
3
+ metadata.gz: 403d8e26f8694b1dcd29406d069d6b1a64774f3290f5422347b0bad791b9ee5c
4
+ data.tar.gz: 8771f3e2158e38ad976f3d188bfcf2fbd890d211d543139031718dc68376f593
5
5
  SHA512:
6
- metadata.gz: eea66cabb0155161fdf1b0e7dd25d239b9f3a54750fc8bd33e9528c50ec305e6b0644afed29e9d9560476c5b8a73e0d279d30fedee40154a151ff5cbdabebbce
7
- data.tar.gz: b1213c76694bea4ace6b52339a75b879ecfecfa792227e6025e3f91f69b14f2e20752944ecedda3c89cbbbc4b391a813c306a1fc0b64139d2335f30d11f34be6
6
+ metadata.gz: 85c2708f22fef8d75a31dcbc2ed67f27a35a33490f21e2a4611a791cc7c9c644898be362afea8701115da932b6709ea9c91eb92d5166a5b99e523c24768b234c
7
+ data.tar.gz: 7bd3d4203d3a39baaabc4acffb9a88f1a0246c69fcb6db0a512205e3ced2868803d241489c55c84eb04b05a54d244132283d942134185ff56a00cb9edb610789
data/exe/jsg CHANGED
@@ -12,8 +12,7 @@ module JSG
12
12
  destination = File.join(Dir.pwd, project_name)
13
13
 
14
14
  if Dir.exist?(destination)
15
- puts "Sorry #{destination} already exists, please choose other name or delete the folder"
16
- return
15
+ raise "Sorry #{destination} already exists, please choose other name or delete the folder"
17
16
  end
18
17
  FileUtils.mkdir_p(destination)
19
18
 
@@ -32,6 +31,8 @@ module JSG
32
31
 
33
32
  relative_path = file_path.sub("#{base_path}/", "").gsub(/\.erb$/, "")
34
33
  new_file_path = File.join(destination, relative_path)
34
+
35
+ new_file_path.gsub!("gitignore", ".gitignore")
35
36
  FileUtils.mkdir_p(File.dirname(new_file_path))
36
37
  File.write(new_file_path, result)
37
38
  end
@@ -39,8 +40,26 @@ module JSG
39
40
 
40
41
  def self.build
41
42
  system("bundle install")
42
- # rbwasm --log-level debug build --ruby-version 3.3 --target wasm32-unknown-wasip1 --build-profile full
43
- system("bundle exec rbwasm build -o assets/ruby-app.wasm")
43
+ system("rbwasm build -o assets/ruby-app.wasm")
44
+ end
45
+
46
+ def self.server
47
+ require 'webrick'
48
+
49
+ port = 8080
50
+
51
+ loop do
52
+ begin
53
+ server = WEBrick::HTTPServer.new(BindAddres: '0.0.0.0', :Port => port, :DocumentRoot => Dir.pwd)
54
+ trap('INT') { server.shutdown }
55
+ puts "Serving at port http://0.0.0.0.:#{port}"
56
+ server.start
57
+ break
58
+ rescue Errno::EADDRINUSE
59
+ port += 1
60
+ end
61
+ end
62
+
44
63
  end
45
64
  end
46
65
 
@@ -52,17 +71,27 @@ when "new"
52
71
  project_name = ARGV.shift # Next argument should be the project name
53
72
 
54
73
  if project_name
55
- JSG.create_project(project_name)
56
- JSG.build
74
+ begin
75
+ JSG.create_project(project_name)
76
+ # check if we have an internet connection or think about caching this somewhere.
77
+ Dir.chdir(project_name) do
78
+ JSG.build
79
+ end
80
+ rescue StandardError => e
81
+ end
57
82
  else
58
83
  puts "Error: Project name is required."
59
- puts "For help, run: jsg new --help"
84
+ #puts "For help, run: jsg new --help"
60
85
  exit 1
61
86
  end
62
87
  when "build"
63
88
  JSG.build
89
+ when "serve", "server"
90
+ JSG.server
64
91
  else
65
92
  puts "Unknown command: #{command}"
66
- puts "Use 'jsg new --help' for creating new projects."
93
+ puts "Use 'jsg new projectname' for creating new projects."
94
+ puts "Use 'jsg build to build the .wasm file of the project."
95
+ puts "Use 'jsg server to start a server."
67
96
  exit 1
68
97
  end
data/lib/jsg/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JSG
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andi
@@ -61,11 +61,10 @@ files:
61
61
  - jsg.rb
62
62
  - lib/jsg/version.rb
63
63
  - sig/jsg.rbs
64
- - template/.gitignore
65
64
  - template/Gemfile
66
65
  - template/assets/browser.script.iife.js
66
+ - template/gitignore
67
67
  - template/index.html.erb
68
- - template/serve.sh
69
68
  - template/src/main.rb
70
69
  homepage: https://github.com/largo/jsg
71
70
  licenses:
data/template/serve.sh DELETED
@@ -1 +0,0 @@
1
- ruby -run -e httpd . -p 8080
File without changes