From 638e6f0450663020c8e0016aba9995e895dfde26 Mon Sep 17 00:00:00 2001 From: Eduard Kyvenko Date: Wed, 29 Aug 2018 23:36:40 +0200 Subject: [PATCH 1/5] chore(tests/*): Move eslint configuration for tests into a separate file. --- tests/build.spec.js | 3 --- tests/cliAccessibility.js | 1 - tests/create-elm-app.spec.js | 1 - tests/elm-app.build.spec.js | 1 - tests/elm-app.eject.spec.js | 1 - tests/elm-app.test.spec.js | 1 - 6 files changed, 8 deletions(-) diff --git a/tests/build.spec.js b/tests/build.spec.js index d9cf99e0..22c85e2d 100644 --- a/tests/build.spec.js +++ b/tests/build.spec.js @@ -1,6 +1,3 @@ -/* eslint-disable */ -/* eslint-env mocha */ -const fs = require('fs'); const path = require('path'); const spawn = require('cross-spawn'); const rimraf = require('rimraf'); diff --git a/tests/cliAccessibility.js b/tests/cliAccessibility.js index b16a5c6a..c5f587fa 100644 --- a/tests/cliAccessibility.js +++ b/tests/cliAccessibility.js @@ -1,4 +1,3 @@ -/* eslint-env mocha */ const expect = require('unexpected'); const spawn = require('cross-spawn'); diff --git a/tests/create-elm-app.spec.js b/tests/create-elm-app.spec.js index 8339fa5c..87a34039 100644 --- a/tests/create-elm-app.spec.js +++ b/tests/create-elm-app.spec.js @@ -1,4 +1,3 @@ -/* eslint-env mocha */ const path = require('path'); const expect = require('unexpected'); const spawn = require('cross-spawn'); diff --git a/tests/elm-app.build.spec.js b/tests/elm-app.build.spec.js index 2ca72373..1931f1cd 100644 --- a/tests/elm-app.build.spec.js +++ b/tests/elm-app.build.spec.js @@ -1,4 +1,3 @@ -/* eslint-env mocha */ const fs = require('fs'); const path = require('path'); const spawn = require('cross-spawn'); diff --git a/tests/elm-app.eject.spec.js b/tests/elm-app.eject.spec.js index 496ca92a..ec4ec158 100644 --- a/tests/elm-app.eject.spec.js +++ b/tests/elm-app.eject.spec.js @@ -1,4 +1,3 @@ -/* eslint-env mocha */ const fs = require('fs'); const path = require('path'); const expect = require('unexpected'); diff --git a/tests/elm-app.test.spec.js b/tests/elm-app.test.spec.js index 29c61150..f203e544 100644 --- a/tests/elm-app.test.spec.js +++ b/tests/elm-app.test.spec.js @@ -1,4 +1,3 @@ -/* eslint-env mocha */ const path = require('path'); const spawn = require('cross-spawn'); const rimraf = require('rimraf'); From 8ddfd0da337b442f559a0905399b0bd70c5b0d60 Mon Sep 17 00:00:00 2001 From: Eduard Kyvenko Date: Wed, 29 Aug 2018 23:38:03 +0200 Subject: [PATCH 2/5] fix(webpack.config.dev.js): Use elm-hot-webpack-loader instead of deprecated elm-hot-loader. --- config/webpack.config.dev.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config/webpack.config.dev.js b/config/webpack.config.dev.js index f6e9be64..851503ed 100644 --- a/config/webpack.config.dev.js +++ b/config/webpack.config.dev.js @@ -112,7 +112,7 @@ module.exports = { exclude: [/elm-stuff/, /node_modules/], use: [ { - loader: require.resolve('elm-hot-loader') + loader: require.resolve('elm-hot-webpack-loader') }, // string-replace-loader works as InterpolateHtmlPlugin for Elm, // it replaces all of the %PUBLIC_URL% with the URL of your diff --git a/package.json b/package.json index 7776e35c..e97e1a41 100644 --- a/package.json +++ b/package.json @@ -33,7 +33,7 @@ "css-loader": "^0.28.9", "dotenv": "^5.0.0", "elm": "0.19.0-bugfix2", - "elm-hot-loader": "0.5.4", + "elm-hot-webpack-loader": "^1.0.0", "elm-test": "^0.19.0-beta4", "elm-webpack-loader": "^5.0.0", "extract-text-webpack-plugin": "^3.0.2", From 44d778217b29964a0c2503fcfa7abdcaf61906e1 Mon Sep 17 00:00:00 2001 From: Eduard Kyvenko Date: Wed, 29 Aug 2018 23:38:55 +0200 Subject: [PATCH 3/5] fix(template/*): Upgrade the code of the tempalte to 0.19 Use Browser instead of Html.App --- template/src/Main.elm | 7 ++++--- template/src/index.js | 6 ++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/template/src/Main.elm b/template/src/Main.elm index c23c23b8..c3ab4830 100644 --- a/template/src/Main.elm +++ b/template/src/Main.elm @@ -1,5 +1,6 @@ module Main exposing (..) +import Browser import Html exposing (Html, text, div, h1, img) import Html.Attributes exposing (src) @@ -45,11 +46,11 @@ view model = ---- PROGRAM ---- -main : Program Never Model Msg +main : Program () Model Msg main = - Html.program + Browser.element { view = view - , init = init + , init = \_ -> init , update = update , subscriptions = always Sub.none } diff --git a/template/src/index.js b/template/src/index.js index 3f79cf93..1942e644 100644 --- a/template/src/index.js +++ b/template/src/index.js @@ -1,7 +1,9 @@ import './main.css'; -import { Main } from './Main.elm'; +import { Elm } from './Main.elm'; import registerServiceWorker from './registerServiceWorker'; -Main.embed(document.getElementById('root')); +Elm.Main.init({ + node: document.getElementById('root') +}); registerServiceWorker(); From 4da4587c791f6c72147f526db326e13515cf016a Mon Sep 17 00:00:00 2001 From: Eduard Kyvenko Date: Wed, 29 Aug 2018 23:39:42 +0200 Subject: [PATCH 4/5] chore(package.json): Add scripts for running elm-app scripts in the template --- package.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index e97e1a41..87c3a64f 100644 --- a/package.json +++ b/package.json @@ -96,7 +96,8 @@ "test": "npm run test:cli && npm run test:functional", "test:cli": "mocha tests/cliAccessibility.js --reporter spec --timeout 15000", "test:functional": "mocha tests/*.spec.js --reporter spec --timeout 15000", - "build": "cd template && node ../bin/elm-app-cli.js build", - "start": "cd template && node ../bin/elm-app-cli.js start" + "app:build": "cd template && node ../bin/elm-app-cli.js build", + "app:start": "cd template && node ../bin/elm-app-cli.js start", + "app:test": "cd template && node ../bin/elm-app-cli.js test" } } From dd68f93efe711888921b0f9be905f4ae385668e1 Mon Sep 17 00:00:00 2001 From: Eduard Kyvenko Date: Wed, 29 Aug 2018 23:41:31 +0200 Subject: [PATCH 5/5] fix: Fix the create-elm-app test by disabling the output of the initial elm-make run --- scripts/create.js | 2 +- tests/create-elm-app.spec.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/create.js b/scripts/create.js index 47a23324..fa49e7ce 100644 --- a/scripts/create.js +++ b/scripts/create.js @@ -42,7 +42,7 @@ function createElmApp(name) { // Run initial `elm make` const spawnElmPkgResult = spawnSync( path.resolve(__dirname, '../node_modules/.bin/elm'), - ['make', 'src/Main.elm'], + ['make', 'src/Main.elm', '--output=/dev/null'], { stdio: 'inherit' } ); diff --git a/tests/create-elm-app.spec.js b/tests/create-elm-app.spec.js index 87a34039..96249eb4 100644 --- a/tests/create-elm-app.spec.js +++ b/tests/create-elm-app.spec.js @@ -35,7 +35,7 @@ describe('Create Elm application with `create-elm-app` command', () => { it(`'${testAppName}' should have the same file structure as template`, () => { const templateDir = path.join(rootDir, 'template'); const options = { - excludeFilter: 'elm-stuff, elm.json, gitignore, .gitignore' + excludeFilter: 'elm-stuff, elm.json, gitignore, .gitignore, build' }; const { same } = dircompare.compareSync(templateDir, testAppDir, options); expect(same, 'to be', true);