@learnpack/learnpack 5.0.23 → 5.0.26
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 +11 -11
- package/lib/managers/session.js +7 -6
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
- package/src/commands/translate.ts +0 -1
- package/src/managers/session.ts +8 -7
- package/src/utils/incrementVersion.js +49 -40
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.26 win32-x64 node-v20.16.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.26/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.26/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.26/src\commands\download.ts)_
|
112
112
|
|
113
113
|
## `learnpack help [COMMAND]`
|
114
114
|
|
@@ -140,7 +140,7 @@ OPTIONS
|
|
140
140
|
-y, --yes Skip all prompts and initialize an empty project
|
141
141
|
```
|
142
142
|
|
143
|
-
_See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
143
|
+
_See code: [src\commands\init.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.26/src\commands\init.ts)_
|
144
144
|
|
145
145
|
## `learnpack login [PACKAGE]`
|
146
146
|
|
@@ -158,7 +158,7 @@ DESCRIPTION
|
|
158
158
|
Extra documentation goes here
|
159
159
|
```
|
160
160
|
|
161
|
-
_See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
161
|
+
_See code: [src\commands\login.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.26/src\commands\login.ts)_
|
162
162
|
|
163
163
|
## `learnpack logout [PACKAGE]`
|
164
164
|
|
@@ -176,7 +176,7 @@ DESCRIPTION
|
|
176
176
|
Extra documentation goes here
|
177
177
|
```
|
178
178
|
|
179
|
-
_See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
179
|
+
_See code: [src\commands\logout.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.26/src\commands\logout.ts)_
|
180
180
|
|
181
181
|
## `learnpack plugins`
|
182
182
|
|
@@ -307,7 +307,7 @@ OPTIONS
|
|
307
307
|
-h, --help show CLI help
|
308
308
|
```
|
309
309
|
|
310
|
-
_See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
310
|
+
_See code: [src\commands\publish.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.26/src\commands\publish.ts)_
|
311
311
|
|
312
312
|
## `learnpack start`
|
313
313
|
|
@@ -329,7 +329,7 @@ OPTIONS
|
|
329
329
|
-y, --yes Skip all prompts and initialize an empty project
|
330
330
|
```
|
331
331
|
|
332
|
-
_See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
332
|
+
_See code: [src\commands\start.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.26/src\commands\start.ts)_
|
333
333
|
|
334
334
|
## `learnpack test [EXERCISESLUG]`
|
335
335
|
|
@@ -346,7 +346,7 @@ OPTIONS
|
|
346
346
|
-y, --yes Skip all prompts and initialize an empty project
|
347
347
|
```
|
348
348
|
|
349
|
-
_See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
349
|
+
_See code: [src\commands\test.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.26/src\commands\test.ts)_
|
350
350
|
|
351
351
|
## `learnpack translate`
|
352
352
|
|
@@ -360,7 +360,7 @@ OPTIONS
|
|
360
360
|
-y, --yes Skip all prompts and initialize an empty project
|
361
361
|
```
|
362
362
|
|
363
|
-
_See code: [src\commands\translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.
|
363
|
+
_See code: [src\commands\translate.ts](https://github.com/learnpack/learnpack-cli/blob/v5.0.26/src\commands\translate.ts)_
|
364
364
|
<!-- commandsstop -->
|
365
365
|
|
366
366
|
> > > > > > > 0cb3e56d84c197f9d008836bb573eade212b7e57
|
package/lib/managers/session.js
CHANGED
@@ -8,6 +8,9 @@ const fs = require("fs");
|
|
8
8
|
const cli_ux_1 = require("cli-ux");
|
9
9
|
const storage = require("node-persist");
|
10
10
|
const telemetry_1 = require("./telemetry");
|
11
|
+
const path = require("path");
|
12
|
+
const os = require("os");
|
13
|
+
const GLOBAL_SESSION_PATH = path.join(os.homedir(), ".learnpack-session");
|
11
14
|
const Session = {
|
12
15
|
sessionStarted: false,
|
13
16
|
token: null,
|
@@ -15,13 +18,11 @@ const Session = {
|
|
15
18
|
currentCohort: null,
|
16
19
|
initialize: async function () {
|
17
20
|
if (!this.sessionStarted) {
|
18
|
-
|
19
|
-
|
21
|
+
// Use a system-wide path instead of config.dirPath
|
22
|
+
if (!fs.existsSync(GLOBAL_SESSION_PATH)) {
|
23
|
+
fs.mkdirSync(GLOBAL_SESSION_PATH, { recursive: true });
|
20
24
|
}
|
21
|
-
|
22
|
-
fs.mkdirSync(this.config.dirPath);
|
23
|
-
}
|
24
|
-
await storage.init({ dir: `${this.config.dirPath}/.session` });
|
25
|
+
await storage.init({ dir: GLOBAL_SESSION_PATH });
|
25
26
|
this.sessionStarted = true;
|
26
27
|
}
|
27
28
|
return true;
|
package/oclif.manifest.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":"5.0.
|
1
|
+
{"version":"5.0.26","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":{"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.26",
|
5
5
|
"author": "Alejandro Sanchez @alesanchezr",
|
6
6
|
"contributors": [
|
7
7
|
{
|
@@ -5,7 +5,6 @@ import * as prompts from "prompts"
|
|
5
5
|
import { translateExercise } from "../utils/rigoActions"
|
6
6
|
import SessionManager from "../managers/session"
|
7
7
|
import Console from "../utils/console"
|
8
|
-
import { log } from "node-persist"
|
9
8
|
|
10
9
|
// This function list the names of the exercise directories inside the ./exercises folder, if the exercises folder doesn't exist, it will look for the ./.learn/exercises folder
|
11
10
|
const listExercises = async () => {
|
package/src/managers/session.ts
CHANGED
@@ -11,6 +11,10 @@ import * as storage from "node-persist"
|
|
11
11
|
import { IPayload, ISession, IStartProps } from "../models/session"
|
12
12
|
import { IConfigObj } from "../models/config"
|
13
13
|
import TelemetryManager from "./telemetry"
|
14
|
+
import * as path from "path"
|
15
|
+
import * as os from "os"
|
16
|
+
|
17
|
+
const GLOBAL_SESSION_PATH = path.join(os.homedir(), ".learnpack-session")
|
14
18
|
|
15
19
|
const Session: ISession = {
|
16
20
|
sessionStarted: false,
|
@@ -19,15 +23,12 @@ const Session: ISession = {
|
|
19
23
|
currentCohort: null,
|
20
24
|
initialize: async function () {
|
21
25
|
if (!this.sessionStarted) {
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
if (!fs.existsSync(this.config.dirPath)) {
|
27
|
-
fs.mkdirSync(this.config.dirPath)
|
26
|
+
// Use a system-wide path instead of config.dirPath
|
27
|
+
if (!fs.existsSync(GLOBAL_SESSION_PATH)) {
|
28
|
+
fs.mkdirSync(GLOBAL_SESSION_PATH, { recursive: true })
|
28
29
|
}
|
29
30
|
|
30
|
-
await storage.init({ dir:
|
31
|
+
await storage.init({ dir: GLOBAL_SESSION_PATH })
|
31
32
|
this.sessionStarted = true
|
32
33
|
}
|
33
34
|
|
@@ -2,13 +2,21 @@ const fs = require("fs")
|
|
2
2
|
const path = require("path")
|
3
3
|
const readline = require("readline")
|
4
4
|
|
5
|
+
// Get command-line arguments
|
6
|
+
const args = process.argv.slice(2)
|
7
|
+
const partIndex = args.findIndex(arg => arg === "-p" || arg === "--part")
|
8
|
+
const part =
|
9
|
+
partIndex !== -1 && args[partIndex + 1] ?
|
10
|
+
args[partIndex + 1].toLowerCase() :
|
11
|
+
null
|
12
|
+
|
5
13
|
const packagePath = path.resolve(process.cwd(), "package.json")
|
6
14
|
|
7
15
|
try {
|
8
|
-
//
|
16
|
+
// Read package.json file
|
9
17
|
const packageJson = JSON.parse(fs.readFileSync(packagePath, "utf8"))
|
10
18
|
|
11
|
-
//
|
19
|
+
// Check if "version" field exists
|
12
20
|
if (!packageJson.version) {
|
13
21
|
throw new Error(
|
14
22
|
'El archivo package.json no contiene una propiedad "version".'
|
@@ -17,48 +25,49 @@ try {
|
|
17
25
|
|
18
26
|
const [major, minor, patch] = packageJson.version.split(".").map(Number)
|
19
27
|
|
20
|
-
//
|
21
|
-
const
|
22
|
-
|
23
|
-
|
24
|
-
|
28
|
+
// Function to update version
|
29
|
+
const updateVersion = part => {
|
30
|
+
let newVersion
|
31
|
+
switch (part) {
|
32
|
+
case "major":
|
33
|
+
newVersion = `${major + 1}.0.0`
|
34
|
+
break
|
35
|
+
case "minor":
|
36
|
+
newVersion = `${major}.${minor + 1}.0`
|
37
|
+
break
|
38
|
+
case "patch":
|
39
|
+
newVersion = `${major}.${minor}.${patch + 1}`
|
40
|
+
break
|
41
|
+
default:
|
42
|
+
console.error("Opción no válida. Usa: major, minor o patch.")
|
43
|
+
process.exit(1)
|
44
|
+
}
|
25
45
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
answer => {
|
30
|
-
let newVersion
|
46
|
+
// Update package.json
|
47
|
+
packageJson.version = newVersion
|
48
|
+
fs.writeFileSync(packagePath, JSON.stringify(packageJson, null, 2), "utf8")
|
31
49
|
|
32
|
-
|
33
|
-
|
34
|
-
newVersion = `${major + 1}.0.0`
|
35
|
-
break
|
36
|
-
case "minor":
|
37
|
-
newVersion = `${major}.${minor + 1}.0`
|
38
|
-
break
|
39
|
-
case "patch":
|
40
|
-
newVersion = `${major}.${minor}.${patch + 1}`
|
41
|
-
break
|
42
|
-
default:
|
43
|
-
console.error("Opción no válida. Usa: major, minor o patch.")
|
44
|
-
rl.close()
|
45
|
-
process.exit(1)
|
46
|
-
}
|
50
|
+
console.log(`Versión actualizada: ${packageJson.version} -> ${newVersion}`)
|
51
|
+
}
|
47
52
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
53
|
+
if (part) {
|
54
|
+
// If flag is provided, update immediately
|
55
|
+
updateVersion(part)
|
56
|
+
} else {
|
57
|
+
// Otherwise, ask the user interactively
|
58
|
+
const rl = readline.createInterface({
|
59
|
+
input: process.stdin,
|
60
|
+
output: process.stdout,
|
61
|
+
})
|
55
62
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
63
|
+
rl.question(
|
64
|
+
"¿Qué parte de la versión deseas incrementar? (major, minor, patch): ",
|
65
|
+
answer => {
|
66
|
+
updateVersion(answer.toLowerCase())
|
67
|
+
rl.close()
|
68
|
+
}
|
69
|
+
)
|
70
|
+
}
|
62
71
|
} catch (error) {
|
63
72
|
console.error(`Error: ${error.message}`)
|
64
73
|
process.exit(1)
|