Dotclear

source: build-tools/build-module.sh @ 4038:cdde7b1dcda8

Revision 4038:cdde7b1dcda8, 1.9 KB checked in by franck <carnet.franck.paul@…>, 6 years ago (diff)

Better this way (module name check)

Line 
1#!/bin/sh
2
3# Usage: build-module.sh [theme]
4# The local directory of module must be a git repo and version will be extracted from its tags
5# The module installable archive will be created inside the current directory (module root)
6#
7# Examples:
8# (Assuming that the current path is the dotclear local repo root)
9#
10# Plugin module, inside plugins folder:
11# $ cd plugins/my-plugin
12# $ ../build-tools/build-module.sh
13#
14# Theme module, inside themes folder:
15# $ cd themes/my-theme
16# $ ../build-tools/build-module.sh theme
17
18# Module type
19MOD_TYPE="plugin"
20
21# Default module version
22DEF_VERSION="0.1"
23
24# Path for JS minifier (1st argument is the js file to minify)
25DIRECTORY=$(dirname "$0")
26MIN_JS="$DIRECTORY/min-js.php"
27
28# Check optionnal 1st parameter (module type)
29if [ "$1" = "theme" ]; then
30  MOD_TYPE="theme"
31fi
32
33# Find module name
34MOD_NAME=$(basename "$PWD")
35if [ "$MOD_NAME" = "themes" ] || [ "$MOD_NAME" = "plugins" ] || [ -d ./plugins ] ; then
36  echo "Launch this command inside the module folder!"
37  exit 1
38fi
39
40# Copy all files to tmp dir
41if [ -d "$MOD_NAME" ]; then
42  rm -rf ./"$MOD_NAME"
43fi
44mkdir ./"$MOD_NAME"
45rsync --exclude="$MOD_NAME" --exclude="mkdocs" --exclude="build.sh" --exclude=".git*" --exclude=".DS_Store" --exclude="*.zip" --exclude="*.map" --exclude="*.rb" --exclude="sass" --exclude="scss" --exclude=".sass*" --exclude="scripts" -a . ./"$MOD_NAME"
46
47# Pack Javascript files
48if [ -f "$MIN_JS" ]; then
49  find ./"$MOD_NAME" -name '*.js' -exec "$MIN_JS" \{\} \;
50fi
51
52# Find last version (if any)
53CUR_VERSION=$(git tag -l | sort -r -V | grep -E "[0-9]" | head -n 1)
54if [ -z "$CUR_VERSION" ]; then
55  CUR_VERSION=$DEF_VERSION
56fi
57
58# Make installable archive
59if [ -f $MOD_TYPE-"$MOD_NAME"-$CUR_VERSION.zip ]; then
60  rm $MOD_TYPE-"$MOD_NAME"-$CUR_VERSION.zip
61fi
62zip -q -r $MOD_TYPE-"$MOD_NAME"-$CUR_VERSION.zip ./"$MOD_NAME"/
63
64# Cleanup
65rm -rf ./"$MOD_NAME"
66
67# Final output
68echo "$MOD_TYPE-$MOD_NAME-$CUR_VERSION.zip ready!"
Note: See TracBrowser for help on using the repository browser.

Sites map