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
16 changes: 13 additions & 3 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,28 @@
"name": "Debug CLI",
"program": "${workspaceFolder}/bin/dev.js",
"runtimeExecutable": "tsx",
"args": ["${input:cliCommand}"],
"args": [
"${input:cliCommand}",
"${input:cliFlags}"
],
"runtimeArgs": ["--inspect"],
"console": "integratedTerminal",
"autoAttachChildProcesses": true
"autoAttachChildProcesses": true,
"skipFiles": ["<node_internals>/**"]
}
],
"inputs": [
{
"id": "cliCommand",
"type": "promptString",
"description": "Enter the CLI command to debug (e.g. app:list, code:push, etc.)",
"description": "Enter the CLI command (e.g. app:list, code:push)",
"default": "app:list"
},
{
"id": "cliFlags",
"type": "promptString",
"description": "Enter command flags (e.g. -d /path/to/folder, --appId 123)",
"default": ""
}
]
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mondaycom/apps-cli",
"version": "4.10.4",
"version": "4.10.5",
"description": "A cli tool to manage apps (and monday-code projects) in monday.com",
"author": "monday.com Apps Team",
"type": "module",
Expand Down
14 changes: 8 additions & 6 deletions src/commands/database/connection-string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { VAR_UNKNOWN } from 'consts/messages';
import { getDatabaseConnectionString } from 'services/database-service';
import { DynamicChoicesService } from 'services/dynamic-choices-service';
import { defaultVersionByAppId } from 'src/services/app-versions-service';
import { chooseRegionIfNeeded, getRegionFromString } from 'src/utils/region';
import { addRegionToFlags, chooseRegionIfNeeded, getRegionFromString } from 'src/utils/region';
import { HttpError } from 'types/errors';
import logger from 'utils/logger';

