Skip to content

Commit

Permalink
Replace Vagrant with Docker
Browse files Browse the repository at this point in the history
  • Loading branch information
AliasIO committed May 14, 2017
1 parent 8a6f9ba commit 1985fbc
Show file tree
Hide file tree
Showing 97 changed files with 216 additions and 3,200 deletions.
14 changes: 5 additions & 9 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
.vagrant

build/*
src/icons/converted/*

node_modules
npm-debug.log

tags
/build/*
/src/icons/converted/*
/node_modules
/npm-debug.log

!.gitkeep

# Junk files
Thumbs.db
Desktop.ini
*.DS_Store
Expand Down
16 changes: 2 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
language: node_js
node_js:
- "node"
sudo: false
dist: trusty
before_install:
- export WAPPALYZER_ROOT=$TRAVIS_BUILD_DIR
- export WAPPALYZER_NODE_PATH=$TRAVIS_BUILD_DIR
- export PATH=$PATH:$TRAVIS_BUILD_DIR/bin
- ln -s docker/node/package.json package.json
before_script: npm i -g manifoldjs
services: docker
after_success:
- sha256sum build/* > build/SHA256SUMS
- cat build/SHA256SUMS
script: ./run build
deploy:
provider: releases
api_key:
Expand All @@ -22,9 +14,5 @@ deploy:
on:
repo: AliasIO/Wappalyzer
tags: true
after_script: ls -l --block-size=kB build
cache:
directories:
- node_modules
env:
- CXX=g++-4.8
3 changes: 0 additions & 3 deletions CONTRIBUTING.md

This file was deleted.

32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM alpine

MAINTAINER Elbert Alias <[email protected]>

ENV WAPPALYZER_DIR=/opt/wappalyzer

RUN apk add --no-cache \
bash \
curl \
fontconfig \
nodejs \
optipng \
zip

RUN mkdir -p /usr/share && \
cd /usr/share \
&& curl -L https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.1.1-linux-x86_64.tar.bz2 | tar xj \
&& ln -s /usr/share/phantomjs/phantomjs /usr/bin/phantomjs

RUN apk del \
curl

RUN npm i -g \
jsonlint-cli \
manifoldjs \
svg2png-many

RUN mkdir -p $WAPPALYZER_DIR

WORKDIR $WAPPALYZER_DIR

CMD [ "./bin/run" ]
71 changes: 23 additions & 48 deletions bin/wappalyzer-build → bin/build
Original file line number Diff line number Diff line change
@@ -1,82 +1,57 @@
#!/bin/bash

if [ -z $WAPPALYZER_ROOT ]
then
echo "\$WAPPALYZER_ROOT not set"
cd "$(dirname $0)/.."

exit 1
fi

if [ -z $WAPPALYZER_NODE_PATH ]
then
echo "\$WAPPALYZER_NODE_PATH not set"

exit 1
fi

set -eu

wappalyzer validate
./bin/validate

echo "Prettifying apps.json..."

node $WAPPALYZER_NODE_PATH/node_modules/jsonlint/lib/cli.js -ist $'\t' $WAPPALYZER_ROOT/src/apps.json

echo "Compressing PNG and SVG icons..."

node $WAPPALYZER_NODE_PATH/node_modules/imagemin-cli/cli.js $WAPPALYZER_ROOT/src/icons/* --out-dir $WAPPALYZER_ROOT/src/icons 2>&1 > /dev/null
jsonlint-cli -ist $'\t' src/apps.json

echo "Converting SVG icons to PNG..."

OIFS="$IFS"
IFS=$'\n'

for svg in $(find $WAPPALYZER_ROOT/src/icons -type f -name "*.svg")
do
echo " Converting $(basename "$svg")..."

dest="$WAPPALYZER_ROOT/src/icons/converted/$(basename "$svg").png"

if [[ -f "$dest" ]]; then
rm "$dest"
fi
#svg2png-many -i src/icons/ -o src/icons/converted/ --width=32 --height=32

node $WAPPALYZER_NODE_PATH/node_modules/svg2png/bin/svg2png-cli "$svg" --width=32 --height=32 --output "$dest" || true
done
echo "Compressing PNG icons..."

IFS="$OIFS"
optipng -quiet "src/icons/*.png"
optipng -quiet "src/icons/converted/*.png"

echo "Compressing converted PNG icons..."

node $WAPPALYZER_NODE_PATH/node_modules/imagemin-cli/cli.js $WAPPALYZER_ROOT/src/icons/converted/* $WAPPALYZER_ROOT/src/icons/converted

wappalyzer links

# WebExtension
echo "Building WebExtension driver..."
echo "Building WebExtension..."

webextension_dir=$WAPPALYZER_ROOT/src/drivers/webextension
webextension_dir=src/drivers/webextension

pushd $webextension_dir > /dev/null

zip -qr $WAPPALYZER_ROOT/build/wappalyzer_webextension.zip .
zip -qr ../../../build/wappalyzer_webextension.zip .

popd > /dev/null

# Edge
echo "Building Edge application..."

pushd $WAPPALYZER_ROOT/build > /dev/null
pushd build > /dev/null

webextension_dir="../$webextension_dir"
manifest_dir="Wappalyzer/edgeextension/manifest"

mv $webextension_dir/manifest.json $webextension_dir/manifest.webextension.json
mv $webextension_dir/manifest.edge.json $webextension_dir/manifest.json

manifoldjs -l debug -p edgeextension -f edgeextension -m $webextension_dir/manifest.json

# Replace symlinks with actual files
rm $manifest_dir/Extension/images/icons

cp ../src/apps.json $manifest_dir/Extension
cp ../src/wappalyzer.js $manifest_dir/Extension/js
cp -r ../src/icons $manifest_dir/Extension/images

mv $webextension_dir/manifest.json $webextension_dir/manifest.edge.json
mv $webextension_dir/manifest.webextension.json $webextension_dir/manifest.json

manifest_dir="Wappalyzer/edgeextension/manifest"

sed -i 's/INSERT-YOUR-PACKAGE-IDENTITY-NAME-HERE/Wappalyzer/' $manifest_dir/appxmanifest.xml
sed -i 's/INSERT-YOUR-PACKAGE-IDENTITY-PUBLISHER-HERE/Wappalyzer/' $manifest_dir/appxmanifest.xml
sed -i 's/INSERT-YOUR-PACKAGE-PROPERTIES-PUBLISHERDISPLAYNAME-HERE/Wappalyzer/' $manifest_dir/appxmanifest.xml
Expand All @@ -94,4 +69,4 @@ rm -rf Wappalyzer

popd > /dev/null

echo "Done. Builds have been created in $WAPPALYZER_ROOT/build."
echo "Done."
2 changes: 1 addition & 1 deletion bin/wappalyzer-help → bin/help
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

cat << 'EOF'
usage: wappalyzer <command> [<args>]
usage: ./run <command> [<args>]
The following commands are available:
build Package drivers
Expand Down
14 changes: 14 additions & 0 deletions bin/links
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

cd "$(dirname $0)/../src"

echo "Creating links..."

ln -nsf ../../apps.json drivers/npm
ln -nsf ../../wappalyzer.js drivers/npm

ln -nsf ../../apps.json drivers/webextension
ln -nsf ../../../wappalyzer.js drivers/webextension/js
ln -nsf ../../../icons/ drivers/webextension/images/icons

echo "Done."
11 changes: 11 additions & 0 deletions bin/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

cd "$(dirname $0)"

if [[ -f "$1" ]]; then
./$1 $@
else
./help

exit 1
fi
17 changes: 17 additions & 0 deletions bin/validate
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

cd "$(dirname $0)/.."

set -eu

echo "Validating apps.json..."

jsonlint-cli -s schema.json src/apps.json

echo "Validating regular expressions..."

./bin/validate-regex

echo "Validating icons..."

./bin/validate-icons
43 changes: 43 additions & 0 deletions bin/validate-icons
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env node

var
app,
fs = require('fs'),
fileType = require('../node_modules/file-type'),
readChunk = require('../node_modules/read-chunk')
isSvg = require('../node_modules/is-svg')
json = require('../src/apps.json');

for (app in json.apps) {
(function(app) {
var
basePath = 'src/icons/';
iconPath = json.apps[app].icon || 'default.svg';
path = basePath + iconPath,
ext = iconPath.substr(iconPath.length - 4);

if ( ext !== '.png' && ext !== '.svg' ) {
throw err = new Error('Icon file extension specified for app "' + app + '" is not ".png" or ".svg": src/icons/' + iconPath);
}

fs.exists(path, function(exists) {
if ( exists ) {
if ( ext === '.png' ) {
var buffer = fileType(readChunk.sync(path, 0, 262));

if ( buffer === null ) {
throw new Error('Unknown mimetype or bad file for "' + app + '": src/icons/' + iconPath);
} else if ( buffer.mime !== 'image/png' ) {
throw new Error('Incorrect mimetype "' + buffer.mime + '" when expected PNG for app "' + app + '": src/icons/' + iconPath);
}
} else if ( type === 'svg' ) {
if ( !isSvg(fs.readFileSync(path)) ) {
throw new Error('Incorrect mimetype when expected SVG for app "' + app + '": src/icons/' + iconPath);
}
}
} else {
throw Error('Missing file for app "' + app + '": src/icons/' + iconPath);
}
});
}(app));
}
3 changes: 1 addition & 2 deletions bin/wappalyzer-validate-regex → bin/validate-regex
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

var
app,
modulesPath = process.env.WAPPALYZER_NODE_PATH !== undefined ? process.env.WAPPALYZER_NODE_PATH + '/node_modules/' : '',
json = require(process.env.WAPPALYZER_ROOT + '/src/apps.json');
json = require('../src/apps.json');

for ( app in json.apps ) {
['headers', 'html', 'env', 'meta', 'script'].forEach(function(type) {
Expand Down
12 changes: 0 additions & 12 deletions bin/wappalyzer

This file was deleted.

45 changes: 0 additions & 45 deletions bin/wappalyzer-links

This file was deleted.

Loading

0 comments on commit 1985fbc

Please sign in to comment.