-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[AC-2579] Set up bit-cli folder #9092
Conversation
* services are managed by the ServiceContainer * the app is bootstrapped by Main
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9092 +/- ##
==========================================
+ Coverage 27.77% 28.12% +0.35%
==========================================
Files 2422 2427 +5
Lines 70328 70345 +17
Branches 13124 13124
==========================================
+ Hits 19531 19788 +257
+ Misses 49277 49030 -247
- Partials 1520 1527 +7 ☔ View full report in Codecov by Sentry. |
No New Or Fixed Issues Found |
dd4b74f
to
7045afc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is actually just bw.ts
renamed, with the run()
method and all program classes removed. There are no changes to the rest of the file, e.g. how services are bootstrapped, this is not new code.
import { registerBitPrograms } from "./register-bit-programs"; | ||
import { ServiceContainer } from "./service-container"; | ||
|
||
async function main() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One change (compared to the old Main.run()
method) is that we used to explicitly check for no arguments and show help text: https://github.com/bitwarden/clients/blob/main/apps/cli/src/bw.ts#L740-L742. However, Commander does this automatically since version 5 and we're now on version 11: SO reference, Github reference. I've removed this code block, which also has the nice effect of removing any real logic from main
- now it's all just initialization.
I've refactored this since the draft yesterday and updated the description above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tools changes LGTM.
Kudos 👍🏻 - Loving how simple the entry point is now.
Thoughts 💭 - I'm guessing license issues don't apply to us due to CLAs, but it's still a little curious that we directly derive from the CLI's service class.
Nitpick ⛏️ - Can any of this be unit tested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks just about perfect! well done. I want to understand the plan on script updates, but depending on your answer I'll approve as is.
apps/cli/package.json
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please update normal build scripts to build:oss
(see web scripts as pattern). If this is intended as part of your automation follow up, that's fine, too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do! I avoided changing any existing scripts because that will require updates to Github workflows, which I didn't want to deal with here. But I will include it in the follow-up.
Additional changes:
|
Type of change
Objective
We're now adding Bitwarden Licensed code to the CLI client, so we need a separate
bit-cli
folder and build.This PR does 2 things:
bitwarden_license/bit-cli
folder, config files, and entrypoint, and addsbit
commands toapps/cli/package.json
. This largely follows thebit-web
structure.Setting up CI builds is out of scope and will be done separately.
Code changes
Tools team: the only changes to your files are updating imports and naming.
Architecture devs: I would like you to review the substantive changes here.
The
bit-cli
config files and the newpackage.json
commands are fairly self-explanatory, although they still need to be checked over.The changes to the CLI app structure require a bit more explanation. At the moment, our services (from
libs/common
) and the CLI program classes are tightly coupled in theMain
class, which is responsible for instantiating services, registering programs, and starting execution of the app. This is too many responsibilities and is quite rigid.The refactored code takes advantage of Commander's builder pattern to give us more flexibility. The new code works like this:
ServiceContainer
is responsible for initializing all services and making them available to programs (usually passed into their constructors)registerOssPrograms
is responsible for initializing and registering all (OSS) programsbw.ts
stitches it together: instantiate the service container, pass it toregisterOssPrograms
, start the app.bit-cli has an identical structure:
ServiceContainer
subclasses the OSS class and allows for registration of additional bit-licensed servicesregisterBitPrograms
registers bit-licensed programsbw.ts
stitches it together, note that it callsregisterOssPrograms
first so that bit-cli is always a superset of the OSS functionality.Screenshots
Before you submit