@learnpack/learnpack 5.0.310 → 5.0.312
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/lib/commands/publish.js +16 -6
- package/lib/utils/errors.d.ts +1 -1
- package/lib/utils/errors.js +23 -28
- package/package.json +1 -1
- package/src/commands/publish.ts +533 -517
- package/src/utils/errors.ts +108 -117
package/lib/commands/publish.js
CHANGED
|
@@ -44,9 +44,14 @@ const handleAssetCreation = async (sessionPayload, learnJson, selectedLang, lear
|
|
|
44
44
|
readme_raw: b64IndexReadme,
|
|
45
45
|
all_translations,
|
|
46
46
|
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
try {
|
|
48
|
+
await api_1.default.updateRigoPackage(sessionPayload.rigobotToken.trim(), learnJson.slug, {
|
|
49
|
+
asset_id: asset.id,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console_1.default.error("Error updating Rigo package:", error);
|
|
54
|
+
}
|
|
50
55
|
console_1.default.info("Asset created with id", asset.id);
|
|
51
56
|
return asset;
|
|
52
57
|
}
|
|
@@ -58,9 +63,14 @@ const handleAssetCreation = async (sessionPayload, learnJson, selectedLang, lear
|
|
|
58
63
|
description: learnJson.description[selectedLang],
|
|
59
64
|
all_translations,
|
|
60
65
|
});
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
66
|
+
try {
|
|
67
|
+
await api_1.default.updateRigoPackage(sessionPayload.rigobotToken.trim(), learnJson.slug, {
|
|
68
|
+
asset_id: asset.id,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
console_1.default.error("Error updating Rigo package:", error);
|
|
73
|
+
}
|
|
64
74
|
console_1.default.info("Asset updated with id", asset.id);
|
|
65
75
|
return asset;
|
|
66
76
|
}
|
package/lib/utils/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ISolution, IError } from
|
|
1
|
+
import { ISolution, IError } from "../models/errors";
|
|
2
2
|
export declare const getSolution: (slug?: string) => ISolution;
|
|
3
3
|
export declare const ValidationError: (error: IError | string) => IError;
|
|
4
4
|
export declare const NotFoundError: (error: IError | string) => IError;
|
package/lib/utils/errors.js
CHANGED
|
@@ -2,32 +2,27 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InternalError = exports.AuthError = exports.TestingError = exports.CompilerError = exports.NotFoundError = exports.ValidationError = exports.getSolution = void 0;
|
|
4
4
|
const console_1 = require("./console");
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
const solutions = {
|
|
6
|
+
"install-jest": {
|
|
7
|
+
gif: "",
|
|
8
|
+
video: "",
|
|
9
|
+
message: "You need to install jest",
|
|
10
|
+
},
|
|
11
|
+
};
|
|
8
12
|
const uknown = {
|
|
9
|
-
video:
|
|
10
|
-
message:
|
|
11
|
-
slug:
|
|
12
|
-
gif:
|
|
13
|
+
video: "https://www.youtube.com/watch?v=gD1Sa99GiE4",
|
|
14
|
+
message: "Uknown internal error",
|
|
15
|
+
slug: "uknown",
|
|
16
|
+
gif: "https://github.com/breatheco-de/breathecode-cli/blob/master/docs/errors/uknown.gif?raw=true",
|
|
13
17
|
};
|
|
14
18
|
const getSolution = (slug) => {
|
|
15
19
|
if (!slug) {
|
|
16
|
-
console_1.default.debug(
|
|
20
|
+
console_1.default.debug("Getting solution templates from the learnpack repository");
|
|
17
21
|
}
|
|
18
22
|
else {
|
|
19
23
|
console_1.default.debug(`Getting solution for ${slug}`, solutions);
|
|
20
24
|
}
|
|
21
|
-
|
|
22
|
-
console_1.default.debug('Fetching for errors.json on github');
|
|
23
|
-
fetch('https://raw.githubusercontent.com/breatheco-de/breathecode-cli/master/docs/errors/errors.json')
|
|
24
|
-
.then((r) => r.json())
|
|
25
|
-
.then(function (_s) {
|
|
26
|
-
solutions = _s;
|
|
27
|
-
});
|
|
28
|
-
return uknown;
|
|
29
|
-
}
|
|
30
|
-
return typeof solutions[slug || ''] === 'undefined' || !slug ?
|
|
25
|
+
return typeof solutions[slug || ""] === "undefined" || !slug ?
|
|
31
26
|
uknown :
|
|
32
27
|
solutions[slug];
|
|
33
28
|
};
|
|
@@ -36,11 +31,11 @@ const ValidationError = (error) => {
|
|
|
36
31
|
const message = error.message || error;
|
|
37
32
|
const _err = new Error(message);
|
|
38
33
|
_err.status = 400;
|
|
39
|
-
_err.type =
|
|
34
|
+
_err.type = "validation-error";
|
|
40
35
|
const sol = (0, exports.getSolution)(error.slug);
|
|
41
36
|
_err.video = sol.video;
|
|
42
37
|
_err.gif = sol.gif;
|
|
43
|
-
_err.message = typeof message ===
|
|
38
|
+
_err.message = typeof message === "string" ? message : sol.message;
|
|
44
39
|
return _err;
|
|
45
40
|
};
|
|
46
41
|
exports.ValidationError = ValidationError;
|
|
@@ -48,11 +43,11 @@ const NotFoundError = (error) => {
|
|
|
48
43
|
const message = error.message || error;
|
|
49
44
|
const _err = new Error(message);
|
|
50
45
|
_err.status = 400;
|
|
51
|
-
_err.type =
|
|
46
|
+
_err.type = "not-found-error";
|
|
52
47
|
const sol = (0, exports.getSolution)(error.slug);
|
|
53
48
|
_err.video = sol.video;
|
|
54
49
|
_err.gif = sol.gif;
|
|
55
|
-
_err.message = typeof message ===
|
|
50
|
+
_err.message = typeof message === "string" ? message : sol.message;
|
|
56
51
|
return _err;
|
|
57
52
|
};
|
|
58
53
|
exports.NotFoundError = NotFoundError;
|
|
@@ -60,11 +55,11 @@ const CompilerError = (error) => {
|
|
|
60
55
|
const message = error.message || error;
|
|
61
56
|
const _err = new Error(message);
|
|
62
57
|
_err.status = 400;
|
|
63
|
-
_err.type =
|
|
58
|
+
_err.type = "compiler-error";
|
|
64
59
|
const sol = (0, exports.getSolution)(error.slug);
|
|
65
60
|
_err.video = sol.video;
|
|
66
61
|
_err.gif = sol.gif;
|
|
67
|
-
_err.message = typeof message ===
|
|
62
|
+
_err.message = typeof message === "string" ? message : sol.message;
|
|
68
63
|
return _err;
|
|
69
64
|
};
|
|
70
65
|
exports.CompilerError = CompilerError;
|
|
@@ -72,7 +67,7 @@ const TestingError = (error) => {
|
|
|
72
67
|
const message = error.message || error;
|
|
73
68
|
const _err = new Error(message);
|
|
74
69
|
_err.status = 400;
|
|
75
|
-
_err.type =
|
|
70
|
+
_err.type = "testing-error";
|
|
76
71
|
return _err;
|
|
77
72
|
};
|
|
78
73
|
exports.TestingError = TestingError;
|
|
@@ -80,7 +75,7 @@ const AuthError = (error) => {
|
|
|
80
75
|
const message = error.message || error;
|
|
81
76
|
const _err = new Error(message);
|
|
82
77
|
_err.status = 403;
|
|
83
|
-
_err.type =
|
|
78
|
+
_err.type = "auth-error";
|
|
84
79
|
return _err;
|
|
85
80
|
};
|
|
86
81
|
exports.AuthError = AuthError;
|
|
@@ -88,11 +83,11 @@ const InternalError = (error) => {
|
|
|
88
83
|
const message = error.message || error;
|
|
89
84
|
const _err = new Error(message);
|
|
90
85
|
_err.status = 500;
|
|
91
|
-
_err.type =
|
|
86
|
+
_err.type = "internal-error";
|
|
92
87
|
const sol = (0, exports.getSolution)(error.slug);
|
|
93
88
|
_err.video = sol.video;
|
|
94
89
|
_err.gif = sol.gif;
|
|
95
|
-
_err.message = typeof message ===
|
|
90
|
+
_err.message = typeof message === "string" ? message : sol.message;
|
|
96
91
|
return _err;
|
|
97
92
|
};
|
|
98
93
|
exports.InternalError = InternalError;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@learnpack/learnpack",
|
|
3
3
|
"description": "Seamlessly build, sell and/or take interactive & auto-graded tutorials, start learning now or build a new tutorial to your audience.",
|
|
4
|
-
"version": "5.0.
|
|
4
|
+
"version": "5.0.312",
|
|
5
5
|
"author": "Alejandro Sanchez @alesanchezr",
|
|
6
6
|
"contributors": [
|
|
7
7
|
{
|