Skip to content

Commit 6d14bf8

Browse files
authored
refactor: use LocalState from @netlify/dev-utils (#7454)
* Replaced usages of CLIState to LocalState * Exported type LocalState in types
1 parent 0034927 commit 6d14bf8

File tree

11 files changed

+21
-147
lines changed

11 files changed

+21
-147
lines changed

src/commands/base-command.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { NetlifyAPI } from '@netlify/api'
77
import { DefaultLogger, Project } from '@netlify/build-info'
88
import { NodeFS, NoopLogger } from '@netlify/build-info/node'
99
import { resolveConfig } from '@netlify/config'
10-
import { getGlobalConfigStore } from '@netlify/dev-utils'
10+
import { getGlobalConfigStore, LocalState } from '@netlify/dev-utils'
1111
import { isCI } from 'ci-info'
1212
import { Command, Help, Option, type OptionValues } from 'commander'
1313
import debug from 'debug'
@@ -38,7 +38,6 @@ import type { FeatureFlags } from '../utils/feature-flags.js'
3838
import { getFrameworksAPIPaths } from '../utils/frameworks-api.js'
3939
import { getSiteByName } from '../utils/get-site.js'
4040
import openBrowser from '../utils/open-browser.js'
41-
import CLIState from '../utils/cli-state.js'
4241
import { identify, reportError, track } from '../utils/telemetry/index.js'
4342
import type { NetlifyOptions } from './types.js'
4443
import type { CachedConfig } from '../lib/build.js'
@@ -566,7 +565,7 @@ export default class BaseCommand extends Command {
566565
// ==================================================
567566
// Retrieve Site id and build state from the state.json
568567
// ==================================================
569-
const state = new CLIState(this.workingDir)
568+
const state = new LocalState(this.workingDir)
570569
const [token] = await getToken(flags.auth)
571570

572571
const apiUrlOpts: {

src/commands/dev/dev.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import openBrowser from '../../utils/open-browser.js'
2727
import { generateInspectSettings, startProxyServer } from '../../utils/proxy-server.js'
2828
import { getProxyUrl } from '../../utils/proxy.js'
2929
import { runDevTimeline } from '../../utils/run-build.js'
30-
import type { CLIState, ServerSettings } from '../../utils/types.js'
30+
import type { LocalState, ServerSettings } from '../../utils/types.js'
3131
import type BaseCommand from '../base-command.js'
3232
import { getBaseOptionValues } from '../base-command.js'
3333
import type { NetlifySite } from '../types.js'
@@ -46,7 +46,7 @@ const handleLiveTunnel = async ({
4646
options: OptionValues
4747
settings: ServerSettings
4848
site: NetlifySite
49-
state: CLIState
49+
state: LocalState
5050
}) => {
5151
const { live } = options
5252

src/commands/init/init.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ import { track } from '../../utils/telemetry/index.js'
1010
import type BaseCommand from '../base-command.js'
1111
import { link } from '../link/link.js'
1212
import { sitesCreate } from '../sites/sites-create.js'
13-
import type { CLIState, SiteInfo } from '../../utils/types.js'
13+
import type { LocalState, SiteInfo } from '../../utils/types.js'
1414
import { getBuildSettings, saveNetlifyToml } from '../../utils/init/utils.js'
1515
import { type InitExitCode, LINKED_EXISTING_SITE_EXIT_CODE, LINKED_NEW_SITE_EXIT_CODE } from './constants.js'
1616

17-
const persistState = ({ siteInfo, state }: { siteInfo: SiteInfo; state: CLIState }): void => {
17+
const persistState = ({ siteInfo, state }: { siteInfo: SiteInfo; state: LocalState }): void => {
1818
// Save to .netlify/state.json file
1919
state.set('siteId', siteInfo.id)
2020
}
@@ -47,7 +47,7 @@ const createNewSiteAndExit = async ({
4747
customizeExitMessage,
4848
}: {
4949
command: BaseCommand
50-
state: CLIState
50+
state: LocalState
5151
disableLinking: boolean
5252
customizeExitMessage: InitExitMessageCustomizer | undefined
5353
}): Promise<never> => {
@@ -131,7 +131,7 @@ const handleNoGitRemoteAndExit = async ({
131131
}: {
132132
command: BaseCommand
133133
error?: unknown
134-
state: CLIState
134+
state: LocalState
135135
disableLinking: boolean
136136
customizeExitMessage: InitExitMessageCustomizer | undefined
137137
}): Promise<never> => {

src/commands/types.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { NetlifyAPI } from '@netlify/api'
22

33
import type { FrameworksAPIPaths } from '../utils/frameworks-api.ts'
4-
import type CLIState from '../utils/cli-state.js'
4+
import type { LocalState } from '../utils/types.ts'
55
import type { MinimalAccount, GlobalConfigStore, SiteInfo } from '../utils/types.ts'
66
import type { NormalizedCachedConfigConfig } from '../utils/command-helpers.js'
77
import type { CachedConfig } from '../lib/build.js'
@@ -40,7 +40,7 @@ export type NetlifyOptions = {
4040
config: NormalizedCachedConfigConfig
4141
cachedConfig: CachedConfig
4242
globalConfig: GlobalConfigStore
43-
state: CLIState
43+
state: LocalState
4444
frameworksAPIPaths: FrameworksAPIPaths
4545
}
4646

src/lib/edge-functions/proxy.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { BlobsContextWithEdgeAccess } from '../blobs/blobs.js'
1919
import { getGeoLocation } from '../geo-location.js'
2020
import { getPathInProject } from '../settings.js'
2121
import { type Spinner, startSpinner, stopSpinner } from '../spinner.js'
22-
import type { CLIState, ServerSettings } from '../../utils/types.js'
22+
import type { LocalState, ServerSettings } from '../../utils/types.js'
2323

2424
import { getBootstrapURL } from './bootstrap.js'
2525
import { DIST_IMPORT_MAP_PATH, EDGE_FUNCTIONS_SERVE_FOLDER } from './consts.js'
@@ -112,7 +112,7 @@ export const initializeProxy = async ({
112112
repositoryRoot?: string
113113
settings: ServerSettings
114114
siteInfo: $TSFixMe
115-
state: CLIState
115+
state: LocalState
116116
}) => {
117117
const userFunctionsPath = config.build.edge_functions
118118
const isolatePort = await getAvailablePort()

src/lib/functions/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { NFFunctionName, NFFunctionRoute } from '../../utils/headers.js'
2323
import type { BlobsContextWithEdgeAccess } from '../blobs/blobs.js'
2424
import { headers as efHeaders } from '../edge-functions/headers.js'
2525
import { getGeoLocation } from '../geo-location.js'
26-
import type { CLIState, ServerSettings, SiteInfo } from '../../utils/types.js'
26+
import type { LocalState, ServerSettings, SiteInfo } from '../../utils/types.js'
2727

2828
import { handleBackgroundFunction, handleBackgroundFunctionResult } from './background.js'
2929
import { createFormSubmissionHandler } from './form-submissions-handler.js'
@@ -265,7 +265,7 @@ interface GetFunctionsServerOptions {
265265
accountId?: string | undefined
266266
geoCountry: string
267267
offline: boolean
268-
state: CLIState
268+
state: LocalState
269269
config: NormalizedCachedConfigConfig
270270
geolocationMode: 'cache' | 'update' | 'mock'
271271
}

src/utils/cli-state.ts

Lines changed: 0 additions & 125 deletions
This file was deleted.

src/utils/live-tunnel.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { getPathInHome } from '../lib/settings.js'
99

1010
import { NETLIFYDEVERR, NETLIFYDEVLOG, chalk, exit, log } from './command-helpers.js'
1111
import execa from './execa.js'
12-
import type CLIState from './cli-state.js'
12+
import type { LocalState } from './types.js'
1313

1414
const PACKAGE_NAME = 'live-tunnel-client'
1515
const EXEC_NAME = PACKAGE_NAME
@@ -174,7 +174,7 @@ export const startLiveTunnel = async ({
174174
return session.session_url
175175
}
176176

177-
export const getLiveTunnelSlug = (state: CLIState, override?: string) => {
177+
export const getLiveTunnelSlug = (state: LocalState, override?: string) => {
178178
if (override !== undefined) {
179179
return override
180180
}

src/utils/proxy-server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { FunctionsRegistry } from '../lib/functions/registry.js'
55

66
import { exit, log, NETLIFYDEVERR, type NormalizedCachedConfigConfig } from './command-helpers.js'
77
import { startProxy } from './proxy.js'
8-
import type CLIState from './cli-state.js'
8+
import type { LocalState } from './types.js'
99
import type { ServerSettings } from './types.js'
1010

1111
interface InspectSettings {
@@ -84,7 +84,7 @@ export const startProxyServer = async ({
8484
siteInfo: $TSFixMe
8585
projectDir: string
8686
repositoryRoot?: string
87-
state: CLIState
87+
state: LocalState
8888
functionsRegistry?: FunctionsRegistry
8989
}) => {
9090
const url = await startProxy({

src/utils/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import type { PollingStrategy } from '@netlify/build-info'
55
import type { Match } from 'netlify-redirector'
66

77
export type { GlobalConfigStore } from '@netlify/dev-utils'
8-
export { default as CLIState } from './cli-state.js'
8+
export type { LocalState } from '@netlify/dev-utils'
99

1010
export type FrameworkNames = '#static' | '#auto' | '#custom' | string
1111

0 commit comments

Comments
 (0)