Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
I
init-things
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
init-things
Commits
e33ea961
Commit
e33ea961
authored
Oct 17, 2021
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use schemagen as default
parent
6a881169
Pipeline
#6277
passed with stages
in 1 minute and 33 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
16 deletions
+21
-16
things/koishi-plugin-init/install-npm.sh
things/koishi-plugin-init/install-npm.sh
+2
-1
things/koishi-plugin-init/src/config.ts
things/koishi-plugin-init/src/config.ts
+8
-0
things/koishi-plugin-init/src/index.ts
things/koishi-plugin-init/src/index.ts
+4
-3
things/koishi-plugin-init/src/plugin.ts
things/koishi-plugin-init/src/plugin.ts
+7
-12
No files found.
things/koishi-plugin-init/install-npm.sh
View file @
e33ea961
...
...
@@ -15,4 +15,5 @@ npm install --save-dev \
ts-loader
\
webpack
\
webpack-cli
\
koishi@^4.0.0-alpha.9
koishi@^4.0.0-alpha.9
\
koishi-utils-schemagen
things/koishi-plugin-init/src/config.ts
0 → 100644
View file @
e33ea961
import
'
source-map-support/register
'
;
import
{
DefineSchema
,
UseSchema
}
from
'
koishi-utils-schemagen
'
;
import
{
Schema
}
from
'
koishi
'
;
export
class
Config
{
@
DefineSchema
({
type
:
'
string
'
,
desc
:
'
命令名
'
,
default
:
'
cmd
'
})
commandName
:
string
;
}
things/koishi-plugin-init/src/index.ts
View file @
e33ea961
import
'
source-map-support/register
'
;
import
{
Context
}
from
'
koishi
'
;
import
{
Config
,
MyPlugin
}
from
'
./plugin
'
;
export
{
Config
}
from
'
./plugin
'
;
import
{
MyPlugin
}
from
'
./plugin
'
;
import
{
Config
}
from
'
./config
'
;
export
{
Config
}
from
'
./config
'
;
export
const
name
=
'
my-plugin
'
;
const
plugin
=
new
MyPlugin
();
export
const
schema
=
plugin
.
schema
;
export
function
apply
(
ctx
:
Context
,
config
:
Config
)
{
export
function
apply
(
ctx
:
Context
,
config
:
Partial
<
Config
>
)
{
ctx
.
plugin
(
plugin
,
config
);
}
things/koishi-plugin-init/src/plugin.ts
View file @
e33ea961
import
'
source-map-support/register
'
;
import
{
Context
,
Schema
}
from
'
koishi
'
;
export
interface
Config
{
prefix
:
string
;
}
import
{
Config
}
from
'
./config
'
;
import
{
schemaFromClass
,
schemaTransform
}
from
'
koishi-utils-schemagen
'
;
export
class
MyPlugin
{
config
:
Config
ctx
:
Context
;
private
config
:
Config
;
private
ctx
:
Context
;
name
=
'
my-plugin-main
'
;
schema
:
Schema
<
Config
>
=
Schema
.
object
({
prefix
:
Schema
.
string
(
'
desc
'
)
});
apply
(
ctx
:
Context
,
config
:
Config
)
{
schema
:
Schema
<
Config
>
=
schemaFromClass
(
Config
);
apply
(
ctx
:
Context
,
config
:
Partial
<
Config
>
)
{
this
.
ctx
=
ctx
;
this
.
config
=
Schema
.
validate
(
config
,
this
.
schema
);
;
this
.
config
=
schemaTransform
(
Config
,
config
)
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment