Bonnes Pratiques Web & Cloud
58.8K views | +4 today
Follow
Bonnes Pratiques Web & Cloud
Administration cloud et développement web
Curated by Mickael Ruau
Your new post is loading...
Your new post is loading...

Popular Tags

Current selected tag: 'gestionnaire de dépendances'. Clear
Scooped by Mickael Ruau
Scoop.it!

Package management basics - Learn web development | MDN

Package management basics - Learn web development | MDN | Bonnes Pratiques Web & Cloud | Scoop.it
This brings us to the end of our tour of package managers. Our next move is to build up a sample toolchain, putting all that we've learnt so far into practice.

 

 

In this article we'll look at package managers in some detail to understand how we can use them in our own projects — to install project tool dependencies, keep them up-to-date, and more.

Mickael Ruau's insight:
 

What exactly is a package manager?

We've met npm already, but stepping back from npm itself, a package manager is a system that will manage your project dependencies.

The package manager will provide a method to install new dependencies (also referred to as "packages"), manage where packages are stored on your file system, and offer capabilities for you to publish your own packages.

In theory you may not need a package manager and you could manually download and store your project dependencies, but a package manager will seamlessly handle installing and uninstalling packages. If you didn't use one, you'd have to manually handle:

  • Finding all the correct package JavaScript files.
  • Checking them to make sure they don't have any known vulnerabilities.
  • Downloading them and putting them in the correct locations in your project.
  • Writing the code to include the package(s) in your application (this tends to be done using JavaScript modules, another subject that is worth reading up on and understanding).
  • Doing the same thing for all of the packages' sub-dependencies, of which there could be tens, or hundreds.
  • Removing all the files again if you want to remove the packages.

In addition, package managers handle duplicate dependencies (something that becomes important and common in front-end development).

In the case of npm (and JavaScript- and Node-based package managers) you have two options for where you install your dependencies. As we touched on in the previous article, dependencies can be installed globally or locally to your project. Although there tend to be more pros for installing globally, the pros for installing locally are more important — such as code portability and version locking.

For example, if your project relied on Webpack with a certain configuration, you'd want to ensure that if you installed that project on another machine or returned to it much later on, the configuration would still work. If a different version of Webpack was installed, it may not be compatible. To mitigate this dependencies are installed locally to a project.

To see local dependencies really shine, all you need to do is try to download and run an existing project — if it works and all the dependencies work right out of the box, then you have local dependencies to thank for the fact that the code is portable.

Note: npm is not the only package manager available. A successful and popular alternative package manager is Yarn. Yarn resolves the dependencies using a different algorithm that can mean a faster user experience. There are also a number of other emerging clients, such as pnpm.

Package registries

For a package manager to work, it needs to know where to install packages from, and this comes in the form of a package registry. The registry is a central place that a package is published to and thus can be installed from. npm, as well as being a package manager, is also the name of the most commonly-used package registry for JavaScript packages. The npm registry exists at npmjs.com.

npm is not the only option. You could manage your own package registry — products like Microsoft Azure allow you to create proxies to the npm registry (so you can override or lock certain packages), GitHub also offers a package registry service, and there will be likely more options appearing as time goes on.

What is important is that you ensure you've chosen the best registry for you. Many projects will use npm, and we’ll stick to this in our examples throughout the rest of the module.

Using the package ecosystem

Let’s run through an example to get you started with using a package manager and registry to install a command line utility.

Parcel is a(nother) tool that developers commonly use in their development process. Parcel is clever in that it can watch the contents of our code for calls to dependencies and automatically installs any dependencies it sees that our code needs. It can also automatically build our code.

In our previous chapter we installed Prettier as a global tool. Here however, let’s use npm to install Parcel as a local tool, as best practices dictate. We'll install it as part of an experimental app.

No comment yet.
Scooped by Mickael Ruau
Scoop.it!

packages — Pourquoi préférer un gestionnaire de packages à un dossier de bibliothèque?

Quand je pense aux avantages et aux inconvénients d'un dossier de bibliothèque statique et d'un gestionnaire de packages, j'ai l'impression que le dossier de bibliothèque est une meilleure approche.

