satis: "Your package name My Repository is invalid": bug or breaking change?

Hello,

Using the satis.json from the docs at https://getcomposer.org/doc/articles/handling-private-packages.md#setup :

{
  "name": "My Repository",
  "homepage": "http://packages.example.org",
  "repositories": [
    { "type": "vcs", "url": "https://github.com/mycompany/privaterepo" },
    { "type": "vcs", "url": "http://svn.example.org/private/repo" },
    { "type": "vcs", "url": "https://github.com/mycompany/privaterepo2" }
  ],
  "require-all": true
}

And the latest container tag:

Digest: sha256:0f6cb23de613edf42bfe4da17333b5ada6bb99e21c20324ed91db5f13bb9e744
Status: Downloaded newer image for composer/satis:latest

I get this error:

docker run --rm --init -it \
  --user $(id -u):$(id -g) \
  --volume $(pwd):/build \
  composer/satis build satis.json foo

In RootPackageLoader.php line 76:
                                                                                                                                                                                                           
  Your package name My Repository is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package name can be words separated by -, . or _. The complete name shoul  
  d match "^[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9](([_.]?|-{0,2})[a-z0-9]+)*$".                                                                                                                               
                                                                                                                                                                                                           

build [--repository-url [REPOSITORY-URL]] [--repository-strict] [--no-html-output] [--skip-errors] [--stats] [--] [<file> [<output-dir> [<packages>...]]]

Is this a bug or a breaking change?

Cheers!

About this issue

  • Original URL
  • State: open
  • Created 3 years ago
  • Comments: 17 (9 by maintainers)

Commits related to this issue

Most upvoted comments

I’ve applied this patch to our local Satis:


From b122c20bb36c2dc3da8a92ab07f6d4a7329e6a40 Mon Sep 17 00:00:00 2001
From: Sean <snip@snip.com>
Date: Wed, 14 Jul 2021 10:31:00 -0700
Subject: [PATCH] fix(web): move the "name" property to "repository-name",
 allow pretty names with Composer v2

---
 res/satis-schema.json                |  4 ++--
 src/Builder/WebBuilder.php           | 20 ++++++++++++++++----
 src/Console/Command/BuildCommand.php |  1 +
 3 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/res/satis-schema.json b/res/satis-schema.json
index 7985852..e63f961 100644
--- a/res/satis-schema.json
+++ b/res/satis-schema.json
@@ -3,9 +3,9 @@
     "name": "Repository Configuration",
     "type": "object",
     "additionalProperties": false,
-    "required": [ "name", "homepage" ],
+    "required": [ "repository-name", "homepage" ],
     "properties": {
-        "name": {
+        "repository-name": {
             "type": "string",
             "description": "Repository name."
         },
diff --git a/src/Builder/WebBuilder.php b/src/Builder/WebBuilder.php
index f8a82e0..97f63aa 100644
--- a/src/Builder/WebBuilder.php
+++ b/src/Builder/WebBuilder.php
@@ -29,6 +29,8 @@ class WebBuilder extends Builder
     private $dependencies;
     /** @var Environment */
     private $twig;
+    /** @var string|null */
+    private $repositoryName = null;
     /** @var string[string] The labels for the fields to toggle on the front end */
     private $fieldsToToggle = [
         'description' => 'Description',
@@ -46,10 +48,13 @@ public function dump(array $packages): void
     {
         $mappedPackages = $this->getMappedPackageList($packages);
 
-        $name = $this->rootPackage->getPrettyName();
-        if ('__root__' === $name) {
-            $name = 'A';
-            $this->output->writeln('Define a "name" property in your json config to name the repository');
+        $name = $this->repositoryName;
+        if ($name === null) {
+            $name = $this->rootPackage->getPrettyName();
+            if ('__root__' === $name) {
+                $name = 'A';
+                $this->output->writeln('Define a "name" property in your json config to name the repository');
+            }
         }
 
         if (!$this->rootPackage->getHomepage()) {
@@ -134,6 +139,13 @@ private function setDependencies(array $packages): self
         return $this;
     }
 
+    public function setRepositoryName(?string $repositoryName): self
+    {
+        $this->repositoryName = $repositoryName;
+
+        return $this;
+    }
+
     /**
      * Gets a list of packages grouped by name with a list of versions.
      *
diff --git a/src/Console/Command/BuildCommand.php b/src/Console/Command/BuildCommand.php
index 472ada4..70ab724 100644
--- a/src/Console/Command/BuildCommand.php
+++ b/src/Console/Command/BuildCommand.php
@@ -217,6 +217,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
         if ($htmlView) {
             $web = new WebBuilder($output, $outputDir, $config, $skipErrors);
             $web->setRootPackage($composer->getPackage());
+            $web->setRepositoryName($config['repository-name'] ?? null);
             $web->dump($packages);
         }
 
-- 
2.32.0

This is especially confusing since the linked docs still show a non-package-valid name:

https://getcomposer.org/doc/articles/handling-private-packages.md