I generates a minimal install.rdf and a chrome.manifest, an empty skin and a XUL overlay loading a locale DTD and an empty JS script.
It also generates a folder for preferences and of course the (en-US) locale folder with the DTD and properties files.
It's written for the bash shell, because I have no idea what Windows programmers use (are batch files still a thing?), and for the first version I opted to use something I have and I find easy to work with.
I'd like to make it "multiplatform", but I need to know what other people expect me to use before working on anything.
It seems I can't attach the file for some reason, so here's a code block with the whole thing in it:
Code: Select all
#!/bin/bash
# Copyright 2019 Alessio Vanni
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THIS=$(basename $0)
VERSION="1.0.0"
DIRPATH=""
ID=""
NAME=""
ERROR=0
function usage() {
echo "$THIS - Create a basic environment for extension development"
echo
echo "Usage:"
echo "$THIS -n NAME -p PATH -i ID"
echo "$THIS -h"
echo "$THIS -V"
echo
echo -e "-n NAME\tGive the extension the name NAME (Required)"
echo -e "-p PATH\tUse PATH as root directory (Required)"
echo -e "-i ID\tUse the id ID in install.rdf (Required)"
echo
echo -e "-h\tShow this message"
echo -e "-V\tShow the program's version"
}
while getopts 'hVp:n:i:' opts; do
case $opts in
'h') usage
exit 1
;;
'V') echo "$VERSION"
exit 1
;;
'n') NAME=$OPTARG
;;
'i') ID=$OPTARG
;;
'p') DIRPATH=$OPTARG
;;
esac
done
if test "x$DIRPATH" == "x" -o "x$ID" == "x" -o "x$NAME" == "x"; then
echo 'Error: Missing required option'
usage
exit 1
fi
if test -d $DIRPATH -o -f $DIRPATH; then
echo "$DIRPATH already exists"
exit 1
fi
echo "Generating extension '$NAME' with id '$ID' in '$DIRPATH'"
echo
mkdir -p $DIRPATH
cd $DIRPATH
mkdir -p content locale/en-US skin defaults/preferences
echo 'Generating install.rdf...'
cat <<EOF > install.rdf
<?xml version='1.0' encoding='utf-8'?>
<!-- REMEMBER TO PLACE YOUR LICENSE BLOCK HERE -->
<r:RDF xmlns:r="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://www.mozilla.org/2004/em-rdf#">
<r:Description about="urn:mozilla:install-manifest">
<id>$ID</id>
<type>2</type>
<name>$NAME</name>
<description></description>
<version>1.0.0</version>
<targetApplication>
<r:Description>
<id>{8de7fcbb-c55c-4fbe-bfc5-fc555c87dbc4}</id>
<minVersion>28.0</minVersion>
<maxVersion>28.*</maxVersion>
</r:Description>
</targetApplication>
</r:Description>
</r:RDF>
EOF
SLUG=$(echo $NAME | tr A-Z a-z | tr -d ' ')
echo 'Generating chrome.manifest...'
cat <<EOF > chrome.manifest
# REMEMBER TO PLACE YOUR LICENSE BLOCK HERE
content $SLUG content/
skin $SLUG classic/1.0 skin/
overlay chrome://browser/content/browser.xul chrome://$SLUG/content/overlay.xul
locale $SLUG en-US locale/en-US/
EOF
echo 'Generating content/overlay.xul...'
cat <<EOF > content/overlay.xul
<?xml version='1.0' encoding='utf-8'?>
<!-- REMEMBER TO PLACE YOUR LICENSE BLOCK HERE -->
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
<?sml-stylesheet href="chrome://$SLUG/skin/overlay.css" type="text/css"?>
<!DOCTYPE window SYSTEM "chrome://$SLUG/locale/translations.dtd">
<overlay xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
id="$SLUG-overlay">
<stringbundleset id="stringbundleset">
<stringbundle id="strings"
src="chrome://$SLUG/locale/strings.properties">
</stringbundle>
</stringbundleset>
<script src="overlay.js"></script>
</overlay>
EOF
echo 'Generating content/overlay.js...'
cat <<EOF > content/overlay.js
// REMEMBER TO PLACE YOUR LICENSE BLOCK HERE
'use strict';
EOF
echo 'Generating skin/overlay.css...'
cat <<EOF > skin/overlay.css
/* REMEMBER TO PLACE YOUR LICENSE BLOCK HERE */
EOF
echo 'Generating locale/translations.dtd...'
cat <<EOF > locale/en-US/translations.dtd
<!-- REMEBER TO PLACE YOUR LICENSE BLOCK HERE -->
EOF
echo 'Generating locale/strings.properties...'
cat <<EOF > locale/en-US/strings.properties
# REMEMBER TO PLACE YOUR LICENSE BLOCK HERE
EOF
echo 'Generating defaults/prefs.js...'
cat <<EOF > defaults/preferences/prefs.js
// REMEMBER TO PLACE YOUR LICENSE BLOCK HERE
EOF
echo
echo 'All done!'
echo
echo '+-----------------------------------------+'
echo '| Remember to review the generated files! |'
echo '+-----------------------------------------+'