Skip to content

Commit 60af43a

Browse files
committed
Restructure repository
1 parent 8985e84 commit 60af43a

22 files changed

+28
-27
lines changed

.eslintignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
node_modules/*
22
coverage/*
3-
lib/*
3+
dist/*
44
build/*
55
.vscode/*

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ npm-debug.log*
77
node_modules
88

99
# Production output
10-
lib
10+
dist
1111
build
1212

1313
# Codecov

.npmignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
src
1+
demo
2+
lib
23
coverage
34
test
45
.circleci

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The following style-related props have been removed and replaced:
3232
+ inputStyle
3333
```
3434

35-
Instead of having a unique prop for styling only some parts of the terminal elements, every style aspect is now overridable. Any styles defines in [src/defs/styles/Terminal.js](src/defs/styles/Terminal.js) can be overridden via the new props. See [the guide](docs/CONFIG.md#re-styling) for more details.
35+
Instead of having a unique prop for styling only some parts of the terminal elements, every style aspect is now overridable. Any styles defines in [lib/defs/styles/Terminal.js](lib/defs/styles/Terminal.js) can be overridden via the new props. See [the guide](docs/CONFIG.md#re-styling) for more details.
3636

3737
### Other changes
3838

src/App.jsx demo/App.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// react-console-emulator example app
22
import React from 'react'
33

4-
import Terminal from './components/Terminal' // In your app, import from 'react-console-emulator'
4+
import Terminal from '../lib/Terminal' // In your app, import from 'react-console-emulator'
55
import './demo.scss' // Demo only
66

77
// Demo only

src/demo.scss demo/demo.scss

File renamed without changes.

src/index.html demo/index.html

File renamed without changes.

src/index.jsx demo/index.jsx

File renamed without changes.

docs/API.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,15 @@ The only notable caveat of this method is the breaking of component encapsulatio
7676

7777
Per standard, the terminal operates in the following way when a command is entered. You can hook into these processes when the terminal is exposed via the refs API.
7878

79-
- A key event triggers the [handleInput](src/components/Terminal.jsx#L242) function.
80-
- The [handleInput](src/components/Terminal.jsx#L242) function behaves as follows:
81-
- If the either up or down arrow was pressed, [scrollHistory](src/components/Terminal.jsx#L200) is called with either `up` or `down` as a parameter, corresponding to the arrow key that was pressed.
82-
- If the Enter key was pressed, [processCommand](src/components/Terminal.jsx#L163) is called.
83-
- Following the Enter path, if automatic output isn't disabled via the `noAutomaticStdout` prop, [pushToStdout](src/components/Terminal.jsx#L128) is called for the first time. This echoes the command that was entered into the terminal verbatim to mimic a UNIX terminal.
79+
- A key event triggers the [handleInput](../lib/Terminal.jsx#L164) function.
80+
- The [handleInput](../lib/Terminal.jsx#L164) function behaves as follows:
81+
- If the either up or down arrow was pressed, [scrollHistory](../lib/Terminal.jsx#L151) is called with either `up` or `down` as a parameter, corresponding to the arrow key that was pressed.
82+
- If the Enter key was pressed, [processCommand](../lib/Terminal.jsx#111) is called.
83+
- Following the Enter path, if automatic output isn't disabled via the `noAutomaticStdout` prop, [pushToStdout](../lib/Terminal.jsx#L85) is called for the first time. This echoes the command that was entered into the terminal verbatim to mimic a UNIX terminal.
8484
- If history isn't disabled via the `noHistory` prop, the entered command is also stored in the history at this stage.
8585
- If the input isn't empty, command processing begins.
8686
- If the command doesn't exist, an error message is pushed to the output. If a custom error text is set via the `errorText` prop, it takes precedence over the default one.
8787
- If the command exists, the command function is executed and the return value of that function is pushed to the terminal (Without storing the return value in history). If the `explicitExec` property on the command object is truthy, the function will explicitly execute a second time after the output being sent.
88-
- The [clearInput](src/components/Terminal.jsx#L158) function is called.
88+
- The [clearInput](../lib/Terminal.jsx#L106) function is called.
8989
- If automatic scrolling isn't disabled via the `noAutoScroll` prop, the terminal will scroll to the bottom of the output.
9090
- If a command callback function is defined via the `commandCallback` prop, it is called at this stage.

jest.coverage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ module.exports = {
33
preset: 'jest-puppeteer',
44
setupFilesAfterEnv: ['<rootDir>/test/setupTests.js'],
55
collectCoverage: true,
6-
collectCoverageFrom: ['<rootDir>/src/components/Terminal.jsx'],
6+
collectCoverageFrom: ['<rootDir>/lib/Terminal.jsx'],
77
coverageDirectory: './coverage/'
88
}

src/components/Terminal.jsx lib/Terminal.jsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import isEqual from 'react-fast-compare'
66
import TerminalMessage from './TerminalMessage'
77

88
// Handlers
9-
import validateCommands from '../handlers/validateCommands'
10-
import scrollHistory from '../handlers/scrollHistory'
9+
import validateCommands from './handlers/validateCommands'
10+
import scrollHistory from './handlers/scrollHistory'
1111

1212
// Definitions
13-
import sourceStyles from '../defs/styles/Terminal'
14-
import types from '../defs/types/Terminal'
13+
import sourceStyles from './defs/styles/Terminal'
14+
import types from './defs/types/Terminal'
1515

1616
export default class Terminal extends Component {
1717
constructor (props) {

src/components/TerminalMessage.jsx lib/TerminalMessage.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React, { Component } from 'react'
22
import html from 'react-inner-html'
33

4-
import types from '../defs/types/TerminalMessage'
5-
import sourceStyles from '../defs/styles/TerminalMessage'
4+
import types from './defs/types/TerminalMessage'
5+
import sourceStyles from './defs/styles/TerminalMessage'
66

77
export default class TerminalMessage extends Component {
88
static propTypes = types
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22
"name": "react-console-emulator",
33
"version": "3.0.3",
44
"description": "A simple terminal emulator component for React. ",
5-
"main": "lib/components/Terminal.js",
5+
"main": "dist/Terminal.js",
66
"files": [
7-
"lib/**"
7+
"dist/**"
88
],
99
"scripts": {
1010
"start": "cross-env NODE_ENV=development webpack-dev-server",
1111
"build": "cross-env NODE_ENV=production webpack -p",
12-
"compile": "babel src --ignore \"src/**/*.scss\",\"src/**/*.html\",\"src/App.jsx\",\"src/index.jsx\" --out-dir lib",
12+
"compile": "babel lib --out-dir dist",
1313
"lint": "eslint .",
1414
"lint-fix": "eslint . --fix",
1515
"codecov": "codecov --disable=gcov",

