create_component 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/component +14 -13
- data/create_component.gemspec +1 -1
- data/lib/create_component/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15679e02588019cbb86cbf430efc0c907f03236c
|
4
|
+
data.tar.gz: 906c148d941162392d7354bdb31f7eabe8c73f32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc9e6a1dfe3e4afdd5e1375e2bac708b17b8fa75c24ba31983665040fa2724c037afc6ad9567cbb0c5eaf46f3af0eb461a87b54517b8c1c02f5f26ce4f39a176
|
7
|
+
data.tar.gz: b7a06c49bc91b9981d363bcffc916db61cb8afbaf9e87c9f412a003ed913635b7741ab67eaa168a9db22d6f7963f69496e513482e7fec68bd3316d2286aef0c6
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Simple script to avoid creating folders and typing React component boilerplate code.
|
4
4
|
|
5
|
-
Provided that on your project's root directory you have a sub-directory `/src/components`, this script will create a folder with the name of the component with two files inside.
|
5
|
+
Provided that on your project's **root** directory you have a sub-directory `/src` or `/src/components`, this script will create a folder with the name of the component with two files inside.
|
6
6
|
|
7
7
|
**MyComponent.js**
|
8
8
|
```
|
data/bin/component
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
exit(1)
|
2
|
+
unless !ARGV.empty?
|
3
|
+
puts 'No component name was given.'
|
4
|
+
exit(1)
|
6
5
|
end
|
7
6
|
|
8
7
|
component = ARGV[0]
|
@@ -12,12 +11,12 @@ index_js = "index.js"
|
|
12
11
|
# Changes directory to 'src/components/' or 'src/'
|
13
12
|
root = Dir.pwd
|
14
13
|
unless Dir.exist?("#{root}/src")
|
15
|
-
|
16
|
-
|
14
|
+
puts "Directory src doesn't exist."
|
15
|
+
exit(1)
|
17
16
|
end
|
18
17
|
|
19
18
|
destination = "/src/components"
|
20
|
-
|
19
|
+
unless Dir.exist?("#{root}#{destination}")
|
21
20
|
destination = "/src"
|
22
21
|
end
|
23
22
|
Dir.chdir("#{root}#{destination}")
|
@@ -32,17 +31,19 @@ system("touch #{index_js}")
|
|
32
31
|
|
33
32
|
# index.js
|
34
33
|
contents = "export { default } from './#{component}';"
|
35
|
-
open(index_js, 'a') do |
|
36
|
-
|
34
|
+
open(index_js, 'a') do |file|
|
35
|
+
file << contents
|
36
|
+
file << "\n"
|
37
37
|
end
|
38
38
|
|
39
39
|
# Component.js
|
40
40
|
import_react_statement = "import React from 'react';"
|
41
41
|
export_default_statement = "export default;"
|
42
|
-
open(component_js, 'a') do |
|
43
|
-
|
44
|
-
|
45
|
-
|
42
|
+
open(component_js, 'a') do |file|
|
43
|
+
file << import_react_statement
|
44
|
+
file << "\n"
|
45
|
+
file << export_default_statement
|
46
|
+
file << "\n"
|
46
47
|
end
|
47
48
|
|
48
49
|
puts "#{component_js} and #{index_js} created succesfully at #{destination}!"
|
data/create_component.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["frankkair@gmail.com"]
|
11
11
|
|
12
12
|
spec.summary = "Simple script to create React components."
|
13
|
-
spec.description = "
|
13
|
+
spec.description = "Script to create React components."
|
14
14
|
spec.homepage = "https://github.com/FrankKair/create-component"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: create_component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Kair
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-08-
|
11
|
+
date: 2017-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
-
description:
|
41
|
+
description: Script to create React components.
|
42
42
|
email:
|
43
43
|
- frankkair@gmail.com
|
44
44
|
executables:
|