deepal / baapan Goto Github PK
View Code? Open in Web Editor NEW✨ Super Cool NPM Playground right on the Node REPL ✨
✨ Super Cool NPM Playground right on the Node REPL ✨
Allow users to directly disclose the vulnerabilities identified. For secure secure disclosure, introduce an email with PGP signed key and add it to README
Currently, only --experimental-repl-await
command line argument is supported. Baapan needs to support all command line arguments that is supported by node
CLI.
I am trying to set BAAPAN_WS_PATH
env variable to a previously created workspace of baapan but in env of baapan I see new workspace path everytime I run baapan. How can I persist the workspace?
Cannot install winston
on REPL and it throws the following error.
Creating workspace...
Initializing workspace...
Workspace loaded!
> const winston = require('winston')
Thrown:
{ Error: Cannot find module '/Users/djayasekara/.baapan/workspace/node_modules/readable-stream/writable'
at require (internal/modules/cjs/helpers.js:25:18)
at Module._module.Module.require (/Users/djayasekara/MyProjects/baapan/index.js:128:12)
at Module.require (internal/modules/cjs/loader.js:690:17)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) code: 'MODULE_NOT_FOUND' }
>
It appears that, when winston is installed on REPL, it installs the latest version of readable-stream 3.4.0
(as of this writing). But winston fails trying to require readable-stream/writable
module which is available in v2.4.1 of readable-stream.
VSCode extension should:
require()
require()
is removed?Top level await is not supported since v2.x.x as Baapan is now implemented using repl
module instead of a dynamically required module similar to node --require baapan
.
Due to this, using --experimental-repl-await
is not possible anymore in order to facilitate top level REPL await.
e.g. mytest.js
const lodash = require('lodash')
lodash.get({a: {b: 10}}, 'a.b')
Introduce the ability to run baapan
command similar to node
command in order to run JavaScript.
e.g,
baapan mytest.js
baapan
should automatically download any require
d dependencies and run the script.
This is currently possible by .load
repl command as follows:
$ baapan
Creating workspace...
Initializing workspace...
Workspace loaded!
> .load mytest.js
const lodash = require('lodash')
lodash.get({a: {b: 10}}, 'a.b')
Fetching and installing module 'lodash' from npm...
Done!
10
>
Readme is getting longer with new features, and becoming boring to read. Probably, it's time to add a ToC at the top of Readme.
Resolving local modules with relative paths has broken in Node v12.3.0 probably due to nodejs/node#27598
$ ls src/baapan.js
src/baapan.js
$ /Users/deepal/.nvm/versions/node/v12.3.0/bin/node --require @babel/register src/entrypoint.js
Switching to workspace /Users/deepal/.baapan/workspace_47039_1584287356022
Workspace loaded!
> require('./src/baapan.js')
Thrown:
Error: Cannot find module './src/baapan.js'
Require stack:
- /Users/deepal/Projects/baapan/src/baapan.js
- /Users/deepal/Projects/baapan/src/index.js
- /Users/deepal/Projects/baapan/src/entrypoint.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:623:15)
at Function.resolve (internal/modules/cjs/helpers.js:21:19)
at Module._module.Module.require (/Users/deepal/Projects/baapan/src/baapan.js:130:19)
at require (internal/modules/cjs/helpers.js:16:16) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/deepal/Projects/baapan/src/baapan.js',
'/Users/deepal/Projects/baapan/src/index.js',
'/Users/deepal/Projects/baapan/src/entrypoint.js'
]
}
>
Requiring with absolute path works fine
> require('/Users/deepal/Projects/baapan/src/baapan.js')
{ default: [Function: BaapanREPLServer] }
>
Change log for Node v12.3.0 https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V12.md#2019-05-21-version-1230-current-bridgear
Baapan on Windows platform is not tested. This needs to be verified
The standard baapan REPL require
resolves a required module path starting from the current directory's node_modules
directory all the way up to the parent directories (and some additional directories) until the module is located. This behaviour is identical to the original Node REPL.
If baapan
Sandbox mode is enabled, require
will not try to resolve a 3rd party module's path outside the working directory. If the module is not installed in the workspace, it should try to install it to the workspace. However, this behaviour should not affect local modules (relative/absolute paths) or native modules
Steps to reproduce:
chance
firstunderscore
secondunderscore
does not have an index.js
at the module root. Instead, the entry point is configured via main
attribute in package.json
> require('chance')
Fetching and installing module 'chance' from npm...
Done!
[Function: Chance] { Chance: [Circular] }
> require('underscore')
Fetching and installing module 'underscore' from npm...
Done!
Uncaught:
Error: Cannot find module '/Users/deepal/.baapan/workspace_90531_1584193257750/node_modules/underscore'
Require stack:
- <repl>
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
at Function.Module._load (internal/modules/cjs/loader.js:864:27)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at Module._module.Module.require (/Users/deepal/Projects/baapan/src/baapan.js:131:34)
at require (internal/modules/cjs/helpers.js:77:18) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '<repl>' ]
}
>
This happens if the require()
has been called once to install a module dynamically. Installation of the second module is successful, but it cannot be require
d and throws MODULE_NOT_FOUND
error.
This issue is due to nodejs/node#29492
After v2.x.x, baapan does not keep REPL history across sessions anymore. It is required to find a way to write history manually to `~/.node_repl_history
Reference: https://nodejs.org/api/repl.html#repl_persistent_history
baapan
requires to be run from the user's home directory. If the user starts baapan
on an npm project directory, all modules installed through baapan is installed in the project directory.
To fix this, the command should run on a dedicated directory (e.g, $HOME/.baapan
). This will make the module installable via npm i -g
or yarn global add
getting error with
'rm' is not recognized as an internal or external command, operable program or batch file.
We need a way to support 3rd party/Private NPM registries where the user should be able to set the NPM registry via an environment variable.
Can use NPM flag --registry
in order to pass the registry on the fly when installing an NPM module.
The fallback registry should be https://registry.npmjs.org
Baapan needs to be rewritten for v4.0.0 using typescript
The following error is thrown during installing a module when the module is not found in NPM. This error message is vague and does not indicate the specific error. This needs to be improved.
Creating workspace...
Initializing workspace...
Workspace loaded!
> require('ERTGB23456789sdf_')
Fetching and installing module 'ERTGB23456789sdf_' from npm...
Thrown:
{ Error: Command failed: npm install --silent ERTGB23456789sdf_
at require (internal/modules/cjs/helpers.js:25:18)
at Module.installModule [as require] (/Users/djayasekara/MyProjects/baapan/index.js:203:7)
at installModule (/Users/djayasekara/MyProjects/baapan/index.js:73:3)
at execSync (child_process.js:666:13)
at checkExecSyncError (child_process.js:629:11)
status: 1,
signal: null,
output: [ null, <Buffer >, <Buffer > ],
pid: 7825,
stdout: <Buffer >,
stderr: <Buffer > }
>
Currently, modules should be installed/require'ed using baapan
command as follows.
const lodash = await baapan('lodash');
Investigate the ability to replace this with a sane version as follows:
const lodash = require('lodash')
Baapan should intercept require
calls and if the module is not available, install it immediately and require.
Concerns:
require
an async function which returns a promise.Need to write unit tests
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.