Expand All @@ -15,12 +15,14 @@ export default class ConnectionString extends AuthenticatedCommand {

static examples = ['<%= config.bin %> <%= command.id %> -a APP_ID'];

static flags = ConnectionString.serializeFlags({
appId: Flags.integer({
char: 'a',
description: 'Select the app that you wish to retrieve the connection string for',
static flags = ConnectionString.serializeFlags(
addRegionToFlags({
appId: Flags.integer({
char: 'a',
description: 'Select the app that you wish to retrieve the connection string for',
}),
}),
});
);

public async run(): Promise<void> {
const { flags } = await this.parse(ConnectionString);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/scheduler/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { PromptService } from 'src/services/prompt-service';
import { SchedulerService } from 'src/services/scheduler-service';
import { printJobs, validateCronExpression, validateTargetUrl } from 'src/services/scheduler-service.utils';
import logger from 'src/utils/logger';
import { chooseRegionIfNeeded, getRegionFromString } from 'src/utils/region';
import { chooseSchedulerRegionIfNeeded, getRegionFromString } from 'src/utils/region';
import { addPrefixIfNotExists } from 'src/utils/urls-builder';
import { isDefined } from 'src/utils/validations';

Expand All @@ -29,7 +29,7 @@ export default class SchedulerCreate extends AuthenticatedCommand {
const parsedRegion = getRegionFromString(region);

if (!appId) appId = await DynamicChoicesService.chooseApp();
const selectedRegion = await chooseRegionIfNeeded(parsedRegion, { appId });
const selectedRegion = await chooseSchedulerRegionIfNeeded(parsedRegion, { appId });
if (!name) name = await PromptService.promptInput(SchedulerMessages.name, true);
if (!schedule) schedule = await PromptService.promptInput(SchedulerMessages.schedule, true);
validateCronExpression(schedule);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/scheduler/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SchedulerBaseFlags } from 'src/consts/scheduler/flags';
import { DynamicChoicesService } from 'src/services/dynamic-choices-service';
import { SchedulerService } from 'src/services/scheduler-service';
import logger from 'src/utils/logger';
import { chooseRegionIfNeeded, getRegionFromString } from 'src/utils/region';
import { chooseSchedulerRegionIfNeeded, getRegionFromString } from 'src/utils/region';

export default class SchedulerDelete extends AuthenticatedCommand {
static description = 'Delete a scheduler job for an app';
Expand All @@ -20,7 +20,7 @@ export default class SchedulerDelete extends AuthenticatedCommand {
const parsedRegion = getRegionFromString(region);

if (!appId) appId = await DynamicChoicesService.chooseApp();
const selectedRegion = await chooseRegionIfNeeded(parsedRegion, { appId });
const selectedRegion = await chooseSchedulerRegionIfNeeded(parsedRegion, { appId });
if (!name) name = await DynamicChoicesService.chooseSchedulerJob(appId, selectedRegion);

logger.debug(`Deleting scheduler job ${name} for appId: ${appId}`, this.DEBUG_TAG);
Expand Down
5 changes: 3 additions & 2 deletions src/commands/scheduler/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import { DynamicChoicesService } from 'src/services/dynamic-choices-service';
import { SchedulerService } from 'src/services/scheduler-service';
import { printJobs } from 'src/services/scheduler-service.utils';
import logger from 'src/utils/logger';
import { chooseRegionIfNeeded, getRegionFromString } from 'src/utils/region';
import { chooseSchedulerRegionIfNeeded, getRegionFromString, regionFlag } from 'src/utils/region';

export default class SchedulerList extends AuthenticatedCommand {
static description = 'List all scheduler jobs for an app';
static examples = ['<%= config.bin %> <%= command.id %> -a APP_ID'];

static flags = SchedulerList.serializeFlags({
appId: SchedulerBaseFlags.appId,
...regionFlag,
});

DEBUG_TAG = 'scheduler_list';
Expand All @@ -23,7 +24,7 @@ export default class SchedulerList extends AuthenticatedCommand {
const parsedRegion = getRegionFromString(region);

appId = appId ? Number(appId) : await DynamicChoicesService.chooseApp();
const selectedRegion = await chooseRegionIfNeeded(parsedRegion, { appId });
const selectedRegion = await chooseSchedulerRegionIfNeeded(parsedRegion, { appId });

logger.debug(`Listing scheduler jobs for appId: ${appId}`, this.DEBUG_TAG);
this.preparePrintCommand(this, { appId, region: selectedRegion });
Expand Down
4 changes: 2 additions & 2 deletions src/commands/scheduler/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { SchedulerBaseFlags } from 'src/consts/scheduler/flags';
import { DynamicChoicesService } from 'src/services/dynamic-choices-service';
import { SchedulerService } from 'src/services/scheduler-service';
import logger from 'src/utils/logger';
import { chooseRegionIfNeeded, getRegionFromString } from 'src/utils/region';
import { chooseSchedulerRegionIfNeeded, getRegionFromString } from 'src/utils/region';

export default class SchedulerRun extends AuthenticatedCommand {
static description = 'Manually trigger a scheduled job to run for an app';
Expand All @@ -20,7 +20,7 @@ export default class SchedulerRun extends AuthenticatedCommand {
const parsedRegion = getRegionFromString(region);

if (!appId) appId = await DynamicChoicesService.chooseApp();
const selectedRegion = await chooseRegionIfNeeded(parsedRegion, { appId });
const selectedRegion = await chooseSchedulerRegionIfNeeded(parsedRegion, { appId });
if (!name) name = await DynamicChoicesService.chooseSchedulerJob(appId, selectedRegion);

logger.debug(`Running scheduler job ${name} for appId: ${appId}`, this.DEBUG_TAG);
Expand Down
4 changes: 2 additions & 2 deletions src/commands/scheduler/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { SchedulerService } from 'src/services/scheduler-service';
import { printJobs, validateCronExpression, validateTargetUrl } from 'src/services/scheduler-service.utils';
import { UpdateJobRequest } from 'src/types/services/scheduler-service';
import logger from 'src/utils/logger';
import { chooseRegionIfNeeded, getRegionFromString } from 'src/utils/region';
import { chooseSchedulerRegionIfNeeded, getRegionFromString } from 'src/utils/region';
import { addPrefixIfNotExists } from 'src/utils/urls-builder';
import { isDefined, isDefinedAndNotEmpty } from 'src/utils/validations';

Expand All @@ -30,7 +30,7 @@ export default class SchedulerUpdate extends AuthenticatedCommand {
const parsedRegion = getRegionFromString(region);

if (!appId) appId = await DynamicChoicesService.chooseApp();
const selectedRegion = await chooseRegionIfNeeded(parsedRegion, { appId });
const selectedRegion = await chooseSchedulerRegionIfNeeded(parsedRegion, { appId });
const jobs = await SchedulerService.listJobs(appId, selectedRegion);
if (!name) name = await DynamicChoicesService.chooseSchedulerJob(appId, selectedRegion, jobs);

Expand Down
1 change: 1 addition & 0 deletions src/types/general/region.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ export enum Region {
US = 'us',
EU = 'eu',
AU = 'au',
IL = 'il',
}
15 changes: 14 additions & 1 deletion src/utils/region.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function addRegionToFlags<T>(flags: T): T {
}

const regionsPrompt = async () =>
PromptService.promptList('Choose region', [Region.US, Region.EU, Region.AU], Region.US);
PromptService.promptList('Choose region', [Region.US, Region.EU, Region.AU, Region.IL], Region.US);

export async function chooseRegionIfNeeded(
region?: Region,
Expand Down Expand Up @@ -72,3 +72,16 @@ export async function chooseRegionIfNeeded(
const returnedRegion = await regionsPrompt();
return getRegionFromString(returnedRegion);
}

export async function chooseSchedulerRegionIfNeeded(
region?: Region,
options?: { appId?: number; appVersionId?: number },
): Promise<Region | undefined> {
if (region === Region.IL) {
throw new Error(
'Cloud Scheduler is not available in the IL region. Please use a different region (US, EU, or AU) for scheduler operations.',
);
}

return chooseRegionIfNeeded(region, options);
}
Loading