arkana 2.0.0 → 2.1.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: 191140e1234c08e36b1d1bb3591bac7b77041edd8b7e00565f15480fd47bfe81
4
- data.tar.gz: 8dd30c6bd576db0cd779b3f645cb9ec15541f5189dd71bd461c2f8895334a6e3
3
+ metadata.gz: 52db8a00775241c44fa0e1768eb111a694e32215b505ec8122491db0700973c9
4
+ data.tar.gz: 0fee4f39353e59be30345847795a1017b547d9bfb6118edb85bc370e07bd76cc
5
5
  SHA512:
6
- metadata.gz: a79924122cac3f3a32e471f49218ff85227fab2898821e56436a32d6c8e7e6d8cea1af20538e71eb010383ac47cef7266964ccc1a9251ee058538227ae5a9a2d
7
- data.tar.gz: dc8a20dfe2d1650cc14e1d3e8d24733229a795f8b6471272ff8d67cdaf72fd453925ea50d35d86386dfb1419c05fbf8910b8a7dbacbce4d80febed50883465cc
6
+ metadata.gz: dc8efcd05fd71b489a182688595d8fc8a29139cd7ca403c382940f9969cff1cb28fcd35b2a0998c9df588d9a88b155acd29d1963386b686f855c7d7ce0eec950
7
+ data.tar.gz: 182c8023f7b3d66bcda9e218d44ed0f78c79c9cfd8cc99f7861d8f74abe2484d699504a63bc71de5913f2c8357428d5fecfe1dba7efdd40e6f1b5b48236a5ffd
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "yaml"
3
+ require "yaml" unless defined?(YAML)
4
4
  require_relative "models/config"
5
5
  require_relative "helpers/ui"
6
6
 
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "arkana/helpers/string"
3
+ require_relative "helpers/string"
4
4
 
5
5
  # The encoder is responsible for finding the env vars for given keys, encoding them, and creating Secrets based on the generated data.
6
6
  module Encoder
@@ -26,10 +26,9 @@ module Encoder
26
26
  result << (byte ^ cipher[index % cipher.length]) # XOR operation with a value of the cipher array.
27
27
  end
28
28
 
29
- encoded_key = []
30
- result.each do |element|
29
+ encoded_key = result.map do |element|
31
30
  # Warning: this might be specific to Swift implementation. When generating code for other languages, beware.
32
- encoded_key << format("%#x", element) # Format the binary number to "0xAB" format.
31
+ format("%#x", element) # Format the binary number to "0xAB" format.
33
32
  end
34
33
 
35
34
  encoded_key.join(", ")
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "erb"
4
- require "fileutils"
3
+ require "erb" unless defined?(Erb)
4
+ require "fileutils" unless defined?(FileUtils)
5
5
  require_relative "helpers/string"
6
6
 
7
7
  # Responsible for generating Kotlin source and test files.
@@ -9,22 +9,27 @@ module KotlinCodeGenerator
9
9
  # Generates Kotlin code and test files for the given template arguments.
10
10
  def self.generate(template_arguments:, config:)
11
11
  kotlin_module_dir = config.result_path
12
- kotlin_sources_dir = File.join(kotlin_module_dir, "src", "main", config.kotlin_sources_path, config.kotlin_package_name.split("."))
13
- kotlin_tests_dir = File.join(kotlin_module_dir, "src", "test", config.kotlin_sources_path, config.kotlin_package_name.split("."))
12
+
13
+ source_set = config.is_kotlin_multiplatform_module ? "commonMain" : "main"
14
+ test_set = config.is_kotlin_multiplatform_module ? "commonTest" : "test"
15
+
16
+ kotlin_sources_dir = File.join(kotlin_module_dir, "src", source_set, config.kotlin_sources_path, config.kotlin_package_name.split("."))
17
+ kotlin_tests_dir = File.join(kotlin_module_dir, "src", test_set, config.kotlin_sources_path, config.kotlin_package_name.split("."))
14
18
 
15
19
  if config.should_generate_gradle_build_file
16
- set_up_kotlin_module(kotlin_module_dir, template_arguments)
20
+ set_up_kotlin_module(kotlin_module_dir, template_arguments, config)
17
21
  end
18
22
 
19
23
  set_up_kotlin_interfaces(kotlin_sources_dir, template_arguments, config)
20
24
  set_up_kotlin_classes(kotlin_sources_dir, kotlin_tests_dir, template_arguments, config)
21
25
  end
22
26
 
23
- def self.set_up_kotlin_module(path, template_arguments)
27
+ def self.set_up_kotlin_module(path, template_arguments, config)
24
28
  dirname = File.dirname(__FILE__)
25
29
  sources_dir = path
26
30
  readme_template = File.read("#{dirname}/templates/readme.erb")
27
- source_template = File.read("#{dirname}/templates/kotlin/build.gradle.kts.erb")
31
+ gradle_template_file = config.is_kotlin_multiplatform_module ? "build_kmp.gradle.kts.erb" : "build.gradle.kts.erb"
32
+ source_template = File.read("#{dirname}/templates/kotlin/#{gradle_template_file}")
28
33
  FileUtils.mkdir_p(path)
