Skip to content

Commit

Permalink
chore: create @signalk/server-admin-ui package with repo
Browse files Browse the repository at this point in the history
Move admin-ui to /packages/admin-ui and use it from npm
as a separate module instead of building it as part of
the server module. This makes it easier for this github
repo to be used as a "monorepo" and when developing/running
the server off git you don't need to build it.

Since admin-ui is its own module it should have its own
ignore files. This removes old rules from the root and
adds them to packages/admin-ui directory.

Docker build still retains the app-build intermediate
container build, which should be removed separately.
  • Loading branch information
webmasterkai authored and tkurki committed Apr 28, 2018
1 parent f9dc758 commit 8569861
Show file tree
Hide file tree
Showing 104 changed files with 48 additions and 81 deletions.
1 change: 0 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
node_modules
admin-ui/node_modules
packages
work
3 changes: 0 additions & 3 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,6 @@ compilation-stats.json
public/*.hot-update.js
public/*.hot-update.json

admin-ui/*
!admin-ui/public/

plugin-config-data/

samples/*
Expand Down
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ RUN git clone https://github.com/canboat/canboat.git && cd canboat && make bin &
ENV PATH="/home/signalk/canboat/rel/linux-x86_64:${PATH}"

COPY . .
COPY --from=app-builder /app-build/admin-ui/public admin-ui/public

EXPOSE 3000
ENTRYPOINT bin/signalk-server
1 change: 0 additions & 1 deletion Dockerfile_arm32v7
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ RUN git clone https://github.com/canboat/canboat.git && cd canboat && make bin &
ENV PATH="/home/signalk/canboat/rel/linux-armv7l:${PATH}"

COPY . .
COPY --from=app-builder /app-build/admin-ui/public admin-ui/public

EXPOSE 3000
ENTRYPOINT bin/signalk-server
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,9 @@ To generate your own vessel settings file and configure your Pi to start the ser
```
git clone https://github.com/SignalK/signalk-server-node.git
cd signalk-server-node
npm install && npm run prepublishOnly
npm install
```

`prepublishOnly` builds the admin and plugin config web apps. This is a pretty heavy process and for example on RPi will take a huge amount of time, so you may want to build them separately on a more powerful computer and just transfer the resulting artifacts in `admin-ui/public/*` over.

Start the server with sample data:
* NMEA0183 sample data: `bin/nmea-from-file`
* NMEA2000 sample data: `bin/n2k-from-file-js`
Expand Down
20 changes: 15 additions & 5 deletions lib/config/get.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,20 @@
const path = require('path')
const { getInstalledPathSync } = require('get-installed-path')
const { flow, get, partialRight } = require('lodash/fp')

// #521 Returns path to load plugin-config assets.
const getPluginConfigPublic = () =>
path.join(getInstalledPathSync('@signalk/plugin-config'), 'public')
const appPath = path.normalize(__dirname + '/../../')
const addModules = partialRight(path.join, ['node_modules/'])
const appModules = addModules(appPath)

// Return the appPath from an app object.
const getAppPath = get('config.appPath')

// Build path to the public dir of a module. getInstalledPathSync(moduleName, { local: true })
const getModulePublic = moduleName =>
flow(getAppPath, addModules, partialRight(path.join, [moduleName, 'public']))

module.exports = {
getPluginConfigPublic
appModules,
appPath,
getAppPath,
getModulePublic
}
31 changes: 0 additions & 31 deletions lib/interfaces/admin-ui.js

This file was deleted.

17 changes: 5 additions & 12 deletions lib/interfaces/plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ var _ = require('lodash')
const modulesWithKeyword = require('../modules').modulesWithKeyword
const getLogger = require('../logging')
const _putPath = require('../put').putPath
const { getModulePublic } = require('../config/get')

// #521 Returns path to load plugin-config assets.
const getPluginConfigPublic = getModulePublic('@signalk/plugin-config')

module.exports = function (app) {
return {
Expand All @@ -30,18 +34,7 @@ module.exports = function (app) {

ensureExists(path.join(app.config.configPath, 'plugin-config-data'))

app.use(
'/plugins/configure',
express.static(
path.join(
app.config.appPath,
'node_modules',
'@signalk',
'plugin-config',
'public'
)
)
)
app.use('/plugins/configure', express.static(getPluginConfigPublic(app)))

router = express.Router()

Expand Down
5 changes: 4 additions & 1 deletion lib/serverroutes.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ module.exports = function(app, saveSecurityConfig, getSecurityConfig) {
var securityWasEnabled

app.get('/', (req, res) => {
res.redirect('admin')
res.redirect('@signalk/server-admin-ui')
})
app.get('/admin', (req, res) => {
res.redirect('/@signalk/server-admin-ui')
})

app.get('/apps', (req, res, next) => {
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
"start": "node bin/signalk-server",
"test": "mocha --exit",
"precommit": "lint-staged",
"format": "prettier-standard lib/**/*.js* providers/*.js* test/*.js* index.js",
"prepublishOnly": "cd admin-ui && npm install && npm run build",
"heroku-postbuild": "npm run prepublishOnly"
"format": "prettier-standard lib/**/*.js* providers/*.js* test/*.js* index.js"
},
"lint-staged": {
"linters": {
Expand Down Expand Up @@ -90,6 +88,7 @@
"@signalk/playground": "^1.0.0",
"@signalk/plugin-config": "^1.0.0",
"@signalk/sailgauge": "^1.1.0",
"@signalk/server-admin-ui": "^1.0.0",
"@signalk/set-system-time": "^1.2.0",
"@signalk/signalk-schema": "1.0.3",
"@signalk/signalk-to-nmea0183": "^1.0.0",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
41 changes: 21 additions & 20 deletions admin-ui/package.json → packages/server-admin-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@signalk/server-admin",
"version": "0.0.4",
"name": "@signalk/server-admin-ui",
"version": "1.0.0",
"description": "Signal K server admin webapp",
"author": "Łukasz Holeczek",
"contributors": [
Expand All @@ -12,49 +12,50 @@
}
],
"license": "MIT",
"keywords": ["signalk-webapp"],
"keywords": [
"signalk-webapp"
],
"devDependencies": {
"babel-core": "6.26.0",
"babel-loader": "7.1.2",
"babel-plugin-transform-object-rest-spread": "6.26.0",
"babel-preset-env": "1.6.1",
"babel-preset-react": "6.24.1",
"bootstrap": "4.0.0-beta.2",
"chart.js": "2.7.1",
"copy-webpack-plugin": "4.2.1",
"css-hot-loader": "1.3.3",
"css-loader": "0.28.7",
"extract-text-webpack-plugin": "3.0.2",
"file-loader": "1.1.5",
"font-awesome": "4.7.0",
"history": "4.7.2",
"html-loader": "0.5.1",
"html-webpack-plugin": "2.30.1",
"node-sass": "4.7.1",
"react": "16.1.1",
"react-chartjs-2": "2.6.4",
"react-dom": "16.1.1",
"react-redux": "^5.0.6",
"react-router-dom": "4.2.2",
"react-transition-group": "2.2.1",
"reactstrap": "5.0.0-alpha.4",
"redux": "^3.7.2",
"redux-thunk": "^2.2.0",
"rimraf": "2.6.2",
"sass-loader": "6.0.6",
"simple-line-icons": "2.4.1",
"source-list-map": "2.0.0",
"style-loader": "0.19.0",
"uglify-js": "3.1.10",
"url-loader": "0.6.2",
"webpack": "3.8.1",
"webpack-dev-server": "2.9.4",
"bootstrap": "4.0.0-beta.2",
"chart.js": "2.7.1",
"font-awesome": "4.7.0",
"history": "4.7.2",
"react": "16.1.1",
"react-chartjs-2": "2.6.4",
"react-dom": "16.1.1",
"react-router-dom": "4.2.2",
"react-transition-group": "2.2.1",
"reactstrap": "5.0.0-alpha.4",
"redux-thunk": "^2.2.0",
"simple-line-icons": "2.4.1"
"webpack": "^3.8.1",
"webpack-dev-server": "2.9.4"
},
"dependencies": {},
"scripts": {
"prepublish": "npm run clean && npm run build",
"dev":
"webpack -d --progress --watch --profile --json > compilation-stats.json --env.dev",
"prepublishOnly": "npm run clean && npm run build",
"dev": "webpack -d --progress --watch --profile --json > compilation-stats.json --env.dev",
"start": "webpack-dev-server --progress --colors --inline --env.dev",
"build": "webpack -p --progress --env.prod",
"clean": "rimraf ./build"
Expand Down
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.
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.
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.
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.
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.
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.
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.
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.
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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 8569861

Please sign in to comment.