-
Notifications
You must be signed in to change notification settings - Fork 361
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: updates to typescript w/n the env command #6905
Open
tlane25
wants to merge
15
commits into
netlify:main
Choose a base branch
from
wconrad265:TypeScript
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
e7447a2
fix: add types to env commands
wconrad265 76fab2b
feat: updated types for api and env
wconrad265 8a30660
fix: prettier fix
wconrad265 113cf8b
feat: added types for the env commands
wconrad265 0a5a07e
fix: prettier
wconrad265 a7a8f40
feat: env-clone types update in progress
wconrad265 8267aa5
feat: more types in
54f664f
fix: prettier
0a23af1
feat: finished adding types for Env folder
wconrad265 2fecfa3
fix: update error Type
wconrad265 796367f
fix: fixed Type issues for tests
wconrad265 c4c60fd
Merge remote-tracking branch 'origin/main' into TypeScript
tlane25 c06b36e
fix: prettier
tlane25 f0fecd4
Merge branch 'main' into TypeScript
wconrad265 80e88e6
chore: more explicit type names
tlane25 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,213 @@ | ||
import type { NetlifyAPI } from 'netlify' | ||
|
||
import { DeployContext } from './types.d.ts' | ||
|
||
type ApiContext = DeployContext | 'branch' | ||
|
||
interface UpdatedBy { | ||
id: string; | ||
full_name: string; | ||
email: string; | ||
avatar_url: string; | ||
} | ||
|
||
export type NarrowedEnvVarValue = Pick<EnvVarValue, 'value' | 'context' | 'context_parameter'> | ||
|
||
interface EnvVarValue { | ||
value: string, | ||
context: ApiContext, | ||
context_parameter?: string, | ||
id?: string, | ||
} | ||
|
||
export interface EnvVar { | ||
key: string; | ||
scopes: Scope[]; | ||
values: EnvVarValue[]; | ||
is_secret?: boolean; | ||
updated_at?: string; | ||
updated_by?: UpdatedBy; | ||
} | ||
|
||
interface GetEnvParams { | ||
accountId: string, | ||
siteId?: string, | ||
context?: DeployContext, | ||
scope?: EnvironmentVariableScope | ||
} | ||
|
||
interface DeleteEnvVarValueParams { | ||
accountId: string, | ||
key: string, | ||
id?: string, | ||
siteId?: string | ||
} | ||
|
||
interface SetEnvVarValueBody { | ||
context: string, | ||
value: string, | ||
contextParameter?: string, | ||
} | ||
|
||
interface SetEnvVarValueParams { | ||
accountId: string, | ||
key: string, | ||
siteId?: string, | ||
body: SetEnvVarValueBody | ||
} | ||
|
||
interface UpdateEnvVarBody { | ||
key: string, | ||
scopes: string[], | ||
values: EnvVar[] | ||
is_secret: boolean | ||
} | ||
|
||
interface UpdateEnvVarParams { | ||
accountId: string, | ||
key: string, | ||
siteId?: string | ||
body: EnvVar | ||
} | ||
|
||
interface CreateEnvVarParams { | ||
accountId: string, | ||
key?: string, | ||
siteId?: string, | ||
body: EnvVar[] | ||
} | ||
|
||
interface SiteInfo { | ||
id: string; | ||
state: string; | ||
plan: string; | ||
name: string; | ||
custom_domain: string | null; | ||
domain_aliases: string[]; | ||
branch_deploy_custom_domain: string | null; | ||
deploy_preview_custom_domain: string | null; | ||
password: string | null; | ||
notification_email: string | null; | ||
url: string; | ||
ssl_url: string; | ||
admin_url: string; | ||
screenshot_url: string; | ||
created_at: string; | ||
updated_at: string; | ||
user_id: string; | ||
session_id: string; | ||
ssl: boolean; | ||
force_ssl: boolean | null; | ||
managed_dns: boolean; | ||
deploy_url: string; | ||
published_deploy: PublishedDeploy; | ||
account_id: string; | ||
account_name: string; | ||
account_slug: string; | ||
git_provider?: string; | ||
deploy_hook: string; | ||
capabilities: Capabilities; | ||
processing_settings: ProcessingSettings; | ||
build_settings: BuildSettings; | ||
id_domain: string; | ||
default_hooks_data?: DefaultHooksData; | ||
build_image: string; | ||
prerender: string | null; | ||
functions_region: string; | ||
feature_flags: FeatureFlags; | ||
} | ||
|
||
interface PublishedDeploy { | ||
id: string; | ||
site_id: string; | ||
user_id: string; | ||
build_id: string; | ||
state: string; | ||
name: string; | ||
url: string; | ||
ssl_url: string; | ||
admin_url: string; | ||
deploy_url: string; | ||
deploy_ssl_url: string; | ||
screenshot_url: string; | ||
review_id: number | null; | ||
draft: boolean; | ||
required: string[]; | ||
required_functions: string[]; | ||
error_message: string; | ||
branch: string; | ||
commit_ref: string; | ||
commit_url: string; | ||
skipped: boolean | null; | ||
created_at: string; | ||
updated_at: string; | ||
published_at: string; | ||
title: string; | ||
context: string; | ||
locked: boolean | null; | ||
review_url: string | null; | ||
framework: string; | ||
function_schedules: FunctionSchedule[] | []; | ||
} | ||
|
||
interface FunctionSchedule { | ||
name: string; | ||
cron: string; | ||
} | ||
|
||
interface Capabilities { | ||
[key: string]: Record<string, unknown>; | ||
} | ||
|
||
// Processing Settings Interface | ||
interface ProcessingSettings { | ||
html: HTMLProcessingSettings; | ||
} | ||
|
||
// HTML Processing Settings Interface | ||
interface HTMLProcessingSettings { | ||
pretty_urls: boolean; | ||
} | ||
|
||
interface BuildSettings { | ||
id: number; | ||
provider: string; | ||
deploy_key_id: string; | ||
repo_path: string; | ||
repo_branch: string; | ||
dir: string; | ||
functions_dir: string; | ||
cmd: string; | ||
allowed_branches: string[]; | ||
public_repo: boolean; | ||
private_logs: boolean; | ||
repo_url: string; | ||
env: EnvVariables; | ||
installation_id: number; | ||
stop_builds: boolean; | ||
} | ||
|
||
interface EnvVariables { | ||
[key: string]: string; | ||
} | ||
|
||
interface DefaultHooksData { | ||
access_token: string; | ||
} | ||
|
||
interface GetSiteParams { | ||
siteId?: string, | ||
feature_flags?: string | ||
site_id?: string | ||
} | ||
|
||
export interface ExtendedNetlifyAPI extends NetlifyAPI { | ||
getEnvVar(params: GetEnvVarParams): Promise<EnvVar> | ||
getEnvVars( params: GetEnvParams): Promise<EnvVar[]> | ||
deleteEnvVarValue( params: DeleteEnvVarValueParams ): Promise<void> | ||
setEnvVarValue( params: SetEnvVarValueParams): Promise<EnvVar> | ||
deleteEnvVar(params: DeleteEnvVarValueParams): Promise<void> | ||
updateEnvVar(params: UpdateEnvVarParams): Promise<EnvVar> | ||
createEnvVars(params: CreateEnvVarParams): Promise<EnvVar[]> | ||
getSite(params: GetSiteParams): Promise<SiteInfo> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import { OptionValues } from 'commander' | ||
|
||
import { chalk, log, logJson } from '../../utils/command-helpers.js' | ||
import { AVAILABLE_CONTEXTS, getEnvelopeEnv } from '../../utils/env/index.js' | ||
import BaseCommand from '../base-command.js' | ||
|
||
export const envGet = async (name: string, options: OptionValues, command: BaseCommand) => { | ||
import { EnvOptions } from './types.js' | ||
|
||
export const envGet = async (name: string, options: EnvOptions, command: BaseCommand) => { | ||
const { context, scope } = options | ||
const { api, cachedConfig, site } = command.netlify | ||
const siteId = site.id | ||
|
@@ -15,6 +15,7 @@ export const envGet = async (name: string, options: OptionValues, command: BaseC | |
} | ||
|
||
const { siteInfo } = cachedConfig | ||
|
||
const env = await getEnvelopeEnv({ api, context, env: cachedConfig.env, key: name, scope, siteInfo }) | ||
|
||
const { value } = env[name] || {} | ||
|
@@ -26,7 +27,7 @@ export const envGet = async (name: string, options: OptionValues, command: BaseC | |
} | ||
|
||
if (!value) { | ||
const contextType = AVAILABLE_CONTEXTS.includes(context) ? 'context' : 'branch' | ||
const contextType = context === undefined ? 'branch' : AVAILABLE_CONTEXTS.includes(context) | ||
const withContext = `in the ${chalk.magenta(context)} ${contextType}` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why was this changed? It now returns a boolean instead of a string |
||
const withScope = scope === 'any' ? '' : ` and the ${chalk.magenta(scope)} scope` | ||
log(`No value set ${withContext}${withScope} for environment variable ${chalk.yellow(name)}`) | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need all these comments, they're all basically just saying the name of the interfaces are