Package manager - how to extend module with ability of module update - laravel

When I use some package manager like Composer I want to use some 3rd-party module and to have an ability for example to change some views (templates) of this module, and simultaneously to have an ability to update this module trough composer.
How can I do this?
If not - may be it is question to think about to integrate to package managers some pattern to have an ability do this well ?
Pattern - I mean some rules with that programmers will be able to show some files that will be able to be edited by consumer and to do it, developer should do some api for it by some standartized method that will be written in rules, f.e. in some composer config of his module developer will write, what files should be duplicated to userpath. After install, these files will be copied and user will be able to change it, and composer will do it able modules to see these files in users folder. And after update this user folder will not rewrite these edited files... Something like that or maybe somehow more flexibly

How to modify views of packages installed by composer in Laravel:
https://laravel.com/docs/5.0/packages#views
Customized views should be placed in folder /resources/views/vendor/
with same names as original
This is the first place where views are searched by framework

Related

How to install node modules but commit only relevant styles

So, I am setting up a new site and my project's folder structure looks like this now.
foo.com/
index.php
assets/
css/
img/
js/
vendor/
I have added vendor/ for js/css libraries that I must install to keep them separate, since I want anyone who installs my project to install those in vendor from package.json - most libraries contain too many files 99% which I don't want to push to production.
Now once the project is finished, I would like to push the code to production with only the necessary js/css files.
This is where the problem comes. For example, if I install bulma css using:
yarn add bulma --modules-folder ./assets/vendor
It will dump all bulma-related files which are almost 70 into /vendor/bulma/ but I will only be needing one or two css files afterwards, since I will compiles the sass file to css as:
sass vendors/bulmna/style.scss assets/css/style.css
So my questions is: I am assuming this is how every developer does it and there are no documentations I can find that suggest how to do it. Is it safe to ignore the /vendor directory? What if I install vue, font-awesome, bootstrap .. how can I only fetch the files I need but not everything in /vendors folder?
Your question is actually quite broad - however, I'll try to list as much as possible.
Lets say you're building a project from scratch and needed to include vuejs, jquery, fontawesome but only need to include a couple of files.
The issue you're hitting here is module dependency with respect to npm modules. (and there are many different tools that you can use to manage versions on your library dependencies as well as ensuring they are included into your project, i.e. package managers).
Ok - now from here, you may say to yourself
but I only need say, one icon from fontawesome in your final build (dist) and I don't want to commit all my modules into source control
Again, this is where you omit node_modules and other dependent libraries from source control (i.e. include node_modules your .gitignore)
To reiterate
You can install the required library,
add node_modules to .gitignore ,
bundle those libraries into a vendor single file to be consumed by your users (can be via browserify/webpack/rollup/gulp/grunt/yarn etc).
generate bundle within npm script
Now you may ask further -
Why would I use any of those tools? - they're distracting me from simply copy/pasting vendor libaries into my source control.
Build tools were created to
streamline the developer pipeline so that you DONT have to copy/paste vendor libaries into a vendor folder.
ensures that all files are bundled to the client automatically
allows you to keep track/restrict library version updates/ when required via package.json
allows you to add other build steps (such as minification, md5hash versioning, compression, code splitting, asset management to name a few).
Now lets break down the original question here:
How to ensure other developers get everything they need when cloning the repository
how do I ensure I can provide only the necessary files to the end user (if I only use specific parts of vendor libaries?)
1. How to ensure developers get what they need
Again, to reiterate above, adding devDependancies and .gitignoring allows you to only add the necessary files to your project.
2. How can I ensure clients get what they need without bloating request files?
This is where build tools such as webpack, browserify, gulp, grunt, rollup, attempt to achieve. This is because with some libraries that exceed in file size of 200kb minified, you may need to separate these files into different client requests (and as such, not demand the user to request one large file, which was symtomatic of browserify projects).
The second technique you will need to be aware of, is with specific libraries, you can use import mdn link where you can require one function/class from a dependant library (which further reduces file size).
Another technique is using less import statements (which can extract less functions/styles similar to above, but this isn't currently supported in SCSS). for SCSS, you're basically left with copy/pasting the necessary styles into your base scss and that'll save you space as well.
EDIT
How to create a bundle from npm install libaries
From the comments you've mentioned above (about not wanting to include a tool into your workflow, there's no point outlining any one particular strategy - you can find answers/tutorials online about how to setup gulp/browserify/webpack for your particular needs).
However, As you are currently using yarn - I'll go into details about that.
Firstly, yarn is a package manager (like npm). All it does with the --modules-folder is install the package into the specified folder, that's all. So we don't really care about that (since it's doing the same thing as npm). (i.e. your vendor folder is the same as node_modules in many respects).
We could use
webpack
gulp
grunt
rollup
browserify
brunch
(All build tools that essentially allow you to bundle all those packages into a single entry point to be packaged to the client).
I won't go into how, because that is a process you can find online, and from the above comments, I can tell you don't particularly care either.
What you are looking for is a zero-config javascript build tool. (Extremely out of the scope of your original question, and i'll only answer that in a separate Q&A).
I'd try Googling on "tree shaking CSS" to see if that gives you something.
Maybe something like: https://github.com/jacobp100/es-css-modules
Rollup plugin may be useful. It works for js, with postcss, the link says it works with css also.
https://code.lengstorf.com/learn-rollup-css
Have a look at Pancake. It has been built specifically for the purpose of moving only those files out of the node_modules folder that you need. I wrote an article about it here: https://medium.com/dailyjs/npm-and-the-front-end-950c79fc22ce
(probably not an answer but a good tip)
PS: I am the author of both, the article and the tool so with clear bias :)

How to reuse custom module with all in one installation in magento 1.9

I created a custom module that represents a custom payment method, the steps I follow are;
1) Create a module architecture in /app/local/NameSpace/MyModule
2) Create an xml file in /etc/modules to configure my module
3) Create templates /design/frontend/base/default/template/mymodule
The module works well, but i want to reuse the module in other projects with all in one installation. now, i want to know if i must develop a script to copy the xml file in /etc/modules and templates manually? or there is an existing solution in magento 1.9 to do this operation?
Thanks in advance,
You want to create a Magento Connect package. There's a UI for doing this under the System Magento menu (although the UI is sort of terrible) and some googling around should set you right. Once you have a connect package, you can install it into any system via the /downloader UI (also available via the System menu) or the ./mage CLI command.
Also -- if you choose "Magento Other" as the role for all your files, your resulting tgz archive can simply get uncompressed/unarchived into any Magento system's root folder. Also of interest -- my script for creating Connect Packages from raw tar archives.

