UNPKG

21.6 kBMarkdownView Raw
1# Tortilla
2
3[![CircleCI](https://circleci.com/gh/Urigo/tortilla.svg?style=svg&circle-token=12d30ba8bd17ea8294ef5430fbeb60af1474ab73)](https://circleci.com/gh/Urigo/tortilla)
4
5<p align="center"><img src="https://cloud.githubusercontent.com/assets/7648874/24250888/833ec58e-0fbf-11e7-95e5-42d5827f0dd6.png" alt="tortilla" width="500"></p>
6
7Tortilla is a framework for building tutorials based on git and NodeJS which will help you create AWESOME tutorials and upload them to any git-host which supports markdown rendering, like GitHub. Tortilla operates by simply wrapping an existing git project, thus providing you with some advanced git functions dedicated to create the most perfect and most beautiful tutorial in the world. In addition, Tortilla is easily accessible through a CLI, making it very convenient to use.
8
9What's the advantages of using Tortilla over writing a simple blog-post?
10- The code and the instructions will always stay correlatively updated.
11- You can reference code snippets directly from the instructions.
12- You can use template-helpers to write complex instructions with minimal efforts.
13- You can take advantages of most git features like creating commits, tags and branches.
14- You can use neat features natively provided with the git host like reporting issues and opening pull requests.
15- The tutorial is linked directly to your git host account.
16- You can enjoy the great traffic of the git host.
17- You can easily navigate through the project at any specific point of the tutorial.
18- You can historicize different versions of your tutorial.
19- You can compare different versions of the tutorial and see the differences.
20- The list goes on and on and on...
21
22Tutorials for example:
23- [How to implement a game engine in JavaScript and build a Tron-style game](https://github.com/DAB0mB/radial-snake)
24- [How to build a Whatsapp-clone using Ionic 2 CLI and Meteor](https://github.com/Urigo/Ionic2CLI-Meteor-WhatsApp)
25
26If you're not familiar with Tortilla I recommend you to go through the this `README.md` file since it contains everything you have to know about Tortilla in order to use it.
27
28[![intro](https://cloud.githubusercontent.com/assets/7648874/25558853/02cbaaf4-2d0e-11e7-89db-9aff3c87cc18.png)](https://www.youtube.com/watch?v=uboqQ8B4XFk)
29
30## Tutorial Structure
31
32See:
33- [steps](#steps)
34 - [sub-steps](#sub-step)
35 - [super-steps](#super-steps)
36- [manuals](#manuals)
37 - [translations](#translations)
38 - [template-helpers](#template-helpers)
39- [releases](#releases)
40 - [release-tags](#release-tags)
41 - [history-branches](#history-branches)
42- [submodules](#submodules)
43 - [checkouts](#checkouts)
44
45### Steps
46
47Each commit should represent a single step in the tutorial, using the following message template:
48
49 Step (step index): (step description)
50
51Here's a list of commits for example:
52
53 Step 2: Add todo-list
54 Step 2.3: Add todo-list controller
55 Step 2.2: Add todo-list view
56 Step 2.1: Add todo-list model
57 Step 1: Bundling
58 Step 1.3: Install the necessary packages for Webpack's build
59 Step 1.2: Add Webpack build to gulp tasks
60 Step 1.1: Create a basic Webpack config
61 How to create a todo list
62
63As you can see, some of the commits represent a [sub-step](#sub-step) (e.g. step 1.1, 1.2) and some of them represent a [super-step](#super-step) (e.g. step 1, 2); Together they form a whole single step. Note that the only exception is the root commit whose message can be whatever you'd like (will most likely be something which describes the tutorial), but the rest of the commits **must** follow these rules, otherwise you will encounter some unexpected behaviors.
64
65> Credit goes to **[@stubailo](http://www.github.com/stubailo)** who originally came up with the commit templates concept.
66
67**Related CLI:** [tortilla-step CLI](#tortilla-step-cli)
68
69#### Sub Step
70
71A sub-step is a small portion of the whole step. Each sub-step should usually represent a small change which should be followed by an explanation in the tutorial. Sub-steps should be sorted by their chronological order; Sub-steps which assemble the same step should have the same super index, and a consecutive sub index separated by a period (e.g. 1.1, 1.2).
72
73#### Super Step
74
75A super-step should **always** come at the end of each step, and should be represented with a single index (e.g. 1, 2). The super-step should add a [manual](#manuals) file which goes through the implementation of the associated step.
76
77### Manuals
78
79Manuals are markdown files which should contain some handy instructions regards the implementation of each step in the tutorial. The manuals are located under the `.tortilla/manuals` directory, and are separated into 2 directories - `templates` and `views`. When writing manuals, we should never touch the `views` files, because they should be auto-generated by Tortilla's CLI. The `templates` directory, as the name suggests, should contain manual templates. Just so you can get the idea, here's an example of a `.tortilla/manuals` directory structure:
80
81 .tortilla/manuals
82 ├─ templates
83 │ ├ root.tmpl
84 │ ├ step1.tmpl
85 │ ├ step2.tmpl
86 │ └ step3.tmpl
87 └─ views
88 ├ root.md
89 ├ step1.md
90 ├ step2.md
91 └ step3.md
92
93The main difference between a manual template and a manual view is that templates are more simplified and will be most likely used for development purposes. They contain some handy [template helpers](#template-helpers) we can be used to render complex markdown components, so our tutorial can be good-looking and easy-to-read, with minimum maintenance. As you can see in the files tree above, manual template files have an extension of `.tmpl`, unlike their belonging views which finish with an extension of `.md`. That's because the manual templates are not exactly markdown files, since they are packed with some extra syntactic abilities provided by [Handlebars'](http://handlebarsjs.com/) simple yet powerful templating engine. Indeed, you can still use markdown's templating syntax, but just know that this is not a pure markdown we're talking about. The only template-view fs correlation exception is the `root.tmpl` file which should be mapped to the `README.md` file, so we can see a nice introduction for our tutorial when entering the repository. The `root.md` file is just a symbolic link to the main `README.md` file.
94
95Note that manual templates shouldn't be written with a title, since it should be attached automatically when rendering the template's view using its belonging commit message. In addition, a navigation bar between steps should be appended at the end of the manual. For example, a root manual template which looks likes this:
96
97```
98- FOO
99- BAR
100- BAZ
101```
102
103And is matched with the commit message:
104
105 Les Trois Mousquetaires
106
107Should result with the following view after rendering:
108
109```md
110# Les Trois Mousquetaires
111
112- FOO
113- BAR
114- BAZ
115
116[{]: <helper> (navStep)
117
118| [Begin Tutorial >](manuals/views/step1.md) |
119|----------------------:|
120
121[}]: #
122```
123
124**Related CLI:** [tortilla-manual CLI](#tortilla-manual-cli)
125
126#### Translations
127
128Manuals don't necessarily have to be written in English, and can be also be written in whatever language you'd choose. Translated manual templates are located under the `templates/locales/your-language` path, and their belonging views are localed under `views/locales/your-language`. Here's an example of a manuals directory with manuals which are translated into Hebrew (`he`):
129
130 .tortilla/manuals
131 ├─ templates
132 │ ├ root.tmpl
133 │ ├ step1.tmpl
134 │ ├ step2.tmpl
135 │ ├ step3.tmpl
136 │ └ locales/he
137 │ ├ root.tmpl
138 │ ├ step1.tmpl
139 │ ├ step2.tmpl
140 │ └ step3.tmpl
141 └─ views
142 ├ root.md
143 ├ step1.md
144 ├ step2.md
145 ├ step3.md
146 └ locales/he
147 ├ root.md
148 ├ step1.md
149 ├ step2.md
150 └ step3.md
151
152Translations for step messages (and potentially other stuff) can be defined under the `.tortilla/locales` directory in a `json` file with the relevant language code (e.g. `.tortilla/locales/he.json`). Here's an example of a translation file which translates step messages:
153
154```json
155{
156 "step": {
157 "root": "כיצד ליצור רשימת מטלות",
158 "1.1": "יצירת קובץ הגדרות בסיסי ל Webpack",
159 "1.2": "הוספת משימה של בנייה בעזרת Webpack לרשימת המשימות של gulp",
160 "1.3": "התקנת החבילות הנחוצות בכדי שנוכל לבנות בעזרת Webpack",
161 "1": "צרירת הפרוייקט",
162 "2.1": "יצירת מודל למטלה יחידה",
163 "2.2": "יצירת רשימת מטלות ויזואלית",
164 "2.3": "יצירת רשימת מטלות לוגית",
165 "2": "הוספת רשימת מטלות"
166 }
167}
168```
169
170#### Template Helpers
171
172Template helpers are used when writing a manual file to make our lives a bit easier when it comes to formatting complex markdown components. The templates are rendered using [Handlebars'](http://handlebarsjs.com/) templating, so I recommend you to go through its rules and syntax so you can be familiar with it, but just for the heck of demonstration, a manual template file which looks like this:
173
174```
175*Here's how we should use template-helpers*
176
177{{{diffStep 1.1}}}
178```
179
180Should be rendered to:
181
182```md
183*Here's how we should use template-helpers*
184
185[{]: <helper> (diffStep 1.1)
186
187#### Step 1.1: Demo commit
188
189##### Added demo-file.js
190\`\`\`diff
191@@ -0,0 +1,3 @@
192+┊ ┊1┊foo
193+┊ ┊2┊bar
194+┊ ┊3┊baz🚫↵
195\`\`\`
196
197[}]: #
198```
199
200**🌟 Available {{view models}} 🌟**
201
202- `step` - The number of the current step.
203
204- `commit_message` - The current commit message.
205
206**🌟 Available {{{template helpers}}} 🌟**
207
208- `navStep` - A navigation bar between step manuals. Will present two buttons - "Previous step" and "Next step". This template helper may receives the following options:
209 - `prevRef` - The reference which we will be redirected to once pressed on "Previous step" button.
210 - `nextRef` - The reference which we will be redirected to once pressed on "Next step" button.
211
212- `diffStep <step>` - Will run `git diff` for the specified step's commit. This template helper may receives the following options:
213 - `files` - A list of specific file paths separated by a comma (`,`) that we would like to present in our diff. The rest of the files in the diff will be ignored.
214 - `submodule` - The name of the submodule which contains the step we would like to reference.
215
216### Releases
217
218A Tortilla project may contain [release tags](#release-tags) which represent different versions of the tutorial in different time points. Here's a list of tags for example:
219
220 master@root@0.0.1
221 master@step1@0.0.1
222 master@0.0.1
223 master@root@0.1.0
224 master@step1@0.1.0
225 master@0.1.0
226 foo@root@0.0.1
227 foo@step1@0.0.1
228 foo@0.0.1
229
230In addition, a stack of all the releases is available through [history branches](#history-branches):
231
232 master-history
233 foo-history
234
235**Related CLI:** [tortilla-release CLI](#tortilla-release-cli)
236
237#### Release Tags
238
239A release tag should represent the tutorial at a specific state (e.g. step 2 of master branch) and time point (e.g. version 1.2.1). A release tag should contain the name of the branch, the step descriptor, if at all, and a [semver](http://semver.org/) version, separated with at (`@`) signs (e.g. `master@step1@0.0.1`, `foo@0.1.0`).
240
241#### History Branches
242
243The history is specific for a certain branch. Its name should end with `history` preceded by the branch name (e.g. `master-history`). Each commit in that branch represents all the changes made in a specific release, making the comparison between releases much easier (even if they have different roots!). Here's an example of a commits list in a history branch named `master-history`:
244
245 master@1.0.0: Add favorites page
246 master@0.0.2: Update step 2
247 master@0.0.1: Initial tutorial creation
248
249### Submodules
250
251Often times, we would like to have a single repository where we include all the manual files, and the implementation logic would be implemented in different repositories which will be referenced from the main repository using git's submodules architecture; E.g. a single repository that includes submodules referencing the client and the server. Another advantage for that architecture is that we can implement similar applications using different stacks, or having a single back-end for multiple front-end applications, with almost identical instructions.
252
253**Related CLI:** [tortilla-submodule CLI](#tortilla-submodule-cli)
254
255#### Checkouts
256
257There would be cases where submodule's steps won't be correlated to the same step indices in the main repository; E.g. in manual file for step 3 the client would be set to step 1 and the server would be et to step 2. In-order to specify which steps should be checked out in the submodules for each step in the main repository, we would need to specify a `checkouts.json` file under the `.tortilla` directory. Here's an example checkouts file:
258
259```json
260{
261 "server": {
262 "head": "master",
263 "steps": ["root", "root", 1, 1]
264 },
265 "client": {
266 "head": "master",
267 "steps": ["root", 1, 1, 2]
268 }
269}
270```
271
272Each key represents a submodule name. The `head` property represents which branch should be checked out before looking for the steps at each submodule, and the `steps` property represents the steps that should be checked out at the submodule at each step at the main repository (e.g. "root" would be checked out at the server and step number 1 would be checked out in the client for step 1 in the main repository). Needless to say that submodules should be defined beforehand.
273
274## Quick Startup
275
276First you will need to install Tortilla's CLI tool:
277
278 $ sudo npm install tortilla -g
279
280Once you have it installed you can go ahead and create a new Tortilla project:
281
282 $ tortilla create my-tutorial -m "How to create my app"
283
284This command will initialize a new Tortilla project called `my-tutorial` with an initial commit message of `How to create my app`.
285
286After uploading this project and cloning it, be sure to initialize Tortilla so it can work properly:
287
288 $ git clone git@github.com:John/my-tutorial.git
289 $ tortilla init my-tutorial
290
291A manual page for the usage of Tortilla's CLI tool can be brought any time by typing the following:
292
293 $ tortilla --help
294
295For further information, I'd recommend you going through the [CLI](#CLI) section.
296
297## CLI
298
299See:
300
301- [tortilla](#tortilla-cli)
302 - [tortilla-manual](#tortilla-manual-cli)
303 - [tortilla-release](#tortilla-release-cli)
304 - [tortilla-step](#tortilla-step-cli)
305 - [tortilla-strict](#tortilla-strict-cli)
306 - [tortilla-package](#tortilla-package-cli)
307
308### tortilla CLI
309
310**command:** `tortilla create [name]`
311
312Creates a new Tortilla project with the provided name.
313
314- *option:* `-o, --output [path]` - The output path of the newly created project.
315- *option:* `-m, --message [message]` - The created project's initial commit's message.
316- *option:* `--override` - Override project directory if already exists.
317
318**command:** `tortilla init [name]`
319
320Initializes Tortilla essentials in the provided project.
321
322**command:** `tortilla dump [out]`
323
324Dumps tutorial data as a JSON file. The default dump file name would be `tutorial.json`, although an optional output path might be provided. Here's a brief description of the schema of the generated dump file:
325
326```json
327[
328 {
329 "branchName": "Current branch",
330 "historyBranchName": "History branch matching current branch",
331 "releases": [
332 {
333 "ReleaseVersion": "x.x.x",
334 "tagName": "The name of the tag",
335 "tagRevision": "The revision of the tag",
336 "historyRevision": "Commit hash based on history branch",
337 "manuals": [
338 {
339 "manualTitle": "Step commit message",
340 "stepRevision": "Step commit revision",
341 "manualView": "Manual view content"
342 }
343 ]
344 }
345 ]
346 }
347]
348```
349
350- *option:* `--filter [filter]` - A list of branches we would like to filter separated with spaces.
351- *option:* `--reject [reject]` - A list of branches we would like to reject separated with spaces.
352- *option:* `--override` - Override file if already exists.
353
354### tortilla-manual CLI
355
356For more information see the [manuals](#manuals) section.
357
358**command:** `tortilla manual render [step]`
359
360Renders specified manual view.
361
362- *option:* `--root` - Render root manual (`README.md`).
363- *option:* `--all` - Render all manuals.
364
365### tortilla-release CLI
366
367For more information see the [releases](#releases) section.
368
369**command:** `tortilla release bump <type>`
370
371Bumps the current release of the tutorial. This will create some new release tags accordingly and will update the associated history branch. The provided type represents a [semver version type](http://semver.org/) (major, minor and patch) we would like to bump.
372
373- *option:* `-m, --message [message]` - A message describing the newly created release. If not provided, and editor will be opened instead where we can type a full document.
374
375**command:** `tortilla release current`
376
377Prints the current release.
378
379**command:** `tortilla release diff <sourceRelease> <destinationRelease>`
380
381Runs `git diff` between 2 specified releases. This will also be able to run the operation between 2 different releases which are completely different from their root! You can also provide this command with some additional native [git-diff options](https://git-scm.com/docs/git-diff#_options).
382
383### tortilla-step CLI
384
385For more information see the [steps](#steps) section.
386
387**command:** `tortilla step push`
388
389Pushes a new step. Staged files will be committed along with this step.
390
391- *option:* `-m, --message [message]` - A message describing the newly created step.
392
393**command:** `tortilla step pop`
394
395Pops the most recent step. This will completely discard the step's changes.
396
397**command:** `tortilla step tag`
398
399Mark this step as finished and move on to the next one. This will increase the index of the [super-step](#super-steps) and zero the index of the [sub-step](#sub-steps).
400
401- *option:* `-m, --message [message]` - A message describing the newly created step.
402
403**command:** `tortilla step edit [step]`
404
405Edits the specified step/s. This will enter rebase mode where the step's hash is at. Once finished editing, you may proceed using [git-rebase commands](https://git-scm.com/docs/git-rebase).
406
407- *option:* `--root` - Edit the root step (initial commit).
408- *option:* `--udiff [path]` - Updates the `diffStep` template helpers of manuals being rebased. Note that manuals prior to the current step being edited won't be updated, since the rebasing process never looks backwards. An optional can be provided which will be a reference to another repository which contains the current repository as a submodule; This will result in updating the provided repository's manuals rather than the current one. Note that submodule's package names located in `package.json` should be distinct.
409
410**command:** `tortilla step reword [step]`
411
412Rename the specified step's commit message.
413
414- *option:* `-m, --message [message]` - The new message of the reworded step. If not provided, and editor will be opened instead where we can type a full document.
415
416### tortilla-strict CLI
417
418Strict mode determines whether Tortilla's git-hook validations are enabled or disabled. It's highly recommended to leave it on, since you might accidentally digress from Tortilla's strict project rules.
419
420**command:** `tortilla strict get`
421
422Prints whether strict mode is enabled or disabled.
423
424**command:** `tortilla strict set <mode>`
425
426Sets strict mode. Provided mode must be either a truthy value (e.g. `1`, `true`) or a falsy value (`0`, `false`).
427
428### tortilla-submodule CLI
429
430Submodules are useful whenever you would like to split the tutorial into different logical segments, e.g. we will have the repo with all the instructions manual referencing the backend repo and the frontend repo.
431
432**command:** `tortilla submodule add <remotes...>`
433
434Add a new submodules to the root commit. We can either provide a set of remotes or a remote following by its submodule name. A remote and a submodule will be differentiated based on whether they contain a `/` character or not, which indicates that a remote path was provided.
435
436**command:** `tortilla submodule remove [submodules...]`
437
438Remove submodules from the root commit. If non was provided - will remove all submodules.
439
440**command:** `tortilla submodule update [submodules...]`
441
442Update submodules in the root commit. If non was provided - will update all submodules.
443
444**command:** `tortilla submodule reset [submodules...]`
445
446Reset submodules in the root commit. If non was provided - will update all submodules. Unlike the `update` function, this will remove all the given submodules and re-add them, which will always result in the most recent submodules, event if the HEAD was rebased.
447
448### tortilla-package CLI
449
450`package.json` related commands are useful when we wanna update our dependencies' versions all across the tutorial, without needing to deal with any conflicts across the process.
451
452**command:** `tortilla pacakge update-deps`
453
454This will start the dependencies updating process by creating a temporary file will contain a list of all our dependencies (merged with dev and peer) where we can specify the new versions that we would like to use in our tutorial. Once this file has been saved and closed Tortilla will handle the rebasing process.
455
456## License
457
458MIT