-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RSDK-5362 generate protos from pinned versions (#180)
- Loading branch information
1 parent
8d9bcb7
commit c2b11a5
Showing
9 changed files
with
93 additions
and
22 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* RSDK-5362: This script gets the pinned version of a buf proto from the | ||
* buf.lock file. We need this to generate pinned versions of our protos. | ||
* | ||
* If we find a way to make `buf generate` build proto apis using the versions | ||
* stored in buf.lock directly then we can retire this script. | ||
* | ||
* See this thread for more details: | ||
* https://viaminc.slack.com/archives/C039G724TKP/p1697119526822429 | ||
*/ | ||
|
||
'use strict'; | ||
|
||
const fs = require('node:fs'); | ||
const YAML = require('yaml'); | ||
|
||
const buflockPath = './buf.lock'; | ||
|
||
const input = process.argv[2]; | ||
if (!input) { | ||
throw new Error('Please specify a buf proto'); | ||
} | ||
|
||
const [remote, owner, repository] = input.split('/'); | ||
|
||
const buflock = fs.readFileSync(buflockPath, 'utf8'); | ||
const parsed = YAML.parse(buflock); | ||
|
||
const { commit } = parsed.deps.find( | ||
(dep) => | ||
dep.remote === remote && | ||
dep.owner === owner && | ||
dep.repository === repository | ||
); | ||
const pinnedDep = `${remote}/${owner}/${repository}:${commit}`; | ||
|
||
console.log(pinnedDep); |
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