-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
975 additions
and
156 deletions.
There are no files selected for viewing
This file contains 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 @@ | ||
node_modules/ |
This file contains 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,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 }; |
This file contains 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,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" | ||
} | ||
} |
Oops, something went wrong.