bullet_train 1.2.3 → 1.2.5
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa2dfac5d71da28521ac903aef4acba2c5834f2da5c83ed89f4eb2dd1badf143
|
4
|
+
data.tar.gz: 7786d24e4271cf0547b495addefabbc46b0aaf58eb1672a3ab24ff5cb22a366e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf4cb1f74f1c85df573e544a7e6d03eac8d0db92a7fdb847de163d26527d153d7343cef139450e88d4d5332fe3728fbc9dc61f592ad84eeaf314bc40f378b40c
|
7
|
+
data.tar.gz: a347aa6b5e8234d6a90ce95a3c3e19e372597b45d4272e1e9a6feecc28bfbbfe5d9e24e6bc914ceb7e95eb8cdf9b187bc7a564ee30d8bd6c5f9d5e089ea62782
|
@@ -10,6 +10,18 @@ class SessionsController < Devise::SessionsController
|
|
10
10
|
end
|
11
11
|
helper_method :user_return_to_is_oauth
|
12
12
|
|
13
|
+
def new
|
14
|
+
# We allow people to pass in a URL to redirect to after sign in is complete. We have to do this because Safari
|
15
|
+
# doesn't allow them to set this in a session before a redirect if there isn't already a session. However, for
|
16
|
+
# security reasons we have to make sure we control the URL where we will redirect to, otherwise people could
|
17
|
+
# trick folks into redirecting to a fake destination in a phishing scheme.
|
18
|
+
if params[:return_url]&.start_with?(ENV["BASE_URL"])
|
19
|
+
store_location_for(resource_name, params[:return_url])
|
20
|
+
end
|
21
|
+
|
22
|
+
super
|
23
|
+
end
|
24
|
+
|
13
25
|
def destroy
|
14
26
|
if params.include?(:onboard_logout)
|
15
27
|
signed_out = (Devise.sign_out_all_scopes ? sign_out : sign_out(resource_name))
|
@@ -25,6 +25,8 @@ module Memberships::Base
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
scope :excluding_platform_agents, -> { where(platform_agent_of: nil) }
|
29
|
+
scope :platform_agents, -> { where.not(platform_agent_of: nil) }
|
28
30
|
scope :current_and_invited, -> { includes(:invitation).where("user_id IS NOT NULL OR invitations.id IS NOT NULL").references(:invitation) }
|
29
31
|
scope :current, -> { where("user_id IS NOT NULL") }
|
30
32
|
scope :tombstones, -> { includes(:invitation).where("user_id IS NULL AND invitations.id IS NULL AND platform_agent IS FALSE").references(:invitation) }
|
@@ -38,6 +38,12 @@ module Teams::Base
|
|
38
38
|
validates :time_zone, inclusion: {in: ActiveSupport::TimeZone.all.map(&:name)}, allow_nil: true
|
39
39
|
end
|
40
40
|
|
41
|
+
def platform_agent_access_tokens
|
42
|
+
# TODO This could be written better.
|
43
|
+
platform_agent_user_ids = memberships.platform_agents.map(&:user_id).compact
|
44
|
+
Platform::AccessToken.joins(:application).where(resource_owner_id: platform_agent_user_ids, application: {team: nil})
|
45
|
+
end
|
46
|
+
|
41
47
|
def admins
|
42
48
|
memberships.current_and_invited.admins
|
43
49
|
end
|
data/lib/bullet_train/version.rb
CHANGED
@@ -91,13 +91,15 @@ namespace :bullet_train do
|
|
91
91
|
puts ""
|
92
92
|
end
|
93
93
|
|
94
|
+
framework_packages = I18n.t("framework_packages")
|
95
|
+
|
94
96
|
# Process any flags that were passed.
|
95
97
|
if arguments[:all_options].present?
|
96
98
|
flags_with_values = []
|
97
99
|
|
98
100
|
arguments[:all_options].split(/\s+/).each do |option|
|
99
101
|
if option.match?(/^--/)
|
100
|
-
flags_with_values << {flag: option
|
102
|
+
flags_with_values << {flag: option, values: []}
|
101
103
|
else
|
102
104
|
flags_with_values.last[:values] << option
|
103
105
|
end
|
@@ -105,34 +107,27 @@ namespace :bullet_train do
|
|
105
107
|
|
106
108
|
if flags_with_values.any?
|
107
109
|
flags_with_values.each do |process|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
end
|
130
|
-
|
131
|
-
line
|
132
|
-
end
|
133
|
-
|
134
|
-
File.write("./Gemfile", new_lines.join)
|
135
|
-
system "bundle install"
|
110
|
+
case process[:flag]
|
111
|
+
when "--help"
|
112
|
+
puts "bin/hack: Clone bullet_train-core and link up gems (will only link up gems if already cloned).".blue
|
113
|
+
puts "bin/hack --link: Link all of your Bullet Train gems to `local/bullet_train-core`".blue
|
114
|
+
puts "bin/hack --reset: Resets all of your gems to their original definition.".blue
|
115
|
+
puts "bin/hack --watch-js: Watches for any changes in JavaScript files gems that have an npm package.".blue
|
116
|
+
puts "bin/hack --clean-js: Resets all of your npm packages from `local/bullet_train-core` to their original definition".blue
|
117
|
+
exit
|
118
|
+
when "--link", "--reset"
|
119
|
+
set_core_gems(process[:flag], framework_packages)
|
120
|
+
stream "bundle install"
|
121
|
+
when "--watch-js"
|
122
|
+
set_npm_packages(process[:flag], framework_packages)
|
123
|
+
|
124
|
+
puts "Proceeding to reset your Bullet Train npm packages according to your root directory's `package.json`.".yellow
|
125
|
+
puts "If you press `Ctrl + C` before the process completely exits, just run `bin/hack --clean-js`".yellow
|
126
|
+
set_npm_packages("--clean-js", framework_packages)
|
127
|
+
break
|
128
|
+
when "--clean-js"
|
129
|
+
set_npm_packages(process[:flag], framework_packages)
|
130
|
+
break
|
136
131
|
end
|
137
132
|
end
|
138
133
|
|
@@ -140,123 +135,147 @@ namespace :bullet_train do
|
|
140
135
|
end
|
141
136
|
end
|
142
137
|
|
143
|
-
|
138
|
+
puts "Welcome! Let's get hacking.".blue
|
144
139
|
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
puts " #{framework_packages.keys.find_index(gem) + 1}. #{gem}".blue
|
149
|
-
end
|
150
|
-
puts ""
|
151
|
-
puts "Enter a number below and hit <Enter>:".blue
|
152
|
-
number = $stdin.gets.chomp
|
140
|
+
# Adding these flags enables us to execute git commands in the gem from our starter repo.
|
141
|
+
work_tree_flag = "--work-tree=local/bullet_train-core"
|
142
|
+
git_dir_flag = "--git-dir=local/bullet_train-core/.git"
|
153
143
|
|
154
|
-
|
144
|
+
if File.exist?("local/bullet_train-core")
|
145
|
+
puts "We found the repository in `local/bullet_train-core`. We will try to use what's already there.".yellow
|
146
|
+
puts ""
|
155
147
|
|
156
|
-
|
157
|
-
|
158
|
-
|
148
|
+
git_status = `git #{work_tree_flag} #{git_dir_flag} status`
|
149
|
+
unless git_status.match?("nothing to commit, working tree clean")
|
150
|
+
puts "This package currently has uncommitted changes.".red
|
151
|
+
puts "Please make sure the branch is clean and try again.".red
|
152
|
+
exit
|
153
|
+
end
|
159
154
|
|
160
|
-
|
161
|
-
|
155
|
+
current_branch = `git #{work_tree_flag} #{git_dir_flag} branch`.split("\n").select { |branch_name| branch_name.match?(/^\*\s/) }.pop.gsub(/^\*\s/, "")
|
156
|
+
unless current_branch == "main"
|
157
|
+
puts "Previously on #{current_branch}.".blue
|
158
|
+
puts "Switching local/bullet_train-core to main branch.".blue
|
159
|
+
stream("git #{work_tree_flag} #{git_dir_flag} checkout main")
|
160
|
+
end
|
162
161
|
|
163
|
-
|
164
|
-
|
165
|
-
|
162
|
+
puts "Updating the main branch with the latest changes.".blue
|
163
|
+
stream("git #{work_tree_flag} #{git_dir_flag} pull origin main")
|
164
|
+
else
|
165
|
+
# Use https:// URLs when using this task in Gitpod.
|
166
|
+
stream "git clone #{(`whoami`.chomp == "gitpod") ? "https://github.com/" : "git@github.com:"}/bullet-train-co/bullet_train-core.git local/bullet_train-core"
|
167
|
+
end
|
166
168
|
|
167
|
-
|
168
|
-
|
169
|
-
|
169
|
+
stream("git #{work_tree_flag} #{git_dir_flag} fetch")
|
170
|
+
stream("git #{work_tree_flag} #{git_dir_flag} branch -r")
|
171
|
+
puts "The above is a list of remote branches.".blue
|
172
|
+
puts "If there's one you'd like to work on, please enter the branch name and press <Enter>.".blue
|
173
|
+
puts "If not, just press <Enter> to continue.".blue
|
174
|
+
input = $stdin.gets.strip
|
175
|
+
unless input.empty?
|
176
|
+
puts "Switching to #{input.gsub("origin/", "")}".blue # TODO: Should we remove origin/ here if the developer types it?
|
177
|
+
stream("git #{work_tree_flag} #{git_dir_flag} checkout #{input}")
|
178
|
+
end
|
170
179
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
puts "Please make sure the branch is clean and try again.".red
|
175
|
-
exit
|
176
|
-
end
|
180
|
+
# Link all of the local gems to the current Gemfile.
|
181
|
+
puts "Now we'll try to link up the Bullet Train core repositories in the `Gemfile`.".blue
|
182
|
+
set_core_gems("--link", framework_packages)
|
177
183
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
puts "Switching local/#{package} to main branch.".blue
|
182
|
-
stream("git #{work_tree_flag} #{git_dir_flag} checkout main")
|
183
|
-
end
|
184
|
+
puts ""
|
185
|
+
puts "Now we'll run `bundle install`.".blue
|
186
|
+
stream "bundle install"
|
184
187
|
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
# Use https:// URLs when using this task in Gitpod.
|
189
|
-
stream "git clone #{(`whoami`.chomp == "gitpod") ? "https://github.com/" : "git@github.com:"}#{details[:git]}.git local/#{package}"
|
190
|
-
end
|
188
|
+
puts ""
|
189
|
+
puts "We'll restart any running Rails server now.".blue
|
190
|
+
stream "rails restart"
|
191
191
|
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
puts "If not, just press <Enter> to continue.".blue
|
197
|
-
input = $stdin.gets.strip
|
198
|
-
unless input.empty?
|
199
|
-
puts "Switching to #{input.gsub("origin/", "")}".blue # TODO: Should we remove origin/ here if the developer types it?
|
200
|
-
stream("git #{work_tree_flag} #{git_dir_flag} checkout #{input}")
|
201
|
-
end
|
192
|
+
puts ""
|
193
|
+
puts "OK, we're opening bullet_train-core in your IDE, `#{ENV["IDE"] || "code"}`. (You can configure this with `export IDE=whatever`.)".blue
|
194
|
+
`#{ENV["IDE"] || "code"} local/bullet_train-core`
|
195
|
+
puts ""
|
202
196
|
|
203
|
-
|
204
|
-
|
205
|
-
|
197
|
+
puts "Bullet Train has a few npm packages, so we will and install those now.".blue
|
198
|
+
puts "We will also watch for any changes in your JavaScript files and recompile as we go.".blue
|
199
|
+
puts "When you're done, you can hit <Control + C> and we'll clean all off this up.".blue
|
200
|
+
puts ""
|
201
|
+
set_npm_packages("--watch-js", framework_packages)
|
206
202
|
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
}
|
203
|
+
# Clean up the npm packages after the developer enters `Ctrl + C`.
|
204
|
+
puts "Cleaning up npm packages...".blue
|
205
|
+
puts "If you cancel out of this process early, just run `bin/hack --clean-js` to revert to your original npm packages.".blue
|
206
|
+
set_npm_packages("--clean-js", framework_packages)
|
207
|
+
|
208
|
+
puts ""
|
209
|
+
puts "OK, here's a list of things this script still doesn't do you for you:".yellow
|
210
|
+
puts "1. It doesn't clean up the repository that was cloned into `local`.".yellow
|
211
|
+
puts "2. Unless you remove it, it won't update that repository the next time you link to it.".yellow
|
212
|
+
end
|
213
|
+
|
214
|
+
# Pass "--link" or "--reset" as a flag to set the gems.
|
215
|
+
def set_core_gems(flag, framework_packages)
|
216
|
+
packages = framework_packages.keys
|
217
|
+
gemfile_lines = File.readlines("./Gemfile")
|
218
|
+
new_lines = gemfile_lines.map do |line|
|
219
|
+
packages.each do |package|
|
220
|
+
if line.match?(/"#{package}"/)
|
221
|
+
original_path = "gem \"#{package}\""
|
222
|
+
local_path = "gem \"#{package}\", path: \"local/bullet_train-core/#{package}\""
|
223
|
+
|
224
|
+
case flag
|
225
|
+
when "--link"
|
226
|
+
if `cat Gemfile | grep "gem \\\"#{package}\\\", path: \\\"local/#{package}\\\""`.chomp.present?
|
227
|
+
puts "#{package} is already linked to a checked out copy in `local` in the `Gemfile`.".green
|
228
|
+
elsif `cat Gemfile | grep "gem \\\"#{package}\\\","`.chomp.present?
|
229
|
+
puts "#{package} already has some sort of alternative source configured in the `Gemfile`.".yellow
|
230
|
+
puts "We can't do anything with this. Sorry! We'll proceed, but you have to link this package yourself.".red
|
231
|
+
elsif `cat Gemfile | grep "gem \\\"#{package}\\\""`.chomp.present?
|
232
|
+
puts "#{package} is directly present in the `Gemfile`, so we'll update that line.".green
|
233
|
+
line.gsub!(original_path, local_path)
|
234
|
+
end
|
235
|
+
break
|
236
|
+
when "--reset"
|
237
|
+
line.gsub!(local_path, original_path)
|
238
|
+
puts "Resetting '#{package}' package in the Gemfile...".blue
|
239
|
+
break
|
240
|
+
end
|
241
|
+
end
|
225
242
|
end
|
243
|
+
line
|
244
|
+
end
|
226
245
|
|
227
|
-
|
228
|
-
|
229
|
-
stream "bundle install"
|
246
|
+
File.write("./Gemfile", new_lines.join)
|
247
|
+
end
|
230
248
|
|
231
|
-
|
232
|
-
|
233
|
-
stream "rails restart"
|
249
|
+
def set_npm_packages(flag, framework_packages)
|
250
|
+
packages = framework_packages.select { |k, v| v[:npm].present? }.compact
|
234
251
|
|
235
|
-
|
236
|
-
puts "
|
237
|
-
|
252
|
+
if flag == "--watch-js"
|
253
|
+
puts "Make sure your server is running before proceeding. When you're ready, press <Enter>".blue
|
254
|
+
$stdin.gets.strip
|
238
255
|
|
256
|
+
puts "Linking npm packages...".blue
|
239
257
|
puts ""
|
240
|
-
if details[:npm]
|
241
|
-
puts "This package also has an npm package, so we'll link that up as well.".blue
|
242
|
-
stream "cd local/#{gem} && yarn install && npm_config_yes=true npx yalc link && cd ../.. && npm_config_yes=true npx yalc link \"#{details[:npm]}\""
|
243
258
|
|
259
|
+
yarn_watch_command = []
|
260
|
+
packages.each do |package_name, details|
|
261
|
+
puts "Linking JavaScript for #{package_name}".blue
|
262
|
+
stream "cd local/bullet_train-core/#{package_name} && yarn install && npm_config_yes=true && npx yalc link && cd ../../.. && npm_config_yes=true npx yalc link \"#{details[:npm]}\""
|
263
|
+
puts "#{package_name} has been linked.".blue
|
244
264
|
puts ""
|
245
|
-
|
246
|
-
puts "When you're done, you can hit <Control + C> and we'll clean all off this up.".blue
|
247
|
-
stream "cd local/#{gem} && yarn watch"
|
248
|
-
else
|
249
|
-
puts "This package has no npm package, so we'll just hang out here and do nothing. However, when you hit <Enter> here, we'll start the process of cleaning all of this up.".blue
|
250
|
-
$stdin.gets
|
265
|
+
yarn_watch_command << "yarn --cwd local/bullet_train-core/#{package_name} watch"
|
251
266
|
end
|
252
267
|
|
268
|
+
# We use `&` to run the processes in parallel.
|
269
|
+
puts "Preparing to watch changes".blue
|
270
|
+
stream yarn_watch_command.join(" & ")
|
271
|
+
elsif flag == "--clean-js"
|
272
|
+
puts "Resetting packages to their original path".blue
|
253
273
|
puts ""
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
puts "Invalid option, \"#{number}\". Try again.".red
|
274
|
+
|
275
|
+
packages.each do |package_name, details|
|
276
|
+
system "yarn yalc remove #{details[:npm]}"
|
277
|
+
system "yarn add #{details[:npm]}"
|
278
|
+
end
|
260
279
|
end
|
261
280
|
end
|
262
281
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bullet_train
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Culver
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: standard
|