add script for creating plugin

This commit is contained in:
Pig Fang 2019-12-05 23:03:04 +08:00
parent f24aff75d9
commit ba17160ec0
2 changed files with 70 additions and 1 deletions

View File

@ -8,5 +8,5 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.php]
[*.{php,ps1}]
indent_size = 4

69
create.ps1 Normal file
View File

@ -0,0 +1,69 @@
param (
[Parameter(Mandatory, Position = 0)]
[string]
$Id,
[Parameter(Mandatory)]
[string]
$Title,
[Parameter(Mandatory)]
[string]
$Description,
[Parameter(Mandatory)]
[string]
$Author,
[Parameter(Mandatory)]
[string]
$Namespace,
[Parameter()]
[string]
$Url,
[Parameter()]
[switch]
[Alias('Views')]
$View,
[Parameter()]
[switch]
[Alias('Assets')]
$Asset,
[Parameter()]
[switch]
$Lang
)
$manifest = [PSCustomObject]@{
name = $Id
title = $Title
version = '0.1.0'
description = $Description
author = $Author
url = $Url
namespace = $Namespace
require = @{
'blessing-skin-server' = '^5.0.0'
}
enchants = @{}
}
New-Item "./$Id/src" -ItemType Directory | Out-Null
ConvertTo-Json $manifest | Set-Content "./$Id/package.json"
Set-Content -Value "<?php`n`nreturn function () {};" -Path "./$Id/bootstrap.php"
if ($View) {
New-Item "./$Id/views" -ItemType Directory | Out-Null
}
if ($Asset) {
New-Item "./$Id/assets" -ItemType Directory | Out-Null
}
if ($Lang) {
New-Item "./$Id/lang" -ItemType Directory | Out-Null
}