Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion bin/elm-app-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ switch (script) {

break;
}
case 'install': {
const executable = executablePaths['elm-package'];
spawn.sync(path.normalize(executable), process.argv.slice(2), {
stdio: 'inherit'
});
break;
}
default:
// Proxy elm-platform cli commands.
if (['package', 'reactor', 'make', 'repl'].indexOf(script) !== -1) {
Expand All @@ -74,7 +81,9 @@ switch (script) {
function help(version) {
console.log('\nUsage: elm-app <command>\n');
console.log('where <command> is one of:');
console.log(' create, build, start, package, reactor, make, repl\n');
console.log(
' create, build, start, install, package, reactor, make, repl\n'
);
console.log('\nElm ' + elmPlatformVersion + '\n');
console.log(
'create-elm-app@' + version + ' ' + path.resolve(__dirname, '..')
Expand Down
14 changes: 8 additions & 6 deletions scripts/utils/webpackHotDevClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ var connection = new SockJS(
hostname: window.location.hostname,
port: window.location.port,
// Hardcoded in WebpackDevServer
pathname: '/sockjs-node',
pathname: '/sockjs-node'
})
);

Expand Down Expand Up @@ -218,7 +218,7 @@ function handleWarnings(warnings) {
// Print warnings to the console.
var formatted = formatWebpackMessages({
warnings: warnings,
errors: [],
errors: []
});

if (typeof console !== 'undefined' && typeof console.warn === 'function') {
Expand Down Expand Up @@ -259,10 +259,12 @@ function handleErrors(errors) {
hasCompileErrors = true;

// "Massage" webpack messages.
var formatted = highlightElmCompilerErrors(formatWebpackMessages({
errors: errors,
warnings: [],
}));
var formatted = highlightElmCompilerErrors(
formatWebpackMessages({
errors: errors,
warnings: []
})
);

// Only show the first error.
showErrorOverlay(formatted.errors[0]);
Expand Down
15 changes: 14 additions & 1 deletion template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ You can find the most recent version of this guide [here](https://github.com/hal
- [Available scripts](#available-scripts)
- [elm-app build](#elm-app-build)
- [elm-app start](#elm-app-start)
- [elm-app install](#elm-app-install)
- [elm-app test](#elm-app-test)
- [elm-app eject](#elm-app-eject)
- [elm-app <elm-platform-comand>](#elm-app-elm-platform-comand)
Expand Down Expand Up @@ -41,9 +42,11 @@ You are very welcome with any [feedback](https://github.com/halfzebra/create-elm
## Installing Elm packages

```sh
elm-app package install <package-name>
elm-app install <package-name>
```

Other `elm-package` commands are also [available.](#package)

## Installing JavaScript packages

To use JavaScript packages from npm, you'll need to add a `package.json`, install the dependencies, and you're ready to go.
Expand Down Expand Up @@ -102,6 +105,10 @@ Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.
You will also see any lint errors in the console.

### `elm-app install`

An alias for [`elm-app package install`](#package)

### `elm-app test`
Run tests with [node-test-runner](https://github.com/rtfeldman/node-test-runner/tree/master)

Expand All @@ -111,6 +118,7 @@ elm-app test --watch
```

### `elm-app eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time.
Expand All @@ -120,20 +128,25 @@ Instead, it will copy all the configuration files and the transitive dependencie
You don’t have to use 'eject' The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However, we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

### `elm-app <elm-platform-comand>`

Create Elm App does not rely on the global installation of Elm Platform, but you still can use it's local Elm Platform to access default command line tools:

#### `package`

Alias for [elm-package](http://guide.elm-lang.org/get_started.html#elm-package)

Use it for installing Elm packages from [package.elm-lang.org](http://package.elm-lang.org/)

#### `repl`

Alias for [elm-repl](http://guide.elm-lang.org/get_started.html#elm-repl)

#### `make`

Alias for [elm-make](http://guide.elm-lang.org/get_started.html#elm-make)

#### `reactor`

Alias for [elm-reactor](http://guide.elm-lang.org/get_started.html#elm-reactor)


Expand Down
25 changes: 11 additions & 14 deletions tests/elm-app.build.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,24 +40,21 @@ describe('Building Elm application with `elm-app build`', function() {
expect(fs.existsSync(path.join(testAppDir, 'build'))).to.be.equal(true);
}).timeout(12 * 60 * 1000);

it(
'`elm-app build` should exit with non zero status code when build failed',
function() {
const normalFile = path.join(testAppDir, 'src/Main.elm');
const malformedFile = path.join(rootDir, './tests/fixtures/Main.elm');
it('`elm-app build` should exit with non zero status code when build failed', function() {
const normalFile = path.join(testAppDir, 'src/Main.elm');
const malformedFile = path.join(rootDir, './tests/fixtures/Main.elm');

copyFileSync(normalFile, 'Main.elm-normal');
copyFileSync(malformedFile, normalFile);
copyFileSync(normalFile, 'Main.elm-normal');
copyFileSync(malformedFile, normalFile);

const result = spawn.sync('node', [elmAppCmd, 'build']);
const result = spawn.sync('node', [elmAppCmd, 'build']);

const oldNormalFile = path.resolve('Main.elm-normal');
copyFileSync(oldNormalFile, normalFile);
fs.unlink(oldNormalFile);
const oldNormalFile = path.resolve('Main.elm-normal');
copyFileSync(oldNormalFile, normalFile);
fs.unlink(oldNormalFile);

expect(result.status).to.be.at.least(1);
}
).timeout(2 * 60 * 1000);
expect(result.status).to.be.at.least(1);
}).timeout(2 * 60 * 1000);
});

function copyFileSync(from, to) {
Expand Down
23 changes: 10 additions & 13 deletions tests/elm-app.eject.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,15 @@ describe('Ejecting Elm application. (Please wait...)', () => {
expect(same).to.be.equal(true);
});

it(
'It should be possible to build ejected applitaction, using npm scripts',
() => {
const result = spawn.sync('npm', ['run', 'build']);
const outputString = result.output
.map(function(out) {
return out !== null ? out.toString() : '';
})
.join('');
it('It should be possible to build ejected applitaction, using npm scripts', () => {
const result = spawn.sync('npm', ['run', 'build']);
const outputString = result.output
.map(function(out) {
return out !== null ? out.toString() : '';
})
.join('');

expect(result.status).to.be.equal(0);
expect(outputString).to.have.string('Compiled successfully');
}
).timeout(5 * 60 * 1000);
expect(result.status).to.be.equal(0);
expect(outputString).to.have.string('Compiled successfully');
}).timeout(5 * 60 * 1000);
});