Skip to content

Commit 0ffb8e2

Browse files
committed
Add usage instructions
1 parent f42e71c commit 0ffb8e2

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

README.md

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,96 @@ The CLI can:
99
- Upload lessons/units.
1010
- Extract audio from video files.
1111
- Replace audio inside of video files.
12+
13+
# Usage
14+
15+
## Uploading Units
16+
17+
To upload a unit use the `npx cratecode upload path/to/manifest.json` command.
18+
19+
### Creating Lessons/Units
20+
21+
Uploading works by creating a manifest file which imports other manifest files, and can also specify a unit to upload. This "root" manifest file commonly links to either subunits (which in turn link to lessons or other subunits) or lessons, which will be uploaded.
22+
23+
Instead of working with IDs directly, items are linked and mapped with "friendly names", which are human-readable identifiers that are only used during the uploading process. Instead of specifying an ID for a unit/project, specify a friendly name. If the item doesn't already exist, it will be created.
24+
25+
Units can reference lessons or other units. If you need to use someone else's unit/lesson, you can use their ID by starting the ID with a ":" and placing it in the friendly name field.
26+
27+
Unit manifest files contain the definition for the unit. That is, they include a starting lesson for the unit, and what lessons other lessons point to. They follow the following format:
28+
29+
```json
30+
{
31+
"type": "unit",
32+
"id": "friendly_name",
33+
"name": "Display Name",
34+
"upload": ["folder1/manifest.json"],
35+
"lessons": {
36+
"first_lesson": {
37+
"next": ["next_lesson"]
38+
},
39+
"next_lesson": {
40+
"next": []
41+
}
42+
}
43+
}
44+
```
45+
46+
Where `id` is a friendly name/id for the unit, `name` is the display name for the unit, `upload` is a list of manifests that the unit depends on and which will be uploaded, and `lessons` is a list of every lesson included in the unit along with what lessons/units will come after them (`next`), optionally what lessons/units will come before them (`requires`), and optionally if every lesson/unit in `requires` must be completed for them to be available (`requireAll`).
47+
48+
For the root manifest (the one you specify in the upload command), a `templates` item can be specified which points to the templates directory. Every directory in the templates directory will be an available template, which lessons can extend (using their directory names) and use to provide default files.
49+
50+
Lesson manifest files include information about the lesson. They should be included in the directory containing the lesson's contents. For example, a lesson manifest might be in a folder that looks like:
51+
52+
```
53+
folder/
54+
-- index.js
55+
-- manifest.json
56+
-- README.md
57+
```
58+
59+
During the uploading process, `manifest.json`, `config.json`, and `video.cv` will not be uploaded to the lesson files and will be treated separately. For a lesson manifest, the following format is used:
60+
61+
```json
62+
{
63+
"type": "lesson",
64+
"id": "friendly_name",
65+
"name": "Display Name",
66+
"spec": null,
67+
"class": "tutorial"
68+
}
69+
```
70+
71+
Where `id` is a friendly name/id for the unit, `name` is the display name for the unit, `spec` is the specification for what the lesson's code should be, and `class` is the type of lesson (null, `tutorial`, `activity`, `project`, and `challenge`).
72+
73+
A typical setup might look like the below file tree, where the first manifest is the first example manifest and the second manifest is the second example manifest:
74+
75+
```
76+
folder/
77+
-- manifest.json
78+
-- lessons/
79+
-- lesson_1/
80+
-- index.js
81+
-- manifest.json
82+
-- README.md
83+
```
84+
85+
You may also subdivide your unit into multiple smaller units. In the example below, the first two manifests are unit manifests (like the first example manifest), while the second is a lesson manifest (like the second example manifest). In this example, the first manifest may upload the second manifest and link to the unit described by the second manifest, while the second manifest may upload the third and link to the lesson described by the third.
86+
87+
```
88+
folder/
89+
-- manifest.json
90+
-- units/
91+
-- unit_1/
92+
-- manifest.json
93+
-- lessons/
94+
-- lesson_1/
95+
-- index.js
96+
-- manifest.json
97+
-- README.md
98+
```
99+
100+
As you can see, many configurations are possible. To look at an actual example, please head over to the [Cratecode Intro](https://github.com/Cratecode/intro.git) repository.
101+
102+
## Manipulating Videos
103+
104+
You can use the CLI to modify a video's audio. Use the `npx cratecode extract path/to/video.cv` command to extract the audio file, modify it, then use the `npx cratecode combine path/to/video.cv path/to/audio.ogg` command to add the new audio to the video.

0 commit comments

Comments
 (0)