Skip to content

Commit

Permalink
fixing the message users get when code:push to an app with latest liv…
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaharshaki2 committed Sep 16, 2024
1 parent 6f3b3cf commit e4223da
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/consts/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ export const VAR_UNKNOWN = 'unknown';
export const APP_FEATURE_ID_TO_ENTER = 'Please enter the app feature id of your app:';

export const BUILD_ID_TO_ENTER = 'Please enter the build id of your app:';

export const LIVE_VERSION_ERROR_LOG =
'Operation failed: The latest app version is live. Create a new draft or use --force to override';
8 changes: 6 additions & 2 deletions src/services/app-versions-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ export const listAppVersionsByAppId = async (appId: AppId): Promise<Array<AppVer
}
};

export const defaultVersionByAppId = async (appId: AppId, useLiveVersion = false): Promise<AppVersion | undefined> => {
export const defaultVersionByAppId = async (
appId: AppId,
customLogMessage?: string,
useLiveVersion = false,
): Promise<AppVersion | undefined> => {
logger.info(`Getting the latest valid version for app id - ${appId}`);

const appVersions = await listAppVersionsByAppId(appId);
Expand All @@ -46,7 +50,7 @@ export const defaultVersionByAppId = async (appId: AppId, useLiveVersion = false
if (validVersion) {
logger.info(`Using version - ${validVersion?.id} for app id - ${appId}`);
} else {
logger.error(`No valid version found for app id - ${appId}`);
logger.info(customLogMessage || `No valid version found for app id - ${appId}`);
}

return validVersion;
Expand Down
2 changes: 1 addition & 1 deletion src/services/apps-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export const cloneAppTemplateAndLoadManifest = async (
};

export const createFeatures = async (ctx: AppCreateCommandTasksContext) => {
const defaultVersion = await defaultVersionByAppId(ctx.appId!, false);
const defaultVersion = await defaultVersionByAppId(ctx.appId!, undefined, false);
const baseUrl = await getTunnelingDomain();
if (!defaultVersion) throw new Error(`No default version found for app id - ${ctx.appId}`);
ctx.appVersionId = defaultVersion.id;
Expand Down
3 changes: 2 additions & 1 deletion src/services/dynamic-choices-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { listAppFeaturesByAppVersionId } from 'services/app-features-service';
import { defaultVersionByAppId, listAppVersionsByAppId } from 'services/app-versions-service';
import { listApps } from 'services/apps-service';
import { PromptService } from 'services/prompt-service';
import { LIVE_VERSION_ERROR_LOG } from 'src/consts/messages';
import { AppFeature, AppFeatureType } from 'src/types/services/app-features-service';

export const DynamicChoicesService = {
Expand Down Expand Up @@ -57,7 +58,7 @@ export const DynamicChoicesService = {
if (useLiveVersion) filterByStatus.push(APP_VERSION_STATUS.LIVE);

if (appId && autoSelectVersion) {
const defaultVersion = await defaultVersionByAppId(appId, useLiveVersion);
const defaultVersion = await defaultVersionByAppId(appId, LIVE_VERSION_ERROR_LOG, useLiveVersion);
if (!defaultVersion) throw new Error(`No default version found for app id - ${appId}`);

return { appId, appVersionId: defaultVersion.id };
Expand Down

0 comments on commit e4223da

Please sign in to comment.