From 783bdbbca55188d4719636705e4efdaf3bdaa9cd Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 15 Apr 2018 15:45:05 +0200 Subject: [PATCH 01/32] The binary is now `elm`, not `elm-make`. --- index.js | 43 +++++++++++++++++++++---------------------- test/compile.js | 4 ++-- test/compileSync.js | 2 +- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/index.js b/index.js index 1019993..dac7c51 100644 --- a/index.js +++ b/index.js @@ -2,7 +2,7 @@ var spawn = require("cross-spawn"); var _ = require("lodash"); -var compilerBinaryName = "elm-make"; +var elmBinaryName = "elm"; var fs = require("fs"); var path = require("path"); var temp = require("temp").track(); @@ -12,8 +12,7 @@ var defaultOptions = { emitWarning: console.warn, spawn: spawn, cwd: undefined, - pathToMake: undefined, - yes: undefined, + pathToElm: undefined, help: undefined, output: undefined, report: undefined, @@ -40,9 +39,9 @@ function prepareOptions(options, spawnFn) { function prepareProcessArgs(sources, options) { var preparedSources = prepareSources(sources); - var compilerArgs = compilerArgsFromOptions(options, options.emitWarning); - return preparedSources ? preparedSources.concat(compilerArgs) : compilerArgs; + + return ["make"].concat(preparedSources ? preparedSources.concat(compilerArgs) : compilerArgs); } function prepareProcessOpts(options) { @@ -51,7 +50,7 @@ function prepareProcessOpts(options) { } -function runCompiler(sources, options, pathToMake) { +function runCompiler(sources, options, pathToElm) { if (typeof options.spawn !== "function") { throw "options.spawn was a(n) " + (typeof options.spawn) + " instead of a function."; } @@ -60,17 +59,17 @@ function runCompiler(sources, options, pathToMake) { var processOpts = prepareProcessOpts(options); if (options.verbose) { - console.log(["Running", pathToMake].concat(processArgs || []).join(" ")); + console.log(["Running", pathToElm].concat(processArgs).join(" ")); } - return options.spawn(pathToMake, processArgs, processOpts); + return options.spawn(pathToElm, processArgs, processOpts); } -function handleCompilerError(err, pathToMake) { +function handleCompilerError(err, pathToElm) { if ((typeof err === "object") && (typeof err.code === "string")) { - handleError(pathToMake, err); + handleError(pathToElm, err); } else { - console.error("Exception thrown when attempting to run Elm compiler " + JSON.stringify(pathToMake) + ":\n"); + console.error("Exception thrown when attempting to run Elm compiler " + JSON.stringify(pathToElm) + ":\n"); } throw err; @@ -79,29 +78,29 @@ function handleCompilerError(err, pathToMake) { function compileSync(sources, options) { var optionsWithDefaults = prepareOptions(options, options.spawn || spawn.sync); - var pathToMake = options.pathToMake || compilerBinaryName; + var pathToElm = options.pathToElm || elmBinaryName; try { - return runCompiler(sources, optionsWithDefaults, pathToMake); + return runCompiler(sources, optionsWithDefaults, pathToElm); } catch (err) { - handleCompilerError(err, pathToMake); + handleCompilerError(err, pathToElm); } } function compile(sources, options) { var optionsWithDefaults = prepareOptions(options, options.spawn || spawn); - var pathToMake = options.pathToMake || compilerBinaryName; + var pathToElm = options.pathToElm || elmBinaryName; try { - return runCompiler(sources, optionsWithDefaults, pathToMake) + return runCompiler(sources, optionsWithDefaults, pathToElm) .on('error', function(err) { - handleError(pathToMake, err); + handleError(pathToElm, err); process.exit(1); }); } catch (err) { - handleCompilerError(err, pathToMake); + handleCompilerError(err, pathToElm); } } @@ -164,13 +163,13 @@ function compileToStringSync(sources, options) { return fs.readFileSync(file.path, {encoding: "utf8"}); } -function handleError(pathToMake, err) { +function handleError(pathToElm, err) { if (err.code === "ENOENT") { - console.error("Could not find Elm compiler \"" + pathToMake + "\". Is it installed?") + console.error("Could not find Elm compiler \"" + pathToElm + "\". Is it installed?") } else if (err.code === "EACCES") { - console.error("Elm compiler \"" + pathToMake + "\" did not have permission to run. Do you need to give it executable permissions?"); + console.error("Elm compiler \"" + pathToElm + "\" did not have permission to run. Do you need to give it executable permissions?"); } else { - console.error("Error attempting to run Elm compiler \"" + pathToMake + "\":\n" + err); + console.error("Error attempting to run Elm compiler \"" + pathToElm + "\":\n" + err); } } diff --git a/test/compile.js b/test/compile.js index f836588..489080c 100644 --- a/test/compile.js +++ b/test/compile.js @@ -39,7 +39,7 @@ describe("#compile", function() { var compileProcess = compiler.compile(prependFixturesDir("Bad.elm"), opts); compileProcess.on("exit", function(exitCode) { - var desc = "Expected elm-make to have exit code 1"; + var desc = "Expected elm make to have exit code 1"; expect(exitCode, desc).to.equal(1); done(); }); @@ -158,7 +158,7 @@ describe("#compileToString", function() { var compilePromise = compiler.compileToString(prependFixturesDir("Parent.elm"), opts) return compilePromise.then(function(result) { - var desc = "Expected elm-make to return the result of the compilation"; + var desc = "Expected elm make to return the result of the compilation"; expect(result.toString(), desc).to.be.a('string'); }); }; diff --git a/test/compileSync.js b/test/compileSync.js index e81a584..b3ef9a8 100644 --- a/test/compileSync.js +++ b/test/compileSync.js @@ -30,7 +30,7 @@ describe("#compileSync", function() { var compileProcess = compiler.compileSync(prependFixturesDir("Bad.elm"), opts); var exitCode = compileProcess.status; - var desc = "Expected elm-make to have exit code 1"; + var desc = "Expected elm make to have exit code 1"; expect(exitCode, desc).to.equal(1); }); From 143fc9caa1c52f7217de1122510d477837efcaee Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 15 Apr 2018 15:47:50 +0200 Subject: [PATCH 02/32] :skull: --yes --- examples/compileHelloWorld.js | 4 ++-- index.js | 1 - test/compile.js | 34 +--------------------------------- test/compileSync.js | 9 --------- test/compileToStringSync.js | 4 ++-- worker.js | 2 +- 6 files changed, 6 insertions(+), 48 deletions(-) diff --git a/examples/compileHelloWorld.js b/examples/compileHelloWorld.js index b8f0b9b..658b03c 100644 --- a/examples/compileHelloWorld.js +++ b/examples/compileHelloWorld.js @@ -8,10 +8,10 @@ compile(["./HelloWorld.elm"], { }); -compileToString(["./HelloWorld.elm"], { yes: true }).then(function(data){ +compileToString(["./HelloWorld.elm"], {}).then(function(data){ console.log("Text", data.toString()); }); -compileToString(["./HelloWorld.elm"], { yes: true, output: "index.html" }).then(function(data){ +compileToString(["./HelloWorld.elm"], { output: "index.html" }).then(function(data){ console.log("Text", data.toString()); }); diff --git a/index.js b/index.js index dac7c51..66dadbc 100644 --- a/index.js +++ b/index.js @@ -179,7 +179,6 @@ function compilerArgsFromOptions(options, emitWarning) { return _.flatten(_.map(options, function(value, opt) { if (value) { switch(opt) { - case "yes": return ["--yes"]; case "help": return ["--help"]; case "output": return ["--output", value]; case "report": return ["--report", value]; diff --git a/test/compile.js b/test/compile.js index 489080c..148c8b7 100644 --- a/test/compile.js +++ b/test/compile.js @@ -20,19 +20,8 @@ describe("#compile", function() { // Use a timeout of 5 minutes because Travis on Linux can be SUPER slow. this.timeout(300000); - it("works with --yes", function (done) { - var opts = {yes: true, output: "/dev/null", verbose: true, cwd: fixturesDir}; - var compileProcess = compiler.compile(prependFixturesDir("Parent.elm"), opts); - - compileProcess.on("exit", function(exitCode) { - expect(exitCode, "Expected elm-make to have exit code 0").to.equal(0); - done(); - }); - }); - it("reports errors on bad source", function (done) { var opts = { - yes: true, verbose: true, cwd: fixturesDir }; @@ -49,7 +38,6 @@ describe("#compile", function() { var opts = { foo: "bar", emitWarning: chai.spy(), - yes: true, output: "/dev/null", verbose: true, cwd: fixturesDir @@ -68,23 +56,8 @@ describe("#compileToString", function() { // Use an epic timeout because Travis on Linux can be SUPER slow. this.timeout(600000); - it("works with --yes", function () { - var opts = { - yes: true, - verbose: true, - cwd: fixturesDir - }; - var compilePromise = compiler.compileToString(prependFixturesDir("Parent.elm"), opts); - - return compilePromise.then(function(result) { - var desc = "Expected elm-make to return the result of the compilation"; - expect(result.toString(), desc).to.be.a('string'); - }); - }); - it("adds runtime options as arguments", function () { var opts = { - yes: true, verbose: true, cwd: fixturesDir, runtimeOptions: "-A128M -H128M -n8m" @@ -92,12 +65,11 @@ describe("#compileToString", function() { return expect(compiler ._prepareProcessArgs("a.elm", opts) - .join(" ")).to.equal("a.elm --yes +RTS -A128M -H128M -n8m -RTS"); + .join(" ")).to.equal("a.elm +RTS -A128M -H128M -n8m -RTS"); }); it("reports errors on bad syntax", function () { var opts = { - yes: true, verbose: true, cwd: fixturesDir }; @@ -113,7 +85,6 @@ describe("#compileToString", function() { it("reports type errors", function () { var opts = { - yes: true, verbose: true, cwd: fixturesDir }; @@ -131,7 +102,6 @@ describe("#compileToString", function() { var opts = { foo: "bar", emitWarning: chai.spy(), - yes: true, verbose: true, cwd: fixturesDir }; @@ -146,7 +116,6 @@ describe("#compileToString", function() { it("works when run multiple times", function () { var opts = { - yes: true, verbose: true, cwd: fixturesDir }; @@ -176,7 +145,6 @@ describe("#compileWorker", function() { it("works with BasicWorker.elm", function() { var opts = { - yes: true, verbose: true, cwd: fixturesDir }; diff --git a/test/compileSync.js b/test/compileSync.js index b3ef9a8..212a18a 100644 --- a/test/compileSync.js +++ b/test/compileSync.js @@ -14,16 +14,8 @@ describe("#compileSync", function() { // Use a timeout of 5 minutes because Travis on Linux can be SUPER slow. this.timeout(300000); - it("works with --yes", function () { - var opts = {yes: true, output: "/dev/null", verbose: true, cwd: fixturesDir}; - var compileProcess = compiler.compileSync(prependFixturesDir("Parent.elm"), opts); - - expect(compileProcess.status, "Expected elm-make to have exit code 0").to.equal(0); - }); - it("reports errors on bad source", function () { var opts = { - yes: true, verbose: true, cwd: fixturesDir }; @@ -38,7 +30,6 @@ describe("#compileSync", function() { var opts = { foo: "bar", emitWarning: chai.spy(), - yes: true, output: "/dev/null", verbose: true, cwd: fixturesDir diff --git a/test/compileToStringSync.js b/test/compileToStringSync.js index 1a8b007..4f9ac22 100644 --- a/test/compileToStringSync.js +++ b/test/compileToStringSync.js @@ -13,7 +13,7 @@ function prependFixturesDir(filename) { describe("#compileToStringSync", function() { it('returns string JS output of the given elm file', function() { - var opts = {yes: true, verbose: true, cwd: fixturesDir}; + var opts = {verbose: true, cwd: fixturesDir}; var result = compiler.compileToStringSync(prependFixturesDir("Parent.elm"), opts); expect(result).to.include("globalElm[publicModule] = Elm[publicModule];"); @@ -21,7 +21,7 @@ describe("#compileToStringSync", function() { }); it('returns html output given "html" output option', function() { - var opts = {yes: true, verbose: true, cwd: fixturesDir, output: '.html'}; + var opts = {verbose: true, cwd: fixturesDir, output: '.html'}; var result = compiler.compileToStringSync(prependFixturesDir("Parent.elm"), opts); expect(result).to.include(''); diff --git a/worker.js b/worker.js index 78c54b8..50e8aae 100644 --- a/worker.js +++ b/worker.js @@ -42,7 +42,7 @@ module.exports = function(compile) { .then(function (tmpDirPath) { var dest = path.join(tmpDirPath, jsEmitterFilename); - return compileEmitter(compile, modulePath, {output: dest, yes: true}) + return compileEmitter(compile, modulePath, {output: dest}) .then(function() { return runWorker(dest, moduleName, workerArgs) }); }) .then(function(worker) { From 149d60d4c6589e82ba510ed1781faef3824334a6 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 15 Apr 2018 15:48:11 +0200 Subject: [PATCH 03/32] Blow up if we get an unknown option. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 66dadbc..d040dab 100644 --- a/index.js +++ b/index.js @@ -188,7 +188,7 @@ function compilerArgsFromOptions(options, emitWarning) { case "runtimeOptions": return ["+RTS", value, "-RTS"] default: if (supportedOptions.indexOf(opt) === -1) { - emitWarning('Unknown Elm compiler option: ' + opt); + throw new Error('node-elm-compiler was given an unrecognized Elm compiler option: ' + opt); } return []; From 6a9f3b0fbc896a690b70e299804324c51de168cd Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 15 Apr 2018 15:48:26 +0200 Subject: [PATCH 04/32] elm-pacakge.json -> elm.json --- examples/elm-package.json | 15 --------------- examples/elm.json | 18 ++++++++++++++++++ test/fixtures/elm-package.json | 16 ---------------- test/fixtures/elm.json | 18 ++++++++++++++++++ 4 files changed, 36 insertions(+), 31 deletions(-) delete mode 100644 examples/elm-package.json create mode 100644 examples/elm.json delete mode 100644 test/fixtures/elm-package.json create mode 100644 test/fixtures/elm.json diff --git a/examples/elm-package.json b/examples/elm-package.json deleted file mode 100644 index 7905f63..0000000 --- a/examples/elm-package.json +++ /dev/null @@ -1,15 +0,0 @@ -{ - "version": "1.0.0", - "summary": "helpful summary of your project, less than 80 characters", - "repository": "https://github.com/rtf/foo.git", - "license": "BSD3", - "source-directories": [ - "." - ], - "exposed-modules": [], - "dependencies": { - "elm-lang/core": "5.0.0 <= v < 6.0.0", - "elm-lang/html": "2.0.0 <= v < 3.0.0" - }, - "elm-version": "0.18.0 <= v < 0.19.0" -} diff --git a/examples/elm.json b/examples/elm.json new file mode 100644 index 0000000..a8d3d10 --- /dev/null +++ b/examples/elm.json @@ -0,0 +1,18 @@ +{ + "type": "application", + "source-directories": [ + "." + ], + "elm-version": "0.19.0", + "dependencies": { + "elm-lang/core": "6.0.0", + "elm-lang/html": "3.0.0" + }, + "test-dependencies": {}, + "do-not-edit-this-by-hand": { + "transitive-dependencies": { + "elm-lang/json": "1.0.0", + "elm-lang/virtual-dom": "3.0.0" + } + } +} \ No newline at end of file diff --git a/test/fixtures/elm-package.json b/test/fixtures/elm-package.json deleted file mode 100644 index e181c3d..0000000 --- a/test/fixtures/elm-package.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "version": "1.0.0", - "summary": "helpful summary of your project, less than 80 characters", - "repository": "https://github.com/foo/bar.git", - "license": "BSD3", - "source-directories": [ - "." - ], - "native-modules": true, - "exposed-modules": [], - "dependencies": { - "elm-lang/core": "5.0.0 <= v < 6.0.0", - "elm-lang/html": "2.0.0 <= v < 3.0.0" - }, - "elm-version": "0.18.0 <= v < 0.19.0" -} diff --git a/test/fixtures/elm.json b/test/fixtures/elm.json new file mode 100644 index 0000000..a8d3d10 --- /dev/null +++ b/test/fixtures/elm.json @@ -0,0 +1,18 @@ +{ + "type": "application", + "source-directories": [ + "." + ], + "elm-version": "0.19.0", + "dependencies": { + "elm-lang/core": "6.0.0", + "elm-lang/html": "3.0.0" + }, + "test-dependencies": {}, + "do-not-edit-this-by-hand": { + "transitive-dependencies": { + "elm-lang/json": "1.0.0", + "elm-lang/virtual-dom": "3.0.0" + } + } +} \ No newline at end of file From 98a9808a54daca77b69f9bcdce77c296ce2b7978 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 15 Apr 2018 16:09:01 +0200 Subject: [PATCH 05/32] Don't print the whole string on the example. --- examples/compileHelloWorld.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/compileHelloWorld.js b/examples/compileHelloWorld.js index 658b03c..c5f1156 100644 --- a/examples/compileHelloWorld.js +++ b/examples/compileHelloWorld.js @@ -9,9 +9,9 @@ compile(["./HelloWorld.elm"], { compileToString(["./HelloWorld.elm"], {}).then(function(data){ - console.log("Text", data.toString()); + console.log("compileToString produced a string with this length:", data.toString().length); }); compileToString(["./HelloWorld.elm"], { output: "index.html" }).then(function(data){ - console.log("Text", data.toString()); + console.log("compileToString --output index.html produced a string with this length:", data.toString().length); }); From 76acd58639d095964f1056f618e2cc20037760dc Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 15 Apr 2018 16:16:13 +0200 Subject: [PATCH 06/32] :skull: Native --- test/fixtures/Native/Child.js | 3 --- test/fixtures/Parent.elm | 1 - test/fixtures/ParentWithPort.elm | 1 - test/fixtures/ParentWithUnindentedMultilineComment.elm | 1 - test/fixtures/Test/Sample/NestedChild.elm | 1 - worker.js | 1 - 6 files changed, 8 deletions(-) delete mode 100644 test/fixtures/Native/Child.js diff --git a/test/fixtures/Native/Child.js b/test/fixtures/Native/Child.js deleted file mode 100644 index b9ca6f3..0000000 --- a/test/fixtures/Native/Child.js +++ /dev/null @@ -1,3 +0,0 @@ -function doNativeStuff() { - console.log("I'm not elm code!") -} diff --git a/test/fixtures/Parent.elm b/test/fixtures/Parent.elm index 1b20aa2..09082d5 100644 --- a/test/fixtures/Parent.elm +++ b/test/fixtures/Parent.elm @@ -6,7 +6,6 @@ import Test.ChildA -- This is a comment in between two import statements. import Test.ChildB exposing (..) -import Native.Child exposing (..) import Html diff --git a/test/fixtures/ParentWithPort.elm b/test/fixtures/ParentWithPort.elm index b21cdf5..84a1e8c 100644 --- a/test/fixtures/ParentWithPort.elm +++ b/test/fixtures/ParentWithPort.elm @@ -6,7 +6,6 @@ import Test.ChildA -- This is a comment in between two import statements. import Test.ChildB exposing (..) -import Native.Child exposing (..) import Html diff --git a/test/fixtures/ParentWithUnindentedMultilineComment.elm b/test/fixtures/ParentWithUnindentedMultilineComment.elm index 8fd819c..425f5b9 100644 --- a/test/fixtures/ParentWithUnindentedMultilineComment.elm +++ b/test/fixtures/ParentWithUnindentedMultilineComment.elm @@ -9,7 +9,6 @@ import Test.ChildA import Test.ChildB exposing (..) {- this comment will end before an import -} -import Native.Child exposing (..) import Html diff --git a/test/fixtures/Test/Sample/NestedChild.elm b/test/fixtures/Test/Sample/NestedChild.elm index ec27820..bdd8f3c 100644 --- a/test/fixtures/Test/Sample/NestedChild.elm +++ b/test/fixtures/Test/Sample/NestedChild.elm @@ -1,7 +1,6 @@ module Test.Sample.NestedChild exposing (..) import Test.ChildB -import Native.Child exposing (..) main = diff --git a/worker.js b/worker.js index 50e8aae..e01d0e1 100644 --- a/worker.js +++ b/worker.js @@ -5,7 +5,6 @@ var jsEmitterFilename = "emitter.js"; var KNOWN_MODULES = [ - "Native", "fullscreen", "embed", "worker", From fbb37d4a872dc64c0ea77cd92592f188d3f10f09 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 15 Apr 2018 16:51:28 +0200 Subject: [PATCH 07/32] Throw instead of warning. Fixes #68 --- index.js | 51 +++++++++++++++++++++------------------------ test/compile.js | 26 +++++++++++------------ test/compileSync.js | 11 +++++----- 3 files changed, 42 insertions(+), 46 deletions(-) diff --git a/index.js b/index.js index d040dab..84439bc 100644 --- a/index.js +++ b/index.js @@ -9,7 +9,6 @@ var temp = require("temp").track(); var findAllDependencies = require("find-elm-dependencies").findAllDependencies; var defaultOptions = { - emitWarning: console.warn, spawn: spawn, cwd: undefined, pathToElm: undefined, @@ -39,7 +38,7 @@ function prepareOptions(options, spawnFn) { function prepareProcessArgs(sources, options) { var preparedSources = prepareSources(sources); - var compilerArgs = compilerArgsFromOptions(options, options.emitWarning); + var compilerArgs = compilerArgsFromOptions(options); return ["make"].concat(preparedSources ? preparedSources.concat(compilerArgs) : compilerArgs); } @@ -65,15 +64,21 @@ function runCompiler(sources, options, pathToElm) { return options.spawn(pathToElm, processArgs, processOpts); } -function handleCompilerError(err, pathToElm) { +function compilerErrorToString(err, pathToElm) { if ((typeof err === "object") && (typeof err.code === "string")) { - handleError(pathToElm, err); + switch (err.code) { + case "ENOENT": + return ("Could not find Elm compiler \"" + pathToElm + "\". Is it installed?") + + case "EACCES": + return ("Elm compiler \"" + pathToElm + "\" did not have permission to run. Do you need to give it executable permissions?"); + + default: + return ("Error attempting to run Elm compiler \"" + pathToElm + "\":\n" + err); + } } else { - console.error("Exception thrown when attempting to run Elm compiler " + JSON.stringify(pathToElm) + ":\n"); + return ("Exception thrown when attempting to run Elm compiler " + JSON.stringify(pathToElm) + ":\n"); } - throw err; - - process.exit(1); } function compileSync(sources, options) { @@ -83,7 +88,7 @@ function compileSync(sources, options) { try { return runCompiler(sources, optionsWithDefaults, pathToElm); } catch (err) { - handleCompilerError(err, pathToElm); + throw compilerErrorToString(err, pathToElm); } } @@ -94,13 +99,9 @@ function compile(sources, options) { try { return runCompiler(sources, optionsWithDefaults, pathToElm) - .on('error', function(err) { - handleError(pathToElm, err); - - process.exit(1); - }); + .on('error', function(err) { throw(err); }); } catch (err) { - handleCompilerError(err, pathToElm); + throw compilerErrorToString(err, pathToElm); } } @@ -123,7 +124,13 @@ function compileToString(sources, options){ options.output = info.path; options.processOpts = { stdio: 'pipe' } - var compiler = compile(sources, options); + var compiler; + + try { + compiler = compile(sources, options); + } catch(compileError) { + return reject(compileError); + } compiler.stdout.setEncoding("utf8"); compiler.stderr.setEncoding("utf8"); @@ -163,19 +170,9 @@ function compileToStringSync(sources, options) { return fs.readFileSync(file.path, {encoding: "utf8"}); } -function handleError(pathToElm, err) { - if (err.code === "ENOENT") { - console.error("Could not find Elm compiler \"" + pathToElm + "\". Is it installed?") - } else if (err.code === "EACCES") { - console.error("Elm compiler \"" + pathToElm + "\" did not have permission to run. Do you need to give it executable permissions?"); - } else { - console.error("Error attempting to run Elm compiler \"" + pathToElm + "\":\n" + err); - } -} - // Converts an object of key/value pairs to an array of arguments suitable // to be passed to child_process.spawn for elm-make. -function compilerArgsFromOptions(options, emitWarning) { +function compilerArgsFromOptions(options) { return _.flatten(_.map(options, function(value, opt) { if (value) { switch(opt) { diff --git a/test/compile.js b/test/compile.js index 148c8b7..14b29a7 100644 --- a/test/compile.js +++ b/test/compile.js @@ -34,21 +34,18 @@ describe("#compile", function() { }); }); - it("invokes custom `emitWarning`", function (done) { + it("throws when given an unrecognized argument", function () { var opts = { foo: "bar", - emitWarning: chai.spy(), output: "/dev/null", verbose: true, cwd: fixturesDir }; - var compileProcess = compiler.compile(prependFixturesDir("Parent.elm"), opts); - compileProcess.on("exit", function(exitCode) { - var desc = "Expected emitWarning to have been called"; - expect(opts.emitWarning, desc).to.have.been.called(); - done(); - }); + expect(function() { + var compileProcess = compiler.compile(prependFixturesDir("Parent.elm"), opts); + + }).to.throw(); }); }); @@ -98,18 +95,21 @@ describe("#compileToString", function() { }); }); - it("invokes custom `emitWarning`", function () { + it("Rejects the Promise when given an unrecognized argument like `yes`", function () { var opts = { foo: "bar", - emitWarning: chai.spy(), verbose: true, cwd: fixturesDir }; + var compilePromise = compiler.compileToString(prependFixturesDir("Parent.elm"), opts); - return compilePromise.then(function(err) { - var desc = "Expected emitWarning to have been called"; - expect(opts.emitWarning, desc).to.have.been.called(); + return new Promise(function(resolve, reject) { + return compilePromise.then(function() { + reject("Expected the compilation promise to be rejected due to the unrecognized compiler argument."); + }).catch(function() { + resolve(); + }); }); }); diff --git a/test/compileSync.js b/test/compileSync.js index 212a18a..56b6ce3 100644 --- a/test/compileSync.js +++ b/test/compileSync.js @@ -26,17 +26,16 @@ describe("#compileSync", function() { expect(exitCode, desc).to.equal(1); }); - it("invokes custom `emitWarning`", function () { + it("throws when given an unrecognized argument like `yes`", function () { var opts = { - foo: "bar", - emitWarning: chai.spy(), + yes: true, output: "/dev/null", verbose: true, cwd: fixturesDir }; - var compileProcess = compiler.compileSync(prependFixturesDir("Parent.elm"), opts); - var desc = "Expected emitWarning to have been called"; - expect(opts.emitWarning, desc).to.have.been.called(); + expect(function() { + var compileProcess = compiler.compileSync(prependFixturesDir("Parent.elm"), opts); + }).to.throw(); }); }); From f4a12903ed6de09a9e9b758f4fd2827dfe6cd5b0 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 15 Apr 2018 17:16:14 +0200 Subject: [PATCH 08/32] Give a custom error for passing the `yes` opt. --- index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index 84439bc..581f05d 100644 --- a/index.js +++ b/index.js @@ -185,7 +185,11 @@ function compilerArgsFromOptions(options) { case "runtimeOptions": return ["+RTS", value, "-RTS"] default: if (supportedOptions.indexOf(opt) === -1) { - throw new Error('node-elm-compiler was given an unrecognized Elm compiler option: ' + opt); + if (opt === "yes") { + throw new Error('node-elm-compiler received the `yes` option, but that was removed in Elm 0.19. Try re-running without passing the `yes` option.'); + } else { + throw new Error('node-elm-compiler was given an unrecognized Elm compiler option: ' + opt); + } } return []; From ef5c6f20067b4b793872db0527573d680bd41cb5 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 15 Apr 2018 17:22:01 +0200 Subject: [PATCH 09/32] Update fixture expectations for 0.19 output. --- test/compile.js | 2 +- test/compileToStringSync.js | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/test/compile.js b/test/compile.js index 14b29a7..1b1c02f 100644 --- a/test/compile.js +++ b/test/compile.js @@ -62,7 +62,7 @@ describe("#compileToString", function() { return expect(compiler ._prepareProcessArgs("a.elm", opts) - .join(" ")).to.equal("a.elm +RTS -A128M -H128M -n8m -RTS"); + .join(" ")).to.equal("make a.elm +RTS -A128M -H128M -n8m -RTS"); }); it("reports errors on bad syntax", function () { diff --git a/test/compileToStringSync.js b/test/compileToStringSync.js index 4f9ac22..e537261 100644 --- a/test/compileToStringSync.js +++ b/test/compileToStringSync.js @@ -16,8 +16,7 @@ describe("#compileToStringSync", function() { var opts = {verbose: true, cwd: fixturesDir}; var result = compiler.compileToStringSync(prependFixturesDir("Parent.elm"), opts); - expect(result).to.include("globalElm[publicModule] = Elm[publicModule];"); - expect(result).to.include("Elm['Parent'] = Elm['Parent'] || {}"); + expect(result).to.include("_Platform_export"); }); it('returns html output given "html" output option', function() { @@ -26,7 +25,6 @@ describe("#compileToStringSync", function() { expect(result).to.include(''); expect(result).to.include('Parent'); - expect(result).to.include("globalElm[publicModule] = Elm[publicModule];"); - expect(result).to.include("Elm['Parent'] = Elm['Parent'] || {}"); + expect(result).to.include("_Platform_export"); }); }); From 1c0c4d5bbe73679eb993fa2b46b3b75c8fbb4ea2 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 15 Apr 2018 17:27:06 +0200 Subject: [PATCH 10/32] :skull: Unused chai-spies dependency --- package.json | 1 - test/compile.js | 3 --- test/compileToStringSync.js | 1 - 3 files changed, 5 deletions(-) diff --git a/package.json b/package.json index 2e75841..de99c71 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,6 @@ }, "devDependencies": { "chai": "3.5.0", - "chai-spies": "0.7.1", "glob": "7.1.1", "mocha": "5.1.1" } diff --git a/test/compile.js b/test/compile.js index 1b1c02f..c02e1eb 100644 --- a/test/compile.js +++ b/test/compile.js @@ -1,13 +1,10 @@ var chai = require("chai") -var spies = require("chai-spies"); var path = require("path"); var compiler = require(path.join(__dirname, "..")); var childProcess = require("child_process"); var _ = require("lodash"); var temp = require("temp"); -chai.use(spies); - var expect = chai.expect; var fixturesDir = path.join(__dirname, "fixtures"); diff --git a/test/compileToStringSync.js b/test/compileToStringSync.js index e537261..5e075cb 100644 --- a/test/compileToStringSync.js +++ b/test/compileToStringSync.js @@ -1,5 +1,4 @@ var chai = require("chai"); -// var spies = require("chia-spies"); var path = require("path"); var compiler = require(path.join(__dirname, "..")); From 7867ee62e22d868a02bd1f59ecacff12ae86249b Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 15 Apr 2018 18:08:31 +0200 Subject: [PATCH 11/32] Rename report port to reportFromWorker --- test/fixtures/BasicWorker.elm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/test/fixtures/BasicWorker.elm b/test/fixtures/BasicWorker.elm index ca97691..e915ea2 100644 --- a/test/fixtures/BasicWorker.elm +++ b/test/fixtures/BasicWorker.elm @@ -1,16 +1,15 @@ port module BasicWorker exposing (..) -import Html import Platform -main : Program Never String msg +main : Program () String msg main = - Platform.program - { init = ( "", report "it's alive!" ) + Platform.worker + { init = \_ -> ( "", reportFromWorker "it's alive!" ) , update = \_ _ -> ( "", Cmd.none ) - , subscriptions = (\_ -> Sub.none) + , subscriptions = \_ -> Sub.none } -port report : String -> Cmd a +port reportFromWorker : String -> Cmd a From 897fd04d8025ce1d0eee1a9acced45aa4299c458 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sun, 15 Apr 2018 18:29:34 +0200 Subject: [PATCH 12/32] Update changelog. --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index ecd4f48..5f5798c 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,10 @@ $ node compileHelloWorld.js # Releases +## 5.0.0 + +Add 0.19 support. Remove `yes` option. Throw exceptions instead of emitting warnings or using process.exit. + ## 4.5.0 Add `runtimeOptions` From 080c74f9eea0b1086567a05f43fce0fb23873688 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 26 Apr 2018 21:38:58 -0400 Subject: [PATCH 13/32] Update test for new compiler error. --- test/compile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/compile.js b/test/compile.js index c02e1eb..738b5e0 100644 --- a/test/compile.js +++ b/test/compile.js @@ -73,7 +73,7 @@ describe("#compileToString", function() { expect(err).to.be.an('error'); expect(String(err)) .to.contain("Compilation failed") - .and.contain("SYNTAX PROBLEM"); + .and.contain("PARSE ERROR"); }); }); From 0820ff6e49095ec56601f565b02083c08f2642ef Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 26 Apr 2018 21:45:29 -0400 Subject: [PATCH 14/32] Update worker for 0.19 --- worker.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/worker.js b/worker.js index e01d0e1..76c943b 100644 --- a/worker.js +++ b/worker.js @@ -99,7 +99,7 @@ function noPortsMessage(moduleName){ function runWorker(jsFilename, moduleName, workerArgs) { return new Promise(function (resolve, reject) { - var Elm = require(jsFilename); + var Elm = require(jsFilename).Elm; if (!(moduleName in Elm)){ return reject(missingEntryModuleMessage(moduleName, Elm)); From 262f12ba103d6f826f8ab7abe6a1831dc14f802a Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 26 Apr 2018 21:45:37 -0400 Subject: [PATCH 15/32] Fix worker port name. --- test/compile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/compile.js b/test/compile.js index 738b5e0..e3b9de1 100644 --- a/test/compile.js +++ b/test/compile.js @@ -152,7 +152,7 @@ describe("#compileWorker", function() { ); return compilePromise.then(function(app) { - app.ports.report.subscribe(function(str) { + app.ports.reportFromWorker.subscribe(function(str) { expect(str).to.equal("it's alive!"); }); }) From bc8b6263ddf02af5347d2e75d7e4eb06c50a2b45 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Thu, 26 Apr 2018 21:49:40 -0400 Subject: [PATCH 16/32] Bump to 5.0.0-alpha1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index de99c71..9e0255d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "node-elm-compiler", - "version": "4.5.0", + "version": "5.0.0-alpha1", "description": "A Node.js interface to the Elm compiler binaries. Supports Elm version 0.17, 0.18", "main": "index.js", "scripts": { From 169a5dd381f4d6159dfb102fee20b35efc402bd5 Mon Sep 17 00:00:00 2001 From: Hugo Saracino Date: Thu, 23 Aug 2018 16:53:29 +0200 Subject: [PATCH 17/32] Support Elm 0.19's --optimize flag --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 581f05d..00e7a7c 100644 --- a/index.js +++ b/index.js @@ -15,11 +15,11 @@ var defaultOptions = { help: undefined, output: undefined, report: undefined, - warn: undefined, debug: undefined, verbose: false, processOpts: undefined, docs: undefined, + optimize: undefined, }; var supportedOptions = _.keys(defaultOptions); @@ -179,9 +179,9 @@ function compilerArgsFromOptions(options) { case "help": return ["--help"]; case "output": return ["--output", value]; case "report": return ["--report", value]; - case "warn": return ["--warn"]; case "debug": return ["--debug"]; case "docs": return ["--docs", value] + case "optimize": return ["--optimize"]; case "runtimeOptions": return ["+RTS", value, "-RTS"] default: if (supportedOptions.indexOf(opt) === -1) { From cad36b5957de44c6e0e21e3315995a1e72072b5b Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Fri, 24 Aug 2018 12:49:41 -0400 Subject: [PATCH 18/32] Update Changelog --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5f5798c..2ec8a75 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ $ node compileHelloWorld.js ## 5.0.0 -Add 0.19 support. Remove `yes` option. Throw exceptions instead of emitting warnings or using process.exit. +Add 0.19 support. Remove `yes` option. Add `optimize` option. Throw exceptions instead of emitting warnings or using process.exit. ## 4.5.0 From 7449d9da76558a0393dd7e9dc9190ca6d6f61f85 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Sat, 25 Aug 2018 10:40:12 -0400 Subject: [PATCH 19/32] Upgrade find-elm-dependencies to 1.0.3 --- package-lock.json | 415 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 416 insertions(+), 1 deletion(-) create mode 100644 package-lock.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..e8d85df --- /dev/null +++ b/package-lock.json @@ -0,0 +1,415 @@ +{ + "name": "node-elm-compiler", + "version": "5.0.0-alpha1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "assertion-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.0.2.tgz", + "integrity": "sha1-E8pRXYYgbaC6xm6DTdOX2HWBCUw=", + "dev": true + }, + "browser-stdout": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", + "dev": true + }, + "chai": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-3.5.0.tgz", + "integrity": "sha1-TQJjewZ/6Vi9v906QOxW/vc3Mkc=", + "dev": true, + "requires": { + "assertion-error": "^1.0.1", + "deep-eql": "^0.1.3", + "type-detect": "^1.0.0" + } + }, + "commander": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", + "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", + "dev": true + }, + "cross-spawn": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-4.0.0.tgz", + "integrity": "sha1-glR3SrR4a4xbPPTfumbOVjkywlI=", + "requires": { + "lru-cache": "^4.0.1", + "which": "^1.2.9" + }, + "dependencies": { + "lru-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.0.1.tgz", + "integrity": "sha1-E0OVXtry432bnn7nJB4nxLn7cr4=", + "requires": { + "pseudomap": "^1.0.1", + "yallist": "^2.0.0" + }, + "dependencies": { + "pseudomap": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" + }, + "yallist": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.0.0.tgz", + "integrity": "sha1-MGxUODXwnuGkyyO3vOmrNByRzdQ=" + } + } + }, + "which": { + "version": "1.2.10", + "resolved": "https://registry.npmjs.org/which/-/which-1.2.10.tgz", + "integrity": "sha1-kc2b0HUTIkEbZZtA8FSyHelXqy0=", + "requires": { + "isexe": "^1.1.1" + }, + "dependencies": { + "isexe": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-1.1.2.tgz", + "integrity": "sha1-NvPiLmB1CSD15yQaR2qMakInWtA=" + } + } + } + } + }, + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "deep-eql": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz", + "integrity": "sha1-71WKyrjeJSBs1xOQbXTlaTDrafI=", + "dev": true, + "requires": { + "type-detect": "0.1.1" + }, + "dependencies": { + "type-detect": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-0.1.1.tgz", + "integrity": "sha1-C6XsKohWQORw6k6FBZcZANrFiCI=", + "dev": true + } + } + }, + "diff": { + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", + "dev": true + }, + "find-elm-dependencies": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/find-elm-dependencies/-/find-elm-dependencies-1.0.3.tgz", + "integrity": "sha512-NG1Wcy0Gd47KqD7fTOP0ce3vNkCHGT1eEo3PRZ6OxKO1ZxNZy5mv109SOk9CerJULykj1L3u26F/K6uMVZOz/A==", + "requires": { + "firstline": "1.2.0", + "lodash": "4.17.10" + } + }, + "firstline": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/firstline/-/firstline-1.2.0.tgz", + "integrity": "sha1-yfSIbn9/vwr8EtcZQdzgaxkq6gU=" + }, + "glob": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", + "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.2", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "dependencies": { + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", + "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + } + } + }, + "growl": { + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", + "dev": true + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", + "dev": true + }, + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", + "dev": true + }, + "lodash": { + "version": "4.17.10", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", + "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" + }, + "minimist": { + "version": "0.0.8", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz", + "integrity": "sha1-hX/Kv8M5fSYluCKCYuhqp6ARsF0=", + "dev": true + }, + "mkdirp": { + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", + "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", + "dev": true, + "requires": { + "minimist": "0.0.8" + } + }, + "mocha": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.1.1.tgz", + "integrity": "sha512-kKKs/H1KrMMQIEsWNxGmb4/BGsmj0dkeyotEvbrAuQ01FcWRLssUNXCEUZk6SZtyJBi6EE7SL0zDDtItw1rGhw==", + "dev": true, + "requires": { + "browser-stdout": "1.3.1", + "commander": "2.11.0", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.3", + "he": "1.1.1", + "minimatch": "3.0.4", + "mkdirp": "0.5.1", + "supports-color": "4.4.0" + }, + "dependencies": { + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", + "dev": true + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", + "dev": true + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", + "dev": true + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "dev": true, + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", + "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=", + "dev": true + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "dev": true, + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "dev": true, + "requires": { + "wrappy": "1" + } + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", + "dev": true + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", + "dev": true + } + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "supports-color": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", + "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "dev": true, + "requires": { + "has-flag": "^2.0.0" + } + }, + "temp": { + "version": "0.8.3", + "resolved": "https://registry.npmjs.org/temp/-/temp-0.8.3.tgz", + "integrity": "sha1-4Ma8TSa5AxJEEOT+2BEDAU38H1k=", + "requires": { + "os-tmpdir": "^1.0.0", + "rimraf": "~2.2.6" + }, + "dependencies": { + "os-tmpdir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.1.tgz", + "integrity": "sha1-6bQjoe2vR5iCVi6S7XHXdDoHG24=" + }, + "rimraf": { + "version": "2.2.8", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-2.2.8.tgz", + "integrity": "sha1-5Dm+Kq7jJzIZUnMPmaiSnk/FBYI=" + } + } + }, + "type-detect": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-1.0.0.tgz", + "integrity": "sha1-diIXzAbbJY7EiQihKY6LlRIejqI=", + "dev": true + } + } +} diff --git a/package.json b/package.json index 9e0255d..8a11c87 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "homepage": "https://github.com/rtfeldman/node-elm-compiler", "dependencies": { "cross-spawn": "4.0.0", - "find-elm-dependencies": "1.0.2", + "find-elm-dependencies": "1.0.3", "lodash": "4.17.10", "temp": "^0.8.3" }, From b1cb2f9749c3b002bf059b06a32695cc3d53b4d0 Mon Sep 17 00:00:00 2001 From: Eduard Kyvenko Date: Sun, 26 Aug 2018 21:21:44 +0200 Subject: [PATCH 20/32] Upgraded the example to use 0.19 --- examples/elm.json | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/examples/elm.json b/examples/elm.json index a8d3d10..a587ae1 100644 --- a/examples/elm.json +++ b/examples/elm.json @@ -5,14 +5,20 @@ ], "elm-version": "0.19.0", "dependencies": { - "elm-lang/core": "6.0.0", - "elm-lang/html": "3.0.0" - }, - "test-dependencies": {}, - "do-not-edit-this-by-hand": { - "transitive-dependencies": { - "elm-lang/json": "1.0.0", - "elm-lang/virtual-dom": "3.0.0" + "direct": { + "elm/browser": "1.0.0", + "elm/core": "1.0.0", + "elm/html": "1.0.0" + }, + "indirect": { + "elm/json": "1.0.0", + "elm/time": "1.0.0", + "elm/url": "1.0.0", + "elm/virtual-dom": "1.0.0" } + }, + "test-dependencies": { + "direct": {}, + "indirect": {} } } \ No newline at end of file From 636dd45a8819b9d8f0febc995072d519948aa2c4 Mon Sep 17 00:00:00 2001 From: Eduard Kyvenko Date: Sun, 26 Aug 2018 22:25:24 +0200 Subject: [PATCH 21/32] Remove unused dependencies, added missing semicolons. --- index.js | 5 ++--- worker.js | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/index.js b/index.js index 00e7a7c..2384f22 100644 --- a/index.js +++ b/index.js @@ -4,7 +4,6 @@ var spawn = require("cross-spawn"); var _ = require("lodash"); var elmBinaryName = "elm"; var fs = require("fs"); -var path = require("path"); var temp = require("temp").track(); var findAllDependencies = require("find-elm-dependencies").findAllDependencies; @@ -180,9 +179,9 @@ function compilerArgsFromOptions(options) { case "output": return ["--output", value]; case "report": return ["--report", value]; case "debug": return ["--debug"]; - case "docs": return ["--docs", value] + case "docs": return ["--docs", value]; case "optimize": return ["--optimize"]; - case "runtimeOptions": return ["+RTS", value, "-RTS"] + case "runtimeOptions": return ["+RTS", value, "-RTS"]; default: if (supportedOptions.indexOf(opt) === -1) { if (opt === "yes") { diff --git a/worker.js b/worker.js index 76c943b..88682c8 100644 --- a/worker.js +++ b/worker.js @@ -1,4 +1,3 @@ -var fs = require("fs"); var temp = require("temp").track(); var path = require("path"); var jsEmitterFilename = "emitter.js"; @@ -53,7 +52,7 @@ module.exports = function(compile) { throw Error(err); }); }; -} +}; function createTmpDir() { return new Promise(function (resolve, reject) { From c32873892e597b9209ce3f166a580d5614d4af13 Mon Sep 17 00:00:00 2001 From: Eduard Kyvenko Date: Sun, 26 Aug 2018 22:25:36 +0200 Subject: [PATCH 22/32] Fix the tests. --- test/fixtures/elm.json | 18 +++++++++++++++--- worker.js | 2 +- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/test/fixtures/elm.json b/test/fixtures/elm.json index a8d3d10..ce36fa3 100644 --- a/test/fixtures/elm.json +++ b/test/fixtures/elm.json @@ -5,10 +5,22 @@ ], "elm-version": "0.19.0", "dependencies": { - "elm-lang/core": "6.0.0", - "elm-lang/html": "3.0.0" + "direct": { + "elm/browser": "1.0.0", + "elm/core": "1.0.0", + "elm/html": "1.0.0" + }, + "indirect": { + "elm/json": "1.0.0", + "elm/time": "1.0.0", + "elm/url": "1.0.0", + "elm/virtual-dom": "1.0.0" + } + }, + "test-dependencies": { + "direct": {}, + "indirect": {} }, - "test-dependencies": {}, "do-not-edit-this-by-hand": { "transitive-dependencies": { "elm-lang/json": "1.0.0", diff --git a/worker.js b/worker.js index 88682c8..3684e65 100644 --- a/worker.js +++ b/worker.js @@ -104,7 +104,7 @@ function runWorker(jsFilename, moduleName, workerArgs) { return reject(missingEntryModuleMessage(moduleName, Elm)); } - var worker = Elm[moduleName].worker(workerArgs); + var worker = Elm[moduleName].init(workerArgs); if (Object.keys(worker.ports).length === 0){ return reject(noPortsMessage(moduleName, portName)); From c589ace0b23b8bac6b196bcc7d3537727020c3b9 Mon Sep 17 00:00:00 2001 From: Eduard Kyvenko Date: Sun, 26 Aug 2018 22:35:33 +0200 Subject: [PATCH 23/32] Upgrade Travis CI config to run 0.19 --- .travis.yml | 20 +------------------- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/.travis.yml b/.travis.yml index 42589a8..e88b81f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,31 +1,17 @@ sudo: false -cache: - directories: - - test/elm-stuff/build-artifacts - - sysconfcpus - os: - linux - osx env: matrix: - - ELM_VERSION=0.18.0 TARGET_NODE_VERSION=node + - ELM_VERSION=0.19.0 TARGET_NODE_VERSION=node before_install: - if [ ${TRAVIS_OS_NAME} == "osx" ]; then brew update; brew install nvm; mkdir ~/.nvm; export NVM_DIR=~/.nvm; source $(brew --prefix nvm)/nvm.sh; fi - - | # epic build time improvement - see https://github.com/elm-lang/elm-compiler/issues/1473#issuecomment-245704142 - if [ ! -d sysconfcpus/bin ]; - then - git clone https://github.com/obmarg/libsysconfcpus.git; - cd libsysconfcpus; - ./configure --prefix=$TRAVIS_BUILD_DIR/sysconfcpus; - make && make install; - cd ..; - fi install: - nvm install $TARGET_NODE_VERSION @@ -33,10 +19,6 @@ install: - node --version - npm --version - npm install -g elm@$ELM_VERSION - - mv $(npm config get prefix)/bin/elm-make $(npm config get prefix)/bin/elm-make-old - - printf "#\041/bin/bash\n\necho \"Running elm-make with sysconfcpus -n 2\"\n\n$TRAVIS_BUILD_DIR/sysconfcpus/bin/sysconfcpus -n 2 elm-make-old \"\$@\"" > $(npm config get prefix)/bin/elm-make - - chmod +x $(npm config get prefix)/bin/elm-make - - npm install script: - npm test From 2b75716353568c51cdc2b7517c4698e2f4626c6a Mon Sep 17 00:00:00 2001 From: Eduard Kyvenko Date: Sun, 26 Aug 2018 22:40:00 +0200 Subject: [PATCH 24/32] Added npm install to the install script on Travis CI --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e88b81f..239bbc4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,6 +19,7 @@ install: - node --version - npm --version - npm install -g elm@$ELM_VERSION + - npm install script: - npm test From aa58cbed8778401204fe9cfdd3d8296a1790011b Mon Sep 17 00:00:00 2001 From: Eduard Kyvenko Date: Sun, 26 Aug 2018 22:48:58 +0200 Subject: [PATCH 25/32] Use 0.19 on th appveyor --- appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/appveyor.yml b/appveyor.yml index cc8832e..f904d8f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,5 +1,5 @@ environment: - ELM_VERSION: "0.18.0" + ELM_VERSION: "0.19.0" matrix: - nodejs_version: "5.0" - nodejs_version: "4.0" From 92681a63950c2397c7609ba90dbd17e329539a19 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 28 Aug 2018 14:38:22 -0400 Subject: [PATCH 26/32] Upgrade to find-elm-dependencies 2.0.0 --- package-lock.json | 6 +++--- package.json | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index e8d85df..0e05a9f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -119,9 +119,9 @@ "dev": true }, "find-elm-dependencies": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/find-elm-dependencies/-/find-elm-dependencies-1.0.3.tgz", - "integrity": "sha512-NG1Wcy0Gd47KqD7fTOP0ce3vNkCHGT1eEo3PRZ6OxKO1ZxNZy5mv109SOk9CerJULykj1L3u26F/K6uMVZOz/A==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/find-elm-dependencies/-/find-elm-dependencies-2.0.0.tgz", + "integrity": "sha512-lnLilxwdS3U/CSPoMnfUL1u21MBNolv6NF54y4Yds7WxdRMrTBXrmugrcvIGvakWQ2anYuinmBSUR+jUQy+vpA==", "requires": { "firstline": "1.2.0", "lodash": "4.17.10" diff --git a/package.json b/package.json index 8a11c87..6eb3d0a 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "homepage": "https://github.com/rtfeldman/node-elm-compiler", "dependencies": { "cross-spawn": "4.0.0", - "find-elm-dependencies": "1.0.3", + "find-elm-dependencies": "2.0.0", "lodash": "4.17.10", "temp": "^0.8.3" }, From 280a5959afd8b0620a8226aba6e01b56e393362b Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 28 Aug 2018 14:50:18 -0400 Subject: [PATCH 27/32] Add test for compileSync succeeding --- test/compileSync.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/compileSync.js b/test/compileSync.js index 56b6ce3..04cbd29 100644 --- a/test/compileSync.js +++ b/test/compileSync.js @@ -14,6 +14,18 @@ describe("#compileSync", function() { // Use a timeout of 5 minutes because Travis on Linux can be SUPER slow. this.timeout(300000); + it("succeeds on SimplestMain", function () { + var opts = { + verbose: true, + cwd: fixturesDir + }; + var compileProcess = compiler.compileSync(prependFixturesDir("SimplestMain.elm"), opts); + + var exitCode = compileProcess.status; + var desc = "Expected elm make to have exit code 0"; + expect(exitCode, desc).to.equal(0); + }); + it("reports errors on bad source", function () { var opts = { verbose: true, From 042a9b6cc575b708458ec8916a4d737d77201d6b Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 28 Aug 2018 14:50:28 -0400 Subject: [PATCH 28/32] Wipe fixtures/elm-stuff before running tests. --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6eb3d0a..b696fe5 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "A Node.js interface to the Elm compiler binaries. Supports Elm version 0.17, 0.18", "main": "index.js", "scripts": { - "test": "mocha test/*.js" + "test": "rm -rf test/fixtures/elm-stuff; mocha test/*.js" }, "repository": { "type": "git", From b5816d50f98abcbfca3a3c21fb310dcc422b81c5 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 28 Aug 2018 14:51:01 -0400 Subject: [PATCH 29/32] Have Travis run on more node versions --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 239bbc4..a8abe6b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,7 +6,10 @@ os: env: matrix: - - ELM_VERSION=0.19.0 TARGET_NODE_VERSION=node + - ELM_VERSION=0.19.0-bugfix2 TARGET_NODE_VERSION=4.0 + - ELM_VERSION=0.19.0-bugfix2 TARGET_NODE_VERSION=6.0 + - ELM_VERSION=0.19.0-bugfix2 TARGET_NODE_VERSION=8.0 + - ELM_VERSION=0.19.0-bugfix2 TARGET_NODE_VERSION=node before_install: - if [ ${TRAVIS_OS_NAME} == "osx" ]; From e0f6d44a11eada7ec1ea7da0cf97f08ccaaba020 Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 28 Aug 2018 14:51:20 -0400 Subject: [PATCH 30/32] Have Travis clear out ~/.elm before running --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a8abe6b..60a2bbe 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,6 +12,7 @@ env: - ELM_VERSION=0.19.0-bugfix2 TARGET_NODE_VERSION=node before_install: + - rm -rf ~/.elm - if [ ${TRAVIS_OS_NAME} == "osx" ]; then brew update; brew install nvm; mkdir ~/.nvm; export NVM_DIR=~/.nvm; source $(brew --prefix nvm)/nvm.sh; fi From a11ea4ce9fb22be8ce0ce1af5b36f3ce10b2e33b Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 28 Aug 2018 15:00:59 -0400 Subject: [PATCH 31/32] Update README --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 2ec8a75..9826a38 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ # node-elm-compiler [![Version](https://img.shields.io/npm/v/node-elm-compiler.svg)](https://www.npmjs.com/package/node-elm-compiler) [![Travis build Status](https://travis-ci.org/rtfeldman/node-elm-compiler.svg?branch=master)](http://travis-ci.org/rtfeldman/node-elm-compiler) [![AppVeyor build status](https://ci.appveyor.com/api/projects/status/xv83jcomgb81i1iu/branch/master?svg=true)](https://ci.appveyor.com/project/rtfeldman/node-elm-compiler/branch/master) -Wraps [Elm](https://elm-lang.org) and exposes a [Node](https://nodejs.org) API to compile Elm sources. - -Supports Elm version 0.17, 0.18 +Wraps [Elm](https://elm-lang.org) and exposes a [Node](https://nodejs.org) API to compile Elm 0.19 sources. # Example From 665e6d7d4c89486ace1876935bdf8ed1fb44c57a Mon Sep 17 00:00:00 2001 From: Richard Feldman Date: Tue, 28 Aug 2018 15:05:36 -0400 Subject: [PATCH 32/32] Update Appveyor --- appveyor.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f904d8f..c6d942b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,8 @@ environment: - ELM_VERSION: "0.19.0" + ELM_VERSION: "0.19.0-bugfix2" matrix: - - nodejs_version: "5.0" + - nodejs_version: "8.0" + - nodejs_version: "6.0" - nodejs_version: "4.0" platform: