README
Basil - IC plugin
@spices/basil plugin
Installation
- Install the package →
yarn add @spices/basil-ic
- Install the plugin
import { basil, install } from '@spices/basil'
import { install as ic } from '@spices/basil-ic'
Vue.use(install)
basil.use(ic)
API
date
Transforms the different types of javascript (Date, Number, Object, String) into strandardized Date object for JavaScript
Syntax
basil.ic.date(value:[Date,Number,Object,String])
Examples
let value = '2021-06-01 13:40'
basil.ic.date(value) // Tue Jun 01 2021 13:40:00 GMT+0200 (Central European Summer Time)
let value = 1622547700000
basil.ic.date(value) // Tue Jun 01 2021 13:41:40 GMT+0200 (Central European Summer Time)
Parameters
value
Required
The value to convert. Must be a valid date.
Returns
A standard Date object in JavaScript
getEnvValue
Retrieve an environment variable provided at build or runtime. Returns a default value if none of the above values are available
Syntax
basil.ic.getEnvValue(name:String, options:Object{
defaultValue:*,
env:Boolean = false,
formatter:Function(value, name) = null,
fromBuild:Boolean = true,
fromExecution:Boolean = true,
kind:String = 'string'
})
Examples
process.env.APP_ID = 'abc123'
basil.ic.getEnvValue('app-id', { env: true, fromExecution: false, kind: 'string' }) // abc123
basil.ic.getEnvValue('not-present', { defaultValue: 'not-found-value' }) // not-found-value
Parameters
name
Required
The name of the environment variable to find
options.env
Whether or not to use the environment in the key. If set to true, a prefix containing the name of the environment will be added before the name of the key
options.formatter
Allows custom formatting of the value found
options.fromBuild
Whether or not to search in build variables
options.fromExecution
Whether or not to search in runtime variables
options.kind
How to return the value found. Possible values are:
basil.ic.Kinds.ARRAY
Returns the value as an arraybasil.ic.Kinds.FLOAT
Returns the value as a floating Numberbasil.ic.Kinds.INTEGER
Returns the value as an Integerbasil.ic.Kinds.OBJECT
Returns the value as an Objectbasil.ic.Kinds.STRING
Returns the value as an String
Returns
The value found according to the options in String format, according to the genre provided or according to the formatter
getBuildtimeValue
Retrieve an environment variable injected at buildtime (.env)
Syntax
basil.ic.getBuildtimeValue(key:String)
Examples
process.env.APP_ID = 'abc123'
basil.ic.getBuildtimeValue('app-id') // abc123
basil.ic.getBuildtimeValue('not-present') // null
Parameters
key
Required
The key to find
Returns
The value found in the process.env
getRuntimeValue
Retrieve an environment variable injected at runtime
Syntax
basil.ic.getRuntimeValue(key:String)
Examples
sayl('app-id', 'abc123')
basil.ic.getRuntimeValue('app-id') // abc123
basil.ic.getRuntimeValue('not-present') // null
Parameters
key
Required
The key to find
Returns
The value found