Skip to content
Open
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
22 changes: 10 additions & 12 deletions src/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ import signup from '@metacall/protocol/signup';
import { expiresIn } from '@metacall/protocol/token';
import args from './cli/args';
import { input, maskedInput } from './cli/inputs';
import { error, info, warn } from './cli/messages';
import { error, info, success, warn } from './cli/messages';
import { loginSelection } from './cli/selection';
import { Config, save } from './config';
import { ErrorCode } from './deploy';
import { forever } from './utils';

const authToken = async (config: Config): Promise<string> => {
const askToken = (): Promise<string> =>
maskedInput('Please enter your metacall token');
maskedInput('Enter your MetaCall token:');

const shouldKeepAsking = args['token'] === undefined;
let token: string = args['token'] || (await askToken());
Expand Down Expand Up @@ -62,11 +62,10 @@ const authToken = async (config: Config): Promise<string> => {
};

const authLogin = async (config: Config): Promise<string> => {
const askEmail = (): Promise<string> =>
input('Please enter your email id:');
const askEmail = (): Promise<string> => input('Enter your email address:');

const askPassword = (): Promise<string> =>
maskedInput('Please enter your password:');
maskedInput('Enter your password:');

let email = '';
let password = '';
Expand Down Expand Up @@ -107,16 +106,15 @@ const authLogin = async (config: Config): Promise<string> => {
};

const authSignup = async (config: Config): Promise<string> => {
const askEmail = (): Promise<string> =>
input('Please enter your email id:');
const askEmail = (): Promise<string> => input('Enter your email address:');

const askAlias = (): Promise<string> => input('Please enter your Alias:');
const askAlias = (): Promise<string> => input('Enter your alias:');

const askPassword = (): Promise<string> =>
maskedInput('Please enter your password:');
maskedInput('Enter your password:');

const askPasswordConfirmation = (): Promise<string> =>
maskedInput('Confirm password:');
maskedInput('Confirm your password:');

let email = '';
let password = '';
Expand All @@ -136,7 +134,7 @@ const authSignup = async (config: Config): Promise<string> => {
await askCredentials();

if (password !== passwordConfirmation) {
warn('Passwords did not match.');
warn('Passwords do not match.');
password = '';
passwordConfirmation = '';
} else {
Expand Down Expand Up @@ -199,7 +197,7 @@ const authSelection = async (config: Config): Promise<string> => {

await save({ token });

info('Login Successfull!');
success('Login successful.');

return token;
};
Expand Down
4 changes: 2 additions & 2 deletions src/cli/selection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const loginSelection = (methods: string[]): Promise<string> =>
{
type: 'list',
name: 'method',
message: 'Select the login method',
message: 'Select a login method:',
choices: methods
}
]).then((res: { method: string }) => res.method);
Expand All @@ -36,7 +36,7 @@ export const languageSelection = (
{
type: 'checkbox',
name: 'langs',
message: 'Select languages to run on MetaCall',
message: 'Select languages to run on MetaCall:',
choices: languages.map(lang => Languages[lang].displayName)
}
]).then((res: { langs: string[] }) =>
Expand Down
2 changes: 1 addition & 1 deletion src/cli/validateToken.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const validateToken = async (api: APIInterface): Promise<void> => {

(await exists(configFile)) && (await unlink(configFile));

info('Try to login again!');
info('Please login again.');

return error(
`Token validation failed, potential causes include:\n\t1) The JWT may be mistranslated (Invalid Signature).\n\t2) JWT might have expired.`
Expand Down
2 changes: 1 addition & 1 deletion src/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const deleteBySelection = async (api: APIInterface): Promise<void> => {
const deployments: Deployment[] = (await api.inspect()).filter(
dep => dep.status === 'ready'
);
if (!deployments.length) error('No deployment found');
if (!deployments.length) error('No deployments found.');

const project: string = await listSelection(
[...deployments.map(el => `${el.suffix} ${el.version}`)],
Expand Down
27 changes: 17 additions & 10 deletions src/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ import { promises as fs } from 'fs';
import { join } from 'path';
import args from './cli/args';
import { input } from './cli/inputs';
import { apiError, error, info, printLanguage, warn } from './cli/messages';
import {
apiError,
error,
info,
printLanguage,
success,
warn
} from './cli/messages';
import Progress from './cli/progress';
import { languageSelection, listSelection } from './cli/selection';
import { logs } from './logs';
Expand Down Expand Up @@ -95,8 +102,8 @@ export const deployPackage = async (
}

if (deploy) {
info(
'Repository deployed, Use command $ metacall-deploy --inspect, to know more about deployment'
success(
'Package deployed successfully. Use $ metacall-deploy --inspect to view deployment details.'
);
}
} catch (err) {
Expand Down Expand Up @@ -163,7 +170,7 @@ export const deployPackage = async (
.map(el => printLanguage(el))
.join(
', '
)} but you didn't select any file, do you want to continue? (Y/N):`
)} but didn't select any files. Do you want to continue? (Y/N):`
)
).toUpperCase();

Expand Down Expand Up @@ -210,11 +217,11 @@ export const deployPackage = async (
}
case PackageError.JsonNotFound: {
warn(
`No metacall.json was found in ${rootPath}, launching the wizard...`
`No metacall.json was found in ${rootPath}. Launching the wizard...`
);

const askToCachePackagesFile = (): Promise<string> =>
input('Do you want to save metacall.json file? (Y/N):');
input('Do you want to save the metacall.json file? (Y/N):');

await createJsonAndDeploy(
(await askToCachePackagesFile()).toUpperCase()
Expand All @@ -235,7 +242,7 @@ export const deployFromRepository = async (
try {
const { branches } = await api.branchList(url);

if (!branches.length) return error('Invalid Repository URL');
if (!branches.length) return error('Invalid repository URL.');

// TODO: API response type should be created in protocol, it is string as of now
const selectedBranch =
Expand All @@ -245,7 +252,7 @@ export const deployFromRepository = async (

if (branches.length === 1)
info(
`Only one branch found : ${selectedBranch}, Selecting it automatically.`
`Only one branch found: ${selectedBranch}. Selecting it automatically.`
);

const runners = Array.from(
Expand All @@ -268,8 +275,8 @@ export const deployFromRepository = async (
await logs(runners, deploy.suffix, args['dev']);

if (deploy)
info(
'Repository deployed, Use command $ metacall-deploy --inspect, to know more about deployment'
success(
'Repository deployed successfully. Use $ metacall-deploy --inspect to view deployment details.'
);
} catch (e) {
error(String(e), ErrorCode.DeployRepositoryFailed);
Expand Down
4 changes: 2 additions & 2 deletions src/force.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { error, info } from './cli/messages';
import { del } from './delete';

export const force = async (api: APIInterface): Promise<string> => {
info('Trying to deploy forcefully!');
info('Attempting forceful deployment.');

const suffix = args['addrepo']
? args['addrepo']?.split('com/')[1].split('/').join('-')
Expand Down Expand Up @@ -33,7 +33,7 @@ export const force = async (api: APIInterface): Promise<string> => {
}
} catch (e) {
error(
'Deployment Aborted because this directory is not being used by any applications.'
'Deployment aborted. This directory is not associated with any applications.'
);
}

Expand Down
6 changes: 3 additions & 3 deletions src/logout.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { unlink } from 'fs/promises';
import { error, info } from './cli/messages';
import { error, success } from './cli/messages';
import { configFilePath } from './config';
import { exists } from './utils';

export const logout = async (): Promise<void> => {
const configFile = configFilePath();

!(await exists(configFile)) &&
error("You haven't logged in yet! Kindly log in.");
error('You are not logged in. Please log in first.');

await unlink(configFile);

info('You have logout! See you later.');
success('Logged out successfully.');
};
2 changes: 1 addition & 1 deletion src/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ export const plan = async (api: APIInterface): Promise<Plans> => {
}

// Otherwise, prompt user to select from available plans
return await planSelection('Please select plan from the list', availPlans);
return await planSelection('Select a plan:', availPlans);
};
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ export const getEnv = async (
{
type: 'input',
name: 'env',
message: 'Type env vars in the format: K1=V1, K2=V2'
message: 'Enter environment variables in the format K1=V1, K2=V2:'
}
]);

Expand Down