forked from ibm-functions/shell
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
202 changed files
with
17,952 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
*~ | ||
dist/build | ||
dist/plugins | ||
*.log | ||
node_modules | ||
wskng.iml | ||
app/.version | ||
app/content/**/*.js.map | ||
app/plugins/.pre-scanned |
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,62 @@ | ||
language: node_js | ||
dist: trusty | ||
sudo: false | ||
node_js: 6 | ||
services: | ||
- docker | ||
addons: | ||
apt: | ||
sources: | ||
- google-chrome | ||
packages: | ||
- dbus | ||
- dbus-x11 | ||
- xvfb | ||
- google-chrome-stable | ||
- libnotify-cil-dev | ||
|
||
install: | ||
- Xvfb :99 -screen 0 1400x1050x24 > /dev/null 2>&1 & | ||
|
||
env: | ||
global: | ||
- DISPLAY=":99.0" | ||
- KEY_FROM_LAYER=true | ||
- DO_NOT_SET_WSKPROPS=true | ||
- WINDOW_WIDTH=1400 | ||
- WINDOW_HEIGHT=1050 | ||
- NO_DEBUGGER_BREAKPOINTS=true | ||
- NO_NOTIFICATIONS=true | ||
- NO_FIRST_TIMER=true | ||
- UV_THREADPOOL_SIZE=64 | ||
|
||
script: echo "Running Tests!" | ||
|
||
jobs: | ||
include: | ||
- stage: init | ||
script: (./tools/travis/setup.sh;./tools/travis/build.sh) | ||
- script: (cd app && npm install) | ||
- script: (cd tests && npm install) | ||
- script: (cd dist && npm install) | ||
|
||
- stage: compile | ||
script: (cd dist && ./compile.js) | ||
|
||
- stage: test | ||
script: (cd tests && npm run test) | ||
env: LAYER=01 | ||
- script: (cd tests && npm run test) | ||
env: LAYER=02 | ||
- script: (cd tests && npm run test) | ||
env: LAYER=03 | ||
- script: (cd tests && npm run test) | ||
env: LAYER=04 | ||
- script: (cd tests && npm run test) | ||
env: LAYER=05 | ||
- script: (cd tests && npm run test) | ||
env: LAYER=06 | ||
- script: (cd tests && npm run test) | ||
env: LAYER=07 | ||
- script: (cd tests && npm run test) | ||
env: LAYER=08 |
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 @@ | ||
Icons for MacOS |
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 @@ | ||
Icons for Windows |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,155 @@ | ||
#!/usr/bin/env bash | ||
|
||
PLATFORM=${1-all} | ||
VERSION=`git rev-parse master` | ||
BUILDDIR=build | ||
APP_NAME="IBM Cloud Functions Shell" | ||
|
||
# openwhisk icons | ||
#ICON_MAC=../assets/icons/icns/OpenWhisk-512x512.icns | ||
#ICON_WIN32=../assets/icons/ico/openwhisk_512x512_jnb_icon.ico | ||
|
||
# dolphin icons | ||
ICON_MAC=../assets/icons/icns/blue-dolphin-transparent.icns | ||
ICON_WIN32=../assets/icons/ico/blue-dolphin-transparent.ico | ||
ICON_LINUX=../assets/icons/png/blue-dolphin-transparent.png | ||
|
||
function init { | ||
# make the build directory | ||
if [ ! -d $BUILDDIR ]; then | ||
mkdir $BUILDDIR | ||
if [ $? != 0 ]; then | ||
exit 1 | ||
fi | ||
fi | ||
|
||
if [ ! -d node_modules ]; then | ||
npm install | ||
fi | ||
|
||
# assemble plugins | ||
UGLIFY=true ./compile.js | ||
|
||
# minify the css | ||
cp ../app/content/css/ui.css /tmp | ||
./node_modules/.bin/minify /tmp/ui.css | ||
cp /tmp/ui.min.css ../app/content/css/ui.css | ||
|
||
VERSION=`cat ../app/package.json | jq --raw-output .version` | ||
echo "$VERSION" > ../app/.version | ||
} | ||
|
||
function cleanup { | ||
# rm ../app/plugins/.pre-scanned | ||
rm ../app/.version | ||
|
||
cp /tmp/ui.css ../app/content/css/ui.css | ||
|
||
UGLIFY=true ./compile.js cleanup | ||
} | ||
|
||
function win32 { | ||
if [ "$PLATFORM" == "all" ] || [ "$PLATFORM" == "win32" ] || [ "$PLATFORM" == "windows" ]; then | ||
# create the bundles | ||
./node_modules/.bin/electron-packager \ | ||
../app \ | ||
"$APP_NAME" \ | ||
--asar=true \ | ||
--build-version=$VERSION \ | ||
--out=$BUILDDIR \ | ||
--platform=win32 \ | ||
--icon=$ICON_WIN32 \ | ||
--protocol=wsk --protocol-name="Execute ${APP_NAME} commands" \ | ||
--overwrite \ | ||
--win32metadata.CompanyName="Apache" \ | ||
--win32metadata.ProductName="${APP_NAME}" | ||
|
||
# CLI scripts | ||
cp ../app/bin/fsh "$BUILDDIR/${APP_NAME}-win32-x64/fsh" | ||
cp ../app/bin/fsh.bat "$BUILDDIR/${APP_NAME}-win32-x64" | ||
|
||
# | ||
# deal with win32 packaging | ||
# | ||
if [ -z "$NO_INSTALLER" ]; then | ||
(cd $BUILDDIR && zip -q -r "${APP_NAME}-win32-x64" "${APP_NAME}-win32-x64" -x \*~) | ||
fi | ||
fi | ||
} | ||
|
||
|
||
# | ||
# deal with darwin/macOS packaging | ||
# | ||
function mac { | ||
if [ "$PLATFORM" == "all" ] || [ "$PLATFORM" == "mac" ] || [ "$PLATFORM" == "macos" ] || [ "$PLATFORM" == "darwin" ]; then | ||
./node_modules/.bin/electron-packager \ | ||
../app \ | ||
"${APP_NAME}" \ | ||
--asar=true \ | ||
--build-version=$VERSION \ | ||
--ignore='~$' \ | ||
--out=$BUILDDIR \ | ||
--platform=darwin \ | ||
--icon=$ICON_MAC \ | ||
--protocol=wsk --protocol-name="Execute ${APP_NAME} commands" \ | ||
--overwrite | ||
|
||
# use a custom icon for mac | ||
cp $ICON_MAC "$BUILDDIR/${APP_NAME}-darwin-x64/${APP_NAME}.app/Contents/Resources/electron.icns" | ||
|
||
# CLI script | ||
cp ../app/bin/fsh "$BUILDDIR/${APP_NAME}-darwin-x64/${APP_NAME}.app/Contents/MacOS/" | ||
|
||
# create the installers | ||
if [ -n "$ZIP_INSTALLER" ]; then | ||
(cd $BUILDDIR && zip -q -r "${APP_NAME}-darwin-x64" "${APP_NAME}-darwin-x64" -x \*~) | ||
|
||
elif [ -z "$NO_INSTALLER" ]; then | ||
./node_modules/.bin/electron-installer-dmg \ | ||
"$BUILDDIR/${APP_NAME}-darwin-x64/${APP_NAME}.app" \ | ||
"${APP_NAME}" \ | ||
--out=$BUILDDIR \ | ||
--icon=$ICON_MAC \ | ||
--icon-size=128 \ | ||
--overwrite | ||
fi | ||
fi | ||
} | ||
|
||
# | ||
# deal with linux packaging | ||
# | ||
function linux { | ||
if [ "$PLATFORM" == "all" ] || [ "$PLATFORM" == "linux" ]; then | ||
./node_modules/.bin/electron-packager \ | ||
../app \ | ||
"${APP_NAME}" \ | ||
--asar=true \ | ||
--build-version=$VERSION \ | ||
--out=$BUILDDIR \ | ||
--platform=linux \ | ||
--protocol=wsk --protocol-name="Execute ${APP_NAME} commands" \ | ||
--icon=$ICON_LINUX \ | ||
--overwrite | ||
|
||
# CLI script | ||
cp ../app/bin/fsh "$BUILDDIR/${APP_NAME}-linux-x64" | ||
|
||
if [ -z "$NO_INSTALLER" ]; then | ||
(cd $BUILDDIR && zip -q -r "${APP_NAME}-linux-x64" "${APP_NAME}-linux-x64" -x \*~) | ||
fi | ||
fi | ||
} | ||
|
||
|
||
# line up the work | ||
init | ||
win32 | ||
mac | ||
linux | ||
cleanup | ||
|
||
# TODO: | ||
# upload to OS | ||
# (cd ../prebuilt && npm version publish) |
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,98 @@ | ||
#!/usr/bin/env node | ||
|
||
const fs = require('fs-extra'), | ||
path = require('path'), | ||
events = require('events'), | ||
mkdirp = require('mkdirp-promise'), | ||
{ exec } = require('child_process'), | ||
TMP = 'plugins' // we'll stash the original plugins here | ||
|
||
global.plugins = require(path.join(__dirname, '../app/content/js/plugins')) | ||
global.localStorage = { getItem: () => '{}' } | ||
global.eventBus = new events.EventEmitter() | ||
global.ui = { | ||
startsWithVowel: () => false | ||
} | ||
|
||
/** | ||
* Write the plugin list to the .pre-scanned file in app/plugins/.pre-scanned | ||
* | ||
*/ | ||
const writeToFile = modules => new Promise((resolve, reject) => { | ||
fs.writeFile(path.join(__dirname, '..', 'app', 'plugins', '.pre-scanned'), | ||
JSON.stringify(modules, undefined, 4), | ||
err => { | ||
if (err) reject(err) | ||
else resolve() | ||
}) | ||
}) | ||
|
||
/** | ||
* Uglify the javascript | ||
* | ||
*/ | ||
const uglify = modules => modules.flat.map(module => new Promise((resolve, reject) => { | ||
if (!process.env.UGLIFY) resolve() | ||
|
||
const src = path.join(__dirname, '..', 'app', 'plugins', module.path), | ||
target = src, // we'll copy it aside, and overwrite the original | ||
tmpPath = path.join(TMP, module.path), | ||
tmpDir = path.join(tmpPath, '..') // we want the name of the enclosing directory | ||
|
||
//console.log(`uglifying ${module.route} ${src}`) | ||
|
||
mkdirp(tmpDir) | ||
.then(() => fs.copy(src, tmpPath).then(() => tmpPath)) | ||
.then(() => { | ||
exec(`${path.join(__dirname, 'node_modules', '.bin', 'uglifyjs')} --compress --mangle -o "${target}" -- "${tmpPath}"`, | ||
(err, stdout, stderr) => { | ||
if (err) reject(err) | ||
else resolve() | ||
}) | ||
}) | ||
.catch(reject) | ||
})) | ||
|
||
/** | ||
* Generic filesystem scanning routine | ||
* Note that, when scanning for plugins, we ignore subdirectories named "helpers" | ||
* | ||
*/ | ||
const readDirRecursively = dir => path.basename(dir) !== 'helpers' && path.basename(dir) !== 'node_modules' && fs.statSync(dir).isDirectory() | ||
? Array.prototype.concat(...fs.readdirSync(dir).map(f => readDirRecursively(path.join(dir, f)))) | ||
: dir | ||
|
||
/** | ||
* assemble the list of plugins, then minify the plugins, if we can, | ||
* and write the list to the .pre-scanned file | ||
* | ||
*/ | ||
if (process.argv[2] === 'cleanup') { | ||
// copy the TMP originals back in place | ||
Promise.all(require('../app/content/js/plugins.js').scanForPlugins(TMP) | ||
.map(pluginJsFile => { | ||
const pluginRoot = path.join(__dirname, '..', 'app'), | ||
originalLocation = path.join(pluginRoot, pluginJsFile) | ||
return fs.copy(pluginJsFile, originalLocation) | ||
})) | ||
.then(() => process.exit(0)) | ||
.catch(err => { | ||
console.error(err) | ||
process.exit(1) | ||
}) | ||
|
||
} else { | ||
plugins.assemble() | ||
.then(modules => Object.assign(modules, { | ||
flat: modules.flat.map(module => Object.assign(module, { | ||
// make the paths relative to the root directory | ||
path: path.relative(path.join(__dirname, '..', 'app', 'plugins'), module.path) | ||
})) | ||
})) | ||
.then(modules => Promise.all([writeToFile(modules), ...uglify(modules)])) | ||
.then(() => process.exit(0)) | ||
.catch(err => { | ||
console.error(err) | ||
process.exit(1) | ||
}) | ||
} |
Oops, something went wrong.