@learnpack/learnpack 2.1.52 → 2.1.54
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 +10 -10
- package/lib/commands/start.js +22 -0
- package/lib/managers/socket.js +7 -0
- package/lib/managers/telemetry.d.ts +1 -1
- package/lib/managers/telemetry.js +10 -2
- package/lib/models/action.d.ts +1 -1
- package/lib/models/socket.d.ts +1 -0
- package/lib/utils/checkNotInstalled.js +1 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/start.ts +355 -320
- package/src/managers/socket.ts +9 -0
- package/src/managers/telemetry.ts +353 -346
- package/src/models/action.ts +11 -10
- package/src/models/socket.ts +60 -59
- package/src/models/status.ts +16 -16
- package/src/utils/checkNotInstalled.ts +3 -4
package/src/models/action.ts
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
export type TAction =
|
2
|
-
| "test"
|
3
|
-
| "log"
|
4
|
-
| "reload"
|
5
|
-
| "ready"
|
6
|
-
| "clean"
|
7
|
-
| "ask"
|
8
|
-
| "file_change"
|
9
|
-
|
10
|
-
|
1
|
+
export type TAction =
|
2
|
+
| "test"
|
3
|
+
| "log"
|
4
|
+
| "reload"
|
5
|
+
| "ready"
|
6
|
+
| "clean"
|
7
|
+
| "ask"
|
8
|
+
| "file_change"
|
9
|
+
| "dialog";
|
10
|
+
|
11
|
+
export type ICallback = (...agrs: any[]) => any;
|
package/src/models/socket.ts
CHANGED
@@ -1,59 +1,60 @@
|
|
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
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
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
|
+
dialog: (message: string) => void;
|
53
|
+
success: (type: any, stdout: string) => void;
|
54
|
+
onTestingFinished: (obj: any) => void;
|
55
|
+
}
|
56
|
+
|
57
|
+
export type TOpenWindowData = {
|
58
|
+
url: string;
|
59
|
+
exerciseSlug: string;
|
60
|
+
};
|
package/src/models/status.ts
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
export type TStatus =
|
2
|
-
| "ready"
|
3
|
-
| "internal-error"
|
4
|
-
| "compiler-success"
|
5
|
-
| "testing-success"
|
6
|
-
| "compiling"
|
7
|
-
| "testing"
|
8
|
-
| "start_exercise"
|
9
|
-
| "initializing"
|
10
|
-
| "configuration_loaded"
|
11
|
-
| "connection_ended"
|
12
|
-
| "reset_exercise"
|
13
|
-
| "open_files"
|
14
|
-
| "open_window"
|
15
|
-
| "instructions_closed"
|
16
|
-
| "completed";
|
1
|
+
export type TStatus =
|
2
|
+
| "ready"
|
3
|
+
| "internal-error"
|
4
|
+
| "compiler-success"
|
5
|
+
| "testing-success"
|
6
|
+
| "compiling"
|
7
|
+
| "testing"
|
8
|
+
| "start_exercise"
|
9
|
+
| "initializing"
|
10
|
+
| "configuration_loaded"
|
11
|
+
| "connection_ended"
|
12
|
+
| "reset_exercise"
|
13
|
+
| "open_files"
|
14
|
+
| "open_window"
|
15
|
+
| "instructions_closed"
|
16
|
+
| "completed";
|
@@ -1,11 +1,11 @@
|
|
1
1
|
import { IExercise } from "../models/exercise-obj"
|
2
2
|
import { promisify } from "util"
|
3
3
|
import { exec as execCallback } from "child_process"
|
4
|
+
|
4
5
|
const exec = promisify(execCallback)
|
5
6
|
|
6
7
|
import { cli } from "cli-ux"
|
7
8
|
import Console from "./console"
|
8
|
-
import { TGrading } from "../models/config"
|
9
9
|
|
10
10
|
type TNeededPlugins = {
|
11
11
|
needed: string[];
|
@@ -191,9 +191,7 @@ export const checkNotInstalledDependencies = async (
|
|
191
191
|
}
|
192
192
|
|
193
193
|
if (jestNeeded) {
|
194
|
-
const { stdout, stderr } = await exec(
|
195
|
-
"npm ls jest jest-environment-jsdom -g"
|
196
|
-
)
|
194
|
+
const { stdout, stderr } = await exec("npm ls -g")
|
197
195
|
if (stderr) {
|
198
196
|
Console.error(`Error executing ${npmLsCommand}. Use debug for more info`)
|
199
197
|
Console.debug(stderr)
|
@@ -207,6 +205,7 @@ return true
|
|
207
205
|
const confirmInstall = await cli.confirm(
|
208
206
|
"Do you want to install the needed dependencies? (y/n)"
|
209
207
|
)
|
208
|
+
|
210
209
|
if (!confirmInstall) {
|
211
210
|
Console.error(
|
212
211
|
`The exercises can't be tested without the following dependencies: ${jsPluginsDependencies.join(
|