Add script for packaging.

This commit is contained in:
CismonX 2021-03-18 14:31:29 +08:00
parent d9c86edd4e
commit dfb63ce3f5
Signed by: cismonx
GPG Key ID: 3094873E29A482FB
4 changed files with 30 additions and 5 deletions

View File

@ -13,5 +13,6 @@ steps:
- name: build - name: build
image: node:14.15.4 image: node:14.15.4
commands: commands:
- npm -g install vsce
- npm ci - npm ci
- npm run vscode:prepublish - npm run package

View File

@ -8,11 +8,14 @@
**/*.map **/*.map
**/*.ts **/*.ts
**/tsconfig.json **/*.vsce-pre-package-backup
.drone.yml .drone.yml
.gitignore .gitignore
.gitattributes .gitattributes
.travis.yml .travis.yml
.vscode/** .vscode/
src/** LICENSE_NOTICE.md
scripts/** node_modules/
src/
scripts/
tsconfig.json

View File

@ -35,6 +35,7 @@
}, },
"scripts": { "scripts": {
"vscode:prepublish": "webpack --mode production", "vscode:prepublish": "webpack --mode production",
"package": "sh ./scripts/package.sh",
"build": "webpack --mode development", "build": "webpack --mode development",
"prepare": "sh ./scripts/prepare.sh", "prepare": "sh ./scripts/prepare.sh",
"lint": "eslint --ext ts --fix src", "lint": "eslint --ext ts --fix src",

20
scripts/package.sh Executable file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env sh
#
# 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.
#
BACKUP_SUFFIX=vsce-pre-package-backup
JSON_FILES=(package.json language-configuration.json)
for file in ${JSON_FILES[@]}; do
mv $file $file.$BACKUP_SUFFIX
json -j0 -f $file.$BACKUP_SUFFIX > $file
done
json -j0 -I -e 'delete this.eslintConfig; delete this.devDependencies;' -f package.json
vsce package --baseContentUrl=`json -f package.json repository.url`
for file in ${JSON_FILES[@]}; do
mv $file.$BACKUP_SUFFIX $file
done