How to add AngularJS with different modules to a Visual Studio project?

So far I thought that using Nuget to add the AngularJS modules is the way to go. But nuget adds the packages to whatever directory it is configured to. For example it adds the angularjs.core package to my main Scripts folder. It adds the angular-ui-router module again to my Scripts folder. But the angular-ui-bootstrap module is added to Scripts\angular-ui. If I am to use Nuget and keep the packages up to date, etc. I need to stick with this, which is inconsistent. Not to speak that I want to have all my angularjs scripts in a Scripts/vendors folder.
Can I somehow work around this problem or just ditch Nuget for this?

joomla-extracting a component as installable?

I am writing a joomla componenet but it has many folders and sql tables. I don't prefere to make the package manually. Is there any know extension to make me able to extract my component as a zip file to make it installable.
I'm so confused. Why would you need an extension to compile your component? By the sounds of thing, you have simply started editing a pre-made component.
You should have started with the folder and file stricture when you first started building the component.
Create 2 folders:
admin
site
Put all backend end related folder inside the admin folder, and all frontend related folders inside the site folder.
Then edit your XML file accordingly to it points to the correct folders
There is a third-party component: http://joomlatoys.com/index.php/toys/jtbuilder which can package the selected extensions and generate an installable archive for you.

ASP.NET MVC folder structure and NuGet

I want a custom directory structure for my Content in my MVC project for example:
\Content
--\js
--\css
--\img
Is it possible to tell a NuGet package to install scripts in the Content\js folder? For example the jQuery package so that the jquery-1.6.js file is installed in the Content\js folder?
A workaround is to use the Nuget Package Explorer and download the package you want into that. You can then edit the folders within the package using Package Explorer to suit your taste and save it into your own Nuget repository. This can be a file system folder or you can get more sophisticated here: Hosting Your Own NuGet Feeds.
Of course this means that you have to keep the packages in your private repository up to date. Clearly if you have a lot of packages to deal with this could become a problem. However it seems quite likely that a future release of Nuget will deal with the issue of local feeds because it's an issue for companies that 'restrict which third-party libraries their developers may use' as mentioned in the Hosting your own NuGet feeds reference above.
I believe the answer to that is "No." There are, however, some references to be able to set the root folder NuGet installs things into: http://nuget.codeplex.com/workitem/215 (see the comments)
How jQuery gets installed is determined by the package producer, which is the jQuery team in your case.
Where the jQuery package gets installed is up to you.
However, the where can only be adjusted in terms of the location of the installed package ($(SolutionDir)\packages folder is the default), and the target project where you install it into. From then on, the package producer takes over and decides where each piece of the package content ends up.
There are some good conventions for ASP.NET MVC, such as a Content folder, a Scripts folder, an App_Start folder (for WebActivator), etc. Think about the risks and extra effort involved of trying to move away from these conventions. Do they outweigh the benefits?
Now if you really want to use your own conventions, you could create your own package with your desired content structure and put the jQuery scripts where you want them in the consuming projects.
This means you would be using your own package with that specific version of jQuery. You just have to be careful to respect the licensing policy of the original package, and not to break any specific installation steps or requirements from the original package, which is fairly easy to do if you manually start changing package structure.
The answer to this is "no" because the "Content" folder is one of the Nuget's convention folders. However, if you rename your Content folder to, for instance, public and then have Nuget pack your public/js folder then when you bring the package in it will extract the files to the public/js folder.
Since I started to use Nuget I switched to using public for my public content instead of Content and rather use Content for files that I want to bring in untouched like source files (see here one usage of Content).

Resources