Refactor build scripts.
This commit is contained in:
parent
e69ec067f2
commit
19e34d8ed6
|
@ -10,3 +10,4 @@
|
||||||
.vscode/
|
.vscode/
|
||||||
node_modules/
|
node_modules/
|
||||||
out/
|
out/
|
||||||
|
texinfo-*.d/
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
**/*.map
|
**/*.map
|
||||||
**/*.ts
|
**/*.ts
|
||||||
**/*.vsce-pre-package-backup
|
|
||||||
.drone.yml
|
.drone.yml
|
||||||
.gitignore
|
.gitignore
|
||||||
.gitattributes
|
.gitattributes
|
||||||
|
@ -19,4 +18,5 @@ LICENSE_NOTICE.md
|
||||||
node_modules/
|
node_modules/
|
||||||
src/
|
src/
|
||||||
scripts/
|
scripts/
|
||||||
|
texinfo-*.d/
|
||||||
tsconfig.json
|
tsconfig.json
|
||||||
|
|
|
@ -53,7 +53,10 @@
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"root": true,
|
"root": true,
|
||||||
"ignorePatterns": "out/**",
|
"ignorePatterns": [
|
||||||
|
"out/**",
|
||||||
|
"scripts/**"
|
||||||
|
],
|
||||||
"parser": "@typescript-eslint/parser",
|
"parser": "@typescript-eslint/parser",
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"@typescript-eslint"
|
"@typescript-eslint"
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
/**
|
||||||
|
* Copyright (C) 2021 CismonX <admin@cismon.net>
|
||||||
|
*
|
||||||
|
* Copying and distribution of this file, with or without modification, are
|
||||||
|
* permitted in any medium without royalty, provided the copyright notice and
|
||||||
|
* this notice are preserved. This file is offered as-is, without any warranty.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const fs = require('fs')
|
||||||
|
const yazl = require('yazl');
|
||||||
|
|
||||||
|
async function addPathToZipFile(zipFile, path) {
|
||||||
|
for (file of await fs.promises.readdir(path, { withFileTypes: true })) {
|
||||||
|
const name = `${path}/${file.name}`;
|
||||||
|
if (file.isDirectory()) {
|
||||||
|
await addPathToZipFile(zipFile, name);
|
||||||
|
} else {
|
||||||
|
zippedPath = name.substr(name.indexOf('/') + 1);
|
||||||
|
console.log(`+ ${zippedPath}`);
|
||||||
|
zipFile.addFile(name, zippedPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
const vsixFile = process.argv.pop();
|
||||||
|
console.log(`Creating ${vsixFile}:`);
|
||||||
|
const zipFile = new yazl.ZipFile();
|
||||||
|
zipFile.outputStream.pipe(fs.createWriteStream(vsixFile))
|
||||||
|
.on('close', () => console.log(`Finish creating ${vsixFile}`));
|
||||||
|
await addPathToZipFile(zipFile, `${vsixFile}.d`);
|
||||||
|
zipFile.end();
|
||||||
|
})()
|
|
@ -7,31 +7,24 @@
|
||||||
# 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.
|
||||||
#
|
#
|
||||||
|
|
||||||
BACKUP_SUFFIX=vsce-pre-package-backup
|
VSIX_FILE_NAME=texinfo-$(json -f package.json version).vsix
|
||||||
JSON_FILES=(package.json language-configuration.json)
|
PACKAGE_JSON_CLEANUP_JS=$(cat ./scripts/package-json-cleanup.js)
|
||||||
for file in ${JSON_FILES[@]}; do
|
|
||||||
mv $file $file.$BACKUP_SUFFIX
|
|
||||||
json5 -o $file $file.$BACKUP_SUFFIX
|
|
||||||
done
|
|
||||||
XML_PATH=./node_modules/vsce/resources
|
|
||||||
XML_FILES=($XML_PATH/\[Content_Types\].xml $XML_PATH/extension.vsixmanifest)
|
|
||||||
for file in ${XML_FILES[@]}; do
|
|
||||||
mv $file $file.$BACKUP_SUFFIX
|
|
||||||
minify-xml --output $file $file.$BACKUP_SUFFIX
|
|
||||||
done
|
|
||||||
MD_FILES=(README.md CHANGELOG.md)
|
|
||||||
for file in ${MD_FILES[@]}; do
|
|
||||||
mv $file $file.$BACKUP_SUFFIX
|
|
||||||
tail -n +9 $file.$BACKUP_SUFFIX > $file
|
|
||||||
done
|
|
||||||
json -j0 -I -e "$(cat ./scripts/package-json-cleanup.js)" -f package.json
|
|
||||||
vsce package --baseContentUrl=$(json -f package.json repository.url)/tree
|
vsce package --baseContentUrl=$(json -f package.json repository.url)/tree
|
||||||
for file in ${JSON_FILES[@]}; do
|
|
||||||
mv $file.$BACKUP_SUFFIX $file
|
unzip -d $VSIX_FILE_NAME{.d,}
|
||||||
done
|
cd $VSIX_FILE_NAME.d
|
||||||
for file in ${MD_FILES[@]}; do
|
minify-xml --output \[Content_Types\].xml{,}
|
||||||
mv $file.$BACKUP_SUFFIX $file
|
minify-xml --output extension.vsixmanifest{,}
|
||||||
done
|
cd extension
|
||||||
for file in ${XML_FILES[@]}; do
|
# Minify JSON files.
|
||||||
mv $file.$BACKUP_SUFFIX $file
|
json -j0 -I -e "$PACKAGE_JSON_CLEANUP_JS" -f package.json
|
||||||
done
|
json5 -o package.json{,}
|
||||||
|
json5 -o language-configuration.json{,}
|
||||||
|
# Remove comments from Markdown files.
|
||||||
|
sed -i '' -e '1,8d' README.md CHANGELOG.md
|
||||||
|
cd ../..
|
||||||
|
|
||||||
|
# Re-package .vsix file.
|
||||||
|
node ./scripts/make-vsix.js $VSIX_FILE_NAME
|
||||||
|
rm -r $VSIX_FILE_NAME.d
|
||||||
|
|
|
@ -15,10 +15,11 @@
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"rootDir": "src",
|
"rootDir": "src",
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"noImplicitReturns": true
|
"noImplicitReturns": true,
|
||||||
},
|
},
|
||||||
"exclude": [
|
"exclude": [
|
||||||
|
"*.config.ts",
|
||||||
"node_modules",
|
"node_modules",
|
||||||
"*.config.ts"
|
"scripts",
|
||||||
]
|
],
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue