@learnpack/learnpack 2.0.0 → 2.0.2
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +38 -33
- package/bin/run +1 -1
- package/package.json +1 -2
- package/src/commands/clean.ts +29 -29
- package/src/commands/download.ts +62 -62
- package/src/commands/init.ts +172 -169
- package/src/commands/login.ts +42 -42
- package/src/commands/logout.ts +43 -43
- package/src/commands/publish.ts +107 -107
- package/src/commands/start.ts +234 -229
- package/src/commands/test.ts +85 -83
- package/src/managers/config/exercise.ts +302 -295
- package/src/managers/config/index.ts +405 -404
- package/src/managers/file.ts +169 -169
- package/src/managers/server/index.ts +69 -69
- package/src/managers/server/routes.ts +255 -250
- package/src/managers/test.ts +83 -83
- package/src/plugin/plugin.ts +94 -94
- package/src/plugin/utils.ts +87 -87
- package/src/utils/BaseCommand.ts +47 -47
- package/src/utils/api.ts +188 -188
- package/src/utils/fileQueue.ts +198 -198
- package/oclif.manifest.json +0 -1
package/README.md
CHANGED
@@ -8,45 +8,49 @@ Create, sell or download and take learning amazing learning packages
|
|
8
8
|
[![License](https://img.shields.io/npm/l/learnpack.svg)](https://github.com/learnpack/learnpack-cli/blob/master/package.json)
|
9
9
|
|
10
10
|
<!-- toc -->
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
|
12
|
+
- [learnpack](#learnpack)
|
13
|
+
- [Usage](#usage)
|
14
|
+
- [Commands](#commands)
|
14
15
|
<!-- tocstop -->
|
15
16
|
|
16
17
|
# Usage
|
17
18
|
|
18
19
|
<!-- usage -->
|
20
|
+
|
19
21
|
```sh-session
|
20
22
|
$ npm install -g @learnpack/learnpack
|
21
23
|
$ learnpack COMMAND
|
22
24
|
running command...
|
23
25
|
$ learnpack (-v|--version|version)
|
24
|
-
@learnpack/learnpack/2.0.
|
26
|
+
@learnpack/learnpack/2.0.2 win32-x64 node-v16.14.0
|
25
27
|
$ learnpack --help [COMMAND]
|
26
28
|
USAGE
|
27
29
|
$ learnpack COMMAND
|
28
30
|
...
|
29
31
|
```
|
32
|
+
|
30
33
|
<!-- usagestop -->
|
31
34
|
|
32
35
|
# Commands
|
33
36
|
|
34
37
|
<!-- commands -->
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
38
|
+
|
39
|
+
- [`learnpack audit`](#learnpack-audit)
|
40
|
+
- [`learnpack clean`](#learnpack-clean)
|
41
|
+
- [`learnpack download [PACKAGE]`](#learnpack-download-package)
|
42
|
+
- [`learnpack help [COMMAND]`](#learnpack-help-command)
|
43
|
+
- [`learnpack init`](#learnpack-init)
|
44
|
+
- [`learnpack login [PACKAGE]`](#learnpack-login-package)
|
45
|
+
- [`learnpack logout [PACKAGE]`](#learnpack-logout-package)
|
46
|
+
- [`learnpack plugins`](#learnpack-plugins)
|
47
|
+
- [`learnpack plugins:install PLUGIN...`](#learnpack-pluginsinstall-plugin)
|
48
|
+
- [`learnpack plugins:link PLUGIN`](#learnpack-pluginslink-plugin)
|
49
|
+
- [`learnpack plugins:uninstall PLUGIN...`](#learnpack-pluginsuninstall-plugin)
|
50
|
+
- [`learnpack plugins:update`](#learnpack-pluginsupdate)
|
51
|
+
- [`learnpack publish [PACKAGE]`](#learnpack-publish-package)
|
52
|
+
- [`learnpack start`](#learnpack-start)
|
53
|
+
- [`learnpack test [EXERCISESLUG]`](#learnpack-test-exerciseslug)
|
50
54
|
|
51
55
|
## `learnpack audit`
|
52
56
|
|
@@ -63,7 +67,7 @@ DESCRIPTION
|
|
63
67
|
2. The command learnpack clean has been run. (Error)
|
64
68
|
3. If a markdown or test file doesn't have any content. (Error)
|
65
69
|
4. The links are accessing to valid servers. (Error)
|
66
|
-
5. The relative images are working (If they have the shortest path to the image or if the images exists in the
|
70
|
+
5. The relative images are working (If they have the shortest path to the image or if the images exists in the
|
67
71
|
assets). (Error)
|
68
72
|
6. The external images are working (If they are pointing to a valid server). (Error)
|
69
73
|
7. The exercises directory names are valid. (Error)
|
@@ -74,7 +78,7 @@ DESCRIPTION
|
|
74
78
|
12. If there is a file within the exercises folder but not inside of any particular exercise's folder. (Warning)
|
75
79
|
```
|
76
80
|
|
77
|
-
_See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v2.0.
|
81
|
+
_See code: [src\commands\audit.ts](https://github.com/learnpack/learnpack-cli/blob/v2.0.2/src\commands\audit.ts)_
|
78
82
|
|
79
83
|
## `learnpack clean`
|
80
84
|
|
@@ -89,7 +93,7 @@ DESCRIPTION
|
|
89
93
|
Extra documentation goes here
|
90
94
|
```
|
91
95
|
|
92
|
-
_See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v2.0.
|
96
|
+
_See code: [src\commands\clean.ts](https://github.com/learnpack/learnpack-cli/blob/v2.0.2/src\commands\clean.ts)_
|
93
97
|
|
94
98
|
## `learnpack download [PACKAGE]`
|
95
99
|
|
@@ -107,7 +111,7 @@ DESCRIPTION
|
|
107
111
|
Extra documentation goes here
|
108
112
|
```
|
109
113
|
|
110
|
-
_See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v2.0.
|
114
|
+
_See code: [src\commands\download.ts](https://github.com/learnpack/learnpack-cli/blob/v2.0.2/src\commands\download.ts)_
|
111
115
|
|
112
116
|
## `learnpack help [COMMAND]`
|
113
117
|
|
@@ -138,7 +142,7 @@ OPTIONS
|
|
138
142
|
-h, --grading show CLI help
|
139
143
|
```
|
140
144
|
|
141
|
-
_See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v2.0.
|
145
|
+
_See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v2.0.2/src\commands\init.ts)_
|
142
146
|
|
143
147
|
## `learnpack login [PACKAGE]`
|
144
148
|
|
@@ -156,7 +160,7 @@ DESCRIPTION
|
|
156
160
|
Extra documentation goes here
|
157
161
|
```
|
158
162
|
|
159
|
-
_See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v2.0.
|
163
|
+
_See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v2.0.2/src\commands\login.ts)_
|
160
164
|
|
161
165
|
## `learnpack logout [PACKAGE]`
|
162
166
|
|
@@ -174,7 +178,7 @@ DESCRIPTION
|
|
174
178
|
Extra documentation goes here
|
175
179
|
```
|
176
180
|
|
177
|
-
_See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v2.0.
|
181
|
+
_See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v2.0.2/src\commands\logout.ts)_
|
178
182
|
|
179
183
|
## `learnpack plugins`
|
180
184
|
|
@@ -214,15 +218,15 @@ DESCRIPTION
|
|
214
218
|
|
215
219
|
Installation of a user-installed plugin will override a core plugin.
|
216
220
|
|
217
|
-
e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
|
218
|
-
will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
|
221
|
+
e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
|
222
|
+
will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
|
219
223
|
the CLI without the need to patch and update the whole CLI.
|
220
224
|
|
221
225
|
ALIASES
|
222
226
|
$ learnpack plugins:add
|
223
227
|
|
224
228
|
EXAMPLES
|
225
|
-
$ learnpack plugins:install myplugin
|
229
|
+
$ learnpack plugins:install myplugin
|
226
230
|
$ learnpack plugins:install https://github.com/someuser/someplugin
|
227
231
|
$ learnpack plugins:install someuser/someplugin
|
228
232
|
```
|
@@ -247,7 +251,7 @@ OPTIONS
|
|
247
251
|
DESCRIPTION
|
248
252
|
Installation of a linked plugin will override a user-installed or core plugin.
|
249
253
|
|
250
|
-
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
|
254
|
+
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
|
251
255
|
command will override the user-installed or core plugin implementation. This is useful for development work.
|
252
256
|
|
253
257
|
EXAMPLE
|
@@ -309,7 +313,7 @@ DESCRIPTION
|
|
309
313
|
Extra documentation goes here
|
310
314
|
```
|
311
315
|
|
312
|
-
_See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v2.0.
|
316
|
+
_See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v2.0.2/src\commands\publish.ts)_
|
313
317
|
|
314
318
|
## `learnpack start`
|
315
319
|
|
@@ -330,7 +334,7 @@ OPTIONS
|
|
330
334
|
-w, --watch Watch for file changes
|
331
335
|
```
|
332
336
|
|
333
|
-
_See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v2.0.
|
337
|
+
_See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v2.0.2/src\commands\start.ts)_
|
334
338
|
|
335
339
|
## `learnpack test [EXERCISESLUG]`
|
336
340
|
|
@@ -344,5 +348,6 @@ ARGUMENTS
|
|
344
348
|
EXERCISESLUG The name of the exercise to test
|
345
349
|
```
|
346
350
|
|
347
|
-
_See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v2.0.
|
351
|
+
_See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v2.0.2/src\commands\test.ts)_
|
352
|
+
|
348
353
|
<!-- commandsstop -->
|
package/bin/run
CHANGED
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@learnpack/learnpack",
|
3
3
|
"description": "Create, sell or download and take learning amazing learning packages",
|
4
|
-
"version": "2.0.
|
4
|
+
"version": "2.0.2",
|
5
5
|
"author": "Alejandro Sanchez @alesanchezr",
|
6
6
|
"bin": {
|
7
7
|
"learnpack": "bin/run"
|
@@ -117,7 +117,6 @@
|
|
117
117
|
},
|
118
118
|
"scripts": {
|
119
119
|
"postpack": "rm -f oclif.manifest.json && eslint . --ext .ts --config .eslintrc",
|
120
|
-
"prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
|
121
120
|
"pre": "node ./test/precommit/index.ts",
|
122
121
|
"test": "NODE_ENV=test nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
|
123
122
|
"version": "oclif-dev readme && git add README.md",
|
package/src/commands/clean.ts
CHANGED
@@ -1,29 +1,29 @@
|
|
1
|
-
// import {flags} from '@oclif/command'
|
2
|
-
import Console from "../utils/console";
|
3
|
-
import SessionCommand from "../utils/SessionCommand";
|
4
|
-
|
5
|
-
class CleanCommand extends SessionCommand {
|
6
|
-
static description = `Clean the configuration object
|
7
|
-
...
|
8
|
-
Extra documentation goes here
|
9
|
-
`;
|
10
|
-
|
11
|
-
static flags: any = {
|
12
|
-
// name: flags.string({char: 'n', description: 'name to print'}),
|
13
|
-
};
|
14
|
-
|
15
|
-
async init() {
|
16
|
-
const { flags } = this.parse(CleanCommand);
|
17
|
-
await this.initSession(flags);
|
18
|
-
}
|
19
|
-
|
20
|
-
async run() {
|
21
|
-
const { flags } = this.parse(CleanCommand);
|
22
|
-
|
23
|
-
this.configManager?.clean();
|
24
|
-
|
25
|
-
Console.success("Package cleaned successfully, ready to publish");
|
26
|
-
}
|
27
|
-
}
|
28
|
-
|
29
|
-
export default CleanCommand;
|
1
|
+
// import {flags} from '@oclif/command'
|
2
|
+
import Console from "../utils/console";
|
3
|
+
import SessionCommand from "../utils/SessionCommand";
|
4
|
+
|
5
|
+
class CleanCommand extends SessionCommand {
|
6
|
+
static description = `Clean the configuration object
|
7
|
+
...
|
8
|
+
Extra documentation goes here
|
9
|
+
`;
|
10
|
+
|
11
|
+
static flags: any = {
|
12
|
+
// name: flags.string({char: 'n', description: 'name to print'}),
|
13
|
+
};
|
14
|
+
|
15
|
+
async init() {
|
16
|
+
const { flags } = this.parse(CleanCommand);
|
17
|
+
await this.initSession(flags);
|
18
|
+
}
|
19
|
+
|
20
|
+
async run() {
|
21
|
+
const { flags } = this.parse(CleanCommand);
|
22
|
+
|
23
|
+
this.configManager?.clean();
|
24
|
+
|
25
|
+
Console.success("Package cleaned successfully, ready to publish");
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
export default CleanCommand;
|
package/src/commands/download.ts
CHANGED
@@ -1,62 +1,62 @@
|
|
1
|
-
import {Command /* , flags */} from
|
2
|
-
// import fetch from 'node-fetch'
|
3
|
-
import {clone} from
|
4
|
-
import Console from
|
5
|
-
import api from
|
6
|
-
import {askPackage} from
|
7
|
-
// const BaseCommand = require('../utils/BaseCommand');
|
8
|
-
|
9
|
-
class DownloadCommand extends Command {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
hidden: false, // hide this arg from help
|
26
|
-
},
|
27
|
-
]
|
28
|
-
// async init() {
|
29
|
-
// const {flags} = this.parse(DownloadCommand)
|
30
|
-
// await this.initSession(flags)
|
31
|
-
// }
|
32
|
-
|
33
|
-
async run() {
|
34
|
-
const {/* flags, */ args} = this.parse(DownloadCommand)
|
35
|
-
// start watching for file changes
|
36
|
-
let _package: string = args.package
|
37
|
-
if (!_package) {
|
38
|
-
_package = (await askPackage()) as string
|
39
|
-
}
|
40
|
-
|
41
|
-
if (!_package) {
|
42
|
-
return null
|
43
|
-
}
|
44
|
-
|
45
|
-
try {
|
46
|
-
const packageInfo = await api.getAllPackages({slug: _package})
|
47
|
-
if (packageInfo.results.length === 0)
|
48
|
-
Console.error(`Package ${_package} not found`)
|
49
|
-
else
|
50
|
-
clone(packageInfo.results[0].repository)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
} catch {}
|
59
|
-
}
|
60
|
-
}
|
61
|
-
|
62
|
-
export default DownloadCommand
|
1
|
+
import { Command /* , flags */ } from "@oclif/command";
|
2
|
+
// import fetch from 'node-fetch'
|
3
|
+
import { clone } from "../managers/file";
|
4
|
+
import Console from "../utils/console";
|
5
|
+
import api from "../utils/api";
|
6
|
+
import { askPackage } from "../ui/download";
|
7
|
+
// const BaseCommand = require('../utils/BaseCommand');
|
8
|
+
|
9
|
+
class DownloadCommand extends Command {
|
10
|
+
static description = `Describe the command here
|
11
|
+
...
|
12
|
+
Extra documentation goes here
|
13
|
+
`;
|
14
|
+
|
15
|
+
static flags: any = {
|
16
|
+
// name: flags.string({char: 'n', description: 'name to print'}),
|
17
|
+
};
|
18
|
+
|
19
|
+
static args = [
|
20
|
+
{
|
21
|
+
name: "package", // name of arg to show in help and reference with args[name]
|
22
|
+
required: false, // make the arg required with `required: true`
|
23
|
+
description:
|
24
|
+
"The unique string that identifies this package on learnpack", // help description
|
25
|
+
hidden: false, // hide this arg from help
|
26
|
+
},
|
27
|
+
];
|
28
|
+
// async init() {
|
29
|
+
// const {flags} = this.parse(DownloadCommand)
|
30
|
+
// await this.initSession(flags)
|
31
|
+
// }
|
32
|
+
|
33
|
+
async run() {
|
34
|
+
const { /* flags, */ args } = this.parse(DownloadCommand);
|
35
|
+
// start watching for file changes
|
36
|
+
let _package: string = args.package;
|
37
|
+
if (!_package) {
|
38
|
+
_package = (await askPackage()) as string;
|
39
|
+
}
|
40
|
+
|
41
|
+
if (!_package) {
|
42
|
+
return null;
|
43
|
+
}
|
44
|
+
|
45
|
+
try {
|
46
|
+
const packageInfo = await api.getAllPackages({ slug: _package });
|
47
|
+
if (packageInfo.results.length === 0)
|
48
|
+
Console.error(`Package ${_package} not found`);
|
49
|
+
else
|
50
|
+
clone(packageInfo.results[0].repository)
|
51
|
+
.then(_result => {
|
52
|
+
Console.success("Successfully downloaded");
|
53
|
+
Console.info(
|
54
|
+
`You can now CD into the folder like this: $ cd ${_package}`
|
55
|
+
);
|
56
|
+
})
|
57
|
+
.catch(error => Console.error(error.message || error));
|
58
|
+
} catch {}
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
export default DownloadCommand;
|