foobara-typescript-remote-command-generator 1.5.0 → 1.5.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/src/generate_typescript.rb +14 -7
- data/src/generators/typescript_from_manifest_base_generator.rb +2 -0
- data/src/remote_generator.rb +15 -0
- data/src/write_typescript_to_disk.rb +2 -0
- data/templates/Domain/config.ts.erb +1 -1
- data/templates/Organization/config.ts.erb +1 -1
- data/templates/base/RemoteCommand.ts.erb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3ea5e21e87c906d2b3605a56ef2a49245d7eb47266909cd6763c3272872e3ce3
|
|
4
|
+
data.tar.gz: 02fb6e36dce4acd76a517f42c6950617a80350bd570708321877daf7d523005e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c73ce6914c21030225dc6b29a27c49e9e0828e6dcb4c6e0ff96c66c63a50b989480dd66bbb67d5f982c84934057cd5ee6024893a1cf36125f82a3aa9f997f7eb
|
|
7
|
+
data.tar.gz: 75a7d0058162533cce17ec2a3b8693bbd19c2f9f30f7cb43dbd960dfdf19aa5c6cb83dceb15c6e5882c80e9a7adc4ff995cc5233a2e79ea69c31402d2c156a69
|
data/CHANGELOG.md
CHANGED
data/src/generate_typescript.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
require "net/http"
|
|
2
2
|
require "uri"
|
|
3
3
|
|
|
4
|
+
require_relative "remote_generator"
|
|
5
|
+
|
|
4
6
|
module Foobara
|
|
5
7
|
module RemoteGenerator
|
|
6
8
|
class GenerateTypescript < Foobara::Generators::Generate
|
|
@@ -16,10 +18,11 @@ module Foobara
|
|
|
16
18
|
default: false,
|
|
17
19
|
description: "Never generate Foobara::Auth's RequiresAuthCommand, even if the " \
|
|
18
20
|
"manifest contains that domain. For apps that import it from elsewhere."
|
|
21
|
+
env_expression :env_expression, default: "import.meta.env"
|
|
19
22
|
end
|
|
20
23
|
|
|
21
24
|
def execute
|
|
22
|
-
|
|
25
|
+
apply_remote_generator_config do
|
|
23
26
|
load_manifest_if_needed
|
|
24
27
|
|
|
25
28
|
include_non_templated_files
|
|
@@ -36,6 +39,16 @@ module Foobara
|
|
|
36
39
|
paths_to_source_code
|
|
37
40
|
end
|
|
38
41
|
|
|
42
|
+
def apply_remote_generator_config
|
|
43
|
+
RemoteGenerator.no_foobara_auth(no_foobara_auth) do
|
|
44
|
+
RemoteGenerator.auto_dirty_queries(auto_dirty_queries) do
|
|
45
|
+
RemoteGenerator.with_env_expression(env_expression) do
|
|
46
|
+
yield
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
39
52
|
def validate
|
|
40
53
|
if raw_manifest.nil? && manifest_url.nil?
|
|
41
54
|
# simplecov:disable
|
|
@@ -83,12 +96,6 @@ module Foobara
|
|
|
83
96
|
end
|
|
84
97
|
end
|
|
85
98
|
|
|
86
|
-
def generate_element
|
|
87
|
-
RemoteGenerator.auto_dirty_queries(auto_dirty_queries) do
|
|
88
|
-
super
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
|
|
92
99
|
def add_root_manifest_to_set_of_elements_to_generate
|
|
93
100
|
elements_to_generate << manifest
|
|
94
101
|
end
|
data/src/remote_generator.rb
CHANGED
|
@@ -2,6 +2,8 @@ module Foobara
|
|
|
2
2
|
module RemoteGenerator
|
|
3
3
|
foobara_domain!
|
|
4
4
|
|
|
5
|
+
foobara_register_type(:env_expression, :string, one_of: ["import.meta.env", "process.env"])
|
|
6
|
+
|
|
5
7
|
class << self
|
|
6
8
|
def auto_dirty_queries(auto_dirty_queries)
|
|
7
9
|
if auto_dirty_queries == @auto_dirty_queries
|
|
@@ -35,6 +37,19 @@ module Foobara
|
|
|
35
37
|
def no_foobara_auth?
|
|
36
38
|
@no_foobara_auth
|
|
37
39
|
end
|
|
40
|
+
|
|
41
|
+
def with_env_expression(env_expression)
|
|
42
|
+
old = @env_expression
|
|
43
|
+
|
|
44
|
+
begin
|
|
45
|
+
@env_expression = env_expression
|
|
46
|
+
yield
|
|
47
|
+
ensure
|
|
48
|
+
@env_expression = old
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
attr_reader :env_expression
|
|
38
53
|
end
|
|
39
54
|
end
|
|
40
55
|
end
|
|
@@ -19,6 +19,7 @@ module Foobara
|
|
|
19
19
|
default: false,
|
|
20
20
|
description: "Never generate Foobara::Auth's RequiresAuthCommand, even if the " \
|
|
21
21
|
"manifest contains that domain. For apps that import it from elsewhere."
|
|
22
|
+
env_expression :env_expression, default: "import.meta.env"
|
|
22
23
|
end
|
|
23
24
|
|
|
24
25
|
possible_error :missing_manifest
|
|
@@ -56,6 +57,7 @@ module Foobara
|
|
|
56
57
|
|
|
57
58
|
inputs[:auto_dirty_queries] = auto_dirty_queries
|
|
58
59
|
inputs[:no_foobara_auth] = no_foobara_auth
|
|
60
|
+
inputs[:env_expression] = env_expression
|
|
59
61
|
|
|
60
62
|
self.paths_to_source_code = run_subcommand!(GenerateTypescript, inputs)
|
|
61
63
|
end
|
|
@@ -15,7 +15,7 @@ export default abstract class RemoteCommand<Inputs, Result, CommandError extends
|
|
|
15
15
|
let base = this._urlBase
|
|
16
16
|
|
|
17
17
|
if (base == null) {
|
|
18
|
-
base =
|
|
18
|
+
base = <%= env_expression %>.REACT_APP_FOOBARA_GLOBAL_URL_BASE
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
if (base == null) {
|