Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions packages/app/src/cli/commands/app/app-logs/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ export default class Sources extends AppLinkedCommand {
userProvidedConfigName: flags.config,
})

if (!app.errors.isEmpty()) {
process.exit(2)
} else {
if (app.errors.isEmpty()) {
sources(app)
} else {
process.exit(2)
}
return {app}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/cli/commands/app/function/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,15 @@ export default class FunctionRun extends AppUnlinkedCommand {
if (targeting.length > 1 && isTTY({})) {
const targets = targeting.map((target) => ({
label: target.target,
value: target.export || DEFAULT_FUNCTION_EXPORT,
value: target.export || DEFAULT_FUNCTION_EXPORT, // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing -- empty export should use default
}))

functionExport = await renderAutocompletePrompt({
message: `Which target would you like to execute?`,
choices: targets,
})
} else {
functionExport = targeting?.[0]?.export || DEFAULT_FUNCTION_EXPORT
functionExport = targeting?.[0]?.export || DEFAULT_FUNCTION_EXPORT // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing -- empty export should use default
outputDebug(
`Using export '${functionExport}'. Use the --export flag or an interactive terminal to select a different export.`,
)
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/cli/commands/app/webhook/trigger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export default class WebhookTrigger extends AppLinkedCommand {
deliveryMethod: flags['delivery-method'],
address: flags.address,
clientId: flags['client-id'],
clientSecret: flags['client-secret'] || flags['shared-secret'],
clientSecret: flags['client-secret'] || flags['shared-secret'], // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing -- empty flag should try next
path: flags.path,
config: flags.config,
organizationId: appContextResult.organization.id,
Expand Down
8 changes: 3 additions & 5 deletions packages/app/src/cli/models/app/identifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,9 @@ export async function updateAppIdentifiers(
): Promise<AppInterface> {
let dotenvFile = app.dotenv

if (!dotenvFile) {
dotenvFile = {
path: joinPath(app.directory, getDotEnvFileName(app.configPath)),
variables: {},
}
dotenvFile ??= {
path: joinPath(app.directory, getDotEnvFileName(app.configPath)),
variables: {},
}
const updatedVariables: {[key: string]: string} = {...(app.dotenv?.variables ?? {})}
if (!systemEnvironment[app.idEnvironmentVariableName]) {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/cli/prompts/generate/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const generateExtensionPrompts = async (

const extensionTemplate = extensionTemplates.find((template) => template.identifier === templateType)!

const name = options.name || (await promptName(options.directory, extensionTemplate.defaultName))
const name = options.name || (await promptName(options.directory, extensionTemplate.defaultName)) // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing -- empty name should prompt
const flavor = options.extensionFlavor ?? (await promptFlavor(extensionTemplate))
const extensionContent = {name, flavor}

Expand Down
24 changes: 11 additions & 13 deletions packages/app/src/cli/prompts/init/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,18 +84,16 @@ const init = async (options: InitOptions): Promise<InitOutput> => {
template: templates.reactRouter.url,
} as const

if (!template) {
template = await renderSelectPrompt({
choices: templateOptionsInOrder.map((key) => {
return {
label: templates[key].label || key,
value: key,
}
}),
message: 'Get started building your app:',
defaultValue: allTemplates.find((key) => templates[key].url === defaults.template),
})
}
template ??= await renderSelectPrompt({
choices: templateOptionsInOrder.map((key) => {
return {
label: templates[key].label || key, // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing -- empty label should show key
value: key,
}
}),
message: 'Get started building your app:',
defaultValue: allTemplates.find((key) => templates[key].url === defaults.template),
})

const answers: InitOutput = {
...options,
Expand Down Expand Up @@ -129,7 +127,7 @@ const init = async (options: InitOptions): Promise<InitOutput> => {
selectedUrl = `${selectedUrl}#${branch}`
}

answers.template = selectedUrl || answers.template || defaults.template
answers.template = selectedUrl || answers.template || defaults.template // eslint-disable-line @typescript-eslint/prefer-nullish-coalescing -- empty URL should fall through

answers.globalCLIResult = await installGlobalCLIPrompt()

Expand Down
4 changes: 1 addition & 3 deletions packages/app/src/cli/services/app-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,7 @@ export async function linkedAppContext({
const effectiveClientId = clientId ?? configClientId

// Fetch the remote app, using a different clientID if provided via flag.
if (!remoteApp) {
remoteApp = await appFromIdentifiers({apiKey: effectiveClientId})
}
remoteApp ??= await appFromIdentifiers({apiKey: effectiveClientId})
const developerPlatformClient = remoteApp.developerPlatformClient

const organization = await fetchOrgFromId(remoteApp.organizationId, developerPlatformClient)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export const pollAppLogs = async ({
stdout,
appLogsFetchInput: {
jwtToken: nextJwtToken,
cursor: responseCursor || cursor,
cursor: responseCursor ?? cursor,
},
developerPlatformClient,
resubscribeCallback,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ const EMPTY_FILTERS = {status: undefined, sources: undefined}
const createMockResponse = (data: any, status = 200, statusText = 'OK') => {
if (status !== 200 || data.errors) {
return {
errors: data.errors || [`Error with status ${status}`],
errors: data.errors ?? [`Error with status ${status}`],
status,
}
}

return {
app_logs: data.app_logs || [],
app_logs: data.app_logs ?? [],
cursor: data.cursor,
status,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export async function renderJsonLogs({
options: {variables, developerPlatformClient},
pollOptions: {
jwtToken: nextJwtToken || pollOptions.jwtToken,
cursor: nextCursor || pollOptions.cursor,
cursor: nextCursor ?? pollOptions.cursor,
filters: pollOptions.filters,
},
storeNameById,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ const Logs: FunctionComponent<LogsProps> = ({
</Box>
<Box marginLeft={1} marginTop={1}>
<Text>
{prettyPrintJsonIfPossible(appLog.inputQueryVariablesMetafieldValue) || (
{prettyPrintJsonIfPossible(appLog.inputQueryVariablesMetafieldValue) ?? (
<Text color="red">Metafield is not set</Text>
)}
</Text>
Expand Down
8 changes: 4 additions & 4 deletions packages/app/src/cli/services/app-logs/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ export function parseNetworkAccessRequestExecutedPayload(payload: string): Netwo
const parsedPayload = JSON.parse(payload)
return new NetworkAccessRequestExecutedLog({
attempt: parsedPayload.attempt,
connectTimeMs: parsedPayload.connect_time_ms || null,
writeReadTimeMs: parsedPayload.write_read_time_ms || null,
connectTimeMs: parsedPayload.connect_time_ms ?? null,
writeReadTimeMs: parsedPayload.write_read_time_ms ?? null,
httpRequest: parsedPayload.http_request,
httpResponse: parsedPayload.http_response || null,
error: parsedPayload.error || null,
httpResponse: parsedPayload.http_response ?? null,
error: parsedPayload.error ?? null,
})
}

Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/cli/services/app/select-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export async function fetchAppRemoteConfiguration(
flags: Flag[],
activeAppVersion?: AppVersion,
) {
const appVersion = activeAppVersion || (await developerPlatformClient.activeAppVersion(remoteApp))
const appVersion = activeAppVersion ?? (await developerPlatformClient.activeAppVersion(remoteApp))
const appModuleVersionsConfig =
appVersion?.appModuleVersions.filter(
(module) => extensionTypeStrategy(specifications, module.specification?.identifier) !== 'uuid',
) || []
) ?? []

// This might be droppable -- if remote apps always have an active version and some modules?
if (appModuleVersionsConfig.length === 0) return undefined
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export async function executeIncludeAssetsStep(
const counts = await Promise.all(
config.inclusions.map(async (entry) => {
const warn = (msg: string) => options.stdout.write(msg)
const sanitizedDest = entry.destination !== undefined ? sanitizeRelativePath(entry.destination, warn) : undefined
const sanitizedDest = entry.destination === undefined ? undefined : sanitizeRelativePath(entry.destination, warn)

if (entry.type === 'pattern') {
const sourceDir = entry.baseDir ? joinPath(extension.directory, entry.baseDir) : extension.directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ export async function copySourceEntry(
// Resolve destination path and log message up front, then dispatch on file vs directory.
let destPath: string
let logMsg: string
if (destination !== undefined) {
destPath = joinPath(outputDir, destination)
if (destination === undefined) {
destPath = joinPath(outputDir, basename(sourcePath))
logMsg = `Included ${source}\n`
} else {
destPath = joinPath(outputDir, basename(sourcePath))
destPath = joinPath(outputDir, destination)
logMsg = `Included ${source}\n`
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ async function resolveRemoteExtensionIdentifiersBreakdown(
specs: ExtensionSpecification[],
activeAppVersion?: AppVersion,
): Promise<ExtensionIdentifiersBreakdown | undefined> {
const version = activeAppVersion || (await developerPlatformClient.activeAppVersion(remoteApp))
const version = activeAppVersion ?? (await developerPlatformClient.activeAppVersion(remoteApp))
if (!version) return

const extensionIdentifiersBreakdown = loadExtensionsIdentifiersBreakdown(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ function matchWebhooks(remoteSource: RemoteSource, extension: ExtensionInstance)
const remoteVersionConfig = remoteSource.activeVersion?.config
const remoteVersionConfigObj = remoteVersionConfig ? JSON.parse(remoteVersionConfig) : {}
const localConfig = extension.configuration as unknown as SingleWebhookSubscriptionType
const remoteUri: string = remoteVersionConfigObj.uri || ''
const remoteUri: string = remoteVersionConfigObj.uri ?? ''
return (
remoteVersionConfigObj.topic === localConfig.topic &&
remoteUri.endsWith(localConfig.uri) &&
Expand Down
4 changes: 1 addition & 3 deletions packages/app/src/cli/services/dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -352,9 +352,7 @@ async function setupNetworkingOptions(

let frontendPort = frontendConfig?.configuration.port
if (frontendConfig) {
if (!frontendPort) {
frontendPort = frontendConfig === backendConfig ? backendPort : await getAvailableTCPPort()
}
frontendPort ??= frontendConfig === backendConfig ? backendPort : await getAvailableTCPPort()
frontendConfig.configuration.port = frontendPort
}
frontendPort = frontendPort ?? (await getAvailableTCPPort())
Expand Down
14 changes: 7 additions & 7 deletions packages/app/src/cli/services/dev/extension/localization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ export async function getLocalization(
return {localization: undefined, status: ''}
}

const localization = options.currentLocalizationPayload
? options.currentLocalizationPayload
: ({
defaultLocale: 'en',
translations: {},
lastUpdated: 0,
} as Localization)
const localization =
options.currentLocalizationPayload ??
({
defaultLocale: 'en',
translations: {},
lastUpdated: 0,
} as Localization)

let status: ExtensionAssetBuildStatus = 'success'

Expand Down
7 changes: 3 additions & 4 deletions packages/app/src/cli/services/dev/graphiql/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export function deriveGraphiQLKey(apiSecret: string, storeFqdn: string): string
* if non-empty, otherwise derives one deterministically from the app secret.
*/
export function resolveGraphiQLKey(providedKey: string | undefined, apiSecret: string, storeFqdn: string): string {
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentional: empty string after trim should fall through to deriveGraphiQLKey
return providedKey?.trim() || deriveGraphiQLKey(apiSecret, storeFqdn)
}

Expand Down Expand Up @@ -83,10 +84,8 @@ export function setupGraphiQLServer({

let _token: string | undefined
async function token(): Promise<string> {
if (!_token) {
// eslint-disable-next-line require-atomic-updates
_token = await refreshToken()
}
// eslint-disable-next-line require-atomic-updates
_token ??= await refreshToken()
return _token
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ export function setupSendUninstallWebhookProcess({
}): SendWebhookProcess | undefined {
const {backendConfig, frontendConfig} = frontAndBackendConfig(webs)
const webhooksPath =
webs.map(({configuration}) => configuration.webhooks_path).find((path) => path) || '/api/webhooks'
const sendUninstallWebhook = Boolean(webhooksPath) && remoteAppUpdated && Boolean(frontendConfig || backendConfig)
webs.map(({configuration}) => configuration.webhooks_path).find((path) => path) ?? '/api/webhooks'
const sendUninstallWebhook = Boolean(webhooksPath) && remoteAppUpdated && Boolean(frontendConfig ?? backendConfig)
if (!sendUninstallWebhook) {
return
}
Expand Down
8 changes: 4 additions & 4 deletions packages/app/src/cli/services/dev/select-app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ export async function selectOrCreateApp(
{directory: options.directory},
)

if (!app) {
if (attempt < MAX_PROMPT_RETRIES - 1) outputInfo('App selection failed. Retrying...')
continue
} else {
if (app) {
const selectedToml = tomls[app.apiKey]
if (selectedToml) setCachedCommandTomlPreference(selectedToml)

Expand All @@ -72,6 +69,9 @@ export async function selectOrCreateApp(
if (fullSelectedApp) {
return fullSelectedApp
}
} else {
if (attempt < MAX_PROMPT_RETRIES - 1) outputInfo('App selection failed. Retrying...')
continue
}
}

Expand Down
10 changes: 5 additions & 5 deletions packages/app/src/cli/services/dev/update-extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ describe('updateExtensionDraft()', () => {
errors: [{message: 'Network error'}, {message: 'Timeout error'}],
}
const developerPlatformClient: DeveloperPlatformClient = testDeveloperPlatformClient({
updateExtension: (_extensionInput: ExtensionUpdateDraftMutationVariables) => Promise.reject(systemError),
updateExtension: (_extensionInput: ExtensionUpdateDraftMutationVariables) => Promise.reject(systemError), // eslint-disable-line @typescript-eslint/prefer-promise-reject-errors -- testing non-Error rejection handling,
})

await inTemporaryDirectory(async (tmpDir) => {
Expand Down Expand Up @@ -313,7 +313,7 @@ describe('updateExtensionDraft()', () => {
test('handles system error with message string', async () => {
const systemError = {message: 'API connection failed'}
const developerPlatformClient: DeveloperPlatformClient = testDeveloperPlatformClient({
updateExtension: (_extensionInput: ExtensionUpdateDraftMutationVariables) => Promise.reject(systemError),
updateExtension: (_extensionInput: ExtensionUpdateDraftMutationVariables) => Promise.reject(systemError), // eslint-disable-line @typescript-eslint/prefer-promise-reject-errors -- testing non-Error rejection handling,
})

await inTemporaryDirectory(async (tmpDir) => {
Expand Down Expand Up @@ -348,7 +348,7 @@ describe('updateExtensionDraft()', () => {
test('handles string error', async () => {
const systemError = 'Connection timeout'
const developerPlatformClient: DeveloperPlatformClient = testDeveloperPlatformClient({
updateExtension: (_extensionInput: ExtensionUpdateDraftMutationVariables) => Promise.reject(systemError),
updateExtension: (_extensionInput: ExtensionUpdateDraftMutationVariables) => Promise.reject(systemError), // eslint-disable-line @typescript-eslint/prefer-promise-reject-errors -- testing non-Error rejection handling,
})

await inTemporaryDirectory(async (tmpDir) => {
Expand Down Expand Up @@ -382,7 +382,7 @@ describe('updateExtensionDraft()', () => {

test('handles null/undefined error with fallback message', async () => {
const developerPlatformClient: DeveloperPlatformClient = testDeveloperPlatformClient({
updateExtension: (_extensionInput: ExtensionUpdateDraftMutationVariables) => Promise.reject(null),
updateExtension: (_extensionInput: ExtensionUpdateDraftMutationVariables) => Promise.reject(null), // eslint-disable-line @typescript-eslint/prefer-promise-reject-errors -- testing null rejection handling,
})

await inTemporaryDirectory(async (tmpDir) => {
Expand Down Expand Up @@ -415,7 +415,7 @@ describe('updateExtensionDraft()', () => {
test('handles object error without errors or message properties', async () => {
const systemError = {status: 500, code: 'INTERNAL_ERROR'}
const developerPlatformClient: DeveloperPlatformClient = testDeveloperPlatformClient({
updateExtension: (_extensionInput: ExtensionUpdateDraftMutationVariables) => Promise.reject(systemError),
updateExtension: (_extensionInput: ExtensionUpdateDraftMutationVariables) => Promise.reject(systemError), // eslint-disable-line @typescript-eslint/prefer-promise-reject-errors -- testing non-Error rejection handling,
})

await inTemporaryDirectory(async (tmpDir) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/cli/services/extensions/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export async function ensureDownloadedExtensionFlavorExists(
extensionFlavor: ExtensionFlavor | undefined,
templateDownloadDir: string,
): Promise<string> {
const templatePath = extensionFlavor?.path || ''
const templatePath = extensionFlavor?.path ?? ''
const origin = joinPath(templateDownloadDir, templatePath)
if (!(await fileExists(origin))) {
throw new AbortError(`\nThe extension is not available for ${extensionFlavor?.value}`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const serializeConfigField = (field: SerializedField, type: FlowPartnersExtensio

const serializedField: ConfigField = {
key: field.name,
description: field.description ? field.description : undefined,
description: field.description ?? undefined,
type: fieldType,
}

Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/cli/services/function/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ export function ${identifier}() { return __runFunction(${alias}) }`
}

export function jsExports(fun: ExtensionInstance<FunctionConfigType>) {
const targets = fun.configuration.targeting || []
const targets = fun.configuration.targeting ?? []
const withoutExport = targets.filter((target) => !target.export)
const withExport = targets.filter((target) => Boolean(target.export))

Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/cli/services/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ function limitReached(app: AppInterface, specifications: ExtensionSpecification[
const type = template.type
const specification = specifications.find((spec) => spec.identifier === type || spec.externalIdentifier === type)
const existingExtensions = app.extensionsForType({identifier: type, externalIdentifier: type})
return existingExtensions.length >= (specification?.registrationLimit || 1)
return existingExtensions.length >= (specification?.registrationLimit ?? 1)
}

async function saveAnalyticsMetadata(promptAnswers: GenerateExtensionPromptOutput, typeFlag: string | undefined) {
Expand Down
Loading
Loading