# @digitalist-net-services/plugin-composer-packages

> This plugins purpouse is to show packages, modules, libraries etc. from a composer.lock file.

Latest version **0.1.13** (published 2021-11-20) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install @digitalist-net-services/plugin-composer-packages
pnpm add @digitalist-net-services/plugin-composer-packages
yarn add @digitalist-net-services/plugin-composer-packages
bun add @digitalist-net-services/plugin-composer-packages
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.13 |
| Published | 2021-11-20 |
| First published | 2021-10-20 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 12 |
| Unpacked size | 23.3 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | ewert-the-dragon |
| Keywords | backstage, composer-packages |

## Links

- npm: https://www.npmjs.com/package/@digitalist-net-services/plugin-composer-packages
- Repository: https://github.com/digitalist-se/backstage-plugin-composer-packages
- Homepage: https://github.com/digitalist-se/backstage-plugin-composer-packages#readme
- Issues: https://github.com/digitalist-se/backstage-plugin-composer-packages/issues
- npm.io page: https://npm.io/package/@digitalist-net-services/plugin-composer-packages

## Dependencies (12)

- [react](https://npm.io/package/react.md) ^17.0.2
- [react-dom](https://npm.io/package/react-dom.md) ^17.0.2
- [react-use](https://npm.io/package/react-use.md) ^17.3.1
- [meilisearch](https://npm.io/package/meilisearch.md) ^0.22.3
- [@backstage/theme](https://npm.io/package/@backstage/theme.md) ^0.2.13
- [@material-ui/lab](https://npm.io/package/@material-ui/lab.md) 4.0.0-alpha.60
- [@material-ui/core](https://npm.io/package/@material-ui/core.md) ^4.12.3
- [@material-ui/icons](https://npm.io/package/@material-ui/icons.md) ^4.11.2
- [@backstage/catalog-model](https://npm.io/package/@backstage/catalog-model.md) ^0.9.7
- [@backstage/core-components](https://npm.io/package/@backstage/core-components.md) ^0.7.4
- [@backstage/core-plugin-api](https://npm.io/package/@backstage/core-plugin-api.md) ^0.2.0
- [@backstage/plugin-catalog-react](https://npm.io/package/@backstage/plugin-catalog-react.md) ^0.6.4

## Recent versions

- 0.1.13 (latest) — 2021-11-20
- 0.1.12 — 2021-10-30
- 0.1.11 — 2021-10-30
- 0.1.10 — 2021-10-20

## README

# Composer packages

This plugins purpouse is to show packages, modules,
libraries etc. from a composer.lock file.

It's dependent on a external index of packages, modules,
libraries etc. in [Mielesearch](https://www.meilisearch.com/).

See example in the end how you could create an index in Mielesearch,
and use jq and uuidgen for extracting information from a composer.lock
file.

## Config

```yaml
composerpackages:
  index: 'modules'
  url: 'https://meilisearch.url'
  apikey: '2FXWwAope4nJroSD'
```

This configuration is a must.

## Getting started

All composer packages in you projects are avaible from route: `composer-packages`.

To add which packages are in your project you need to use annotation:
`'packagist.org/composer-packages-site'`. Where the identfier is the project
you added to the index, `example-com`, `example.com` or whatever standard you
want to use.

To show the it, as an example, add to `packages/app/src/components/catalog/EntityPage.tsx`:

```typescript
import {
  EntityComposerPackagesContent,
  iscomposerPackagesAvailable,
} from '@digitalist-net-services/plugin-composer-packages';
```

```typescript
const serviceEntityPage = (
<EntityLayout>
  ...
    <EntityLayout.Route if={iscomposerPackagesAvailable} path="/composer-packages" title="Composer Packages">
        <EntityComposerPackagesContent />
    </EntityLayout.Route>
    ...
</EntityLayout>
```

## Mielesearch

## Example of creation of the index

First you need an instance of Mielesearch up (doh!), and then create the index.
(the index is named modules in `app-confi.yaml` so we are using it here)

```bash
curl \
  --header "X-Meili-API-Key: ${MEILIAPIKEY}" \
  -X POST "${MEILIURL}/indexes/modules/documents" \
  -H 'Content-Type: application/json'
```

Set filter attributes:

```bash
curl \
  --header "X-Meili-API-Key: ${MEILIAPIKEY}" \
  -X POST "${MEILIURL}/indexes/modules/settings" \
  -H 'Content-Type: application/json' \
  --data-binary '{ "filterableAttributes": [ "name", "version", "type", "site" ]}'
```

## Update index

MeiliSearch does not yet support updating indexes, just deletion, so to later update, you need to delete it first, and then resend all the documents:

```bash
curl \
  --header "X-Meili-API-Key: ${MEILIAPIKEY}" \
  -X DELETE "${MEILIURL}/indexes/modules"
```

## Example usage

### Gitlab runner.

```yaml
stages:
  - collect
  - upload

module_collection:
  stage: collect
  rules:
    - if: $NIGHTLY == "true"
      when: never
    - if: $CI_COMMIT_BRANCH == "module_scan"
      when: always
  image:
    name: ozziio/jq:0.1 #or any image with jq and uuidgen
    entrypoint:
      - ''
  script:
    - .ci/modules_report.sh > modules.json
  artifacts:
    expire_in: 120 min
    paths:
      - 'modules.json'
module_upload:
  stage: upload
  rules:
    - if: $NIGHTLY == "true"
      when: never
    - if: $CI_COMMIT_BRANCH == "module_scan"
      when: always
  image:
    name: curlimages/curl:7.79.1
    entrypoint:
      - ''
  script:
    - sh .ci/uplod_modules_report.sh
  artifacts:
    expire_in: 120 min
    paths:
      - 'modules.json'
```

```bash
# .ci/modules_report.sh

export SITE=$CI_PROJECT_NAME

jq -nR --argfile input $CI_PROJECT_DIR/composer.lock '
  $input
  | .packages[]
  | {site: env.SITE, name: .name, version: .version, type: .type, id: input}
 ' < <(while true; do uuidgen; done)| jq -s
```

```bash
# .ci/uplod_modules_report.sh


curl \
  -X POST "${MEILIURL}/indexes/modules/documents" \
  --data @modules.json \
  --header "X-Meili-API-Key: ${MEILIAPIKEY}"

```

---
_Source: https://npm.io/package/@digitalist-net-services/plugin-composer-packages · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
