FileManager @kubb/core
WARNING
Under construction
getEnvSource
See packages/core/src/managers/fileManager/utils.ts.
When using client
in for examples the plugin @kubb/swagger-client
the following things will happen:
- Read in
client.ts
- Copy paste
client.ts
to the output folder of the@kubb/swagger-client
plugin - Replace p
rocess.env[NAME] by a correct env set in the type File
❕environments should always be UPPERCASED
Example with process.env
typescript
import path from 'node:path'
const file: File = {
path: path.resolve('./src/models/file1.ts'),
fileName: 'file1.ts',
source: 'export const hello = process.env.HELLO; ',
imports: [
{
name: ['Pets'],
path: './Pets',
isTypeOnly: true,
},
],
env: {
HELLO: `"world"`,
},
}
import path from 'node:path'
const file: File = {
path: path.resolve('./src/models/file1.ts'),
fileName: 'file1.ts',
source: 'export const hello = process.env.HELLO;' ,
imports: [
{
name: ['Pets'],
path: './Pets',
isTypeOnly: true,
},
],
env: {
HELLO: `"world"`,
},
}
typescript
import type { Pets } from './Pets'
export const hello = 'world'
import type { Pets } from './Pets'
export const hello = 'world'
Example with globals
typescript
import path from 'node:path'
const file: File = {
path: path.resolve('./src/models/file1.ts'),
fileName: 'file1.ts',
source: 'declare const HELLO: string; export const hello = typeof HELLO !== "undefined" ? HELLO : undefined',
imports: [
{
name: ['Pets'],
path: './Pets',
isTypeOnly: true,
},
],
env: {
HELLO: `"world"`,
},
}
import path from 'node:path'
const file: File = {
path: path.resolve('./src/models/file1.ts'),
fileName: 'file1.ts',
source: 'declare const HELLO: string; export const hello = typeof HELLO !== "undefined" ? HELLO : undefined',
imports: [
{
name: ['Pets'],
path: './Pets',
isTypeOnly: true,
},
],
env: {
HELLO: `"world"`,
},
}
typescript
import type { Pets } from './Pets'
export const hello = typeof 'world' !== 'undefined' ? 'world' : undefined
import type { Pets } from './Pets'
export const hello = typeof 'world' !== 'undefined' ? 'world' : undefined