29
34
  render(readme_template, template_arguments, File.join(path, "README.md"))
30
35
  render(source_template, template_arguments, File.join(sources_dir, "build.gradle.kts"))
@@ -34,6 +34,8 @@ class Config
34
34
  attr_reader :should_generate_gradle_build_file
35
35
  # @returns [int]
36
36
  attr_reader :kotlin_jvm_toolchain_version
37
+ # @returns [boolean]
38
+ attr_reader :is_kotlin_multiplatform_module
37
39
 
38
40
  # @returns [string]
39
41
  attr_accessor :current_flavor
@@ -64,6 +66,8 @@ class Config
64
66
  @should_generate_gradle_build_file = yaml["should_generate_gradle_build_file"]
65
67
  @should_generate_gradle_build_file = true if @should_generate_gradle_build_file.nil?
66
68
  @kotlin_jvm_toolchain_version = yaml["kotlin_jvm_toolchain_version"] || 11
69
+ @is_kotlin_multiplatform_module = yaml["is_kotlin_multiplatform_module"]
70
+ @is_kotlin_multiplatform_module = false if @should_generate_gradle_build_file.nil?
67
71
  end
68
72
  # rubocop:enable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
69
73
 
@@ -10,10 +10,9 @@ class Salt
10
10
 
11
11
  def initialize(raw:)
12
12
  @raw = raw
13
- formatted_salt = []
14
- raw.each do |element|
13
+ formatted_salt = raw.map do |element|
15
14
  # Warning: this might be specific to Swift implementation. When generating code for other languages, beware.
16
- formatted_salt << format("%#x", element)
15
+ format("%#x", element)
17
16
  end
18
17
  @formatted = formatted_salt.join(", ")
19
18
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "arkana/models/secret"
3
+ require_relative "secret"
4
4
 
5
5
  # A class that defines template arguments in a language-agnostic form.
6
6
  class TemplateArguments
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "securerandom"
3
+ require "securerandom" unless defined?(SecureRandom)
4
4
  require_relative "models/salt"
5
5
 
6
6
  # Responsible for generating the salt.
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "erb"
4
- require "fileutils"
3
+ require "erb" unless defined?(Erb)
4
+ require "fileutils" unless defined?(FileUtils)
5
5
  require_relative "helpers/string"
6
6
 
7
7
  # Responsible for generating Swift source and test files.
@@ -13,7 +13,7 @@ object <%= @namespace %> {
13
13
  val decoded = encoded.mapIndexed { index, item ->
14
14
  (item xor cipher[(index % cipher.size)]).toByte()
15
15
  }.toByteArray()
16
- return decoded.toString(Charsets.UTF_8)
16
+ return decoded.decodeToString()
17
17
  }
18
18
 
19
19
  internal fun decodeInt(encoded: List<Int>, cipher: List<Int>): Int {
@@ -0,0 +1,28 @@
1
+ // DO NOT MODIFY
2
+ // Automatically generated by Arkana (https://github.com/rogerluan/arkana)
3
+
4
+ plugins {
5
+ id("org.jetbrains.kotlin.multiplatform")
6
+ }
7
+
8
+ kotlin {
9
+ jvm()
10
+ iosX64()
11
+ iosArm64()
12
+ iosSimulatorArm64()
13
+ linuxX64()
14
+ js {
15
+ browser()
16
+ nodejs()
17
+ }
18
+
19
+ sourceSets {
20
+ val commonTest by getting {
21
+ dependencies {
22
+ implementation(kotlin("test"))
23
+ }
24
+ }
25
+ }
26
+
27
+ jvmToolchain(<%= @kotlin_jvm_toolchain_version %>)
28
+ }
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Arkana
4
- VERSION = "2.0.0"
4
+ VERSION = "2.1.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arkana
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roger Oba
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-22 00:00:00.000000000 Z
11
+ date: 2024-06-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -84,6 +84,7 @@ files:
84
84
  - lib/arkana/templates/kotlin/arkana_protocol.kt.erb
85
85
  - lib/arkana/templates/kotlin/arkana_tests.kt.erb
86
86
  - lib/arkana/templates/kotlin/build.gradle.kts.erb
87
+ - lib/arkana/templates/kotlin/build_kmp.gradle.kts.erb
87
88
  - lib/arkana/templates/readme.erb
88
89
  - lib/arkana/templates/swift/arkana.podspec.erb
89
90
  - lib/arkana/templates/swift/arkana.swift.erb
@@ -117,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
118
  - !ruby/object:Gem::Version
118
119
  version: '0'
119
120
  requirements: []
120
- rubygems_version: 3.4.10
121
+ rubygems_version: 3.5.11
121
122
  signing_key:
122
123
  specification_version: 4
123
124
  summary: Store your keys and secrets away from your source code. Designed for Android