UNPKG

@aws-amplify/cli-internal

Version:
45 lines 1.98 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TsConfigGenerator = void 0; const node_path_1 = __importDefault(require("node:path")); const promises_1 = __importDefault(require("node:fs/promises")); class TsConfigGenerator { constructor(outputDir) { this.outputDir = outputDir; } async plan() { const filePath = node_path_1.default.join(this.outputDir, 'amplify', 'tsconfig.json'); return [ { validate: () => undefined, describe: async () => ['Generate amplify/tsconfig.json'], execute: async () => { const tsconfig = { compilerOptions: { target: 'es2022', module: 'es2022', moduleResolution: 'bundler', resolveJsonModule: true, esModuleInterop: true, forceConsistentCasingInFileNames: true, strict: true, skipLibCheck: true, paths: { '$amplify/*': ['../.amplify/generated/*'], }, }, }; await promises_1.default.mkdir(node_path_1.default.dirname(filePath), { recursive: true }); const json = JSON.stringify(tsconfig, null, 2); const collapsed = json.replace(/\[\s*\n\s*"([^"]+)"\s*\n\s*\]/g, '["$1"]'); await promises_1.default.writeFile(filePath, collapsed + '\n', 'utf-8'); }, }, ]; } } exports.TsConfigGenerator = TsConfigGenerator; //# sourceMappingURL=tsconfig.generator.js.map