Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
K
Koishi Thirdeye
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
3rdeye
Koishi Thirdeye
Commits
f337c600
Commit
f337c600
authored
May 08, 2022
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix no register in map plugin
parent
4678eb38
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
17 deletions
+29
-17
src/plugin-operators/map-plugin.ts
src/plugin-operators/map-plugin.ts
+17
-16
tests/map-plugin.spec.ts
tests/map-plugin.spec.ts
+12
-1
No files found.
src/plugin-operators/map-plugin.ts
View file @
f337c600
...
...
@@ -28,18 +28,17 @@ export class MapPluginBase<M extends Dict<PluginClass>>
onApply
()
{
const
dict
=
this
.
_getDict
();
for
(
const
[
key
,
plugin
]
of
Object
.
entries
(
dict
))
{
if
(
this
.
config
[
key
]
!=
null
)
{
const
ctx
=
typeof
this
.
config
[
key
]
===
'
object
'
?
this
.
ctx
.
select
(
this
.
config
[
key
])
:
this
.
ctx
;
const
clonedPlugin
=
ClonePlugin
(
plugin
,
`
${
this
.
constructor
.
name
}
_
${
plugin
.
name
}
_dict_
${
key
}
`
,
(
o
)
=>
this
.
_instanceMap
.
set
(
key
,
o
),
);
ctx
.
plugin
(
clonedPlugin
,
this
.
config
[
key
]);
}
if
(
this
.
config
[
key
]?.[
NoRegisterSym
])
continue
;
const
ctx
=
typeof
this
.
config
[
key
]
===
'
object
'
?
this
.
ctx
.
select
(
this
.
config
[
key
])
:
this
.
ctx
;
const
clonedPlugin
=
ClonePlugin
(
plugin
,
`
${
this
.
constructor
.
name
}
_
${
plugin
.
name
}
_dict_
${
key
}
`
,
(
o
)
=>
this
.
_instanceMap
.
set
(
key
,
o
),
);
ctx
.
plugin
(
clonedPlugin
,
this
.
config
[
key
]);
}
}
...
...
@@ -49,6 +48,8 @@ export class MapPluginBase<M extends Dict<PluginClass>>
}
}
const
NoRegisterSym
=
'
__no_register
'
as
const
;
function
MappedConfig
<
M
extends
Dict
<
PluginClass
>>
(
dict
:
M
,
):
ClassType
<
MapPluginToConfig
<
M
>>
{
...
...
@@ -60,10 +61,10 @@ function MappedConfig<M extends Dict<PluginClass>>(
plugin
[
'
Config
'
]
||
plugin
[
'
schema
'
]
||
reflector
.
get
(
'
KoishiPredefineSchema
'
,
plugin
);
SchemaProperty
({
type
:
propertySchemaClass
,
default
:
undefined
})(
PropertySchema
.
prototype
,
key
,
);
SchemaProperty
({
type
:
propertySchemaClass
,
default
:
{
[
NoRegisterSym
]:
true
}
,
})(
PropertySchema
.
prototype
,
key
);
}
return
PropertySchema
;
}
...
...
tests/map-plugin.spec.ts
View file @
f337c600
...
...
@@ -19,7 +19,7 @@ class DressPlugin extends StarterPlugin(DressConfig) {
}
class
SkirtConfig
{
@
SchemaProperty
()
@
SchemaProperty
(
{
default
:
'
S
'
}
)
size
:
string
;
}
...
...
@@ -60,4 +60,15 @@ describe('register map plugin instance', () => {
expect
(
await
app
.
command
(
'
skirtSize
'
).
execute
({})).
toBe
(
'
XL
'
);
expect
(
await
app
.
command
(
'
wearingStrip
'
).
execute
({})).
toBe
(
'
pink
'
);
});
it
(
'
should partial register
'
,
async
()
=>
{
const
app
=
new
App
();
app
.
plugin
(
WearingPlugin
,
{
dress
:
{
color
:
'
red
'
},
strip
:
'
pink
'
,
});
await
app
.
start
();
expect
(
await
app
.
command
(
'
dressColor
'
).
execute
({})).
toBe
(
'
red
'
);
expect
(
await
app
.
command
(
'
wearingStrip
'
).
execute
({})).
toBe
(
'
pink
'
);
expect
(
await
app
.
command
(
'
skirtSize
'
).
execute
({})).
toBeFalsy
();
});
});
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