GithubHelp home page GithubHelp logo

monaca / monaca-lib Goto Github PK

View Code? Open in Web Editor NEW
13.0 13.0 11.0 25.42 MB

npm package for handling Monaca cloud API and local debugging API

Home Page: http://monaca.io

License: Other

JavaScript 99.23% Shell 0.77%
cordova hybrid javascript monaca monaca-api monaca-cloud-api monaca-lib

monaca-lib's People

Contributors

adamkozuch avatar andipavllo avatar argelius avatar as-hirose avatar asial-matagawa avatar asialatsushi avatar asialmakki avatar dependabot[bot] avatar erisu avatar frandiox avatar jw-vinayak avatar knaito-asial avatar knight9999 avatar masahirotanaka avatar msakamaki avatar takuyaw avatar yong-asial avatar

Stargazers

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

Watchers

 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

monaca-lib's Issues

Support TypeScript 2.x.

@andipavllo @frankdiox

Reported by @anatoo.
Since 1.0.0-rc2, angular2-onsenui requires TypeScript 2.x but current monaca-lib is using TypeScript 1.8.10 as a build dependency.
So monaca-lib needs to update typescript in package.json from 1.8.10 to 2.0.10 (latest).

But I am not sure that it is enough, so could you update typescript in right way?

Note:

  • Current Angular 2 monaca-templates are also incompatible with TypeScript 2.x.
    We have to fix Angular 2 monaca-templates before updating monaca-lib.

'monaca livesync' fails often

The first time I execute the command 'monaca livesync', it will fail quite often.
I have no CLI error message, but the monacan debugger does not respond.
The second time the command work correctly.

Importing images in public dir

In Angular 2 templates, if I add an <img> with a relative path like this:

<img src="image.png">

I get the following error:

Module not found: Error: Cannot resolve 'file' or 'directory' ./image.png

I am forced to use absolute paths but in that case the app will only work when deployed in the root.

Create monaca_config.json if it does not exist.

When clean installing monaca-cli and configure a proxy server, it will return an error like the one below.

# monaca proxy set http://localhost:1080      
Unable to set proxy server: Error: ENOENT, open '/root/.cordova/monaca_config.json'

Can you please create the configuration file if it is not found?

Filter files when running getLocalProjectFiles()

If the project has very large amount of files, it will cause trouble when getting file tree from the debugger. When calling this.monaca.getLocalProjectFiles() from Localkit.getProjectFiles(), it is actually filtering to get files in the "/www" directory, and ignoring all dot-files.

However, Monaca.getLocalProjectFiles() first get all files in the specified directory and calculating CRC32 hash for each found files, before filtering out the unnecessary files.

Therefore, please fix the logic and only calculate the hash files that are necessary to use.

Pass client_info to Login API

Please pass client_info parameter as follows:

  • version: Passed from monaca-cli or Localkit. Should be something like: monaca-cli 1.0.2. Must be passed by the caller of the JavaScript API.
  • os: Operating system that monaca-lib is running on.

README files

I think the templates should generate a README.md file with information about how it was created and how to install Monaca CLI and how to run the app.

missing script build when upload

I do these steps:

  1. monaca login
  2. monaca clone
  3. change a file
  4. monaca upload

here is the terminal output:

? Do you want to continue? (y/N) y
? Do you want to continue? Yes
Running Transpiler...


> com.######[email protected] monaca:transpile
> npm run build

npm ERR! Missing script: "build"
npm ERR!
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

what should to do to solve?

Create full test spec

Please create and complete the test spec for monaca-lib.
There are many features that are added after our last change to the test spec.
Can you please add new tests and complete all test cases?

Usage?

Can I use this for the backend api? If so, how ? I'm using the vue template for onsen ui, but I keep getting errors everywhere when I'm importing this.

Sorry if this sounds like a silly question, I searched everywhere and still couldn't find an answer...

Any plans to upgrade vulnerable dependencies?

Hi there,

