Skip to content

Commit

Permalink
feat: add default registry
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanFlurry committed Mar 7, 2024
1 parent c77e8a8 commit 9086f91
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 46 deletions.
30 changes: 25 additions & 5 deletions src/project/project.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { dirname, exists, resolve, copy } from "../deps.ts";
import { glob, bold, brightRed } from "./deps.ts";
import { copy, dirname, exists, resolve } from "../deps.ts";
import { bold, brightRed, glob } from "./deps.ts";
import { readConfig as readProjectConfig } from "../config/project.ts";
import { ProjectConfig } from "../config/project.ts";
import { loadModule, Module } from "./module.ts";
Expand Down Expand Up @@ -29,6 +29,7 @@ export async function loadProject(opts: LoadProjectOpts): Promise<Project> {

// Load registries
const registries = new Map();

for (const registryName in projectConfig.registries) {
const registryConfig = projectConfig.registries[registryName];
const registry = await loadRegistry(
Expand All @@ -39,6 +40,25 @@ export async function loadProject(opts: LoadProjectOpts): Promise<Project> {
registries.set(registryName, registry);
}

if (!registries.has("default")) {
const defaultRegistry = await loadRegistry(
projectRoot,
"default",
{
git: {
url: {
https: "https://github.com/rivet-gg/open-game-services.git",
ssh: "[email protected]:rivet-gg/opengb-registry.git",
},
// TODO: https://github.com/rivet-gg/opengb/issues/151
rev: "f28b9c0ddbb69fcc092dfff12a18707065a69251",
directory: "./modules",
},
},
);
registries.set("default", defaultRegistry);
}

// Load modules
const modules = new Map<string, Module>();
for (const projectModuleName in projectConfig.modules) {
Expand Down Expand Up @@ -71,7 +91,9 @@ export async function loadProject(opts: LoadProjectOpts): Promise<Project> {
if (missingDepsByModule.size > 0) {
let message = bold(brightRed("Unresolved module dependencies:\n"));
for (const [moduleName, missingDeps] of missingDepsByModule) {
message += `\tModule ${moduleName} is missing dependencies: ${missingDeps.join(", ")}\n`;
message += `\tModule ${moduleName} is missing dependencies: ${
missingDeps.join(", ")
}\n`;
}
throw new Error(message);
}
Expand All @@ -92,8 +114,6 @@ export async function loadProject(opts: LoadProjectOpts): Promise<Project> {
throw new Error(message);
}



return { path: projectRoot, config: projectConfig, registries, modules };
}

Expand Down
10 changes: 0 additions & 10 deletions src/template/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,6 @@ export async function templateProject(rootPath: string) {
// Create backend.yaml
const defaultBackend: ProjectConfig = {
registries: {
default: {
git: {
url: {
https: "https://github.com/rivet-gg/open-game-services.git",
ssh: "[email protected]:rivet-gg/opengb-registry.git"
},
branch: "main",
directory: "./modules",
},
},
local: {
local: {
directory: "modules",
Expand Down
9 changes: 1 addition & 8 deletions tests/test_project/backend.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
registries:
default:
git:
url:
https: https://github.com/rivet-gg/open-game-services.git
ssh: [email protected]:rivet-gg/opengb-registry.git
rev: f28b9c0ddbb69fcc092dfff12a18707065a69251
directory: ./modules
# default:
# local:
# directory: ../../../opengb-registry/modules
Expand All @@ -17,7 +10,7 @@ modules:
# friends: {}
# rate_limit: {}
# tokens: {}
# users: {}
users: {}
# auth:
# config:
# google:
Expand Down
23 changes: 0 additions & 23 deletions tests/test_project/opengb.yaml

This file was deleted.

0 comments on commit 9086f91

Please sign in to comment.