Skip to content

Commit 9a9fefe

Browse files
committed
prettier
1 parent 187b1d7 commit 9a9fefe

14 files changed

+833
-726
lines changed

.coverage/cobertura.xml

Lines changed: 689 additions & 655 deletions
Large diffs are not rendered by default.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
Please do not submit any Pull Requests here. They will be closed.
2-
---
1+
## Please do not submit any Pull Requests here. They will be closed.
32

43
Please submit your PR here instead:
54
https://github.com/valksor/php-dev

Binary/BinaryAssetManager.php

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ final class BinaryAssetManager
6060
* source: 'github'|'npm'|'github-zip',
6161
* repo?: string,
6262
* npm_package?: string,
63+
* npm_dist_tag?: string,
6364
* assets: array<int,array{pattern:string,target:string,executable:bool,extract_path?:string}>,
6465
* target_dir: string,
6566
* version_in_path?: bool,
@@ -289,8 +290,19 @@ private function downloadNpmAsset(
289290
): void {
290291
$assetConfig = $this->toolConfig['assets'][0];
291292
$platform = self::detectPlatform();
292-
$npmPackage = sprintf('@esbuild/%s', $platform);
293-
$url = sprintf('https://registry.npmjs.org/%s/-/%s-%s.tgz', $npmPackage, $platform, $version);
293+
294+
// Use the actual npm package from configuration instead of hardcoded @esbuild
295+
$npmPackage = $this->toolConfig['npm_package'];
296+
297+
// For scoped packages (@scope/package), use the correct URL format
298+
if (str_starts_with($npmPackage, '@')) {
299+
$scope = substr($npmPackage, 0, strpos($npmPackage, '/'));
300+
$packageName = substr($npmPackage, strpos($npmPackage, '/') + 1);
301+
$url = sprintf('https://registry.npmjs.org/%s/-/%s-%s.tgz', $npmPackage, $packageName, $version);
302+
} else {
303+
// For regular packages, download the full package
304+
$url = sprintf('https://registry.npmjs.org/%s/-/%s-%s.tgz', $npmPackage, $npmPackage, $version);
305+
}
294306

295307
$context = stream_context_create([
296308
'http' => [
@@ -321,22 +333,34 @@ private function downloadNpmAsset(
321333
$extractDir = $tmpDir . '/extracted';
322334
$this->ensureDirectory($extractDir);
323335

324-
exec(sprintf('tar -xzf %s -C %s %s 2>&1', escapeshellarg($tgzPath), escapeshellarg($extractDir), escapeshellarg($extractPath)), $output, $returnCode);
336+
// Extract the entire tarball
337+
exec(sprintf('tar -xzf %s -C %s 2>&1', escapeshellarg($tgzPath), escapeshellarg($extractDir)), $output, $returnCode);
325338

326339
if (0 !== $returnCode) {
327340
throw new RuntimeException(sprintf('Failed to extract %s tarball: %s', $this->toolConfig['name'], implode("\n", $output)));
328341
}
329342

330-
$extractedBinary = $extractDir . '/' . $extractPath;
331-
332-
if (!is_file($extractedBinary)) {
333-
throw new RuntimeException(sprintf('Extracted binary not found at %s', $extractedBinary));
334-
}
335-
343+
// Handle both file and directory extraction
344+
$sourcePath = $extractDir . '/' . $extractPath;
336345
$targetPath = $targetDir . '/' . $assetConfig['target'];
337346

338-
if (!rename($extractedBinary, $targetPath)) {
339-
throw new RuntimeException(sprintf('Failed to move %s binary to %s', $this->toolConfig['name'], $targetPath));
347+
// If target is '.', copy the entire extracted directory
348+
if ('.' === $assetConfig['target']) {
349+
// Copy entire extracted directory contents to target
350+
exec(sprintf('cp -r %s/* %s/ 2>&1', escapeshellarg($sourcePath), escapeshellarg($targetDir)), $output, $returnCode);
351+
352+
if (0 !== $returnCode) {
353+
throw new RuntimeException(sprintf('Failed to copy %s package: %s', $this->toolConfig['name'], implode("\n", $output)));
354+
}
355+
} else {
356+
// Original behavior: move specific file
357+
if (!is_file($sourcePath)) {
358+
throw new RuntimeException(sprintf('Extracted binary not found at %s', $sourcePath));
359+
}
360+
361+
if (!rename($sourcePath, $targetPath)) {
362+
throw new RuntimeException(sprintf('Failed to move %s binary to %s', $this->toolConfig['name'], $targetPath));
363+
}
340364
}
341365

342366
if ($assetConfig['executable']) {
@@ -410,7 +434,8 @@ private function fetchLatestCommit(): array
410434
*/
411435
private function fetchLatestNpmVersion(): array
412436
{
413-
$packageUrl = sprintf('https://registry.npmjs.org/%s/latest', $this->toolConfig['npm_package']);
437+
$distTag = $this->toolConfig['npm_dist_tag'] ?? 'latest';
438+
$packageUrl = sprintf('https://registry.npmjs.org/%s/%s', $this->toolConfig['npm_package'], $distTag);
414439

415440
$context = stream_context_create([
416441
'http' => [

Binary/BinaryInterface.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ interface BinaryInterface
2626
/**
2727
* Create a configured BinaryAssetManager for this tool.
2828
*
29-
* @param string $varDir The base var directory (e.g., /path/to/project/var)
29+
* @param string $varDir The base var directory (e.g., /path/to/project/var)
30+
* @param string $requestedName The actual binary name requested (e.g., '@valksor/valksor@next')
3031
*
3132
* @return BinaryAssetManager Configured manager ready to download/ensure the binary
3233
*/
3334
public function createManager(
3435
string $varDir,
36+
?string $requestedName = null,
3537
): BinaryAssetManager;
3638

3739
/**

Binary/BinaryRegistry.php

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function __construct(
4646
/**
4747
* Get a provider by binary name.
4848
*
49-
* @param string $name The binary name (e.g., 'tailwindcss')
49+
* @param string $name The binary name (e.g., 'tailwindcss', '@valksor/valksor@next')
5050
*
5151
* @return BinaryInterface The registered provider
5252
*
@@ -59,7 +59,17 @@ public function get(
5959
throw new RuntimeException(sprintf('No binary provider registered for: %s', $name));
6060
}
6161

62-
return $this->providers[$name];
62+
// Direct match first
63+
if (isset($this->providers[$name])) {
64+
return $this->providers[$name];
65+
}
66+
67+
// For @valksor/valksor packages, return the base provider
68+
if (str_starts_with($name, '@valksor/valksor')) {
69+
return $this->providers['@valksor/valksor'];
70+
}
71+
72+
throw new RuntimeException(sprintf('No binary provider registered for: %s', $name));
6373
}
6474

6575
/**
@@ -75,14 +85,24 @@ public function getAvailableNames(): array
7585
/**
7686
* Check if a provider is registered for the given binary name.
7787
*
78-
* @param string $name The binary name (e.g., 'tailwindcss')
88+
* @param string $name The binary name (e.g., 'tailwindcss', '@valksor/valksor@next')
7989
*
8090
* @return bool True if provider exists
8191
*/
8292
public function has(
8393
string $name,
8494
): bool {
85-
return isset($this->providers[$name]);
95+
// Direct match first
96+
if (isset($this->providers[$name])) {
97+
return true;
98+
}
99+
100+
// For @valksor/valksor packages, check for base provider
101+
if (str_starts_with($name, '@valksor/valksor')) {
102+
return isset($this->providers['@valksor/valksor']);
103+
}
104+
105+
return false;
86106
}
87107

88108
/**

Binary/DaisyUiBinary.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ final class DaisyUiBinary implements BinaryInterface
1919
{
2020
public function createManager(
2121
string $varDir,
22+
?string $requestedName = null,
2223
): BinaryAssetManager {
2324
return self::createForDaisyUi($varDir . '/daisyui');
2425
}

Binary/EsbuildBinary.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ final class EsbuildBinary implements BinaryInterface
1919
{
2020
public function createManager(
2121
string $varDir,
22+
?string $requestedName = null,
2223
): BinaryAssetManager {
2324
return self::createForEsbuild($varDir . '/esbuild');
2425
}

Binary/LucideBinary.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ final class LucideBinary implements BinaryInterface
1919
{
2020
public function createManager(
2121
string $varDir,
22+
?string $requestedName = null,
2223
): BinaryAssetManager {
2324
return self::createForLucide($varDir . '/lucide');
2425
}

Binary/TailwindBinary.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ final class TailwindBinary implements BinaryInterface
2121
{
2222
public function createManager(
2323
string $varDir,
24+
?string $requestedName = null,
2425
): BinaryAssetManager {
2526
return self::createForTailwindCss($varDir . '/tailwindcss');
2627
}

CODE_OF_CONDUCT.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,24 @@ diverse, inclusive, and healthy community.
1616
Examples of behavior that contributes to a positive environment for our
1717
community include:
1818

19-
* Demonstrating empathy and kindness toward other people
20-
* Being respectful of differing opinions, viewpoints, and experiences
21-
* Giving and gracefully accepting constructive feedback
22-
* Accepting responsibility and apologizing to those affected by our mistakes,
19+
- Demonstrating empathy and kindness toward other people
20+
- Being respectful of differing opinions, viewpoints, and experiences
21+
- Giving and gracefully accepting constructive feedback
22+
- Accepting responsibility and apologizing to those affected by our mistakes,
2323
and learning from the experience
24-
* Focusing on what is best not just for us as individuals, but for the overall
24+
- Focusing on what is best not just for us as individuals, but for the overall
2525
community
2626

2727
Examples of unacceptable behavior include:
2828

29-
* The use of sexualized language or imagery, and sexual attention or advances
29+
- The use of sexualized language or imagery, and sexual attention or advances
3030
of any kind
31-
* Trolling, insulting or derogatory comments, and personal or political
31+
- Trolling, insulting or derogatory comments, and personal or political
3232
attacks
33-
* Public or private harassment
34-
* Publishing others’ private information, such as a physical or email address,
33+
- Public or private harassment
34+
- Publishing others’ private information, such as a physical or email address,
3535
without their explicit permission
36-
* Other conduct which could reasonably be considered inappropriate in a
36+
- Other conduct which could reasonably be considered inappropriate in a
3737
professional setting
3838

3939
## Enforcement Responsibilities
@@ -71,13 +71,15 @@ determining the consequences for any action they deem in violation of this
7171
Code of Conduct:
7272

7373
### 1. Correction
74+
7475
**Community Impact**: Use of inappropriate language or other behavior deemed
7576
unprofessional or unwelcome in the community.
7677
**Consequence**: A private, written warning from community leaders,
7778
providing clarity around the nature of the violation and an explanation of why
7879
the behavior was inappropriate. A public apology may be requested.
7980

8081
### 2. Warning
82+
8183
**Community Impact**: A violation through a single incident or series of
8284
actions.
8385
**Consequence**: A warning with consequences for continued behavior. No
@@ -88,6 +90,7 @@ like social media. Violating these terms may lead to a temporary or permanent
8890
ban.
8991

9092
### 3. Temporary Ban
93+
9194
**Community Impact**: A serious violation of community standards, including
9295
sustained inappropriate behavior.
9396
**Consequence**: A temporary ban from any sort of interaction or public
@@ -97,6 +100,7 @@ with those enforcing the Code of Conduct, is allowed during this period.
97100
Violating these terms may lead to a permanent ban.
98101

99102
### 4. Permanent Ban
103+
100104
**Community Impact**: Demonstrating a pattern of violation of community
101105
standards, including sustained inappropriate behavior, harassment of an
102106
individual, or aggression toward or disparagement of classes of individuals.

0 commit comments

Comments
 (0)