Skip to content
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

support version without v #1354

Merged
merged 2 commits into from
Oct 19, 2022
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
12 changes: 7 additions & 5 deletions packages/cli/src/commands/deployment/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import inquirer from 'inquirer';
import {BASE_PROJECT_URL, DEFAULT_DEPLOYMENT_TYPE, ROOT_API_URL_PROD} from '../../constants';
import {
deployToHostedService,
ipfsCID_validate,
networkEndpoints,
dictionaryEndpoints,
imageVersions,
ipfsCID_validate,
networkEndpoints,
processEndpoints,
redeploy,
projectsInfo,
redeploy,
} from '../../controller/deploy-controller';
import {checkToken, promptWithDefaultValues, valueOrPrompt} from '../../utils';
import {addV, checkToken, promptWithDefaultValues, valueOrPrompt} from '../../utils';

const ACCESS_TOKEN_PATH = path.resolve(process.env.HOME, '.subql/SUBQL_ACCESS_TOKEN');
export default class Deploy extends Command {
Expand Down Expand Up @@ -52,6 +52,8 @@ export default class Deploy extends Command {
ipfsCID = await valueOrPrompt(ipfsCID, 'Enter IPFS CID', 'IPFS CID is required');

const validator = await ipfsCID_validate(ipfsCID, authToken, ROOT_API_URL_PROD);
queryVersion = addV(queryVersion);
indexerVersion = addV(indexerVersion);

if (!validator.valid) {
throw new Error(chalk.bgRedBright('Invalid IPFS CID'));
Expand Down Expand Up @@ -151,7 +153,7 @@ export default class Deploy extends Command {
ROOT_API_URL_PROD
).catch((e) => this.error(e));
this.log(`Project: ${deploymentOutput.projectKey}
\nStatus: ${chalk.blue(deploymentOutput.status)}
\nStatus: ${chalk.blue(deploymentOutput.status)}
\nDeploymentID: ${deploymentOutput.id}
\nDeployment Type: ${deploymentOutput.type}
\nIndexer version: ${deploymentOutput.indexerImage}
Expand Down
7 changes: 7 additions & 0 deletions packages/cli/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ export async function valueOrPrompt<T>(value: T, msg: string, error: string): Pr
}
}

export function addV(str: string | undefined) {
if (str && !str.includes('v')) {
return `v${str}`;
}
return str;
}

export async function promptWithDefaultValues(
promptType: Inquirer | typeof ux,
msg: string,
Expand Down