@nestia/migrate 6.0.6 → 7.0.0-dev.20250606
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 +92 -92
 - package/lib/NestiaMigrateApplication.d.ts +23 -0
 - package/lib/NestiaMigrateApplication.js +17522 -0
 - package/lib/NestiaMigrateApplication.js.map +1 -0
 - package/lib/analyzers/NestiaMigrateControllerAnalyzer.d.ts +5 -0
 - package/lib/analyzers/{MigrateControllerAnalyzer.js → NestiaMigrateControllerAnalyzer.js} +10 -10
 - package/lib/analyzers/NestiaMigrateControllerAnalyzer.js.map +1 -0
 - package/lib/archivers/NestiaMigrateFileArchiver.d.ts +8 -0
 - package/lib/archivers/NestiaMigrateFileArchiver.js +36 -0
 - package/lib/archivers/NestiaMigrateFileArchiver.js.map +1 -0
 - package/lib/bundles/NEST_TEMPLATE.d.ts +1 -5
 - package/lib/bundles/NEST_TEMPLATE.js +50 -242
 - package/lib/bundles/NEST_TEMPLATE.js.map +1 -1
 - package/lib/bundles/SDK_TEMPLATE.d.ts +1 -5
 - package/lib/bundles/SDK_TEMPLATE.js +23 -107
 - package/lib/bundles/SDK_TEMPLATE.js.map +1 -1
 - package/lib/{internal/MigrateCommander.d.ts → executable/NestiaMigrateCommander.d.ts} +1 -1
 - package/lib/{internal/MigrateCommander.js → executable/NestiaMigrateCommander.js} +23 -21
 - package/lib/executable/NestiaMigrateCommander.js.map +1 -0
 - package/lib/{internal/MigrateInquirer.d.ts → executable/NestiaMigrateInquirer.d.ts} +2 -1
 - package/lib/{internal/MigrateInquirer.js → executable/NestiaMigrateInquirer.js} +22 -9
 - package/lib/executable/NestiaMigrateInquirer.js.map +1 -0
 - package/lib/executable/migrate.js +2 -2
 - package/lib/executable/migrate.js.map +1 -1
 - package/lib/index.mjs +10041 -693
 - package/lib/index.mjs.map +1 -1
 - package/lib/module.d.ts +2 -5
 - package/lib/module.js +2 -5
 - package/lib/module.js.map +1 -1
 - package/lib/programmers/NestiaMigrateApiFileProgrammer.d.ts +13 -0
 - package/lib/programmers/NestiaMigrateApiFileProgrammer.js +40 -0
 - package/lib/programmers/NestiaMigrateApiFileProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateApiFunctionProgrammer.d.ts +14 -0
 - package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js +132 -0
 - package/lib/programmers/NestiaMigrateApiFunctionProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.d.ts +14 -0
 - package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js +237 -0
 - package/lib/programmers/NestiaMigrateApiNamespaceProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateApiProgrammer.d.ts +4 -0
 - package/lib/programmers/{MigrateApiProgrammer.js → NestiaMigrateApiProgrammer.js} +31 -30
 - package/lib/programmers/NestiaMigrateApiProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateApiSimulationProgrammer.d.ts +14 -0
 - package/lib/programmers/{MigrateApiSimulationProgrammer.js → NestiaMigrateApiSimulationProgrammer.js} +54 -36
 - package/lib/programmers/NestiaMigrateApiSimulationProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateApiStartProgrammer.d.ts +4 -0
 - package/lib/programmers/{MigrateApiStartProgrammer.js → NestiaMigrateApiStartProgrammer.js} +23 -20
 - package/lib/programmers/NestiaMigrateApiStartProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateDtoProgrammer.d.ts +15 -0
 - package/lib/programmers/{MigrateDtoProgrammer.js → NestiaMigrateDtoProgrammer.js} +14 -10
 - package/lib/programmers/NestiaMigrateDtoProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateE2eFileProgrammer.d.ts +14 -0
 - package/lib/programmers/NestiaMigrateE2eFileProgrammer.js +81 -0
 - package/lib/programmers/NestiaMigrateE2eFileProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateE2eProgrammer.d.ts +4 -0
 - package/lib/programmers/NestiaMigrateE2eProgrammer.js +32 -0
 - package/lib/programmers/NestiaMigrateE2eProgrammer.js.map +1 -0
 - package/lib/programmers/{MigrateImportProgrammer.d.ts → NestiaMigrateImportProgrammer.d.ts} +1 -1
 - package/lib/programmers/{MigrateImportProgrammer.js → NestiaMigrateImportProgrammer.js} +4 -4
 - package/lib/programmers/NestiaMigrateImportProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateNestControllerProgrammer.d.ts +12 -0
 - package/lib/programmers/{MigrateNestControllerProgrammer.js → NestiaMigrateNestControllerProgrammer.js} +20 -13
 - package/lib/programmers/NestiaMigrateNestControllerProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateNestMethodProgrammer.d.ts +15 -0
 - package/lib/programmers/{MigrateNestMethodProgrammer.js → NestiaMigrateNestMethodProgrammer.js} +85 -69
 - package/lib/programmers/NestiaMigrateNestMethodProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateNestModuleProgrammer.d.ts +5 -0
 - package/lib/programmers/{MigrateNestModuleProgrammer.js → NestiaMigrateNestModuleProgrammer.js} +6 -6
 - package/lib/programmers/NestiaMigrateNestModuleProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateNestProgrammer.d.ts +4 -0
 - package/lib/programmers/NestiaMigrateNestProgrammer.js +65 -0
 - package/lib/programmers/NestiaMigrateNestProgrammer.js.map +1 -0
 - package/lib/programmers/NestiaMigrateSchemaProgrammer.d.ts +10 -0
 - package/lib/programmers/NestiaMigrateSchemaProgrammer.js +414 -0
 - package/lib/programmers/NestiaMigrateSchemaProgrammer.js.map +1 -0
 - package/lib/structures/INestiaMigrateConfig.d.ts +10 -0
 - package/lib/structures/{IHttpMigrateFile.js → INestiaMigrateConfig.js} +1 -1
 - package/lib/structures/INestiaMigrateConfig.js.map +1 -0
 - package/lib/structures/INestiaMigrateContext.d.ts +9 -0
 - package/lib/structures/INestiaMigrateContext.js +3 -0
 - package/lib/structures/INestiaMigrateContext.js.map +1 -0
 - package/lib/structures/INestiaMigrateController.d.ts +7 -0
 - package/lib/structures/{IHttpMigrateController.js → INestiaMigrateController.js} +1 -1
 - package/lib/structures/INestiaMigrateController.js.map +1 -0
 - package/lib/structures/{IHttpMigrateDto.d.ts → INestiaMigrateDto.d.ts} +2 -2
 - package/lib/structures/{IHttpMigrateRoute.js → INestiaMigrateDto.js} +1 -1
 - package/lib/structures/INestiaMigrateDto.js.map +1 -0
 - package/lib/structures/{IHttpMigrateFile.d.ts → INestiaMigrateFile.d.ts} +1 -1
 - package/lib/structures/{IHttpMigrateDto.js → INestiaMigrateFile.js} +1 -1
 - package/lib/structures/INestiaMigrateFile.js.map +1 -0
 - package/lib/structures/INestiaMigrateProgram.d.ts +9 -0
 - package/lib/structures/INestiaMigrateProgram.js +3 -0
 - package/lib/structures/INestiaMigrateProgram.js.map +1 -0
 - package/lib/structures/INestiaMigrateSchema.d.ts +4 -0
 - package/lib/structures/{IHttpMigrateProgram.js → INestiaMigrateSchema.js} +1 -1
 - package/lib/structures/INestiaMigrateSchema.js.map +1 -0
 - package/lib/utils/openapi-down-convert/converter.js +2 -2
 - package/package.json +8 -8
 - package/src/NestiaMigrateApplication.ts +144 -0
 - package/src/analyzers/{MigrateControllerAnalyzer.ts → NestiaMigrateControllerAnalyzer.ts} +51 -51
 - package/src/archivers/NestiaMigrateFileArchiver.ts +28 -0
 - package/src/bundles/NEST_TEMPLATE.ts +50 -242
 - package/src/bundles/SDK_TEMPLATE.ts +23 -107
 - package/src/{internal/MigrateCommander.ts → executable/NestiaMigrateCommander.ts} +98 -94
 - package/src/{internal/MigrateInquirer.ts → executable/NestiaMigrateInquirer.ts} +106 -89
 - package/src/executable/bundle.js +129 -127
 - package/src/executable/migrate.ts +7 -7
 - package/src/factories/TypeLiteralFactory.ts +57 -57
 - package/src/index.ts +4 -4
 - package/src/module.ts +2 -8
 - package/src/programmers/NestiaMigrateApiFileProgrammer.ts +55 -0
 - package/src/programmers/NestiaMigrateApiFunctionProgrammer.ts +256 -0
 - package/src/programmers/NestiaMigrateApiNamespaceProgrammer.ts +524 -0
 - package/src/programmers/NestiaMigrateApiProgrammer.ts +107 -0
 - package/src/programmers/NestiaMigrateApiSimulationProgrammer.ts +340 -0
 - package/src/programmers/NestiaMigrateApiStartProgrammer.ts +198 -0
 - package/src/programmers/{MigrateDtoProgrammer.ts → NestiaMigrateDtoProgrammer.ts} +101 -96
 - package/src/programmers/NestiaMigrateE2eFileProgrammer.ts +153 -0
 - package/src/programmers/NestiaMigrateE2eProgrammer.ts +46 -0
 - package/src/programmers/{MigrateImportProgrammer.ts → NestiaMigrateImportProgrammer.ts} +118 -118
 - package/src/programmers/NestiaMigrateNestControllerProgrammer.ts +66 -0
 - package/src/programmers/NestiaMigrateNestMethodProgrammer.ts +406 -0
 - package/src/programmers/{MigrateNestModuleProgrammer.ts → NestiaMigrateNestModuleProgrammer.ts} +65 -65
 - package/src/programmers/NestiaMigrateNestProgrammer.ts +88 -0
 - package/src/programmers/NestiaMigrateSchemaProgrammer.ts +475 -0
 - package/src/structures/INestiaMigrateConfig.ts +10 -0
 - package/src/structures/INestiaMigrateContext.ts +15 -0
 - package/src/structures/INestiaMigrateController.ts +8 -0
 - package/src/structures/{IHttpMigrateDto.ts → INestiaMigrateDto.ts} +8 -8
 - package/src/structures/{IHttpMigrateFile.ts → INestiaMigrateFile.ts} +5 -5
 - package/src/structures/INestiaMigrateProgram.ts +11 -0
 - package/src/structures/INestiaMigrateSchema.ts +4 -0
 - package/src/utils/FilePrinter.ts +38 -38
 - package/src/utils/MapUtil.ts +13 -13
 - package/src/utils/OpenApiTypeChecker.ts +73 -73
 - package/src/utils/SetupWizard.ts +12 -12
 - package/src/utils/StringUtil.ts +113 -113
 - package/src/utils/openapi-down-convert/RefVisitor.ts +139 -139
 - package/src/utils/openapi-down-convert/converter.ts +527 -527
 - package/lib/MigrateApplication.d.ts +0 -28
 - package/lib/MigrateApplication.js +0 -7994
 - package/lib/MigrateApplication.js.map +0 -1
 - package/lib/analyzers/MigrateApplicationAnalyzer.d.ts +0 -4
 - package/lib/analyzers/MigrateApplicationAnalyzer.js +0 -12
 - package/lib/analyzers/MigrateApplicationAnalyzer.js.map +0 -1
 - package/lib/analyzers/MigrateControllerAnalyzer.d.ts +0 -7
 - package/lib/analyzers/MigrateControllerAnalyzer.js.map +0 -1
 - package/lib/archivers/MigrateFileArchiver.d.ts +0 -8
 - package/lib/archivers/MigrateFileArchiver.js +0 -35
 - package/lib/archivers/MigrateFileArchiver.js.map +0 -1
 - package/lib/internal/MigrateCommander.js.map +0 -1
 - package/lib/internal/MigrateInquirer.js.map +0 -1
 - package/lib/programmers/MigrateApiFileProgrammer.d.ts +0 -11
 - package/lib/programmers/MigrateApiFileProgrammer.js +0 -30
 - package/lib/programmers/MigrateApiFileProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateApiFunctionProgrammer.d.ts +0 -9
 - package/lib/programmers/MigrateApiFunctionProgrammer.js +0 -102
 - package/lib/programmers/MigrateApiFunctionProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateApiNamespaceProgrammer.d.ts +0 -9
 - package/lib/programmers/MigrateApiNamespaceProgrammer.js +0 -142
 - package/lib/programmers/MigrateApiNamespaceProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateApiProgrammer.d.ts +0 -5
 - package/lib/programmers/MigrateApiProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateApiSimulationProgrammer.d.ts +0 -8
 - package/lib/programmers/MigrateApiSimulationProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateApiStartProgrammer.d.ts +0 -5
 - package/lib/programmers/MigrateApiStartProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateDtoProgrammer.d.ts +0 -12
 - package/lib/programmers/MigrateDtoProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateE2eFileProgrammer.d.ts +0 -8
 - package/lib/programmers/MigrateE2eFileProgrammer.js +0 -45
 - package/lib/programmers/MigrateE2eFileProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateE2eProgrammer.d.ts +0 -5
 - package/lib/programmers/MigrateE2eProgrammer.js +0 -25
 - package/lib/programmers/MigrateE2eProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateImportProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateNestControllerProgrammer.d.ts +0 -7
 - package/lib/programmers/MigrateNestControllerProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateNestMethodProgrammer.d.ts +0 -9
 - package/lib/programmers/MigrateNestMethodProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateNestModuleProgrammer.d.ts +0 -5
 - package/lib/programmers/MigrateNestModuleProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateNestProgrammer.d.ts +0 -5
 - package/lib/programmers/MigrateNestProgrammer.js +0 -69
 - package/lib/programmers/MigrateNestProgrammer.js.map +0 -1
 - package/lib/programmers/MigrateSchemaProgrammer.d.ts +0 -6
 - package/lib/programmers/MigrateSchemaProgrammer.js +0 -335
 - package/lib/programmers/MigrateSchemaProgrammer.js.map +0 -1
 - package/lib/structures/IHttpMigrateController.d.ts +0 -7
 - package/lib/structures/IHttpMigrateController.js.map +0 -1
 - package/lib/structures/IHttpMigrateDto.js.map +0 -1
 - package/lib/structures/IHttpMigrateFile.js.map +0 -1
 - package/lib/structures/IHttpMigrateProgram.d.ts +0 -33
 - package/lib/structures/IHttpMigrateProgram.js.map +0 -1
 - package/lib/structures/IHttpMigrateRoute.d.ts +0 -1
 - package/lib/structures/IHttpMigrateRoute.js.map +0 -1
 - package/lib/structures/IHttpMigrateSchema.d.ts +0 -4
 - package/lib/structures/IHttpMigrateSchema.js +0 -3
 - package/lib/structures/IHttpMigrateSchema.js.map +0 -1
 - package/src/MigrateApplication.ts +0 -124
 - package/src/analyzers/MigrateApplicationAnalyzer.ts +0 -18
 - package/src/archivers/MigrateFileArchiver.ts +0 -38
 - package/src/programmers/MigrateApiFileProgrammer.ts +0 -51
 - package/src/programmers/MigrateApiFunctionProgrammer.ts +0 -213
 - package/src/programmers/MigrateApiNamespaceProgrammer.ts +0 -418
 - package/src/programmers/MigrateApiProgrammer.ts +0 -104
 - package/src/programmers/MigrateApiSimulationProgrammer.ts +0 -324
 - package/src/programmers/MigrateApiStartProgrammer.ts +0 -194
 - package/src/programmers/MigrateE2eFileProgrammer.ts +0 -117
 - package/src/programmers/MigrateE2eProgrammer.ts +0 -34
 - package/src/programmers/MigrateNestControllerProgrammer.ts +0 -57
 - package/src/programmers/MigrateNestMethodProgrammer.ts +0 -397
 - package/src/programmers/MigrateNestProgrammer.ts +0 -84
 - package/src/programmers/MigrateSchemaProgrammer.ts +0 -378
 - package/src/structures/IHttpMigrateController.ts +0 -8
 - package/src/structures/IHttpMigrateProgram.ts +0 -35
 - package/src/structures/IHttpMigrateRoute.ts +0 -1
 - package/src/structures/IHttpMigrateSchema.ts +0 -4
 
