Giter VIP home page Giter VIP logo

koji-tools's People

Contributors

arist0tl3 avatar jonesnxt avatar mirismaili avatar rgruesbeck avatar sthielen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

koji-tools's Issues

Bug in wrapConsole.js: `window.parent` is always truthy

log: (...args) => {
window.__originalConsole.log.apply(this, args);
if (window.parent) {
try {
window.parent.postMessage({

From if (window.parent) seems the author wanted to sure the app (web page) is running in a container (not in the browser directly). If so, this is not the correct way. According to MDN:

If a window does not have a parent, its parent property is a reference to itself.

This means window.parent is always truthy whether the window has a parent or not. So the if statement filters nothing!

We can implement the same purpose as follows:

if (window.parent !== window)

koji-tools ignores nested git repositories (git submodules)

In a root-level repository with one or more descendant submodules, like this:

> git submodule status

 22080c4f11209c089b948c3a23c3513b7da85a9c browser (v0.2.0-4-g22080c4)
 2b853655204e50a0f4c37a8b932647d4c04b8214 server (v0.2.7-3-g2b85365)

the result of koji-tools watch is something like below:

> koji-tools watch

koji-tools watching
new config
Watching /PROJECT/ROOT/DIRECTORY/.koji/customization/about_customization.md
Watching /PROJECT/ROOT/DIRECTORY/.koji/customization/metadata.json
Watching /PROJECT/ROOT/DIRECTORY/.koji/customization/texts.json
Watching /PROJECT/ROOT/DIRECTORY/.koji/customization/theme.json
Watching /PROJECT/ROOT/DIRECTORY/.koji/hooks/about_hooks.md
Watching /PROJECT/ROOT/DIRECTORY/.koji/hooks/post-clone.sh
Watching /PROJECT/ROOT/DIRECTORY/.koji/project/about_project.md
Watching /PROJECT/ROOT/DIRECTORY/.koji/project/deploy.json
Watching /PROJECT/ROOT/DIRECTORY/.koji/project/develop.json
Watching /PROJECT/ROOT/DIRECTORY/.koji/scripts/buildConfig.js
Watching /PROJECT/ROOT/DIRECTORY/.koji/scripts/buildManifest.js

While there is two .koji folders in above two submodules (browser and server).


  • Expected behavior:

     > koji-tools watch
    
     koji-tools watching
     new config
     Watching /PROJECT/ROOT/DIRECTORY/.koji\customization\about_customization.md
     Watching /PROJECT/ROOT/DIRECTORY/.koji\customization\metadata.json
     Watching /PROJECT/ROOT/DIRECTORY/.koji\customization\texts.json
     Watching /PROJECT/ROOT/DIRECTORY/.koji\customization\theme.json
     Watching /PROJECT/ROOT/DIRECTORY/.koji\hooks\about_hooks.md
     Watching /PROJECT/ROOT/DIRECTORY/.koji\hooks\post-clone.sh
     Watching /PROJECT/ROOT/DIRECTORY/.koji\project\about_project.md
     Watching /PROJECT/ROOT/DIRECTORY/.koji\project\deploy.json
     Watching /PROJECT/ROOT/DIRECTORY/.koji\project\develop.json
     Watching /PROJECT/ROOT/DIRECTORY/.koji\scripts\buildConfig.js
     Watching /PROJECT/ROOT/DIRECTORY/.koji\scripts\buildManifest.js
     Watching /PROJECT/ROOT/DIRECTORY/browser\.koji\customization\about_customization.md
     Watching /PROJECT/ROOT/DIRECTORY/browser\.koji\customization\metadata.json
     Watching /PROJECT/ROOT/DIRECTORY/browser\.koji\customization\texts.json
     Watching /PROJECT/ROOT/DIRECTORY/browser\.koji\customization\theme.json
     Watching /PROJECT/ROOT/DIRECTORY/browser\.koji\hooks\about_hooks.md
     Watching /PROJECT/ROOT/DIRECTORY/browser\.koji\hooks\post-clone.sh
     Watching /PROJECT/ROOT/DIRECTORY/browser\.koji\project\about_project.md
     Watching /PROJECT/ROOT/DIRECTORY/browser\.koji\project\deploy.json
     Watching /PROJECT/ROOT/DIRECTORY/browser\.koji\project\develop.json
     Watching /PROJECT/ROOT/DIRECTORY/browser\.koji\scripts\buildConfig.js
     Watching /PROJECT/ROOT/DIRECTORY/browser\.koji\scripts\buildManifest.js
     Watching /PROJECT/ROOT/DIRECTORY/server\.koji\customization\about_customization.md
     Watching /PROJECT/ROOT/DIRECTORY/server\.koji\customization\metadata.json
     Watching /PROJECT/ROOT/DIRECTORY/server\.koji\customization\texts.json
     Watching /PROJECT/ROOT/DIRECTORY/server\.koji\customization\theme.json
     Watching /PROJECT/ROOT/DIRECTORY/server\.koji\hooks\about_hooks.md
     Watching /PROJECT/ROOT/DIRECTORY/server\.koji\hooks\post-clone.sh
     Watching /PROJECT/ROOT/DIRECTORY/server\.koji\project\about_project.md
     Watching /PROJECT/ROOT/DIRECTORY/server\.koji\project\deploy.json
     Watching /PROJECT/ROOT/DIRECTORY/server\.koji\project\develop.json
     Watching /PROJECT/ROOT/DIRECTORY/server\.koji\scripts\buildConfig.js
     Watching /PROJECT/ROOT/DIRECTORY/server\.koji\scripts\buildManifest.js

What is "VCC"?

Hello,

What is "VCC" stands for? I couldn't find its documentation.


I also saw a similar acronym in API section:

... Koji Customization Controls (CVV's) ...

Isn't this ("CVV") a misspelled (and the same "VCC")? Isn't "VCC" the abbreviation of "Visual Customization Controls", probably?

Bug in request.js: throws error in onFulfilled handler!

According to MDN the first parameter of then function (of a Promise) is onFulfilled callback:

p.then(onFulfilled[, onRejected]);

So below throw command will run when json() method successfully resolved:

function checkStatus(response) {
if (response.status >= 200 && response.status < 300) {
return response;
}
return response
.json()
.then(({ error }) => {
throw new Error(error || 'api_error');
});
}

According to the same page

If a handler function [...] throws an error, the promise returned by then gets rejected with the thrown error as its value

So in the below lines:

// Process an HTTP request
module.exports = (route, params) => {
return wrapFetch(route, params)
.then(checkStatus)
.then(parseJSON)
.catch((err) => {
throw err;
});
}

the first then() will get rejected:

module.exports = (route, params) => {
  return wrapFetch(route, params)
    .then(checkStatus)  // <- WILL GET REJECTED with: `new Error(error || 'api_error')`
    .then(parseJSON)
    .catch((err) => {
      throw err;
    });
}

Additionally, json() method will apply two times in below sequence:

.then(checkStatus)
.then(parseJSON)

first in checkStatus() and then in parseJSON():

function parseJSON(response) {
return response.json();
}
// Check the status of an HTTP request
function checkStatus(response) {
if (response.status >= 200 && response.status < 300) {
return response;
}
return response
.json()
.then(({ error }) => {
throw new Error(error || 'api_error');
});
}

Bug in watch.js: Doesn't fire if 2 events are less than 1 second apart

Hello,

The algorithm used in watch.js to handle near events (less than 1 second apart) together, has a bug. Such way the second (and third, fourth, ...) event is (are) not handled at all!

koji-tools/watch.js

Lines 26 to 33 in a1ca3c2

fs.watch(path, (eventType, filename) => {
if (fsWait) return;
fsWait = setTimeout(() => {
fsWait = false;
}, 1000);
console.log(eventType, filename);
refresh();
});

This is the first thing in the handler callback (and there is nothing before it):

if (fsWait) return;

So the question is simple: What happens when fsWait is not falsy? The answer is simple too. The function just returns! And the event? Who will handle it? It goes to a black hole.

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.