Git Product home page Git Product logo

Comments (5)

webpro avatar webpro commented on May 13, 2024

Thanks for trying out dyson.

Let me try to describe how I meant this to work:

  1. The "init" command creates e.g. /myApp/configs/get/dummy.js.
  2. Then from within the myApp directory, dyson should be started with dyson configs/

Dyson also sends the registered services to the console on boot (just like the demo), so if there's only "Dyson listening" then it didn't find any configs.

So what might went wrong in your situation is starting dyson with the [dir] argument (containing the method config directories).

But of course there can also be a bug in dyson, which I would really care to know about.

from dyson.

jessecravens avatar jessecravens commented on May 13, 2024

Well, looks like loader is not overriding the defaults in load():

['get', 'post', 'put', 'delete'].forEach(function(method) {
    methodDir = configDir + '/' + method;
    methodConfigs = _.flatten(requireDir(methodDir), true);
    console.log(methodConfigs)
    configs[method] = defaults.assign(methodConfigs, method);
});

returns 4 empty arrays:

[]
[]
[]
[]

In requireDir(),

it returns on the first conditional: if(!(fs.existsSync(dir) && fs.statSync(dir).isDirectory())) return;

UPDATE:

I think it is actually working as designed when I run dyson configs/ from within my app directory.
I wasn't initially including the trailing slash, then I was trying 'configs', '/configs,' and 'configs/' and comparing the results.

So, when using 'configs/' , it is erroring on var g = require('dyson').generators from within get/dummy.js.

module.js:340
throw err;
^
Error: Cannot find module 'dyson'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object. (/Users/jesse.cravens/Code/static_projects/sp-static/configs/get/dummy.js:1:71)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)

So, my app is not a node app. It is just a static ember.js application for now, but I would think that since dyson is installed globally, that require('dyson') would still resolve.

So by hardcoding the dependencies (dyson and lodash) back to the global directories:
/Users/username/nvm/v0.8.14/lib/node_modules/dyson/lib/dyson
/Users/username/nvm/v0.8.14/lib/node_modules/dyson/node_modules/lodash/lodash

everything works.

from dyson.

webpro avatar webpro commented on May 13, 2024

That is mentioned, yet briefly, in the README:

To use the data generators, dyson needs to be added to the devDependencies.

So you would need to add a package.json and make it a Node project, e.g.:

{
    "name": "myProject",
    "version" : "0.0.1",
    "dependencies": {},
    "devDependencies": {
        "dyson": "0.0.4",
    }
}

And then npm install. I will think about a better way when I get to it. As you found out, like me before (#2), requiring the global dyson doesn't work.

from dyson.

jessecravens avatar jessecravens commented on May 13, 2024

Ok ... make sense. Thanks a bunch.

from dyson.

webpro avatar webpro commented on May 13, 2024

OK, I hope things are working out for you now. I updated the README with a note, and you can now include dyson-generators (instead of ('dyson').generators), as can be found in the examples in both projects.

from dyson.

Related Issues (20)

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.