@lark-apaas/fullstack-nestjs-core 1.0.3-alpha.12 → 1.0.3-alpha.13
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/dist/index.cjs +50 -16
- package/dist/index.js +40 -6
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -370,8 +370,8 @@ var import_cookie_parser = __toESM(require("cookie-parser"), 1);
|
|
|
370
370
|
|
|
371
371
|
// src/modules/devtool-v2/index.ts
|
|
372
372
|
var import_swagger = require("@nestjs/swagger");
|
|
373
|
-
var
|
|
374
|
-
var
|
|
373
|
+
var import_node_fs4 = require("fs");
|
|
374
|
+
var import_node_path4 = require("path");
|
|
375
375
|
|
|
376
376
|
// src/modules/devtool-v2/helper.ts
|
|
377
377
|
var import_node_path = require("path");
|
|
@@ -427,6 +427,39 @@ export const createClientConfig: CreateClientConfig = (config) => ({
|
|
|
427
427
|
}
|
|
428
428
|
__name(generateClientConfig, "generateClientConfig");
|
|
429
429
|
|
|
430
|
+
// src/modules/devtool-v2/plugins/add-ts-nocheck.ts
|
|
431
|
+
var import_node_fs3 = require("fs");
|
|
432
|
+
var import_node_path3 = require("path");
|
|
433
|
+
function addTsNocheckToGeneratedFiles(outputPath) {
|
|
434
|
+
const files = getAllTsFiles(outputPath);
|
|
435
|
+
for (const filePath of files) {
|
|
436
|
+
addTsNocheckToFile(filePath);
|
|
437
|
+
}
|
|
438
|
+
}
|
|
439
|
+
__name(addTsNocheckToGeneratedFiles, "addTsNocheckToGeneratedFiles");
|
|
440
|
+
function getAllTsFiles(dirPath) {
|
|
441
|
+
const files = [];
|
|
442
|
+
const entries = (0, import_node_fs3.readdirSync)(dirPath);
|
|
443
|
+
for (const entry of entries) {
|
|
444
|
+
const fullPath = (0, import_node_path3.join)(dirPath, entry);
|
|
445
|
+
const stat = (0, import_node_fs3.statSync)(fullPath);
|
|
446
|
+
if (stat.isDirectory()) {
|
|
447
|
+
files.push(...getAllTsFiles(fullPath));
|
|
448
|
+
} else if (stat.isFile() && entry.endsWith(".ts")) {
|
|
449
|
+
files.push(fullPath);
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
return files;
|
|
453
|
+
}
|
|
454
|
+
__name(getAllTsFiles, "getAllTsFiles");
|
|
455
|
+
function addTsNocheckToFile(filePath) {
|
|
456
|
+
const content = (0, import_node_fs3.readFileSync)(filePath, "utf-8");
|
|
457
|
+
const newContent = `// @ts-nocheck
|
|
458
|
+
${content}`;
|
|
459
|
+
(0, import_node_fs3.writeFileSync)(filePath, newContent, "utf-8");
|
|
460
|
+
}
|
|
461
|
+
__name(addTsNocheckToFile, "addTsNocheckToFile");
|
|
462
|
+
|
|
430
463
|
// src/modules/devtool-v2/index.ts
|
|
431
464
|
var DevToolsV2Module = class {
|
|
432
465
|
static {
|
|
@@ -447,11 +480,11 @@ var DevToolsV2Module = class {
|
|
|
447
480
|
});
|
|
448
481
|
console.log(`[OpenAPI] Swagger UI \u5DF2\u6302\u8F7D\u81F3 ${options.docsPath}`);
|
|
449
482
|
}
|
|
450
|
-
const openapiPath = (0,
|
|
483
|
+
const openapiPath = (0, import_node_path4.resolve)(baseDirname, options.openapiOut);
|
|
451
484
|
ensureDirAndWrite(openapiPath, JSON.stringify(document, null, 2));
|
|
452
485
|
if (options.needGenerateClientSdk) {
|
|
453
|
-
const clientSdkOutPath = (0,
|
|
454
|
-
(0,
|
|
486
|
+
const clientSdkOutPath = (0, import_node_path4.resolve)(baseDirname, options.clientSdkOut);
|
|
487
|
+
(0, import_node_fs4.mkdirSync)(clientSdkOutPath, {
|
|
455
488
|
recursive: true
|
|
456
489
|
});
|
|
457
490
|
const { createClient } = await import("@hey-api/openapi-ts");
|
|
@@ -465,10 +498,11 @@ var DevToolsV2Module = class {
|
|
|
465
498
|
"@hey-api/sdk",
|
|
466
499
|
{
|
|
467
500
|
name: "@hey-api/client-axios",
|
|
468
|
-
runtimeConfigPath: (0,
|
|
501
|
+
runtimeConfigPath: (0, import_node_path4.join)(clientSdkOutPath, "./client.config.ts")
|
|
469
502
|
}
|
|
470
503
|
]
|
|
471
504
|
});
|
|
505
|
+
addTsNocheckToGeneratedFiles(clientSdkOutPath);
|
|
472
506
|
ensureDirAndWrite(openapiPath, JSON.stringify(document, null, 2));
|
|
473
507
|
generateClientConfig({
|
|
474
508
|
outputPath: clientSdkOutPath
|
|
@@ -499,12 +533,12 @@ __name(configureApp, "configureApp");
|
|
|
499
533
|
|
|
500
534
|
// src/modules/devtool/index.ts
|
|
501
535
|
var import_swagger2 = require("@nestjs/swagger");
|
|
502
|
-
var
|
|
503
|
-
var
|
|
536
|
+
var import_node_fs6 = require("fs");
|
|
537
|
+
var import_node_path6 = require("path");
|
|
504
538
|
|
|
505
539
|
// src/modules/devtool/helper.ts
|
|
506
|
-
var
|
|
507
|
-
var
|
|
540
|
+
var import_node_path5 = require("path");
|
|
541
|
+
var import_node_fs5 = require("fs");
|
|
508
542
|
function normalizeBasePath2(rawBasePath) {
|
|
509
543
|
const normalizedBasePath = rawBasePath.startsWith("/") ? rawBasePath : `/${rawBasePath}`;
|
|
510
544
|
return normalizedBasePath.endsWith("/") ? normalizedBasePath.slice(0, -1) : normalizedBasePath;
|
|
@@ -531,11 +565,11 @@ function resolveOptsWithDefaultValue2(options) {
|
|
|
531
565
|
}
|
|
532
566
|
__name(resolveOptsWithDefaultValue2, "resolveOptsWithDefaultValue");
|
|
533
567
|
function ensureDirAndWrite2(filePath, content) {
|
|
534
|
-
const dir = (0,
|
|
535
|
-
(0,
|
|
568
|
+
const dir = (0, import_node_path5.dirname)(filePath);
|
|
569
|
+
(0, import_node_fs5.mkdirSync)(dir, {
|
|
536
570
|
recursive: true
|
|
537
571
|
});
|
|
538
|
-
(0,
|
|
572
|
+
(0, import_node_fs5.writeFileSync)(filePath, content);
|
|
539
573
|
}
|
|
540
574
|
__name(ensureDirAndWrite2, "ensureDirAndWrite");
|
|
541
575
|
|
|
@@ -561,11 +595,11 @@ var DevToolsModule = class {
|
|
|
561
595
|
});
|
|
562
596
|
console.log(`[OpenAPI] Swagger UI \u5DF2\u6302\u8F7D\u81F3 ${options.docsPath}`);
|
|
563
597
|
}
|
|
564
|
-
const openapiPath = (0,
|
|
598
|
+
const openapiPath = (0, import_node_path6.resolve)(baseDirname, options.openapiOut);
|
|
565
599
|
ensureDirAndWrite2(openapiPath, JSON.stringify(document, null, 2));
|
|
566
600
|
if (options.needGenerateClientSdk) {
|
|
567
|
-
const clientSdkOutPath = (0,
|
|
568
|
-
(0,
|
|
601
|
+
const clientSdkOutPath = (0, import_node_path6.resolve)(baseDirname, options.clientSdkOut);
|
|
602
|
+
(0, import_node_fs6.mkdirSync)(clientSdkOutPath, {
|
|
569
603
|
recursive: true
|
|
570
604
|
});
|
|
571
605
|
const { generate } = await import("openapi-typescript-codegen");
|
package/dist/index.js
CHANGED
|
@@ -322,14 +322,14 @@ PlatformModule = _ts_decorate5([
|
|
|
322
322
|
|
|
323
323
|
// src/setup.ts
|
|
324
324
|
import { AppLogger as AppLogger2 } from "@lark-apaas/nestjs-logger";
|
|
325
|
-
import { join as
|
|
325
|
+
import { join as join3 } from "path";
|
|
326
326
|
import { __express as hbsExpressEngine } from "hbs";
|
|
327
327
|
import cookieParser from "cookie-parser";
|
|
328
328
|
|
|
329
329
|
// src/modules/devtool-v2/index.ts
|
|
330
330
|
import { SwaggerModule, DocumentBuilder } from "@nestjs/swagger";
|
|
331
331
|
import { mkdirSync as mkdirSync2 } from "fs";
|
|
332
|
-
import { resolve as resolve2, join } from "path";
|
|
332
|
+
import { resolve as resolve2, join as join2 } from "path";
|
|
333
333
|
|
|
334
334
|
// src/modules/devtool-v2/helper.ts
|
|
335
335
|
import { dirname } from "path";
|
|
@@ -385,6 +385,39 @@ export const createClientConfig: CreateClientConfig = (config) => ({
|
|
|
385
385
|
}
|
|
386
386
|
__name(generateClientConfig, "generateClientConfig");
|
|
387
387
|
|
|
388
|
+
// src/modules/devtool-v2/plugins/add-ts-nocheck.ts
|
|
389
|
+
import { readdirSync, readFileSync, writeFileSync as writeFileSync3, statSync } from "fs";
|
|
390
|
+
import { join } from "path";
|
|
391
|
+
function addTsNocheckToGeneratedFiles(outputPath) {
|
|
392
|
+
const files = getAllTsFiles(outputPath);
|
|
393
|
+
for (const filePath of files) {
|
|
394
|
+
addTsNocheckToFile(filePath);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
__name(addTsNocheckToGeneratedFiles, "addTsNocheckToGeneratedFiles");
|
|
398
|
+
function getAllTsFiles(dirPath) {
|
|
399
|
+
const files = [];
|
|
400
|
+
const entries = readdirSync(dirPath);
|
|
401
|
+
for (const entry of entries) {
|
|
402
|
+
const fullPath = join(dirPath, entry);
|
|
403
|
+
const stat = statSync(fullPath);
|
|
404
|
+
if (stat.isDirectory()) {
|
|
405
|
+
files.push(...getAllTsFiles(fullPath));
|
|
406
|
+
} else if (stat.isFile() && entry.endsWith(".ts")) {
|
|
407
|
+
files.push(fullPath);
|
|
408
|
+
}
|
|
409
|
+
}
|
|
410
|
+
return files;
|
|
411
|
+
}
|
|
412
|
+
__name(getAllTsFiles, "getAllTsFiles");
|
|
413
|
+
function addTsNocheckToFile(filePath) {
|
|
414
|
+
const content = readFileSync(filePath, "utf-8");
|
|
415
|
+
const newContent = `// @ts-nocheck
|
|
416
|
+
${content}`;
|
|
417
|
+
writeFileSync3(filePath, newContent, "utf-8");
|
|
418
|
+
}
|
|
419
|
+
__name(addTsNocheckToFile, "addTsNocheckToFile");
|
|
420
|
+
|
|
388
421
|
// src/modules/devtool-v2/index.ts
|
|
389
422
|
var DevToolsV2Module = class {
|
|
390
423
|
static {
|
|
@@ -423,10 +456,11 @@ var DevToolsV2Module = class {
|
|
|
423
456
|
"@hey-api/sdk",
|
|
424
457
|
{
|
|
425
458
|
name: "@hey-api/client-axios",
|
|
426
|
-
runtimeConfigPath:
|
|
459
|
+
runtimeConfigPath: join2(clientSdkOutPath, "./client.config.ts")
|
|
427
460
|
}
|
|
428
461
|
]
|
|
429
462
|
});
|
|
463
|
+
addTsNocheckToGeneratedFiles(clientSdkOutPath);
|
|
430
464
|
ensureDirAndWrite(openapiPath, JSON.stringify(document, null, 2));
|
|
431
465
|
generateClientConfig({
|
|
432
466
|
outputPath: clientSdkOutPath
|
|
@@ -443,7 +477,7 @@ async function configureApp(app, options) {
|
|
|
443
477
|
app.use(cookieParser());
|
|
444
478
|
const globalPrefix = process.env.CLIENT_BASE_PATH ?? "";
|
|
445
479
|
app.setGlobalPrefix(globalPrefix);
|
|
446
|
-
app.setBaseViewsDir(
|
|
480
|
+
app.setBaseViewsDir(join3(process.cwd(), options?.viewsDir ?? "dist/client"));
|
|
447
481
|
app.setViewEngine("html");
|
|
448
482
|
app.engine("html", hbsExpressEngine);
|
|
449
483
|
if (process.env.NODE_ENV !== "production") {
|
|
@@ -462,7 +496,7 @@ import { resolve as resolve3 } from "path";
|
|
|
462
496
|
|
|
463
497
|
// src/modules/devtool/helper.ts
|
|
464
498
|
import { dirname as dirname2 } from "path";
|
|
465
|
-
import { writeFileSync as
|
|
499
|
+
import { writeFileSync as writeFileSync4, mkdirSync as mkdirSync3 } from "fs";
|
|
466
500
|
function normalizeBasePath2(rawBasePath) {
|
|
467
501
|
const normalizedBasePath = rawBasePath.startsWith("/") ? rawBasePath : `/${rawBasePath}`;
|
|
468
502
|
return normalizedBasePath.endsWith("/") ? normalizedBasePath.slice(0, -1) : normalizedBasePath;
|
|
@@ -493,7 +527,7 @@ function ensureDirAndWrite2(filePath, content) {
|
|
|
493
527
|
mkdirSync3(dir, {
|
|
494
528
|
recursive: true
|
|
495
529
|
});
|
|
496
|
-
|
|
530
|
+
writeFileSync4(filePath, content);
|
|
497
531
|
}
|
|
498
532
|
__name(ensureDirAndWrite2, "ensureDirAndWrite");
|
|
499
533
|
|