test/Terminal.test.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ import React from 'react'
44
import { shallow, mount, render } from 'enzyme'
55
import skipIf from 'skip-if'
66

7-
import * as src from '../src/components/Terminal'
8-
import * as prod from '../lib/components/Terminal'
7+
import * as src from '../lib/Terminal'
8+
import * as prod from '../dist/Terminal'
99

1010
let Terminal
1111

1212
if (process.env.PROD_RUN) {
13-
console.log('Performing production run, testing version from "lib".')
13+
console.log('Performing production run, testing version from "dist".')
1414
Terminal = prod.default
1515
} else {
16-
console.log('Performing development run, testing version from "src".')
16+
console.log('Performing development run, testing version from "lib".')
1717
Terminal = src.default
1818
}
1919

webpack.config.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const OptimizeJSWebpackPlugin = require('terser-webpack-plugin')
88
const dev = process.env.NODE_ENV !== 'production' || process.argv.indexOf('-p') === -1
99

1010
const HTMLInjecterConfig = new HTMLWebpackPlugin({
11-
template: path.join(__dirname, '/src/index.html'),
11+
template: path.join(__dirname, '/demo/index.html'),
1212
filename: 'index.html',
1313
inject: 'body'
1414
})
@@ -52,7 +52,7 @@ module.exports = {
5252
// Entry point
5353
entry: [
5454
'react-hot-loader/patch',
55-
path.join(__dirname, '/src/index.jsx')
55+
path.join(__dirname, '/demo/index.jsx')
5656
],
5757

5858
// Dummies for native Node modules not present in browser scope

0 commit comments

Comments
 (0)