| 
         @@ -1,94 +1,98 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            import { OpenApiV3, OpenApiV3_1, SwaggerV2 } from "@samchon/openapi";
         
     | 
| 
       2 
     | 
    
         
            -
            import sortImport from "@trivago/prettier-plugin-sort-imports";
         
     | 
| 
       3 
     | 
    
         
            -
            import fs from "fs";
         
     | 
| 
       4 
     | 
    
         
            -
            import path from "path";
         
     | 
| 
       5 
     | 
    
         
            -
            import { format } from "prettier";
         
     | 
| 
       6 
     | 
    
         
            -
            import jsDoc from "prettier-plugin-jsdoc";
         
     | 
| 
       7 
     | 
    
         
            -
            import typia, { IValidation, tags } from "typia";
         
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
            import {  
     | 
| 
       10 
     | 
    
         
            -
            import {  
     | 
| 
       11 
     | 
    
         
            -
            import {  
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
            export namespace  
     | 
| 
       14 
     | 
    
         
            -
              export const main = async (): Promise<void> => {
         
     | 
| 
       15 
     | 
    
         
            -
                const resolve = (str: string | undefined) =>
         
     | 
| 
       16 
     | 
    
         
            -
                  str ? path.resolve(str).split("\\").join("/") : undefined;
         
     | 
| 
       17 
     | 
    
         
            -
                const options:  
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
                 
     | 
| 
       21 
     | 
    
         
            -
                 
     | 
| 
       22 
     | 
    
         
            -
                 
     | 
| 
       23 
     | 
    
         
            -
                  halt(" 
     | 
| 
       24 
     | 
    
         
            -
                else if (fs. 
     | 
| 
       25 
     | 
    
         
            -
                  halt(" 
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                  |  
     | 
| 
       32 
     | 
    
         
            -
                   
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                     
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                   
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                   
     | 
| 
       43 
     | 
    
         
            -
                     
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
                 
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
                 
     | 
| 
       52 
     | 
    
         
            -
                   
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                   
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
                 
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
                 
     | 
| 
       62 
     | 
    
         
            -
                   
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
                 
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
                     
     | 
| 
       82 
     | 
    
         
            -
                     
     | 
| 
       83 
     | 
    
         
            -
                     
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
                 
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            import { OpenApiV3, OpenApiV3_1, SwaggerV2 } from "@samchon/openapi";
         
     | 
| 
      
 2 
     | 
    
         
            +
            import sortImport from "@trivago/prettier-plugin-sort-imports";
         
     | 
| 
      
 3 
     | 
    
         
            +
            import fs from "fs";
         
     | 
| 
      
 4 
     | 
    
         
            +
            import path from "path";
         
     | 
| 
      
 5 
     | 
    
         
            +
            import { format } from "prettier";
         
     | 
| 
      
 6 
     | 
    
         
            +
            import jsDoc from "prettier-plugin-jsdoc";
         
     | 
| 
      
 7 
     | 
    
         
            +
            import typia, { IValidation, tags } from "typia";
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            import { NestiaMigrateApplication } from "../NestiaMigrateApplication";
         
     | 
| 
      
 10 
     | 
    
         
            +
            import { NestiaMigrateFileArchiver } from "../archivers/NestiaMigrateFileArchiver";
         
     | 
| 
      
 11 
     | 
    
         
            +
            import { NestiaMigrateInquirer } from "./NestiaMigrateInquirer";
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
            export namespace NestiaMigrateCommander {
         
     | 
| 
      
 14 
     | 
    
         
            +
              export const main = async (): Promise<void> => {
         
     | 
| 
      
 15 
     | 
    
         
            +
                const resolve = (str: string | undefined) =>
         
     | 
| 
      
 16 
     | 
    
         
            +
                  str ? path.resolve(str).split("\\").join("/") : undefined;
         
     | 
| 
      
 17 
     | 
    
         
            +
                const options: NestiaMigrateInquirer.IOutput =
         
     | 
| 
      
 18 
     | 
    
         
            +
                  await NestiaMigrateInquirer.parse();
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                // VALIDATE OUTPUT DIRECTORY
         
     | 
| 
      
 21 
     | 
    
         
            +
                const parent: string = resolve(options.output + "/..")!;
         
     | 
| 
      
 22 
     | 
    
         
            +
                if (fs.existsSync(options.output))
         
     | 
| 
      
 23 
     | 
    
         
            +
                  halt("Response directory already exists.");
         
     | 
| 
      
 24 
     | 
    
         
            +
                else if (fs.existsSync(parent) === false)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  halt("Response directory's parent directory does not exist.");
         
     | 
| 
      
 26 
     | 
    
         
            +
                else if (fs.statSync(parent).isDirectory() === false)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  halt("Response directory's parent is not a directory.");
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                // READ SWAGGER
         
     | 
| 
      
 30 
     | 
    
         
            +
                const document:
         
     | 
| 
      
 31 
     | 
    
         
            +
                  | SwaggerV2.IDocument
         
     | 
| 
      
 32 
     | 
    
         
            +
                  | OpenApiV3.IDocument
         
     | 
| 
      
 33 
     | 
    
         
            +
                  | OpenApiV3_1.IDocument = await (async () => {
         
     | 
| 
      
 34 
     | 
    
         
            +
                  if (typia.is<string & tags.Format<"uri">>(options.input)) {
         
     | 
| 
      
 35 
     | 
    
         
            +
                    const response: Response = await fetch(options.input);
         
     | 
| 
      
 36 
     | 
    
         
            +
                    const content: string = await response.text();
         
     | 
| 
      
 37 
     | 
    
         
            +
                    return JSON.parse(content);
         
     | 
| 
      
 38 
     | 
    
         
            +
                  }
         
     | 
| 
      
 39 
     | 
    
         
            +
                  if (fs.existsSync(options.input) === false)
         
     | 
| 
      
 40 
     | 
    
         
            +
                    halt("Unable to find the input swagger.json file.");
         
     | 
| 
      
 41 
     | 
    
         
            +
                  const stats: fs.Stats = fs.statSync(options.input);
         
     | 
| 
      
 42 
     | 
    
         
            +
                  if (stats.isFile() === false)
         
     | 
| 
      
 43 
     | 
    
         
            +
                    halt("The input swagger.json is not a file.");
         
     | 
| 
      
 44 
     | 
    
         
            +
                  const content: string = await fs.promises.readFile(
         
     | 
| 
      
 45 
     | 
    
         
            +
                    options.input,
         
     | 
| 
      
 46 
     | 
    
         
            +
                    "utf-8",
         
     | 
| 
      
 47 
     | 
    
         
            +
                  );
         
     | 
| 
      
 48 
     | 
    
         
            +
                  return JSON.parse(content);
         
     | 
| 
      
 49 
     | 
    
         
            +
                })();
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
                const result: IValidation<NestiaMigrateApplication> =
         
     | 
| 
      
 52 
     | 
    
         
            +
                  NestiaMigrateApplication.validate(document);
         
     | 
| 
      
 53 
     | 
    
         
            +
                if (result.success === false) {
         
     | 
| 
      
 54 
     | 
    
         
            +
                  console.log(result.errors);
         
     | 
| 
      
 55 
     | 
    
         
            +
                  throw new Error(
         
     | 
| 
      
 56 
     | 
    
         
            +
                    `Invalid swagger file (must follow the OpenAPI 3.0 spec).`,
         
     | 
| 
      
 57 
     | 
    
         
            +
                  );
         
     | 
| 
      
 58 
     | 
    
         
            +
                }
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                const app: NestiaMigrateApplication = result.data;
         
     | 
| 
      
 61 
     | 
    
         
            +
                const files: Record<string, string> =
         
     | 
| 
      
 62 
     | 
    
         
            +
                  options.mode === "nest" ? app.nest(options) : app.sdk(options);
         
     | 
| 
      
 63 
     | 
    
         
            +
                if (app.getErrors())
         
     | 
| 
      
 64 
     | 
    
         
            +
                  for (const error of app.getErrors())
         
     | 
| 
      
 65 
     | 
    
         
            +
                    console.error(
         
     | 
| 
      
 66 
     | 
    
         
            +
                      `Failed to migrate ${error.method} ${error.path}`,
         
     | 
| 
      
 67 
     | 
    
         
            +
                      ...error.messages.map((msg) => `  - ${msg}`),
         
     | 
| 
      
 68 
     | 
    
         
            +
                    );
         
     | 
| 
      
 69 
     | 
    
         
            +
                await NestiaMigrateFileArchiver.archive({
         
     | 
| 
      
 70 
     | 
    
         
            +
                  mkdir: fs.promises.mkdir,
         
     | 
| 
      
 71 
     | 
    
         
            +
                  writeFile: async (file, content) =>
         
     | 
| 
      
 72 
     | 
    
         
            +
                    fs.promises.writeFile(file, await beautify(content), "utf-8"),
         
     | 
| 
      
 73 
     | 
    
         
            +
                  root: options.output,
         
     | 
| 
      
 74 
     | 
    
         
            +
                  files,
         
     | 
| 
      
 75 
     | 
    
         
            +
                });
         
     | 
| 
      
 76 
     | 
    
         
            +
              };
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
              export const beautify = async (script: string): Promise<string> => {
         
     | 
| 
      
 79 
     | 
    
         
            +
                try {
         
     | 
| 
      
 80 
     | 
    
         
            +
                  return await format(script, {
         
     | 
| 
      
 81 
     | 
    
         
            +
                    parser: "typescript",
         
     | 
| 
      
 82 
     | 
    
         
            +
                    plugins: [sortImport, jsDoc],
         
     | 
| 
      
 83 
     | 
    
         
            +
                    importOrder: ["<THIRD_PARTY_MODULES>", "^[./]"],
         
     | 
| 
      
 84 
     | 
    
         
            +
                    importOrderSeparation: true,
         
     | 
| 
      
 85 
     | 
    
         
            +
                    importOrderSortSpecifiers: true,
         
     | 
| 
      
 86 
     | 
    
         
            +
                    importOrderParserPlugins: ["decorators-legacy", "typescript", "jsx"],
         
     | 
| 
      
 87 
     | 
    
         
            +
                    bracketSpacing: true,
         
     | 
| 
      
 88 
     | 
    
         
            +
                  });
         
     | 
| 
      
 89 
     | 
    
         
            +
                } catch {
         
     | 
| 
      
 90 
     | 
    
         
            +
                  return script;
         
     | 
| 
      
 91 
     | 
    
         
            +
                }
         
     | 
| 
      
 92 
     | 
    
         
            +
              };
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
              const halt = (desc: string): never => {
         
     | 
| 
      
 95 
     | 
    
         
            +
                console.error(desc);
         
     | 
| 
      
 96 
     | 
    
         
            +
                process.exit(-1);
         
     | 
| 
      
 97 
     | 
    
         
            +
              };
         
     | 
| 
      
 98 
     | 
    
         
            +
            }
         
     | 
| 
         @@ -1,89 +1,106 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            import commander from "commander";
         
     | 
| 
       2 
     | 
    
         
            -
            import inquirer from "inquirer";
         
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
            export namespace  
     | 
| 
       5 
     | 
    
         
            -
              export interface IOutput {
         
     | 
| 
       6 
     | 
    
         
            -
                mode: "nest" | "sdk";
         
     | 
| 
       7 
     | 
    
         
            -
                input: string;
         
     | 
| 
       8 
     | 
    
         
            -
                output: string;
         
     | 
| 
       9 
     | 
    
         
            -
                 
     | 
| 
       10 
     | 
    
         
            -
                 
     | 
| 
       11 
     | 
    
         
            -
                 
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
                 
     | 
| 
       17 
     | 
    
         
            -
                commander.program.option(
         
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
                  " 
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
                 
     | 
| 
       22 
     | 
    
         
            -
                commander.program.option("-- 
     | 
| 
       23 
     | 
    
         
            -
                commander.program.option("-- 
     | 
| 
       24 
     | 
    
         
            -
                commander.program.option("-- 
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
                 
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
                 
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
                       
     | 
| 
       34 
     | 
    
         
            -
                         
     | 
| 
       35 
     | 
    
         
            -
                      }
         
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                   
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                   
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
                     
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
                         
     | 
| 
       52 
     | 
    
         
            -
                         
     | 
| 
       53 
     | 
    
         
            -
                         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
                   
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
                       
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                   
     | 
| 
       74 
     | 
    
         
            -
                  partial. 
     | 
| 
       75 
     | 
    
         
            -
                   
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
                   
     | 
| 
       78 
     | 
    
         
            -
                     
     | 
| 
       79 
     | 
    
         
            -
                       
     | 
| 
       80 
     | 
    
         
            -
                      " 
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            import commander from "commander";
         
     | 
| 
      
 2 
     | 
    
         
            +
            import inquirer from "inquirer";
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
      
 4 
     | 
    
         
            +
            export namespace NestiaMigrateInquirer {
         
     | 
| 
      
 5 
     | 
    
         
            +
              export interface IOutput {
         
     | 
| 
      
 6 
     | 
    
         
            +
                mode: "nest" | "sdk";
         
     | 
| 
      
 7 
     | 
    
         
            +
                input: string;
         
     | 
| 
      
 8 
     | 
    
         
            +
                output: string;
         
     | 
| 
      
 9 
     | 
    
         
            +
                keyword: boolean;
         
     | 
| 
      
 10 
     | 
    
         
            +
                simulate: boolean;
         
     | 
| 
      
 11 
     | 
    
         
            +
                e2e: boolean;
         
     | 
| 
      
 12 
     | 
    
         
            +
                package: string;
         
     | 
| 
      
 13 
     | 
    
         
            +
              }
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              export const parse = async (): Promise<IOutput> => {
         
     | 
| 
      
 16 
     | 
    
         
            +
                // PREPARE ASSETS
         
     | 
| 
      
 17 
     | 
    
         
            +
                commander.program.option("--mode [nest/sdk]", "migration mode");
         
     | 
| 
      
 18 
     | 
    
         
            +
                commander.program.option(
         
     | 
| 
      
 19 
     | 
    
         
            +
                  "--input [swagger.json]",
         
     | 
| 
      
 20 
     | 
    
         
            +
                  "location of target swagger.json file",
         
     | 
| 
      
 21 
     | 
    
         
            +
                );
         
     | 
| 
      
 22 
     | 
    
         
            +
                commander.program.option("--output [directory]", "output directory path");
         
     | 
| 
      
 23 
     | 
    
         
            +
                commander.program.option("--keyword [boolean]", "Keyword parameter mode");
         
     | 
| 
      
 24 
     | 
    
         
            +
                commander.program.option("--simulate [boolean]", "Mockup simulator");
         
     | 
| 
      
 25 
     | 
    
         
            +
                commander.program.option("--e2e [boolean]", "Generate E2E tests");
         
     | 
| 
      
 26 
     | 
    
         
            +
                commander.program.option("--package [name]", "Package name");
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                // INTERNAL PROCEDURES
         
     | 
| 
      
 29 
     | 
    
         
            +
                const questioned = { value: false };
         
     | 
| 
      
 30 
     | 
    
         
            +
                const action = (closure: (options: Partial<IOutput>) => Promise<IOutput>) =>
         
     | 
| 
      
 31 
     | 
    
         
            +
                  new Promise<IOutput>((resolve, reject) => {
         
     | 
| 
      
 32 
     | 
    
         
            +
                    commander.program.action(async (options) => {
         
     | 
| 
      
 33 
     | 
    
         
            +
                      try {
         
     | 
| 
      
 34 
     | 
    
         
            +
                        resolve(await closure(options));
         
     | 
| 
      
 35 
     | 
    
         
            +
                      } catch (exp) {
         
     | 
| 
      
 36 
     | 
    
         
            +
                        reject(exp);
         
     | 
| 
      
 37 
     | 
    
         
            +
                      }
         
     | 
| 
      
 38 
     | 
    
         
            +
                    });
         
     | 
| 
      
 39 
     | 
    
         
            +
                    commander.program.parseAsync().catch(reject);
         
     | 
| 
      
 40 
     | 
    
         
            +
                  });
         
     | 
| 
      
 41 
     | 
    
         
            +
                const select =
         
     | 
| 
      
 42 
     | 
    
         
            +
                  (name: string) =>
         
     | 
| 
      
 43 
     | 
    
         
            +
                  (message: string) =>
         
     | 
| 
      
 44 
     | 
    
         
            +
                  async <Choice extends string>(
         
     | 
| 
      
 45 
     | 
    
         
            +
                    choices: Choice[],
         
     | 
| 
      
 46 
     | 
    
         
            +
                    filter?: (value: string) => Choice,
         
     | 
| 
      
 47 
     | 
    
         
            +
                  ): Promise<Choice> => {
         
     | 
| 
      
 48 
     | 
    
         
            +
                    questioned.value = true;
         
     | 
| 
      
 49 
     | 
    
         
            +
                    return (
         
     | 
| 
      
 50 
     | 
    
         
            +
                      await inquirer.createPromptModule()({
         
     | 
| 
      
 51 
     | 
    
         
            +
                        type: "list",
         
     | 
| 
      
 52 
     | 
    
         
            +
                        name: name,
         
     | 
| 
      
 53 
     | 
    
         
            +
                        message: message,
         
     | 
| 
      
 54 
     | 
    
         
            +
                        choices: choices,
         
     | 
| 
      
 55 
     | 
    
         
            +
                        filter,
         
     | 
| 
      
 56 
     | 
    
         
            +
                      })
         
     | 
| 
      
 57 
     | 
    
         
            +
                    )[name];
         
     | 
| 
      
 58 
     | 
    
         
            +
                  };
         
     | 
| 
      
 59 
     | 
    
         
            +
                const input = (name: string) => async (message: string) =>
         
     | 
| 
      
 60 
     | 
    
         
            +
                  (
         
     | 
| 
      
 61 
     | 
    
         
            +
                    await inquirer.createPromptModule()({
         
     | 
| 
      
 62 
     | 
    
         
            +
                      type: "input",
         
     | 
| 
      
 63 
     | 
    
         
            +
                      name,
         
     | 
| 
      
 64 
     | 
    
         
            +
                      message,
         
     | 
| 
      
 65 
     | 
    
         
            +
                    })
         
     | 
| 
      
 66 
     | 
    
         
            +
                  )[name];
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                // DO CONSTRUCT
         
     | 
| 
      
 69 
     | 
    
         
            +
                return action(async (partial) => {
         
     | 
| 
      
 70 
     | 
    
         
            +
                  partial.mode ??= await select("mode")("Migration mode")(
         
     | 
| 
      
 71 
     | 
    
         
            +
                    ["NestJS" as "nest", "SDK" as "sdk"],
         
     | 
| 
      
 72 
     | 
    
         
            +
                    (value) => (value === "NestJS" ? "nest" : "sdk"),
         
     | 
| 
      
 73 
     | 
    
         
            +
                  );
         
     | 
| 
      
 74 
     | 
    
         
            +
                  partial.input ??= await input("input")("Swagger file location");
         
     | 
| 
      
 75 
     | 
    
         
            +
                  partial.output ??= await input("output")("Response directory path");
         
     | 
| 
      
 76 
     | 
    
         
            +
                  partial.package ??= await input("package")("Package name");
         
     | 
| 
      
 77 
     | 
    
         
            +
                  partial.keyword ??=
         
     | 
| 
      
 78 
     | 
    
         
            +
                    (await select("keyword")("Keyword parameter mode")([
         
     | 
| 
      
 79 
     | 
    
         
            +
                      "true",
         
     | 
| 
      
 80 
     | 
    
         
            +
                      "false",
         
     | 
| 
      
 81 
     | 
    
         
            +
                    ])) === "true";
         
     | 
| 
      
 82 
     | 
    
         
            +
             
     | 
| 
      
 83 
     | 
    
         
            +
                  if (partial.keyword)
         
     | 
| 
      
 84 
     | 
    
         
            +
                    partial.keyword = (partial.keyword as any) === "true";
         
     | 
| 
      
 85 
     | 
    
         
            +
                  else
         
     | 
| 
      
 86 
     | 
    
         
            +
                    partial.keyword =
         
     | 
| 
      
 87 
     | 
    
         
            +
                      (await select("keyword")("Keyword parameter mode")([
         
     | 
| 
      
 88 
     | 
    
         
            +
                        "true",
         
     | 
| 
      
 89 
     | 
    
         
            +
                        "false",
         
     | 
| 
      
 90 
     | 
    
         
            +
                      ])) === "true";
         
     | 
| 
      
 91 
     | 
    
         
            +
                  if (partial.simulate)
         
     | 
| 
      
 92 
     | 
    
         
            +
                    partial.simulate = (partial.simulate as any) === "true";
         
     | 
| 
      
 93 
     | 
    
         
            +
                  else
         
     | 
| 
      
 94 
     | 
    
         
            +
                    partial.simulate =
         
     | 
| 
      
 95 
     | 
    
         
            +
                      (await select("simulate")("Mokup Simulator")(["true", "false"])) ===
         
     | 
| 
      
 96 
     | 
    
         
            +
                      "true";
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
      
 98 
     | 
    
         
            +
                  if (partial.e2e) partial.e2e = (partial.e2e as any) === "true";
         
     | 
| 
      
 99 
     | 
    
         
            +
                  else
         
     | 
| 
      
 100 
     | 
    
         
            +
                    partial.e2e =
         
     | 
| 
      
 101 
     | 
    
         
            +
                      (await select("e2e")("Generate E2E tests")(["true", "false"])) ===
         
     | 
| 
      
 102 
     | 
    
         
            +
                      "true";
         
     | 
| 
      
 103 
     | 
    
         
            +
                  return partial as IOutput;
         
     | 
| 
      
 104 
     | 
    
         
            +
                });
         
     | 
| 
      
 105 
     | 
    
         
            +
              };
         
     | 
| 
      
 106 
     | 
    
         
            +
            }
         
     | 
    
        package/src/executable/bundle.js
    CHANGED
    
    | 
         @@ -1,127 +1,129 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            const { version } = require("../../../../package.json");
         
     | 
| 
       2 
     | 
    
         
            -
            const cp = require("child_process");
         
     | 
| 
       3 
     | 
    
         
            -
            const fs = require("fs");
         
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
            const ROOT = `${__dirname}/../..`;
         
     | 
| 
       6 
     | 
    
         
            -
            const ASSETS = `${ROOT}/assets`;
         
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
            const update = (content) => {
         
     | 
| 
       9 
     | 
    
         
            -
              const parsed = JSON.parse(content);
         
     | 
| 
       10 
     | 
    
         
            -
              for (const record of [
         
     | 
| 
       11 
     | 
    
         
            -
                parsed.dependencies ?? {},
         
     | 
| 
       12 
     | 
    
         
            -
                parsed.devDependencies ?? {},
         
     | 
| 
       13 
     | 
    
         
            -
              ])
         
     | 
| 
       14 
     | 
    
         
            -
                for (const key of Object.keys(record))
         
     | 
| 
       15 
     | 
    
         
            -
                  if (
         
     | 
| 
       16 
     | 
    
         
            -
                    key === "@nestia/core" ||
         
     | 
| 
       17 
     | 
    
         
            -
                    key === "@nestia/fetcher" ||
         
     | 
| 
       18 
     | 
    
         
            -
                    key === "@nestia/sdk"
         
     | 
| 
       19 
     | 
    
         
            -
                  )
         
     | 
| 
       20 
     | 
    
         
            -
                    record[key] = `^${version}`;
         
     | 
| 
       21 
     | 
    
         
            -
              return JSON.stringify(parsed, null, 2);
         
     | 
| 
       22 
     | 
    
         
            -
            };
         
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
            const bundle = async ({ mode, repository, exceptions, transform }) => {
         
     | 
| 
       25 
     | 
    
         
            -
              const root = `${__dirname}/../..`;
         
     | 
| 
       26 
     | 
    
         
            -
              const assets = `${root}/assets`;
         
     | 
| 
       27 
     | 
    
         
            -
              const template = `${assets}/${mode}`;
         
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
              const clone = async () => {
         
     | 
| 
       30 
     | 
    
         
            -
                // CLONE REPOSITORY
         
     | 
| 
       31 
     | 
    
         
            -
                if (fs.existsSync(template))
         
     | 
| 
       32 
     | 
    
         
            -
                  await fs.promises.rm(template, { recursive: true });
         
     | 
| 
       33 
     | 
    
         
            -
                else
         
     | 
| 
       34 
     | 
    
         
            -
                  try {
         
     | 
| 
       35 
     | 
    
         
            -
                    await fs.promises.mkdir(ASSETS);
         
     | 
| 
       36 
     | 
    
         
            -
                  } catch {}
         
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
                cp.execSync(`git clone https://github.com/samchon/${repository} ${mode}`, {
         
     | 
| 
       39 
     | 
    
         
            -
                  cwd: ASSETS,
         
     | 
| 
       40 
     | 
    
         
            -
                });
         
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
                // REMOVE VULNERABLE FILES
         
     | 
| 
       43 
     | 
    
         
            -
                for (const location of exceptions ?? [])
         
     | 
| 
       44 
     | 
    
         
            -
                  await fs.promises.rm(`${template}/${location}`, { recursive: true });
         
     | 
| 
       45 
     | 
    
         
            -
              };
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
              const iterate = (collection) => async (location) => {
         
     | 
| 
       48 
     | 
    
         
            -
                const directory = await fs.promises.readdir(location);
         
     | 
| 
       49 
     | 
    
         
            -
                for (const file of directory) {
         
     | 
| 
       50 
     | 
    
         
            -
                  const absolute = location + "/" + file;
         
     | 
| 
       51 
     | 
    
         
            -
                  const stats = await fs.promises.stat(absolute);
         
     | 
| 
       52 
     | 
    
         
            -
                  if (stats.isDirectory()) await iterate(collection)(absolute);
         
     | 
| 
       53 
     | 
    
         
            -
                  else {
         
     | 
| 
       54 
     | 
    
         
            -
                    const content = await fs.promises.readFile(absolute, "utf-8");
         
     | 
| 
       55 
     | 
    
         
            -
                    collection 
     | 
| 
       56 
     | 
    
         
            -
                       
     | 
| 
       57 
     | 
    
         
            -
                        const str =  
     | 
| 
       58 
     | 
    
         
            -
                        return str[0] === "/" ? str.substring(1) : str;
         
     | 
| 
       59 
     | 
    
         
            -
                      })() 
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
               
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                const name =  
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
                 
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
                 
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
                   
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
              };
         
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
               
     | 
| 
       83 
     | 
    
         
            -
               
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
              await archive(collection);
         
     | 
| 
       87 
     | 
    
         
            -
            };
         
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
            const main = async () => {
         
     | 
| 
       90 
     | 
    
         
            -
              await bundle({
         
     | 
| 
       91 
     | 
    
         
            -
                mode: "nest",
         
     | 
| 
       92 
     | 
    
         
            -
                repository: "nestia-start",
         
     | 
| 
       93 
     | 
    
         
            -
                exceptions: [
         
     | 
| 
       94 
     | 
    
         
            -
                  ".git",
         
     | 
| 
       95 
     | 
    
         
            -
                  ".github/dependabot.yml",
         
     | 
| 
       96 
     | 
    
         
            -
                  ".github/workflows/dependabot-automerge.yml",
         
     | 
| 
       97 
     | 
    
         
            -
                  "src/api/functional",
         
     | 
| 
       98 
     | 
    
         
            -
                  "src/controllers",
         
     | 
| 
       99 
     | 
    
         
            -
                  "src/MyModule.ts",
         
     | 
| 
       100 
     | 
    
         
            -
                  "src/providers",
         
     | 
| 
       101 
     | 
    
         
            -
                  "test/features",
         
     | 
| 
       102 
     | 
    
         
            -
                ],
         
     | 
| 
       103 
     | 
    
         
            -
                transform: ( 
     | 
| 
       104 
     | 
    
         
            -
                  if ( 
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
               
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
                 
     | 
| 
       110 
     | 
    
         
            -
                 
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
                  ". 
     | 
| 
       113 
     | 
    
         
            -
                  ".github/ 
     | 
| 
       114 
     | 
    
         
            -
                  ".github/workflows/ 
     | 
| 
       115 
     | 
    
         
            -
                  " 
     | 
| 
       116 
     | 
    
         
            -
                  "src/ 
     | 
| 
       117 
     | 
    
         
            -
                  " 
     | 
| 
       118 
     | 
    
         
            -
             
     | 
| 
       119 
     | 
    
         
            -
                 
     | 
| 
       120 
     | 
    
         
            -
             
     | 
| 
       121 
     | 
    
         
            -
             
     | 
| 
       122 
     | 
    
         
            -
             
     | 
| 
       123 
     | 
    
         
            -
            } 
     | 
| 
       124 
     | 
    
         
            -
             
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            const { version } = require("../../../../package.json");
         
     | 
| 
      
 2 
     | 
    
         
            +
            const cp = require("child_process");
         
     | 
| 
      
 3 
     | 
    
         
            +
            const fs = require("fs");
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            const ROOT = `${__dirname}/../..`;
         
     | 
| 
      
 6 
     | 
    
         
            +
            const ASSETS = `${ROOT}/assets`;
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
            const update = (content) => {
         
     | 
| 
      
 9 
     | 
    
         
            +
              const parsed = JSON.parse(content);
         
     | 
| 
      
 10 
     | 
    
         
            +
              for (const record of [
         
     | 
| 
      
 11 
     | 
    
         
            +
                parsed.dependencies ?? {},
         
     | 
| 
      
 12 
     | 
    
         
            +
                parsed.devDependencies ?? {},
         
     | 
| 
      
 13 
     | 
    
         
            +
              ])
         
     | 
| 
      
 14 
     | 
    
         
            +
                for (const key of Object.keys(record))
         
     | 
| 
      
 15 
     | 
    
         
            +
                  if (
         
     | 
| 
      
 16 
     | 
    
         
            +
                    key === "@nestia/core" ||
         
     | 
| 
      
 17 
     | 
    
         
            +
                    key === "@nestia/fetcher" ||
         
     | 
| 
      
 18 
     | 
    
         
            +
                    key === "@nestia/sdk"
         
     | 
| 
      
 19 
     | 
    
         
            +
                  )
         
     | 
| 
      
 20 
     | 
    
         
            +
                    record[key] = `^${version}`;
         
     | 
| 
      
 21 
     | 
    
         
            +
              return JSON.stringify(parsed, null, 2);
         
     | 
| 
      
 22 
     | 
    
         
            +
            };
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            const bundle = async ({ mode, repository, exceptions, transform }) => {
         
     | 
| 
      
 25 
     | 
    
         
            +
              const root = `${__dirname}/../..`;
         
     | 
| 
      
 26 
     | 
    
         
            +
              const assets = `${root}/assets`;
         
     | 
| 
      
 27 
     | 
    
         
            +
              const template = `${assets}/${mode}`;
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              const clone = async () => {
         
     | 
| 
      
 30 
     | 
    
         
            +
                // CLONE REPOSITORY
         
     | 
| 
      
 31 
     | 
    
         
            +
                if (fs.existsSync(template))
         
     | 
| 
      
 32 
     | 
    
         
            +
                  await fs.promises.rm(template, { recursive: true });
         
     | 
| 
      
 33 
     | 
    
         
            +
                else
         
     | 
| 
      
 34 
     | 
    
         
            +
                  try {
         
     | 
| 
      
 35 
     | 
    
         
            +
                    await fs.promises.mkdir(ASSETS);
         
     | 
| 
      
 36 
     | 
    
         
            +
                  } catch {}
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                cp.execSync(`git clone https://github.com/samchon/${repository} ${mode}`, {
         
     | 
| 
      
 39 
     | 
    
         
            +
                  cwd: ASSETS,
         
     | 
| 
      
 40 
     | 
    
         
            +
                });
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                // REMOVE VULNERABLE FILES
         
     | 
| 
      
 43 
     | 
    
         
            +
                for (const location of exceptions ?? [])
         
     | 
| 
      
 44 
     | 
    
         
            +
                  await fs.promises.rm(`${template}/${location}`, { recursive: true });
         
     | 
| 
      
 45 
     | 
    
         
            +
              };
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              const iterate = (collection) => async (location) => {
         
     | 
| 
      
 48 
     | 
    
         
            +
                const directory = await fs.promises.readdir(location);
         
     | 
| 
      
 49 
     | 
    
         
            +
                for (const file of directory) {
         
     | 
| 
      
 50 
     | 
    
         
            +
                  const absolute = location + "/" + file;
         
     | 
| 
      
 51 
     | 
    
         
            +
                  const stats = await fs.promises.stat(absolute);
         
     | 
| 
      
 52 
     | 
    
         
            +
                  if (stats.isDirectory()) await iterate(collection)(absolute);
         
     | 
| 
      
 53 
     | 
    
         
            +
                  else {
         
     | 
| 
      
 54 
     | 
    
         
            +
                    const content = await fs.promises.readFile(absolute, "utf-8");
         
     | 
| 
      
 55 
     | 
    
         
            +
                    collection[
         
     | 
| 
      
 56 
     | 
    
         
            +
                      (() => {
         
     | 
| 
      
 57 
     | 
    
         
            +
                        const str = absolute.replace(template, "");
         
     | 
| 
      
 58 
     | 
    
         
            +
                        return str[0] === "/" ? str.substring(1) : str;
         
     | 
| 
      
 59 
     | 
    
         
            +
                      })()
         
     | 
| 
      
 60 
     | 
    
         
            +
                    ] = content;
         
     | 
| 
      
 61 
     | 
    
         
            +
                  }
         
     | 
| 
      
 62 
     | 
    
         
            +
                }
         
     | 
| 
      
 63 
     | 
    
         
            +
              };
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
              const archive = async (collection) => {
         
     | 
| 
      
 66 
     | 
    
         
            +
                const name = `${mode.toUpperCase()}_TEMPLATE`;
         
     | 
| 
      
 67 
     | 
    
         
            +
                const body = JSON.stringify(collection, null, 2);
         
     | 
| 
      
 68 
     | 
    
         
            +
                const content = `export const ${name}: Record<string, string> = ${body}`;
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                try {
         
     | 
| 
      
 71 
     | 
    
         
            +
                  await fs.promises.mkdir(`${ROOT}/src/bundles`);
         
     | 
| 
      
 72 
     | 
    
         
            +
                } catch {}
         
     | 
| 
      
 73 
     | 
    
         
            +
                await fs.promises.writeFile(
         
     | 
| 
      
 74 
     | 
    
         
            +
                  `${ROOT}/src/bundles/${name}.ts`,
         
     | 
| 
      
 75 
     | 
    
         
            +
                  content,
         
     | 
| 
      
 76 
     | 
    
         
            +
                  "utf8",
         
     | 
| 
      
 77 
     | 
    
         
            +
                );
         
     | 
| 
      
 78 
     | 
    
         
            +
              };
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
              const collection = {};
         
     | 
| 
      
 81 
     | 
    
         
            +
              await clone();
         
     | 
| 
      
 82 
     | 
    
         
            +
              await iterate(collection)(template);
         
     | 
| 
      
 83 
     | 
    
         
            +
              if (transform)
         
     | 
| 
      
 84 
     | 
    
         
            +
                for (const [key, value] of Object.entries(collection))
         
     | 
| 
      
 85 
     | 
    
         
            +
                  collection[key] = transform(key, value);
         
     | 
| 
      
 86 
     | 
    
         
            +
              await archive(collection);
         
     | 
| 
      
 87 
     | 
    
         
            +
            };
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
            const main = async () => {
         
     | 
| 
      
 90 
     | 
    
         
            +
              await bundle({
         
     | 
| 
      
 91 
     | 
    
         
            +
                mode: "nest",
         
     | 
| 
      
 92 
     | 
    
         
            +
                repository: "nestia-start",
         
     | 
| 
      
 93 
     | 
    
         
            +
                exceptions: [
         
     | 
| 
      
 94 
     | 
    
         
            +
                  ".git",
         
     | 
| 
      
 95 
     | 
    
         
            +
                  ".github/dependabot.yml",
         
     | 
| 
      
 96 
     | 
    
         
            +
                  ".github/workflows/dependabot-automerge.yml",
         
     | 
| 
      
 97 
     | 
    
         
            +
                  "src/api/functional",
         
     | 
| 
      
 98 
     | 
    
         
            +
                  "src/controllers",
         
     | 
| 
      
 99 
     | 
    
         
            +
                  "src/MyModule.ts",
         
     | 
| 
      
 100 
     | 
    
         
            +
                  "src/providers",
         
     | 
| 
      
 101 
     | 
    
         
            +
                  "test/features",
         
     | 
| 
      
 102 
     | 
    
         
            +
                ],
         
     | 
| 
      
 103 
     | 
    
         
            +
                transform: (key, value) => {
         
     | 
| 
      
 104 
     | 
    
         
            +
                  if (key === "package.json") return update(value);
         
     | 
| 
      
 105 
     | 
    
         
            +
                  return value;
         
     | 
| 
      
 106 
     | 
    
         
            +
                },
         
     | 
| 
      
 107 
     | 
    
         
            +
              });
         
     | 
| 
      
 108 
     | 
    
         
            +
              await bundle({
         
     | 
| 
      
 109 
     | 
    
         
            +
                mode: "sdk",
         
     | 
| 
      
 110 
     | 
    
         
            +
                repository: "nestia-sdk-template",
         
     | 
| 
      
 111 
     | 
    
         
            +
                exceptions: [
         
     | 
| 
      
 112 
     | 
    
         
            +
                  ".git",
         
     | 
| 
      
 113 
     | 
    
         
            +
                  ".github/dependabot.yml",
         
     | 
| 
      
 114 
     | 
    
         
            +
                  ".github/workflows/build.yml",
         
     | 
| 
      
 115 
     | 
    
         
            +
                  ".github/workflows/dependabot-automerge.yml",
         
     | 
| 
      
 116 
     | 
    
         
            +
                  "src/functional",
         
     | 
| 
      
 117 
     | 
    
         
            +
                  "src/structures",
         
     | 
| 
      
 118 
     | 
    
         
            +
                  "test/features",
         
     | 
| 
      
 119 
     | 
    
         
            +
                ],
         
     | 
| 
      
 120 
     | 
    
         
            +
                transform: (key, value) => {
         
     | 
| 
      
 121 
     | 
    
         
            +
                  if (key === "package.json") return update(value);
         
     | 
| 
      
 122 
     | 
    
         
            +
                  return value;
         
     | 
| 
      
 123 
     | 
    
         
            +
                },
         
     | 
| 
      
 124 
     | 
    
         
            +
              });
         
     | 
| 
      
 125 
     | 
    
         
            +
            };
         
     | 
| 
      
 126 
     | 
    
         
            +
            main().catch((exp) => {
         
     | 
| 
      
 127 
     | 
    
         
            +
              console.error(exp);
         
     | 
| 
      
 128 
     | 
    
         
            +
              process.exit(-1);
         
     | 
| 
      
 129 
     | 
    
         
            +
            });
         
     |