Compare commits

...

3 Commits

Author SHA1 Message Date
jheyworth 1166af05a7
Merge 46a3d854f3 into 3e89b30b3c 2026-04-27 20:49:48 -05:00
Jérôme Revillard 3e89b30b3c
fix: use full update path when --custom-source is passed with --yes (#2336)
* fix: use full update path when --custom-source is passed with --yes

When --yes is used on an existing install, the installer auto-selects
quick-update. However, quick-update never re-clones custom module repos
— it only reads whatever is already in the cache. This means
--custom-source with a new version tag (e.g. @1.1.0) is silently
ignored and the previously cached version (e.g. 1.0.1) is reported as
"already up to date".

Default to the full update path when --custom-source is present, so the
custom repo gets re-cloned at the requested version. Also ensure all
installed modules are included in the selection when --yes is combined
with --custom-source, preventing previously installed modules from being
removed.

* fix: address review feedback on choices.find() and comment clarity

* style: prettier fix for empty-body methods in custom-module-manager

---------

Co-authored-by: Brian <bmadcode@gmail.com>
2026-04-27 20:49:21 -05:00
LanyGuan b4d73b7daf
Fix installer custom modules http (#2344)
* fix(installer): preserve http protocol in custom module clone URLs

Previously, parseSource() hardcoded 'https://' when building cloneUrl,
forcing http:// Git URLs (e.g., internal LAN hosts) to upgrade to https.
This broke cloning for self-hosted Git servers that only serve over HTTP.

- Capture the protocol from the regex match instead of discarding it
- Update JSDoc and inline comments to document HTTP support
- Update install-custom-modules docs (EN, ZH, VN) to list HTTP URL type

Fixes the --custom-source flag for http:// addresses.

* docs(installer): update JSDoc to mention HTTP support in cloneRepo

Add HTTP to the cloneRepo method's JSDoc param description.
Also fixes minor spacing in empty arrow functions (formatting).

* docs(installer): fix JSDoc annotation for cloneRepo param

Correct @param backtick escaping in cloneRepo JSDoc.
Also documents HTTP as a supported protocol alongside HTTPS and SSH.

---------

Co-authored-by: 关惠民 <9155544@qq.com>
2026-04-27 19:58:38 -05:00
5 changed files with 21 additions and 11 deletions

View File

@ -68,6 +68,7 @@ Select **Yes**, then provide a source:
| Input Type | Example | | Input Type | Example |
| --------------------- | ------------------------------------------------- | | --------------------- | ------------------------------------------------- |
| HTTPS URL (any host) | `https://github.com/org/repo` | | HTTPS URL (any host) | `https://github.com/org/repo` |
| HTTP URL (any host) | `http://host/org/repo` |
| HTTPS URL with subdir | `https://github.com/org/repo/tree/main/my-module` | | HTTPS URL with subdir | `https://github.com/org/repo/tree/main/my-module` |
| SSH URL | `git@github.com:org/repo.git` | | SSH URL | `git@github.com:org/repo.git` |
| Local path | `/Users/me/projects/my-module` | | Local path | `/Users/me/projects/my-module` |

View File

@ -68,6 +68,7 @@ Chọn **Yes**, rồi nhập nguồn:
| Loại đầu vào | Ví dụ | | Loại đầu vào | Ví dụ |
| --------------------- | ------------------------------------------------- | | --------------------- | ------------------------------------------------- |
| HTTPS URL trên bất kỳ host nào | `https://github.com/org/repo` | | HTTPS URL trên bất kỳ host nào | `https://github.com/org/repo` |
| HTTP URL trên bất kỳ host nào | `http://host/org/repo` |
| HTTPS URL trỏ vào một thư mục con | `https://github.com/org/repo/tree/main/my-module` | | HTTPS URL trỏ vào một thư mục con | `https://github.com/org/repo/tree/main/my-module` |
| SSH URL | `git@github.com:org/repo.git` | | SSH URL | `git@github.com:org/repo.git` |
| Đường dẫn cục bộ | `/Users/me/projects/my-module` | | Đường dẫn cục bộ | `/Users/me/projects/my-module` |

View File

@ -68,6 +68,7 @@ Would you like to install from a custom source (Git URL or local path)?
| 输入类型 | 示例 | | 输入类型 | 示例 |
| -------- | ---- | | -------- | ---- |
| HTTPS URL任意主机 | `https://github.com/org/repo` | | HTTPS URL任意主机 | `https://github.com/org/repo` |
| HTTP URL任意主机 | `http://host/org/repo` |
| 带子目录的 HTTPS URL | `https://github.com/org/repo/tree/main/my-module` | | 带子目录的 HTTPS URL | `https://github.com/org/repo/tree/main/my-module` |
| SSH URL | `git@github.com:org/repo.git` | | SSH URL | `git@github.com:org/repo.git` |
| 本地路径 | `/Users/me/projects/my-module` | | 本地路径 | `/Users/me/projects/my-module` |

View File

@ -24,8 +24,9 @@ class CustomModuleManager {
/** /**
* Parse a user-provided source input into a structured descriptor. * Parse a user-provided source input into a structured descriptor.
* Accepts local file paths, HTTPS Git URLs, and SSH Git URLs. * Accepts local file paths, HTTPS Git URLs, HTTP Git URLs, and SSH Git URLs.
* For HTTPS URLs with deep paths (e.g., /tree/main/subdir), extracts the subdir. * For HTTPS/HTTP URLs with deep paths (e.g., /tree/main/subdir), extracts the subdir.
* The original protocol (http or https) is preserved in the returned cloneUrl.
* *
* @param {string} input - URL or local file path * @param {string} input - URL or local file path
* @returns {Object} Parsed source descriptor: * @returns {Object} Parsed source descriptor:
@ -127,11 +128,11 @@ class CustomModuleManager {
}; };
} }
// HTTPS URL: https://host/owner/repo[/tree/branch/subdir][.git] // HTTPS/HTTP URL: https://host/owner/repo[/tree/branch/subdir][.git]
const httpsMatch = trimmed.match(/^https?:\/\/([^/]+)\/([^/]+)\/([^/.]+?)(?:\.git)?(\/.*)?$/); const httpsMatch = trimmed.match(/^(https?):\/\/([^/]+)\/([^/]+)\/([^/.]+?)(?:\.git)?(\/.*)?$/);
if (httpsMatch) { if (httpsMatch) {
const [, host, owner, repo, remainder] = httpsMatch; const [, protocol, host, owner, repo, remainder] = httpsMatch;
const cloneUrl = `https://${host}/${owner}/${repo}`; const cloneUrl = `${protocol}://${host}/${owner}/${repo}`;
let subdir = null; let subdir = null;
let urlRef = null; // branch/tag extracted from /tree/<ref>/subdir let urlRef = null; // branch/tag extracted from /tree/<ref>/subdir
@ -311,7 +312,7 @@ class CustomModuleManager {
/** /**
* Clone a custom module repository to cache. * Clone a custom module repository to cache.
* Supports any Git host (GitHub, GitLab, Bitbucket, self-hosted, etc.). * Supports any Git host (GitHub, GitLab, Bitbucket, self-hosted, etc.).
* @param {string} sourceInput - Git URL (HTTPS or SSH) * @param {string} sourceInput - Git URL (HTTPS, HTTP, or SSH)
* @param {Object} [options] - Clone options * @param {Object} [options] - Clone options
* @param {boolean} [options.silent] - Suppress spinner output * @param {boolean} [options.silent] - Suppress spinner output
* @param {boolean} [options.skipInstall] - Skip npm install (for browsing before user confirms) * @param {boolean} [options.skipInstall] - Skip npm install (for browsing before user confirms)

View File

@ -200,12 +200,15 @@ class UI {
actionType = options.action; actionType = options.action;
await prompts.log.info(`Using action from command-line: ${actionType}`); await prompts.log.info(`Using action from command-line: ${actionType}`);
} else if (options.yes) { } else if (options.yes) {
// Default to quick-update if available, otherwise first available choice // Default to quick-update if available, unless flags that require the
// full update path are present (e.g. --custom-source which re-clones
// modules at a new version — quick-update skips that entirely).
if (choices.length === 0) { if (choices.length === 0) {
throw new Error('No valid actions available for this installation'); throw new Error('No valid actions available for this installation');
} }
const hasQuickUpdate = choices.some((c) => c.value === 'quick-update'); const hasQuickUpdate = choices.some((c) => c.value === 'quick-update');
actionType = hasQuickUpdate ? 'quick-update' : choices[0].value; const needsFullUpdate = !!options.customSource;
actionType = hasQuickUpdate && !needsFullUpdate ? 'quick-update' : (choices.find((c) => c.value === 'update') || choices[0]).value;
await prompts.log.info(`Non-interactive mode (--yes): defaulting to ${actionType}`); await prompts.log.info(`Non-interactive mode (--yes): defaulting to ${actionType}`);
} else { } else {
actionType = await prompts.select({ actionType = await prompts.select({
@ -241,8 +244,11 @@ class UI {
.map((m) => m.trim()) .map((m) => m.trim())
.filter(Boolean); .filter(Boolean);
await prompts.log.info(`Using modules from command-line: ${selectedModules.join(', ')}`); await prompts.log.info(`Using modules from command-line: ${selectedModules.join(', ')}`);
} else if (options.customSource) { } else if (options.customSource && !options.yes) {
// Custom source without --modules: start with empty list (core added below) // Custom source without --modules or --yes: start with empty list
// (only custom source modules + core will be installed).
// When --yes is also set, fall through to the --yes branch so all
// installed modules are included alongside the custom source modules.
selectedModules = []; selectedModules = [];
} else if (options.yes) { } else if (options.yes) {
selectedModules = await this.getDefaultModules(installedModuleIds); selectedModules = await this.getDefaultModules(installedModuleIds);