@learnpack/learnpack 4.0.9 → 4.0.12
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +25 -10
- package/lib/commands/audit.d.ts +6 -6
- package/lib/commands/audit.js +327 -327
- package/lib/commands/build.d.ts +11 -0
- package/lib/commands/build.js +160 -0
- package/lib/commands/clean.d.ts +8 -8
- package/lib/commands/clean.js +22 -22
- package/lib/commands/download.d.ts +13 -13
- package/lib/commands/download.js +52 -52
- package/lib/commands/init.d.ts +9 -9
- package/lib/commands/init.js +127 -127
- package/lib/commands/login.d.ts +14 -14
- package/lib/commands/login.js +34 -34
- package/lib/commands/logout.d.ts +14 -14
- package/lib/commands/logout.js +34 -34
- package/lib/commands/publish.d.ts +14 -14
- package/lib/commands/publish.js +79 -79
- package/lib/commands/start.d.ts +7 -7
- package/lib/commands/start.js +252 -250
- package/lib/commands/test.d.ts +6 -6
- package/lib/commands/test.js +62 -62
- package/lib/index.d.ts +1 -1
- package/lib/index.js +4 -4
- package/lib/managers/config/allowed_files.d.ts +5 -5
- package/lib/managers/config/allowed_files.js +30 -30
- package/lib/managers/config/defaults.d.ts +47 -48
- package/lib/managers/config/defaults.js +51 -51
- package/lib/managers/config/exercise.d.ts +36 -36
- package/lib/managers/config/exercise.js +243 -236
- package/lib/managers/config/index.d.ts +3 -3
- package/lib/managers/config/index.js +464 -459
- package/lib/managers/file.d.ts +14 -14
- package/lib/managers/file.js +190 -184
- package/lib/managers/gitpod.d.ts +3 -3
- package/lib/managers/gitpod.js +67 -67
- package/lib/managers/server/index.d.ts +5 -6
- package/lib/managers/server/index.js +58 -58
- package/lib/managers/server/routes.d.ts +4 -4
- package/lib/managers/server/routes.js +228 -220
- package/lib/managers/session.d.ts +3 -3
- package/lib/managers/session.js +125 -125
- package/lib/managers/socket.d.ts +3 -3
- package/lib/managers/socket.js +188 -186
- package/lib/managers/telemetry.d.ts +74 -74
- package/lib/managers/telemetry.js +215 -214
- package/lib/managers/test.js +84 -84
- package/lib/models/action.d.ts +2 -2
- package/lib/models/action.js +2 -2
- package/lib/models/audit.d.ts +15 -15
- package/lib/models/audit.js +2 -2
- package/lib/models/config-manager.d.ts +21 -21
- package/lib/models/config-manager.js +2 -2
- package/lib/models/config.d.ts +86 -86
- package/lib/models/config.js +2 -2
- package/lib/models/counter.d.ts +11 -11
- package/lib/models/counter.js +2 -2
- package/lib/models/errors.d.ts +15 -15
- package/lib/models/errors.js +2 -2
- package/lib/models/exercise-obj.d.ts +29 -30
- package/lib/models/exercise-obj.js +2 -2
- package/lib/models/file.d.ts +5 -5
- package/lib/models/file.js +2 -2
- package/lib/models/findings.d.ts +17 -17
- package/lib/models/findings.js +2 -2
- package/lib/models/flags.d.ts +10 -10
- package/lib/models/flags.js +2 -2
- package/lib/models/front-matter.d.ts +11 -11
- package/lib/models/front-matter.js +2 -2
- package/lib/models/gitpod-data.d.ts +16 -16
- package/lib/models/gitpod-data.js +2 -2
- package/lib/models/language.d.ts +4 -4
- package/lib/models/language.js +2 -2
- package/lib/models/package.d.ts +7 -7
- package/lib/models/package.js +2 -2
- package/lib/models/plugin-config.d.ts +16 -16
- package/lib/models/plugin-config.js +2 -2
- package/lib/models/session.d.ts +31 -31
- package/lib/models/session.js +2 -2
- package/lib/models/socket.d.ts +37 -37
- package/lib/models/socket.js +2 -2
- package/lib/models/status.d.ts +1 -1
- package/lib/models/status.js +2 -2
- package/lib/models/success-types.d.ts +1 -1
- package/lib/models/success-types.js +2 -2
- package/lib/plugin/command/compile.d.ts +6 -6
- package/lib/plugin/command/compile.js +18 -18
- package/lib/plugin/command/test.d.ts +6 -6
- package/lib/plugin/command/test.js +25 -25
- package/lib/plugin/index.d.ts +27 -27
- package/lib/plugin/index.js +7 -7
- package/lib/plugin/plugin.d.ts +8 -8
- package/lib/plugin/plugin.js +68 -68
- package/lib/plugin/utils.d.ts +16 -16
- package/lib/plugin/utils.js +58 -58
- package/lib/ui/download.d.ts +5 -5
- package/lib/ui/download.js +62 -61
- package/lib/utils/BaseCommand.d.ts +8 -8
- package/lib/utils/BaseCommand.js +41 -41
- package/lib/utils/SessionCommand.d.ts +10 -10
- package/lib/utils/SessionCommand.js +43 -43
- package/lib/utils/api.d.ts +14 -14
- package/lib/utils/api.js +255 -255
- package/lib/utils/audit.d.ts +16 -16
- package/lib/utils/audit.js +303 -303
- package/lib/utils/checkNotInstalled.d.ts +8 -8
- package/lib/utils/checkNotInstalled.js +185 -181
- package/lib/utils/console.d.ts +12 -12
- package/lib/utils/console.js +19 -19
- package/lib/utils/errors.d.ts +17 -17
- package/lib/utils/errors.js +107 -100
- package/lib/utils/exercisesQueue.d.ts +9 -9
- package/lib/utils/exercisesQueue.js +38 -38
- package/lib/utils/fileQueue.d.ts +43 -43
- package/lib/utils/fileQueue.js +169 -169
- package/lib/utils/misc.d.ts +1 -1
- package/lib/utils/misc.js +24 -23
- package/lib/utils/osOperations.d.ts +5 -5
- package/lib/utils/osOperations.js +72 -72
- package/lib/utils/validators.d.ts +5 -5
- package/lib/utils/validators.js +16 -17
- package/lib/utils/watcher.d.ts +2 -2
- package/lib/utils/watcher.js +25 -25
- package/oclif.manifest.json +1 -1
- package/package.json +6 -4
- package/src/commands/build.ts +181 -0
- package/src/managers/config/index.ts +5 -0
- package/src/managers/server/routes.ts +11 -1
- package/src/managers/session.ts +1 -1
package/lib/managers/file.d.ts
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
export declare const decompress: (sourcePath: string, destinationPath: string) => Promise<unknown>;
|
2
|
-
export declare const downloadEditor: (version: string | undefined, destination: string) => Promise<unknown>;
|
3
|
-
export declare const download: (url: string, dest: string) => Promise<unknown>;
|
4
|
-
export declare const clone: (repository?: string, folder?: string) => Promise<unknown>;
|
5
|
-
export declare const rmSync: (path: string) => void;
|
6
|
-
export declare const checkIfDirectoryExists: (path: string) => boolean;
|
7
|
-
declare const _default: {
|
8
|
-
download: (url: string, dest: string) => Promise<unknown>;
|
9
|
-
decompress: (sourcePath: string, destinationPath: string) => Promise<unknown>;
|
10
|
-
downloadEditor: (version: string | undefined, destination: string) => Promise<unknown>;
|
11
|
-
clone: (repository?: string, folder?: string) => Promise<unknown>;
|
12
|
-
rmSync: (path: string) => void;
|
13
|
-
};
|
14
|
-
export default _default;
|
1
|
+
export declare const decompress: (sourcePath: string, destinationPath: string) => Promise<unknown>;
|
2
|
+
export declare const downloadEditor: (version: string | undefined, destination: string) => Promise<unknown>;
|
3
|
+
export declare const download: (url: string, dest: string) => Promise<unknown>;
|
4
|
+
export declare const clone: (repository?: string, folder?: string) => Promise<unknown>;
|
5
|
+
export declare const rmSync: (path: string) => void;
|
6
|
+
export declare const checkIfDirectoryExists: (path: string) => boolean;
|
7
|
+
declare const _default: {
|
8
|
+
download: (url: string, dest: string) => Promise<unknown>;
|
9
|
+
decompress: (sourcePath: string, destinationPath: string) => Promise<unknown>;
|
10
|
+
downloadEditor: (version: string | undefined, destination: string) => Promise<unknown>;
|
11
|
+
clone: (repository?: string, folder?: string) => Promise<unknown>;
|
12
|
+
rmSync: (path: string) => void;
|
13
|
+
};
|
14
|
+
export default _default;
|
package/lib/managers/file.js
CHANGED
@@ -1,184 +1,190 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.checkIfDirectoryExists = exports.rmSync = exports.clone = exports.download = exports.downloadEditor = exports.decompress = void 0;
|
4
|
-
const fs = require("fs");
|
5
|
-
const p = require("path");
|
6
|
-
const shell = require("shelljs");
|
7
|
-
const cli_ux_1 = require("cli-ux");
|
8
|
-
const targz = require("targz");
|
9
|
-
const console_1 = require("../utils/console");
|
10
|
-
const https = require("https");
|
11
|
-
const errors_1 = require("../utils/errors");
|
12
|
-
// eslint-disable-next-line
|
13
|
-
const fetch = require("node-fetch");
|
14
|
-
|
15
|
-
console_1.default.debug("Decompressing " + sourcePath);
|
16
|
-
targz.decompress({
|
17
|
-
src: sourcePath,
|
18
|
-
dest: destinationPath,
|
19
|
-
}, function (err) {
|
20
|
-
if (err) {
|
21
|
-
console_1.default.error("Error when trying to decompress");
|
22
|
-
reject(err);
|
23
|
-
}
|
24
|
-
else {
|
25
|
-
console_1.default.info("Decompression finished successfully");
|
26
|
-
resolve(/* */ "");
|
27
|
-
}
|
28
|
-
});
|
29
|
-
});
|
30
|
-
exports.
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
const
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
const
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
version
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
.
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
version
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
.replace("
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
};
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
}
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
}
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
//
|
171
|
-
|
172
|
-
}
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
}
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.checkIfDirectoryExists = exports.rmSync = exports.clone = exports.download = exports.downloadEditor = exports.decompress = void 0;
|
4
|
+
const fs = require("fs");
|
5
|
+
const p = require("path");
|
6
|
+
const shell = require("shelljs");
|
7
|
+
const cli_ux_1 = require("cli-ux");
|
8
|
+
const targz = require("targz");
|
9
|
+
const console_1 = require("../utils/console");
|
10
|
+
const https = require("https");
|
11
|
+
const errors_1 = require("../utils/errors");
|
12
|
+
// eslint-disable-next-line
|
13
|
+
const fetch = require("node-fetch");
|
14
|
+
const decompress = (sourcePath, destinationPath) => new Promise((resolve, reject) => {
|
15
|
+
console_1.default.debug("Decompressing " + sourcePath);
|
16
|
+
targz.decompress({
|
17
|
+
src: sourcePath,
|
18
|
+
dest: destinationPath,
|
19
|
+
}, function (err) {
|
20
|
+
if (err) {
|
21
|
+
console_1.default.error("Error when trying to decompress");
|
22
|
+
reject(err);
|
23
|
+
}
|
24
|
+
else {
|
25
|
+
console_1.default.info("Decompression finished successfully");
|
26
|
+
resolve(/* */ "");
|
27
|
+
}
|
28
|
+
});
|
29
|
+
});
|
30
|
+
exports.decompress = decompress;
|
31
|
+
const downloadEditor = async (version, destination) => {
|
32
|
+
console_1.default.info("Downloading the LearnPack coding UI, this may take a minute...");
|
33
|
+
if (!version) {
|
34
|
+
const res = await fetch("https://raw.githubusercontent.com/learnpack/ide/master/package.json");
|
35
|
+
const json = await res.json();
|
36
|
+
version = json.version || "4.0.0";
|
37
|
+
if (!version)
|
38
|
+
throw (0, errors_1.InternalError)(`Coding Editor version was not found on learnpack repository, check the config.editor.version property on learn.json`);
|
39
|
+
}
|
40
|
+
const [major, minor] = version.split(".");
|
41
|
+
const versionPrefix = `${major}.${minor}`;
|
42
|
+
let tags;
|
43
|
+
try {
|
44
|
+
const tagsRes = await fetch("https://raw.githubusercontent.com/learnpack/ide/master/versions.json");
|
45
|
+
tags = await tagsRes.json();
|
46
|
+
if (!Array.isArray(tags)) {
|
47
|
+
throw new TypeError(`Invalid versions.json format`);
|
48
|
+
}
|
49
|
+
}
|
50
|
+
catch (error) {
|
51
|
+
console_1.default.debug("Error reading versions.json, defaulting to version 4.0.2", error);
|
52
|
+
version = "4.0.2";
|
53
|
+
tags = [`learnpack-${version}.tar.gz`];
|
54
|
+
}
|
55
|
+
let matchingTags;
|
56
|
+
try {
|
57
|
+
if (tags.length === 0 || !tags)
|
58
|
+
throw (0, errors_1.InternalError)(`No found tags in versions.json ${tags}`);
|
59
|
+
matchingTags = tags
|
60
|
+
.filter(tag => tag.includes(versionPrefix))
|
61
|
+
.sort((a, b) => b.localeCompare(a, undefined, { numeric: true }));
|
62
|
+
if (matchingTags.length === 0)
|
63
|
+
throw (0, errors_1.InternalError)(`No matching version found for prefix ${versionPrefix} in the versions.json`);
|
64
|
+
}
|
65
|
+
catch (error) {
|
66
|
+
console_1.default.debug("Error processing tags, defaulting to version 4.0.2", error);
|
67
|
+
version = "4.0.2";
|
68
|
+
matchingTags = [`learnpack-${version}.tar.gz`];
|
69
|
+
}
|
70
|
+
const latestVersion = matchingTags[0]
|
71
|
+
.replace("learnpack-", "")
|
72
|
+
.replace(".tar.gz", "");
|
73
|
+
const versionNumber = parseInt(latestVersion.split(".")[0]);
|
74
|
+
let url = `https://github.com/learnpack/coding-ide/blob/${latestVersion}/dist`;
|
75
|
+
if (versionNumber > 2)
|
76
|
+
url = `https://github.com/learnpack/ide/blob/master/bin/learnpack-${latestVersion}.tar.gz`;
|
77
|
+
const resp2 = await fetch(url, { method: "HEAD" });
|
78
|
+
if (!resp2.ok)
|
79
|
+
throw (0, errors_1.InternalError)(`Coding Editor ${latestVersion} was not found on learnpack repository, check the config.editor.version property on learn.json`);
|
80
|
+
url += versionNumber > 2 ? `?raw=true` : `/app.tar.gz?raw=true`;
|
81
|
+
return (0, exports.download)(url, destination);
|
82
|
+
};
|
83
|
+
exports.downloadEditor = downloadEditor;
|
84
|
+
const download = (url, dest) => {
|
85
|
+
console_1.default.debug("Downloading " + url);
|
86
|
+
return new Promise((resolve, reject) => {
|
87
|
+
const request = https.get(url, response => {
|
88
|
+
if (response.statusCode === 200) {
|
89
|
+
const file = fs.createWriteStream(dest, { flags: "wx" });
|
90
|
+
file.on("finish", () => {
|
91
|
+
resolve(true);
|
92
|
+
});
|
93
|
+
file.on("error", err => {
|
94
|
+
file.close();
|
95
|
+
if (err.code === "EEXIST") {
|
96
|
+
console_1.default.debug("File already exists");
|
97
|
+
resolve("File already exists");
|
98
|
+
}
|
99
|
+
else {
|
100
|
+
console_1.default.debug("Error ", err.message);
|
101
|
+
fs.unlink(dest, () => reject(err.message)); // Delete temp file
|
102
|
+
}
|
103
|
+
});
|
104
|
+
response.pipe(file);
|
105
|
+
}
|
106
|
+
else if (response.statusCode === 302 || response.statusCode === 301) {
|
107
|
+
// Console.debug("Servers redirected to "+response.headers.location)
|
108
|
+
// Recursively follow redirects, only a 200 will resolve.
|
109
|
+
if (response.headers.location) {
|
110
|
+
(0, exports.download)(response.headers.location, dest)
|
111
|
+
.then(() => resolve(/* */ ""))
|
112
|
+
.catch(error => {
|
113
|
+
console_1.default.error(error);
|
114
|
+
reject(error);
|
115
|
+
});
|
116
|
+
}
|
117
|
+
}
|
118
|
+
else {
|
119
|
+
console_1.default.debug(`Server responded with ${response.statusCode}: ${response.statusMessage}`);
|
120
|
+
reject(`Server responded with ${response.statusCode}: ${response.statusMessage}`);
|
121
|
+
}
|
122
|
+
});
|
123
|
+
request.on("error", err => {
|
124
|
+
reject(err.message);
|
125
|
+
});
|
126
|
+
});
|
127
|
+
};
|
128
|
+
exports.download = download;
|
129
|
+
const clone = (repository = "", folder = "./") => new Promise((resolve, reject) => {
|
130
|
+
if (!repository) {
|
131
|
+
reject("Missing repository url for this package");
|
132
|
+
// return false
|
133
|
+
}
|
134
|
+
cli_ux_1.cli.action.start("Verifying GIT...");
|
135
|
+
if (!shell.which("git")) {
|
136
|
+
reject("Sorry, this script requires git");
|
137
|
+
// return false
|
138
|
+
}
|
139
|
+
cli_ux_1.cli.action.stop();
|
140
|
+
let fileName = p.basename(repository);
|
141
|
+
if (!fileName) {
|
142
|
+
reject("Invalid repository information on package: " + repository);
|
143
|
+
// return false
|
144
|
+
}
|
145
|
+
fileName = fileName.split(".")[0];
|
146
|
+
if (fs.existsSync("./" + fileName)) {
|
147
|
+
reject(`Directory ${fileName} already exists; Did you download this package already?`);
|
148
|
+
// return false
|
149
|
+
}
|
150
|
+
cli_ux_1.cli.action.start(`Cloning repository ${repository}...`);
|
151
|
+
if (shell.exec(`git clone ${repository}`).code !== 0) {
|
152
|
+
reject("Error: Installation failed");
|
153
|
+
}
|
154
|
+
cli_ux_1.cli.action.stop();
|
155
|
+
cli_ux_1.cli.action.start("Cleaning installation...");
|
156
|
+
if (shell.exec(`rm -R -f ${folder}${fileName}/.git`).code !== 0) {
|
157
|
+
reject("Error: removing .git directory");
|
158
|
+
}
|
159
|
+
cli_ux_1.cli.action.stop();
|
160
|
+
resolve("Done");
|
161
|
+
});
|
162
|
+
exports.clone = clone;
|
163
|
+
const rmSync = function (path) {
|
164
|
+
let files = [];
|
165
|
+
if (fs.existsSync(path)) {
|
166
|
+
files = fs.readdirSync(path);
|
167
|
+
for (const [, file] of files.entries()) {
|
168
|
+
const curPath = path + "/" + file;
|
169
|
+
if (fs.lstatSync(curPath).isDirectory()) {
|
170
|
+
// recurse
|
171
|
+
(0, exports.rmSync)(curPath);
|
172
|
+
}
|
173
|
+
else {
|
174
|
+
// delete file
|
175
|
+
fs.unlinkSync(curPath);
|
176
|
+
}
|
177
|
+
}
|
178
|
+
fs.rmdirSync(path);
|
179
|
+
}
|
180
|
+
};
|
181
|
+
exports.rmSync = rmSync;
|
182
|
+
const checkIfDirectoryExists = (path) => {
|
183
|
+
const fs = require("fs");
|
184
|
+
if (fs.existsSync(path)) {
|
185
|
+
return true;
|
186
|
+
}
|
187
|
+
return false;
|
188
|
+
};
|
189
|
+
exports.checkIfDirectoryExists = checkIfDirectoryExists;
|
190
|
+
exports.default = { download: exports.download, decompress: exports.decompress, downloadEditor: exports.downloadEditor, clone: exports.clone, rmSync: exports.rmSync };
|
package/lib/managers/gitpod.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
import { IGitpod } from '../models/gitpod-data';
|
2
|
-
declare const Gitpod: IGitpod;
|
3
|
-
export default Gitpod;
|
1
|
+
import { IGitpod } from '../models/gitpod-data';
|
2
|
+
declare const Gitpod: IGitpod;
|
3
|
+
export default Gitpod;
|
package/lib/managers/gitpod.js
CHANGED
@@ -1,67 +1,67 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
const console_1 = require("../utils/console");
|
4
|
-
const shell = require("shelljs");
|
5
|
-
const socket_1 = require("./socket");
|
6
|
-
const fs = require("fs");
|
7
|
-
const Gitpod = {
|
8
|
-
socket: null,
|
9
|
-
config: null,
|
10
|
-
initialized: false,
|
11
|
-
hasGPCommand: false,
|
12
|
-
init: function (config) {
|
13
|
-
if (this.initialized) {
|
14
|
-
return;
|
15
|
-
}
|
16
|
-
this.initialized = true;
|
17
|
-
if (config) {
|
18
|
-
this.config = config;
|
19
|
-
}
|
20
|
-
if (shell.exec('gp -h', { silent: true }).code === 0) {
|
21
|
-
this.hasGPCommand = true;
|
22
|
-
if (config) {
|
23
|
-
config.address = shell
|
24
|
-
.exec('gp url', { silent: true })
|
25
|
-
.stdout.replace(/(\r\n|\n|\r)/gm, '');
|
26
|
-
}
|
27
|
-
}
|
28
|
-
else {
|
29
|
-
console_1.default.debug('Gitpod command line tool not found');
|
30
|
-
}
|
31
|
-
},
|
32
|
-
openFiles: async function (files) {
|
33
|
-
var _a;
|
34
|
-
console_1.default.debug('Attempting to open files in gitpod mode', files);
|
35
|
-
this.init(); // initilize gitpod config
|
36
|
-
// gitpod will open files only on isolated mode
|
37
|
-
if (!this.config || ((_a = this.config.config) === null || _a === void 0 ? void 0 : _a.grading) !== 'isolated') {
|
38
|
-
console_1.default.debug('Files cannot be automatically opened because we are not on isolated grading (only for isolated)');
|
39
|
-
socket_1.default.log('ready', ['Ready to compile or test...']);
|
40
|
-
return true;
|
41
|
-
}
|
42
|
-
if (this.hasGPCommand)
|
43
|
-
for (const f of files.reverse()) {
|
44
|
-
if (shell.exec(`gp open ${f}`).code > 0) {
|
45
|
-
console_1.default.debug(`Error opening file ${f} on gitpod`);
|
46
|
-
}
|
47
|
-
}
|
48
|
-
socket_1.default.log('ready', ['Ready to compile or test...']);
|
49
|
-
},
|
50
|
-
setup(config) {
|
51
|
-
this.init(config); // initilize gitpod config
|
52
|
-
this.autosave('on');
|
53
|
-
},
|
54
|
-
autosave: async function (value = 'on') {
|
55
|
-
this.init(); // initilize gitpod config
|
56
|
-
if (this.hasGPCommand) {
|
57
|
-
if (!fs.existsSync('./.theia'))
|
58
|
-
fs.mkdirSync('./.theia');
|
59
|
-
if (!fs.existsSync('./.theia/settings.json')) {
|
60
|
-
fs.writeFileSync('./.theia/settings.json', JSON.stringify({
|
61
|
-
'editor.autoSave': value,
|
62
|
-
}, null, 4));
|
63
|
-
}
|
64
|
-
}
|
65
|
-
},
|
66
|
-
};
|
67
|
-
exports.default = Gitpod;
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
const console_1 = require("../utils/console");
|
4
|
+
const shell = require("shelljs");
|
5
|
+
const socket_1 = require("./socket");
|
6
|
+
const fs = require("fs");
|
7
|
+
const Gitpod = {
|
8
|
+
socket: null,
|
9
|
+
config: null,
|
10
|
+
initialized: false,
|
11
|
+
hasGPCommand: false,
|
12
|
+
init: function (config) {
|
13
|
+
if (this.initialized) {
|
14
|
+
return;
|
15
|
+
}
|
16
|
+
this.initialized = true;
|
17
|
+
if (config) {
|
18
|
+
this.config = config;
|
19
|
+
}
|
20
|
+
if (shell.exec('gp -h', { silent: true }).code === 0) {
|
21
|
+
this.hasGPCommand = true;
|
22
|
+
if (config) {
|
23
|
+
config.address = shell
|
24
|
+
.exec('gp url', { silent: true })
|
25
|
+
.stdout.replace(/(\r\n|\n|\r)/gm, '');
|
26
|
+
}
|
27
|
+
}
|
28
|
+
else {
|
29
|
+
console_1.default.debug('Gitpod command line tool not found');
|
30
|
+
}
|
31
|
+
},
|
32
|
+
openFiles: async function (files) {
|
33
|
+
var _a;
|
34
|
+
console_1.default.debug('Attempting to open files in gitpod mode', files);
|
35
|
+
this.init(); // initilize gitpod config
|
36
|
+
// gitpod will open files only on isolated mode
|
37
|
+
if (!this.config || ((_a = this.config.config) === null || _a === void 0 ? void 0 : _a.grading) !== 'isolated') {
|
38
|
+
console_1.default.debug('Files cannot be automatically opened because we are not on isolated grading (only for isolated)');
|
39
|
+
socket_1.default.log('ready', ['Ready to compile or test...']);
|
40
|
+
return true;
|
41
|
+
}
|
42
|
+
if (this.hasGPCommand)
|
43
|
+
for (const f of files.reverse()) {
|
44
|
+
if (shell.exec(`gp open ${f}`).code > 0) {
|
45
|
+
console_1.default.debug(`Error opening file ${f} on gitpod`);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
socket_1.default.log('ready', ['Ready to compile or test...']);
|
49
|
+
},
|
50
|
+
setup(config) {
|
51
|
+
this.init(config); // initilize gitpod config
|
52
|
+
this.autosave('on');
|
53
|
+
},
|
54
|
+
autosave: async function (value = 'on') {
|
55
|
+
this.init(); // initilize gitpod config
|
56
|
+
if (this.hasGPCommand) {
|
57
|
+
if (!fs.existsSync('./.theia'))
|
58
|
+
fs.mkdirSync('./.theia');
|
59
|
+
if (!fs.existsSync('./.theia/settings.json')) {
|
60
|
+
fs.writeFileSync('./.theia/settings.json', JSON.stringify({
|
61
|
+
'editor.autoSave': value,
|
62
|
+
}, null, 4));
|
63
|
+
}
|
64
|
+
}
|
65
|
+
},
|
66
|
+
};
|
67
|
+
exports.default = Gitpod;
|
@@ -1,6 +1,5 @@
|
|
1
|
-
|
2
|
-
import
|
3
|
-
import {
|
4
|
-
|
5
|
-
export
|
6
|
-
export default function (configObj: IConfigObj, configManager: IConfigManager, isTestingEnvironment?: boolean): Promise<any>;
|
1
|
+
import * as http from "http";
|
2
|
+
import { IConfigObj } from "../../models/config";
|
3
|
+
import { IConfigManager } from "../../models/config-manager";
|
4
|
+
export declare let TEST_SERVER: http.Server;
|
5
|
+
export default function (configObj: IConfigObj, configManager: IConfigManager, isTestingEnvironment?: boolean): Promise<any>;
|