@learnpack/learnpack 2.1.43 → 2.1.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +364 -29
- package/lib/utils/checkNotInstalled.js +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/start.ts +339 -339
- package/src/models/config.ts +91 -91
- package/src/models/socket.ts +59 -59
- package/src/utils/checkNotInstalled.ts +42 -42
package/src/models/config.ts
CHANGED
@@ -1,91 +1,91 @@
|
|
1
|
-
import { IExercise } from "./exercise-obj"
|
2
|
-
import { TTelemetryUrls } from "../managers/telemetry"
|
3
|
-
|
4
|
-
export type TGrading = "isolated" | "incremental" | "no-grading";
|
5
|
-
|
6
|
-
export type TMode = "preview" | "extension";
|
7
|
-
|
8
|
-
export type TConfigAction =
|
9
|
-
| "test"
|
10
|
-
| "build"
|
11
|
-
| "tutorial"
|
12
|
-
| "reset"
|
13
|
-
| "generate";
|
14
|
-
|
15
|
-
export type TConfigObjAttributes = "config" | "exercises" | "grading";
|
16
|
-
|
17
|
-
export type TCompiler =
|
18
|
-
| "webpack"
|
19
|
-
| "vanillajs"
|
20
|
-
| "react"
|
21
|
-
| "html"
|
22
|
-
| "node"
|
23
|
-
| "python"
|
24
|
-
| "css";
|
25
|
-
|
26
|
-
export interface IConfigPath {
|
27
|
-
base: string;
|
28
|
-
}
|
29
|
-
|
30
|
-
type TAgent = "vscode" | "os";
|
31
|
-
|
32
|
-
export interface IEditor {
|
33
|
-
mode?: TMode;
|
34
|
-
version: string;
|
35
|
-
agent?: TAgent;
|
36
|
-
}
|
37
|
-
|
38
|
-
export interface TEntries {
|
39
|
-
python3?: string;
|
40
|
-
html?: string;
|
41
|
-
node?: string;
|
42
|
-
react?: string;
|
43
|
-
java?: string;
|
44
|
-
}
|
45
|
-
|
46
|
-
export interface IConfig {
|
47
|
-
os: string;
|
48
|
-
port?: string;
|
49
|
-
repository?: string;
|
50
|
-
description?: string;
|
51
|
-
slug?: string;
|
52
|
-
dirPath: string;
|
53
|
-
preview?: string; // Picture thumbnail
|
54
|
-
entries: TEntries;
|
55
|
-
grading: TGrading;
|
56
|
-
configPath: string;
|
57
|
-
translations: Array<string>;
|
58
|
-
outputPath?: string;
|
59
|
-
editor: IEditor;
|
60
|
-
language: string;
|
61
|
-
title: string;
|
62
|
-
duration: number;
|
63
|
-
difficulty?: string;
|
64
|
-
exercisesPath: string;
|
65
|
-
disableGrading: boolean; // TODO: Deprecate
|
66
|
-
actions: Array<string>; // TODO: Deprecate
|
67
|
-
autoPlay: boolean;
|
68
|
-
projectType?: string;
|
69
|
-
// TODO: nameExerciseValidation
|
70
|
-
contact?: string;
|
71
|
-
disabledActions?: Array<TConfigAction>;
|
72
|
-
compiler: TCompiler;
|
73
|
-
compilers: Array<TCompiler>;
|
74
|
-
publicPath: string;
|
75
|
-
publicUrl?: string;
|
76
|
-
bugsLink?: string;
|
77
|
-
videoSolutions?: boolean;
|
78
|
-
skills: Array<string>;
|
79
|
-
telemetry?: TTelemetryUrls;
|
80
|
-
runHook: (...agrs: Array<any>) => void;
|
81
|
-
testingFinishedCallback: (arg: any | undefined) => void;
|
82
|
-
}
|
83
|
-
|
84
|
-
export interface IConfigObj {
|
85
|
-
session?: number;
|
86
|
-
currentExercise?: any;
|
87
|
-
config?: IConfig;
|
88
|
-
exercises?: Array<IExercise>;
|
89
|
-
confPath?: IConfigPath;
|
90
|
-
address?: string; // Maybe
|
91
|
-
}
|
1
|
+
import { IExercise } from "./exercise-obj"
|
2
|
+
import { TTelemetryUrls } from "../managers/telemetry"
|
3
|
+
|
4
|
+
export type TGrading = "isolated" | "incremental" | "no-grading";
|
5
|
+
|
6
|
+
export type TMode = "preview" | "extension";
|
7
|
+
|
8
|
+
export type TConfigAction =
|
9
|
+
| "test"
|
10
|
+
| "build"
|
11
|
+
| "tutorial"
|
12
|
+
| "reset"
|
13
|
+
| "generate";
|
14
|
+
|
15
|
+
export type TConfigObjAttributes = "config" | "exercises" | "grading";
|
16
|
+
|
17
|
+
export type TCompiler =
|
18
|
+
| "webpack"
|
19
|
+
| "vanillajs"
|
20
|
+
| "react"
|
21
|
+
| "html"
|
22
|
+
| "node"
|
23
|
+
| "python"
|
24
|
+
| "css";
|
25
|
+
|
26
|
+
export interface IConfigPath {
|
27
|
+
base: string;
|
28
|
+
}
|
29
|
+
|
30
|
+
type TAgent = "vscode" | "os";
|
31
|
+
|
32
|
+
export interface IEditor {
|
33
|
+
mode?: TMode;
|
34
|
+
version: string;
|
35
|
+
agent?: TAgent;
|
36
|
+
}
|
37
|
+
|
38
|
+
export interface TEntries {
|
39
|
+
python3?: string;
|
40
|
+
html?: string;
|
41
|
+
node?: string;
|
42
|
+
react?: string;
|
43
|
+
java?: string;
|
44
|
+
}
|
45
|
+
|
46
|
+
export interface IConfig {
|
47
|
+
os: string;
|
48
|
+
port?: string;
|
49
|
+
repository?: string;
|
50
|
+
description?: string;
|
51
|
+
slug?: string;
|
52
|
+
dirPath: string;
|
53
|
+
preview?: string; // Picture thumbnail
|
54
|
+
entries: TEntries;
|
55
|
+
grading: TGrading;
|
56
|
+
configPath: string;
|
57
|
+
translations: Array<string>;
|
58
|
+
outputPath?: string;
|
59
|
+
editor: IEditor;
|
60
|
+
language: string;
|
61
|
+
title: string;
|
62
|
+
duration: number;
|
63
|
+
difficulty?: string;
|
64
|
+
exercisesPath: string;
|
65
|
+
disableGrading: boolean; // TODO: Deprecate
|
66
|
+
actions: Array<string>; // TODO: Deprecate
|
67
|
+
autoPlay: boolean;
|
68
|
+
projectType?: string;
|
69
|
+
// TODO: nameExerciseValidation
|
70
|
+
contact?: string;
|
71
|
+
disabledActions?: Array<TConfigAction>;
|
72
|
+
compiler: TCompiler;
|
73
|
+
compilers: Array<TCompiler>;
|
74
|
+
publicPath: string;
|
75
|
+
publicUrl?: string;
|
76
|
+
bugsLink?: string;
|
77
|
+
videoSolutions?: boolean;
|
78
|
+
skills: Array<string>;
|
79
|
+
telemetry?: TTelemetryUrls;
|
80
|
+
runHook: (...agrs: Array<any>) => void;
|
81
|
+
testingFinishedCallback: (arg: any | undefined) => void;
|
82
|
+
}
|
83
|
+
|
84
|
+
export interface IConfigObj {
|
85
|
+
session?: number;
|
86
|
+
currentExercise?: any;
|
87
|
+
config?: IConfig;
|
88
|
+
exercises?: Array<IExercise>;
|
89
|
+
confPath?: IConfigPath;
|
90
|
+
address?: string; // Maybe
|
91
|
+
}
|
package/src/models/socket.ts
CHANGED
@@ -1,59 +1,59 @@
|
|
1
|
-
import { IConfig } from "./config"
|
2
|
-
import { Server } from "socket.io"
|
3
|
-
import { DefaultEventsMap } from "socket.io/dist/typed-events"
|
4
|
-
import { TAction, ICallback } from "./action"
|
5
|
-
import { TStatus } from "./status"
|
6
|
-
|
7
|
-
export type TPossibleActions =
|
8
|
-
| "build"
|
9
|
-
| "test"
|
10
|
-
| "reset"
|
11
|
-
| "tutorial"
|
12
|
-
| "generate";
|
13
|
-
|
14
|
-
export interface ISocket {
|
15
|
-
socket: Server<
|
16
|
-
DefaultEventsMap,
|
17
|
-
DefaultEventsMap,
|
18
|
-
DefaultEventsMap,
|
19
|
-
any
|
20
|
-
> | null;
|
21
|
-
config: IConfig | null;
|
22
|
-
allowedActions: Array<TPossibleActions>;
|
23
|
-
actionCallBacks: { [key: string]: ICallback };
|
24
|
-
possibleActions: Array<TPossibleActions>;
|
25
|
-
isTestingEnvironment: boolean;
|
26
|
-
addAllowed: (actions: any) => void;
|
27
|
-
removeAllowed: (actions: any) => void;
|
28
|
-
start: (config: IConfig, server: any, isTestingEnvironment: boolean) => void;
|
29
|
-
on: (action: any, callBack: any) => void;
|
30
|
-
clean: (_: string, logs: Array<any>) => void;
|
31
|
-
complete: () => void;
|
32
|
-
ask: (questions: Array<string>) => void;
|
33
|
-
reload: (files: Array<string> | null, exercises: Array<string>) => void;
|
34
|
-
openWindow: (id: string) => void;
|
35
|
-
log: (
|
36
|
-
status: TStatus,
|
37
|
-
messages?: string | Array<string>,
|
38
|
-
report?: Array<string>,
|
39
|
-
data?: any
|
40
|
-
) => void;
|
41
|
-
emit: (
|
42
|
-
action: TAction,
|
43
|
-
status: TStatus | string,
|
44
|
-
logs: string | Array<string>,
|
45
|
-
inputs?: Array<string>,
|
46
|
-
report?: Array<string>,
|
47
|
-
data?: any
|
48
|
-
) => void;
|
49
|
-
ready: (message: string) => void;
|
50
|
-
error: (type: any, stdout: string) => void;
|
51
|
-
fatal: (msg: string) => void;
|
52
|
-
success: (type: any, stdout: string) => void;
|
53
|
-
onTestingFinished: (obj: any) => void;
|
54
|
-
}
|
55
|
-
|
56
|
-
export type TOpenWindowData = {
|
57
|
-
url: string;
|
58
|
-
exerciseSlug: string;
|
59
|
-
};
|
1
|
+
import { IConfig } from "./config"
|
2
|
+
import { Server } from "socket.io"
|
3
|
+
import { DefaultEventsMap } from "socket.io/dist/typed-events"
|
4
|
+
import { TAction, ICallback } from "./action"
|
5
|
+
import { TStatus } from "./status"
|
6
|
+
|
7
|
+
export type TPossibleActions =
|
8
|
+
| "build"
|
9
|
+
| "test"
|
10
|
+
| "reset"
|
11
|
+
| "tutorial"
|
12
|
+
| "generate";
|
13
|
+
|
14
|
+
export interface ISocket {
|
15
|
+
socket: Server<
|
16
|
+
DefaultEventsMap,
|
17
|
+
DefaultEventsMap,
|
18
|
+
DefaultEventsMap,
|
19
|
+
any
|
20
|
+
> | null;
|
21
|
+
config: IConfig | null;
|
22
|
+
allowedActions: Array<TPossibleActions>;
|
23
|
+
actionCallBacks: { [key: string]: ICallback };
|
24
|
+
possibleActions: Array<TPossibleActions>;
|
25
|
+
isTestingEnvironment: boolean;
|
26
|
+
addAllowed: (actions: any) => void;
|
27
|
+
removeAllowed: (actions: any) => void;
|
28
|
+
start: (config: IConfig, server: any, isTestingEnvironment: boolean) => void;
|
29
|
+
on: (action: any, callBack: any) => void;
|
30
|
+
clean: (_: string, logs: Array<any>) => void;
|
31
|
+
complete: () => void;
|
32
|
+
ask: (questions: Array<string>) => void;
|
33
|
+
reload: (files: Array<string> | null, exercises: Array<string>) => void;
|
34
|
+
openWindow: (id: string) => void;
|
35
|
+
log: (
|
36
|
+
status: TStatus,
|
37
|
+
messages?: string | Array<string>,
|
38
|
+
report?: Array<string>,
|
39
|
+
data?: any
|
40
|
+
) => void;
|
41
|
+
emit: (
|
42
|
+
action: TAction,
|
43
|
+
status: TStatus | string,
|
44
|
+
logs: string | Array<string>,
|
45
|
+
inputs?: Array<string>,
|
46
|
+
report?: Array<string>,
|
47
|
+
data?: any
|
48
|
+
) => void;
|
49
|
+
ready: (message: string) => void;
|
50
|
+
error: (type: any, stdout: string) => void;
|
51
|
+
fatal: (msg: string) => void;
|
52
|
+
success: (type: any, stdout: string) => void;
|
53
|
+
onTestingFinished: (obj: any) => void;
|
54
|
+
}
|
55
|
+
|
56
|
+
export type TOpenWindowData = {
|
57
|
+
url: string;
|
58
|
+
exerciseSlug: string;
|
59
|
+
};
|
@@ -1,42 +1,42 @@
|
|
1
|
-
import { IExercise } from "../models/exercise-obj"
|
2
|
-
export const checkNotInstalledPlugins = (
|
3
|
-
exercises: IExercise[],
|
4
|
-
installedPlugins: string[]
|
5
|
-
) => {
|
6
|
-
const usefulExtensions = new Set(["py", "js", "jsx", "html"])
|
7
|
-
const foundExtensions: string[] = []
|
8
|
-
|
9
|
-
for (const e of exercises) {
|
10
|
-
for (const f of e.files) {
|
11
|
-
const ext = f.name.split(".").pop()
|
12
|
-
if (ext && usefulExtensions.has(ext) && !foundExtensions.includes(ext)) {
|
13
|
-
foundExtensions.push(ext)
|
14
|
-
}
|
15
|
-
}
|
16
|
-
}
|
17
|
-
|
18
|
-
const neededPlugins: string[] = []
|
19
|
-
if (foundExtensions.length > 0) {
|
20
|
-
if (foundExtensions.includes("html") && foundExtensions.includes("js")) {
|
21
|
-
neededPlugins.push("@learnpack/dom")
|
22
|
-
}
|
23
|
-
|
24
|
-
if (foundExtensions.includes("html") && !foundExtensions.includes("js")) {
|
25
|
-
neededPlugins.push("@learnpack/html")
|
26
|
-
}
|
27
|
-
|
28
|
-
if (foundExtensions.includes("jsx")) {
|
29
|
-
neededPlugins.push("@learnpack/react")
|
30
|
-
}
|
31
|
-
|
32
|
-
if (foundExtensions.includes("py")) {
|
33
|
-
neededPlugins.push("@learnpack/python")
|
34
|
-
}
|
35
|
-
|
36
|
-
if (foundExtensions.includes("js")
|
37
|
-
neededPlugins.push("@learnpack/node")
|
38
|
-
}
|
39
|
-
}
|
40
|
-
|
41
|
-
return neededPlugins.filter(item => !installedPlugins.includes(item))
|
42
|
-
}
|
1
|
+
import { IExercise } from "../models/exercise-obj"
|
2
|
+
export const checkNotInstalledPlugins = (
|
3
|
+
exercises: IExercise[],
|
4
|
+
installedPlugins: string[]
|
5
|
+
) => {
|
6
|
+
const usefulExtensions = new Set(["py", "js", "jsx", "html"])
|
7
|
+
const foundExtensions: string[] = []
|
8
|
+
|
9
|
+
for (const e of exercises) {
|
10
|
+
for (const f of e.files) {
|
11
|
+
const ext = f.name.split(".").pop()
|
12
|
+
if (ext && usefulExtensions.has(ext) && !foundExtensions.includes(ext)) {
|
13
|
+
foundExtensions.push(ext)
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
17
|
+
|
18
|
+
const neededPlugins: string[] = []
|
19
|
+
if (foundExtensions.length > 0) {
|
20
|
+
if (foundExtensions.includes("html") && foundExtensions.includes("js")) {
|
21
|
+
neededPlugins.push("@learnpack/dom")
|
22
|
+
}
|
23
|
+
|
24
|
+
if (foundExtensions.includes("html") && !foundExtensions.includes("js")) {
|
25
|
+
neededPlugins.push("@learnpack/html")
|
26
|
+
}
|
27
|
+
|
28
|
+
if (foundExtensions.includes("jsx")) {
|
29
|
+
neededPlugins.push("@learnpack/react")
|
30
|
+
}
|
31
|
+
|
32
|
+
if (foundExtensions.includes("py")) {
|
33
|
+
neededPlugins.push("@learnpack/python")
|
34
|
+
}
|
35
|
+
|
36
|
+
if (foundExtensions.includes("js")) {
|
37
|
+
neededPlugins.push("@learnpack/node")
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
return neededPlugins.filter(item => !installedPlugins.includes(item))
|
42
|
+
}
|