New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

learnpack

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

learnpack - npm Package Compare versions

Comparing version
0.1.26
to
0.1.27
+1
-1
oclif.manifest.json

@@ -1,1 +0,1 @@

{"version":"0.1.26","commands":{"audit":{"id":"audit","description":"Check if the configuration object has slug, description and repository property\n...\nExtra documentation goes here\n","pluginName":"learnpack","pluginType":"core","aliases":[],"flags":{},"args":[]},"clean":{"id":"clean","description":"Clean the configuration object\n...\nExtra documentation goes here\n","pluginName":"learnpack","pluginType":"core","aliases":[],"flags":{},"args":[]},"download":{"id":"download","description":"Describe the command here\n...\nExtra documentation goes here\n","pluginName":"learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"hello":{"id":"hello","description":"Describe the command here\n...\nExtra documentation goes here\n","pluginName":"learnpack","pluginType":"core","aliases":[],"flags":{"name":{"name":"name","type":"option","char":"n","description":"name to print"}},"args":[]},"init":{"id":"init","description":"Create a new learning package: Book, Tutorial or Exercise","pluginName":"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...\nExtra documentation goes here\n","pluginName":"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...\nExtra documentation goes here\n","pluginName":"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":"Describe the command here\n...\nExtra documentation goes here\n","pluginName":"learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"start":{"id":"start","description":"Runs a small server with all the exercise instructions","pluginName":"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":"dg","description":"disble grading functionality","allowNo":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Watch for file changes","allowNo":false},"mode":{"name":"mode","type":"option","char":"m","description":"Load a standalone editor or just the preview to be embeded in another editor: Choices: [standalone, preview]","options":["standalone","preview"]},"version":{"name":"version","type":"option","char":"v","description":"E.g: 1.0.1","default":null},"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","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"exerciseSlug","description":"The name of the exercise to test","required":false,"hidden":false}]}}}
{"version":"0.1.27","commands":{"audit":{"id":"audit","description":"Check if the configuration object has slug, description and repository property\n...\nExtra documentation goes here\n","pluginName":"learnpack","pluginType":"core","aliases":[],"flags":{},"args":[]},"clean":{"id":"clean","description":"Clean the configuration object\n...\nExtra documentation goes here\n","pluginName":"learnpack","pluginType":"core","aliases":[],"flags":{},"args":[]},"download":{"id":"download","description":"Describe the command here\n...\nExtra documentation goes here\n","pluginName":"learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"hello":{"id":"hello","description":"Describe the command here\n...\nExtra documentation goes here\n","pluginName":"learnpack","pluginType":"core","aliases":[],"flags":{"name":{"name":"name","type":"option","char":"n","description":"name to print"}},"args":[]},"init":{"id":"init","description":"Create a new learning package: Book, Tutorial or Exercise","pluginName":"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...\nExtra documentation goes here\n","pluginName":"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...\nExtra documentation goes here\n","pluginName":"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":"Describe the command here\n...\nExtra documentation goes here\n","pluginName":"learnpack","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"package","description":"The unique string that identifies this package on learnpack","required":false,"hidden":false}]},"start":{"id":"start","description":"Runs a small server with all the exercise instructions","pluginName":"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":"dg","description":"disble grading functionality","allowNo":false},"watch":{"name":"watch","type":"boolean","char":"w","description":"Watch for file changes","allowNo":false},"mode":{"name":"mode","type":"option","char":"m","description":"Load a standalone editor or just the preview to be embeded in another editor: Choices: [standalone, preview]","options":["standalone","preview"]},"version":{"name":"version","type":"option","char":"v","description":"E.g: 1.0.1","default":null},"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","pluginType":"core","aliases":[],"flags":{},"args":[{"name":"exerciseSlug","description":"The name of the exercise to test","required":false,"hidden":false}]}}}
{
"name": "learnpack",
"description": "Seamlessly build or take interactive & auto-graded tutorials, start learning now or build a tutorial.",
"version": "0.1.26",
"version": "0.1.27",
"author": "Alejandro Sanchez @alesanchezr",

@@ -6,0 +6,0 @@ "bin": {

@@ -1,2 +0,5 @@

const shell = require('shelljs')
const shell = require('shelljs');
const { CompilationError } = require("./command/compile")
const { TestingError } = require("./command/test")
/**

@@ -9,64 +12,73 @@ * Main Plugin Runner, it defines the behavior of a learnpack plugin

return async (args) => {
const { action, exercise, socket, configuration } = args
const { action, exercise, socket, configuration, telemetry } = args
if(pluginConfig.language === undefined) throw Error(`Missing language on the plugin configuration object`)
if(typeof action !== "string"){
if (pluginConfig.language === undefined) throw Error(`Missing language on the plugin configuration object`)
if (typeof action !== "string") {
throw Error("Missing action property on hook details")
}
if(!exercise || exercise === undefined){
}
if (!exercise || exercise === undefined) {
throw Error("Missing exercise information")
}
// if the action does not exist I don't do anything
if(pluginConfig[action] === undefined){
if (pluginConfig[action] === undefined) {
console.log(`Ignoring ${action}`)
return () => null
}
}
// ignore if the plugin language its not the same as the exercise language
if(exercise.language !== pluginConfig.language){
if (exercise.language !== pluginConfig.language) {
return () => null
}
if( !exercise.files || exercise.files.length == 0){
if (!exercise.files || exercise.files.length == 0) {
throw Error(`No files to process`)
}
try{
const _action = pluginConfig[action]
}
if(_action == null || typeof _action != 'object') throw Error(`The ${pluginConfig.language} ${action} module must export an object configuration`)
if(_action.validate === undefined) throw Error(`Missing validate method for ${pluginConfig.language} ${action}`)
if(_action.run === undefined) throw Error(`Missing run method for ${pluginConfig.language} ${action}`)
if(_action.dependencies !== undefined){
if(!Array.isArray(_action.dependencies)) throw Error(`${action}.dependencies must be an array of package names`)
_action.dependencies.forEach(packageName => {
if (!shell.which(packageName)) {
throw Error(`🚫 You need to have ${packageName} installed to run test the exercises`);
}
})
try {
const _action = pluginConfig[action]
if (_action == null || typeof _action != 'object') throw Error(`The ${pluginConfig.language} ${action} module must export an object configuration`)
if (_action.validate === undefined) throw Error(`Missing validate method for ${pluginConfig.language} ${action}`)
if (_action.run === undefined) throw Error(`Missing run method for ${pluginConfig.language} ${action}`)
if (_action.dependencies !== undefined) {
if (!Array.isArray(_action.dependencies)) throw Error(`${action}.dependencies must be an array of package names`)
_action.dependencies.forEach(packageName => {
if (!shell.which(packageName)) {
throw Error(`🚫 You need to have ${packageName} installed to run test the exercises`);
}
})
}
const valid = await _action.validate(({ exercise, configuration }))
if(valid){
// look for the command standard implementation and execute it
const execute = require("./command/"+action+".js").default
// no matter the command, the response must always be a stdout
const stdout = await execute({ ...args, action: _action, configuration })
const valid = await _action.validate(({ exercise, configuration }))
if (valid) {
// look for the command standard implementation and execute it
const execute = require("./command/" + action + ".js").default
// no matter the command, the response must always be a result object
// Map the action names to socket messaging standards
const actionToSuccessMapper = { compile: 'compiler', test: 'testing' }
const result = await execute({ ...args, action: _action, configuration })
socket.success(actionToSuccessMapper[action], stdout)
return stdout
}
// Telemetry parses the stdout, stderr and source_code to b64
// so we need to make a copy yo avoid modifying the original object
const resultCopy = JSON.parse(JSON.stringify(result))
const actionToEventMapper = { compile: 'compile', test: 'test' }
telemetry.registerStepEvent(exercise.position, actionToEventMapper[action], resultCopy);
if (result.exitCode > 0 && action === "compile") throw CompilationError(result.stderr);
if (result.exitCode > 0 && action === "test") throw TestingError(result.stderr);
// Map the action names to socket messaging standards
const actionToSuccessMapper = { compile: 'compiler', test: 'testing' }
socket.success(actionToSuccessMapper[action], result.stdout)
return result.stdout
}
catch(error){
if(error.type == undefined) socket.fatal(error)
else socket.error(error.type, error.stdout)
}
}
}
catch (error) {
if (error.type == undefined) socket.fatal(error)
else socket.error(error.type, error.stdout)
}
}
}
+354
-2

@@ -1,3 +0,355 @@

We have moved this package to:
learnpack
=========
https://www.npmjs.com/package/@learnpack/learnpack
Create, sell or download and take learning amazing learning packages
[![oclif](https://img.shields.io/badge/cli-oclif-brightgreen.svg)](https://oclif.io)
[![Version](https://img.shields.io/npm/v/learnpack.svg)](https://npmjs.org/package/learnpack)
[![Downloads/week](https://img.shields.io/npm/dw/learnpack.svg)](https://npmjs.org/package/learnpack)
[![License](https://img.shields.io/npm/l/learnpack.svg)](https://github.com/learnpack/learnpack-cli/blob/master/package.json)
<!-- toc -->
* [Usage](#usage)
* [Commands](#commands)
<!-- tocstop -->
# Usage
<!-- usage -->
```sh-session
$ npm install -g learnpack
$ learnpack COMMAND
running command...
$ learnpack (-v|--version|version)
learnpack/0.1.27 darwin-arm64 node-v16.20.0
$ learnpack --help [COMMAND]
USAGE
$ learnpack COMMAND
...
```
<!-- usagestop -->
# Commands
<!-- commands -->
* [`learnpack audit`](#learnpack-audit)
* [`learnpack clean`](#learnpack-clean)
* [`learnpack download [PACKAGE]`](#learnpack-download-package)
* [`learnpack hello`](#learnpack-hello)
* [`learnpack help [COMMAND]`](#learnpack-help-command)
* [`learnpack init`](#learnpack-init)
* [`learnpack login [PACKAGE]`](#learnpack-login-package)
* [`learnpack logout [PACKAGE]`](#learnpack-logout-package)
* [`learnpack plugins`](#learnpack-plugins)
* [`learnpack plugins:install PLUGIN...`](#learnpack-pluginsinstall-plugin)
* [`learnpack plugins:link PLUGIN`](#learnpack-pluginslink-plugin)
* [`learnpack plugins:uninstall PLUGIN...`](#learnpack-pluginsuninstall-plugin)
* [`learnpack plugins:update`](#learnpack-pluginsupdate)
* [`learnpack publish [PACKAGE]`](#learnpack-publish-package)
* [`learnpack start`](#learnpack-start)
* [`learnpack test [EXERCISESLUG]`](#learnpack-test-exerciseslug)
## `learnpack audit`
Check if the configuration object has slug, description and repository property
```
USAGE
$ learnpack audit
DESCRIPTION
...
Extra documentation goes here
```
_See code: [src/commands/audit.js](https://github.com/learnpack/learnpack-cli/blob/v0.1.27/src/commands/audit.js)_
## `learnpack clean`
Clean the configuration object
```
USAGE
$ learnpack clean
DESCRIPTION
...
Extra documentation goes here
```
_See code: [src/commands/clean.js](https://github.com/learnpack/learnpack-cli/blob/v0.1.27/src/commands/clean.js)_
## `learnpack download [PACKAGE]`
Describe the command here
```
USAGE
$ learnpack download [PACKAGE]
ARGUMENTS
PACKAGE The unique string that identifies this package on learnpack
DESCRIPTION
...
Extra documentation goes here
```
_See code: [src/commands/download.js](https://github.com/learnpack/learnpack-cli/blob/v0.1.27/src/commands/download.js)_
## `learnpack hello`
Describe the command here
```
USAGE
$ learnpack hello
OPTIONS
-n, --name=name name to print
DESCRIPTION
...
Extra documentation goes here
```
_See code: [src/commands/hello.js](https://github.com/learnpack/learnpack-cli/blob/v0.1.27/src/commands/hello.js)_
## `learnpack help [COMMAND]`
display help for learnpack
```
USAGE
$ learnpack help [COMMAND]
ARGUMENTS
COMMAND command to show help for
OPTIONS
--all see all commands in CLI
```
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v3.1.0/src/commands/help.ts)_
## `learnpack init`
Create a new learning package: Book, Tutorial or Exercise
```
USAGE
$ learnpack init
OPTIONS
-h, --grading show CLI help
```
_See code: [src/commands/init.js](https://github.com/learnpack/learnpack-cli/blob/v0.1.27/src/commands/init.js)_
## `learnpack login [PACKAGE]`
Describe the command here
```
USAGE
$ learnpack login [PACKAGE]
ARGUMENTS
PACKAGE The unique string that identifies this package on learnpack
DESCRIPTION
...
Extra documentation goes here
```
_See code: [src/commands/login.js](https://github.com/learnpack/learnpack-cli/blob/v0.1.27/src/commands/login.js)_
## `learnpack logout [PACKAGE]`
Describe the command here
```
USAGE
$ learnpack logout [PACKAGE]
ARGUMENTS
PACKAGE The unique string that identifies this package on learnpack
DESCRIPTION
...
Extra documentation goes here
```
_See code: [src/commands/logout.js](https://github.com/learnpack/learnpack-cli/blob/v0.1.27/src/commands/logout.js)_
## `learnpack plugins`
list installed plugins
```
USAGE
$ learnpack plugins
OPTIONS
--core show core plugins
EXAMPLE
$ learnpack plugins
```
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v1.8.0/src/commands/plugins/index.ts)_
## `learnpack plugins:install PLUGIN...`
installs a plugin into the CLI
```
USAGE
$ learnpack plugins:install PLUGIN...
ARGUMENTS
PLUGIN plugin to install
OPTIONS
-f, --force yarn install with force flag
-h, --help show CLI help
-v, --verbose
DESCRIPTION
Can be installed from npm or a git url.
Installation of a user-installed plugin will override a core plugin.
e.g. If you have a core plugin that has a 'hello' command, installing a user-installed plugin with a 'hello' command
will override the core plugin implementation. This is useful if a user needs to update core plugin functionality in
the CLI without the need to patch and update the whole CLI.
ALIASES
$ learnpack plugins:add
EXAMPLES
$ learnpack plugins:install myplugin
$ learnpack plugins:install https://github.com/someuser/someplugin
$ learnpack plugins:install someuser/someplugin
```
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v1.8.0/src/commands/plugins/install.ts)_
## `learnpack plugins:link PLUGIN`
links a plugin into the CLI for development
```
USAGE
$ learnpack plugins:link PLUGIN
ARGUMENTS
PATH [default: .] path to plugin
OPTIONS
-h, --help show CLI help
-v, --verbose
DESCRIPTION
Installation of a linked plugin will override a user-installed or core plugin.
e.g. If you have a user-installed or core plugin that has a 'hello' command, installing a linked plugin with a 'hello'
command will override the user-installed or core plugin implementation. This is useful for development work.
EXAMPLE
$ learnpack plugins:link myplugin
```
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v1.8.0/src/commands/plugins/link.ts)_
## `learnpack plugins:uninstall PLUGIN...`
removes a plugin from the CLI
```
USAGE
$ learnpack plugins:uninstall PLUGIN...
ARGUMENTS
PLUGIN plugin to uninstall
OPTIONS
-h, --help show CLI help
-v, --verbose
ALIASES
$ learnpack plugins:unlink
$ learnpack plugins:remove
```
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v1.8.0/src/commands/plugins/uninstall.ts)_
## `learnpack plugins:update`
update installed plugins
```
USAGE
$ learnpack plugins:update
OPTIONS
-h, --help show CLI help
-v, --verbose
```
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v1.8.0/src/commands/plugins/update.ts)_
## `learnpack publish [PACKAGE]`
Describe the command here
```
USAGE
$ learnpack publish [PACKAGE]
ARGUMENTS
PACKAGE The unique string that identifies this package on learnpack
DESCRIPTION
...
Extra documentation goes here
```
_See code: [src/commands/publish.js](https://github.com/learnpack/learnpack-cli/blob/v0.1.27/src/commands/publish.js)_
## `learnpack start`
Runs a small server with all the exercise instructions
```
USAGE
$ learnpack start
OPTIONS
-d, --debug debugger mode for more verbage
-d, --disableGrading disble grading functionality
-g, --grading=isolated|incremental [isolated, incremental]
-h, --host=host server host
-m, --mode=standalone|preview Load a standalone editor or just the preview to be embeded in another editor:
Choices: [standalone, preview]
-p, --port=port server port
-v, --version=version E.g: 1.0.1
-w, --watch Watch for file changes
```
_See code: [src/commands/start.js](https://github.com/learnpack/learnpack-cli/blob/v0.1.27/src/commands/start.js)_
## `learnpack test [EXERCISESLUG]`
Test exercises
```
USAGE
$ learnpack test [EXERCISESLUG]
ARGUMENTS
EXERCISESLUG The name of the exercise to test
```
_See code: [src/commands/test.js](https://github.com/learnpack/learnpack-cli/blob/v0.1.27/src/commands/test.js)_
<!-- commandsstop -->

@@ -6,3 +6,3 @@ const fs = require('fs')

const Console = require('../utils/console')
const { isUrl, findInFile, checkForEmptySpaces, showErrors, showWarnings } = require('../utils/audit')
const { isUrl, findInFile, checkLearnpackClean, checkForEmptySpaces, showErrors, showWarnings } = require('../utils/audit')
const SessionCommand = require('../utils/SessionCommand');

@@ -19,11 +19,8 @@ const fm = require("front-matter")

const { flags } = this.parse(AuditCommand)
Console.log("Running command audit...")
// Build exercises if they are not built yet.
if (!this.configManager.get().exercises) this.configManager.buildIndex()
// Get configuration object.
const config = this.configManager.get();
let errors = []

@@ -43,3 +40,9 @@ let warnings = []

}
// Checks if learnpack clean has been run
checkLearnpackClean(config, errors)
// Build exercises if they are not built yet.
if (!this.configManager.get().exercises) this.configManager.buildIndex()
// Check if the exercises folder has some files within any ./exercise

@@ -123,3 +126,3 @@ const exercisesPath = config.config.exercisesPath

let res = await fetch(obj[link].mdUrl, { method: "HEAD" });
if (!res.ok) {
if (res.status > 399 && res.status < 200) {
counter.links.error++;

@@ -244,2 +247,2 @@ errors.push({ exercise: exercise.title, msg: `This link is broken: ${obj[link].mdUrl}` })

module.exports = AuditCommand
module.exports = AuditCommand
const Console = require('./console')
const fetch = require('node-fetch')
const fs = require('fs')
module.exports = {

@@ -32,2 +32,7 @@ // This function checks if a url is valid.

},
checkLearnpackClean: (configObj, errors) => {
if(fs.existsSync(configObj.config.outputPath) || fs.existsSync(configObj.config.dirPath + "/_app") || fs.existsSync(configObj.config.dirPath + "/reports") || fs.existsSync(configObj.config.dirPath + "/resets") || fs.existsSync(configObj.config.dirPath + "/app.tar.gz") || fs.existsSync(configObj.config.dirPath + "/config.json") || fs.existsSync(configObj.config.dirPath + "/vscode_queue.json")) {
errors.push({ exercise: null, msg: `You have to run learnpack clean command` })
}
},
findInFile: (types, content) => {

@@ -34,0 +39,0 @@ const regex = {