Angular Schematics, how to use own schematic - angular-schematics

I can't find how to use a newly created schematics.
Here is my structure :
|- tools/
|- schematics
|- my-first-schematic
|- my-second-schematic
I want to use my-first-schematic within my-second-schematic.
I know about externalSchematic() but it's useful when we want to call schematif from another collection. I just want to use my own schematic.
Thanks!

Related

laravel proper way to extend(expand)/override specific vendor package file

the project I involved has composer require fengqi/hanzi into the vendor folder, which is used to convert simplified Chinese and traditional Chinese
For people who want to take a look at the package https://github.com/fengqi/hanzi
Inside the vendor folder, the package has the following example directory structure:
vendor/
--hanzi/
----src/
------Hanzi.php
------HanziDict.php
------Pinyin.php
The specific file HanziDict.php I want to modify has a really simple code structure:
<?php namespace fengqi\Hanzi;
return array (
'啊' => '啊',
...
...
'sample char A'=>'sample char B'
);
The github repository of the package suggested that I can insert any "char C => char D" inside the php file if I found the certain chars are missing from the dictionary.
But I believe I should not directly put the code inside vendor folder since it will be override after update.
So, my problem is how I can properly override/extend this file in Laravel (such as insert "char C => char D" into the array).
I already read and know how to properly extend class outside of vendor folder but did not find any useful information about other types of php files. I wonder if there is certain ways or rules to do with this kinds of files.
Ideally I want to achieve something like:
outside of the vendor folder, I have an expanded ExtraHanziDict.php. So it can always build upon the vendor dict.php.
The following links is the vendor class code (only fewer simple functions to read the dict and convert character)
https://github.com/fengqi/hanzi/blob/master/src/Hanzi.php (apology for throwing the code)
Unfortunately, in this case, there's no easy way to change the dictionary. As you correctly guessed you should never change the content of the vendor folder as it's not committed to version control.
In your specific case what you can do is:
Ask the repository mantainer to add an api that allows you to add new dictionaries at runtime.
Fork the repository, change what you need, and use that instead (see loading a custom git repository with composer). If you think your changes can be useful to others open a Pull request on the original repository.
There's no much logic on the repository you linked. Each package you add to your composer.json file is a burden, code that doesn't belongs to you and you MUST blindly thrust (what if at some point the repository is hacked and some malicious code hidden into it?). Just create your own service to do such a simple task.

How to add a custom or external fact for role in Puppet?

I'm using a control-repo for my puppet master profiles/roles.
I'm using Hiera and I would like to add role in the hierarchy
My hiera.yaml looks like :
:backends:
- yaml
:yaml:
:datadir: "/etc/puppetlabs/code/environments/%{::environment}/hieradata"
:hierarchy:
- "nodes/%{::trusted.certname}"
- "roles/%{::role}"
- "common"
site.pp
node xx01 {
include role::cassandra
}
node xx02 {
include role::mysql
}
node xx03 {
include role::cassandra
}
For example I should add role fact for node xx01 and xx03. So it would useless to add fact for every new node in the future. so I want the fact to be added for every new node.
So the best way is to add a code to add a the fact for role in the control repo. not in the modules.
The puppet agent doesn't seem to intrinsically have the role fact, so I added a role fact in /etc/puppetlabs/facter/facts.d
I think it's useless to compare with hostname to add the fact for roles if the hostname reflects the role. so I could use the hierarchy with a hostname rather than role.
You can either do this with an external fact or a custom fact. I should also note that your hiera file is completely fine and will automatically pick up your role fact for data resolution once that fact is populated. I am also going to assume from that hiera file that you are using Puppet 4, Facter 3, and Hiera 3 (not the Puppet Data Provider with module data lookups etc.), since you are using syntax and conventions consistent with those.
Let us say you have roles app, db, and report.
For custom facts, you would want to write some code like the following in the lib/facter/role.rb directory of a compiled module:
Facter.add('role') do
setcode do
case Facter.value(:hostname)
when /db/ then role = 'db'
when /app/ then role = 'app'
when /report/ then role = 'report'
else role = default
role
end
end
This would be a simple example of how to do this.
You can also do this with an external fact placed in the lib/facts.d directory of a compiled module, like a role.yaml or role.sh file. The yaml would be good for static data, and the shell script would be an example of how to dynamically ascertain the role of the server without using ruby.
You can check additional documentation here: https://docs.puppet.com/facter/3.4/custom_facts.html

