@ctx-core/env 16.1.44 → 16.3.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ctx-core/env
2
2
 
3
+ ## 16.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - - + import_meta_env__ensure: add proxy to process.env if import.meta.env is not present
8
+
9
+ ## 16.2.0
10
+
11
+ ### Minor Changes
12
+
13
+ - extract _.js & _.d.ts into directories
14
+
3
15
  ## 16.1.44
4
16
 
5
17
  ### Patch Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctx-core/env",
3
- "version": "16.1.44",
3
+ "version": "16.3.0",
4
4
  "description": "ctx-core env",
5
5
  "keywords": [
6
6
  "ctx-core",
@@ -1,5 +1,5 @@
1
- import { type WritableAtom_ } from '@ctx-core/nanostores'
2
- import { type B } from '@ctx-core/object'
1
+ import type { WritableAtom_ } from '@ctx-core/nanostores'
2
+ import type { B } from '@ctx-core/object'
3
3
  export declare const CACHE_VERSION__:B<WritableAtom_<false|string>>
4
4
  export {
5
5
  CACHE_VERSION__ as CACHE_VERSION$_,
@@ -1,9 +1,8 @@
1
1
  import { atom_ } from '@ctx-core/nanostores'
2
2
  import { be_ } from '@ctx-core/object'
3
- /** @type {import('./CACHE_VERSION__').CACHE_VERSION__} */
3
+ /** @type {typeof import('./index.d.ts').CACHE_VERSION__} */
4
4
  export const CACHE_VERSION__ = be_('CACHE_VERSION__', ()=>
5
- atom_(typeof process === 'object' && process.env.CACHE_VERSION)
6
- )
5
+ atom_(typeof process === 'object' && process.env.CACHE_VERSION))
7
6
  export {
8
7
  CACHE_VERSION__ as CACHE_VERSION$_,
9
8
  CACHE_VERSION__ as b__CACHE_VERSION,
@@ -1,5 +1,5 @@
1
- import { type WritableAtom_ } from '@ctx-core/nanostores'
2
- import { type B } from '@ctx-core/object'
1
+ import type { WritableAtom_ } from '@ctx-core/nanostores'
2
+ import type { B } from '@ctx-core/object'
3
3
  export declare const NODE_ENV__:B<WritableAtom_<string>>
4
4
  export {
5
5
  NODE_ENV__ as NODE_ENV$_,
@@ -1,7 +1,8 @@
1
1
  import { atom_ } from '@ctx-core/nanostores'
2
2
  import { be_ } from '@ctx-core/object'
3
- /** @type {import('NODE_ENV__').NODE_ENV__} */
4
- export const NODE_ENV__ = be_('NODE_ENV__', ()=>atom_(process.env.NODE_ENV))
3
+ /** @type {typeof import('./index.d.ts').NODE_ENV__} */
4
+ export const NODE_ENV__ = be_('NODE_ENV__', ()=>
5
+ atom_(process.env.NODE_ENV))
5
6
  export {
6
7
  NODE_ENV__ as NODE_ENV$_,
7
8
  NODE_ENV__ as b__NODE_ENV,
@@ -0,0 +1,4 @@
1
+ import type { WritableAtom_ } from '@ctx-core/nanostores'
2
+ import type { B } from '@ctx-core/object'
3
+ export declare const VERSION__:B<WritableAtom_<string>>
4
+ export { VERSION__ as VERSION$_ }
@@ -1,6 +1,6 @@
1
1
  import { atom_ } from '@ctx-core/nanostores'
2
2
  import { be_ } from '@ctx-core/object'
3
- /** @type {import('VERSION__').VERSION__} */
3
+ /** @type {typeof import('./index.d.ts').VERSION__} */
4
4
  export const VERSION__ = be_('VERSION__', ()=>
5
5
  atom_(
6
6
  typeof process === 'object' && (
@@ -0,0 +1,9 @@
1
+ export default function import_meta_env__ensure():ImportMetaEnv
2
+ declare global {
3
+ interface ImportMeta {
4
+ readonly env:ImportMetaEnv
5
+ }
6
+ }
7
+ interface ImportMetaEnv {
8
+ [key:string]:any;
9
+ }
@@ -0,0 +1,15 @@
1
+ export function import_meta_env__ensure() {
2
+ if (!import.meta.env) {
3
+ Object.assign(import.meta, {
4
+ env: new Proxy(process.env, {
5
+ get(target, prop, receiver) {
6
+ return Reflect.get(target, prop, receiver)
7
+ },
8
+ set(target, prop, value) {
9
+ return Reflect.get(target, prop, value)
10
+ }
11
+ })
12
+ })
13
+ }
14
+ return import.meta.env
15
+ }
package/src/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './CACHE_VERSION__'
2
+ export * from './import_meta_env__ensure'
2
3
  export * from './is_development__'
3
4
  export * from './is_production__'
4
5
  export * from './is_staging__'
package/src/index.js CHANGED
@@ -1,7 +1,8 @@
1
- export * from './CACHE_VERSION__.js'
2
- export * from './is_development__.js'
3
- export * from './is_production__.js'
4
- export * from './is_staging__.js'
5
- export * from './NODE_ENV__.js'
6
- export * from './throw_missing_env.js'
7
- export * from './VERSION__.js'
1
+ export * from './CACHE_VERSION__/index.js'
2
+ export * from './import_meta_env__ensure/index.js'
3
+ export * from './is_development__/index.js'
4
+ export * from './is_production__/index.js'
5
+ export * from './is_staging__/index.js'
6
+ export * from './NODE_ENV__/index.js'
7
+ export * from './throw_missing_env/index.js'
8
+ export * from './VERSION__/index.js'
@@ -1,4 +1,4 @@
1
- import { type ReadableAtom_ } from '@ctx-core/nanostores'
2
- import { type B } from '@ctx-core/object'
1
+ import type { ReadableAtom_ } from '@ctx-core/nanostores'
2
+ import type { B } from '@ctx-core/object'
3
3
  export declare const is_development__:B<ReadableAtom_<boolean>>
4
4
  export { is_development__ as is_development$_ }
@@ -1,11 +1,9 @@
1
1
  import { computed_ } from '@ctx-core/nanostores'
2
2
  import { be_ } from '@ctx-core/object'
3
- import { NODE_ENV__ } from './NODE_ENV__.js'
4
- /** @type {import('is_development__').is_development__} */
3
+ import { NODE_ENV__ } from '../NODE_ENV__/index.js'
4
+ /** @type {typeof import('./index.d.ts').is_development__} */
5
5
  export const is_development__ = be_('is_development__', ctx=>
6
6
  computed_(NODE_ENV__(ctx),
7
7
  (NODE_ENV)=>
8
- NODE_ENV === 'dev' || NODE_ENV === 'development'
9
- )
10
- )
8
+ NODE_ENV === 'dev' || NODE_ENV === 'development'))
11
9
  export { is_development__ as is_development$_ }
@@ -0,0 +1,8 @@
1
+ import type { ReadableAtom_ } from '@ctx-core/nanostores'
2
+ import type { B } from '@ctx-core/object'
3
+ export declare const is_production__:B<is_production__T>
4
+ export declare type is_production__T = ReadableAtom_<boolean>
5
+ export {
6
+ is_production__ as is_production$_,
7
+ is_production__ as b__is__production,
8
+ }
@@ -1,13 +1,11 @@
1
1
  import { computed_ } from '@ctx-core/nanostores'
2
2
  import { be_ } from '@ctx-core/object'
3
- import { NODE_ENV__ } from './NODE_ENV__.js'
4
- /** @type {import('is_production__').is_production__} */
3
+ import { NODE_ENV__ } from '../NODE_ENV__/index.js'
4
+ /** @type {typeof import('./index.d.ts').is_production__} */
5
5
  export const is_production__ = be_('is_production__', ctx=>
6
6
  computed_(NODE_ENV__(ctx),
7
7
  (NODE_ENV)=>
8
- NODE_ENV === 'prod' || NODE_ENV === 'production'
9
- )
10
- )
8
+ NODE_ENV === 'prod' || NODE_ENV === 'production'))
11
9
  export {
12
10
  is_production__ as is_production$_,
13
11
  is_production__ as b__is__production,
@@ -1,5 +1,5 @@
1
- import { type ReadableAtom_ } from '@ctx-core/nanostores'
2
- import { type B } from '@ctx-core/object'
1
+ import type { ReadableAtom_ } from '@ctx-core/nanostores'
2
+ import type { B } from '@ctx-core/object'
3
3
  export declare const is_staging__:B<ReadableAtom_<boolean>>
4
4
  export {
5
5
  is_staging__ as is_staging$_,
@@ -1,14 +1,13 @@
1
1
  import { eql_ } from '@ctx-core/function'
2
2
  import { computed_ } from '@ctx-core/nanostores'
3
3
  import { be_ } from '@ctx-core/object'
4
- import { NODE_ENV__ } from './NODE_ENV__.js'
5
- /** @type {import('is_staging__').is_staging__} */
4
+ import { NODE_ENV__ } from '../NODE_ENV__/index.js'
5
+ /** @type {typeof import('./index.d.ts').is_staging__} */
6
6
  export const is_staging__ = be_('is_staging__', ctx=>
7
7
  computed_(NODE_ENV__(ctx),
8
8
  eql_([
9
9
  'staging'
10
- ]))
11
- )
10
+ ])))
12
11
  export {
13
12
  is_staging__ as is_staging$_,
14
13
  is_staging__ as b__is__staging,
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Throws an error for a missing env variable
3
+ */
4
+ export declare function throw_missing_env(env_name:string):void
5
+ export { throw_missing_env as throw__missing__env }
@@ -1,6 +1,6 @@
1
1
  import { error__throw } from '@ctx-core/error'
2
2
  /**
3
- * Throws an error for for a missing env variable
3
+ * Throws an error for a missing env variable
4
4
  */
5
5
  /** @type {import('throw_missing_env').throw_missing_env} */
6
6
  export const throw_missing_env = (env_name)=>{
@@ -11,7 +11,7 @@ heroku: make sure ${env_name} is set using \`heroku config:set\`
11
11
  `.trim()
12
12
  error__throw({
13
13
  error_message,
14
- type: 'missing_env'
14
+ type: 'missing_env',
15
15
  })
16
16
  }
17
17
  export { throw_missing_env as throw__missing__env }
@@ -1,4 +0,0 @@
1
- import { type WritableAtom_ } from '@ctx-core/nanostores'
2
- import { type B } from '@ctx-core/object'
3
- export declare const VERSION__:B<WritableAtom_<string>>
4
- export { VERSION__ as VERSION$_ }
@@ -1,8 +0,0 @@
1
- import { type ReadableAtom_ } from '@ctx-core/nanostores'
2
- import { type B } from '@ctx-core/object'
3
- export declare const is_production__:B<is_production__T>
4
- export declare type is_production__T = ReadableAtom_<boolean>;
5
- export {
6
- is_production__ as is_production$_,
7
- is_production__ as b__is__production,
8
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Throws an error for for a missing env variable
3
- */
4
- export declare function throw_missing_env(env_name:string):void;
5
- export { throw_missing_env as throw__missing__env }