-
Notifications
You must be signed in to change notification settings - Fork 365
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
feat: allow frameworks to detect version of CLI that's being used #6226
Changes from 3 commits
5da2b2e
97a1402
ba81854
3f720b7
fe9278e
e009bee
6ef1cd8
b0576c2
1554fde
1b70e94
283c000
db10c9a
c56483e
4dbe518
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ import { | |
exit, | ||
getToken, | ||
log, | ||
netlifyCliVersion, | ||
normalizeConfig, | ||
padLeft, | ||
pollForToken, | ||
|
@@ -38,6 +39,9 @@ import openBrowser from '../utils/open-browser.js' | |
import StateConfig from '../utils/state-config.js' | ||
import { identify, reportError, track } from '../utils/telemetry/index.js' | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
type $FIXME = any | ||
|
||
// load the autocomplete plugin | ||
inquirer.registerPrompt('autocomplete', inquirerAutocompletePrompt) | ||
/** Netlify CLI client id. Lives in [email protected] */ | ||
|
@@ -229,7 +233,7 @@ export default class BaseCommand extends Command { | |
} | ||
debug(`${name}:preAction`)('start') | ||
this.analytics = { startTime: process.hrtime.bigint() } | ||
await this.init(actionCommand) | ||
await this.init(actionCommand as BaseCommand) | ||
debug(`${name}:preAction`)('end') | ||
}) | ||
} | ||
|
@@ -521,8 +525,7 @@ export default class BaseCommand extends Command { | |
* @param {BaseCommand} actionCommand The command of the action that is run (`this.` gets the parent command) | ||
* @private | ||
*/ | ||
// @ts-expect-error TS(7006) FIXME: Parameter 'actionCommand' implicitly has an 'any' ... Remove this comment to see the full error message | ||
async init(actionCommand) { | ||
async init<C extends BaseCommand>(actionCommand: C) { | ||
debug(`${actionCommand.name()}:init`)('start') | ||
const flags = actionCommand.opts() | ||
// here we actually want to use the process.cwd as we are setting the workingDir | ||
|
@@ -606,7 +609,8 @@ export default class BaseCommand extends Command { | |
token, | ||
...apiUrlOpts, | ||
}) | ||
const { buildDir, config, configPath, repositoryRoot, siteInfo } = cachedConfig | ||
const { buildDir, config, configPath, env, repositoryRoot, siteInfo } = cachedConfig | ||
env.NETLIFY_CLI_VERSION = { sources: ['internal'], value: netlifyCliVersion } | ||
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. This is the main functional change in this PR. I don't have strong feelings around the name of the var - maybe 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. I think this var name is just fine - clear is best imo (even if it's wordy :D ) |
||
const normalizedConfig = normalizeConfig(config) | ||
const agent = await getAgent({ | ||
httpProxy: flags.httpProxy, | ||
|
@@ -689,21 +693,19 @@ export default class BaseCommand extends Command { | |
|
||
/** | ||
* Find and resolve the Netlify configuration | ||
* @param {object} config | ||
* @param {string} config.cwd | ||
* @param {string|null=} config.token | ||
* @param {*} config.state | ||
* @param {boolean=} config.offline | ||
* @param {string=} config.configFilePath An optional path to the netlify configuration file e.g. netlify.toml | ||
* @param {string=} config.packagePath | ||
* @param {string=} config.repositoryRoot | ||
* @param {string=} config.host | ||
* @param {string=} config.pathPrefix | ||
* @param {string=} config.scheme | ||
* @returns {ReturnType<typeof resolveConfig>} | ||
*/ | ||
// @ts-expect-error TS(7023) FIXME: 'getConfig' implicitly has return type 'any' becau... Remove this comment to see the full error message | ||
async getConfig(config) { | ||
async getConfig(config: { | ||
cwd: string | ||
token?: string | null | ||
state: $FIXME | ||
offline?: boolean | ||
configFilePath?: string | ||
packagePath?: string | ||
repositoryRoot?: string | ||
host?: string | ||
pathPrefix?: string | ||
scheme?: string | ||
}): Promise<ReturnType<typeof resolveConfig>> { | ||
// the flags that are passed to the command like `--debug` or `--offline` | ||
const flags = this.opts() | ||
|
||
|
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.
nit: This name feels a bit redundant and overly verbose to me, since everything here pertains to the Netlify CLI and there's no need to make that explicit with a prefix. Could we use something like
version
?