refactor: improve build scripts
This commit is contained in:
parent
ad685014d2
commit
13feb8a1f4
|
@ -1,41 +1,45 @@
|
||||||
#!/usr/bin/env bash
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Copyright (C) 2021 CismonX <admin@cismon.net>
|
# Copyright (C) 2021,2024 CismonX <admin@cismon.net>
|
||||||
#
|
#
|
||||||
# Copying and distribution of this file, with or without modification, are
|
# Copying and distribution of this file, with or without modification, are
|
||||||
# permitted in any medium without royalty, provided the copyright notice and
|
# permitted in any medium without royalty, provided the copyright notice and
|
||||||
# this notice are preserved. This file is offered as-is, without any warranty.
|
# this notice are preserved. This file is offered as-is, without any warranty.
|
||||||
#
|
#
|
||||||
|
|
||||||
VSIX_FILE_NAME=texinfo-$(json -f package.json version).vsix
|
set -e
|
||||||
PACKAGE_JSON_CLEANUP_JS=$(cat ./scripts/package-json-cleanup.js)
|
|
||||||
|
|
||||||
vsce package --baseContentUrl=$(json -f package.json repository.url)/tree
|
version=$(json -f package.json version)
|
||||||
|
vsix_file_name=texinfo-$version.vsix
|
||||||
|
vsce package --baseContentUrl="$(json -f package.json repository.url)/tree"
|
||||||
|
unzip -d "$vsix_file_name.d" "$vsix_file_name"
|
||||||
|
|
||||||
|
cd "$vsix_file_name.d"
|
||||||
|
minify_xml() {
|
||||||
|
minify-xml --no-shorten-namespaces --no-remove-unused-namespaces \
|
||||||
|
--no-remove-unused-default-namespace -i "$1"
|
||||||
|
}
|
||||||
|
minify_xml '[Content_Types].xml'
|
||||||
|
minify_xml extension.vsixmanifest
|
||||||
|
|
||||||
unzip -d $VSIX_FILE_NAME{.d,}
|
|
||||||
cd $VSIX_FILE_NAME.d
|
|
||||||
MINIFY_XML_OPTIONS='--no-shorten-namespaces
|
|
||||||
--no-remove-unused-namespaces
|
|
||||||
--no-remove-unused-default-namespace'
|
|
||||||
minify-xml $MINIFY_XML_OPTIONS --output \[Content_Types\].xml{,}
|
|
||||||
minify-xml $MINIFY_XML_OPTIONS --output extension.vsixmanifest{,}
|
|
||||||
cd extension
|
cd extension
|
||||||
# Minify JSON files.
|
# Minify JSON files.
|
||||||
json -j0 -I -e "$PACKAGE_JSON_CLEANUP_JS" -f package.json
|
json -j0 -I -e "$(cat ../../scripts/package-json-cleanup.js)" -f package.json
|
||||||
perl -pi -e 'chomp if eof' package.json
|
perl -pi -e 'chomp if eof' package.json
|
||||||
json5 -o language-configuration.json{,}
|
json5 language-configuration.json > _ && mv _ language-configuration.json
|
||||||
# Remove comments from Markdown files.
|
# Remove comments from Markdown files.
|
||||||
tail -n +9 README.md > _ && mv _ README.md
|
tail -n +9 README.md > _ && mv _ README.md
|
||||||
tail -n +9 CHANGELOG.md > _ && mv _ CHANGELOG.md
|
tail -n +9 CHANGELOG.md > _ && mv _ CHANGELOG.md
|
||||||
|
|
||||||
cd ext
|
cd ext
|
||||||
# Minify Perl scripts.
|
# Minify Perl scripts.
|
||||||
# You can install perltidy with `cpan Perl::Tidy`
|
# You can install perltidy with `cpan Perl::Tidy`
|
||||||
if [[ -x "$(command -v perltidy)" ]]; then
|
if command -v perltidy; then
|
||||||
perltidy --mangle -dac -b html-preview.pm
|
perltidy --mangle -dac -b html-preview.pm
|
||||||
rm html-preview.pm.bak
|
rm html-preview.pm.bak
|
||||||
fi
|
fi
|
||||||
cd ../../..
|
|
||||||
|
|
||||||
|
cd ../../..
|
||||||
# Re-package .vsix file.
|
# Re-package .vsix file.
|
||||||
node ./scripts/make-vsix.js $VSIX_FILE_NAME
|
node ./scripts/make-vsix.js "$vsix_file_name"
|
||||||
rm -r $VSIX_FILE_NAME.d
|
rm -r "$vsix_file_name.d"
|
||||||
|
|
|
@ -1,17 +1,21 @@
|
||||||
#!/usr/bin/env sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Copyright (C) 2020,2021 CismonX <admin@cismon.net>
|
# Copyright (C) 2020,2021,2024 CismonX <admin@cismon.net>
|
||||||
#
|
#
|
||||||
# Copying and distribution of this file, with or without modification, are
|
# Copying and distribution of this file, with or without modification, are
|
||||||
# permitted in any medium without royalty, provided the copyright notice and
|
# permitted in any medium without royalty, provided the copyright notice and
|
||||||
# this notice are preserved. This file is offered as-is, without any warranty.
|
# this notice are preserved. This file is offered as-is, without any warranty.
|
||||||
#
|
#
|
||||||
|
|
||||||
SRC_PATH=./node_modules/language-texinfo
|
set -e
|
||||||
DEST_PATH=./out/grammars
|
|
||||||
mkdir -p $DEST_PATH
|
|
||||||
# Convert TextMate grammar to JSON, as VSCode cannot recognize CSON ones.
|
|
||||||
cson2json $SRC_PATH/grammars/texinfo.cson | json5 > $DEST_PATH/texinfo.json
|
|
||||||
|
|
||||||
VERSION=$(json -f package.json version)
|
src_path=./node_modules/language-texinfo
|
||||||
echo "@set VERSION $VERSION" > ./doc/version.texi
|
dest_path=./out/grammars
|
||||||
|
|
||||||
|
mkdir -p $dest_path
|
||||||
|
|
||||||
|
# Convert TextMate grammar to JSON, since VSCode cannot recognize CSON ones.
|
||||||
|
cson2json $src_path/grammars/texinfo.cson | json5 > $dest_path/texinfo.json
|
||||||
|
|
||||||
|
version=$(json -f package.json version)
|
||||||
|
echo "@set VERSION $version" > ./doc/version.texi
|
||||||
|
|
Loading…
Reference in New Issue