4
4
5
5
use App \Coding ;
6
6
use Confluence \Content ;
7
- use Illuminate \Support \Facades \Storage ;
8
7
use Illuminate \Support \Str ;
9
8
use LaravelFans \Confluence \Facades \Confluence ;
10
9
use LaravelZero \Framework \Commands \Command ;
11
10
12
11
class WikiImportCommand extends Command
13
12
{
13
+ use WithCoding;
14
+
14
15
/**
15
16
* The signature of the command.
16
17
*
@@ -35,10 +36,6 @@ class WikiImportCommand extends Command
35
36
*/
36
37
protected $ description = 'import wiki from confluence and so on ' ;
37
38
38
- private string $ codingProjectUri ;
39
- private string $ codingTeamDomain ;
40
- private string $ codingToken ;
41
- private Coding $ coding ;
42
39
private \App \Confluence $ confluence ;
43
40
private \DOMDocument $ document ;
44
41
@@ -195,18 +192,12 @@ private function handleConfluenceHtml(): int
195
192
$ this ->info ('标题: ' . $ title );
196
193
$ markdown = $ this ->confluence ->htmlFile2Markdown ($ dataPath . $ page );
197
194
$ mdFilename = substr ($ page , 0 , -5 ) . '.md ' ;
198
- $ zipFileFullPath = $ this ->coding ->createMarkdownZip ($ markdown , $ dataPath , $ mdFilename );
199
- $ zipFilename = basename ($ zipFileFullPath );
200
- $ uploadToken = $ this ->coding ->createUploadToken (
195
+ $ zipFilePath = $ this ->coding ->createMarkdownZip ($ markdown , $ dataPath , $ mdFilename );
196
+ $ result = $ this ->coding ->createWikiByUploadZip (
201
197
$ this ->codingToken ,
202
198
$ this ->codingProjectUri ,
203
- $ zipFilename
199
+ $ zipFilePath
204
200
);
205
- $ this ->coding ->upload ($ uploadToken , $ zipFileFullPath );
206
- $ result = $ this ->coding ->createWikiByZip ($ this ->codingToken , $ this ->codingProjectUri , $ uploadToken , [
207
- 'ParentIid ' => 0 ,
208
- 'FileName ' => $ zipFilename ,
209
- ]);
210
201
$ this ->info ('上传成功,正在处理,任务 ID: ' . $ result ['JobId ' ]);
211
202
}
212
203
} catch (\ErrorException $ e ) {
@@ -216,26 +207,4 @@ private function handleConfluenceHtml(): int
216
207
217
208
return 0 ;
218
209
}
219
-
220
- private function setCodingApi (): void
221
- {
222
- if ($ this ->option ('coding_team_domain ' )) {
223
- $ codingTeamDomain = $ this ->option ('coding_team_domain ' );
224
- } else {
225
- $ codingTeamDomain = config ('coding.team_domain ' ) ?? $ this ->ask ('CODING 团队域名: ' );
226
- }
227
- $ this ->codingTeamDomain = str_replace ('.coding.net ' , '' , $ codingTeamDomain );
228
-
229
- if ($ this ->option ('coding_project_uri ' )) {
230
- $ this ->codingProjectUri = $ this ->option ('coding_project_uri ' );
231
- } else {
232
- $ this ->codingProjectUri = config ('coding.project_uri ' ) ?? $ this ->ask ('CODING 项目标识: ' );
233
- }
234
-
235
- if ($ this ->option ('coding_token ' )) {
236
- $ this ->codingToken = $ this ->option ('coding_token ' );
237
- } else {
238
- $ this ->codingToken = config ('coding.token ' ) ?? $ this ->ask ('CODING Token: ' );
239
- }
240
- }
241
210
}
0 commit comments