-
Notifications
You must be signed in to change notification settings - Fork 520
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
"Your package name My Repository is invalid": bug or breaking change? #656
Comments
Here's the latest working version I've pulled: composer/satis@sha256:a73607b8588f306e307a69449f08342570c807b3afa6aa290f045bd99a1cb5f6
|
Seems related to #526 , composer/composer@5c4ef1e |
Repository names seem to have the same requirement as package names, and composer v2 is enforcing this. So no freestyle names anymore. |
I think it is too much work to work around that requirement. So if it is a blocker for you, I recommend you stick to running an older version of satis (e.g. the |
I had same problem.. after fixing the name, another error appeared: #655 (no solution yet) |
@alcohol One idea to "work around" the requirement is simply to create formatting rules for displaying the package name. For example:
|
Uhm.. not sure I follow. The problem is that some users have a
This name is not allowed in this format anymore with Composer 2.0, it has to follow the |
Using your example:
The user would reformat their Does that help? |
Yeah, okay. I get it. But that seems like a lot of work for something that does not even directly address the original issue. The original issue is that the |
Is there anywhere else that the
You're correct. But, again if I'm not mistaken, this is a composer issue and not something that satis can address. So while the user will still have to change the package name, it at least gives them some structure that they can use to achieve a reasonable title/header for their web portal. And to reiterate, it's a suggestion for your consideration. I certainly didn't mean to cause any confusion. :) |
I tried to verify that the satis package name is really used somewhere as an identifier inside the created repository metadata, but I had no luck finding it. Seems like the Composer part inside is treating it as a package name somewhere, but not putting it into the metadata output. Maybe there is a way to avoid passing in to Composer? Or work around the validation any other way. I'd not propose this if the value is actually used in the metadata, but if so: Where? |
I've applied this patch to our local Satis: From b122c20bb36c2dc3da8a92ab07f6d4a7329e6a40 Mon Sep 17 00:00:00 2001
From: Sean <[email protected]>
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
|
We use the config component from Composer to parse the configuration, since the format is quite similar. But Composer treats it as a root package json file. Hence the requirement that name is a valid package name. |
@AlbinoDrought if you would be willing to submit a PR, I will happily merge it :-) |
This is especially confusing since the linked docs still show a non-package-valid name: https://getcomposer.org/doc/articles/handling-private-packages.md |
That documentation is quite out of sync and outdated. It is open source documentation ;-) |
One could make this work again by dropping/faking the name attribute when pushing the config array into the composer instance. However I would prefer if both formats would be more compatible and satis would put its attributes into the extra or config section of a valid composer.json file. Interested in a patch? |
Hello,
Using the satis.json from the docs at https://getcomposer.org/doc/articles/handling-private-packages.md#setup :
And the latest container tag:
I get this error:
Is this a bug or a breaking change?
Cheers!
The text was updated successfully, but these errors were encountered: