mirror of
https://gitcode.com/github-mirrors/react-native-update-cli.git
synced 2025-10-29 13:53:11 +08:00
* add logic to support SENTRY_PROPERTIES parameter * remove update.json and meta.json files in ppk * udpapte * refactor modles * update * add package-module file * update * update readme file * modifu cli.json file * fix command issues * improve version workflow logic * udpate * update * update * update * udpate * udpate * add example * update readme file * udpate version * change logic to use pushy command uniformly
36 lines
1015 B
TypeScript
36 lines
1015 B
TypeScript
import crypto from 'crypto';
|
|
import type { CommandContext } from 'types';
|
|
import { closeSession, get, post, replaceSession, saveSession } from './api';
|
|
import { question } from './utils';
|
|
import { t } from './utils/i18n';
|
|
|
|
function md5(str: string) {
|
|
return crypto.createHash('md5').update(str).digest('hex');
|
|
}
|
|
|
|
export const userCommands = {
|
|
login: async ({ args }: { args: string[] }) => {
|
|
const email = args[0] || (await question('email:'));
|
|
const pwd = args[1] || (await question('password:', true));
|
|
const { token, info } = await post('/user/login', {
|
|
email,
|
|
pwd: md5(pwd),
|
|
});
|
|
replaceSession({ token });
|
|
await saveSession();
|
|
console.log(t('welcomeMessage', { name: info.name }));
|
|
},
|
|
logout: async (context: CommandContext) => {
|
|
await closeSession();
|
|
console.log(t('loggedOut'));
|
|
},
|
|
me: async () => {
|
|
const me = await get('/user/me');
|
|
for (const k in me) {
|
|
if (k !== 'ok') {
|
|
console.log(`${k}: ${me[k]}`);
|
|
}
|
|
}
|
|
},
|
|
};
|