/ commands / extra-usage / index.ts
index.ts
 1  import { getIsNonInteractiveSession } from '../../bootstrap/state.js'
 2  import type { Command } from '../../commands.js'
 3  import { isOverageProvisioningAllowed } from '../../utils/auth.js'
 4  import { isEnvTruthy } from '../../utils/envUtils.js'
 5  
 6  function isExtraUsageAllowed(): boolean {
 7    if (isEnvTruthy(process.env.DISABLE_EXTRA_USAGE_COMMAND)) {
 8      return false
 9    }
10    return isOverageProvisioningAllowed()
11  }
12  
13  export const extraUsage = {
14    type: 'local-jsx',
15    name: 'extra-usage',
16    description: 'Configure extra usage to keep working when limits are hit',
17    isEnabled: () => isExtraUsageAllowed() && !getIsNonInteractiveSession(),
18    load: () => import('./extra-usage.js'),
19  } satisfies Command
20  
21  export const extraUsageNonInteractive = {
22    type: 'local',
23    name: 'extra-usage',
24    supportsNonInteractive: true,
25    description: 'Configure extra usage to keep working when limits are hit',
26    isEnabled: () => isExtraUsageAllowed() && getIsNonInteractiveSession(),
27    get isHidden() {
28      return !getIsNonInteractiveSession()
29    },
30    load: () => import('./extra-usage-noninteractive.js'),
31  } satisfies Command