Giter Club home page Giter Club logo

studio-helper's People

Contributors

dependabot[bot] avatar eeroniemi avatar elisa-crasman avatar juffe avatar osaton avatar

Watchers

 avatar  avatar  avatar

studio-helper's Issues

StudioHelper error handling

If a login attempt fails due to wrong username/password, Studio API may reply with a HTML page instead of JSON. This causes an error to be thrown:

SyntaxError: Unexpected token '<', "<!doctype "... is not valid JSON
     at JSON.parse (<anonymous>)
     at Request._callback (/Users/thykka/Crasman/studio-akeneo-webui-api/node_modules/studio-helper/StudioHelper.js:313:24)
     ...

The cause can be found within StudioHelper._post method (L313), where the response body is assumed to be JSON:

return new Promise(function(resolve, reject) {
  return request.post(options, function(error, response, body) {
    if (body && passAPIResponseHandling) {
      resolve(JSON.parse(body)); // <-
    }
    /* ... */
  }).form(postData)
}

There seems to be no way to avoid the error terminating the entire node process. For example:

const studio = new StudioHelper({ studio: STUDIO_URL, loginPromptEnabled: false });
try {
  await studio.login('wrong', 'credentials')
    .then((response: any) => {
      // This isn't executed at all, if the login throws an error
    }).catch((error: any) => {
      // This doesn't catch the error
    });
} catch(e) {
  // This doesn't catch the error either.
}

Studio API's login response should of course be JSON and not a HTML document. In the meanwhile we'd need to at least be able to catch such errors outside of the library.

Folders in .studio-ignore are still created in Studio

Original issue: osaton/gulp-studio-push#1

Local dist tree:

dist/
  |__templates/
        |__placeholders/
        |      |__img.jpg
        |__article.html

.studio-ignore file:

dist/templates

gulp task:

var studioSettings = {
  studio  : 'xxx',
  proxy   : yyy'',
  folders : [{
    folderId : '54cf2de1a93bea874fdf38ab', 
    localFolder : 'dist',
    includeSubFolders : true // Create and upload child folders too
  }]
};

gulp.task("push", function() {
  return gulp.src("dist")
             .pipe(studioPush(studioSettings));
});

templates folder and its subfolders are created in Studio, but no files inside templates or subfolders are transferred.

Expected result:

No templates folder created in Studio.

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.