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F;AACD,eAAO,IAAI,MAAJ,CAAW,MAAX,EAAmB,UAAnB,EAA+B,WAA/B,CAAP;AACD,O;;;;;;;;;;;;;kBA3CkB,M","file":"config.js","sourcesContent":["/* @flow */\n\nimport Path from 'path'\nimport * as FS from './fs'\nimport * as Helpers from './helpers'\nimport { MotionError, ERROR_CODE } from './error'\nimport type { Config as ConfigStruct } from './types'\n\nexport default class Config {\n config: ConfigStruct;\n configPath: string;\n projectPath: string;\n\n constructor(config: ConfigStruct, configPath: string, projectPath: string) {\n this.config = config\n this.configPath = configPath\n this.projectPath = projectPath\n }\n getBundleDirectory() {\n return Path.resolve(this.projectPath, this.get('bundleDirectory'))\n }\n getPublicDirectory() {\n return Path.resolve(this.projectPath, this.get('publicDirectory'))\n }\n get(key: $Keys<ConfigStruct>): any {\n return this.config[key]\n }\n async write(): Promise<void> {\n await FS.writeJSON(this.configPath, this.config)\n }\n static async create(projectPath: string): Promise<Config> {\n const config = {\n babel: {\n plugins: ['motion-style/transform'],\n presets: ['babel-preset-motion']\n },\n webServerPort: Helpers.getRandomNumber(8000, 15000),\n saveNpmModules: true,\n bundleDirectory: '.',\n publicDirectory: './public',\n includePolyfills: true\n }\n const configPath = Path.join(projectPath, '.motion.json')\n try {\n Object.assign(config, await FS.readJSON(configPath))\n } catch (error) {\n if (error && error.name === 'SyntaxError') {\n throw new MotionError(ERROR_CODE.INVALID_MANIFEST)\n }\n }\n return new Config(config, configPath, projectPath)\n }\n}\n"]}
\No newline at end of file