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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3665400333aa868dea13a4812bfc7cfbaf13e1475d3823eac5824566b4e4bb2b
4
- data.tar.gz: 764d0161640c99f2b5bfbe8f92f985455509c4a211e15703eb0bbfe1d38b043e
3
+ metadata.gz: 3ea5e21e87c906d2b3605a56ef2a49245d7eb47266909cd6763c3272872e3ce3
4
+ data.tar.gz: 02fb6e36dce4acd76a517f42c6950617a80350bd570708321877daf7d523005e
5
5
  SHA512:
6
- metadata.gz: aa6643f0ff7c9661cc37f9294b50fbe28d52de56b8c2a34e4b549f085d026e76c3f38a84b42ee9004e1d911b7c7f302961999a819e3e796905330fa046f247e1
7
- data.tar.gz: 70ec01c2a3664fcd68a973baa7b2ae5c9e5a519b0aac8067aade428307911bf035e388f84b249f4ac66486f5dc8867c2f1bb34f935e3ff8a04eed88fe815fcbf
6
+ metadata.gz: c73ce6914c21030225dc6b29a27c49e9e0828e6dcb4c6e0ff96c66c63a50b989480dd66bbb67d5f982c84934057cd5ee6024893a1cf36125f82a3aa9f997f7eb
7
+ data.tar.gz: 75a7d0058162533cce17ec2a3b8693bbd19c2f9f30f7cb43dbd960dfdf19aa5c6cb83dceb15c6e5882c80e9a7adc4ff995cc5233a2e79ea69c31402d2c156a69
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## [1.5.1] - 2026-08-22
2
+
3
+ - Allow setting the env expression to either import.meta.env or process.env with --env-expression
4
+
1
5
  ## [1.5.0] - 2026-08-06
2
6
 
3
7
  - Only generate RequiresAuthCommand when its imports will exist
@@ -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
- RemoteGenerator.no_foobara_auth(no_foobara_auth) do
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
@@ -454,6 +454,8 @@ module Foobara
454
454
  def auto_dirty_queries?
455
455
  RemoteGenerator.auto_dirty_queries?
456
456
  end
457
+
458
+ def env_expression = RemoteGenerator.env_expression
457
459
  end
458
460
  end
459
461
  end
@@ -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
@@ -1,4 +1,4 @@
1
- let _urlBase = import.meta.env.REACT_APP_FOOBARA_GLOBAL_URL_BASE
1
+ let _urlBase = <%= env_expression %>.REACT_APP_FOOBARA_GLOBAL_URL_BASE
2
2
 
3
3
  const config = {
4
4
  get urlBase(): string {
@@ -1,4 +1,4 @@
1
- let _urlBase = import.meta.env.REACT_APP_FOOBARA_GLOBAL_URL_BASE
1
+ let _urlBase = <%= env_expression %>.REACT_APP_FOOBARA_GLOBAL_URL_BASE
2
2
 
3
3
  const config = {
4
4
  get urlBase(): string {
@@ -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 = import.meta.env.REACT_APP_FOOBARA_GLOBAL_URL_BASE
18
+ base = <%= env_expression %>.REACT_APP_FOOBARA_GLOBAL_URL_BASE
19
19
  }
20
20
 
21
21
  if (base == null) {
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foobara-typescript-remote-command-generator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Miles Georgi