Avantages que je vois avec un dossier de bibliothèque:

Pas besoin d'un outil externe pour gérer les packages.
Aucune connexion Internet requise pour construire.
Construction plus rapide (pas de vérification de paquet).
Environnement plus simple (moins de connaissances requises).

Je vois avec un gestionnaire de paquets:

Aide avec des arbres de dépendances complexes (et qui peuvent être gérés en téléchargeant une dépendance avec toutes ses dépendances).
Aide à vérifier si une nouvelle version est disponible.

Il semble que l'industrie ait décidé de suivre le chemin du gestionnaire de paquets pour presque tout ce qui est construit aujourd'hui. Alors, qu'est-ce que je manque?
No comment yet.
Scooped by Mickael Ruau
Scoop.it!

DependencyWheel: An Interactive Visualization Of Package Dependencies

DependencyWheel: An Interactive Visualization Of Package Dependencies | Bonnes Pratiques Web & Cloud | Scoop.it


Did you ever dive into an existing project and wonder how much code is hidden behind a given dependency?
Did you ever wonder if a package present in the vendor/ directory is actually useful?
Did you ever look for a visualization that would help you understand the mess that's in a composer.json?

DependencyWheel tries to answer these needs. Also, it tries to make dependencies look beautiful, but that's another story.
No comment yet.
Scooped by Mickael Ruau
Scoop.it!

Dependency graph support is now available for PHP repositories with Composer dependencies

Dependency graph support is now available for PHP repositories with Composer dependencies | Bonnes Pratiques Web & Cloud | Scoop.it


The dependency graph powers many important experiences in GitHub, including security alerts, the “used by” counter, dependency insights, and automatic security fixes. We’re also seeing PHP and Composer grow in popularity—PHP is the fourth most popular language on GitHub and Composer is the fourth most starred PHP project. We’ve taken note, and the dependency graph is now rolling out for all PHP repositories with Composer dependencies. In addition to Composer, GitHub supports package managers for other programming languages, including Maven, NPM, Yarn, and Nuget.
No comment yet.
Scooped by Mickael Ruau
Scoop.it!

Yarn

Yarn | Bonnes Pratiques Web & Cloud | Scoop.it
Un gestionnaire de dépendances rapide, fiable et sécurisé.
No comment yet.
Scooped by Mickael Ruau
Scoop.it!

Tutoriel Maven N°4 : gestion de dépendances

Tutoriel Maven N°4 : gestion de dépendances | Bonnes Pratiques Web & Cloud | Scoop.it
Confiez à MAVEN la recherche des jars nécessaire à votre projet. déclarez vos dépendances dans la section ‘dependencies’ du fichier pom.xml . Optimisez la déclaration des dépendances inter-modules en utilisant l’héritage ainsi que la balise ‘dependencyManagement’. Comprenez enfin le plugin maven ‘dependency’

Ce tutoriel est un extrait de séances pratiques de la formation MAVEN dispensée par Objis.
No comment yet.
Scooped by Mickael Ruau
Scoop.it!

60 outils géniaux de développement web à utiliser en 2021

60 outils géniaux de développement web à utiliser en 2021 | Bonnes Pratiques Web & Cloud | Scoop.it
Comment les outils de développement web peuvent rationaliser votre flux de travail
Comment choisir la bonne pile de développement pour votre projet ?
60 outils géniaux de développement web à utiliser en 2021
No comment yet.
Scooped by Mickael Ruau
Scoop.it!

phpCallGraph - A Static Call Graph Generator for PHP

phpCallGraph - A Static Call Graph Generator for PHP | Bonnes Pratiques Web & Cloud | Scoop.it

phpCallGraph is a tool to generate static call graphs for PHP source code. Such a graph visualizes the call dependencies among methods or functions of an application. Arrows represent calls from one method to another method. Classes are drawn as rectangles containing the respective methods. The graphs can be leveraged to gain a better understanding of large PHP applications or even to debunk design flaws in them.

The example call graph on the right shows the main class of phpCallGraph itself and the internal dependencies among its methods. It is also possible to visualize calls to internal functions of PHP and to some extend call dependencies among different classes. Have a look at the example call graphs to get an impression.

