-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
generate-index: Use west to fetch nrf revision
VSC-2486 Add ncs revision to schemas. Add filtering by ncs version to query params. Add filtering by ncs version to webpage. Fetch nrf-sdk version using west. Signed-off-by: Filip Zajdel <[email protected]>
- Loading branch information
1 parent
391e851
commit 9842085
Showing
8 changed files
with
193 additions
and
38 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* Copyright (c) 2023 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: BSD-3-Clause | ||
*/ | ||
|
||
import { exec } from 'child_process'; | ||
import fs from 'fs/promises'; | ||
import { promisify } from 'util'; | ||
|
||
const execAsync = promisify(exec); | ||
|
||
async function exists(path: string): Promise<boolean> { | ||
try { | ||
await fs.access(path); | ||
return true; | ||
} catch { | ||
return false; | ||
} | ||
} | ||
|
||
class WestEnv { | ||
|
||
constructor(private repoUrl: string, private revision: string, private appPath: string) {} | ||
|
||
async init(): Promise<void> { | ||
try { | ||
const dirExists = await exists(this.appPath); | ||
if (!dirExists) { | ||
await fs.mkdir(this.appPath, { recursive: true }); | ||
} | ||
await execAsync( | ||
`cd ${this.appPath} && west init -m ${this.repoUrl} --mr ${this.revision} && west update` | ||
) | ||
} catch(err) { | ||
Promise.reject(`west init failed with err: ${err}`); | ||
} | ||
} | ||
|
||
async checkout(revision: string): Promise<void> { | ||
|
||
const {stdout} = await execAsync(`cd ${this.appPath} && west config manifest.path`); | ||
const manifestRepoPath = `${this.appPath}/${stdout.trim()}`; | ||
|
||
await execAsync(`cd ${manifestRepoPath} && git checkout ${revision} && west update`) | ||
|
||
this.revision = revision; | ||
} | ||
|
||
get manifestRev(): string { | ||
return this.revision; | ||
} | ||
|
||
async getModuleRev(module: string): Promise<string | undefined> { | ||
|
||
let {stdout} = await execAsync( | ||
`cd ${this.appPath} && west list --all --format "{name};{revision}" | grep "${module};"` | ||
); | ||
|
||
return stdout.split(";")[1]?.trim(); | ||
} | ||
} | ||
|
||
export default WestEnv; |
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