Skip to content

Commit 488801b

Browse files
authored
Merge pull request #8 from taskade/fix/ci-apps-directory-structure
fix: update CI scripts for apps directory structure
2 parents 27daeb0 + cc770e9 commit 488801b

3 files changed

Lines changed: 72 additions & 12 deletions

File tree

scripts/assemble.mjs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,21 @@ function loadArtifacts(dirName) {
3737
}));
3838
}
3939

40+
function loadAppArtifacts(dirName) {
41+
const dirPath = path.join(ROOT, dirName);
42+
if (!fs.existsSync(dirPath)) {
43+
return [];
44+
}
45+
46+
return fs
47+
.readdirSync(dirPath, { withFileTypes: true })
48+
.filter((entry) => entry.isDirectory())
49+
.map((entry) => ({
50+
id: entry.name,
51+
data: readJson(path.join(dirPath, entry.name, "package.json")),
52+
}));
53+
}
54+
4055
// Read manifest
4156
const manifest = readJson(path.join(ROOT, "manifest.json"));
4257

@@ -46,7 +61,7 @@ const bundle = {
4661
agents: loadArtifacts("agents"),
4762
projects: loadArtifacts("projects"),
4863
automations: loadArtifacts("automations"),
49-
apps: loadArtifacts("apps"),
64+
apps: loadAppArtifacts("apps"),
5065
assembledAt: new Date().toISOString(),
5166
};
5267

scripts/summary.mjs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import path from "node:path";
33

44
const ROOT = process.cwd();
55

6-
const BUNDLE_DIRS = ["agents", "apps", "automations", "projects"];
6+
const JSON_DIRS = ["agents", "automations", "projects"];
7+
const APP_DIR = "apps";
78

89
function listJsonFiles(dirName) {
910
const dirPath = path.join(ROOT, dirName);
@@ -18,6 +19,19 @@ function listJsonFiles(dirName) {
1819
.sort();
1920
}
2021

22+
function listAppDirs(dirName) {
23+
const dirPath = path.join(ROOT, dirName);
24+
if (!fs.existsSync(dirPath)) {
25+
return [];
26+
}
27+
28+
return fs
29+
.readdirSync(dirPath, { withFileTypes: true })
30+
.filter((entry) => entry.isDirectory())
31+
.map((entry) => entry.name)
32+
.sort();
33+
}
34+
2135
function readJson(filePath) {
2236
const raw = fs.readFileSync(filePath, "utf8");
2337
return JSON.parse(raw);
@@ -41,7 +55,7 @@ console.log(`Name: ${manifest.name ?? "Unknown"}`);
4155
console.log(`Space ID: ${manifest.spaceId ?? "Unknown"}`);
4256
console.log(`Version: ${manifest.version ?? "Unknown"}`);
4357

44-
for (const dirName of BUNDLE_DIRS) {
58+
for (const dirName of JSON_DIRS) {
4559
const files = listJsonFiles(dirName);
4660
printHeader(`${dirName} (${files.length})`);
4761

@@ -51,4 +65,10 @@ for (const dirName of BUNDLE_DIRS) {
5165
}
5266
}
5367

68+
const appDirs = listAppDirs(APP_DIR);
69+
printHeader(`${APP_DIR} (${appDirs.length})`);
70+
for (const name of appDirs) {
71+
console.log(`- ${name}`);
72+
}
73+
5474
console.log("\nSummary completed.");

scripts/validate.mjs

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import path from "node:path";
33

44
const ROOT = process.cwd();
55

6-
const REQUIRED_DIRS = ["agents", "apps", "automations", "projects"];
6+
const JSON_DIRS = ["agents", "automations", "projects"];
7+
const APP_DIR = "apps";
78

89
const errors = [];
910

@@ -46,6 +47,25 @@ function listJsonFiles(dirName) {
4647
return files;
4748
}
4849

50+
function listAppDirs(dirName) {
51+
const dirPath = path.join(ROOT, dirName);
52+
if (!fs.existsSync(dirPath)) {
53+
fail(`Missing directory: ${dirName}`);
54+
return [];
55+
}
56+
57+
const dirs = fs
58+
.readdirSync(dirPath, { withFileTypes: true })
59+
.filter((entry) => entry.isDirectory())
60+
.map((entry) => path.join(dirPath, entry.name));
61+
62+
if (dirs.length === 0) {
63+
fail(`Directory has no app subdirectories: ${dirName}`);
64+
}
65+
66+
return dirs;
67+
}
68+
4969
function validateManifest() {
5070
const filePath = path.join(ROOT, "manifest.json");
5171
if (!fs.existsSync(filePath)) {
@@ -87,17 +107,21 @@ function validateAgents() {
87107
}
88108

89109
function validateApps() {
90-
for (const filePath of listJsonFiles("apps")) {
91-
const data = readJson(filePath);
110+
for (const appDir of listAppDirs(APP_DIR)) {
111+
const pkgPath = path.join(appDir, "package.json");
112+
const rel = path.relative(ROOT, appDir);
113+
114+
if (!fs.existsSync(pkgPath)) {
115+
fail(`${rel}: missing package.json`);
116+
continue;
117+
}
118+
119+
const data = readJson(pkgPath);
92120
if (data == null) {
93121
continue;
94122
}
95123

96-
const rel = path.relative(ROOT, filePath);
97-
assert(
98-
typeof data.src === "object" && data.src != null,
99-
`${rel}: src object is required`,
100-
);
124+
assert(typeof data.name === "string", `${rel}/package.json: name must be a string`);
101125
}
102126
}
103127

@@ -138,9 +162,10 @@ function validateProjects() {
138162

139163
validateManifest();
140164

141-
for (const dirName of REQUIRED_DIRS) {
165+
for (const dirName of JSON_DIRS) {
142166
listJsonFiles(dirName);
143167
}
168+
listAppDirs(APP_DIR);
144169

145170
validateAgents();
146171
validateApps();

0 commit comments

Comments
 (0)