replicas-cli 0.3.594 → 0.3.596
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +122 -22
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -26526,13 +26526,15 @@ It changes the theme of the one person who has written in this workspace, and pr
|
|
|
26526
26526
|
|
|
26527
26527
|
## Repositories
|
|
26528
26528
|
|
|
26529
|
-
|
|
26529
|
+
List connected repos, see which GitHub or GitLab repos are available to connect, or connect one (admins only):
|
|
26530
26530
|
|
|
26531
26531
|
\`\`\`bash
|
|
26532
26532
|
replicas repos
|
|
26533
|
+
replicas repos available [--provider github|gitlab]
|
|
26534
|
+
replicas repos add <owner/name> [--provider github|gitlab] [-b <branch>]
|
|
26533
26535
|
\`\`\`
|
|
26534
26536
|
|
|
26535
|
-
|
|
26537
|
+
If the org hasn't connected GitHub or GitLab yet, point the user at the integrations page in the dashboard first. Once connected, you can list and add repos directly from the CLI.
|
|
26536
26538
|
|
|
26537
26539
|
## \`replicas.json\` / \`replicas.yaml\`
|
|
26538
26540
|
|
|
@@ -40734,7 +40736,7 @@ var CLI_VERSION;
|
|
|
40734
40736
|
var init_cli_version = __esm({
|
|
40735
40737
|
"../shared/src/cli-version.ts"() {
|
|
40736
40738
|
"use strict";
|
|
40737
|
-
CLI_VERSION = "0.3.
|
|
40739
|
+
CLI_VERSION = "0.3.596";
|
|
40738
40740
|
}
|
|
40739
40741
|
});
|
|
40740
40742
|
|
|
@@ -41524,9 +41526,26 @@ var init_workspace_wait = __esm({
|
|
|
41524
41526
|
});
|
|
41525
41527
|
|
|
41526
41528
|
// ../shared/src/routes/repositories.ts
|
|
41529
|
+
var githubAddRepositoryRequest, gitlabAddRepositoryRequest;
|
|
41527
41530
|
var init_repositories = __esm({
|
|
41528
41531
|
"../shared/src/routes/repositories.ts"() {
|
|
41529
41532
|
"use strict";
|
|
41533
|
+
githubAddRepositoryRequest = (repository) => ({
|
|
41534
|
+
provider: "github",
|
|
41535
|
+
name: repository.fullName,
|
|
41536
|
+
url: repository.cloneUrl,
|
|
41537
|
+
default_branch: repository.defaultBranch || "main",
|
|
41538
|
+
github_installation_id: repository.installationId,
|
|
41539
|
+
github_repository_id: repository.id
|
|
41540
|
+
});
|
|
41541
|
+
gitlabAddRepositoryRequest = (repository) => ({
|
|
41542
|
+
provider: "gitlab",
|
|
41543
|
+
name: repository.nameWithNamespace,
|
|
41544
|
+
url: repository.cloneUrl,
|
|
41545
|
+
default_branch: repository.defaultBranch || "main",
|
|
41546
|
+
gitlab_project_id: repository.id,
|
|
41547
|
+
gitlab_path_with_namespace: repository.pathWithNamespace
|
|
41548
|
+
});
|
|
41530
41549
|
}
|
|
41531
41550
|
});
|
|
41532
41551
|
|
|
@@ -54410,6 +54429,49 @@ var init_version_check = __esm({
|
|
|
54410
54429
|
});
|
|
54411
54430
|
|
|
54412
54431
|
// src/commands/repositories.ts
|
|
54432
|
+
function parseProviderOption(provider2) {
|
|
54433
|
+
if (!provider2) return void 0;
|
|
54434
|
+
const normalized = provider2.toLowerCase();
|
|
54435
|
+
if (normalized === "github" || normalized === "gitlab") return normalized;
|
|
54436
|
+
throw new Error(`Invalid provider "${provider2}". Use "github" or "gitlab".`);
|
|
54437
|
+
}
|
|
54438
|
+
async function fetchAvailableRepositories(provider2) {
|
|
54439
|
+
const fetchGithub = async () => {
|
|
54440
|
+
try {
|
|
54441
|
+
return await orgAuthenticatedFetch("/v1/github/repositories");
|
|
54442
|
+
} catch (error62) {
|
|
54443
|
+
if (!provider2 && error62 instanceof ApiError && error62.status === 409) return null;
|
|
54444
|
+
throw error62;
|
|
54445
|
+
}
|
|
54446
|
+
};
|
|
54447
|
+
const fetchGitlab = async () => {
|
|
54448
|
+
try {
|
|
54449
|
+
return await orgAuthenticatedFetch("/v1/gitlab/repositories");
|
|
54450
|
+
} catch (error62) {
|
|
54451
|
+
if (!provider2 && error62 instanceof ApiError && error62.status === 412) return null;
|
|
54452
|
+
throw error62;
|
|
54453
|
+
}
|
|
54454
|
+
};
|
|
54455
|
+
const [github, gitlab] = await Promise.allSettled([
|
|
54456
|
+
provider2 === "gitlab" ? Promise.resolve(null) : fetchGithub(),
|
|
54457
|
+
provider2 === "github" ? Promise.resolve(null) : fetchGitlab()
|
|
54458
|
+
]);
|
|
54459
|
+
if (provider2 === "github" && github.status === "rejected") throw github.reason;
|
|
54460
|
+
if (provider2 === "gitlab" && gitlab.status === "rejected") throw gitlab.reason;
|
|
54461
|
+
const warnings2 = [];
|
|
54462
|
+
for (const [name, result] of [["GitHub", github], ["GitLab", gitlab]]) {
|
|
54463
|
+
if (result.status === "rejected") {
|
|
54464
|
+
warnings2.push(`${name}: ${result.reason instanceof Error ? result.reason.message : String(result.reason)}`);
|
|
54465
|
+
}
|
|
54466
|
+
}
|
|
54467
|
+
const githubRepositories = github.status === "fulfilled" ? github.value : null;
|
|
54468
|
+
const gitlabRepositories = gitlab.status === "fulfilled" ? gitlab.value : null;
|
|
54469
|
+
if (warnings2.length && !githubRepositories && !gitlabRepositories) {
|
|
54470
|
+
throw new Error(`Could not list repositories. ${warnings2.join("; ")}`);
|
|
54471
|
+
}
|
|
54472
|
+
for (const warning of warnings2) console.error(`Warning: Could not list ${warning}`);
|
|
54473
|
+
return { github: githubRepositories, gitlab: gitlabRepositories, incomplete: warnings2.length > 0 };
|
|
54474
|
+
}
|
|
54413
54475
|
async function repositoriesListCommand() {
|
|
54414
54476
|
ensureOrgApiAuthenticated();
|
|
54415
54477
|
output2(await orgAuthenticatedFetch("/v1/repositories"), ({ repositories }) => {
|
|
@@ -54429,6 +54491,9 @@ Repositories (${repositories.length}):
|
|
|
54429
54491
|
if (repo.github_repository_id) {
|
|
54430
54492
|
console.log(import_chalk20.default.gray(` GitHub ID: ${repo.github_repository_id}`));
|
|
54431
54493
|
}
|
|
54494
|
+
if (repo.gitlab_project_id) {
|
|
54495
|
+
console.log(import_chalk20.default.gray(` GitLab Project ID: ${repo.gitlab_project_id}`));
|
|
54496
|
+
}
|
|
54432
54497
|
console.log();
|
|
54433
54498
|
}
|
|
54434
54499
|
});
|
|
@@ -54441,29 +54506,63 @@ async function resolveRepositoryIds(inputs) {
|
|
|
54441
54506
|
return repository.id;
|
|
54442
54507
|
});
|
|
54443
54508
|
}
|
|
54444
|
-
async function repositoriesAvailableCommand() {
|
|
54445
|
-
|
|
54446
|
-
|
|
54447
|
-
|
|
54509
|
+
async function repositoriesAvailableCommand(options = {}) {
|
|
54510
|
+
const provider2 = parseProviderOption(options.provider);
|
|
54511
|
+
const { github, gitlab } = await fetchAvailableRepositories(provider2);
|
|
54512
|
+
const repositories = [
|
|
54513
|
+
...(github?.repositories ?? []).map((repo) => ({
|
|
54514
|
+
provider: "github",
|
|
54515
|
+
fullName: repo.fullName,
|
|
54516
|
+
defaultBranch: repo.defaultBranch
|
|
54517
|
+
})),
|
|
54518
|
+
...(gitlab?.repositories ?? []).map((repo) => ({
|
|
54519
|
+
provider: "gitlab",
|
|
54520
|
+
fullName: repo.pathWithNamespace,
|
|
54521
|
+
defaultBranch: repo.defaultBranch
|
|
54522
|
+
}))
|
|
54523
|
+
];
|
|
54524
|
+
output2({ repositories, github, gitlab }, () => {
|
|
54525
|
+
if (gitlab?.hasMore) {
|
|
54526
|
+
console.log("Warning: GitLab results are incomplete. Only the most recently active projects are listed; older projects may be missing.");
|
|
54527
|
+
}
|
|
54528
|
+
if (repositories.length === 0) {
|
|
54529
|
+
if (github && !github.hasInstallations) {
|
|
54530
|
+
console.log(`The GitHub app is not installed. Install it: ${github.installUrl}`);
|
|
54531
|
+
return;
|
|
54532
|
+
}
|
|
54533
|
+
if (!github && !gitlab) {
|
|
54534
|
+
console.log("Neither GitHub nor GitLab is connected. Connect one in the Replicas dashboard first.");
|
|
54535
|
+
return;
|
|
54536
|
+
}
|
|
54537
|
+
console.log("No available repositories found.");
|
|
54448
54538
|
return;
|
|
54449
54539
|
}
|
|
54450
|
-
for (const repository of repositories)
|
|
54540
|
+
for (const repository of repositories) {
|
|
54541
|
+
console.log(`${repository.provider} ${repository.fullName} ${repository.defaultBranch ?? ""}`);
|
|
54542
|
+
}
|
|
54451
54543
|
});
|
|
54452
54544
|
}
|
|
54453
54545
|
async function repositoriesAddCommand(fullName, options) {
|
|
54454
|
-
const
|
|
54455
|
-
const
|
|
54456
|
-
|
|
54457
|
-
const
|
|
54458
|
-
|
|
54459
|
-
|
|
54460
|
-
|
|
54461
|
-
|
|
54462
|
-
|
|
54463
|
-
|
|
54464
|
-
};
|
|
54546
|
+
const provider2 = parseProviderOption(options.provider);
|
|
54547
|
+
const { github, gitlab, incomplete } = await fetchAvailableRepositories(provider2);
|
|
54548
|
+
const target = fullName.toLowerCase();
|
|
54549
|
+
const githubMatch = github?.repositories.find((item) => item.fullName.toLowerCase() === target);
|
|
54550
|
+
const gitlabMatch = gitlab?.repositories.find(
|
|
54551
|
+
(item) => item.pathWithNamespace.toLowerCase() === target || item.nameWithNamespace.toLowerCase() === target
|
|
54552
|
+
);
|
|
54553
|
+
if (githubMatch && gitlabMatch) {
|
|
54554
|
+
throw new Error(`Multiple repositories match "${fullName}" (GitHub and GitLab). Pass --provider github or --provider gitlab.`);
|
|
54555
|
+
}
|
|
54556
|
+
const matched = githubMatch ? { body: githubAddRepositoryRequest(githubMatch), label: githubMatch.fullName } : gitlabMatch ? { body: gitlabAddRepositoryRequest(gitlabMatch), label: gitlabMatch.pathWithNamespace } : null;
|
|
54557
|
+
if (!matched) {
|
|
54558
|
+
if (gitlab?.hasMore || incomplete) {
|
|
54559
|
+
throw new Error(`Could not determine whether "${fullName}" is reachable: ${gitlab?.hasMore ? "the GitLab project list is incomplete and may omit older projects" : "a provider could not be searched (see warning above)"}.`);
|
|
54560
|
+
}
|
|
54561
|
+
throw new Error(`${fullName} is not reachable by any connected GitHub or GitLab integration. List options with: replicas repos available`);
|
|
54562
|
+
}
|
|
54563
|
+
const body2 = options.defaultBranch ? { ...matched.body, default_branch: options.defaultBranch } : matched.body;
|
|
54465
54564
|
await orgAuthenticatedFetch("/v1/repositories", { method: "POST", body: body2 });
|
|
54466
|
-
outputSuccess(`Added ${
|
|
54565
|
+
outputSuccess(`Added ${matched.label}`);
|
|
54467
54566
|
}
|
|
54468
54567
|
async function repositoriesUpdateCommand(repository, options) {
|
|
54469
54568
|
const [id] = await resolveRepositoryIds([repository]);
|
|
@@ -54490,6 +54589,7 @@ var init_repositories2 = __esm({
|
|
|
54490
54589
|
init_api2();
|
|
54491
54590
|
init_command_utils();
|
|
54492
54591
|
init_output();
|
|
54592
|
+
init_src();
|
|
54493
54593
|
splitList = (value) => value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
54494
54594
|
}
|
|
54495
54595
|
});
|
|
@@ -59112,8 +59212,8 @@ var init_src2 = __esm({
|
|
|
59112
59212
|
automation.action(run(() => automationListCommand({})));
|
|
59113
59213
|
repos = program.command("repos").description("Manage repositories");
|
|
59114
59214
|
repos.command("list").description("List all repositories").action(run(repositoriesListCommand));
|
|
59115
|
-
repos.command("available").description("List GitHub repositories
|
|
59116
|
-
repos.command("add <owner/name>").description("Add a GitHub repository (admins only)").option("-b, --default-branch <branch>", "Default branch (defaults to the
|
|
59215
|
+
repos.command("available").description("List GitHub and GitLab repositories Replicas can add").option("--provider <provider>", "Filter by provider: github or gitlab").action(run(repositoriesAvailableCommand));
|
|
59216
|
+
repos.command("add <owner/name>").description("Add a GitHub or GitLab repository (admins only)").option("-b, --default-branch <branch>", "Default branch (defaults to the repository default)").option("--provider <provider>", "Provider: github or gitlab").action(run(repositoriesAddCommand));
|
|
59117
59217
|
repos.command("update <name-or-id>").description("Change the default branch of a repository (admins only)").requiredOption("-b, --default-branch <branch>", "New default branch").action(run(repositoriesUpdateCommand));
|
|
59118
59218
|
repos.command("delete <name-or-id>").description("Remove a repository (admins only)").action(run(repositoriesDeleteCommand));
|
|
59119
59219
|
repos.command("branches <name-or-id>").description("List branches of a repository").action(run(repositoriesBranchesCommand));
|