-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): creation of a new
list
command (#775)
* feat(api): creation of a new `list` command * Update packages/api/src/commands/list.ts Co-authored-by: Kanad Gupta <[email protected]> * Update packages/api/src/commands/list.ts Co-authored-by: Kanad Gupta <[email protected]> * Update packages/api/src/commands/list.ts Co-authored-by: Kanad Gupta <[email protected]> * fix: pr feedback --------- Co-authored-by: Kanad Gupta <[email protected]>
- Loading branch information
1 parent
e2b1df9
commit a8b9891
Showing
7 changed files
with
162 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import installCommand from './install.js'; | ||
import listCommand from './list.js'; | ||
|
||
export default { | ||
install: installCommand, | ||
list: listCommand, | ||
}; |
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 chalk from 'chalk'; | ||
import { Command } from 'commander'; | ||
|
||
import logger from '../logger.js'; | ||
import Storage from '../storage.js'; | ||
|
||
const cmd = new Command(); | ||
cmd | ||
.name('list') | ||
.alias('ls') | ||
.description('list any installed API SDKs') | ||
.action(async () => { | ||
// We need to preload the storage system so we can grab the lockfile. | ||
Storage.setStorageDir(); | ||
|
||
const lockfile = Storage.getLockfile(); | ||
|
||
if (!lockfile.apis.length) { | ||
logger('😔 You do not have any SDKs installed.'); | ||
return; | ||
} | ||
|
||
lockfile.apis.forEach((api, i) => { | ||
if (i > 0) { | ||
logger(''); | ||
} | ||
|
||
logger(chalk.yellow.underline(api.identifier)); | ||
if (api.private) { | ||
logger(`package name (${chalk.red('private')}): ${chalk.grey(`@api/${api.identifier}`)}`); | ||
} | ||
|
||
logger(`source: ${chalk.grey(api.source)}`); | ||
logger(`installer version: ${chalk.grey(api.installerVersion)}`); | ||
logger(`created at: ${chalk.grey(api.createdAt || 'n/a')}`); | ||
if (api.updatedAt) { | ||
logger(`updated at: ${chalk.grey(api.updatedAt)}`); | ||
} | ||
}); | ||
}); | ||
|
||
export default cmd; |
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.