grunt-usemin: exclude file from minification

I use KendoUI library in my project, so it's already minified but incredibly big.
Is it possible to exclude it from being uglified when using grunt-usemin?
Thanks!
In your grunt configuration, use an explanation point to make an exclude. Place those at the end of your src array.
e.g., add to the end of the src array, add:
'!htdocs/js/kendo.all.min.js'
You'll have to modify your flow for js and use a custom post-processor, which basically consists on adding a flow property to your useminPrepare.options (follow the basic structure in usemin README file), but instead of just adding a step (e.g. 'uglify'), plug a custom post-processor:
name: 'uglify',
createConfig: function (context, block) {
...
}
To customize how it will handle files, copy the createConfig from the example file you find most useful (see files in grunt-usemin/lib/config/) and modify it as you need (i.e. excluding the file you want).
I used a custom post-processor to add ngAnnotate to the usemin flow for js, just changing name to ngAnnotate and copying the createConfig from uglify).

Laravel: How to find the right blade master template?

To extend a blade template you have to write
#extends('folder.template_name')
This works for standard installation.
I've created a module for the backend and now I can't use my module template because Laravel catches the first record and that is the standard view folder.
My structure looks like this:
app
-- modules
-- modules\backend
-- modules\backend\views
-- modules\backend\views\layouts\master.blade.php
-- views
-- views\layouts\master.blade.php
So when I'm in the backend and try to display my template:
// app\modules\backend\views\page\index.blade.php
#extends('layouts.master')
Laravel renders the app\views\layouts\master.blade.php instead of
app\modules\backend\views\layouts\master.blade.php
I've tried many names inside that #extends e.g.
#extends('app\modules\backend\views\layouts\master')
#extends('app.modules.backend.views.layouts.master')
#extends(base_path(). '\app\modules\backend\views\\' . 'layouts.master')
Nothing works.
While using a package or autoloaded module, referring to it's resources is done using the double colon notation. In your case, to access the module's master template you need to use
#extends('backend::layouts.master')
These conventions are described in the docs, for further info please refer to
Laravel 4 package conventions
Make sure /app/config/view.php has a path entry for where those views are located.
I.E.
'paths' => array(__DIR__.'/../views'),
To
'paths' => array(
__DIR__.'/../views',
__DIR__.'/../modules/backend/views'
),
or whatever represents your actual path.
From here you might want to look into doing the view folder loading via another mechanism if your views are in dynamically generated folders. Maybe a module::boot event that adds the module path to the view paths array? Just an idea.

How to access different test-fragment present in external test plan

I want to create a common test plan and define multiple test fragment in this file. I want to use some of the specific test fragment in the specific test plan. Here is outline of two different test plan.
common-test-plan.jmx
common-test-plan
|--TestFragment1
| |-Sampler11
|
|--TestFragment2
|-Sampler21
Specific-test-plan.jmx
Some-Test-plan
|--ThreadGroup1
|-IncludeController
|-Module controller(accessing the Include controller)
|-Sampler1
|-Sampler2
I used include controller to include the external test plan component. When I use the Module controller it just shows the include controller in the list. It doesn't show all test fragment present in the external test plan.
Is there any way I can specifically use few of the test fragment present in the external test?
 IncludeController references aren't loaded until you run
the test plan which means that the ModuleController can't reference its
internals
The best you have without a code change is one TestFragment per
IncludeController and then to use a TestFragment in your main Test Plan to
Include them all.  ModuleControllers can then reference each included file
to execute its contents.
Answer based on Anthony Johnson on mailing list

Resources