diff --git a/package-lock.json b/package-lock.json index 2e8860e..b9695db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -434,6 +434,46 @@ "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-1.0.0.tgz", "integrity": "sha1-T6kXw+WclKAEzWH47lCdplFocUM=" }, + "cliui": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-5.0.0.tgz", + "integrity": "sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA==", + "requires": { + "string-width": "^3.1.0", + "strip-ansi": "^5.2.0", + "wrap-ansi": "^5.1.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", @@ -714,6 +754,11 @@ "safer-buffer": "^2.1.0" } }, + "emoji-regex": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-7.0.3.tgz", + "integrity": "sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA==" + }, "error-ex": { "version": "1.3.2", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", @@ -1032,6 +1077,11 @@ "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" }, + "get-caller-file": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", + "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==" + }, "get-func-name": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", @@ -1576,6 +1626,22 @@ "strip-bom": "^2.0.0" } }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "requires": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + }, + "dependencies": { + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" + } + } + }, "lodash._baseassign": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz", @@ -2061,6 +2127,29 @@ "integrity": "sha1-nJRWmJ6fZYgBewQ01WCXZ1w9oF4=", "dev": true }, + "p-limit": { + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.2.1.tgz", + "integrity": "sha512-85Tk+90UCVWvbDavCLKPOLC9vvY8OwEX/RtKF+/1OADJMVlFfEHOiMTPVyxg7mk/dKa+ipdHm0OUkTvCpMTuwg==", + "requires": { + "p-try": "^2.0.0" + }, + "dependencies": { + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==" + } + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "requires": { + "p-limit": "^2.0.0" + } + }, "p-map": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/p-map/-/p-map-1.2.0.tgz", @@ -2528,6 +2617,49 @@ "is-finite": "^1.0.0" } }, + "replace-in-file": { + "version": "4.1.3", + "resolved": "https://registry.npmjs.org/replace-in-file/-/replace-in-file-4.1.3.tgz", + "integrity": "sha512-x8uSfKKK/5YiJ8JYsNMwa1PJYvHfPdUABVXd21ro09Nh5BRZ5ATuACwrqCNpktwVqVbFTk/cIGFepeMqY0oX3g==", + "requires": { + "chalk": "^2.4.2", + "glob": "^7.1.4", + "yargs": "^13.3.0" + }, + "dependencies": { + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "requires": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + } + }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" + }, + "supports-color": { + "version": "5.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", + "integrity": "sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==", + "requires": { + "has-flag": "^3.0.0" + } + } + } + }, "request": { "version": "2.88.0", "resolved": "https://registry.npmjs.org/request/-/request-2.88.0.tgz", @@ -2563,6 +2695,16 @@ "throttleit": "^1.0.0" } }, + "require-directory": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", + "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=" + }, + "require-main-filename": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/require-main-filename/-/require-main-filename-2.0.0.tgz", + "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==" + }, "resolve": { "version": "1.12.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.12.0.tgz", @@ -2804,6 +2946,11 @@ "semver": "^5.0.3" } }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha1-BF+XgtARrppoA93TgrJDkrPYkPc=" + }, "set-value": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", @@ -3443,6 +3590,11 @@ "isexe": "^2.0.0" } }, + "which-module": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", + "integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=" + }, "widest-line": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/widest-line/-/widest-line-1.0.0.tgz", @@ -3456,6 +3608,54 @@ "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=" }, + "wrap-ansi": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-5.1.0.tgz", + "integrity": "sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q==", + "requires": { + "ansi-styles": "^3.2.0", + "string-width": "^3.0.0", + "strip-ansi": "^5.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" + }, + "ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "requires": { + "color-convert": "^1.9.0" + } + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", @@ -3524,10 +3724,86 @@ } } }, + "y18n": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-4.0.0.tgz", + "integrity": "sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w==" + }, "yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" + }, + "yargs": { + "version": "13.3.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-13.3.0.tgz", + "integrity": "sha512-2eehun/8ALW8TLoIl7MVaRUrg+yCnenu8B4kBlRxj3GJGDKU1Og7sMXPNm1BYyM1DOJmTZ4YeN/Nwxv+8XJsUA==", + "requires": { + "cliui": "^5.0.0", + "find-up": "^3.0.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^3.0.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^13.1.1" + }, + "dependencies": { + "ansi-regex": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-4.1.0.tgz", + "integrity": "sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg==" + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "requires": { + "locate-path": "^3.0.0" + } + }, + "is-fullwidth-code-point": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", + "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=" + }, + "string-width": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-3.1.0.tgz", + "integrity": "sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w==", + "requires": { + "emoji-regex": "^7.0.1", + "is-fullwidth-code-point": "^2.0.0", + "strip-ansi": "^5.1.0" + } + }, + "strip-ansi": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-5.2.0.tgz", + "integrity": "sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA==", + "requires": { + "ansi-regex": "^4.1.0" + } + } + } + }, + "yargs-parser": { + "version": "13.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.1.1.tgz", + "integrity": "sha512-oVAVsHz6uFrg3XQheFII8ESO2ssAf9luWuAd6Wexsu4F3OtIW0o8IribPXYrD4WC24LWtPrJlGy87y5udK+dxQ==", + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + }, + "dependencies": { + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" + } + } } } } diff --git a/package.json b/package.json index 888c9fa..0b03264 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,7 @@ "getSpecsSynctool": "find specs/synctool -name '*spec.js'" }, "scripts": { - "base": "node src/QPNode.js", - "start": "node src/QPNode.js --output-dir $npm_package_directories_outputDir $npm_package_config_devFlags", + "start": "node src/QPNode.js mametool --output-dir $npm_package_directories_outputDir $npm_package_config_devFlags", "mess-start": "npm run start -- --scan && npm run start -- --softlists", "full": "trash $npm_package_directories_outputDir && mkdir $npm_package_directories_outputDir && npm run start -- --scan && npm run start -- --arcade && npm run start -- --softlists", "basedebug": "node --inspect-brk src/QPNode.js", @@ -39,6 +38,7 @@ "mkdirp": "^0.5.1", "pkg": "^4.3.7", "ramda": "^0.24.1", + "replace-in-file": "^4.1.3", "sanctuary": "^2.0.0", "trash-cli": "^1.4.0", "xml-stream": "^0.4.5" diff --git a/src/QPNode.js b/src/QPNode.js index 96b26cd..2ee06d8 100644 --- a/src/QPNode.js +++ b/src/QPNode.js @@ -17,7 +17,7 @@ const { arcade } = require('./arcade') const { mfm } = require('./mfm') const { testArcadeRun } = require('./testing') const { softlists } = require('./softlists') -const { synctool, synctoolEnable } = require('./synctool') +const { synctool, synctoolEnable, synctoolFolderFlip } = require('./synctool') const configFileName = 'synctool_config.json' // tee output to console and to a logfile https://stackoverflow.com/a/30578473/3536094 @@ -33,8 +33,10 @@ const muxLog = logType => (...args) => { console.log = muxLog('stdout') console.error = muxLog('stderr') -let synctoolInvoked = false -program // TODO: these options need prepending by the command 'mametool' +//https://github.com/tj/commander.js/issues/944 +//TODO: need real nested subcommands, swith to yargs? +program + .command(`mametool`) .option('--output-dir [path]') .option(`--scan`) .option(`--dev`) @@ -44,10 +46,91 @@ program // TODO: these options need prepending by the command 'mametool' .option(`--testArcadeRun`) // messTool options .option(`--softlists [rompath]`) // todo, []=optional, <>=required, surely latter - .option(`--synctoolEnable`) + .action(mametoolObj => { + const outputDir = mametoolObj.outputDir + !mametoolObj.scan && + (fs.existsSync(outputDir) || + _throw( + `output directory ${outputDir} doesn't exist, so Mametool can't output any romdatas` + )) + const devMode = mametoolObj.dev + const jsonOutDir = devMode ? outputDir : `dats` // json will sit in the frontends config dir, or for dev in the passed-in dir + const jsonOutName = `mame.json` + const jsonOutPath = `${jsonOutDir}/${jsonOutName}` + const qpIni = devMode ? `./settings.ini` : `dats\\settings.ini` // settings from QP's ini file, or nix dev settings + const devExtrasOverride = devMode ? `/Volumes/GAMES/MAME/EXTRAs/folders` : `` // on windows its specified in the settings.ini above + + devMode && console.log(`\t*** Mametool is in Dev mode ***\n`) + ;(mametoolObj.scan && !devMode) || console.log(`Output dir: ${outputDir}`) + console.log(`MAME Json dir: ${jsonOutDir}`) + + // read these from the ini + const settings = paths(qpIni, devExtrasOverride) + settings.devMode = devMode + settings.isItRetroArch = path.basename(settings.mameExePath).match(/retroarch/i) // best bet is to limit ourselves to what the emu file is called for this + + console.log( + `MAME extras dir: ${settings.mameExtrasPath} +MAME icons dir: ${settings.winIconDir} +MAME exe: ${settings.mameExe} +MAME exe path: ${settings.mameExePath}` + ) + + const log = { + // datAndEfind + efindProblems: devMode, + loaderCalls: true, + loaderCallsVerbose: false, + // the data/efind/scan artifacts + dat: false, + efind: false, + json: false, + // softlist + // these probably should be printed to the user + printer: true, // prints softlist names as synchronously printed, leave on + fileProblems: true, // as of mame 187, there is persistently one file missing in mame's hash: 'squale' + filePaths: true, // will also print helpful 'necessary to run this rom' file info + // these probably shouldn't + deviceProblems: false, + otherSoftlists: false, + otherGameNames: false, + otherGameConflicts: false, + findRegions: false, + regions: false, + regionsGames: false, + exclusions: false + } + + // determine that location of the systems.dat + const devInputsDir = `inputs/current` + const datInPath = devMode ? `${devInputsDir}/systems.dat` : `dats\\systems.dat` + const datOutPath = devMode ? `${outputDir}/systems.dat` : `dats\\systems.dat` + // are we making a mess or retroarch efinder file? to make both the users has to go through the menu again and select the appropriate emu + const efindOutName = settings.isItRetroArch ? `Mess_Retroarch.ini` : `Mess_Mame.ini` + const efindOutPath = devMode ? `${outputDir}/${efindOutName}` : `EFind\\${efindOutName}` + console.log(`EFind Ini output Path: ${efindOutPath}`) + + // softlist paths + const mameEmuDir = path.dirname(settings.mameExePath) + // mess hash dir is determinable relative to mame exe dir (mame is distributed that way/retroarch users must place it here to work) + const liveHashDir = settings.isItRetroArch + ? `${mameEmuDir}\\system\\mame\\hash\\` + : `${mameEmuDir}\\hash\\` + const hashDir = devMode ? `${devInputsDir}/hash/` : liveHashDir + + if (settings.mameFilePaths) { + addMameFilePathsToSettings(settings, devMode, log) + } + + // TODO: promisify these so you can run combinations + mametoolObj.scan && scan(settings, jsonOutPath, qpIni, efindOutPath, datInPath, datOutPath, log) + mametoolObj.mfm && mfm(settings, readMameJson, jsonOutPath, generateRomdata, outputDir) + mametoolObj.arcade && arcade(settings, jsonOutPath, outputDir, readMameJson, generateRomdata) + mametoolObj.testArcadeRun && testArcadeRun(settings, readMameJson, jsonOutPath, outputDir) + mametoolObj.softlists && softlists(settings, jsonOutPath, hashDir, outputDir, log) + }) program.command(`synctool [rompath]`).action(romPath => { - synctoolInvoked = true synctool(romPath, configFileName) .run() .listen({ @@ -59,25 +142,22 @@ program.command(`synctool [rompath]`).action(romPath => { }) }) -program.parse(process.argv) - -if (!process.argv.slice(2).length) { - console.log( - `MAMETOOL TEST USAGE: -'npm start -- --scan' make a mame json output file, which is used by the arcade and mfm flags -'npm start -- --arcade' make an arcade set to the ini flags in settings.ini, and output to outputsDir in package.json -'npm start -- --mfm' make an arcade set to a flatfile list output of mame file manager, and output to outputsDir in package.json -'npm start -- --testArcadeRun' makes a set of both Mame and RetroArch romdata and splits from a canned list -'npm start -- --softlists' makes a softlist set -'npm run full' deletes the outputs folder, scans, makes an arcade set, and softlists plus embedded (according to config settings) -'npm run mess-start doesn't delete output dir, just runs scan and softlist/embedded generation -'npm run debug -- --arcade' break on ln1 of making an arcade set to the ini flags in settings.ini, and output to outputsDir in package.json) -` - ) - process.exit() -} +program.command(`synctool-romdata-folder-flip `).action(startFolder => { + synctoolFolderFlip(startFolder, configFileName) + .run() + .listen({ + onRejected: rej => { + console.error(rej) + process.exit(1) + }, + onResolved: res => { + console.log(res) + process.exit(0) + } + }) +}) -if (program.synctoolEnable) { +program.command(`synctoolEnable`).action(() => { synctoolEnable(configFileName) .run() .listen({ @@ -90,93 +170,24 @@ if (program.synctoolEnable) { process.exit(0) } }) -} +}) -// bypass mametool stuff if synctool -// program.synctool && synctool(program.synctool) -// TODO: oops as it is we'll fall through to this lot, also empty string falls thorugh -if (!synctoolInvoked && !program.synctoolEnable) { - // DeMorgan - // calculate these - const outputDir = program.outputDir - !program.scan && - (fs.existsSync(outputDir) || - _throw(`output directory ${outputDir} doesn't exist, so Mametool can't output any romdatas`)) - const devMode = program.dev - const jsonOutDir = devMode ? outputDir : `dats` // json will sit in the frontends config dir, or for dev in the passed-in dir - const jsonOutName = `mame.json` - const jsonOutPath = `${jsonOutDir}/${jsonOutName}` - const qpIni = devMode ? `./settings.ini` : `dats\\settings.ini` // settings from QP's ini file, or nix dev settings - const devExtrasOverride = devMode ? `/Volumes/GAMES/MAME/EXTRAs/folders` : `` // on windows its specified in the settings.ini above - - devMode && console.log(`\t*** Mametool is in Dev mode ***\n`) - ;(program.scan && !devMode) || console.log(`Output dir: ${outputDir}`) - console.log(`MAME Json dir: ${jsonOutDir}`) - - // read these from the ini - const settings = paths(qpIni, devExtrasOverride) - settings.devMode = devMode - settings.isItRetroArch = path.basename(settings.mameExePath).match(/retroarch/i) // best bet is to limit ourselves to what the emu file is called for this +program.parse(process.argv) +if (!process.argv.slice(2).length) { console.log( - `MAME extras dir: ${settings.mameExtrasPath} -MAME icons dir: ${settings.winIconDir} -MAME exe: ${settings.mameExe} -MAME exe path: ${settings.mameExePath}` + `MAMETOOL TEST USAGE: +'npm start -- --scan' make a mame json output file, which is used by the arcade and mfm flags +'npm start -- --arcade' make an arcade set to the ini flags in settings.ini, and output to outputsDir in package.json +'npm start -- --mfm' make an arcade set to a flatfile list output of mame file manager, and output to outputsDir in package.json +'npm start -- --testArcadeRun' makes a set of both Mame and RetroArch romdata and splits from a canned list +'npm start -- --softlists' makes a softlist set +'npm run full' deletes the outputs folder, scans, makes an arcade set, and softlists plus embedded (according to config settings) +'npm run mess-start doesn't delete output dir, just runs scan and softlist/embedded generation +'npm run debug -- --arcade' break on ln1 of making an arcade set to the ini flags in settings.ini, and output to outputsDir in package.json) +` ) - - const log = { - // datAndEfind - efindProblems: devMode, - loaderCalls: true, - loaderCallsVerbose: false, - // the data/efind/scan artifacts - dat: false, - efind: false, - json: false, - // softlist - // these probably should be printed to the user - printer: true, // prints softlist names as synchronously printed, leave on - fileProblems: true, // as of mame 187, there is persistently one file missing in mame's hash: 'squale' - filePaths: true, // will also print helpful 'necessary to run this rom' file info - // these probably shouldn't - deviceProblems: false, - otherSoftlists: false, - otherGameNames: false, - otherGameConflicts: false, - findRegions: false, - regions: false, - regionsGames: false, - exclusions: false - } - - // determine that location of the systems.dat - const devInputsDir = `inputs/current` - const datInPath = devMode ? `${devInputsDir}/systems.dat` : `dats\\systems.dat` - const datOutPath = devMode ? `${outputDir}/systems.dat` : `dats\\systems.dat` - // are we making a mess or retroarch efinder file? to make both the users has to go through the menu again and select the appropriate emu - const efindOutName = settings.isItRetroArch ? `Mess_Retroarch.ini` : `Mess_Mame.ini` - const efindOutPath = devMode ? `${outputDir}/${efindOutName}` : `EFind\\${efindOutName}` - console.log(`EFind Ini output Path: ${efindOutPath}`) - - // softlist paths - const mameEmuDir = path.dirname(settings.mameExePath) - // mess hash dir is determinable relative to mame exe dir (mame is distributed that way/retroarch users must place it here to work) - const liveHashDir = settings.isItRetroArch - ? `${mameEmuDir}\\system\\mame\\hash\\` - : `${mameEmuDir}\\hash\\` - const hashDir = devMode ? `${devInputsDir}/hash/` : liveHashDir - - if (settings.mameFilePaths) { - addMameFilePathsToSettings(settings, devMode, log) - } - - // TODO: promisify these so you can run combinations - program.scan && scan(settings, jsonOutPath, qpIni, efindOutPath, datInPath, datOutPath, log) - program.mfm && mfm(settings, readMameJson, jsonOutPath, generateRomdata, outputDir) - program.arcade && arcade(settings, jsonOutPath, outputDir, readMameJson, generateRomdata) - program.testArcadeRun && testArcadeRun(settings, readMameJson, jsonOutPath, outputDir) - program.softlists && softlists(settings, jsonOutPath, hashDir, outputDir, log) + process.exit() } -module.exports = { synctoolEnable } +module.exports = { synctoolEnable, synctoolFolderFlip } diff --git a/src/synctool/index.js b/src/synctool/index.js index 1e7c058..58a18a4 100644 --- a/src/synctool/index.js +++ b/src/synctool/index.js @@ -65,5 +65,8 @@ const synctoolEnable = configFileName => : of('[syncToolEnable] - SyncTool is Disabled') ) : rejected('[synctoolEnable] - no config filename passed') + +const synctoolFolderFlip = startFolder => {} -module.exports = { synctool, synctoolEnable } + +module.exports = { synctool, synctoolEnable, synctoolFolderFlip}