I need to load default factories.yml with default settings, but only for one module in my application:
frontend:
config:
factories.yml
settings.yml
modules:
ajax:
action:
config:
factories.yml
templates:
etc:
action:
templates:
etc2:
action:
templates:
I just need to load for the ajaxmodule a special factories.yml for increase speed issues.
I read something that its not possible, but gives there any solutions for this issue?
I really need help, i dont get it :(
Thx
Did you try to put your custom factories.yml in apps/your_app_name/modules/your_module_name/config instead of apps/your_app_name/config ?
This should override your default factiories.yml in context of your custom module (the same as for example view.yml)
Related
I am looking for a safe way of doing require aliases using gulp.
The idea is similar to what webpack offers with resolve alias.
For example, I put on my source code something like require('#plugin/utils') and it is translated to something of my choice, like require('$/plugins/longer/namespace/utils'). You probably have noticed that it does not match to any actual file path, and that is intentional (they are tiddlywiki files if anyone is interested).
The best thing I found is gulp-replace, but that relies on strings replacements at worst and regular expressions at best.
Ideally I would want something more reliable, something that is AST aware,so I'm sure that I never replace the wrong string (for example, a template string).
I am also using babel, so if there is a babel plugin that I can use I will also be happy about that.
As a last resort I may try to write some babel plugin or a gulp plugin using esprima, but esprima is not up to modern JS standard (doesn't parse object spread) and I would prefer creating another tool.
Thanks in advance
Finally I found a babel module (babel-plugin-module-resolver) that I can integrate with gulp, and with some extra configuration magic with eslint.
So, this is what I added to my gulp pipeline (simplified)
const babelCfg = {
plugins: [[
require.resolve('babel-plugin-module-resolver'),
{
root: [ `${pluginSrc}/**` ],
alias: { '#plugin': `$:/plugins/${pluginNamespace}` },
loglevel: 'silent',
}
]],
};
return gulp
.src(`${pluginSrc}/**/*.js`)
.pipe(babel(babelCfg))
.pipe(gulp.dest(outPath.dist));
That converts all the references to require('#plugin/xxxx') with the proper path.
With some extra configuration you can even make eslint warn you about bad path resolutions.
You need to configure it differently because eslint needs the real path, while the output files needs a special namespace. After installing both eslint-import-resolver-babel-module and eslint-plugin-import this is what you should add to your eslint config to make it work:
plugins:
- import
env:
node: true
browser: true
settings:
import/resolver:
babel-module:
root: ./src/**
alias:
"#plugin": ./src/the/real/path
rules:
import/no-unresolved: [2, { commonjs: true }]
I'm really new in VueJS,
I use RxJS, Vue rx and Vue Resource in a mixin so i can make http calls and get observables back anywhere... awesome!
now i tried
subscriptions () {
return {
titles$: this.getHTTPObservable('https://jsonplaceholder.typicode.com/albums').flatMap(arr => Rx.Observable.from(arr).take(10).map(o => o.title).toArray())
}
The only thing i need now is to specify the end point of the server i am requesting in some configuration file like i would do in angular environments file. When launching the build by hand it should look like when i write
ng serve --env=dev
is there something similar?
Actually i found the answer on this page https://vuejs-templates.github.io/webpack/env.html
so, i can add any configuration variable and then call process.env.varname to get it back,
thanks
Vue.js normally works in conjunction with Webpack to achieve this.
https://v2.vuejs.org/v2/guide/deployment.html#With-Build-Tools
The DefinePlugin from Webpack is used for this. Outside of Webpack I think you are still able to use this:
https://www.npmjs.com/package/cross-env
My use case: application has a header that displays current user's name. This header is the same on all pages.
User data is loaded from JSON API into the Store when user logs in.
Now, how am I supposed to access this data from Store to use it on every page?
One option is to pass it from routes:
{{app-header user=model}}
But then I would have to use the same model in all the routes and also would be unable to use any other? How can a (supposedly reusable) component expect from me to adjust every route to its data structure?
The other option is that component always loads data from Store on its own, but this seems strongly unrecommended and actually very hard to do for me without any proper guide. I managed to discover service injection method (store: Ember.inject.service() in the component) but still can't get the component to properly display data from store in the template.
When I use:
name: () => {
return this.store.peekRecord('user', 1).get('name');
}
then {{name}} in template renders function definition, not what it returns.
When I use:
name: Ember.computed(() => {
return this.store.peekRecord('user', 1).get('name');
})
then {{name}} renders: <!---->
Could you please explain what is a good way to do this? Is there some "master model" defined in application.js besides models from routes? Should I really pass the same data to component in every route? Any information or suggestions will be greatly appreciated.
You could try using a service (guide here).
// app/services/store.js
import DS from 'ember-data';
export default DS.Store.extend({});
// app/services/user-service.js
import Ember from 'ember';
export default Ember.Service.extend({
store: Ember.inject.service(),
user: Ember.computed(function() {
return this.get('store').findRecord('user', ':id');
})
});
Then, in all your other components, controllers, and routes, you can access the service.
// Inside a controller
export default Ember.controller.extend({
userService: Ember.inject.service(),
firstName: Ember.computed.alias('userService.user.firstName')
});
The first name, or even the user object itself is now available in you template.
{{userService.user.firstName}}
OR
{{firstName}}
First approach, (Keeping it in Application Route)
1.Define it in application route model hook - refer multiple modelsin single route.(https://guides.emberjs.com/v2.9.0/routing/specifying-a-routes-model/#toc_multiple-models)
2.If its required in another route, then you can access already resolved model of the parent route through modelFor method.(http://emberjs.com/api/classes/Ember.Route.html#method_modelFor)
Second Approach, (Service)
Like #devman answer, you can load it in service and inject and get it wherever you require.
userService:Ember.inject.service();
name: Ember.computed.alias('userService.name')
The meanjs core module provides a default index page for the home state:
// Home state routing
$stateProvider
.state('home', {
url: '/',
templateUrl: 'modules/core/client/views/home.client.view.html'
})
I have added my own module mymod to the meanjs application. I would like to use my own partial modules/mymod/client/views/browse.client.view.html.
How do I do it WITHOUT modifying the core.client.route.js file? I always avoid modifying code obtained from frameworks and belive in overriding. What is the recommended approach to do this?
I think you are misunderstanding the point of MEANJS. From MEANJS github page:
MEAN.JS is a full-stack JavaScript open-source solution, which provides a solid starting point for MongoDB, Node.js, Express, and AngularJS based applications. The idea is to solve the common issues with connecting those frameworks, build a robust framework to support daily development needs, and help developers use better practices while working with popular JavaScript components.
MEANJS is not a strict platform that will stop working if you change its own code. Of course that there are some code blocks that should not be modified but there are blocks that you can/should modify to avoid clutter in your code as your app grows.
With that said, you can still keep the route as it is:
$stateProvider
.state('home', {
url: '/',
templateUrl: 'modules/core/client/views/home.client.view.html'
});
And in this partial modules/core/client/views/home.client.view.html, you can use AngularJS directive ng-include and in the src put the path for your custom partial browse.client.view.html. This way you don't need to modify core.client.route.js you just have to modify the partial modules/core/client/views/home.client.view.html.
I cannot set up the code coverage configuration, the report is always 0%. I'm using codeception coverage with two projects, the first one with:
Yii2
WebDriver module
Weird stuff:
I have two codeception.yml:
/tests/codeception.yml
/codeception.yml
c3.php is not in root. It is on /vendor/codeception/codeception/tests/data/claypit/c3.php
I'm not sure where I have to include c3.php
Like I'm not sure which codeception.yml is the right file, I have the same configuration on both files.
actor: Tester
paths:
tests: tests
log: tests/_output
data: tests/_data
helpers: tests/_support
settings:
bootstrap: _bootstrap.php
colors: false
memory_limit: 1024M
modules:
config:
coverage:
enabled: true
remote: false
include:
- /controllers/*
c3_url: 'http://127.0.0.1/tmsO/#/'
I have the same problem with the second project, the differences are that I'm using:
Yii1
PhpBrowser module
Asserts module
REST module
Thank you in advance. I really need help.
When you use Codeception for acceptance Tests and using PHPBrowser/WebDriver you need remote coverage (remote: true). Therefore it will always say 0% in the console but will be saved in the _output directory.
On the remote site, the c3.php will collect all the needed data. So you need to include it in every call to your application. (for more information see https://github.com/Codeception/c3).
You can find the documentation for setting up the code coverage here: http://codeception.com/docs/11-Codecoverage