"use strict";exports.__esModule=true;exports.writeDefaultConfig=writeDefaultConfig;var _fs=require("fs");var _chalk=_interopRequireDefault(require("chalk"));var _os=_interopRequireDefault(require("os"));var _path=_interopRequireDefault(require("path"));var CommentJson=_interopRequireWildcard(require("next/dist/compiled/comment-json"));function _getRequireWildcardCache(){if(typeof WeakMap!=="function")return null;var cache=new WeakMap();_getRequireWildcardCache=function(){return cache;};return cache;}function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj;}if(obj===null||typeof obj!=="object"&&typeof obj!=="function"){return{default:obj};}var cache=_getRequireWildcardCache();if(cache&&cache.has(obj)){return cache.get(obj);}var newObj={};var hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;if(desc&&(desc.get||desc.set)){Object.defineProperty(newObj,key,desc);}else{newObj[key]=obj[key];}}}newObj.default=obj;if(cache){cache.set(obj,newObj);}return newObj;}function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}async function writeDefaultConfig(eslintrcFile,pkgJsonPath){const defaultConfig={extends:'next'};if(eslintrcFile){const ext=_path.default.extname(eslintrcFile);let fileContent;if(ext==='.yaml'||ext==='.yml'){fileContent="extends: 'next'";}else{fileContent=CommentJson.stringify(defaultConfig,null,2);if(ext==='.js'){fileContent='module.exports = '+fileContent;}}await _fs.promises.writeFile(eslintrcFile,fileContent+_os.default.EOL);console.log('\n'+_chalk.default.green(`We detected ESLint in your project and updated the ${_chalk.default.bold(_path.default.basename(eslintrcFile))} file for you.`)+'\n');}else if(pkgJsonPath){const pkgJsonContent=await _fs.promises.readFile(pkgJsonPath,{encoding:'utf8'});let packageJsonConfig=CommentJson.parse(pkgJsonContent);packageJsonConfig.eslintConfig=defaultConfig;await _fs.promises.writeFile(pkgJsonPath,CommentJson.stringify(packageJsonConfig,null,2)+_os.default.EOL);console.log('\n'+_chalk.default.green(`We detected ESLint in your project and updated the ${_chalk.default.bold('eslintConfig')} field for you in package.json...`)+'\n');}}
//# sourceMappingURL=writeDefaultConfig.js.map