-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): export config methods and adopt
Command
instances instea…
…d of global `program`(#1130)
- Loading branch information
Showing
22 changed files
with
406 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { veramo } from '../createCommand.js' | ||
import { jest } from '@jest/globals' | ||
import { createObjects } from '../lib/objectCreator' | ||
import { getConfig } from '../setup' | ||
|
||
jest.useFakeTimers() | ||
|
||
describe('cli version', () => { | ||
const writeMock = jest.fn() | ||
|
||
beforeAll(() => { | ||
// veramo | ||
// .exitOverride() | ||
// .configureOutput({ writeOut: writeMock }) | ||
}) | ||
|
||
afterAll(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
it.skip('should list version number', async () => { | ||
expect(() => { | ||
// veramo.parse(['--version'], { from: 'user' }) | ||
}).toThrow() | ||
expect(writeMock).toHaveBeenCalledWith(expect.stringMatching(/^\d\.\d\.\d\n?$/)) | ||
}) | ||
|
||
it.skip('should load the dbConnection', async () => { | ||
// this seems to fail because of some timing issues or an incompatibility with the `chalk` transitive dependency | ||
// all other tests that need to load the dbConnection fail similarly | ||
const res = await createObjects(getConfig('./packages/cli/default/default.yml'), { | ||
my: '/dbConnection', | ||
}) | ||
}) | ||
|
||
it.skip('should check the default config', async () => { | ||
expect(() => { | ||
// veramo.parse(['config', 'check', '-f', './packages/cli/default/default.yml'], { from: 'user' }) | ||
}).toThrow(/hello/) | ||
expect(writeMock).toHaveBeenCalledWith(expect.stringMatching(/^\d\.\d\.\d\n?$/)) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,11 @@ | ||
import { program } from 'commander' | ||
import inquirer from 'inquirer' | ||
import inquirerAutoPrompt from 'inquirer-autocomplete-prompt' | ||
|
||
inquirer.registerPrompt('autocomplete', inquirerAutoPrompt) | ||
|
||
import './did.js' | ||
import './credential.js' | ||
import './presentation.js' | ||
import './explore/index.js' | ||
import './sdr.js' | ||
import './message.js' | ||
import './discover.js' | ||
import './version.js' | ||
import './execute.js' | ||
import './server.js' | ||
import './setup.js' | ||
import './config.js' | ||
import './dev.js' | ||
import { veramo } from './createCommand.js' | ||
|
||
if (!process.argv.slice(2).length) { | ||
program.outputHelp() | ||
veramo.outputHelp() | ||
} else { | ||
program.parse(process.argv) | ||
veramo.parse(process.argv) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Command } from 'commander' | ||
import module from 'module' | ||
|
||
import { config } from './config.js' | ||
import { credential } from './credential.js' | ||
import { dev } from './dev.js' | ||
import { did } from './did.js' | ||
import { discover } from './discover.js' | ||
import { execute } from './execute.js' | ||
import { message } from './message.js' | ||
import { presentation } from './presentation.js' | ||
import { explore } from './explore/index.js' | ||
import { sdr } from './sdr.js' | ||
import { server } from './server.js' | ||
|
||
const requireCjs = module.createRequire(import.meta.url) | ||
const { version } = requireCjs('../package.json') | ||
|
||
const veramo = new Command('veramo') | ||
.version(version, '-v, --version') | ||
.option('--config <string>', 'Configuration file', './agent.yml') | ||
.addCommand(config) | ||
.addCommand(credential) | ||
.addCommand(dev) | ||
.addCommand(did) | ||
.addCommand(discover) | ||
.addCommand(execute) | ||
.addCommand(explore) | ||
.addCommand(message) | ||
.addCommand(presentation) | ||
.addCommand(sdr) | ||
.addCommand(server) | ||
|
||
export { veramo } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.