@learnpack/learnpack 5.0.8 → 5.0.9
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +11 -11
- package/lib/commands/audit.js +12 -9
- package/lib/managers/config/index.d.ts +10 -0
- package/lib/managers/config/index.js +3 -1
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/audit.ts +12 -12
- package/src/managers/config/index.ts +6 -4
package/README.md
CHANGED
@@ -21,7 +21,7 @@ $ npm install -g @learnpack/learnpack
|
|
21
21
|
$ learnpack COMMAND
|
22
22
|
running command...
|
23
23
|
$ learnpack (-v|--version|version)
|
24
|
-
@learnpack/learnpack/5.0.
|
24
|
+
@learnpack/learnpack/5.0.9 darwin-arm64 node-v16.20.0
|
25
25
|
$ learnpack --help [COMMAND]
|
26
26
|
USAGE
|
27
27
|
$ learnpack COMMAND
|
@@ -75,7 +75,7 @@ DESCRIPTION
|
|
75
75
|
12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)
|
76
76
|
```
|
77
77
|
|
78
|
-
_See code: [src/commands/audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
78
|
+
_See code: [src/commands/audit.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.9/src/commands/audit.ts)_
|
79
79
|
|
80
80
|
## `learnpack clean`
|
81
81
|
|
@@ -90,7 +90,7 @@ DESCRIPTION
|
|
90
90
|
Extra documentation goes here
|
91
91
|
```
|
92
92
|
|
93
|
-
_See code: [src/commands/clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
93
|
+
_See code: [src/commands/clean.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.9/src/commands/clean.ts)_
|
94
94
|
|
95
95
|
## `learnpack download [PACKAGE]`
|
96
96
|
|
@@ -108,7 +108,7 @@ DESCRIPTION
|
|
108
108
|
Extra documentation goes here
|
109
109
|
```
|
110
110
|
|
111
|
-
_See code: [src/commands/download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
111
|
+
_See code: [src/commands/download.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.9/src/commands/download.ts)_
|
112
112
|
|
113
113
|
## `learnpack help [COMMAND]`
|
114
114
|
|
@@ -139,7 +139,7 @@ OPTIONS
|
|
139
139
|
-h, --grading show CLI help
|
140
140
|
```
|
141
141
|
|
142
|
-
_See code: [src/commands/init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
142
|
+
_See code: [src/commands/init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.9/src/commands/init.ts)_
|
143
143
|
|
144
144
|
## `learnpack login [PACKAGE]`
|
145
145
|
|
@@ -157,7 +157,7 @@ DESCRIPTION
|
|
157
157
|
Extra documentation goes here
|
158
158
|
```
|
159
159
|
|
160
|
-
_See code: [src/commands/login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
160
|
+
_See code: [src/commands/login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.9/src/commands/login.ts)_
|
161
161
|
|
162
162
|
## `learnpack logout [PACKAGE]`
|
163
163
|
|
@@ -175,7 +175,7 @@ DESCRIPTION
|
|
175
175
|
Extra documentation goes here
|
176
176
|
```
|
177
177
|
|
178
|
-
_See code: [src/commands/logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
178
|
+
_See code: [src/commands/logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.9/src/commands/logout.ts)_
|
179
179
|
|
180
180
|
## `learnpack plugins`
|
181
181
|
|
@@ -306,7 +306,7 @@ OPTIONS
|
|
306
306
|
-h, --help show CLI help
|
307
307
|
```
|
308
308
|
|
309
|
-
_See code: [src/commands/publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
309
|
+
_See code: [src/commands/publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.9/src/commands/publish.ts)_
|
310
310
|
|
311
311
|
## `learnpack start`
|
312
312
|
|
@@ -327,7 +327,7 @@ OPTIONS
|
|
327
327
|
-w, --watch Watch for file changes
|
328
328
|
```
|
329
329
|
|
330
|
-
_See code: [src/commands/start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
330
|
+
_See code: [src/commands/start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.9/src/commands/start.ts)_
|
331
331
|
|
332
332
|
## `learnpack test [EXERCISESLUG]`
|
333
333
|
|
@@ -341,7 +341,7 @@ ARGUMENTS
|
|
341
341
|
EXERCISESLUG The name of the exercise to test
|
342
342
|
```
|
343
343
|
|
344
|
-
_See code: [src/commands/test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
344
|
+
_See code: [src/commands/test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.9/src/commands/test.ts)_
|
345
345
|
|
346
346
|
## `learnpack translate`
|
347
347
|
|
@@ -352,7 +352,7 @@ USAGE
|
|
352
352
|
$ learnpack translate
|
353
353
|
```
|
354
354
|
|
355
|
-
_See code: [src/commands/translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
355
|
+
_See code: [src/commands/translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.9/src/commands/translate.ts)_
|
356
356
|
<!-- commandsstop -->
|
357
357
|
|
358
358
|
> > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
|
package/lib/commands/audit.js
CHANGED
@@ -6,6 +6,7 @@ const console_1 = require("../utils/console");
|
|
6
6
|
const audit_1 = require("../utils/audit");
|
7
7
|
const SessionCommand_1 = require("../utils/SessionCommand");
|
8
8
|
const path = require("path");
|
9
|
+
const index_1 = require("../managers/config/index");
|
9
10
|
// eslint-disable-next-line
|
10
11
|
const fetch = require("node-fetch");
|
11
12
|
class AuditCommand extends SessionCommand_1.default {
|
@@ -16,6 +17,17 @@ class AuditCommand extends SessionCommand_1.default {
|
|
16
17
|
async run() {
|
17
18
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
18
19
|
console_1.default.log("Running command audit...");
|
20
|
+
// Checking the "learn.json" file:
|
21
|
+
let learnjson;
|
22
|
+
try {
|
23
|
+
const configPath = (0, index_1.getConfigPath)().config;
|
24
|
+
const learnJsonContent = fs.readFileSync(configPath);
|
25
|
+
learnjson = JSON.parse(learnJsonContent.toString());
|
26
|
+
}
|
27
|
+
catch (_error) {
|
28
|
+
console_1.default.error("Invalid JSON syntax in learn.json file:", _error.message);
|
29
|
+
process.exit(1);
|
30
|
+
}
|
19
31
|
// Get configuration object.
|
20
32
|
let config = (_a = this.configManager) === null || _a === void 0 ? void 0 : _a.get();
|
21
33
|
if (config) {
|
@@ -236,15 +248,6 @@ class AuditCommand extends SessionCommand_1.default {
|
|
236
248
|
}
|
237
249
|
else {
|
238
250
|
// This is the audit code for Projects
|
239
|
-
// Checking the "learn.json" file:
|
240
|
-
let learnjson;
|
241
|
-
try {
|
242
|
-
learnjson = JSON.parse(fs.readFileSync("./learn.json").toString());
|
243
|
-
}
|
244
|
-
catch (_error) {
|
245
|
-
console_1.default.error("Invalid JSON syntax in learn.json file:", _error.message);
|
246
|
-
process.exit(1);
|
247
|
-
}
|
248
251
|
if (!learnjson) {
|
249
252
|
console_1.default.error("There is no learn.json file located in the root of the project.");
|
250
253
|
process.exit(1);
|
@@ -1,3 +1,13 @@
|
|
1
1
|
import { IConfigManagerAttributes, IConfigManager } from "../../models/config-manager";
|
2
|
+
/**
|
3
|
+
* Retrieves the configuration path for the learnpack package.
|
4
|
+
*
|
5
|
+
* @returns An object containing the configuration file path and the base directory.
|
6
|
+
* @throws NotFoundError if the learn.json file is not found in the current folder.
|
7
|
+
*/
|
8
|
+
export declare const getConfigPath: () => {
|
9
|
+
config: string;
|
10
|
+
base: string;
|
11
|
+
};
|
2
12
|
declare const _default: ({ grading, mode, disableGrading, version, }: IConfigManagerAttributes) => Promise<IConfigManager>;
|
3
13
|
export default _default;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.getConfigPath = void 0;
|
3
4
|
const path = require("path");
|
4
5
|
const fs = require("fs");
|
5
6
|
const shell = require("shelljs");
|
@@ -33,6 +34,7 @@ const getConfigPath = () => {
|
|
33
34
|
throw (0, errors_1.NotFoundError)("learn.json file not found on current folder, is this a learnpack package?");
|
34
35
|
return { config, base: ".learn" };
|
35
36
|
};
|
37
|
+
exports.getConfigPath = getConfigPath;
|
36
38
|
const getExercisesPath = (base) => {
|
37
39
|
const possibleFileNames = ["./exercises", base + "/exercises", "./"];
|
38
40
|
return possibleFileNames.find(file => fs.existsSync(file)) || null;
|
@@ -61,7 +63,7 @@ const getCodespacesNamespace = () => {
|
|
61
63
|
};
|
62
64
|
exports.default = async ({ grading, mode, disableGrading, version, }) => {
|
63
65
|
var _a, _b, _c, _d, _e, _f;
|
64
|
-
const confPath = getConfigPath();
|
66
|
+
const confPath = (0, exports.getConfigPath)();
|
65
67
|
console_1.default.debug("This is the config path: ", confPath);
|
66
68
|
let configObj = {};
|
67
69
|
if (confPath) {
|
package/oclif.manifest.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":"5.0.
|
1
|
+
{"version":"5.0.9","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":[]},"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":{"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":{"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":{},"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":{},"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.9",
|
5
5
|
"author": "Alejandro Sanchez @alesanchezr",
|
6
6
|
"contributors": [
|
7
7
|
{
|
package/src/commands/audit.ts
CHANGED
@@ -10,6 +10,7 @@ import { IFrontmatter } from "../models/front-matter"
|
|
10
10
|
import { IAuditErrors } from "../models/audit"
|
11
11
|
import { ICounter } from "../models/counter"
|
12
12
|
import { IFindings } from "../models/findings"
|
13
|
+
import { getConfigPath } from "../managers/config/index"
|
13
14
|
|
14
15
|
// eslint-disable-next-line
|
15
16
|
const fetch = require("node-fetch");
|
@@ -23,6 +24,17 @@ class AuditCommand extends SessionCommand {
|
|
23
24
|
async run() {
|
24
25
|
Console.log("Running command audit...")
|
25
26
|
|
27
|
+
// Checking the "learn.json" file:
|
28
|
+
let learnjson
|
29
|
+
try {
|
30
|
+
const configPath: string = getConfigPath().config
|
31
|
+
const learnJsonContent: Buffer = fs.readFileSync(configPath)
|
32
|
+
learnjson = JSON.parse(learnJsonContent.toString())
|
33
|
+
} catch (_error: any) {
|
34
|
+
Console.error("Invalid JSON syntax in learn.json file:", _error.message)
|
35
|
+
process.exit(1)
|
36
|
+
}
|
37
|
+
|
26
38
|
// Get configuration object.
|
27
39
|
let config = this.configManager?.get()
|
28
40
|
|
@@ -305,18 +317,6 @@ files.push(` ${item.exercise}`)
|
|
305
317
|
} else {
|
306
318
|
// This is the audit code for Projects
|
307
319
|
|
308
|
-
// Checking the "learn.json" file:
|
309
|
-
let learnjson
|
310
|
-
try {
|
311
|
-
learnjson = JSON.parse(fs.readFileSync("./learn.json").toString())
|
312
|
-
} catch (_error: any) {
|
313
|
-
Console.error(
|
314
|
-
"Invalid JSON syntax in learn.json file:",
|
315
|
-
_error.message
|
316
|
-
)
|
317
|
-
process.exit(1)
|
318
|
-
}
|
319
|
-
|
320
320
|
if (!learnjson) {
|
321
321
|
Console.error(
|
322
322
|
"There is no learn.json file located in the root of the project."
|
@@ -32,9 +32,9 @@ import { IFile } from "../../models/file"
|
|
32
32
|
const execAsync = promisify(exec)
|
33
33
|
|
34
34
|
// eslint-disable-next-line
|
35
|
-
const fetch = require("node-fetch")
|
35
|
+
const fetch = require("node-fetch");
|
36
36
|
// eslint-disable-next-line
|
37
|
-
const chalk = require("chalk")
|
37
|
+
const chalk = require("chalk");
|
38
38
|
|
39
39
|
/* exercise folder name standard */
|
40
40
|
|
@@ -44,7 +44,7 @@ const chalk = require("chalk")
|
|
44
44
|
* @returns An object containing the configuration file path and the base directory.
|
45
45
|
* @throws NotFoundError if the learn.json file is not found in the current folder.
|
46
46
|
*/
|
47
|
-
const getConfigPath = () => {
|
47
|
+
export const getConfigPath = () => {
|
48
48
|
const possibleFileNames = ["learn.json", ".learn/learn.json"]
|
49
49
|
const config = possibleFileNames.find(file => fs.existsSync(file)) || null
|
50
50
|
if (config && fs.existsSync(".breathecode"))
|
@@ -444,7 +444,9 @@ fs.unlinkSync(_path)
|
|
444
444
|
ex => ex.slug === slug
|
445
445
|
)
|
446
446
|
if (!exercise)
|
447
|
-
throw ValidationError(
|
447
|
+
throw ValidationError(
|
448
|
+
`Exercise ${slug} not found on the configuration`
|
449
|
+
)
|
448
450
|
|
449
451
|
if (configObj.config) {
|
450
452
|
for (const fileName of fs.readdirSync(
|