The core of the call graph generator forms an object-oriented PHP5 library, which may also be integrated in other projects. It leverages the InstantSVC CodeAnalyzer and DOT. On top of it, a commandline application allows easy creation of call graphs in various formats, e.g. text, png, jpg or svg. phpCallGraph is free software licensed under GPLv3.
No comment yet.
Scooped by Mickael Ruau
Scoop.it!

Les types de dépendances

Les types de dépendances | Bonnes Pratiques Web & Cloud | Scoop.it

La plupart des gens ont uniquement dependencies et devDependencies, mais il est important de comprendre le rôle de chacun de ces types de dépendances.

dependencies

Ce sont les dépendances normales, à savoir celles dont vous avez besoin pour faire tourner votre code (par exemple React ou ImmutableJS).

devDependencies

Ce sont les dépendances pour le développement, des dépendances dont vous aurez besoin à un moment ou un autre lors de la phase de développement, mais pas pour l’exécution du code (par exemple Babel ou Flow).

peerDependencies

Les peer dependencies sont un type spécial de dépendances auquel vous serez confronté qu’à partir du moment où vous publiez votre propre package.

Avoir une dépendance peer signifie que votre package a besoin d’une dépendance qui doit être exactement la même dépendance que la personne qui est en train d’installer votre package. C’est utile pour des packages comme react qui ont besoin d’avoir une seule copie de react-dom qui sera également utilisée par la personne l’installant.

optionalDependencies

Les dépendances optionnelles sont exactement ce qu’elles mentionnent : optionnelles. Si Yarn ne parvient pas à les installer, le processus d’installation sera quand même réussi.

C’est utile pour les dépendances qui ne marchent pas forcément sur toutes les machines et pour lesquelles vous avez une solution alternative dans le cas où elles ne sont pas installées (par exemple Watchman).

bundledDependencies

Tableau de noms de packages qui seront intégrés à votre package lorsque vous le publierez.

Les dépendances de ce type devraient se trouver dans votre projet. La fonctionnalité est essentiellement la même que les dépendances normales. Ces dépendances seront également embarquées en exécutant yarn pack.

Les dépendances normales sont généralement installée depuis le registre npm. Les bundle dependencies sont utiles lors que les dépendances normales ne suffisent pas :

  • Lorsque vous voulez utiliser une bibliothèque tiers qui ne vient pas du registre npm ou bien que vous avez modifiée.
  • Quand vous voulez utiliser vos propres projets comme modules.
  • Lorsque vous voulez distribuer certains fichiers avec votre module.
No comment yet.
Scooped by Mickael Ruau
Scoop.it!

Tutoriel Vidéo NodeJS Yarn, un nouveau gestionnaire de dépendances

Tutoriel Vidéo NodeJS Yarn, un nouveau gestionnaire de dépendances | Bonnes Pratiques Web & Cloud | Scoop.it

Yarn est un nouveau gestionnaire de dépendances pour NodeJS qui propose une approche plus rapide et plus sécurisée que le gestionnaire historique npm.

Mickael Ruau's insight:

Qu'est ce qui ne va pas avec NPM ?

Avant de commencer à parler d'un nouvel outil il est important de comprendre les limitations de ce qui existe déjà.

Des dépendances non figées

Lors d'un npm install —save les dépendances sont récupérées avec un numéro de version "compatible avec". Par exemple un npm install jquery va ajouter la ligne suivante dans le fichier package.json ^3.1.1 qui indique à NPM de télécharger une version de jQuery >= 3.1.1 et < 4.0.0. Ainsi 2 personnes qui initialise le projet à un moment différent peuvent se retrouver avec des versions différentes et avoir des bugs différents malgré un fichier package.json identique.

Une installation lente

L'autre problème de npm est son extrème lenteur. En effet, à chaque nouveau npm install, il va récupérer les dépendances depuis les dépôts puis les dépendances de ces dépendances et ainsi de suite. Cette résolution en cascade peut rapidement prendre pas mal de temps suivant la taille de votre projet.

Yarn

Créé par Facebook yarn propose de régler ces différents problèmes tout en se reposant (pour le moment) sur l'écosystème déjà construit par npm.

No comment yet.