ts-rails 0.0.1
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.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.travis.yml +11 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +22 -0
- data/Rakefile +13 -0
- data/lib/assets/javascripts/typescript.js.erb +1 -0
- data/lib/rails/generators/typescript/assets/assets_generator.rb +13 -0
- data/lib/rails/generators/typescript/assets/templates/javascript.ts +3 -0
- data/lib/ts-rails.rb +7 -0
- data/lib/typescript/rails.rb +5 -0
- data/lib/typescript/rails/compiler.rb +69 -0
- data/lib/typescript/rails/engine.rb +18 -0
- data/lib/typescript/rails/js_hook.rb +15 -0
- data/lib/typescript/rails/railtie.rb +20 -0
- data/lib/typescript/rails/template.rb +32 -0
- data/lib/typescript/rails/template_handler.rb +21 -0
- data/lib/typescript/rails/transformer.rb +20 -0
- data/lib/typescript/rails/version.rb +5 -0
- data/test/assets_generator_test.rb +15 -0
- data/test/assets_test.rb +48 -0
- data/test/controller_generator_test.rb +19 -0
- data/test/fixtures/assets/javascripts/hello.js.ts +3 -0
- data/test/fixtures/assets/javascripts/included.ts +4 -0
- data/test/fixtures/assets/javascripts/reference.ts +2 -0
- data/test/fixtures/routes.rb +0 -0
- data/test/fixtures/site/es5.js.ts +7 -0
- data/test/fixtures/site/index.js.ts +1 -0
- data/test/fixtures/site/ref1_1.js.ts +3 -0
- data/test/fixtures/site/ref1_2.js.ts +3 -0
- data/test/fixtures/site/ref2_1.d.ts +1 -0
- data/test/fixtures/site/ref2_2.js.ts +3 -0
- data/test/fixtures/site/ref3_1.js.ts +5 -0
- data/test/fixtures/site/ref3_2.ts +3 -0
- data/test/fixtures/site/ref3_3.ts +3 -0
- data/test/scaffold_generator_test.rb +19 -0
- data/test/support/routes.rb +1 -0
- data/test/template_handler_test.rb +59 -0
- data/test/test_helper.rb +17 -0
- data/ts-rails.gemspec +26 -0
- metadata +144 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 34c3072ac1a05a3d0696363f812da6de29f109f3
|
4
|
+
data.tar.gz: cf778dc46327d949e4971fb14864807dd21acefd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0b9d62017c297b3a4a7121145d27c2c29169a694040f6dec8f313d3640e8f6ae626be22b6cdb5ea396653a03cefce4922c5899f842b878b58501c1f9180c062f
|
7
|
+
data.tar.gz: d7a3116e9e1c7c4d5cd449c344dac5dde3a1ff33ae547616db3d789467ba90ae5ddb94e24d87a500a9c1e75dbfc62e38260f7a274f5b7447408e9792fe1411e1
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in ts-rails.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :test do
|
7
|
+
gem 'rails', '~> 4.0'
|
8
|
+
gem 'sprockets-rails', '> 2.0'
|
9
|
+
gem 'minitest-power_assert'
|
10
|
+
gem 'tzinfo-data', platforms: [:mingw, :mswin]
|
11
|
+
end
|
12
|
+
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2017 Valentin Vasilyev
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
<%= TypeScript::Src.js_content %>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "rails/generators/named_base"
|
2
|
+
|
3
|
+
module TypeScript
|
4
|
+
module Generators
|
5
|
+
class AssetsGenerator < ::Rails::Generators::NamedBase
|
6
|
+
source_root File.expand_path("../templates", __FILE__)
|
7
|
+
|
8
|
+
def copy_typescript
|
9
|
+
template "javascript.ts", File.join('app/assets/javascripts', class_path, "#{file_name}.ts")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/ts-rails.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'tsc-ruby'
|
2
|
+
require 'typescript/rails'
|
3
|
+
|
4
|
+
module TypeScript::Rails::Compiler
|
5
|
+
class << self
|
6
|
+
# @!scope class
|
7
|
+
cattr_accessor :default_options
|
8
|
+
|
9
|
+
# Replace relative paths specified in /// <reference path="..." /> with absolute paths.
|
10
|
+
#
|
11
|
+
# @param [String] ts_path Source .ts path
|
12
|
+
# @param [String] source. It might be pre-processed by erb.
|
13
|
+
# @return [String] replaces source
|
14
|
+
def replace_relative_references(ts_path, source)
|
15
|
+
ts_dir = File.dirname(File.expand_path(ts_path))
|
16
|
+
escaped_dir = ts_dir.gsub(/["\\]/, '\\\\\&') # "\"" => "\\\"", '\\' => '\\\\'
|
17
|
+
|
18
|
+
# Why don't we just use gsub? Because it display odd behavior with File.join on Ruby 2.0
|
19
|
+
# So we go the long way around.
|
20
|
+
(source.each_line.map do |l|
|
21
|
+
if l.starts_with?('///') && !(m = %r!^///\s*<reference\s+path=(?:"([^"]+)"|'([^']+)')\s*/>\s*!.match(l)).nil?
|
22
|
+
matched_path = m.captures.compact[0]
|
23
|
+
l = l.sub(matched_path, File.join(escaped_dir, matched_path))
|
24
|
+
end
|
25
|
+
next l
|
26
|
+
end).join
|
27
|
+
end
|
28
|
+
|
29
|
+
# Get all references
|
30
|
+
#
|
31
|
+
# @param [String] path Source .ts path
|
32
|
+
# @param [String] source. It might be pre-processed by erb.
|
33
|
+
# @yieldreturn [String] matched ref abs_path
|
34
|
+
def get_all_reference_paths(path, source, visited_paths=Set.new, &block)
|
35
|
+
visited_paths << path
|
36
|
+
source ||= File.read(path)
|
37
|
+
source.each_line do |l|
|
38
|
+
if l.starts_with?('///') && !(m = %r!^///\s*<reference\s+path=(?:"([^"]+)"|'([^']+)')\s*/>\s*!.match(l)).nil?
|
39
|
+
matched_path = m.captures.compact[0]
|
40
|
+
abs_matched_path = File.expand_path(matched_path, File.dirname(path))
|
41
|
+
unless visited_paths.include? abs_matched_path
|
42
|
+
block.call abs_matched_path
|
43
|
+
get_all_reference_paths(abs_matched_path, nil, visited_paths, &block)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
# @param [String] ts_path
|
50
|
+
# @param [String] source TypeScript source code
|
51
|
+
# @param [Sprockets::Context] sprockets context object
|
52
|
+
# @return [String] compiled JavaScript source code
|
53
|
+
def compile(ts_path, source, context=nil, *options)
|
54
|
+
if context
|
55
|
+
get_all_reference_paths(File.expand_path(ts_path), source) do |abs_path|
|
56
|
+
context.depend_on abs_path
|
57
|
+
end
|
58
|
+
end
|
59
|
+
s = replace_relative_references(ts_path, source)
|
60
|
+
begin
|
61
|
+
::TypeScript::Ruby.compile(s, *default_options, *options)
|
62
|
+
rescue Exception => e
|
63
|
+
raise "TypeScript error in file '#{ts_path}':\n#{e.message}"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
self.default_options = %w(--target ES5 --noImplicitAny)
|
69
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rails/engine'
|
2
|
+
require 'rails/generators'
|
3
|
+
require 'typescript/rails/js_hook'
|
4
|
+
|
5
|
+
class TypeScript::Rails::Engine < Rails::Engine
|
6
|
+
# To become the default generator...
|
7
|
+
# config.app_generators.javascript_engine :typescript
|
8
|
+
|
9
|
+
if config.respond_to?(:annotations)
|
10
|
+
config.annotations.register_extensions(".ts") { |annotation| /#\s*(#{annotation}):?\s*(.*)$/ }
|
11
|
+
end
|
12
|
+
|
13
|
+
initializer 'override js_template hook' do |app|
|
14
|
+
if app.config.generators.rails[:javascript_engine] == :typescript
|
15
|
+
::Rails::Generators::NamedBase.send :include, TypeScript::Rails::JsHook
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module TypeScript
|
2
|
+
module Rails
|
3
|
+
module JsHook
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
no_tasks do
|
8
|
+
redefine_method :js_template do |source, destination|
|
9
|
+
template(source + '.ts', destination + '.ts')
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'typescript/rails'
|
2
|
+
|
3
|
+
class TypeScript::Rails::Railtie < ::Rails::Railtie
|
4
|
+
config.before_initialize do |app|
|
5
|
+
if ::Rails::VERSION::MAJOR >= 4 || app.config.assets.enabled
|
6
|
+
require 'typescript/rails/template'
|
7
|
+
require 'typescript/rails/transformer'
|
8
|
+
require 'sprockets'
|
9
|
+
|
10
|
+
if Sprockets.respond_to?(:register_engine)
|
11
|
+
Sprockets.register_engine '.ts', TypeScript::Rails::Template, silence_deprecation: true
|
12
|
+
end
|
13
|
+
|
14
|
+
if Sprockets.respond_to?(:register_transformer)
|
15
|
+
Sprockets.register_mime_type 'text/typescript', extensions: ['.ts']
|
16
|
+
Sprockets.register_transformer 'text/typescript', 'application/javascript', TypeScript::Rails::Transformer
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'typescript/rails'
|
2
|
+
require 'tilt/template'
|
3
|
+
|
4
|
+
class TypeScript::Rails::Template < ::Tilt::Template
|
5
|
+
self.default_mime_type = 'application/javascript'
|
6
|
+
|
7
|
+
# @!scope class
|
8
|
+
class_attribute :default_bare
|
9
|
+
|
10
|
+
def self.engine_initialized?
|
11
|
+
defined? ::TypeScript::Rails::Compiler
|
12
|
+
end
|
13
|
+
|
14
|
+
def initialize_engine
|
15
|
+
require_template_library 'typescript/rails/compiler'
|
16
|
+
end
|
17
|
+
|
18
|
+
def prepare
|
19
|
+
if !options.key?(:bare) and !options.key?(:no_wrap)
|
20
|
+
options[:bare] = self.class.default_bare
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def evaluate(context, locals, &block)
|
25
|
+
@output ||= ::TypeScript::Rails::Compiler.compile(file, data, context)
|
26
|
+
end
|
27
|
+
|
28
|
+
# @override
|
29
|
+
def allows_script?
|
30
|
+
false
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'typescript/rails/compiler'
|
2
|
+
|
3
|
+
class TypeScript::Rails::TemplateHandler
|
4
|
+
class << self
|
5
|
+
def erb_handler
|
6
|
+
@erb_handler ||= ActionView::Template.registered_template_handler(:erb)
|
7
|
+
end
|
8
|
+
|
9
|
+
def call(template)
|
10
|
+
compiled_source = erb_handler.call(template)
|
11
|
+
path = template.identifier.gsub(/['\\]/, '\\\\\&') # "'" => "\\'", '\\' => '\\\\'
|
12
|
+
<<-EOS
|
13
|
+
::TypeScript::Rails::Compiler.compile('#{path}', (begin;#{compiled_source};end))
|
14
|
+
EOS
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
ActiveSupport.on_load(:action_view) do
|
20
|
+
ActionView::Template.register_template_handler :ts, TypeScript::Rails::TemplateHandler
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'typescript/rails'
|
2
|
+
|
3
|
+
class TypeScript::Rails::Transformer
|
4
|
+
def self.instance
|
5
|
+
@instance ||= new
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.call(input)
|
9
|
+
instance.call(input)
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(input)
|
13
|
+
filename = input[:filename]
|
14
|
+
source = input[:data]
|
15
|
+
context = input[:environment].context_class.new(input)
|
16
|
+
|
17
|
+
result = ::TypeScript::Rails::Compiler.compile(filename, source, context)
|
18
|
+
{ data: result }
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'rails/generators/typescript/assets/assets_generator'
|
3
|
+
|
4
|
+
class AssetGeneratorTest < Rails::Generators::TestCase
|
5
|
+
tests TypeScript::Generators::AssetsGenerator
|
6
|
+
|
7
|
+
destination File.expand_path("../tmp", __FILE__)
|
8
|
+
setup :prepare_destination
|
9
|
+
|
10
|
+
def test_assets
|
11
|
+
run_generator %w(posts)
|
12
|
+
assert_no_file "app/assets/javascripts/posts.js"
|
13
|
+
assert_file "app/assets/javascripts/posts.ts"
|
14
|
+
end
|
15
|
+
end
|
data/test/assets_test.rb
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper.rb')
|
2
|
+
require 'ts-rails'
|
3
|
+
|
4
|
+
require 'action_controller/railtie'
|
5
|
+
require 'sprockets/railtie'
|
6
|
+
|
7
|
+
|
8
|
+
class AssetsTest < ActiveSupport::TestCase
|
9
|
+
include Minitest::PowerAssert::Assertions
|
10
|
+
|
11
|
+
def setup
|
12
|
+
FileUtils.mkdir_p tmp_path
|
13
|
+
|
14
|
+
@app = Class.new(Rails::Application)
|
15
|
+
|
16
|
+
@app.config.eager_load = false
|
17
|
+
@app.config.active_support.deprecation = :stderr
|
18
|
+
@app.config.assets.configure do |env|
|
19
|
+
env.cache = ActiveSupport::Cache.lookup_store(:memory_store)
|
20
|
+
end
|
21
|
+
@app.config.assets.paths << "#{File.dirname(__FILE__)}/fixtures/assets"
|
22
|
+
@app.paths['log'] = "#{tmp_path}/log/test.log"
|
23
|
+
@app.initialize!
|
24
|
+
end
|
25
|
+
|
26
|
+
def teardown
|
27
|
+
FileUtils.rm_rf tmp_path
|
28
|
+
end
|
29
|
+
|
30
|
+
def tmp_path
|
31
|
+
"#{File.dirname(__FILE__)}/tmp"
|
32
|
+
end
|
33
|
+
|
34
|
+
def assets
|
35
|
+
@app.assets
|
36
|
+
end
|
37
|
+
|
38
|
+
test 'typescript.js is included in Sprockets environment' do
|
39
|
+
assert { assets["typescript"].filename.to_s.end_with?('/lib/assets/javascripts/typescript.js.erb') }
|
40
|
+
assert { assets["typescript"].source.include?('var ts;') }
|
41
|
+
end
|
42
|
+
|
43
|
+
test 'assets .js.ts is compiled from TypeScript to JavaScript' do
|
44
|
+
assert { assets['javascripts/hello.js'].present? }
|
45
|
+
assert { assets['javascripts/hello.js'].source.include?('var log_to_console = function (x) {') }
|
46
|
+
assert { assets['javascripts/hello.js'].source.include?('var s = "Hello, world!";') }
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'rails/generators/rails/controller/controller_generator'
|
3
|
+
require 'rails/generators/typescript/assets/assets_generator'
|
4
|
+
|
5
|
+
class ControllerGeneratorTest < Rails::Generators::TestCase
|
6
|
+
tests Rails::Generators::ControllerGenerator
|
7
|
+
|
8
|
+
destination File.expand_path("../tmp", __FILE__)
|
9
|
+
setup do
|
10
|
+
prepare_destination
|
11
|
+
copy_routes
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_assets
|
15
|
+
run_generator %w(posts --javascript-engine=typescript --orm=false)
|
16
|
+
assert_no_file "app/assets/javascripts/posts.js"
|
17
|
+
assert_file "app/assets/javascripts/posts.ts"
|
18
|
+
end
|
19
|
+
end
|
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
var x:number = 5
|
@@ -0,0 +1 @@
|
|
1
|
+
declare var f: (x: number, y: number) => number;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'rails/generators/rails/scaffold/scaffold_generator'
|
3
|
+
require 'rails/generators/typescript/assets/assets_generator'
|
4
|
+
|
5
|
+
class ScaffoldGeneratorTest < Rails::Generators::TestCase
|
6
|
+
tests Rails::Generators::ScaffoldGenerator
|
7
|
+
|
8
|
+
destination File.expand_path("../tmp", __FILE__)
|
9
|
+
setup do
|
10
|
+
prepare_destination
|
11
|
+
copy_routes
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_assets
|
15
|
+
run_generator %w(posts --javascript-engine=typescript --orm=false)
|
16
|
+
assert_no_file "app/assets/javascripts/posts.js"
|
17
|
+
assert_file "app/assets/javascripts/posts.ts"
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# routes dummy file
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper.rb')
|
2
|
+
require 'action_controller'
|
3
|
+
require 'ts-rails'
|
4
|
+
|
5
|
+
class SiteController < ActionController::Base
|
6
|
+
self.view_paths = File.expand_path('../fixtures', __FILE__)
|
7
|
+
end
|
8
|
+
|
9
|
+
DummyApp = ActionDispatch::Routing::RouteSet.new
|
10
|
+
DummyApp.draw do
|
11
|
+
get 'site/index'
|
12
|
+
get 'site/ref1_1'
|
13
|
+
get 'site/ref1_2'
|
14
|
+
get 'site/ref2_1'
|
15
|
+
get 'site/ref2_2'
|
16
|
+
get 'site/ref3_1'
|
17
|
+
get 'site/es5'
|
18
|
+
end
|
19
|
+
|
20
|
+
class TemplateHandlerTest < ActiveSupport::TestCase
|
21
|
+
include Rack::Test::Methods
|
22
|
+
|
23
|
+
def app
|
24
|
+
@app ||= DummyApp
|
25
|
+
end
|
26
|
+
|
27
|
+
def source
|
28
|
+
# source without comments
|
29
|
+
last_response.body.gsub(%r{^//[^\n]*}m, '')
|
30
|
+
end
|
31
|
+
|
32
|
+
test 'typescript views are served as javascript' do
|
33
|
+
get '/site/index.js'
|
34
|
+
assert_match (/var x = 5;\s*/), source
|
35
|
+
end
|
36
|
+
|
37
|
+
test '<reference> to other .ts file works' do
|
38
|
+
get '/site/ref1_2.js'
|
39
|
+
assert_match (/var f = function \(x, y\) \{\s*return x \+ y;\s*\};\s*f\(1, 2\);\s*/),
|
40
|
+
source
|
41
|
+
end
|
42
|
+
|
43
|
+
test '<reference> to other .d.ts file works' do
|
44
|
+
get '/site/ref2_2.js'
|
45
|
+
assert_match /f\(1, 2\);\s*/,
|
46
|
+
source
|
47
|
+
end
|
48
|
+
|
49
|
+
test '<reference> to multiple .ts files works' do
|
50
|
+
get '/site/ref3_1.js'
|
51
|
+
assert_match /var f1 = function \(\) \{\s*\};\s*var f2 = function \(\) \{\s*\};\s*f1\(\);\s*f2\(\);/,
|
52
|
+
source
|
53
|
+
end
|
54
|
+
|
55
|
+
test 'ES5 features' do
|
56
|
+
get '/site/es5.js'
|
57
|
+
assert_equal 200, last_response.status
|
58
|
+
end
|
59
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Configure Rails environment
|
2
|
+
ENV['RAILS_ENV'] = 'test'
|
3
|
+
|
4
|
+
require 'rails'
|
5
|
+
require 'rails/test_help'
|
6
|
+
require 'minitest-power_assert'
|
7
|
+
|
8
|
+
# For generators
|
9
|
+
require 'rails/generators/test_case'
|
10
|
+
|
11
|
+
def copy_routes
|
12
|
+
routes = File.expand_path('../support/routes.rb', __FILE__)
|
13
|
+
destination = File.join(destination_root, 'config')
|
14
|
+
|
15
|
+
FileUtils.mkdir_p(destination)
|
16
|
+
FileUtils.cp routes, destination
|
17
|
+
end
|
data/ts-rails.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'typescript/rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = 'ts-rails'
|
8
|
+
gem.version = TypeScript::Rails::VERSION
|
9
|
+
gem.platform = Gem::Platform::RUBY
|
10
|
+
gem.authors = ['Valentin Vasilyev']
|
11
|
+
gem.email = %w(valentin.vasilyev@outlook.com)
|
12
|
+
gem.description = %q{Adds TypeScript to the Rails Asset pipeline}
|
13
|
+
gem.summary = %q{Adds TypeScript to the Rails Asset pipeline}
|
14
|
+
gem.homepage = 'https://github.com/valve/ts-rails'
|
15
|
+
|
16
|
+
gem.add_runtime_dependency 'tsc-ruby'
|
17
|
+
gem.add_runtime_dependency 'tilt'
|
18
|
+
gem.add_runtime_dependency 'railties'
|
19
|
+
|
20
|
+
gem.files = `git ls-files`.split($/)
|
21
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
22
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
23
|
+
gem.require_paths = ['lib']
|
24
|
+
|
25
|
+
gem.required_ruby_version = '>= 2.0.0'
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ts-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Valentin Vasilyev
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-02-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: tsc-ruby
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: tilt
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: railties
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
description: Adds TypeScript to the Rails Asset pipeline
|
56
|
+
email:
|
57
|
+
- valentin.vasilyev@outlook.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE.txt
|
66
|
+
- Rakefile
|
67
|
+
- lib/assets/javascripts/typescript.js.erb
|
68
|
+
- lib/rails/generators/typescript/assets/assets_generator.rb
|
69
|
+
- lib/rails/generators/typescript/assets/templates/javascript.ts
|
70
|
+
- lib/ts-rails.rb
|
71
|
+
- lib/typescript/rails.rb
|
72
|
+
- lib/typescript/rails/compiler.rb
|
73
|
+
- lib/typescript/rails/engine.rb
|
74
|
+
- lib/typescript/rails/js_hook.rb
|
75
|
+
- lib/typescript/rails/railtie.rb
|
76
|
+
- lib/typescript/rails/template.rb
|
77
|
+
- lib/typescript/rails/template_handler.rb
|
78
|
+
- lib/typescript/rails/transformer.rb
|
79
|
+
- lib/typescript/rails/version.rb
|
80
|
+
- test/assets_generator_test.rb
|
81
|
+
- test/assets_test.rb
|
82
|
+
- test/controller_generator_test.rb
|
83
|
+
- test/fixtures/assets/javascripts/hello.js.ts
|
84
|
+
- test/fixtures/assets/javascripts/included.ts
|
85
|
+
- test/fixtures/assets/javascripts/reference.ts
|
86
|
+
- test/fixtures/routes.rb
|
87
|
+
- test/fixtures/site/es5.js.ts
|
88
|
+
- test/fixtures/site/index.js.ts
|
89
|
+
- test/fixtures/site/ref1_1.js.ts
|
90
|
+
- test/fixtures/site/ref1_2.js.ts
|
91
|
+
- test/fixtures/site/ref2_1.d.ts
|
92
|
+
- test/fixtures/site/ref2_2.js.ts
|
93
|
+
- test/fixtures/site/ref3_1.js.ts
|
94
|
+
- test/fixtures/site/ref3_2.ts
|
95
|
+
- test/fixtures/site/ref3_3.ts
|
96
|
+
- test/scaffold_generator_test.rb
|
97
|
+
- test/support/routes.rb
|
98
|
+
- test/template_handler_test.rb
|
99
|
+
- test/test_helper.rb
|
100
|
+
- ts-rails.gemspec
|
101
|
+
homepage: https://github.com/valve/ts-rails
|
102
|
+
licenses: []
|
103
|
+
metadata: {}
|
104
|
+
post_install_message:
|
105
|
+
rdoc_options: []
|
106
|
+
require_paths:
|
107
|
+
- lib
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 2.0.0
|
113
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
requirements: []
|
119
|
+
rubyforge_project:
|
120
|
+
rubygems_version: 2.5.2
|
121
|
+
signing_key:
|
122
|
+
specification_version: 4
|
123
|
+
summary: Adds TypeScript to the Rails Asset pipeline
|
124
|
+
test_files:
|
125
|
+
- test/assets_generator_test.rb
|
126
|
+
- test/assets_test.rb
|
127
|
+
- test/controller_generator_test.rb
|
128
|
+
- test/fixtures/assets/javascripts/hello.js.ts
|
129
|
+
- test/fixtures/assets/javascripts/included.ts
|
130
|
+
- test/fixtures/assets/javascripts/reference.ts
|
131
|
+
- test/fixtures/routes.rb
|
132
|
+
- test/fixtures/site/es5.js.ts
|
133
|
+
- test/fixtures/site/index.js.ts
|
134
|
+
- test/fixtures/site/ref1_1.js.ts
|
135
|
+
- test/fixtures/site/ref1_2.js.ts
|
136
|
+
- test/fixtures/site/ref2_1.d.ts
|
137
|
+
- test/fixtures/site/ref2_2.js.ts
|
138
|
+
- test/fixtures/site/ref3_1.js.ts
|
139
|
+
- test/fixtures/site/ref3_2.ts
|
140
|
+
- test/fixtures/site/ref3_3.ts
|
141
|
+
- test/scaffold_generator_test.rb
|
142
|
+
- test/support/routes.rb
|
143
|
+
- test/template_handler_test.rb
|
144
|
+
- test/test_helper.rb
|