@learnpack/learnpack 5.0.29 → 5.0.31
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 +12 -12
- package/lib/commands/audit.js +15 -15
- package/lib/commands/init.js +39 -15
- package/lib/commands/logout.js +6 -11
- package/lib/commands/start.js +0 -3
- package/lib/commands/translate.js +2 -10
- package/lib/managers/config/index.js +102 -77
- package/lib/managers/file.js +1 -1
- package/lib/managers/server/routes.js +68 -0
- package/lib/managers/session.js +3 -0
- package/lib/models/config-manager.d.ts +2 -0
- package/lib/utils/creatorUtilities.d.ts +2 -0
- package/lib/utils/creatorUtilities.js +48 -7
- package/lib/utils/rigoActions.d.ts +1 -0
- package/lib/utils/rigoActions.js +13 -2
- package/oclif.manifest.json +1 -1
- package/package.json +3 -2
- package/src/commands/audit.ts +449 -449
- package/src/commands/breakToken.ts +36 -36
- package/src/commands/init.ts +48 -17
- package/src/commands/logout.ts +38 -43
- package/src/commands/publish.ts +312 -312
- package/src/commands/start.ts +0 -3
- package/src/commands/translate.ts +1 -20
- package/src/managers/config/index.ts +742 -715
- package/src/managers/file.ts +1 -1
- package/src/managers/server/routes.ts +103 -1
- package/src/managers/session.ts +4 -0
- package/src/models/config-manager.ts +25 -23
- package/src/utils/console.ts +24 -24
- package/src/utils/creatorUtilities.ts +66 -6
- package/src/utils/rigoActions.ts +13 -1
- package/src/utils/templates/incremental/.github/workflows/learnpack-audit.yml +29 -0
- package/src/utils/templates/isolated/.github/workflows/learnpack-audit.yml +29 -0
@@ -1,13 +1,13 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.makePackageInfo = exports.getExInfo = exports.estimateReadingTime = void 0;
|
3
|
+
exports.saveTranslatedReadme = exports.makePackageInfo = exports.getExInfo = exports.estimateReadingTime = void 0;
|
4
4
|
exports.checkReadingTime = checkReadingTime;
|
5
5
|
exports.extractImagesFromMarkdown = extractImagesFromMarkdown;
|
6
6
|
exports.getFilenameFromUrl = getFilenameFromUrl;
|
7
7
|
exports.estimateDuration = estimateDuration;
|
8
8
|
exports.createFileOnDesktop = createFileOnDesktop;
|
9
9
|
exports.getContentIndex = getContentIndex;
|
10
|
-
|
10
|
+
exports.extractTextFromMarkdown = extractTextFromMarkdown;
|
11
11
|
const frontMatter = require("front-matter");
|
12
12
|
const path = require("path");
|
13
13
|
const fs = require("fs");
|
@@ -41,6 +41,7 @@ exports.estimateReadingTime = estimateReadingTime;
|
|
41
41
|
function checkReadingTime(markdown, wordsPerMinute = 200, maxMinutes = 1) {
|
42
42
|
const parsed = frontMatter(markdown);
|
43
43
|
const readingTime = (0, exports.estimateReadingTime)(parsed.body, wordsPerMinute);
|
44
|
+
// const readingEase = estimateReadingEase(parsed.body)
|
44
45
|
let attributes = parsed.attributes ? parsed.attributes : {};
|
45
46
|
if (typeof parsed.attributes !== "object") {
|
46
47
|
attributes = {};
|
@@ -56,6 +57,7 @@ function checkReadingTime(markdown, wordsPerMinute = 200, maxMinutes = 1) {
|
|
56
57
|
exceedsThreshold: false,
|
57
58
|
minutes: 0,
|
58
59
|
body: "",
|
60
|
+
// readingEase: 0,
|
59
61
|
};
|
60
62
|
}
|
61
63
|
// Reconstruct the markdown with the front matter
|
@@ -65,6 +67,7 @@ function checkReadingTime(markdown, wordsPerMinute = 200, maxMinutes = 1) {
|
|
65
67
|
exceedsThreshold: readingTime.minutes > maxMinutes,
|
66
68
|
minutes: readingTime.minutes,
|
67
69
|
body: parsed.body,
|
70
|
+
// readingEase: 0,
|
68
71
|
};
|
69
72
|
}
|
70
73
|
const slugify = (text) => {
|
@@ -146,11 +149,13 @@ function estimateDuration(listOfSteps) {
|
|
146
149
|
}
|
147
150
|
const writeFilePromise = (0, util_1.promisify)(fs.writeFile);
|
148
151
|
const execPromise = (0, util_1.promisify)(child_process_1.exec);
|
149
|
-
const example_content = `
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
152
|
+
const example_content = `Write or paste your table of content below this line, each topic should be defined on a new line, here is an example:
|
153
|
+
|
154
|
+
Introduction to AI: Explain what is AI and its applications
|
155
|
+
Introduction to Machine Learning: Explain what is machine learning and its applications
|
156
|
+
What is an AI Model: Explain what is an AI model and its applications
|
157
|
+
How to use an AI Model: Different APIs, local models, etc.
|
158
|
+
How to build an AI Model: Fine-tuning, data collection, cleaning and more.
|
154
159
|
`;
|
155
160
|
async function createFileOnDesktop() {
|
156
161
|
try {
|
@@ -191,3 +196,39 @@ function getContentIndex() {
|
|
191
196
|
const content = fs.readFileSync(filePath, "utf8");
|
192
197
|
return content;
|
193
198
|
}
|
199
|
+
// export function fleschKincaidReadingEase(text: string): number {
|
200
|
+
// const sentences = text.split(/[.!?]/).filter((s) => s.trim().length > 0)
|
201
|
+
// const words = text.split(/\s+/).filter((w) => w.trim().length > 0)
|
202
|
+
// const totalSyllables = words.reduce((sum, word) => sum + syllable(word), 0)
|
203
|
+
// const ASL = words.length / sentences.length // Average Sentence Length
|
204
|
+
// const ASW = totalSyllables / words.length // Average Syllables per Word
|
205
|
+
// return Math.round(206.835 - 1.015 * ASL - 84.6 * ASW)
|
206
|
+
// }
|
207
|
+
function extractTextFromMarkdown(mdContent) {
|
208
|
+
let content = mdContent.replace(/!\[.*?]\(.*?\)/g, "");
|
209
|
+
content = content.replace(/\[.*?]\(.*?\)/g, "");
|
210
|
+
content = content.replace(/`.*?`/g, "");
|
211
|
+
content = content.replace(/```[\S\s]*?```/g, "");
|
212
|
+
return content.trim();
|
213
|
+
}
|
214
|
+
// export const estimateReadingEase = async (text: string): Promise<number> => {
|
215
|
+
// const cleanedText = extractTextFromMarkdown(text)
|
216
|
+
// // @ts-ignore
|
217
|
+
// const rs = (await import("text-readability")).default;
|
218
|
+
// // return fleschKincaidReadingEase(cleanedText)
|
219
|
+
// // const score = readability(cleanedText)
|
220
|
+
// // console.log(score)
|
221
|
+
// // return score.fleschKincaid ?? 0
|
222
|
+
// const score = rs.fleschReadingEase(cleanedText)
|
223
|
+
// console.log(score, "SCORE FLESCH READING EASE")
|
224
|
+
// return score
|
225
|
+
// }
|
226
|
+
const cleanReadme = (readme) => {
|
227
|
+
// Replace <text> and </text> with nothing
|
228
|
+
return readme.replace(/<text>/g, "").replace(/<\/text>/g, "");
|
229
|
+
};
|
230
|
+
const saveTranslatedReadme = async (exercise, languageCode, readme) => {
|
231
|
+
const readmePath = path.join(process.cwd(), "exercises", exercise, `README.${languageCode}.md`);
|
232
|
+
fs.writeFileSync(readmePath, cleanReadme(readme));
|
233
|
+
};
|
234
|
+
exports.saveTranslatedReadme = saveTranslatedReadme;
|
@@ -58,4 +58,5 @@ type TReduceReadmeInputs = {
|
|
58
58
|
expected_number_words: string;
|
59
59
|
};
|
60
60
|
export declare function reduceReadme(rigoToken: string, inputs: TReduceReadmeInputs): Promise<any>;
|
61
|
+
export declare const isValidRigoToken: (rigobotToken: string) => Promise<boolean>;
|
61
62
|
export {};
|
package/lib/utils/rigoActions.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.readmeCreator = exports.createCodingReadme = exports.createCodeFile = exports.interactiveCreation = exports.generateCourseIntroduction = exports.translateExercise = exports.generateImage = exports.hasCreatorPermission = exports.createReadme = void 0;
|
3
|
+
exports.isValidRigoToken = exports.readmeCreator = exports.createCodingReadme = exports.createCodeFile = exports.interactiveCreation = exports.generateCourseIntroduction = exports.translateExercise = exports.generateImage = exports.hasCreatorPermission = exports.createReadme = void 0;
|
4
4
|
exports.downloadImage = downloadImage;
|
5
5
|
exports.createPreviewReadme = createPreviewReadme;
|
6
6
|
exports.reduceReadme = reduceReadme;
|
@@ -46,7 +46,7 @@ const hasCreatorPermission = async (token) => {
|
|
46
46
|
return true;
|
47
47
|
}
|
48
48
|
catch (error) {
|
49
|
-
console_1.default.
|
49
|
+
console_1.default.error(error);
|
50
50
|
return false;
|
51
51
|
}
|
52
52
|
};
|
@@ -191,3 +191,14 @@ async function reduceReadme(rigoToken, inputs) {
|
|
191
191
|
return null;
|
192
192
|
}
|
193
193
|
}
|
194
|
+
const isValidRigoToken = async (rigobotToken) => {
|
195
|
+
const rigoUrl = `${RIGOBOT_HOST}/v1/auth/token/${rigobotToken}`;
|
196
|
+
const rigoResp = await fetch(rigoUrl);
|
197
|
+
if (!rigoResp.ok) {
|
198
|
+
console_1.default.debug("Invalid Rigobot token", rigoResp.status);
|
199
|
+
console_1.default.debug(rigoResp.statusText);
|
200
|
+
return false;
|
201
|
+
}
|
202
|
+
return true;
|
203
|
+
};
|
204
|
+
exports.isValidRigoToken = isValidRigoToken;
|
package/oclif.manifest.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":"5.0.
|
1
|
+
{"version":"5.0.31","commands":{"audit":{"id":"audit","description":"learnpack audit is the command in charge of creating an auditory of the repository\n...\nlearnpack audit checks for the following information in a repository:\n 1. The configuration object has slug, repository and description. (Error)\n 2. The command learnpack clean has been run. (Error)\n 3. If a markdown or test file doesn't have any content. (Error)\n 4. The links are accessing to valid servers. (Error)\n 5. The relative images are working (If they have the shortest path to the image or if the images exists in the assets). (Error)\n 6. The external images are working (If they are pointing to a valid server). (Error)\n 7. The exercises directory names are valid. (Error)\n 8. If an exercise doesn't have a README file. (Error)\n 9. The exercises array (Of the config file) has content. (Error)\n 10. The exercses have the same translations. (Warning)\n 11. The .gitignore file exists. (Warning)\n 12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[]},"breakToken":{"id":"breakToken","description":"Break the token","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"grading":{"name":"grading","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"clean":{"id":"clean","description":"Clean the configuration object\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[]},"download":{"id":"download","description":"Describe the command here\n...\nExtra documentation goes here\n","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"init":{"id":"init","description":"Create a new learning package: Book, Tutorial or Exercise","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"grading":{"name":"grading","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"login":{"id":"login","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"logout":{"id":"logout","description":"Describe the command here\n ...\n Extra documentation goes here\n ","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"publish":{"id":"publish","description":"Builds the project by copying necessary files and directories into a zip file","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"help":{"name":"help","type":"boolean","char":"h","description":"show CLI help","allowNo":false}},"args":[]},"start":{"id":"start","description":"Runs a small server with all the exercise instructions","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false},"port":{"name":"port","type":"option","char":"p","description":"server port"},"host":{"name":"host","type":"option","char":"h","description":"server host"},"disableGrading":{"name":"disableGrading","type":"boolean","char":"D","description":"disble grading functionality","allowNo":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Watch for file changes","allowNo":false},"editor":{"name":"editor","type":"option","char":"e","description":"[preview, extension]","options":["extension","preview"]},"version":{"name":"version","type":"option","char":"v","description":"E.g: 1.0.1"},"grading":{"name":"grading","type":"option","char":"g","description":"[isolated, incremental]","options":["isolated","incremental"]},"debug":{"name":"debug","type":"boolean","char":"d","description":"debugger mode for more verbage","allowNo":false}},"args":[]},"test":{"id":"test","description":"Test exercises","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[{"name":"exerciseSlug","description":"The name of the exercise to test","required":false,"hidden":false}]},"translate":{"id":"translate","description":"List all the lessons, the user is able of select many of them to translate to the given languages","pluginName":"@learnpack/learnpack","pluginType":"core","aliases":[],"flags":{"yes":{"name":"yes","type":"boolean","char":"y","description":"Skip all prompts and initialize an empty project","allowNo":false}},"args":[]}}}
|
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.31",
|
5
5
|
"author": "Alejandro Sanchez @alesanchezr",
|
6
6
|
"contributors": [
|
7
7
|
{
|
@@ -50,6 +50,7 @@
|
|
50
50
|
"shelljs": "^0.8.4",
|
51
51
|
"socket.io": "^4.4.1",
|
52
52
|
"targz": "^1.0.1",
|
53
|
+
"text-readability": "^1.1.0",
|
53
54
|
"tslib": "^1",
|
54
55
|
"validator": "^13.1.1",
|
55
56
|
"xxhashjs": "^0.2.2"
|
@@ -64,7 +65,7 @@
|
|
64
65
|
"@types/js-yaml": "^4.0.9",
|
65
66
|
"@types/mocha": "^5",
|
66
67
|
"@types/mock-fs": "^4.13.1",
|
67
|
-
"@types/node": "^
|
68
|
+
"@types/node": "^22.13.5",
|
68
69
|
"@types/node-persist": "^3.1.2",
|
69
70
|
"@types/prompts": "^2.0.14",
|
70
71
|
"@types/shelljs": "^0.8.9",
|