Skip to content

Commit 79f544f

Browse files
committed
Generate course-level skuilder.json for imported courses
The previous fix only generated course-level skuilder.json files for newly scaffolded empty courses. Imported courses (via --import-course-data) were missing this file, causing the manifest hierarchy to be incomplete. Now packCourses() creates the course-level skuilder.json after each course is successfully packed, ensuring all courses have the complete 3-level structure.
1 parent 5d4872b commit 79f544f

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

packages/cli/src/utils/pack-courses.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import chalk from 'chalk';
22
import path from 'path';
3+
import { promises as fs } from 'fs';
34

45
export interface PackCoursesOptions {
56
server: string;
@@ -39,6 +40,38 @@ export async function packCourses(options: PackCoursesOptions): Promise<void> {
3940
});
4041

4142
console.log(chalk.green(`✅ Successfully packed course: ${courseId}`));
43+
44+
// Create course-level skuilder.json for the packed course
45+
const coursePath = path.join(outputDir, courseId);
46+
const manifestPath = path.join(coursePath, 'manifest.json');
47+
48+
// Read the manifest to get course title
49+
let courseTitle = courseId;
50+
try {
51+
const manifestContent = await fs.readFile(manifestPath, 'utf-8');
52+
const manifest = JSON.parse(manifestContent);
53+
courseTitle = manifest.courseName || manifest.courseConfig?.name || courseId;
54+
} catch (error) {
55+
console.warn(chalk.yellow(`⚠️ Could not read manifest for course title, using courseId`));
56+
}
57+
58+
// Create course-level skuilder.json
59+
const courseSkuilderJson = {
60+
name: `@skuilder/course-${courseId}`,
61+
version: '1.0.0',
62+
description: courseTitle,
63+
content: {
64+
type: 'static',
65+
manifest: './manifest.json',
66+
},
67+
};
68+
69+
await fs.writeFile(
70+
path.join(coursePath, 'skuilder.json'),
71+
JSON.stringify(courseSkuilderJson, null, 2)
72+
);
73+
74+
console.log(chalk.gray(`📄 Created skuilder.json for course: ${courseId}`));
4275
} catch (error: unknown) {
4376
console.error(chalk.red(`❌ Failed to pack course ${courseId}:`));
4477
console.error(chalk.red(error instanceof Error ? error.message : String(error)));

0 commit comments

Comments
 (0)