Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 9cc34aa

Browse files
committedApr 19, 2020
ensure tutorial has a unique id by owner/repo:branch
Signed-off-by: shmck <shawn.j.mckay@gmail.com>
1 parent 8ddfcef commit 9cc34aa

File tree

5 files changed

+5419
-13
lines changed

5 files changed

+5419
-13
lines changed
 

‎package-lock.json‎

Lines changed: 5395 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
"eslint": "^6.8.0",
4848
"eslint-config-prettier": "^6.10.1",
4949
"eslint-plugin-prettier": "^3.1.3",
50+
"git-url-parse": "^11.1.2",
5051
"jest": "^25.3.0",
5152
"jsdom": "^16.2.2",
5253
"prettier": "^2.0.4",

‎src/editor/index.ts‎

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,6 @@ class Editor {
1616
})
1717

1818
// commands
19-
this.activateCommands()
20-
21-
// setup tasks or views here
22-
}
23-
public deactivate = (): void => {
24-
// cleanup subscriptions/tasks
25-
for (const disposable of this.vscodeExt.subscriptions) {
26-
disposable.dispose()
27-
}
28-
}
29-
30-
private activateCommands = (): void => {
3119
const commands = createCommands({
3220
extensionPath: this.vscodeExt.extensionPath,
3321
// NOTE: local storage must be bound to the vscodeExt.workspaceState
@@ -40,6 +28,12 @@ class Editor {
4028
this.vscodeExt.subscriptions.push(command)
4129
}
4230
}
31+
public deactivate = (): void => {
32+
// cleanup subscriptions/tasks
33+
for (const disposable of this.vscodeExt.subscriptions) {
34+
disposable.dispose()
35+
}
36+
}
4337
}
4438

4539
export default Editor

‎web-app/src/containers/SelectTutorial/index.tsx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import * as React from 'react'
33
import SelectTutorialForm from './SelectTutorialForm'
44
import TutorialOverview from '../../components/TutorialOverview'
55
import LoadTutorialSummary from './LoadTutorialSummary'
6+
import processTutorial from '../../services/tutorial'
67

78
const styles = {
89
page: {
@@ -39,7 +40,7 @@ const SelectTutorialPage = (props: Props) => {
3940
setPage('loading')
4041
}
4142
const onLoadSummary = (d: TT.Tutorial) => {
42-
setData(d)
43+
setData(processTutorial(d))
4344
setPage('summary')
4445
}
4546
const onClear = () => {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import * as TT from 'typings/tutorial'
2+
// @ts-ignore
3+
import gitUrlParser from 'git-url-parse'
4+
5+
const processTutorial = (tutorial: TT.Tutorial): TT.Tutorial => {
6+
// define tutorial id as the "owner/repo-name"
7+
// see docs at https://github.com/IonicaBizau/git-url-parse
8+
const { repo } = tutorial.config
9+
const { full_name } = gitUrlParser(repo.uri)
10+
tutorial.id = `${full_name}:${repo.branch}`
11+
12+
return tutorial
13+
}
14+
15+
export default processTutorial

0 commit comments

Comments
 (0)
Please sign in to comment.