Giter Site home page Giter Site logo

electrode-io / electrode-confippet Goto Github PK

View Code? Open in Web Editor NEW
108.0 108.0 18.0 193 KB

node.js environment aware application configuration

License: Other

JavaScript 42.17% TypeScript 57.83%
config config-composition configuration-management node nodejs

electrode-confippet's People

Contributors

ananavati avatar caoyangs avatar dmikey avatar dylancwood avatar jchip avatar nicholasdunham avatar tiffine-koch avatar

Stargazers

 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  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  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  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

Watchers

 avatar  avatar  avatar  avatar  avatar

electrode-confippet's Issues

Union merging arrays?

I tried using union merge on an array by prepending + to the key, but it turns out that both the source and the target array need to have the + in the key name. That is surprising. Should it not be possible to append to arrays without requiring the original array key to start with a +?

I also noticed that there are still several calls to util.merge instead of util.uMerge in the code, and I wonder if that is correct?

Windows support?

Sorry, not a windows user myself, but I know that you're supposed to use path.join or path.resolve to get valid paths on both Unix and Windows.

I'm thinking that maybe confippet could have a default function root which takes the remaining refs, resolves them, splits them on /, and then uses path.resolve(config.root || process.cwd, ...refs) to generate a valid path on all platforms? So you could e.g. specify paths as icons: '{{root:config.assets:-icons}}'?

I suppose some way to escape : and / in refs would also be necessary.

Cannot detect config files

I have tried adding a default.json, default.yaml under the config directory but keep getting this error:

Error: Config provider deployment: no file development of extensions json,yaml,js found in /myapp/config
at load (/myapp/node_modules/electrode-confippet/lib/compose-config.js:36:17)
at list.sort.forEach (/myapp/node_modules/electrode-confippet/lib/compose-config.js:87:9)
at Array.forEach ()
at composeConfigDir (/myapp/node_modules/electrode-confippet/lib/compose-config.js:76:6)
at dirs.forEach (/myapp/node_modules/electrode-confippet/lib/compose-config.js:107:5)
at Array.forEach ()
at composeConfig (/myapp/node_modules/electrode-confippet/lib/compose-config.js:106:8)
at Config.compose (/myapp/node_modules/electrode-confippet/lib/store.js:31:28)
at load (/myapp/node_modules/electrode-confippet/lib/preset-config.js:31:13)
at Object.autoLoad (/myapp/node_modules/electrode-confippet/lib/preset-config.js:40:5)

Default file is development.json and default directory is "."

I am using "electrode-confippet": "^1.5.0" and i am seeing that

  • default directory is current directorynot config directory (document says default directory is config)
    -Default file is default.json, but i am seeing development.json is being taken as the default directory.

I think this is a bug on documentation , that needs to be fixed

Config values in React

Probably a stupid question but are you able to reference confippet config values in React code?
hoping to keep all my dev url's defined in one place.

Mention node-config?

Maybe I'm overstepping some bounds here, and I really appreciate Walmart open-sourcing Electrode, but shouldn't this project mention https://github.com/lorenwest/node-config in thanks for the obvious inspiration?

I have no stakes here, in fact I'm very deeply looking into replacing my home grown solution with Electrode because I was doing the same thing (configuration over code, remove all possible boilerplate).

Generate package.json

Problem set:

  • npm does not allow modifying parent dependencies from installed dependencies. This is useful when
    • the app needs to directly require deps, like when setting up eslint or babel. E.g. XO tries to wrap eslint but you still need to install eslint yourself if you add plugins.
    • a peer dep is shared across the app, like React
    • modules are optional, like spdy or session storage plugins, and would otherwise have to always be installed or provided by the app
  • You can't add comments to package.json, so you don't know why a certain dep was added

Solution:

It seems to me that these issues can be fixed by generating the package.json from config. Confippet is well-placed for this IMHO; packages could be put into the configuration, maybe with some logic injection.

When combining the configuration, the final set of required packages and settings is known and automatically compared to package.json. If the package.json differs, a warning is printed asking to regenerate it, or to incorporate the new versions into the app config (it could list where what version should go, like app config says [email protected] but package.json has @15.3).

TL;DR: This would allow e.g. configuring webpack SASS support and automatically installing sass-loader.

(At the beginning of the package.json there could be an attribute "__autogenerated": "This file was autogenerated by confippet. Do not edit.")

Module not found: Error: Cannot resolve module 'fs'

Hello,

When i use electrode-confippet in my code (anywhere in ./electrode/client):
../services/api.js

import axios from 'axios';

const config = require("electrode-confippet").config;
const BASE_URL = config.$("api.url");

const instance = axios.create({
  baseURL: BASE_URL
});

export const API = instance;

(even if i just have require("electrode-confippet"))

I have errors:

WARNING in ./~/electrode-confippet/lib/ext-handlers.js
Critical dependencies:
7:8-15 require function is used in a way in which dependencies cannot be statically extracted
8:6-13 require function is used in a way in which dependencies cannot be statically extracted
 @ ./~/electrode-confippet/lib/ext-handlers.js 7:8-15 8:6-13

ERROR in ./~/electrode-confippet/lib/process-config.js
Module not found: Error: Cannot resolve module 'fs' in /Users/ericsanchez/Projects/projects-node/tproject/node_modules/electrode-confippet/lib
 @ ./~/electrode-confippet/lib/process-config.js 4:11-24

ERROR in ./~/electrode-confippet/lib/compose-config.js
Module not found: Error: Cannot resolve module 'fs' in /Users/ericsanchez/Projects/projects-node/tproject/node_modules/electrode-confippet/lib
 @ ./~/electrode-confippet/lib/compose-config.js 4:11-24

ERROR in ./~/electrode-confippet/lib/ext-handlers.js
Module not found: Error: Cannot resolve module 'fs' in /Users/ericsanchez/Projects/projects-node/tproject/node_modules/electrode-confippet/lib
 @ ./~/electrode-confippet/lib/ext-handlers.js 4:11-24

Whereas i use require("electrode-confippet").config in electrode/server/ it's ok...
An idea ?
Thanks.

fail vs warn

Currently, you can only throw on failure, but you can't get a warning instead. failMissing and warnMissing work on different provider types.

Is this intentional? I would like to remind my users to create a config file for the current environment, not crash the app…

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.