Permalink
Browse files

refactor package depdencies into a top-level package.json that is hea…

…dless

Fixes #1047
  • Loading branch information...
starpit committed Jul 6, 2018
1 parent 3c2d3b1 commit 1bb5f85c28e71a050de43cc12f58ce32deaea58a
Showing with 898 additions and 30 deletions.
  1. +1 −0 .gitignore
  2. +1 −1 .travis.yml
  3. +2 −6 app/bin/fsh
  4. +36 −0 app/bin/seticon.js
  5. +1 −1 app/headless.js
  6. +7 −2 app/main.js
  7. +2 −15 app/package.json
  8. +12 −0 app/plugins/ui/commands/text-search.js
  9. +8 −4 dist/build.sh
  10. +4 −0 fsh.js
  11. +779 −0 package-lock.json
  12. +44 −0 package.json
  13. +1 −1 tests/tests/passes/02/headless.js
View
@@ -3,6 +3,7 @@
dist/build
dist/plugins
*.log
*.bak
node_modules
wskng.iml
app/.version
View
@@ -39,7 +39,7 @@ env:
install:
- echo "APIHOST=foo" > ~/.wskprops # dist/compile.sh needs something here
- echo "AUTH=bar" >> ~/.wskprops # ibid (see the call to initOW in openwhisk-core.js)
- (cd app && npm install && cd ../tests && npm install && npm run _instrument) & # app and tests npm install
- (npm install && npm run install-ui && cd tests && npm install && npm run _instrument) & # app and tests npm install
- (./tools/travis/setup.sh; ./tools/travis/build.sh; ./tools/travis/init_auth.sh) & # initialize openwhisk and test docker
- wait # wait for the above &'d background processes
- Xvfb $DISPLAY -screen 0 ${WINDOW_WIDTH}x${WINDOW_HEIGHT}x24 -ac & # start virtual framebuffer process
View
@@ -20,10 +20,6 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ROOTDIR="$DIR/.."
# indicate that we're in dev mode; this is used e.g. in headless.js to
# determine which argv to ignore
export DEVMODE=true
export FSH_HEADLESS=true
#exec "$ROOTDIR/node_modules/.bin/electron" "$ROOTDIR" --fsh-headless "$@"
exec node "$ROOTDIR/main.js" --fsh-headless "$@"
exec node "$ROOTDIR/main.js" "$@"
View
@@ -0,0 +1,36 @@
#!/usr/bin/env node
/*
* Copyright 2018 IBM Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const { join } = require('path')
const { exec } = require('child_process')
if (process.platform === 'darwin') {
console.log('commencing seticon')
exec(join(__dirname, 'seticon.sh'), { stdio: 'inherit' }, (err, stdout, stderr) => {
if (err) {
console.error(stderr)
process.exit(err.code)
} else {
console.log(stdout)
console.log('done')
}
})
} else {
console.log('skipping seticon')
}
View
@@ -94,7 +94,7 @@ function mimicDom(app, { createWindow }, localStorage) {
classList: {
add: _ => obj._classList.push(_),
remove: _ => {
const idx = obj._classList.findIndex(_)
const idx = obj._classList.findIndex(x => x === _)
if (idx >= 0) {
obj._classList.splice(idx, 1)
}
View
@@ -64,8 +64,12 @@ function initGraphics(command=[], subwindowPlease, subwindowPrefs) {
// is not enabled this allows you (as a developer) to
// debug issues with spawning the subprocess by passing
// DEBUG=* or DEBUG=main
const env = Object.assign({},
process.env,
windowOptions)
delete env.FSH_HEADLESS
const child = spawn(electron, args, { stdio: debug.enabled ? 'inherit' : 'ignore',
env: Object.assign({}, process.env, windowOptions)})
env })
if (!debug.enabled) {
// as with the "ignore stdio" comment immediately
@@ -192,7 +196,7 @@ let mainWindow
*
*/
const fshShell = process.argv.find(arg => arg === 'shell')
const isRunningHeadless = process.argv.find(arg => arg === '--fsh-headless') && !fshShell
const isRunningHeadless = process.env.FSH_HEADLESS && !fshShell
if (!isRunningHeadless) {
// then spawn the electron graphics
const dashDash = process.argv.indexOf('--')
@@ -202,6 +206,7 @@ if (!isRunningHeadless) {
} else {
// otherwise, don't spawn the graphics; stay in headless mode
process.argv.splice(0, 1)
initHeadless()
}
View
@@ -6,9 +6,8 @@
"main": "main.js",
"scripts": {
"start": "electron .",
"postinstall": "cd plugins && npm install && cd .. && npm run build && npm run compile && ./bin/seticon.sh",
"build": "node ./bin/build.js",
"install-ui": "npm install electron electron-squirrel-startup && (cd plugins && npm install)",
"install-ui": "npm install && (cd plugins && npm install)",
"compile": "if [ -d ../dist ]; then cd ../dist && ./compile.js; fi",
"test": "cd ../tests && npm run test"
},
@@ -33,21 +32,9 @@
},
"dependencies": {
"about-window": "^1.11.0",
"adm-zip": "^0.4.11",
"app-module-path": "^2.2.0",
"colors": "^1.3.0",
"columnify": "^1.5.4",
"debug": "^3.1.0",
"electron-editor-context-menu": "^1.1.1",
"electron-squirrel-startup": "^1.0.0",
"es6-promise-pool": "^2.5.0",
"expand-home-dir": "0.0.3",
"inquirer": "^3.3.0",
"js-beautify": "1.7.5",
"jsome": "^2.5.0",
"opn": "^5.3.0",
"pretty-ms": "^3.2.0",
"yargs-parser": "^9.0.2"
"electron-squirrel-startup": "^1.0.0"
},
"optionalDependencies": {
"fileicon": "^0.2.2"
@@ -21,6 +21,18 @@ const path = require('path')
*
*/
module.exports = () => {
try {
registerListener();
} catch (err) {
console.error('Not running in electron environment')
}
}
/**
* Listen for control/command+F
*
*/
function registerListener() {
const app = require('electron');
if (typeof document === 'undefined') return // return if no document
View
@@ -21,6 +21,11 @@
#
PLATFORM=${1-all}
cp ../app/package.json ../app/package.json.bak
node -e 'deps=require("../package.json").dependencies; pj=require("../app/package.json"); Object.assign(pj.dependencies, deps); require("fs").writeFileSync("../app/package.json", JSON.stringify(pj, undefined, 4))'
(cd ../app && npm install)
cp ../app/package.json.bak ../app/package.json
# product name
export PRODUCT_NAME="${PRODUCT_NAME-`cat ../app/build/config.json | jq --raw-output .productName`}"
@@ -93,8 +98,7 @@ function win32 {
--win32metadata.ProductName="${PRODUCT_NAME}"
# CLI scripts
cp ../app/bin/fsh "$BUILDDIR/${PRODUCT_NAME}-win32-x64/fsh"
cp ../app/bin/fsh.bat "$BUILDDIR/${PRODUCT_NAME}-win32-x64"
cp ../fsh.js "$BUILDDIR/${PRODUCT_NAME}-win32-x64/fsh"
#
# deal with win32 packaging
@@ -131,7 +135,7 @@ function mac {
cp $ICON_MAC "$BUILDDIR/${PRODUCT_NAME}-darwin-x64/${PRODUCT_NAME}.app/Contents/Resources/electron.icns"
# CLI script
cp ../app/bin/fsh "$BUILDDIR/${PRODUCT_NAME}-darwin-x64/${PRODUCT_NAME}.app/Contents/MacOS/"
cp ../fsh.js "$BUILDDIR/${PRODUCT_NAME}-darwin-x64/${PRODUCT_NAME}.app/Contents/MacOS/fsh"
# create the installers
if [ -n "$ZIP_INSTALLER" ]; then
@@ -167,7 +171,7 @@ function linux {
--overwrite
# CLI script
cp ./bin/fsh "$BUILDDIR/${PRODUCT_NAME}-linux-x64"
cp ../fsh.js "$BUILDDIR/${PRODUCT_NAME}-linux-x64/fsh"
if [ -z "$NO_INSTALLER" ]; then
(cd $BUILDDIR && zip -q -r "${PRODUCT_NAME}-linux-x64" "${PRODUCT_NAME}-linux-x64" -x \*~)
View
4 fsh.js
@@ -0,0 +1,4 @@
#!/usr/bin/env node
process.env.FSH_HEADLESS = true
require('./app/main')
Oops, something went wrong.

0 comments on commit 1bb5f85

Please sign in to comment.