-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds common-js dist binary webpack build
adds mirador3-e2e-tests package
- Loading branch information
1 parent
9add11e
commit 6d870fd
Showing
26 changed files
with
417 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
build/ | ||
config/ | ||
dist/ | ||
scripts/ | ||
coverage/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
process.env.BABEL_ENV = 'production'; | ||
process.env.NODE_ENV = 'production'; | ||
|
||
require('./env'); | ||
const paths = require('./paths'); | ||
|
||
module.exports = { | ||
mode: 'production', | ||
entry: [paths.appDistIndexJs], | ||
output: { | ||
path: paths.appDist, | ||
filename: 'mirador.bundle.js', | ||
libraryTarget: 'umd', | ||
library: 'Mirador', | ||
libraryExport: 'default', | ||
}, | ||
resolve: { extensions: ['.js'] }, | ||
module: { | ||
rules: [ | ||
{ | ||
oneOf: [ | ||
{ | ||
test: /\.js?$/, | ||
exclude: /(node_modules)/, | ||
loader: 'babel-loader', | ||
}, | ||
{ | ||
test: /\.scss$/, | ||
use: [ | ||
'style-loader', // creates style nodes from JS strings | ||
'css-loader', // translates CSS into CommonJS | ||
'sass-loader', // compiles Sass to CSS, using Node Sass by default | ||
], | ||
}, | ||
{ | ||
loader: require.resolve('file-loader'), | ||
// Exclude `js` files to keep "css" loader working as it injects | ||
// it's runtime that would otherwise be processed through "file" loader. | ||
// Also exclude `html` and `json` extensions so they get processed | ||
// by webpacks internal loaders. | ||
exclude: [/\.(js|mjs|jsx|ts|tsx)$/, /\.html$/, /\.json$/], | ||
options: { | ||
name: 'static/media/[name].[hash:8].[ext]', | ||
}, | ||
}, | ||
], | ||
}, | ||
], | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom'; | ||
import { Provider } from 'react-redux'; | ||
import { store } from 'mirador3-core'; | ||
import App from './components/App'; | ||
import './styles/index.scss'; | ||
|
||
/** | ||
* Default Mirador distribution instantiation | ||
*/ | ||
export default function Mirador(config) { | ||
ReactDOM.render( | ||
<Provider store={store}> | ||
<App config={config} /> | ||
</Provider>, | ||
document.getElementById(config.id), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
lib/ | ||
config/ | ||
coverage/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
dist/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"env": { | ||
"jest/globals": true | ||
}, | ||
"extends": "airbnb", | ||
"globals": { | ||
"page": true, | ||
"document": true | ||
}, | ||
"plugins": ["jest"], | ||
"rules": { | ||
"no-console": "off", | ||
"global-require": "off", | ||
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }], | ||
"require-jsdoc": 0, | ||
"react/prefer-stateless-function": "off" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Mirador3 E2E Tests | ||
|
||
### `npm run cypress:open` | ||
starts server and runs cypress | ||
|
||
### Notes: | ||
webpack is not used here yet, though a configuration is included. | ||
|
||
Currently, `dist` contains the common-js pre-built binary produced by `mirador3-app` with the `npm run dist` command. | ||
|
||
The server uses the index template from views that loads the binary from dist and loads default Mirador export. | ||
|
||
Optimally, `apps` will contain different source Apps that will be built with webpack from ES6 imports | ||
using a published mirador3-app artifact. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[ | ||
"mirador" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"baseUrl": "http://localhost:4000", | ||
"reporter": "junit", | ||
"reporterOptions": { | ||
"mochaFile": "e2e-results.xml", | ||
"toConsole": true | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"name": "Using fixtures to represent data", | ||
"email": "[email protected]", | ||
"body": "Fixtures are a great way to mock data for responses to routes" | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/mirador3-e2e-tests/cypress/integration/mirador-base.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* global cy */ | ||
describe('Mirador Base', () => { | ||
it('Visits Mirador Base', () => { | ||
cy.visit('http://localhost:4000/mirador'); | ||
cy.get('title').contains('Mirador'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// *********************************************************** | ||
// This example plugins/index.js can be used to load plugins | ||
// | ||
// You can change the location of this file or turn off loading | ||
// the plugins file with the 'pluginsFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/plugins-guide | ||
// *********************************************************** | ||
|
||
// This function is called when a project is opened or re-opened (e.g. due to | ||
// the project's config changing) | ||
|
||
module.exports = (on, config) => { | ||
// `on` is used to hook into various events Cypress emits | ||
// `config` is the resolved Cypress config | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// *********************************************** | ||
// This example commands.js shows you how to | ||
// create various custom commands and overwrite | ||
// existing commands. | ||
// | ||
// For more comprehensive examples of custom | ||
// commands please read more here: | ||
// https://on.cypress.io/custom-commands | ||
// *********************************************** | ||
// | ||
// | ||
// -- This is a parent command -- | ||
// Cypress.Commands.add("login", (email, password) => { ... }) | ||
// | ||
// | ||
// -- This is a child command -- | ||
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is a dual command -- | ||
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... }) | ||
// | ||
// | ||
// -- This is will overwrite an existing command -- | ||
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// *********************************************************** | ||
// This example support/index.js is processed and | ||
// loaded automatically before your test files. | ||
// | ||
// This is a great place to put global configuration and | ||
// behavior that modifies Cypress. | ||
// | ||
// You can change the location of this file or turn off | ||
// automatically serving support files with the | ||
// 'supportFile' configuration option. | ||
// | ||
// You can read more here: | ||
// https://on.cypress.io/configuration | ||
// *********************************************************** | ||
|
||
// Import commands.js using ES2015 syntax: | ||
import './commands' | ||
|
||
// Alternatively you can use CommonJS syntax: | ||
// require('./commands') |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "mirador3-e2e-tests", | ||
"version": "0.1.0", | ||
"private": true, | ||
"scripts": { | ||
"start": "node src/start.js", | ||
"test:ci": "npm run start:prod & cypress run cypress.json && kill $!", | ||
"cypress:open": "npm run start & cypress open && kill $!" | ||
}, | ||
"dependencies": { | ||
"ejs": "^2.6.1", | ||
"express": "^4.16.4", | ||
"file-loader": "2.0.0", | ||
"serve-favicon": "^2.5.0", | ||
"webpack": "^4.26.1", | ||
"html-webpack-plugin": "^3.2.0", | ||
"webpack-dev-middleware": "^3.4.0", | ||
"webpack-hot-middleware": "^2.24.3" | ||
}, | ||
"devDependencies": { | ||
"cypress": "^3.1.2" | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
const path = require('path'); | ||
const express = require('express'); | ||
const favicon = require('serve-favicon'); | ||
const apps = require('../apps'); | ||
|
||
module.exports = { | ||
start: (port) => { | ||
const app = express(); | ||
app.set('view engine', 'ejs'); | ||
app.set('views', __dirname + '/views'); | ||
app.use(favicon(__dirname + '/favicon.ico')); | ||
app.get('/', (req, res) => { | ||
res.render('index', { | ||
apps, | ||
}); | ||
}); | ||
app.use('/static', express.static(path.join(__dirname, '../dist'))); | ||
|
||
app.get('/:bundle', (req, res) => { | ||
const bundle = req.params.bundle; | ||
res.render('app-template', { | ||
bundle, | ||
}); | ||
}); | ||
|
||
app.listen(port, () => { | ||
console.log(`server running at localhost:${port}, go refresh and see magic`); | ||
}); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
const server = require('./server'); | ||
|
||
server.start(Number(process.env.PORT || 4000)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<html> | ||
|
||
<head> | ||
<title>Mirador</title> | ||
<!-- <link href="/static/styles.css" rel="stylesheet" /> --> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
</head> | ||
|
||
<body> | ||
<div id='mirador'> | ||
</div> | ||
<script src="/static/<%=bundle%>.bundle.js"></script> | ||
<script type="text/javascript"> | ||
Mirador({ | ||
id: 'mirador', | ||
plugins: ['HelloWorld'] | ||
}); | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<html> | ||
|
||
<head> | ||
<title>Sample Apps</title> | ||
<!-- <link href="/static/styles.css" rel="stylesheet" /> --> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"> | ||
</head> | ||
|
||
<body> | ||
<h2>Apps</h2> | ||
<ul> | ||
<% for(var i=0; i<apps.length; i++) {%> | ||
<li><a href="/<%=apps[i]%>"><%=apps[i]%></a></li> | ||
<% } %> | ||
</ul> | ||
</body> | ||
|
||
</html> |
Oops, something went wrong.