composer-files

Turns your files/objects into PHP Composer artifacts

License

License

MIT
Categories

Categories

Artipie Build Tools Distribution
GroupId

GroupId

com.artipie
ArtifactId

ArtifactId

composer-adapter
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

jar
Description

Description

composer-files
Turns your files/objects into PHP Composer artifacts
Project URL

Project URL

https://github.com/artipie/composer-adapter
Project Organization

Project Organization

jcabi.com
Source Code Management

Source Code Management

https://github.com/artipie/composer-adapter

Download composer-adapter

How to add to project

<!-- https://jarcasting.com/artifacts/com.artipie/composer-adapter/ -->
<dependency>
    <groupId>com.artipie</groupId>
    <artifactId>composer-adapter</artifactId>
    <version>1.0</version>
</dependency>
// https://jarcasting.com/artifacts/com.artipie/composer-adapter/
implementation 'com.artipie:composer-adapter:1.0'
// https://jarcasting.com/artifacts/com.artipie/composer-adapter/
implementation ("com.artipie:composer-adapter:1.0")
'com.artipie:composer-adapter:jar:1.0'
<dependency org="com.artipie" name="composer-adapter" rev="1.0">
  <artifact name="composer-adapter" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.artipie', module='composer-adapter', version='1.0')
)
libraryDependencies += "com.artipie" % "composer-adapter" % "1.0"
[com.artipie/composer-adapter "1.0"]

Dependencies

compile (6)

Group / Artifact Type Version
com.google.guava : guava jar 21.0-rc1
com.artipie : asto jar 0.34
javax.json : javax.json-api jar 1.1.4
com.artipie : http jar 0.17.7
com.artipie : http-client jar 0.3.5
org.apache.commons : commons-compress jar 1.20

provided (1)

Group / Artifact Type Version
com.google.code.findbugs : annotations jar 3.0.1

test (12)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar
org.junit.jupiter : junit-jupiter-engine jar
org.hamcrest : hamcrest jar 2.2-rc1
org.glassfish : javax.json jar 1.1.4
org.cactoos : cactoos jar 0.46
org.slf4j : slf4j-log4j12 jar 1.8.0-beta0
log4j : log4j jar 1.2.17
com.artipie : vertx-server jar 0.3.2
com.artipie : files-adapter jar 0.5
org.junit.jupiter : junit-jupiter-params jar 5.7.1
org.testcontainers : testcontainers jar 1.15.2
org.testcontainers : junit-jupiter jar 1.15.2

Project Modules

There are no modules declared in this project.

EO principles respected here DevOps By Rultor.com We recommend IntelliJ IDEA

Build Status Javadoc License Hits-of-Code Maven Central PDD status

This Java library turns your binary ASTO storage into a PHP Composer repository.

Similar solutions:

Some valuable references:

Getting started

This is the dependency you need:

<dependency>
  <groupId>com.artipie</groupId>
  <artifactId>composer-adapter</artifactId>
  <version>[...]</version>
</dependency>

Save PHP Composer package JSON file like composer.json (particular name does not matter) to ASTO storage.

import com.artipie.asto.*;
Storage storage = new FileStorage(Path.of("/path/to/storage"));
storage.save(
    new Key.From("composer.json"), 
    Files.readAllBytes(Path.of("/my/files/composer.json"))
);

Then, make an instance of Repository class with storage as an argument. Finally, instruct Repository to add the package to repository:

import com.artipie.composer.*;
Repository repo = new Repository(storage);
repo.add(new Key.From("composer.json"));

After that package metadata could be accessed by it's name:

Packages packages = repo.packages(new Name("vendor/package"));

Read the Javadoc for more technical details.

Project status

  • Adding package to repository #1
  • HTTP support for adding package as composer.json #22
  • HTTP support for getting package metadata #24
  • HTTP support for adding package as ZIP archive #23

Composer repository structure

Composer has the following repository structure:

(repository root) 
| -packages.json
| +-vendor
  | -composer.json
  | -composer.lock
  | +-some_vendor
  | | +-package_name
  | | | -files_for_package_name  
  | -autoload.php
  | +-composer
  | | -files_for_composer

composer.lock file is generated automatically. It is necessary for installing packages of specified versions. If it does not exist, it will be generated after calling the command composer install automatically according to composer.json file.
By calling the command composer update composer.lock will be automatically updated according to existing composer.json.

Content of composer.json

There are required packages in this file with specified version. For example, this file. Also, in this file the type of repository could be defined. There are several types of repositories, but it is necessary to pay attention to composer and artifact repositores. Example of composer.json file for composer repository:

{
  "repositories": [ 
    {
      "type": "composer",
      "url": "http://central.artipie.com/"
    },
    {
      "packagist.org": false
    }
  ],
  "require": { 
    "psr/log": "1.1.3" 
  }
}

Example of composer.json file for artifact repository:

{
  "repositories": [ 
    {
      "type": "artifact",
      "url": "path/to/directory/with/zips/"
    },
    {
      "packagist.org": false
    }
  ],
  "require": { 
    "psr/log": "1.1.3" 
  }
}

Packages index file

The only required field is package. An example of JSON file:

{
  "packages": {
    "vendor/package-name": {
      "0.0.1": { 
        "name (required)": "vendor/package-name",
        "version (required)": "0.0.1",
        "dist (required)": {
          "url": "https://host:port/path/vendor/package-name-0.0.1.zip",
          "type": "zip"
        } 
      },
      "1.0.0": { "similar structure": "" }
    }
  }
}

So, information about a specific version of package is obtained from remote source by specifying url.

How to contribute

Fork repository, make changes, send us a pull request. We will review your changes and apply them to the master branch shortly, provided they don't violate our quality standards. To avoid frustration, before sending us your pull request please run full Maven build:

$ mvn clean install -Pqulice

To avoid build errors use Maven 3.2+.

com.artipie

Artipie

Binary Artifact Management Toolkit

Versions

Version
1.0
0.3.7
0.2
0.1
v1.0.1