????

Your IP : 3.149.249.124


Current Path : C:/inetpub/vhost/binhdinhinvest.gdtvietnam.com/api/node_modules/typeorm/commands/
Upload File :
Current File : C:/inetpub/vhost/binhdinhinvest.gdtvietnam.com/api/node_modules/typeorm/commands/InitCommand.js.map

{"version":3,"sources":["../../src/commands/InitCommand.ts"],"names":[],"mappings":";;;;AAAA,iDAA6C;AAC7C,mDAA4B;AAE5B,0DAAyB;AACzB,iDAAoC;AACpC,oCAAuC;AACvC,6DAAyD;AAEzD;;GAEG;AACH,MAAa,WAAW;IAAxB;QACI,YAAO,GAAG,MAAM,CAAA;QAChB,aAAQ,GACJ,+CAA+C;YAC/C,wEAAwE;YACxE,mEAAmE,CAAA;IAmuB3E,CAAC;IAjuBG,OAAO,CAAC,IAAgB;QACpB,OAAO,IAAI;aACN,MAAM,CAAC,GAAG,EAAE;YACT,KAAK,EAAE,MAAM;YACb,QAAQ,EAAE,gCAAgC;SAC7C,CAAC;aACD,MAAM,CAAC,IAAI,EAAE;YACV,KAAK,EAAE,UAAU;YACjB,QAAQ,EAAE,2CAA2C;SACxD,CAAC;aACD,MAAM,CAAC,SAAS,EAAE;YACf,QAAQ,EACJ,8FAA8F;SACrG,CAAC;aACD,MAAM,CAAC,QAAQ,EAAE;YACd,QAAQ,EACJ,4EAA4E;SACnF,CAAC;aACD,MAAM,CAAC,IAAI,EAAE;YACV,KAAK,EAAE,SAAS;YAChB,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;YACxB,OAAO,EAAE,KAAK;YACd,QAAQ,EAAE,oDAAoD;SACjE,CAAC;aACD,MAAM,CAAC,IAAI,EAAE;YACV,KAAK,EAAE,QAAQ;YACf,OAAO,EAAE,CAAC,UAAU,EAAE,KAAK,CAAC;YAC5B,OAAO,EAAE,UAAU;YACnB,QAAQ,EACJ,wEAAwE;SAC/E,CAAC,CAAA;IACV,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,IAAqB;QAC/B,IAAI;YACA,MAAM,QAAQ,GAAY,I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AAA;YAC/C,WAAW,CAAC,YAAY,CAAC,aAAa,CAAC,GAAG,SAAS,CAAA;SACtD;QAED,IAAI,CAAC,WAAW,CAAC,OAAO;YAAE,WAAW,CAAC,OAAO,GAAG,EAAE,CAAA;QAElD,IAAI,YAAY;YACZ,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE;gBAC/B,KAAK,EAAE,8CAA8C,CAAC,wCAAwC;gBAC9F,OAAO,EAAE,qBAAqB;aACjC,CAAC,CAAA;;YAEF,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE;gBAC/B,KAAK,EAAE,8CAA8C,CAAC,sBAAsB;gBAC5E,OAAO,EAAE,0BAA0B;aACtC,CAAC,CAAA;QAEN,OAAO,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,SAAS,EAAE,CAAC,CAAC,CAAA;IACpD,CAAC;CACJ;AAxuBD,kCAwuBC","file":"InitCommand.js","sourcesContent":["import { CommandUtils } from \"./CommandUtils\"\nimport * as path from \"path\"\nimport * as yargs from \"yargs\"\nimport chalk from \"chalk\"\nimport { exec } from \"child_process\"\nimport { TypeORMError } from \"../error\"\nimport { PlatformTools } from \"../platform/PlatformTools\"\n\n/**\n * Generates a new project with TypeORM.\n */\nexport class InitCommand implements yargs.CommandModule {\n    command = \"init\"\n    describe =\n        \"Generates initial TypeORM project structure. \" +\n        \"If name specified then creates files inside directory called as name. \" +\n        \"If its not specified then creates files inside current directory.\"\n\n    builder(args: yargs.Argv) {\n        return args\n            .option(\"n\", {\n                alias: \"name\",\n                describe: \"Name of the project directory.\",\n            })\n            .option(\"db\", {\n                alias: \"database\",\n                describe: \"Database type you'll use in your project.\",\n            })\n            .option(\"express\", {\n                describe:\n                    \"Indicates if express server sample code should be included in the project. False by default.\",\n            })\n            .option(\"docker\", {\n                describe:\n                    \"Set to true if docker-compose must be generated as well. False by default.\",\n            })\n            .option(\"pm\", {\n                alias: \"manager\",\n                choices: [\"npm\", \"yarn\"],\n                default: \"npm\",\n                describe: \"Install packages, expected values are npm or yarn.\",\n            })\n            .option(\"ms\", {\n                alias: \"module\",\n                choices: [\"commonjs\", \"esm\"],\n                default: \"commonjs\",\n                describe:\n                    \"Module system to use for project, expected values are commonjs or esm.\",\n            })\n    }\n\n    async handler(args: yargs.Arguments) {\n        try {\n            const database: string = (args.database as any) || \"postgres\"\n            const isExpress = args.express !== undefined ? true : false\n            const isDocker = args.docker !== undefined ? true : false\n            const basePath = process.cwd() + (args.name ? \"/\" + args.name : \"\")\n            const projectName = args.name\n                ? path.basename(args.name as any)\n                : undefined\n            const installNpm = args.pm === \"yarn\" ? false : true\n            const projectIsEsm = args.ms === \"esm\"\n            await CommandUtils.createFile(\n                basePath + \"/package.json\",\n                InitCommand.getPackageJsonTemplate(projectName, projectIsEsm),\n                false,\n            )\n            if (isDocker)\n                await CommandUtils.createFile(\n                    basePath + \"/docker-compose.yml\",\n                    InitCommand.getDockerComposeTemplate(database),\n                    false,\n                )\n            await CommandUtils.createFile(\n                basePath + \"/.gitignore\",\n                InitCommand.getGitIgnoreFile(),\n            )\n            await CommandUtils.createFile(\n                basePath + \"/README.md\",\n                InitCommand.getReadmeTemplate({ docker: isDocker }),\n                false,\n            )\n            await CommandUtils.createFile(\n                basePath + \"/tsconfig.json\",\n                InitCommand.getTsConfigTemplate(projectIsEsm),\n            )\n            await CommandUtils.createFile(\n                basePath + \"/src/entity/User.ts\",\n                InitCommand.getUserEntityTemplate(database),\n            )\n            await CommandUtils.createFile(\n                basePath + \"/src/data-source.ts\",\n                InitCommand.getAppDataSourceTemplate(projectIsEsm, database),\n            )\n            await CommandUtils.createFile(\n                basePath + \"/src/index.ts\",\n                InitCommand.getAppIndexTemplate(isExpress, projectIsEsm),\n            )\n            await CommandUtils.createDirectories(basePath + \"/src/migration\")\n\n            // generate extra files for express application\n            if (isExpress) {\n                await CommandUtils.createFile(\n                    basePath + \"/src/routes.ts\",\n                    InitCommand.getRoutesTemplate(projectIsEsm),\n                )\n                await CommandUtils.createFile(\n                    basePath + \"/src/controller/UserController.ts\",\n                    InitCommand.getControllerTemplate(projectIsEsm),\n                )\n            }\n\n            const packageJsonContents = await CommandUtils.readFile(\n                basePath + \"/package.json\",\n            )\n            await CommandUtils.createFile(\n                basePath + \"/package.json\",\n                InitCommand.appendPackageJson(\n                    packageJsonContents,\n                    database,\n                    isExpress,\n                    projectIsEsm,\n                ),\n            )\n\n            if (args.name) {\n                console.log(\n                    chalk.green(\n                        `Project created inside ${chalk.blue(\n                            basePath,\n                        )} directory.`,\n                    ),\n                )\n            } else {\n                console.log(\n                    chalk.green(`Project created inside current directory.`),\n                )\n            }\n\n            console.log(chalk.green(`Please wait, installing dependencies...`))\n            if (args.pm && installNpm) {\n                await InitCommand.executeCommand(\"npm install\", basePath)\n            } else {\n                await InitCommand.executeCommand(\"yarn install\", basePath)\n            }\n\n            console.log(chalk.green(`Done! Start playing with a new project!`))\n        } catch (err) {\n            PlatformTools.logCmdErr(\"Error during project initialization:\", err)\n            process.exit(1)\n        }\n    }\n\n    // -------------------------------------------------------------------------\n    // Protected Static Methods\n    // -------------------------------------------------------------------------\n\n    protected static executeCommand(command: string, cwd: string) {\n        return new Promise<string>((ok, fail) => {\n            exec(command, { cwd }, (error: any, stdout: any, stderr: any) => {\n                if (stdout) return ok(stdout)\n                if (stderr) return fail(stderr)\n                if (error) return fail(error)\n                ok(\"\")\n            })\n        })\n    }\n\n    /**\n     * Gets contents of the ormconfig file.\n     */\n    protected static getAppDataSourceTemplate(\n        isEsm: boolean,\n        database: string,\n    ): string {\n        let dbSettings = \"\"\n        switch (database) {\n            case \"mysql\":\n                dbSettings = `type: \"mysql\",\n    host: \"localhost\",\n    port: 3306,\n    username: \"test\",\n    password: \"test\",\n    database: \"test\",`\n                break\n            case \"mariadb\":\n                dbSettings = `type: \"mariadb\",\n    host: \"localhost\",\n    port: 3306,\n    username: \"test\",\n    password: \"test\",\n    database: \"test\",`\n                break\n            case \"sqlite\":\n                dbSettings = `type: \"sqlite\",\n    database: \"database.sqlite\",`\n                break\n            case \"better-sqlite3\":\n                dbSettings = `type: \"better-sqlite3\",\n    database: \"database.sqlite\",`\n                break\n            case \"postgres\":\n                dbSettings = `type: \"postgres\",\n    host: \"localhost\",\n    port: 5432,\n    username: \"test\",\n    password: \"test\",\n    database: \"test\",`\n                break\n            case \"cockroachdb\":\n                dbSettings = `type: \"cockroachdb\",\n    host: \"localhost\",\n    port: 26257,\n    username: \"root\",\n    password: \"\",\n    database: \"defaultdb\",`\n                break\n            case \"mssql\":\n                dbSettings = `type: \"mssql\",\n    host: \"localhost\",\n    username: \"sa\",\n    password: \"Admin12345\",\n    database: \"tempdb\",`\n                break\n            case \"oracle\":\n                dbSettings = `type: \"oracle\",\nhost: \"localhost\",\nusername: \"system\",\npassword: \"oracle\",\nport: 1521,\nsid: \"xe.oracle.docker\",`\n                break\n            case \"mongodb\":\n                dbSettings = `type: \"mongodb\",\n    database: \"test\",`\n                break\n            case \"spanner\":\n                dbSettings = `type: \"spanner\",\n    projectId: \"test\",\n    instanceId: \"test\",\n    databaseId: \"test\",`\n                break\n        }\n        return `import \"reflect-metadata\"\nimport { DataSource } from \"typeorm\"\nimport { User } from \"./entity/User${isEsm ? \".js\" : \"\"}\"\n\nexport const AppDataSource = new DataSource({\n    ${dbSettings}\n    synchronize: true,\n    logging: false,\n    entities: [User],\n    migrations: [],\n    subscribers: [],\n})\n`\n    }\n\n    /**\n     * Gets contents of the ormconfig file.\n     */\n    protected static getTsConfigTemplate(esmModule: boolean): string {\n        if (esmModule)\n            return JSON.stringify(\n                {\n                    compilerOptions: {\n                        lib: [\"es2021\"],\n                        target: \"es2021\",\n                        module: \"es2022\",\n                        moduleResolution: \"node\",\n                        allowSyntheticDefaultImports: true,\n                        outDir: \"./build\",\n                        emitDecoratorMetadata: true,\n                        experimentalDecorators: true,\n                        sourceMap: true,\n                    },\n                },\n                undefined,\n                3,\n            )\n        else\n            return JSON.stringify(\n                {\n                    compilerOptions: {\n                        lib: [\"es5\", \"es6\"],\n                        target: \"es5\",\n                        module: \"commonjs\",\n                        moduleResolution: \"node\",\n                        outDir: \"./build\",\n                        emitDecoratorMetadata: true,\n                        experimentalDecorators: true,\n                        sourceMap: true,\n                    },\n                },\n                undefined,\n                3,\n            )\n    }\n\n    /**\n     * Gets contents of the .gitignore file.\n     */\n    protected static getGitIgnoreFile(): string {\n        return `.idea/\n.vscode/\nnode_modules/\nbuild/\ntmp/\ntemp/`\n    }\n\n    /**\n     * Gets contents of the user entity.\n     */\n    protected static getUserEntityTemplate(database: string): string {\n        return `import { Entity, ${\n            database === \"mongodb\"\n                ? \"ObjectIdColumn, ObjectId\"\n                : \"PrimaryGeneratedColumn\"\n        }, Column } from \"typeorm\"\n\n@Entity()\nexport class User {\n\n    ${\n        database === \"mongodb\"\n            ? \"@ObjectIdColumn()\"\n            : \"@PrimaryGeneratedColumn()\"\n    }\n    id: ${database === \"mongodb\" ? \"ObjectId\" : \"number\"}\n\n    @Column()\n    firstName: string\n\n    @Column()\n    lastName: string\n\n    @Column()\n    age: number\n\n}\n`\n    }\n\n    /**\n     * Gets contents of the route file (used when express is enabled).\n     */\n    protected static getRoutesTemplate(isEsm: boolean): string {\n        return `import { UserController } from \"./controller/UserController${\n            isEsm ? \".js\" : \"\"\n        }\"\n\nexport const Routes = [{\n    method: \"get\",\n    route: \"/users\",\n    controller: UserController,\n    action: \"all\"\n}, {\n    method: \"get\",\n    route: \"/users/:id\",\n    controller: UserController,\n    action: \"one\"\n}, {\n    method: \"post\",\n    route: \"/users\",\n    controller: UserController,\n    action: \"save\"\n}, {\n    method: \"delete\",\n    route: \"/users/:id\",\n    controller: UserController,\n    action: \"remove\"\n}]`\n    }\n\n    /**\n     * Gets contents of the user controller file (used when express is enabled).\n     */\n    protected static getControllerTemplate(isEsm: boolean): string {\n        return `import { AppDataSource } from \"../data-source${\n            isEsm ? \".js\" : \"\"\n        }\"\nimport { NextFunction, Request, Response } from \"express\"\nimport { User } from \"../entity/User${isEsm ? \".js\" : \"\"}\"\n\nexport class UserController {\n\n    private userRepository = AppDataSource.getRepository(User)\n\n    async all(request: Request, response: Response, next: NextFunction) {\n        return this.userRepository.find()\n    }\n\n    async one(request: Request, response: Response, next: NextFunction) {\n        const id = parseInt(request.params.id)\n\n\n        const user = await this.userRepository.findOne({\n            where: { id }\n        })\n\n        if (!user) {\n            return \"unregistered user\"\n        }\n        return user\n    }\n\n    async save(request: Request, response: Response, next: NextFunction) {\n        const { firstName, lastName, age } = request.body;\n\n        const user = Object.assign(new User(), {\n            firstName,\n            lastName,\n            age\n        })\n\n        return this.userRepository.save(user)\n    }\n\n    async remove(request: Request, response: Response, next: NextFunction) {\n        const id = parseInt(request.params.id)\n\n        let userToRemove = await this.userRepository.findOneBy({ id })\n\n        if (!userToRemove) {\n            return \"this user not exist\"\n        }\n\n        await this.userRepository.remove(userToRemove)\n\n        return \"user has been removed\"\n    }\n\n}`\n    }\n\n    /**\n     * Gets contents of the main (index) application file.\n     */\n    protected static getAppIndexTemplate(\n        express: boolean,\n        isEsm: boolean,\n    ): string {\n        if (express) {\n            return `import ${!isEsm ? \"* as \" : \"\"}express from \"express\"\nimport ${!isEsm ? \"* as \" : \"\"}bodyParser from \"body-parser\"\nimport { Request, Response } from \"express\"\nimport { AppDataSource } from \"./data-source${isEsm ? \".js\" : \"\"}\"\nimport { Routes } from \"./routes${isEsm ? \".js\" : \"\"}\"\nimport { User } from \"./entity/User${isEsm ? \".js\" : \"\"}\"\n\nAppDataSource.initialize().then(async () => {\n\n    // create express app\n    const app = express()\n    app.use(bodyParser.json())\n\n    // register express routes from defined application routes\n    Routes.forEach(route => {\n        (app as any)[route.method](route.route, (req: Request, res: Response, next: Function) => {\n            const result = (new (route.controller as any))[route.action](req, res, next)\n            if (result instanceof Promise) {\n                result.then(result => result !== null && result !== undefined ? res.send(result) : undefined)\n\n            } else if (result !== null && result !== undefined) {\n                res.json(result)\n            }\n        })\n    })\n\n    // setup express app here\n    // ...\n\n    // start express server\n    app.listen(3000)\n\n    // insert new users for test\n    await AppDataSource.manager.save(\n        AppDataSource.manager.create(User, {\n            firstName: \"Timber\",\n            lastName: \"Saw\",\n            age: 27\n        })\n    )\n\n    await AppDataSource.manager.save(\n        AppDataSource.manager.create(User, {\n            firstName: \"Phantom\",\n            lastName: \"Assassin\",\n            age: 24\n        })\n    )\n\n    console.log(\"Express server has started on port 3000. Open http://localhost:3000/users to see results\")\n\n}).catch(error => console.log(error))\n`\n        } else {\n            return `import { AppDataSource } from \"./data-source${\n                isEsm ? \".js\" : \"\"\n            }\"\nimport { User } from \"./entity/User${isEsm ? \".js\" : \"\"}\"\n\nAppDataSource.initialize().then(async () => {\n\n    console.log(\"Inserting a new user into the database...\")\n    const user = new User()\n    user.firstName = \"Timber\"\n    user.lastName = \"Saw\"\n    user.age = 25\n    await AppDataSource.manager.save(user)\n    console.log(\"Saved a new user with id: \" + user.id)\n\n    console.log(\"Loading users from the database...\")\n    const users = await AppDataSource.manager.find(User)\n    console.log(\"Loaded users: \", users)\n\n    console.log(\"Here you can setup and run express / fastify / any other framework.\")\n\n}).catch(error => console.log(error))\n`\n        }\n    }\n\n    /**\n     * Gets contents of the new package.json file.\n     */\n    protected static getPackageJsonTemplate(\n        projectName?: string,\n        projectIsEsm?: boolean,\n    ): string {\n        return JSON.stringify(\n            {\n                name: projectName || \"typeorm-sample\",\n                version: \"0.0.1\",\n                description: \"Awesome project developed with TypeORM.\",\n                type: projectIsEsm ? \"module\" : \"commonjs\",\n                devDependencies: {},\n                dependencies: {},\n                scripts: {},\n            },\n            undefined,\n            3,\n        )\n    }\n\n    /**\n     * Gets contents of the new docker-compose.yml file.\n     */\n    protected static getDockerComposeTemplate(database: string): string {\n        switch (database) {\n            case \"mysql\":\n                return `version: '3'\nservices:\n\n  mysql:\n    image: \"mysql:8.0.30\"\n    ports:\n      - \"3306:3306\"\n    environment:\n      MYSQL_ROOT_PASSWORD: \"admin\"\n      MYSQL_USER: \"test\"\n      MYSQL_PASSWORD: \"test\"\n      MYSQL_DATABASE: \"test\"\n\n`\n            case \"mariadb\":\n                return `version: '3'\nservices:\n\n  mariadb:\n    image: \"mariadb:10.8.4\"\n    ports:\n      - \"3306:3306\"\n    environment:\n      MYSQL_ROOT_PASSWORD: \"admin\"\n      MYSQL_USER: \"test\"\n      MYSQL_PASSWORD: \"test\"\n      MYSQL_DATABASE: \"test\"\n\n`\n            case \"postgres\":\n                return `version: '3'\nservices:\n\n  postgres:\n    image: \"postgres:14.5\"\n    ports:\n      - \"5432:5432\"\n    environment:\n      POSTGRES_USER: \"test\"\n      POSTGRES_PASSWORD: \"test\"\n      POSTGRES_DB: \"test\"\n\n`\n            case \"cockroachdb\":\n                return `version: '3'\nservices:\n\n  cockroachdb:\n    image: \"cockroachdb/cockroach:v22.1.6\"\n    command: start --insecure\n    ports:\n      - \"26257:26257\"\n\n`\n            case \"sqlite\":\n            case \"better-sqlite3\":\n                return `version: '3'\nservices:\n`\n            case \"oracle\":\n                throw new TypeORMError(\n                    `You cannot initialize a project with docker for Oracle driver yet.`,\n                ) // todo: implement for oracle as well\n\n            case \"mssql\":\n                return `version: '3'\nservices:\n\n  mssql:\n    image: \"microsoft/mssql-server-linux:rc2\"\n    ports:\n      - \"1433:1433\"\n    environment:\n      SA_PASSWORD: \"Admin12345\"\n      ACCEPT_EULA: \"Y\"\n\n`\n            case \"mongodb\":\n                return `version: '3'\nservices:\n\n  mongodb:\n    image: \"mongo:5.0.12\"\n    container_name: \"typeorm-mongodb\"\n    ports:\n      - \"27017:27017\"\n\n`\n            case \"spanner\":\n                return `version: '3'\nservices:\n\n  spanner:\n    image: gcr.io/cloud-spanner-emulator/emulator:1.4.1\n    ports:\n      - \"9010:9010\"\n      - \"9020:9020\"\n\n`\n        }\n        return \"\"\n    }\n\n    /**\n     * Gets contents of the new readme.md file.\n     */\n    protected static getReadmeTemplate(options: { docker: boolean }): string {\n        let template = `# Awesome Project Build with TypeORM\n\nSteps to run this project:\n\n1. Run \\`npm i\\` command\n`\n\n        if (options.docker) {\n            template += `2. Run \\`docker-compose up\\` command\n`\n        } else {\n            template += `2. Setup database settings inside \\`data-source.ts\\` file\n`\n        }\n\n        template += `3. Run \\`npm start\\` command\n`\n        return template\n    }\n\n    /**\n     * Appends to a given package.json template everything needed.\n     */\n    protected static appendPackageJson(\n        packageJsonContents: string,\n        database: string,\n        express: boolean,\n        projectIsEsm: boolean /*, docker: boolean*/,\n    ): string {\n        const packageJson = JSON.parse(packageJsonContents)\n\n        if (!packageJson.devDependencies) packageJson.devDependencies = {}\n        Object.assign(packageJson.devDependencies, {\n            \"ts-node\": \"10.7.0\",\n            \"@types/node\": \"^16.11.10\",\n            typescript: \"4.5.2\",\n        })\n\n        if (!packageJson.dependencies) packageJson.dependencies = {}\n        Object.assign(packageJson.dependencies, {\n            typeorm:\n                require(\"../package.json\").version !== \"0.0.0\"\n                    ? require(\"../package.json\").version // install version from package.json if present\n                    : require(\"../package.json\").installFrom, // else use custom source\n            \"reflect-metadata\": \"^0.1.13\",\n        })\n\n        switch (database) {\n            case \"mysql\":\n            case \"mariadb\":\n                packageJson.dependencies[\"mysql\"] = \"^2.14.1\"\n                break\n            case \"postgres\":\n            case \"cockroachdb\":\n                packageJson.dependencies[\"pg\"] = \"^8.4.0\"\n                break\n            case \"sqlite\":\n                packageJson.dependencies[\"sqlite3\"] = \"^5.0.2\"\n                break\n            case \"better-sqlite3\":\n                packageJson.dependencies[\"better-sqlite3\"] = \"^7.0.0\"\n                break\n            case \"oracle\":\n                packageJson.dependencies[\"oracledb\"] = \"^5.1.0\"\n                break\n            case \"mssql\":\n                packageJson.dependencies[\"mssql\"] = \"^9.1.1\"\n                break\n            case \"mongodb\":\n                packageJson.dependencies[\"mongodb\"] = \"^5.2.0\"\n                break\n            case \"spanner\":\n                packageJson.dependencies[\"@google-cloud/spanner\"] = \"^5.18.0\"\n                break\n        }\n\n        if (express) {\n            packageJson.dependencies[\"express\"] = \"^4.17.2\"\n            packageJson.dependencies[\"body-parser\"] = \"^1.19.1\"\n        }\n\n        if (!packageJson.scripts) packageJson.scripts = {}\n\n        if (projectIsEsm)\n            Object.assign(packageJson.scripts, {\n                start: /*(docker ? \"docker-compose up && \" : \"\") + */ \"node --loader ts-node/esm src/index.ts\",\n                typeorm: \"typeorm-ts-node-esm\",\n            })\n        else\n            Object.assign(packageJson.scripts, {\n                start: /*(docker ? \"docker-compose up && \" : \"\") + */ \"ts-node src/index.ts\",\n                typeorm: \"typeorm-ts-node-commonjs\",\n            })\n\n        return JSON.stringify(packageJson, undefined, 3)\n    }\n}\n"],"sourceRoot":".."}