nodebbs 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -19
- package/dist/commands/pack/index.js +4 -3
- package/dist/commands/rebuild/index.js +3 -3
- package/dist/commands/start/index.d.ts +1 -1
- package/dist/commands/start/index.js +61 -70
- package/dist/templates/docker-compose.lowmem.yml +49 -3
- package/dist/templates/docker-compose.prod.yml +120 -0
- package/dist/templates/docker-compose.yml +34 -91
- package/dist/templates/env +11 -26
- package/dist/templates/init-db.sql +14 -0
- package/dist/utils/docker.d.ts +1 -1
- package/dist/utils/docker.js +5 -2
- package/dist/utils/env.d.ts +1 -1
- package/dist/utils/selection.d.ts +1 -1
- package/dist/utils/selection.js +6 -5
- package/oclif.manifest.json +112 -146
- package/package.json +1 -1
- package/dist/commands/db/import.d.ts +0 -10
- package/dist/commands/db/import.js +0 -87
package/oclif.manifest.json
CHANGED
|
@@ -61,13 +61,14 @@
|
|
|
61
61
|
"flags": {
|
|
62
62
|
"env": {
|
|
63
63
|
"char": "e",
|
|
64
|
-
"description": "部署环境 (production, lowmem)",
|
|
64
|
+
"description": "部署环境 (production, lowmem, basic)",
|
|
65
65
|
"name": "env",
|
|
66
66
|
"hasDynamicHelp": false,
|
|
67
67
|
"multiple": false,
|
|
68
68
|
"options": [
|
|
69
69
|
"production",
|
|
70
|
-
"lowmem"
|
|
70
|
+
"lowmem",
|
|
71
|
+
"basic"
|
|
71
72
|
],
|
|
72
73
|
"type": "option"
|
|
73
74
|
},
|
|
@@ -96,43 +97,28 @@
|
|
|
96
97
|
"backup.js"
|
|
97
98
|
]
|
|
98
99
|
},
|
|
99
|
-
"db:
|
|
100
|
+
"db:push": {
|
|
100
101
|
"aliases": [],
|
|
101
102
|
"args": {},
|
|
102
|
-
"description": "
|
|
103
|
+
"description": "推送数据库 schema (db:push)",
|
|
103
104
|
"flags": {
|
|
104
105
|
"env": {
|
|
105
106
|
"char": "e",
|
|
106
|
-
"description": "部署环境 (production, lowmem)",
|
|
107
|
+
"description": "部署环境 (production, lowmem, basic)",
|
|
107
108
|
"name": "env",
|
|
108
109
|
"hasDynamicHelp": false,
|
|
109
110
|
"multiple": false,
|
|
110
111
|
"options": [
|
|
111
112
|
"production",
|
|
112
|
-
"lowmem"
|
|
113
|
+
"lowmem",
|
|
114
|
+
"basic"
|
|
113
115
|
],
|
|
114
116
|
"type": "option"
|
|
115
|
-
},
|
|
116
|
-
"file": {
|
|
117
|
-
"char": "f",
|
|
118
|
-
"description": "SQL 备份文件路径",
|
|
119
|
-
"name": "file",
|
|
120
|
-
"required": true,
|
|
121
|
-
"hasDynamicHelp": false,
|
|
122
|
-
"multiple": false,
|
|
123
|
-
"type": "option"
|
|
124
|
-
},
|
|
125
|
-
"yes": {
|
|
126
|
-
"char": "y",
|
|
127
|
-
"description": "跳过确认提示",
|
|
128
|
-
"name": "yes",
|
|
129
|
-
"allowNo": false,
|
|
130
|
-
"type": "boolean"
|
|
131
117
|
}
|
|
132
118
|
},
|
|
133
119
|
"hasDynamicHelp": false,
|
|
134
120
|
"hiddenAliases": [],
|
|
135
|
-
"id": "db:
|
|
121
|
+
"id": "db:push",
|
|
136
122
|
"pluginAlias": "nodebbs",
|
|
137
123
|
"pluginName": "nodebbs",
|
|
138
124
|
"pluginType": "core",
|
|
@@ -143,30 +129,31 @@
|
|
|
143
129
|
"dist",
|
|
144
130
|
"commands",
|
|
145
131
|
"db",
|
|
146
|
-
"
|
|
132
|
+
"push.js"
|
|
147
133
|
]
|
|
148
134
|
},
|
|
149
|
-
"db:
|
|
135
|
+
"db:reset": {
|
|
150
136
|
"aliases": [],
|
|
151
137
|
"args": {},
|
|
152
|
-
"description": "
|
|
138
|
+
"description": "重置数据库 (db:reset) - 危险操作!",
|
|
153
139
|
"flags": {
|
|
154
140
|
"env": {
|
|
155
141
|
"char": "e",
|
|
156
|
-
"description": "部署环境 (production, lowmem)",
|
|
142
|
+
"description": "部署环境 (production, lowmem, basic)",
|
|
157
143
|
"name": "env",
|
|
158
144
|
"hasDynamicHelp": false,
|
|
159
145
|
"multiple": false,
|
|
160
146
|
"options": [
|
|
161
147
|
"production",
|
|
162
|
-
"lowmem"
|
|
148
|
+
"lowmem",
|
|
149
|
+
"basic"
|
|
163
150
|
],
|
|
164
151
|
"type": "option"
|
|
165
152
|
}
|
|
166
153
|
},
|
|
167
154
|
"hasDynamicHelp": false,
|
|
168
155
|
"hiddenAliases": [],
|
|
169
|
-
"id": "db:
|
|
156
|
+
"id": "db:reset",
|
|
170
157
|
"pluginAlias": "nodebbs",
|
|
171
158
|
"pluginName": "nodebbs",
|
|
172
159
|
"pluginType": "core",
|
|
@@ -177,30 +164,31 @@
|
|
|
177
164
|
"dist",
|
|
178
165
|
"commands",
|
|
179
166
|
"db",
|
|
180
|
-
"
|
|
167
|
+
"reset.js"
|
|
181
168
|
]
|
|
182
169
|
},
|
|
183
|
-
"db:
|
|
170
|
+
"db:seed": {
|
|
184
171
|
"aliases": [],
|
|
185
172
|
"args": {},
|
|
186
|
-
"description": "
|
|
173
|
+
"description": "填充种子数据 (db:seed)",
|
|
187
174
|
"flags": {
|
|
188
175
|
"env": {
|
|
189
176
|
"char": "e",
|
|
190
|
-
"description": "部署环境 (production, lowmem)",
|
|
177
|
+
"description": "部署环境 (production, lowmem, basic)",
|
|
191
178
|
"name": "env",
|
|
192
179
|
"hasDynamicHelp": false,
|
|
193
180
|
"multiple": false,
|
|
194
181
|
"options": [
|
|
195
182
|
"production",
|
|
196
|
-
"lowmem"
|
|
183
|
+
"lowmem",
|
|
184
|
+
"basic"
|
|
197
185
|
],
|
|
198
186
|
"type": "option"
|
|
199
187
|
}
|
|
200
188
|
},
|
|
201
189
|
"hasDynamicHelp": false,
|
|
202
190
|
"hiddenAliases": [],
|
|
203
|
-
"id": "db:
|
|
191
|
+
"id": "db:seed",
|
|
204
192
|
"pluginAlias": "nodebbs",
|
|
205
193
|
"pluginName": "nodebbs",
|
|
206
194
|
"pluginType": "core",
|
|
@@ -211,30 +199,27 @@
|
|
|
211
199
|
"dist",
|
|
212
200
|
"commands",
|
|
213
201
|
"db",
|
|
214
|
-
"
|
|
202
|
+
"seed.js"
|
|
215
203
|
]
|
|
216
204
|
},
|
|
217
|
-
"
|
|
205
|
+
"pack": {
|
|
218
206
|
"aliases": [],
|
|
219
207
|
"args": {},
|
|
220
|
-
"description": "
|
|
208
|
+
"description": "生成离线部署包",
|
|
221
209
|
"flags": {
|
|
222
|
-
"
|
|
223
|
-
"char": "
|
|
224
|
-
"description": "
|
|
225
|
-
"name": "
|
|
210
|
+
"output": {
|
|
211
|
+
"char": "o",
|
|
212
|
+
"description": "输出文件名",
|
|
213
|
+
"name": "output",
|
|
214
|
+
"default": "nodebbs-offline.tar.gz",
|
|
226
215
|
"hasDynamicHelp": false,
|
|
227
216
|
"multiple": false,
|
|
228
|
-
"options": [
|
|
229
|
-
"production",
|
|
230
|
-
"lowmem"
|
|
231
|
-
],
|
|
232
217
|
"type": "option"
|
|
233
218
|
}
|
|
234
219
|
},
|
|
235
220
|
"hasDynamicHelp": false,
|
|
236
221
|
"hiddenAliases": [],
|
|
237
|
-
"id": "
|
|
222
|
+
"id": "pack",
|
|
238
223
|
"pluginAlias": "nodebbs",
|
|
239
224
|
"pluginName": "nodebbs",
|
|
240
225
|
"pluginType": "core",
|
|
@@ -244,8 +229,8 @@
|
|
|
244
229
|
"relativePath": [
|
|
245
230
|
"dist",
|
|
246
231
|
"commands",
|
|
247
|
-
"
|
|
248
|
-
"
|
|
232
|
+
"pack",
|
|
233
|
+
"index.js"
|
|
249
234
|
]
|
|
250
235
|
},
|
|
251
236
|
"logs:all": {
|
|
@@ -255,13 +240,14 @@
|
|
|
255
240
|
"flags": {
|
|
256
241
|
"env": {
|
|
257
242
|
"char": "e",
|
|
258
|
-
"description": "部署环境 (production, lowmem)",
|
|
243
|
+
"description": "部署环境 (production, lowmem, basic)",
|
|
259
244
|
"name": "env",
|
|
260
245
|
"hasDynamicHelp": false,
|
|
261
246
|
"multiple": false,
|
|
262
247
|
"options": [
|
|
263
248
|
"production",
|
|
264
|
-
"lowmem"
|
|
249
|
+
"lowmem",
|
|
250
|
+
"basic"
|
|
265
251
|
],
|
|
266
252
|
"type": "option"
|
|
267
253
|
}
|
|
@@ -289,13 +275,14 @@
|
|
|
289
275
|
"flags": {
|
|
290
276
|
"env": {
|
|
291
277
|
"char": "e",
|
|
292
|
-
"description": "部署环境 (production, lowmem)",
|
|
278
|
+
"description": "部署环境 (production, lowmem, basic)",
|
|
293
279
|
"name": "env",
|
|
294
280
|
"hasDynamicHelp": false,
|
|
295
281
|
"multiple": false,
|
|
296
282
|
"options": [
|
|
297
283
|
"production",
|
|
298
|
-
"lowmem"
|
|
284
|
+
"lowmem",
|
|
285
|
+
"basic"
|
|
299
286
|
],
|
|
300
287
|
"type": "option"
|
|
301
288
|
}
|
|
@@ -323,13 +310,14 @@
|
|
|
323
310
|
"flags": {
|
|
324
311
|
"env": {
|
|
325
312
|
"char": "e",
|
|
326
|
-
"description": "部署环境 (production, lowmem)",
|
|
313
|
+
"description": "部署环境 (production, lowmem, basic)",
|
|
327
314
|
"name": "env",
|
|
328
315
|
"hasDynamicHelp": false,
|
|
329
316
|
"multiple": false,
|
|
330
317
|
"options": [
|
|
331
318
|
"production",
|
|
332
|
-
"lowmem"
|
|
319
|
+
"lowmem",
|
|
320
|
+
"basic"
|
|
333
321
|
],
|
|
334
322
|
"type": "option"
|
|
335
323
|
}
|
|
@@ -357,13 +345,14 @@
|
|
|
357
345
|
"flags": {
|
|
358
346
|
"env": {
|
|
359
347
|
"char": "e",
|
|
360
|
-
"description": "部署环境 (production, lowmem)",
|
|
348
|
+
"description": "部署环境 (production, lowmem, basic)",
|
|
361
349
|
"name": "env",
|
|
362
350
|
"hasDynamicHelp": false,
|
|
363
351
|
"multiple": false,
|
|
364
352
|
"options": [
|
|
365
353
|
"production",
|
|
366
|
-
"lowmem"
|
|
354
|
+
"lowmem",
|
|
355
|
+
"basic"
|
|
367
356
|
],
|
|
368
357
|
"type": "option"
|
|
369
358
|
}
|
|
@@ -391,13 +380,14 @@
|
|
|
391
380
|
"flags": {
|
|
392
381
|
"env": {
|
|
393
382
|
"char": "e",
|
|
394
|
-
"description": "部署环境 (production, lowmem)",
|
|
383
|
+
"description": "部署环境 (production, lowmem, basic)",
|
|
395
384
|
"name": "env",
|
|
396
385
|
"hasDynamicHelp": false,
|
|
397
386
|
"multiple": false,
|
|
398
387
|
"options": [
|
|
399
388
|
"production",
|
|
400
|
-
"lowmem"
|
|
389
|
+
"lowmem",
|
|
390
|
+
"basic"
|
|
401
391
|
],
|
|
402
392
|
"type": "option"
|
|
403
393
|
}
|
|
@@ -418,24 +408,35 @@
|
|
|
418
408
|
"web.js"
|
|
419
409
|
]
|
|
420
410
|
},
|
|
421
|
-
"
|
|
411
|
+
"start": {
|
|
422
412
|
"aliases": [],
|
|
423
413
|
"args": {},
|
|
424
|
-
"description": "
|
|
414
|
+
"description": "开始部署",
|
|
425
415
|
"flags": {
|
|
426
|
-
"
|
|
427
|
-
"char": "
|
|
428
|
-
"description": "
|
|
429
|
-
"name": "
|
|
430
|
-
"default": "nodebbs-offline.tar.gz",
|
|
416
|
+
"env": {
|
|
417
|
+
"char": "e",
|
|
418
|
+
"description": "部署环境 (production, lowmem, basic)",
|
|
419
|
+
"name": "env",
|
|
431
420
|
"hasDynamicHelp": false,
|
|
432
421
|
"multiple": false,
|
|
422
|
+
"options": [
|
|
423
|
+
"production",
|
|
424
|
+
"lowmem",
|
|
425
|
+
"basic"
|
|
426
|
+
],
|
|
433
427
|
"type": "option"
|
|
428
|
+
},
|
|
429
|
+
"build": {
|
|
430
|
+
"char": "b",
|
|
431
|
+
"description": "重新构建并启动服务 (跳过健康检查和数据初始化)",
|
|
432
|
+
"name": "build",
|
|
433
|
+
"allowNo": false,
|
|
434
|
+
"type": "boolean"
|
|
434
435
|
}
|
|
435
436
|
},
|
|
436
437
|
"hasDynamicHelp": false,
|
|
437
438
|
"hiddenAliases": [],
|
|
438
|
-
"id": "
|
|
439
|
+
"id": "start",
|
|
439
440
|
"pluginAlias": "nodebbs",
|
|
440
441
|
"pluginName": "nodebbs",
|
|
441
442
|
"pluginType": "core",
|
|
@@ -445,28 +446,7 @@
|
|
|
445
446
|
"relativePath": [
|
|
446
447
|
"dist",
|
|
447
448
|
"commands",
|
|
448
|
-
"
|
|
449
|
-
"index.js"
|
|
450
|
-
]
|
|
451
|
-
},
|
|
452
|
-
"rebuild": {
|
|
453
|
-
"aliases": [],
|
|
454
|
-
"args": {},
|
|
455
|
-
"description": "拉取最新镜像并重启服务 (Update & Restart)",
|
|
456
|
-
"flags": {},
|
|
457
|
-
"hasDynamicHelp": false,
|
|
458
|
-
"hiddenAliases": [],
|
|
459
|
-
"id": "rebuild",
|
|
460
|
-
"pluginAlias": "nodebbs",
|
|
461
|
-
"pluginName": "nodebbs",
|
|
462
|
-
"pluginType": "core",
|
|
463
|
-
"strict": false,
|
|
464
|
-
"enableJsonFlag": false,
|
|
465
|
-
"isESM": true,
|
|
466
|
-
"relativePath": [
|
|
467
|
-
"dist",
|
|
468
|
-
"commands",
|
|
469
|
-
"rebuild",
|
|
449
|
+
"start",
|
|
470
450
|
"index.js"
|
|
471
451
|
]
|
|
472
452
|
},
|
|
@@ -477,13 +457,14 @@
|
|
|
477
457
|
"flags": {
|
|
478
458
|
"env": {
|
|
479
459
|
"char": "e",
|
|
480
|
-
"description": "部署环境 (production, lowmem)",
|
|
460
|
+
"description": "部署环境 (production, lowmem, basic)",
|
|
481
461
|
"name": "env",
|
|
482
462
|
"hasDynamicHelp": false,
|
|
483
463
|
"multiple": false,
|
|
484
464
|
"options": [
|
|
485
465
|
"production",
|
|
486
|
-
"lowmem"
|
|
466
|
+
"lowmem",
|
|
467
|
+
"basic"
|
|
487
468
|
],
|
|
488
469
|
"type": "option"
|
|
489
470
|
}
|
|
@@ -504,6 +485,27 @@
|
|
|
504
485
|
"index.js"
|
|
505
486
|
]
|
|
506
487
|
},
|
|
488
|
+
"rebuild": {
|
|
489
|
+
"aliases": [],
|
|
490
|
+
"args": {},
|
|
491
|
+
"description": "重新构建并启动服务 (start --build)",
|
|
492
|
+
"flags": {},
|
|
493
|
+
"hasDynamicHelp": false,
|
|
494
|
+
"hiddenAliases": [],
|
|
495
|
+
"id": "rebuild",
|
|
496
|
+
"pluginAlias": "nodebbs",
|
|
497
|
+
"pluginName": "nodebbs",
|
|
498
|
+
"pluginType": "core",
|
|
499
|
+
"strict": false,
|
|
500
|
+
"enableJsonFlag": false,
|
|
501
|
+
"isESM": true,
|
|
502
|
+
"relativePath": [
|
|
503
|
+
"dist",
|
|
504
|
+
"commands",
|
|
505
|
+
"rebuild",
|
|
506
|
+
"index.js"
|
|
507
|
+
]
|
|
508
|
+
},
|
|
507
509
|
"shell:api": {
|
|
508
510
|
"aliases": [],
|
|
509
511
|
"args": {},
|
|
@@ -511,13 +513,14 @@
|
|
|
511
513
|
"flags": {
|
|
512
514
|
"env": {
|
|
513
515
|
"char": "e",
|
|
514
|
-
"description": "部署环境 (production, lowmem)",
|
|
516
|
+
"description": "部署环境 (production, lowmem, basic)",
|
|
515
517
|
"name": "env",
|
|
516
518
|
"hasDynamicHelp": false,
|
|
517
519
|
"multiple": false,
|
|
518
520
|
"options": [
|
|
519
521
|
"production",
|
|
520
|
-
"lowmem"
|
|
522
|
+
"lowmem",
|
|
523
|
+
"basic"
|
|
521
524
|
],
|
|
522
525
|
"type": "option"
|
|
523
526
|
}
|
|
@@ -545,13 +548,14 @@
|
|
|
545
548
|
"flags": {
|
|
546
549
|
"env": {
|
|
547
550
|
"char": "e",
|
|
548
|
-
"description": "部署环境 (production, lowmem)",
|
|
551
|
+
"description": "部署环境 (production, lowmem, basic)",
|
|
549
552
|
"name": "env",
|
|
550
553
|
"hasDynamicHelp": false,
|
|
551
554
|
"multiple": false,
|
|
552
555
|
"options": [
|
|
553
556
|
"production",
|
|
554
|
-
"lowmem"
|
|
557
|
+
"lowmem",
|
|
558
|
+
"basic"
|
|
555
559
|
],
|
|
556
560
|
"type": "option"
|
|
557
561
|
}
|
|
@@ -579,13 +583,14 @@
|
|
|
579
583
|
"flags": {
|
|
580
584
|
"env": {
|
|
581
585
|
"char": "e",
|
|
582
|
-
"description": "部署环境 (production, lowmem)",
|
|
586
|
+
"description": "部署环境 (production, lowmem, basic)",
|
|
583
587
|
"name": "env",
|
|
584
588
|
"hasDynamicHelp": false,
|
|
585
589
|
"multiple": false,
|
|
586
590
|
"options": [
|
|
587
591
|
"production",
|
|
588
|
-
"lowmem"
|
|
592
|
+
"lowmem",
|
|
593
|
+
"basic"
|
|
589
594
|
],
|
|
590
595
|
"type": "option"
|
|
591
596
|
}
|
|
@@ -613,13 +618,14 @@
|
|
|
613
618
|
"flags": {
|
|
614
619
|
"env": {
|
|
615
620
|
"char": "e",
|
|
616
|
-
"description": "部署环境 (production, lowmem)",
|
|
621
|
+
"description": "部署环境 (production, lowmem, basic)",
|
|
617
622
|
"name": "env",
|
|
618
623
|
"hasDynamicHelp": false,
|
|
619
624
|
"multiple": false,
|
|
620
625
|
"options": [
|
|
621
626
|
"production",
|
|
622
|
-
"lowmem"
|
|
627
|
+
"lowmem",
|
|
628
|
+
"basic"
|
|
623
629
|
],
|
|
624
630
|
"type": "option"
|
|
625
631
|
}
|
|
@@ -640,48 +646,6 @@
|
|
|
640
646
|
"web.js"
|
|
641
647
|
]
|
|
642
648
|
},
|
|
643
|
-
"start": {
|
|
644
|
-
"aliases": [],
|
|
645
|
-
"args": {},
|
|
646
|
-
"description": "开始部署",
|
|
647
|
-
"flags": {
|
|
648
|
-
"env": {
|
|
649
|
-
"char": "e",
|
|
650
|
-
"description": "部署环境 (production, lowmem)",
|
|
651
|
-
"name": "env",
|
|
652
|
-
"hasDynamicHelp": false,
|
|
653
|
-
"multiple": false,
|
|
654
|
-
"options": [
|
|
655
|
-
"production",
|
|
656
|
-
"lowmem"
|
|
657
|
-
],
|
|
658
|
-
"type": "option"
|
|
659
|
-
},
|
|
660
|
-
"tag": {
|
|
661
|
-
"char": "t",
|
|
662
|
-
"description": "Image version tag (e.g. latest, v0.1.0)",
|
|
663
|
-
"name": "tag",
|
|
664
|
-
"hasDynamicHelp": false,
|
|
665
|
-
"multiple": false,
|
|
666
|
-
"type": "option"
|
|
667
|
-
}
|
|
668
|
-
},
|
|
669
|
-
"hasDynamicHelp": false,
|
|
670
|
-
"hiddenAliases": [],
|
|
671
|
-
"id": "start",
|
|
672
|
-
"pluginAlias": "nodebbs",
|
|
673
|
-
"pluginName": "nodebbs",
|
|
674
|
-
"pluginType": "core",
|
|
675
|
-
"strict": true,
|
|
676
|
-
"enableJsonFlag": false,
|
|
677
|
-
"isESM": true,
|
|
678
|
-
"relativePath": [
|
|
679
|
-
"dist",
|
|
680
|
-
"commands",
|
|
681
|
-
"start",
|
|
682
|
-
"index.js"
|
|
683
|
-
]
|
|
684
|
-
},
|
|
685
649
|
"status": {
|
|
686
650
|
"aliases": [],
|
|
687
651
|
"args": {},
|
|
@@ -689,13 +653,14 @@
|
|
|
689
653
|
"flags": {
|
|
690
654
|
"env": {
|
|
691
655
|
"char": "e",
|
|
692
|
-
"description": "部署环境 (production, lowmem)",
|
|
656
|
+
"description": "部署环境 (production, lowmem, basic)",
|
|
693
657
|
"name": "env",
|
|
694
658
|
"hasDynamicHelp": false,
|
|
695
659
|
"multiple": false,
|
|
696
660
|
"options": [
|
|
697
661
|
"production",
|
|
698
|
-
"lowmem"
|
|
662
|
+
"lowmem",
|
|
663
|
+
"basic"
|
|
699
664
|
],
|
|
700
665
|
"type": "option"
|
|
701
666
|
}
|
|
@@ -730,13 +695,14 @@
|
|
|
730
695
|
},
|
|
731
696
|
"env": {
|
|
732
697
|
"char": "e",
|
|
733
|
-
"description": "部署环境 (production, lowmem)",
|
|
698
|
+
"description": "部署环境 (production, lowmem, basic)",
|
|
734
699
|
"name": "env",
|
|
735
700
|
"hasDynamicHelp": false,
|
|
736
701
|
"multiple": false,
|
|
737
702
|
"options": [
|
|
738
703
|
"production",
|
|
739
|
-
"lowmem"
|
|
704
|
+
"lowmem",
|
|
705
|
+
"basic"
|
|
740
706
|
],
|
|
741
707
|
"type": "option"
|
|
742
708
|
}
|
|
@@ -758,5 +724,5 @@
|
|
|
758
724
|
]
|
|
759
725
|
}
|
|
760
726
|
},
|
|
761
|
-
"version": "0.
|
|
727
|
+
"version": "0.2.0"
|
|
762
728
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Command } from '@oclif/core';
|
|
2
|
-
export default class DbImport extends Command {
|
|
3
|
-
static description: string;
|
|
4
|
-
static flags: {
|
|
5
|
-
env: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
6
|
-
file: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
-
yes: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
-
};
|
|
9
|
-
run(): Promise<void>;
|
|
10
|
-
}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { Command, Flags } from '@oclif/core';
|
|
2
|
-
import { confirm } from '@inquirer/prompts';
|
|
3
|
-
import { getComposeFiles } from '../../utils/docker.js';
|
|
4
|
-
import { logger } from '../../utils/logger.js';
|
|
5
|
-
import { execa } from 'execa';
|
|
6
|
-
import fs from 'node:fs';
|
|
7
|
-
import path from 'node:path';
|
|
8
|
-
import dotenv from 'dotenv';
|
|
9
|
-
import { EnvFlag, selectEnvironment } from '../../utils/selection.js';
|
|
10
|
-
export default class DbImport extends Command {
|
|
11
|
-
static description = '导入数据库 (PostgreSQL)';
|
|
12
|
-
static flags = {
|
|
13
|
-
env: EnvFlag,
|
|
14
|
-
file: Flags.string({
|
|
15
|
-
char: 'f',
|
|
16
|
-
description: 'SQL 备份文件路径',
|
|
17
|
-
required: true,
|
|
18
|
-
}),
|
|
19
|
-
yes: Flags.boolean({
|
|
20
|
-
char: 'y',
|
|
21
|
-
description: '跳过确认提示',
|
|
22
|
-
default: false,
|
|
23
|
-
}),
|
|
24
|
-
};
|
|
25
|
-
async run() {
|
|
26
|
-
const { flags } = await this.parse(DbImport);
|
|
27
|
-
// 1. 选择环境
|
|
28
|
-
const env = await selectEnvironment(flags.env);
|
|
29
|
-
// 2. 验证文件
|
|
30
|
-
const inputPath = path.resolve(process.cwd(), flags.file);
|
|
31
|
-
if (!fs.existsSync(inputPath)) {
|
|
32
|
-
logger.error(`找不到备份文件: ${inputPath}`);
|
|
33
|
-
this.exit(1);
|
|
34
|
-
}
|
|
35
|
-
// 3. 用户确认
|
|
36
|
-
if (!flags.yes) {
|
|
37
|
-
logger.warning('警告:此操作将覆盖当前数据库中的数据!');
|
|
38
|
-
const confirmImport = await confirm({
|
|
39
|
-
message: `确认从 ${flags.file} 恢复数据库?`,
|
|
40
|
-
default: false
|
|
41
|
-
});
|
|
42
|
-
if (!confirmImport) {
|
|
43
|
-
logger.info('操作已取消。');
|
|
44
|
-
this.exit(0);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
// 4. 获取 Compose 文件
|
|
48
|
-
const { files, isBuiltIn } = await getComposeFiles(env);
|
|
49
|
-
logger.info(`正在从文件恢复数据库: ${inputPath}`);
|
|
50
|
-
logger.info('环境: ' + env);
|
|
51
|
-
// 加载环境配置
|
|
52
|
-
const envConfig = dotenv.config().parsed || {};
|
|
53
|
-
const dbUser = envConfig.POSTGRES_USER || 'postgres';
|
|
54
|
-
const dbName = envConfig.POSTGRES_DB || 'nodebbs';
|
|
55
|
-
const dbPassword = envConfig.POSTGRES_PASSWORD;
|
|
56
|
-
// 5. 构建 Compose 参数
|
|
57
|
-
const composeArgs = files.flatMap(f => ['-f', f]);
|
|
58
|
-
if (isBuiltIn) {
|
|
59
|
-
composeArgs.push('--project-directory', process.cwd());
|
|
60
|
-
}
|
|
61
|
-
// 6. 运行 psql
|
|
62
|
-
// const dumpArgs = [...composeArgs, 'exec', '-T'] // backup uses exec
|
|
63
|
-
// import should also use exec -T to accept stdin
|
|
64
|
-
const importArgs = [...composeArgs, 'exec', '-T'];
|
|
65
|
-
// 如果有密码则注入
|
|
66
|
-
if (dbPassword) {
|
|
67
|
-
importArgs.push('-e', `PGPASSWORD=${dbPassword}`);
|
|
68
|
-
}
|
|
69
|
-
importArgs.push('postgres', 'psql', '-U', dbUser, '-d', dbName);
|
|
70
|
-
try {
|
|
71
|
-
const subprocess = execa('docker', ['compose', ...importArgs], {
|
|
72
|
-
input: fs.createReadStream(inputPath)
|
|
73
|
-
});
|
|
74
|
-
// subprocess.stdout?.pipe(process.stdout)
|
|
75
|
-
// subprocess.stderr?.pipe(process.stderr)
|
|
76
|
-
await subprocess;
|
|
77
|
-
logger.success('数据库导入成功!');
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
logger.error('数据库导入失败');
|
|
81
|
-
if (error instanceof Error) {
|
|
82
|
-
logger.error(error.message);
|
|
83
|
-
}
|
|
84
|
-
this.exit(1);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
}
|