Skip to content

Commit

Permalink
fix: fixed failing tests due to TypeScript Refactoring
Browse files Browse the repository at this point in the history
Co-authored-by: Thomas Lane <[email protected]>
  • Loading branch information
wconrad265 and tlane25 committed Nov 1, 2024
1 parent c5054d7 commit 510cba9
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 15 deletions.
9 changes: 5 additions & 4 deletions src/commands/deploy/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,13 @@ const validateDeployFolder = async (deployFolder: string) => {
return error('Permission error when trying to access deploy folder')
}
}
throw error_
}

// @ts-expect-error TS(2339) FIXME: Property 'isDirectory' does not exist on type 'Stats'.
if (!stats.isDirectory()) {
return error('Deploy target must be a path to a directory')
}
// @ts-expect-error TS(2339) FIXME: Property 'isDirectory' does not exist on type 'Stats'.
return stats
}

Expand Down Expand Up @@ -784,9 +785,9 @@ const prepAndRunDeploy = async ({
siteEnv,
})

if (functionsFolder === undefined) {
throw new Error('Functions folder is undefined')
}
// if (functionsFolder === undefined) {
// throw new Error('Functions folder is undefined')
// }

const results = await runDeploy({
alias,
Expand Down
7 changes: 4 additions & 3 deletions src/commands/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,10 @@ export type EnvironmentVariableScope = 'builds' | 'functions' | 'runtime' | 'pos
export type EnvironmentVariableSource = 'account' | 'addons' | 'configFile' | 'general' | 'internal' | 'ui'


type EnviromentVariables = {
[key: string]: string
}
type EnviromentVariables = Record<string, {
sources: EnvironmentVariableSource[];
value: string;
}>;

export type EnvironmentVariables = Record<string, { sources: EnvironmentVariableSource[], value: string; scopes?: EnvironmentVariableScope[] }>
/**
Expand Down
11 changes: 3 additions & 8 deletions src/utils/env/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
Scope,
EnvironmentVariableSource,
EnvironmentVariableScope,
EnvironmentVariables,
} from '../../commands/types.js'
import { error } from '../command-helpers.js'
import { APIEnvError } from '../types.js'
Expand Down Expand Up @@ -59,14 +60,8 @@ export const findValueInValues = (values, context) =>
return [context, 'all'].includes(val.context)
})

/**
* Finds environment variables that match a given source
* @param {object} env - The dictionary of environment variables
* @param {enum<general,account,addons,ui,configFile>} source - The source of the environment variable
* @returns {object} The dictionary of env vars that match the given source
*/
export const filterEnvBySource = (env: EnviromentVariables, source: EnvironmentVariableSource) =>
Object.fromEntries(Object.entries(env).filter(([, variable]) => variable.sources[0] === source))
Object.fromEntries(Object.entries(env || {}).filter(([, variable]) => variable.sources[0] === source))

// Fetches data from Envelope
const fetchEnvelopeItems = async function ({
Expand Down Expand Up @@ -174,7 +169,7 @@ export const getEnvelopeEnv = async ({
raw = false,
scope = 'any',
siteInfo,
}: GetEnvelopeEnvParams): Promise<ProcessedEnvVars> => {
}: GetEnvelopeEnvParams): Promise<EnvironmentVariables> => {
const { account_slug: accountId, id: siteId } = siteInfo

const [accountEnvelopeItems, siteEnvelopeItems] = await Promise.all([
Expand Down
1 change: 1 addition & 0 deletions src/utils/env/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { SiteInfo } from "../../types/api/api.js"
import { Context, EnvironmentVariableSource, EnvironmentVariableScope } from "../../commands/types.js"
import { EnvironmentVariables } from "../../commands/types.js"

export interface GetEnvelopeEnvParams {
api: ExtendedNetlifyAPI,
Expand Down

0 comments on commit 510cba9

Please sign in to comment.