-
Notifications
You must be signed in to change notification settings - Fork 5
Add fetch command #27
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
Merged
astolcenburg
merged 1 commit into
rdkcentral:main
from
astolcenburg:feature/RDKEAPPRT-689
Apr 7, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,106 @@ | ||
| # bolt fetch Command Overview | ||
|
|
||
| ## Purpose | ||
|
|
||
| The `bolt fetch` command downloads a bolt package from a remote package store server into the | ||
| [local package store](local-package-store.md). | ||
|
|
||
| ## Usage | ||
|
|
||
| ``` | ||
| bolt fetch <package> [--force] | ||
| ``` | ||
|
|
||
| - `<package>` is the package name (`id+version`) or file name (`id+version.bolt`). | ||
| It may be prefixed with a sub-directory path (for example an architecture, `arm/<package>`), | ||
| which is appended to the server URL when downloading. | ||
|
|
||
| ## Options | ||
|
|
||
| | Option | Description | | ||
| |-------------|--------------------------------------------------------------------------------------| | ||
| | --force | Replace the package if it already exists in the local package store. | | ||
|
|
||
|
astolcenburg marked this conversation as resolved.
|
||
| ## Configuration | ||
|
|
||
| The remote server URL and package store type are configured in `~/.bolt/config.json`: | ||
|
|
||
| ```json | ||
| { | ||
| "packageStoreURL": "https://packages.example.com/bolts" | ||
| } | ||
| ``` | ||
|
|
||
| | Key | Description | | ||
| |--------------------|--------------------------------------------------------------------| | ||
| | `packageStoreURL` | URL of the remote package store server (required) | | ||
| | `packageStoreType` | Package store type: `"basic"` (default) or `"rdk"` (see below) | | ||
| | `packageStoreUser` | Username for authentication (prompted via stdin if not configured) | | ||
|
|
||
|
astolcenburg marked this conversation as resolved.
|
||
| ## Package Store Types | ||
|
|
||
| ### basic (default) | ||
|
|
||
| Downloads packages directly from `<packageStoreURL>/<id+version>.bolt` with no authentication. | ||
| The server can be a plain static file server — no special API is required. | ||
|
|
||
| ### rdk | ||
|
|
||
| Downloads packages from an RDK package store server, authenticating with a username and password. | ||
| The password is prompted via stdin on first use and never stored. If `packageStoreUser` is not set | ||
| in the config, the username is also prompted. The session is preserved between invocations; when it | ||
| expires, credentials are prompted again automatically. | ||
|
|
||
| Example configuration: | ||
| ```json | ||
| { | ||
| "packageStoreURL": "https://rdk.example.com", | ||
| "packageStoreType": "rdk", | ||
| "packageStoreUser": "myuser" | ||
| } | ||
| ``` | ||
|
|
||
| ## Custom Package Store Types | ||
|
|
||
| Custom types can be implemented as modules placed in `~/.bolt/plugins/`. The module file must be | ||
| named `fetch-<type>.cjs` (e.g., `~/.bolt/plugins/fetch-custom.cjs` for type `"custom"`). | ||
|
|
||
| The module exports a factory function that receives a context object and returns an async fetch | ||
| handler: | ||
|
|
||
| ```js | ||
| module.exports = function(ctx) { | ||
| return async function(packageStoreURL, packageFileName, options) { | ||
| await ctx.downloadPackage(`${packageStoreURL}/${packageFileName}`); | ||
| }; | ||
| }; | ||
| ``` | ||
|
|
||
| Available helpers on the `ctx` object: | ||
|
|
||
| | Method | Description | | ||
| |---------------------------------------------|-----------------------------------------------------------| | ||
| | `ctx.downloadPackage(url, requestOptions?)` | Download a file with progress indicator | | ||
| | `ctx.postJSON(url, body)` | HTTP POST with JSON body, returns `{statusCode, headers, body}` | | ||
| | `ctx.promptCredentials(username?)` | Prompt for username/password via stdin | | ||
| | `ctx.loadData()` | Load saved data. Return `null` if no data | | ||
| | `ctx.saveData(data)` | Save data | | ||
|
|
||
| ## Examples | ||
|
|
||
| - Download a package into the local package store: | ||
| ``` | ||
| bolt fetch com.rdkcentral.base+0.2.0 | ||
| ``` | ||
| - Same, using the file name form: | ||
| ``` | ||
| bolt fetch com.rdkcentral.base+0.2.0.bolt | ||
| ``` | ||
| - Download an architecture-specific package from a subdirectory on the server: | ||
| ``` | ||
| bolt fetch arm/com.rdkcentral.base+0.2.0 | ||
| ``` | ||
| - Re-download, replacing an existing copy: | ||
| ``` | ||
| bolt fetch com.rdkcentral.base+0.2.0 --force | ||
| ``` | ||
This file contains hidden or 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 hidden or 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 hidden or 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,24 @@ | ||
| /* | ||
| * If not stated otherwise in this file or this component's LICENSE file the | ||
| * following copyright and licenses apply: | ||
| * | ||
| * Copyright 2026 RDK Management | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| module.exports = function(ctx) { | ||
| return async function(packageStoreURL, packageFileName) { | ||
| await ctx.downloadPackage(`${packageStoreURL}/${packageFileName}`); | ||
| }; | ||
| }; |
This file contains hidden or 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,67 @@ | ||
| /* | ||
| * If not stated otherwise in this file or this component's LICENSE file the | ||
| * following copyright and licenses apply: | ||
| * | ||
| * Copyright 2026 RDK Management | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| async function login(ctx, base, credentials) { | ||
| const res = await ctx.postJSON(`${base}/auth/login`, { | ||
| username: credentials.username, | ||
| password: credentials.password, | ||
| }); | ||
|
|
||
| if (res.statusCode !== 200) { | ||
| throw new Error(`Authentication failed: HTTP ${res.statusCode}`); | ||
| } | ||
|
|
||
| const setCookie = res.headers['set-cookie']; | ||
| if (!setCookie) { | ||
| throw new Error('Authentication failed: no cookie received from server'); | ||
| } | ||
|
|
||
| const cookieHeader = Array.isArray(setCookie) ? setCookie[0] : setCookie; | ||
| return cookieHeader.split(';')[0].trim(); | ||
| } | ||
|
|
||
| module.exports = function(ctx) { | ||
| return async function(packageStoreURL, packageFileName, options) { | ||
| const packagePath = packageFileName.includes('/') ? packageFileName : `arm/${packageFileName}`; | ||
| const url = `${packageStoreURL}/appcatalog/bolts/${packagePath}`; | ||
| let cookie = ctx.loadData(); | ||
| let prompted = false; | ||
|
|
||
| if (!cookie) { | ||
| const credentials = await ctx.promptCredentials(options.packageStoreUser); | ||
| prompted = true; | ||
| cookie = await login(ctx, packageStoreURL, credentials); | ||
| ctx.saveData(cookie); | ||
| } | ||
|
|
||
| try { | ||
| await ctx.downloadPackage(url, { headers: { Cookie: cookie } }); | ||
| } catch (err) { | ||
| if ((err.statusCode === 401 || err.statusCode === 403) && !prompted) { | ||
| console.log('Session expired, re-authenticating...'); | ||
| const credentials = await ctx.promptCredentials(options.packageStoreUser); | ||
| cookie = await login(ctx, packageStoreURL, credentials); | ||
| ctx.saveData(cookie); | ||
| await ctx.downloadPackage(url, { headers: { Cookie: cookie } }); | ||
| } else { | ||
| throw err; | ||
| } | ||
| } | ||
| }; | ||
| }; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.