Coder Social home page Coder Social logo

baapan's Introduction

baapan's People

Contributors

deepal avatar shahidcodes avatar vishmimoney avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

baapan's Issues

reusing the same workspace

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 due to a breaking change in readable-stream dependency

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.

Baapan VSCode Extension

VSCode extension should:

  • Automatically install modules as you type require()
  • (optional) Automatically uninstall the corresponding module when require() is removed?
  • The user should be able to enable/disable Baapan on the editor easily using the command palate command or a hotkey.
  • The status bar should display whether Baapan is enabled or not.

Support top level REPL await

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.

Ability to run scripts using baapan command

Proposed Feature

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 required dependencies and run the script.

Alternative suggestion

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
>

Add table of contents to readme

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.

Node >= v12.3.0 Cannot require module with relative path

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

Sandbox Mode to instruct baapan not to 'require' modules outside workspace directory

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

Setup CI pipeline

  • Automate linting
  • Automate unit tests
  • Automate build
  • Publish to NPM automatically

Node >= v12.16.0 Cannot install a module without an index.js at root after require() has been called once

Steps to reproduce:

  • Install chance first
  • Install underscore second

underscore 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 required and throws MODULE_NOT_FOUND error.

This issue is specific to Node v12.16.0 and above.

This issue is due to nodejs/node#29492

Package installation is not isolated

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

rm not found on windows

getting error with
'rm' is not recognized as an internal or external command, operable program or batch file.

Support for 3rd party NPM registries

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

User friendly error message when the module installation fails

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 > }
>  

Replace `baapan` function with `require` which makes more sense

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:

  • This should make require an async function which returns a promise.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.