Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
J
Jdaw
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
MyCard
Jdaw
Commits
b1abde72
Commit
b1abde72
authored
Jan 11, 2023
by
nanahira
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix reload cdb plugin
parent
a5470f96
Pipeline
#19410
canceled with stages
in 15 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
7 deletions
+15
-7
src/cdb-loader/cdb-loader.service.ts
src/cdb-loader/cdb-loader.service.ts
+15
-7
No files found.
src/cdb-loader/cdb-loader.service.ts
View file @
b1abde72
import
{
ConsoleLogger
,
Injectable
}
from
'
@nestjs/common
'
;
import
{
ConsoleLogger
,
Injectable
,
OnModuleInit
}
from
'
@nestjs/common
'
;
import
{
PluginDef
,
UsePlugin
}
from
'
koishi-nestjs
'
;
import
{
InjectContext
,
PluginDef
,
UsePlugin
}
from
'
koishi-nestjs
'
;
import
{
ConfigService
}
from
'
@nestjs/config
'
;
import
{
ConfigService
}
from
'
@nestjs/config
'
;
import
path
from
'
path
'
;
import
path
from
'
path
'
;
import
fs
from
'
fs
'
;
import
fs
from
'
fs
'
;
import
simpleGit
,
{
ResetMode
,
SimpleGit
}
from
'
simple-git
'
;
import
simpleGit
,
{
ResetMode
,
SimpleGit
}
from
'
simple-git
'
;
import
YGOCardPlugin
from
'
koishi-plugin-ygocard
'
;
import
YGOCardPlugin
from
'
koishi-plugin-ygocard
'
;
import
{
Cron
}
from
'
@nestjs/schedule
'
;
import
{
Cron
}
from
'
@nestjs/schedule
'
;
import
{
Context
,
ForkScope
}
from
'
koishi
'
;
async
function
exists
(
path
:
string
)
{
async
function
exists
(
path
:
string
)
{
try
{
try
{
...
@@ -17,13 +18,16 @@ async function exists(path: string) {
...
@@ -17,13 +18,16 @@ async function exists(path: string) {
}
}
@
Injectable
()
@
Injectable
()
export
class
CdbLoaderService
extends
ConsoleLogger
{
export
class
CdbLoaderService
extends
ConsoleLogger
implements
OnModuleInit
{
private
repoUrl
=
this
.
config
.
get
<
string
>
(
'
CDB_REPO
'
);
private
repoUrl
=
this
.
config
.
get
<
string
>
(
'
CDB_REPO
'
);
private
repoPath
=
path
.
join
(
process
.
cwd
(),
'
ygopro-database
'
);
private
repoPath
=
path
.
join
(
process
.
cwd
(),
'
ygopro-database
'
);
private
repoBranch
=
this
.
config
.
get
<
string
>
(
'
CDB_BRANCH
'
);
private
repoBranch
=
this
.
config
.
get
<
string
>
(
'
CDB_BRANCH
'
);
private
git
:
SimpleGit
;
private
git
:
SimpleGit
;
constructor
(
private
config
:
ConfigService
)
{
constructor
(
private
config
:
ConfigService
,
@
InjectContext
()
private
ctx
:
Context
,
)
{
super
(
'
CdbLoaderService
'
);
super
(
'
CdbLoaderService
'
);
}
}
...
@@ -39,10 +43,11 @@ export class CdbLoaderService extends ConsoleLogger {
...
@@ -39,10 +43,11 @@ export class CdbLoaderService extends ConsoleLogger {
this
.
git
=
simpleGit
(
this
.
repoPath
);
this
.
git
=
simpleGit
(
this
.
repoPath
);
}
}
@
UsePlugin
()
private
state
:
ForkScope
;
async
load
()
{
async
onModuleInit
()
{
await
this
.
initRepo
();
await
this
.
initRepo
();
return
PluginDef
(
YGOCardPlugin
,
{
this
.
state
=
this
.
ctx
.
plugin
(
YGOCardPlugin
,
{
databasePaths
:
[
path
.
join
(
this
.
repoPath
,
'
locales
'
,
'
zh-CN
'
)],
databasePaths
:
[
path
.
join
(
this
.
repoPath
,
'
locales
'
,
'
zh-CN
'
)],
matchCount
:
20
,
matchCount
:
20
,
lang
:
'
cn
'
,
lang
:
'
cn
'
,
...
@@ -55,6 +60,9 @@ export class CdbLoaderService extends ConsoleLogger {
...
@@ -55,6 +60,9 @@ export class CdbLoaderService extends ConsoleLogger {
this
.
log
(
'
Updating repo
'
);
this
.
log
(
'
Updating repo
'
);
await
this
.
git
.
fetch
([
'
origin
'
,
this
.
repoBranch
]);
await
this
.
git
.
fetch
([
'
origin
'
,
this
.
repoBranch
]);
await
this
.
git
.
reset
(
ResetMode
.
HARD
,
[
'
origin/
'
+
this
.
repoBranch
]);
await
this
.
git
.
reset
(
ResetMode
.
HARD
,
[
'
origin/
'
+
this
.
repoBranch
]);
if
(
this
.
state
)
{
this
.
state
.
restart
();
}
this
.
log
(
'
Repo updated
'
);
this
.
log
(
'
Repo updated
'
);
}
}
}
}
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