Skip to content

Commit

Permalink
support version without v (#1354)
Browse files Browse the repository at this point in the history
* support version without v

* improvement addv FUNC and solved undefined input

Co-authored-by: Louise wang <[email protected]>
  • Loading branch information
bighammerw and Louise wang authored Oct 19, 2022
1 parent e217b32 commit d8964ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/cli/src/commands/deployment/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
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 @@ -64,6 +64,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
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

0 comments on commit d8964ab

Please sign in to comment.