osaton / studio-helper Goto Github PK
View Code? Open in Web Editor NEWCrasman Studio API Helper
Crasman Studio API Helper
POST & GET:
/folderSettings/[folderId]
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.
POST & GET:
/folderSettings/[folderId]
JIRA-1254
For example .DS_Store
Use path.join(folder, file)
instead of folder + '/' + file
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.
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.