Skip to content

Commit

Permalink
Merge branch 'main' into chores/add-deploy-for-bootstrap
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasisnes committed Oct 8, 2024
2 parents cd8107d + 6328a5f commit 37afcf2
Show file tree
Hide file tree
Showing 39 changed files with 1,243 additions and 250 deletions.
1 change: 1 addition & 0 deletions .github/scripts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
48 changes: 48 additions & 0 deletions .github/scripts/_meta.mts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { globby } from "globby";
import path from "node:path";
import fs from "node:fs";

export type VerticalType = "app" | "lib" | "pkg";

export type Vertical = {
readonly type: VerticalType;
readonly name: string;
readonly path: string;
readonly rawConfig: Readonly<Record<string, unknown>>;
};

const vertialDirs = {
app: "src/apps",
lib: "src/libs",
pkg: "src/pkgs",
};

const readVertical = (type: VerticalType, dirPath: string): Vertical => {
const verticalPath = path.resolve(dirPath);
const dirName = path.basename(verticalPath);
const configPath = path.resolve(verticalPath, "conf.json");

let config: Readonly<Record<string, unknown>> = {};
try {
const json = fs.readFileSync(configPath, { encoding: "utf-8" });
config = JSON.parse(json);
} catch (e) {}

let name = dirName;
if (typeof config.name === "string" && config.name) {
name = config.name;
}

return { type, name, path: verticalPath, rawConfig: config };
};

const apps = await globby(`${vertialDirs.app}/*`, { onlyDirectories: true });
const libs = await globby(`${vertialDirs.lib}/*`, { onlyDirectories: true });
const pkgs = await globby(`${vertialDirs.pkg}/*`, { onlyDirectories: true });
const verticals = [
...apps.map((app) => readVertical("app", app)),
...libs.map((lib) => readVertical("lib", lib)),
...pkgs.map((pkg) => readVertical("pkg", pkg)),
];

export { verticals };
17 changes: 17 additions & 0 deletions .github/scripts/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"name": "scripts",
"version": "0.0.0",
"description": "",
"keywords": [],
"author": "",
"private": true,
"devDependencies": {
"@octokit/action": "^7.0.0",
"@types/node": "^20.11.30",
"chalk": "^5.3.0",
"globby": "^14.0.1",
"tsx": "^4.7.1",
"typescript": "^5.4.3",
"zx": "^8.0.0"
}
}
Loading

0 comments on commit 37afcf2

Please sign in to comment.