diff --git a/CHANGELOG.md b/CHANGELOG.md index cf41a151b3..3b9b1d0deb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ - Some global names and old keywords are no longer prefixed. https://github.com/rescript-lang/rescript-compiler/pull/6831 - Remove ml parsing tests and conversion from `.ml` to `.res` via format. https://github.com/rescript-lang/rescript-compiler/pull/6848 - Remove support for compiling `.ml` files, and general cleanup. https://github.com/rescript-lang/rescript-compiler/pull/6852 +- Remove `rescript convert` subcommand. https://github.com/rescript-lang/rescript-compiler/pull/6860 #### :bug: Bug Fix diff --git a/cli/rescript_bsb.js b/cli/rescript_bsb.js index 9155f6518f..a18f3ef0ac 100644 --- a/cli/rescript_bsb.js +++ b/cli/rescript_bsb.js @@ -322,10 +322,7 @@ Please pick a different one using the \`-ws [host:]port\` flag from bsb.`); if (!fileName) return true; return ( - ((fileName.endsWith(".res") || - fileName.endsWith(".resi") || - fileName.endsWith(".ml") || - fileName.endsWith(".mli")) && + ((fileName.endsWith(".res") || fileName.endsWith(".resi")) && !watchGenerated.includes(fileName)) || fileName === resConfig ); diff --git a/cli/rescript_convert.js b/cli/rescript_convert.js deleted file mode 100644 index e0e87e65d3..0000000000 --- a/cli/rescript_convert.js +++ /dev/null @@ -1,128 +0,0 @@ -//@ts-check -var arg = require("./rescript_arg.js"); -var format_usage = `Usage: rescript convert [files] - -\`rescript convert\` converts the current directory - -**This command removes old OCaml files and creates new ReScript -files. Make sure your work is saved first!** -`; - -var child_process = require("child_process"); -var path = require("path"); -var fs = require("fs"); - -/** - * @type {arg.boolref} - */ -var formatProject = { val: undefined }; - -/** - * @type{arg.specs} - */ -var specs = [ - [ - "-all", - { kind: "Unit", data: { kind: "Unit_set", data: formatProject } }, - "Convert the whole project", - ], -]; - -/** - * - * @param {string} file - */ -function shouldConvert(file) { - return [".ml", ".mli"].some(x => file.endsWith(x)); -} - -/** - * - * @param {string} file - * @param {string} bsc_exe - * assume the file is convertible - */ -function handleOneFile(file, bsc_exe) { - // console.log(`processing ${arg}`); - var nextExt = file.endsWith("i") ? ".resi" : ".res"; - child_process.execFile( - bsc_exe, - ["-o", file.substr(0, file.lastIndexOf(".")) + nextExt, "-format", file], - (error, stdout, stderr) => { - if (error === null) { - // todo - fs.unlink(file, () => { - //ignore - }); - } else { - // todo error handling - console.error(`Error when converting ${file}`); - console.log(stderr); - } - }, - ); -} -/** - * @param {string[]} argv - * @param {string} rescript_exe - * @param {string} bsc_exe - */ -function main(argv, rescript_exe, bsc_exe) { - try { - /** - * @type {string[]} - */ - var files = []; - arg.parse_exn(format_usage, argv, specs, xs => { - files = xs; - }); - - var format_project = formatProject.val; - - if (format_project) { - if (files.length !== 0) { - console.error("convert -all can not be in use with other flags"); - process.exit(2); - } - // -all - // TODO: check the rest arguments - var output = child_process.spawnSync( - rescript_exe, - ["info", "-list-files"], - { - encoding: "utf-8", - }, - ); - if (output.status !== 0) { - console.error(output.stdout); - console.error(output.stderr); - process.exit(2); - } - files = output.stdout.split("\n").map(x => x.trim()); - for (let file of files) { - if (shouldConvert(file)) { - handleOneFile(file, bsc_exe); - } - } - } else { - for (let i = 0; i < files.length; ++i) { - let file = files[i]; - if (!shouldConvert(file)) { - console.error(`don't know what do with ${file}`); - process.exit(2); - } - } - files.forEach(file => { - handleOneFile(file, bsc_exe); - }); - } - } catch (e) { - if (e instanceof arg.ArgError) { - console.error(e.message); - process.exit(2); - } else { - throw e; - } - } -} -exports.main = main; diff --git a/jscomp/build_tests/cli_help/input.js b/jscomp/build_tests/cli_help/input.js index 8b2cbffcbf..8fe5b9b9b4 100755 --- a/jscomp/build_tests/cli_help/input.js +++ b/jscomp/build_tests/cli_help/input.js @@ -16,7 +16,6 @@ const cliHelp = " build\n" + " clean\n" + " format\n" + - " convert\n" + " dump\n" + " help\n" + "\n" + @@ -58,17 +57,6 @@ const formatHelp = " -all Format the whole project \n" + " -check Check formatting for file or the whole project. Use `-all` to check the whole project\n"; -const convertHelp = - "Usage: rescript convert [files]\n" + - "\n" + - "`rescript convert` converts the current directory\n" + - "\n" + - "**This command removes old OCaml files and creates new ReScript \n" + - "files. Make sure your work is saved first!**\n" + - "\n" + - "Options:\n" + - " -all Convert the whole project\n"; - const dumpHelp = "Usage: rescript dump [target]\n" + "`rescript dump` dumps the information for the target\n"; @@ -232,26 +220,6 @@ async function test() { assert.equal(out.status, 0); } - { - // Shows convert help with --help arg - const out = await exec(`../../../rescript`, ["convert", "--help"], { - cwd: __dirname, - }); - assert.equal(out.stdout, convertHelp); - assert.equal(out.stderr, ""); - assert.equal(out.status, 0); - } - - { - // Shows convert help with -h arg - const out = await exec(`../../../rescript`, ["convert", "-h"], { - cwd: __dirname, - }); - assert.equal(out.stdout, convertHelp); - assert.equal(out.stderr, ""); - assert.equal(out.status, 0); - } - { // Shows dump help with --help arg const out = await exec(`../../../rescript`, ["dump", "--help"], { diff --git a/packages/artifacts.txt b/packages/artifacts.txt index a2aa707bcf..61c994010b 100644 --- a/packages/artifacts.txt +++ b/packages/artifacts.txt @@ -8,7 +8,6 @@ bsc cli/bin_path.js cli/rescript_arg.js cli/rescript_bsb.js -cli/rescript_convert.js cli/rescript_dump.js cli/rescript_format.js cli/rescript_postinstall.js diff --git a/rescript b/rescript index 94ac87c137..ea84b0f8b4 100755 --- a/rescript +++ b/rescript @@ -36,7 +36,6 @@ Subcommands: build clean format - convert dump help @@ -119,14 +118,6 @@ if (helpArgIndex !== -1 && (firstPositionalArgIndex === -1 || helpArgIndex <= fi ); break; } - case "convert": { - require("./cli/rescript_convert.js").main( - subcmdArgs, - rescript_exe, - bsc_exe - ); - break; - } default: { console.error( `Error: Unknown command "${subcmd}".\n${helpMessage}`