kriss/composer-assets-plugin

Download assets(js/css/npm/github...) to project path

Installs: 145

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:composer-plugin

v1.0.0 2023-11-01 10:05 UTC

This package is auto-updated.

Last update: 2024-04-30 00:46:14 UTC


README

中文

Purpose of the plugin:

Static resources (such as jquery, bootstrap, etc.) are required in PHP projects,

I don't want to use NPM (it may not be NodeJs in the online environment),

I don't want to download the corresponding resources from NPM or GitHub and put them back into the project (it will pollute the Git record, and there may be developers who may have changed such resources)

Logic: Using the Composer plugin, download resources to a folder in the project through the configured URL, and specify the extraction of partial files

Usage

1. Installation dependencies

composer require kriss/composer-assets-plugin

2. Configure the resources that need to be downloaded

Configure 'composer. json' in the root directory of the project and add the following configuration (without comments):

{
  "extra": {
    "assets-dir": "public/assets", // Relative to the vendor directory
    "assets-pkgs": [ // array
      {
        // An example of any URL, from github (currently only supports resources of the. zip/. tar. gz/. tgz class)
        "url": "https://github.com/baidu/amis/releases/download/v2.2.0/sdk.tar.gz",
        "save_path": "amis@2.2.0", // 将保存到 public/assets/amis@2.2.0 下
      },
      {
        // Example of any URL, from NPM
        "url": "https://registry.npmjs.org/amis/-/amis-2.2.0.tgz",
        "save_path": "amis@2.2.0",
      },
      {
        // Example of NPM (recommended)
        "type": "npm",
        "name": "amis", // npm package name
        "version": "2.2.0",
        "only_files": [ // Specify which files are required. After the change, the downloaded directory needs to be deleted, otherwise it cannot be updated
          "sdk/thirds",
          "sdk/helper.css",
          "sdk/iconfont.css",
          "sdk/sdk.js"
        ],
        // "save_path": "amis/2.2.0", // Can override the default NPM save path address
      },
      {
        // Example of Github (using source code)
        "type": "github",
        "name": "baidu/amis", // github repo
        "version": "v2.2.0" // github tag
      }
    ]
  }
}

3. Execute Download

composer assets-download
# or
composer install # trigger from event