定制 innoraft/drupal-quality-checker 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

innoraft/drupal-quality-checker

Composer 安装命令:

composer create-project innoraft/drupal-quality-checker

包简介

Setups code quality checking tools for Drupal project.

README 文档

README

Overview

This composer package will provide some basic code quality checks before committing code by using https://github.com/phpro/grumphp. Check out this Lullabot article for more details.

This has been customised from vijaycs85/drupal-quality-checker for Innoraft needs.

Install

  1. Add innoraft/drupal-quality-checker to composer.json or just run

    composer require --dev innoraft/drupal-quality-checker
  2. Replace grumphp.yml in project's root directory (not Drupal root directory) with vendor/innoraft/drupal-quality-checker/grumphp.yml.dist

That's it. Now, all tasks (listed below) run on every git commit.

Note: As part of install, GrumPHP adds pre-commit hook to repository. Existing pre-commit might get destroyed when install/uninstall.

Out of the box

  1. PHPCS with Drupal standard.
  2. PHP Lint
  3. YAML Lint
  4. Composer
  5. Composer Normalize
  6. JSONLint
  7. Trufflehog

Long list of additional checks/validators available here.

To automatically setup all the packages, follow the below steps:

  1. Download the setup.sh file and place it outside the docroot.

  2. Update Line 12 of setup.sh having the command composer require --dev innoraft/drupal-quality-checker. Use the appropriate environment for your setup. For example, if you are working with Lando, use lando composer require --dev innoraft/drupal-quality-checker.

  3. Update Line 102 of setup.sh having the command composer dump-autoload. Use the appropriate environment for your setup. For example, if you are working with Lando, use lando composer dump-autoload.

  4. From outside the docroot run this command that will make the bash script executable

    chmod +x setup.sh
  5. To execute the bash script run this command from outside the docroot

    ./setup.sh
  6. After executing the script, a prompt will appear asking for the base directory name , site name and custom theme name, which need to be entered cmd

  7. Few other prompts will appear where consent is needed to download the required package for the configuration

    image

  8. When prompted for tasks to run, select any option, as grumphp.yml is already included in the package and will be used for setup, making this selection less critical:

    image

  9. After this, please wait for some time for the script to execute and the setup to be completed.

Incase you want to install them individually, follow the below steps:

ESLint task Setup

  1. Go to custom theme folder and add eslint package with npm

    npm install eslint --save-dev
    npm install eslint-config-airbnb --save-dev
  2. Now run this command at project's root directory

    cp vendor/innoraft/drupal-quality-checker/eslintrc.json.dist .eslintrc.json

    For multisite run the following command

     cp vendor/innoraft/drupal-quality-checker/eslintrc.json.dist docroot/sites/<sitename>/themes/custom/<themename>/.eslintrc.json
  3. Update bin key for eslint task under grumphp.yml file with relative address to eslint's bin file.

    Example: if your theme name is drupal_theme then change it to web/themes/custom/drupal_theme/node_modules/.bin/eslint

Stylelint task Setup

  1. Go to custom theme folder and add stylelint package with npm

    npm install stylelint --save-dev
  2. Now run this command at project's root directory

    cp vendor/innoraft/drupal-quality-checker/stylelintrc.json.dist .stylelintrc.json

    For multisite run the following command

     cp vendor/innoraft/drupal-quality-checker/stylelintrc.json.dist docroot/sites/<sitename>/themes/custom/<themename>/.stylelintrc.json
  3. For multisite run the following command

    npm install stylelint-config-standard
  4. Update bin key for stylelint task under grumphp.yml file with relative address to stylelint's bin file.

    Example: if your theme name is drupal_theme then change it to web/themes/custom/drupal_theme/node_modules/.bin/stylelint

Trufflehog task Setup

  1. Create a new folder tasks at project's root level.

  2. Now run this command at project's root directory

    cp vendor/innoraft/drupal-quality-checker/tasks/SecurityLeaks.php tasks
  3. Now add the following code in your composer.json file which is present at project's root directory. ( For reference you can check composer.json file of this package )

    "autoload": {
        "psr-4": {
            "Innoraft\\QualityChecker\\Trufflehog\\": "tasks"
        }
    },

    Once the code is added in composer.json then execute this command

    composer dump-autoload
  4. Install trufflehog ( If not already install ). You can execute the following command to achieve the same.

    curl -sSfL https://raw.githubusercontent.com/trufflesecurity/trufflehog/main/scripts/install.sh | sh -s -- -b $HOME/.local/bin
  5. Please check and confirm if your grumphp.yml is updated with vendor/innoraft/drupal-quality-checker/grumphp.yml.dist ( Check and confirm if trufflehog tasks & service attribute is added in grumphp.yml file )

  6. Trufflehog is now ready to sniff your secrets :)

innoraft/drupal-quality-checker 适用场景与选型建议

innoraft/drupal-quality-checker 是一款 基于 Shell 开发的 Composer 扩展包,目前已累计 56.32k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 11 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「git」 「quality」 「hooks」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 innoraft/drupal-quality-checker 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 innoraft/drupal-quality-checker 我们能提供哪些服务?
定制开发 / 二次开发

基于 innoraft/drupal-quality-checker 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 56.32k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 32
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 3
  • Forks: 8
  • 开发语言: Shell

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-11-08