Closed i3or1s closed 2 years ago
The README.md should not have the contents of composer.json.
Are you able to create a reproducible example?
Thank you for responding, it looked strange to me. I literally only ran the command and fill out the answers. I tried it three times and got the same result. If you don't know it from the top of your head I can look into it.
Steps to reproduce:
$ composer create-project ramsey/php-library-starter-kit testingLib
Are you ready to get started? (yes/no) [no]:
> yes
What is the GitHub username or org name for your package?:
> i3or1s
What is your package vendor name? [i3or1s]:
>
What is your package name? [i3or1s/testinglib]:
>
Enter a brief description of your library:
> testing library README
What is your name? [Boris Vujicic]:
>
What is your email address? [boris.vujicic@example.com]:
> boris.vujicic@example.com
What is your website address?:
>
Are you the copyright holder? (yes/no) [yes]:
>
What is the copyright year? [2022]:
>
Choose a license for your project [Proprietary]:
[1 ] Proprietary
[2 ] Apache License 2.0
[3 ] BSD 2-Clause "Simplified" License
[4 ] BSD 3-Clause "New" or "Revised" License
[5 ] Creative Commons Zero v1.0 Universal
[6 ] GNU Affero General Public License v3.0 or later
[7 ] GNU General Public License v3.0 or later
[8 ] GNU Lesser General Public License v3.0 or later
[9 ] Hippocratic License 2.1
[10] MIT License
[11] MIT No Attribution
[12] Mozilla Public License 2.0
[13] Unlicense
> 10
Do you want to include a security policy? (yes/no) [yes]:
> yes
What email address should researchers use to submit vulnerability reports?:
> boris.vujicic@example.com
At what URL should researchers submit vulnerability reports?:
>
Choose a code of conduct for your project [None]:
[1] None
[2] Contributor Covenant Code of Conduct, version 1.4
[3] Contributor Covenant Code of Conduct, version 2.0
[4] Citizen Code of Conduct, version 2.3
> 2
What email address should people use to report code of conduct issues?:
> boris.vujicic@example.com
Enter a set of comma-separated keywords describing your library:
> test,README
What is the library's root namespace? [I3or1s\Testinglib]:
>
Renaming template files
-----------------------
- Renaming '/srv/vhosts/testingLib/.gitattributes.template' to '/srv/vhosts/testingLib/.gitattributes'.
Updating composer.json
----------------------
Updating README.md
------------------
Updating license and copyright information
------------------------------------------
Updating source file headers
----------------------------
Updating namespace
------------------
Updating SECURITY.md
--------------------
Updating CODE_OF_CONDUCT.md
---------------------------
Updating CHANGELOG.md
---------------------
Updating CONTRIBUTING.md
------------------------
Updating .github/FUNDING.yml
----------------------------
Installing dependencies
-----------------------
Thanks! I'll run through it with exactly your answers and see if I can reproduce it.
Couple more data points, please...
Distributor ID: Ubuntu
Description: Ubuntu 18.04.6 LTS
Release: 18.04
Codename: bionic
PHP 7.4.27 (cli) (built: Dec 20 2021 21:27:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.27, Copyright (c), by Zend Technologies
with Xdebug v3.1.2, Copyright (c) 2002-2021, by Derick Rethans
I think I have located the error.
Apparently, Finder ->name('README.md');
just appends to the list.
Since you are using the same instance of a Finder it takes the name from the previous task wich is composer.json
and finds that file first.
LibraryStarterKit\Task\Build::getBuilders()
First goes composer after that is readme.
Line of code that is the issue LibraryStarterKit/Task/Builder/UpdateReadme::getReadmeContents()
This Finder is actually the same one as in Composer task.
I have checked Finder and there seems not to be a way to clear it, perhaps just to re-instantiate it. Since it is a private function that relies on dependency which is influenced from the outside (referencing finder here) I would move the finder to arguments and pass in the new instance of the finder, or just simply create a new instance of the finder.
I can make a PR with the proposed fix if this sounds good to you?
Before you open a PR, I want to look into this a bit more. I could have sworn I was creating a new instance of the Finder each time getFinder()
is called, so I'm a little confused right now. 🙂
Clearly, that's a bug, but I don't understand why it's just now showing up. I haven't been able to try the steps to reproduce yet.
One more question. Can you list the output of composer show
here? I want to rule out changes to the behavior of any dependencies, as well.
$this
is given in the constructor for each build task and $this->getEnvironment()->getFinder();
just returns the same instance, while name
function just appends to the list.
public function name($patterns)
{
$this->names = array_merge($this->names, (array) $patterns);
return $this;
}
amphp/amp v2.6.1
amphp/byte-stream v1.8.1
captainhook/captainhook 5.10.6
captainhook/plugin-composer 5.3.2
clue/stream-filter v1.5.0
composer/ca-bundle 1.3.1
composer/composer 2.2.4
composer/metadata-minifier 1.0.0
composer/package-versions-deprecated 1.11.99.4
composer/pcre 1.0.0
composer/semver 3.2.7
composer/spdx-licenses 1.5.6
composer/xdebug-handler 2.0.4
dealerdirect/phpcodesniffer-composer-installer v0.7.1
dnoegel/php-xdg-base-dir v0.1.1
doctrine/instantiator 1.4.0
ergebnis/composer-normalize 2.23.0
ergebnis/json-normalizer 2.1.0
ergebnis/json-printer 3.2.0
ergebnis/json-schema-validator 2.0.0
felixfbecker/advanced-json-rpc v3.2.1
felixfbecker/language-server-protocol 1.5.1
guzzlehttp/guzzle 7.4.1
guzzlehttp/promises 1.5.1
guzzlehttp/psr7 2.1.0
hamcrest/hamcrest-php v2.0.1
jawira/case-converter v3.4.6
justinrainbow/json-schema 5.2.11
knplabs/github-api v3.4.0
laminas/laminas-diactoros 2.8.0
localheinz/diff 1.1.1
m4tthumphrey/php-gitlab-api 11.5.0
madewithlove/license-checker v0.10.0
mockery/mockery 1.4.4
myclabs/deep-copy 1.10.2
netresearch/jsonmapper v4.0.0
nikic/php-parser v4.13.2
openlss/lib-array2xml 1.0.0
opis/json-schema 2.3.0
opis/string 2.0.0
opis/uri 1.1.0
pds/skeleton 1.0.0
phar-io/manifest 2.0.3
phar-io/version 3.1.0
phly/keep-a-changelog 2.11.0
php-http/cache-plugin 1.7.4
php-http/client-common 2.5.0
php-http/discovery 1.14.1
php-http/guzzle7-adapter 0.1.1
php-http/httplug 2.2.0
php-http/message 1.12.0
php-http/message-factory v1.0.2
php-http/multipart-stream-builder 1.2.0
php-http/promise 1.1.0
php-parallel-lint/php-console-color v0.3
php-parallel-lint/php-console-highlighter v0.5
php-parallel-lint/php-parallel-lint v1.3.1
phpcsstandards/phpcsextra 1.0.0-alpha3
phpcsstandards/phpcsutils 1.0.0-alpha3
phpdocumentor/reflection-common 2.2.0
phpdocumentor/reflection-docblock 5.3.0
phpdocumentor/type-resolver 1.6.0
phpspec/prophecy v1.15.0
phpstan/extension-installer 1.1.0
phpstan/phpdoc-parser 1.2.0
phpstan/phpstan 1.3.3
phpstan/phpstan-mockery 1.0.0
phpstan/phpstan-phpunit 1.0.0
phpunit/php-code-coverage 9.2.10
phpunit/php-file-iterator 3.0.6
phpunit/php-invoker 3.1.1
phpunit/php-text-template 2.0.4
phpunit/php-timer 5.0.3
phpunit/phpunit 9.5.11
psalm/plugin-mockery 0.9.1
psalm/plugin-phpunit 0.16.1
psr/cache 1.0.1
psr/container 1.1.2
psr/event-dispatcher 1.0.0
psr/http-client 1.0.1
psr/http-factory 1.0.1
psr/http-message 1.0.1
psr/log 1.1.4
psy/psysh v0.11.1
ralouphie/getallheaders 3.0.3
ramsey/coding-standard 2.0.3
ramsey/composer-repl 1.3.0
ramsey/conventional-commits 1.3.0
ramsey/devtools 1.7.1
ramsey/devtools-lib 1.3.0
react/promise v2.8.0
roave/security-advisories dev-latest 11696ae
sebastian/cli-parser 1.0.1
sebastian/code-unit 1.0.8
sebastian/code-unit-reverse-lookup 2.0.3
sebastian/comparator 4.0.6
sebastian/complexity 2.0.2
sebastian/diff 4.0.4
sebastian/environment 5.1.3
sebastian/exporter 4.0.4
sebastian/global-state 5.0.3
sebastian/lines-of-code 1.0.3
sebastian/object-enumerator 4.0.4
sebastian/object-reflector 2.0.4
sebastian/recursion-context 4.0.4
sebastian/resource-operations 3.0.3
sebastian/type 2.3.4
sebastian/version 3.0.2
sebastianfeldmann/camino 0.9.5
sebastianfeldmann/cli 3.4.1
sebastianfeldmann/git 3.8.1
seld/jsonlint 1.8.3
seld/phar-utils 1.2.0
slevomat/coding-standard 7.0.18
squizlabs/php_codesniffer 3.6.2
symfony/console v5.4.2
symfony/deprecation-contracts v2.5.0
symfony/filesystem v5.4.0
symfony/finder v5.4.2
symfony/options-resolver v5.4.0
symfony/polyfill-ctype v1.24.0
symfony/polyfill-intl-grapheme v1.24.0
symfony/polyfill-intl-normalizer v1.24.0
symfony/polyfill-mbstring v1.24.0
symfony/polyfill-php73 v1.24.0
symfony/polyfill-php80 v1.24.0
symfony/process v5.4.2
symfony/service-contracts v2.5.0
symfony/string v5.4.2
symfony/var-dumper v5.4.2
symfony/yaml v5.4.2
theseer/tokenizer 1.2.1
vimeo/psalm 4.18.1
webmozart/assert 1.10.0
webmozart/path-util 2.3.0
Another solution would be to fix the part of the Setup class to always return a new instance of a finder?
return $this->finder::create();
https://github.com/ramsey/php-library-starter-kit/blob/cd29fbb6bbec4951006cfcc9472a0de52e0f6c21/src/LibraryStarterKit/Setup.php#L94
Hi, did you have time to look into it?
Reminder - I have found two sensible solutions so far.
@i3or1s I chose to use your ::create()
suggestion. Thanks!
I've just released version 3.4.2 with this fix.
I was trying out the library with
composer create-project ramsey/php-library-starter-kit contracts
to generate a new structure. I have answered the questions in the prompt (i did not provide a file with answers). What I ended up with is README.md file that has the contents of a composer.json file. Is this intended?Note: I was looking at the src/LibraryStarterKit/Task/Builder/UpdateReadme.php and it seems to me that behavior should be different.