Do you have any plan to merge the following PRs in a near future: #162, #160, #157 and #156
The adbkit dependency shold also be changed to use @devicefarmer/adbkit since OpenSTF no longer maintains this project (openstf/adbkit#132). And bumping adbkit to @devicefarmer/adbkit 3.2.3 would also fix a bunch of node-forge vulnerabilities (GHSA-x4jg-mjrx-434g, GHSA-cfm4-qjh2-4765, GHSA-92xj-mqp7-vmcj, GHSA-2r2c-g63r-vccr, GHSA-8fr3-hfg3-gpgp, GHSA-5rrq-pxf6-6jx5, GHSA-wxgw-qj99-44c2 and GHSA-gf8q-jrpm-jvxq).

Or maybe monaca-lib isn't affected by these vulnerabilities?

Thank you

No longer able to login

With this latest release of the cli (2.5.0), the lib no longer allows logging in.

We have the following gulp task setup (and have tried adding a logout function 1st to clear whatever is in the mem)

gulp.task('monaca-login', (done) => {
     monaca.login(monacaEmail, monacaPassword).then(
        () => {
            done();
        },
        (error) => {
            console.log('monaca-login', error);
            if (error) throw error;
        }
    );
});

this results in the following issue

monaca-login { status: 'fail',
code: 400,
message: 'Your client is old version. Please upgrade to the latest version.' }

isTranspilable vue.js ?

Hey there!

I'm new to Monaca, loving it so far. I am trying to use Monaca with vue-loader/webpack?

I started off with the "no framework, Blank Template", and thought I could use monaca transpile to build .vue files.

Seems like monaca transpile only supports react & angular2 ?

What's the best way to integrate vue-loader with Monaca hybrid apps?

Thanks!

iOS build trigger fails if new project is created from monaca-lib

We are trying to perform Monaca tasks programmatically to automate the app build process. Please note that everything works fine from the Monaca IDE using a browser, however, the last step which is related to triggering the build fails when we do things programmatically.

Below is the process that we are following:

  1. Create a blank Monaca project.
  2. Clone it on the local machine.
  3. Migrate code to the cloned project.
  4. Upload project from the local machine.
  5. Trigger remote build.

We can successfully perform the first four (4) steps using your NPM library programmatically but during the 5th step, we get the following build error:

Fetching Build Queue Data...
-> Fetched data for queue ID xxxxxxxxxxxxxx
Preparing Build Environment...
Creating Project Build Workspace...
Fetching Project Content...
Downloading Project Archive...
Extracting Project Archive...
Fetching Project Info...
Build Error: Error: Failed to fetch project info with error : Error: project_info.json not found.

We have noticed that if before the 5th step we trigger the build from the Monaca IDE using a browser manually, then the 5th step is successful using the NPM libraries. However, we want to fully automate this process and we would like to find the fix for the build failure.

Folks at Monaca support believe that it is a monaca-lib issue.

Please find npm project src files with this comment.
src.zip

Files in .monacaignore aren't ignored on Reading Local Files step

Description

The getLocalProjectFiles method doesn't use the ignore patterns from the .monacaignore file when getting a listing of files in the project directory. This is a problem on projects with a large number of files in the node_modules folder because it will either take a very long time to get the file listing, or the JS heap will run out of memory.

This is the line that is causing the issue:
https://github.com/monaca/monaca-lib/blob/2.7.5/src/monaca.js#L1458

Version

v2.7.5 is where the issue first occurs.
The same issue does not seem to occur in v2.7.4 and earlier.

Steps to Reproduce

  1. Create a Cordova project with a large number of node module dependencies (~70 dependencies), and run npm install.
  2. Create the following script in the root of your project:
#!/usr/bin/env node

const Monaca = require('monaca-lib').Monaca;
const monaca = new Monaca({clientType: 'cli'});

monaca.login("[email protected]", "password")
    .then(() => monaca.setProjectId(process.cwd(), "project_id"))
    .then(() => monaca.uploadProject(process.cwd()))
    .catch((error) => console.log(error));
  1. Run the script: node ./script.js.

Expected behaviour

Successfully read the local files and then uploads the files to your Monaca project.

Actual behaviour

An Error is thrown:

Reading Local Files...
Reading Remote Files...

<--- Last few GCs --->

[27880:0x103000c00]    83925 ms: Mark-sweep 1400.4 (1511.0) -> 1400.4 (1480.0) MB, 2555.4 / 0.0 ms  (+ 0.0 ms in 0 steps since start of marking, biggest step 0.0 ms, walltime since start of marking 2555 ms) last resort
[27880:0x103000c00]    86320 ms: Mark-sweep 1400.4 (1480.0) -> 1400.4 (1480.0) MB, 2393.4 / 0.0 ms  last resort


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x1554ac228799 <JSObject>
    1: /* anonymous */(aka /* anonymous */) [PROJECT_PATH/node_modules/monaca-lib/node_modules/q/q.js:~1585] [pc=0xb56a773efb3](this=0x170969282311 <undefined>,undefined=0x170969282311<undefined>,promise=0x2d22d4abbf81 <Object map = 0x3cffc4b7ebc1>,index=17726)
    2: arguments adaptor frame: 4->3
    3: reduce(this=0x325b4d343c31 <JSArray[137441]>)
    5: /* an...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: node::Abort() [~/.nvm/versions/node/v8.6.0/bin/node]
 2: node::FatalException(v8::Isolate*, v8::Local<v8::Value>, v8::Local<v8::Message>) [~/.nvm/versions/node/v8.6.0/bin/node]
 3: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [~/.nvm/versions/node/v8.6.0/bin/node]
 4: v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [~/.nvm/versions/node/v8.6.0/bin/node]
 5: v8::internal::Runtime_AllocateInTargetSpace(int, v8::internal::Object**, v8::internal::Isolate*) [~/.nvm/versions/node/v8.6.0/bin/node]
 6: 0xb56a75846fd

Dependant on npm

Hi @JW-Vinayak

I saw it spawns npm in the replaceTemplate method. This will fail if npm is not installed since it's not trying to execute a local npm version.

Test in Node 5

Test and verify that it works in Node 5. If not, resolve all issues.

Install build dependencies fails in Windows.

npm ERR! gentlyRm C:\Users\Fran\.cordova\node_modules\.bin\tsc.cmd is outside C:\Users\Fran\.babun\cygwin\home\Fran\workspace\monaca-cli and not a link
npm ERR! gentlyRm C:\Users\Fran\.cordova\node_modules\.bin\tsserver.cmd is outside C:\Users\Fran\.babun\cygwin\home\Fran\workspace\monaca-cli and not a link

When trying to download a React template it also installs TypeScript and fails.

Ignore `src` attributes in Angular 2 template.

@andipavllo @erisu @frankdiox

Environment

Monaca CLI 2.1.7
monaca-lib 2.2.4

Encountered problem

The current webpack config for Angular 2 crashes with the following error when foo.html which is loaded by require('foo.html') contains an unresolvable path (in a src attribute of img element).

ERROR in ./src/app/app.html
Module not found: Error: Cannot resolve 'file' or 'directory' ./images/pokemon/icons/{{ p.id }}.png in /Users/asial/temp/angular2-onsenui-pokedex/src/app
 @ ./src/app/app.html 1:475-523

How to reproduce

First, run the commands below:

git clone https://github.com/argelius/angular2-onsenui-pokedex.git --no-checkout
cd angular2-onsenui-pokedex
git checkout 2e4210bffa21bd0daaddc76028b3c0082601b0ff

Next, make this change in src/app/app.html:

<img class="sprite" src="/images/pokemon/sprites/{{ pokemon.id }}.png">
<img class="sprite" src="./images/pokemon/sprites/{{ pokemon.id }}.png">

(This is required for running this app in Cordova environment. Otherwise, we would get the following error.)

Then, run the commands below:

npm install
monaca transpile # cause the error

FYI:
If we use template: (content of app.html) instead of template: require('./app.html'), it worked fine on Cordova environment:

But I think this is not a straightforward solution.

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.