Skip to content

Commit

Permalink
feat: using logger for agent shutdown messages
Browse files Browse the repository at this point in the history
chore: change command for vaults delete to be rm|remove

fix: updated tests

fix: removed touch alias for vaults create
  • Loading branch information
aryanjassal committed Nov 18, 2024
1 parent 740c72d commit e4dbc27
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/agent/CommandStart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ class CommandStart extends CommandPolykey {
pkAgent.addEventListener(
polykeyEvents.EventPolykeyAgentStop.name,
() => {
process.stderr.write('Stopping Agent\n');
this.logger.warn('Stopping Agent');
},
{ once: true },
);
Expand Down
6 changes: 3 additions & 3 deletions src/agent/CommandStop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ class CommandStop extends CommandPolykey {
);
const statusInfo = clientStatus.statusInfo;
if (statusInfo?.status === 'DEAD') {
process.stderr.write('Agent is already dead\n');
this.logger.warn('Agent is already dead');
return;
} else if (statusInfo?.status === 'STOPPING') {
process.stderr.write('Agent is already stopping\n');
this.logger.warn('Agent is already stopping');
return;
} else if (statusInfo?.status === 'STARTING') {
throw new errors.ErrorPolykeyCLIAgentStatus('Agent is starting');
Expand Down Expand Up @@ -62,7 +62,7 @@ class CommandStop extends CommandPolykey {
}),
auth,
);
process.stderr.write('Stopping Agent\n');
this.logger.warn('Stopping Agent');
} finally {
if (pkClient! != null) await pkClient.stop();
}
Expand Down
1 change: 0 additions & 1 deletion src/vaults/CommandCreate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ class CommandCreate extends CommandPolykey {
constructor(...args: ConstructorParameters<typeof CommandPolykey>) {
super(...args);
this.name('create');
this.aliases(['touch']);
this.description('Create a new Vault');
this.argument(
'<vaultName>',
Expand Down
7 changes: 4 additions & 3 deletions src/vaults/CommandDelete.ts → src/vaults/CommandRemove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import * as binParsers from '../utils/parsers';
class CommandDelete extends CommandPolykey {
constructor(...args: ConstructorParameters<typeof CommandPolykey>) {
super(...args);
this.name('delete');
this.description('Delete an Existing Vault');
this.name('rm');
this.alias('remove');
this.description('Remove an existing Vault');
this.argument(
'<vaultName>',
'Name of the vault to be deleted',
'Name of the vault to be removed',
binParsers.parseVaultName,
);
this.addOption(binOptions.nodeId);
Expand Down
4 changes: 2 additions & 2 deletions src/vaults/CommandVaults.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import CommandClone from './CommandClone';
import CommandCreate from './CommandCreate';
import CommandDelete from './CommandDelete';
import CommandList from './CommandList';
import CommandLog from './CommandLog';
import CommandScan from './CommandScan';
import CommandPermissions from './CommandPermissions';
import CommandPull from './CommandPull';
import CommandRemove from './CommandRemove';
import CommandRename from './CommandRename';
import CommandShare from './CommandShare';
import CommandUnshare from './CommandUnshare';
Expand All @@ -19,11 +19,11 @@ class CommandVaults extends CommandPolykey {
this.description('Vaults Operations');
this.addCommand(new CommandClone(...args));
this.addCommand(new CommandCreate(...args));
this.addCommand(new CommandDelete(...args));
this.addCommand(new CommandList(...args));
this.addCommand(new CommandLog(...args));
this.addCommand(new CommandPermissions(...args));
this.addCommand(new CommandPull(...args));
this.addCommand(new CommandRemove(...args));
this.addCommand(new CommandRename(...args));
this.addCommand(new CommandShare(...args));
this.addCommand(new CommandUnshare(...args));
Expand Down
6 changes: 3 additions & 3 deletions tests/vaults/delete.test.ts → tests/vaults/remove.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as ids from 'polykey/dist/ids';
import * as keysUtils from 'polykey/dist/keys/utils';
import * as testUtils from '../utils';

describe('commandDeleteVault', () => {
describe('commandRemoveVault', () => {
const password = 'password';
const logger = new Logger('CLI Test', LogLevel.WARN, [new StreamHandler()]);
let dataDir: string;
Expand Down Expand Up @@ -68,8 +68,8 @@ describe('commandDeleteVault', () => {
});
});

test('should delete vault', async () => {
command = ['vaults', 'delete', '-np', dataDir, vaultName];
test('should remove vault', async () => {
command = ['vaults', 'rm', '-np', dataDir, vaultName];
await polykeyAgent.vaultManager.createVault(vaultName);
let id = polykeyAgent.vaultManager.getVaultId(vaultName);
expect(id).toBeTruthy();
Expand Down

0 comments on commit e4dbc27

Please sign in to comment.