1 line
4.7 KiB
Plaintext
1 line
4.7 KiB
Plaintext
{"version":3,"sources":["UserSettings.js"],"names":["async","settings","await","userSettingsJsonFile","let","id","getAsync","uuid","v4","setAsync","anonymousIdentifier","SETTINGS_FILE_NAME","userSettingsFile","dir","dotExpoHomeDirectory","file","path","join","oldFile","fs","statSync","isFile","renameSync","e","jsonParseErrorDefault","cantReadFileDefault","recentExpsJsonFile","mkdirped","dirPath","process","env","__UNSAFE_EXPO_HOME_DIRECTORY","home","Env","Error","oldDirPath","isDirectory","mkdirp","sync","UserSettings","Object","assign"],"mappings":";;;;;;AA2EA;;+BACAA,aAAsD;AACpD,UAAMC,WAAWC,MAAMC,sBAAvB;AACAC,QAAIC,KAAKH,MAAMD,SAASK,QAATL,CAAkB,MAAlBA,EAA0B,IAA1BA,CAAfG;;AAEA,QAAI,CAACC,EAAL,EAAS;AACPA,WAAKE,gCAAKC,EAALD,EAALF;AACAH,YAAMD,SAASQ,QAATR,CAAkB,MAAlBA,EAA0BI,EAA1BJ,CAANC;AACF;;AAEA,WAAOG,EAAP;AACF,G;;kBAVeK,mB;;;;;AAxEf;;;;AACA;AAAA;AAAA;;;;AACA;AAAA;AAAA;;;;AAEA;AAAA;AAAA;;AACA;;;;AAEA;AAAA;AAAA;;;;;;;;AAEA,MAAMC,qBAAqB,YAA3B;;AAEA,SAASC,gBAAT,GAA4B;AAC1BR,MAAIS,MAAMC,sBAAVV;AACAA,MAAIW,OAAOC,cAAKC,IAALD,CAAUH,GAAVG,EAAeL,kBAAfK,CAAXZ;AACA,MAAI;AACF;AACAA,QAAIc,UAAUF,cAAKC,IAALD,CAAUH,GAAVG,EAAe,eAAfA,CAAdZ;AACA,QAAIe,YAAGC,QAAHD,CAAYD,OAAZC,EAAqBE,MAArBF,EAAJ,EAAmC;AACjCA,kBAAGG,UAAHH,CAAcD,OAAdC,EAAuBJ,IAAvBI;AACF;AACF,GANA,CAME,OAAOI,CAAP,EAAU;AACV;AACF;AACA,SAAOR,IAAP;AACF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L0B;AAM1BC;AAN0B,CAA5B6B;;kBASeD,Y","file":"../UserSettings.js","sourcesContent":["/**\n * @flow\n */\n\nimport fs from 'fs';\nimport uuid from 'uuid';\nimport JsonFile from '@expo/json-file';\n\nimport mkdirp from 'mkdirp';\nimport path from 'path';\n\nimport * as Env from './Env';\n\nconst SETTINGS_FILE_NAME = 'state.json';\n\nfunction userSettingsFile() {\n let dir = dotExpoHomeDirectory();\n let file = path.join(dir, SETTINGS_FILE_NAME);\n try {\n // move exponent.json to state.json\n let oldFile = path.join(dir, 'exponent.json');\n if (fs.statSync(oldFile).isFile()) {\n fs.renameSync(oldFile, file);\n }\n } catch (e) {\n // no old directory, continue\n }\n return file;\n}\n\nfunction userSettingsJsonFile() {\n return new JsonFile(userSettingsFile(), {\n jsonParseErrorDefault: {},\n cantReadFileDefault: {},\n });\n}\n\nfunction recentExpsJsonFile() {\n return new JsonFile(path.join(dotExpoHomeDirectory(), 'xde-recent-exps.json'), {\n jsonParseErrorDefault: [],\n cantReadFileDefault: [],\n });\n}\n\nvar mkdirped = false;\nfunction dotExpoHomeDirectory() {\n let dirPath;\n if (process.env.__UNSAFE_EXPO_HOME_DIRECTORY) {\n dirPath = process.env.__UNSAFE_EXPO_HOME_DIRECTORY;\n } else {\n const home = Env.home();\n if (!home) {\n throw new Error(\n \"Can't determine your home directory; make sure your $HOME environment variable is set.\"\n );\n }\n dirPath = path.join(home, '.expo');\n\n try {\n // move .exponent to .expo\n let oldDirPath = path.join(home, '.exponent');\n if (fs.statSync(oldDirPath).isDirectory()) {\n fs.renameSync(oldDirPath, dirPath);\n }\n } catch (e) {\n // no old directory, continue\n }\n }\n if (!mkdirped) {\n mkdirp.sync(dirPath);\n mkdirped = true;\n }\n return dirPath;\n}\n\n// returns an anonymous, unique identifier for a user on the current computer\nasync function anonymousIdentifier(): Promise<string> {\n const settings = await userSettingsJsonFile();\n let id = await settings.getAsync('uuid', null);\n\n if (!id) {\n id = uuid.v4();\n await settings.setAsync('uuid', id);\n }\n\n return id;\n}\n\nconst UserSettings = userSettingsJsonFile();\n\nObject.assign(UserSettings, {\n dotExpoHomeDirectory,\n recentExpsJsonFile,\n userSettingsFile,\n userSettingsJsonFile,\n anonymousIdentifier,\n SETTINGS_FILE_NAME,\n});\n\nexport default UserSettings;\n"],"sourceRoot":"/xdl/src"} |