Skip to content

Commit 75b604f

Browse files
committed
Added author name & email placeholders
1 parent 9a8bde6 commit 75b604f

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

polymorphine-skeleton

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use Shudd3r\Skeletons\Application;
1414
use Shudd3r\Skeletons\InputArgs;
1515
use Shudd3r\Skeletons\Environment\Files\Directory\LocalDirectory;
1616
use Shudd3r\Skeletons\Replacements\Replacement;
17+
use Shudd3r\Skeletons\Replacements\Source;
1718
use Shudd3r\Skeletons\Templates\Contents;
1819
use Shudd3r\Skeletons\Templates\Template;
1920

@@ -43,6 +44,18 @@ $app->replacement('package.name')->add(new Replacement\PackageName());
4344
$app->replacement('repository.name')->add(new Replacement\RepositoryName('package.name'));
4445
$app->replacement('package.description')->add(new Replacement\PackageDescription('package.name'));
4546
$app->replacement('namespace.src')->add(new Replacement\SrcNamespace('package.name'));
47+
$app->replacement('author.name')
48+
->build(fn (Source $source) => $source->composer()->value('authors.0.name') ?? 'Author Name')
49+
->argumentName('author')
50+
->inputPrompt('Author\'s name')
51+
->description('Name of package author [format: non-empty string]' . PHP_EOL . 'Replaces {%s} placeholder')
52+
->validate(fn (string $value) => !empty($value));
53+
$app->replacement('author.email')
54+
->build(fn (Source $source) => $source->composer()->value('authors.0.email') ?? 'default@example.com')
55+
->argumentName('email')
56+
->inputPrompt('Author\'s email address')
57+
->description('Email address of package author [format: <username>@<domain>]' . PHP_EOL . 'Replaces {%s} placeholder')
58+
->validate(fn (string $value) => $value === filter_var($value, FILTER_VALIDATE_EMAIL));
4659

4760
$isUpdate = $args->command() === 'update';
4861
$app->template('composer.json')->createWith(function (Contents $contents) use ($isUpdate) {

template/LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
The MIT License (MIT)
22

3-
Copyright (c) {original.content}
3+
Copyright (c) {original.content} {author.name} <{author.email}>
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

template/composer.json.sk_file

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"license": null,
66
"authors": [
77
{
8-
"name": null,
9-
"email": null,
8+
"name": "{author.name}",
9+
"email": "{author.email}",
1010
"homepage": null,
1111
"role": null
1212
}

0 commit comments

Comments
 (0)