-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cli): Use canary Docker image when using canary CLI client (#1316)
This has been discussed but when using the canary version of the client it's currently not clear that you should also manually set the `ELECTRIC_IMAGE` to the canary tag as well - the proposed solution is to make the CLI automatically detect that and use the appropriate image. The `LIB_VERSION` generated by the changesets does not update for the canary releases so I had to use the `package.json` directly, but since this is for the CLI only (which we are also splitting out of the client) that should be fine, it's not meant to be browser-runnable code. This is mostly a quality of life improvement for us developing electric as the current requirement to remember to point to canary releases for both the sync service and client is slightly annoying.
- Loading branch information
Showing
4 changed files
with
52 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"electric-sql": patch | ||
--- | ||
|
||
Use canary Docker image tag when using the canary CLI client. |
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,35 @@ | ||
import fs from 'fs' | ||
import { LIB_VERSION } from '../../version' | ||
import path from 'path' | ||
import { fileURLToPath } from 'url' | ||
|
||
/** | ||
* Reads and parses the contents of the package.json of the CLI itself | ||
*/ | ||
function readPackageJson(): Record<string, unknown> { | ||
return JSON.parse( | ||
fs.readFileSync( | ||
path.join( | ||
fileURLToPath(import.meta.url), | ||
'..', | ||
'..', | ||
'..', | ||
'..', | ||
'package.json' | ||
), | ||
'utf8' | ||
) | ||
) | ||
} | ||
|
||
/** | ||
* Check whether the CLI is a canary release. | ||
* | ||
* The LIB_VERSION export does not update for canary releases | ||
* so this uses the package.json explicitly for this check | ||
*/ | ||
export function isCanaryRelease(): boolean { | ||
return (readPackageJson().version as string).includes('canary') | ||
} | ||
|
||
export const LIB_MINOR_VERSION = LIB_VERSION.split('.').slice(0, 2).join('.') |