Swiftpack.co - simorgh3196/swift-secret-keys as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by simorgh3196.
simorgh3196/swift-secret-keys 0.1.0
A generator that allows access to environment variables and values defined in the properties file.
⭐️ 0
🕓 1 year ago
macOS
.package(url: "https://github.com/simorgh3196/swift-secret-keys.git", from: "0.1.0")

swift-secret-keys

SecretKeys SwiftLint

A generator that allows access to environment variables and values defined in the properties file.

Installation

Using Swift Package Manager (Command Plugin)

Installation:

Add a dependency to Package.swift.

.package(url: "https://github.com/simorgh3196/swift-secret-keys", from: "0.1.0"),

Execution:

swift package plugin --allow-writing-to-package-directory secret-keys generate

Using Mint

Installation:

Add the following to your Mintfile.

simorgh3196/[email protected]

Execution:

mint run secret-keys generate

Command Options

secret-keys generate --help
USAGE: secret-keys generate [--config <config>] [--project <project>] [--verbose]

OPTIONS:
  -c, --config <config>   The path to the configuration file (default: .secretkeys.yml)
  -p, --project <project> The path to the project root (default: .)
  -v, --verbose           Enables verbose log messages
  --version               Show the version.
  -h, --help              Show help information.

Usage

For a detailed example, see Example/CommandPluginExample.

Generate as Swift Package project

  1. Create a configuration file. (docs)

  2. Set exportType in the Configuration File to swiftpm.

  3. Run the generate command.

    <config:output>
    └── SecretKeys
       ├── .gitignore
       ├── Package.swift
       └── Sources
           ├── Keys
           │  ├── SecretKeys+Keys.swift # Specified in .gitignore by default
           │  └── SecretKeys.swift
           └── SecretValueDecoder
             └── SecretValueDecoder.swift
    
  4. Add a dependency to your project.

    .package(name: "SecretKeys", path: "Dependencies/SwiftPM/SecretKeys")
    

Generate as CocoaPods project

  1. Create a configuration file. (docs)

  2. Set exportType in the Configuration File to cocoapods.

  3. Run the generate command.

    <config:output>
    └── SecretKeys
       ├── .gitignore
       ├── Keys.podspec
       ├── SecretValueDecoder.podspec
       └── Sources
           ├── Keys
           │  ├── SecretKeys+Keys.swift # Specified in .gitignore by default
           │  └── SecretKeys.swift
           └── SecretValueDecoder
             └── SecretValueDecoder.swift
    
  4. Add a dependency to your project.

    pod 'Keys', :path => '<config:output>/SecretKeys'
    pod 'SecretValueDecoder', :path => '<config:output>/SecretKeys'
    

Generate as swift codes

  1. Create a configuration file. (docs)

  2. Set exportType in the Configuration File to sourcesOnly.

  3. Run the generate command.

    <config:output>
    └── SecretKeys
       ├── .gitignore
       ├── Keys
       │  └── Keys.generated.swift # Specified in .gitignore by default
       └── SecretValueDecoder.generated.swift # Specified in .gitignore by default
    
  4. Add swift codes to your project targets.

Configuration File

.secretkeys.yml

# Select the export type from `swiftpm`, `cocoapods` or `sourcesOnly`. (Default: `swiftpm`)
exportType: swiftpm

# The path of output directory. (Default: `Dependencies`)
output: Dependencies

# In addition to environment variables, a properties file can be read.
envFile: .env

# Set the target according to the environment and other requirements that
# you want to use different build modes, etc.
targets:
  SecretKeysDebug:
    namespace: MySecretKeys # can override namespace (Default: `Keys`)
    keys:
      clientID:
        name: CLIENT_ID_DEBUG
      clientSecret:
        name: CLIENT_SECRET_DEBUG
      apiPath:
        name: BASE_API_PATH
      home:
        name: HOME # can load environment variables

  SecretKeysProduction:
    keys:
      clientID:
        name: CLIENT_ID_PRODUCTION
        config:
          DEBUG: CLIENT_ID_ADHOC # can override `name` only when `#if DEBUG`
      clientSecret:
        name: CLIENT_SECRET_PRODUCTION
        config:
          DEBUG: CLIENT_SECRET_ADHOC
      apiPath:
        name: BASE_API_PATH

GitHub

link
Stars: 0
Last commit: 5 days ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics