Skip to content
This repository was archived by the owner on May 13, 2025. It is now read-only.

Commit 055c78c

Browse files
authored
Merge pull request #6 from TwilioDevEd/upgrade-structure
Update structure and add webpacker
2 parents 3d55632 + 94614f5 commit 055c78c

33 files changed

+17339
-58
lines changed

.browserslistrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
defaults

.github/workflows/ruby.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ jobs:
4949
gem install bundler
5050
bundle config path vendor/bundle
5151
bundle install --jobs 4 --retry 3
52+
- name: Setup Node
53+
uses: actions/setup-node@v1
54+
with:
55+
node-version: 12.13.1
56+
- name: Install packages
57+
run: |
58+
npm install
5259
- name: Run tests
5360
run: |
5461
cp .env.example .env

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,10 @@ build-iPhoneSimulator/
8585
.rvmrc
8686

8787
.tool-versions
88+
89+
/public/packs
90+
/public/packs-test
91+
/node_modules
92+
/yarn-error.log
93+
yarn-debug.log*
94+
.yarn-integrity

Dockerfile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ COPY Gemfile ./
66

77
COPY Makefile ./
88

9-
RUN make install
10-
11-
COPY . .
12-
139
# Install a Javascript environment in the container to avoid ExecJS::RuntimeUnavailable
1410
RUN curl -sL https://deb.nodesource.com/setup_10.x | bash - \
1511
&& apt install -y nodejs
1612

13+
RUN make install
14+
15+
COPY . .
16+
1717
RUN make database
1818

1919
EXPOSE 3000

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,5 @@ end
5959

6060
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
6161
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
62+
63+
gem "webpacker"

Gemfile.lock

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ GEM
111111
puma (4.3.5)
112112
nio4r (~> 2.0)
113113
rack (2.2.3)
114+
rack-proxy (0.6.5)
115+
rack
114116
rack-test (1.1.0)
115117
rack (>= 1.0, < 3)
116118
rails (6.0.3.2)
@@ -153,6 +155,7 @@ GEM
153155
sprockets (> 3.0)
154156
sprockets-rails
155157
tilt
158+
semantic_range (2.3.0)
156159
spring (2.1.0)
157160
spring-watcher-listen (2.0.1)
158161
listen (>= 2.7, < 4.0)
@@ -184,6 +187,11 @@ GEM
184187
activemodel (>= 6.0.0)
185188
bindex (>= 0.4.0)
186189
railties (>= 6.0.0)
190+
webpacker (5.1.1)
191+
activesupport (>= 5.2)
192+
rack-proxy (>= 0.6.1)
193+
railties (>= 5.2)
194+
semantic_range (>= 2.3.0)
187195
websocket-driver (0.7.2)
188196
websocket-extensions (>= 0.1.0)
189197
websocket-extensions (0.1.5)
@@ -212,6 +220,7 @@ DEPENDENCIES
212220
tzinfo-data
213221
uglifier (>= 4.2.0)
214222
web-console (>= 4.0.1)
223+
webpacker
215224

216225
BUNDLED WITH
217226
2.1.4

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
.PHONY: install database serve
33

44
install:
5-
bundle install
5+
bundle install; \
6+
npm install;
67

78
database:
89
bundle exec rails db:migrate

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
![](https://github.com/TwilioDevEd/verify-v2-quickstart-rails/workflows/Ruby/badge.svg)
88

9-
> We are currently in the process of updating this sample template. If you are encountering any issues with the sample, please open an issue at [github.com/twilio-labs/code-exchange/issues](https://github.com/twilio-labs/code-exchange/issues) and we'll try to help you.
9+
> This template is part of Twilio CodeExchange. If you encounter any issues with this code, please open an issue at [github.com/twilio-labs/code-exchange/issues](https://github.com/twilio-labs/code-exchange/issues).
1010
1111
## About
1212

@@ -25,7 +25,8 @@ Implementations in other languages:
2525
### Requirements
2626

2727
- [Ruby](https://www.ruby-lang.org/) **2.6.x** version.
28-
- [Sqlite3](https://www.sqlite.org/)
28+
- [Sqlite3](https://www.sqlite.org/).
29+
- [Node.js](https://nodejs.org/en/) **10.x** or **12.x** version.
2930

3031
### Twilio Account Settings
3132

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/* eslint no-console:0 */
2+
// This file is automatically compiled by Webpack, along with any other files
3+
// present in this directory. You're encouraged to place your actual application logic in
4+
// a relevant structure within app/javascript and only use these pack files to reference
5+
// that code so it'll be compiled.
6+
//
7+
// To reference this file, add <%= javascript_pack_tag 'application' %> to the appropriate
8+
// layout file, like app/views/layouts/application.html.erb
9+
10+
11+
// Uncomment to copy all static images under ../images to the output folder and reference
12+
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
13+
// or the `imagePath` JavaScript helper below.
14+
//
15+
// const images = require.context('../images', true)
16+
// const imagePath = (name) => images(name, true)
17+
18+
console.log('Hello World from Webpacker')

babel.config.js

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
module.exports = function(api) {
2+
var validEnv = ['development', 'test', 'production']
3+
var currentEnv = api.env()
4+
var isDevelopmentEnv = api.env('development')
5+
var isProductionEnv = api.env('production')
6+
var isTestEnv = api.env('test')
7+
8+
if (!validEnv.includes(currentEnv)) {
9+
throw new Error(
10+
'Please specify a valid `NODE_ENV` or ' +
11+
'`BABEL_ENV` environment variables. Valid values are "development", ' +
12+
'"test", and "production". Instead, received: ' +
13+
JSON.stringify(currentEnv) +
14+
'.'
15+
)
16+
}
17+
18+
return {
19+
presets: [
20+
isTestEnv && [
21+
'@babel/preset-env',
22+
{
23+
targets: {
24+
node: 'current'
25+
}
26+
}
27+
],
28+
(isProductionEnv || isDevelopmentEnv) && [
29+
'@babel/preset-env',
30+
{
31+
forceAllTransforms: true,
32+
useBuiltIns: 'entry',
33+
corejs: 3,
34+
modules: false,
35+
exclude: ['transform-typeof-symbol']
36+
}
37+
]
38+
].filter(Boolean),
39+
plugins: [
40+
'babel-plugin-macros',
41+
'@babel/plugin-syntax-dynamic-import',
42+
isTestEnv && 'babel-plugin-dynamic-import-node',
43+
'@babel/plugin-transform-destructuring',
44+
[
45+
'@babel/plugin-proposal-class-properties',
46+
{
47+
loose: true
48+
}
49+
],
50+
[
51+
'@babel/plugin-proposal-object-rest-spread',
52+
{
53+
useBuiltIns: true
54+
}
55+
],
56+
[
57+
'@babel/plugin-transform-runtime',
58+
{
59+
helpers: false,
60+
regenerator: true,
61+
corejs: false
62+
}
63+
],
64+
[
65+
'@babel/plugin-transform-regenerator',
66+
{
67+
async: false
68+
}
69+
]
70+
].filter(Boolean)
71+
}
72+
}

0 commit comments

Comments
 (0)