Skip to content

Commit 0a03a6a

Browse files
committed
add build scripts
1 parent f3ba112 commit 0a03a6a

File tree

6 files changed

+23
-22
lines changed

6 files changed

+23
-22
lines changed

.gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,6 @@ typings/
6565

6666
.hkuberc
6767
.hkuberc.json
68-
hkubectl-*
68+
hkubectl-*
69+
helpers/syncthing/syncthing
70+
output

.travis.yml

+6-17
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
1-
sudo: required
21
language: node_js
32
node_js:
43
- "10"
54
branches:
65
only:
76
- master
87
install:
9-
- npm install
10-
- npm install -g snyk
11-
- snyk test || true
8+
- npm ci
129
cache:
1310
directories:
1411
- node_modules
1512
script:
1613
- NODE_ENV=test npm run-script test-travis
17-
after_script: cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js
1814
after_success:
1915
- |
2016
if ([ "$TRAVIS_BRANCH" == "master" ] || [ ! -z "$TRAVIS_TAG" ]) && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
@@ -25,22 +21,15 @@ after_success:
2521
git checkout -f -b version-branch
2622
npm version patch -m "$(git log -1 --pretty=%B) .... bump version [skip ci]"
2723
git push origin version-branch:master --follow-tags
28-
npx pkg .
29-
snyk monitor
24+
npm run build
3025
else
3126
echo "version skiped!"
3227
fi
3328
deploy:
3429
- provider: releases
3530
api_key: "$GH_TOKEN"
3631
file:
37-
- "hkubectl-linux"
38-
- "hkubectl-macos"
39-
- "hkubectl-win.exe"
40-
skip_cleanup: true
41-
- provider: npm
42-
skip_cleanup: true
43-
44-
api_key: "$NPM_AUTH_TOKEN"
45-
on:
46-
branch: master
32+
- "output/hkubectl-linux"
33+
- "output/hkubectl-macos"
34+
- "output/hkubectl-win.exe"
35+
skip_cleanup: true

helpers/syncthing/syncthing.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const EventEmitter = require('events');
22
const fs = require('fs-extra');
3+
const os = require('os');
34
const path = require('path');
45
const { promisify } = require('util');
56
const { spawn } = require('child_process');
@@ -16,6 +17,9 @@ class Syncthing extends EventEmitter {
1617
this._configDir = path.join(configFolder(), 'syncthing');
1718
this._binDir = path.join(configFolder(), 'syncthing', 'bin');
1819
this._command = path.join(this._binDir, 'syncthing')
20+
if (os.platform() === 'win32') {
21+
this._command = `${this._command}.exe`
22+
}
1923
this._apiKey = 'hkubectl';
2024
this._headers = { 'X-API-KEY': this._apiKey }
2125
}
@@ -25,7 +29,9 @@ class Syncthing extends EventEmitter {
2529
// try to copy the exe first. If it fails, the server is already running
2630
await this._copy(path.join(__dirname, 'syncthing'), this._command);
2731
await this._copy(path.join(__dirname, './config.xml'), path.join(this._configDir, 'config.xml'));
28-
await fs.chmod(this._command, '775')
32+
if (os.platform() !== 'win32') {
33+
await fs.chmod(this._command, '775')
34+
}
2935
}
3036
async start({ envs = {}, port = 8384, tunnelUrl, tunnelPort } = {}) {
3137
this._restPort = port;

package.json

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88
},
99
"scripts": {
1010
"test": "mocha test --colors --recursive",
11-
"test-travis": "./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- -R spec test",
12-
"build-linux": "./node_modules/.bin/pkg -t node10-linux-x64 ."
11+
"test-travis": "echo No tests specified",
12+
"build-linux": "./scripts/build.sh linux",
13+
"build-macos": "./scripts/build.sh macos",
14+
"build-win": "./scripts/build.sh win",
15+
"build": "npm run build-linux && npm run build-macos && npm run build-win"
1316
},
1417
"repository": {
1518
"type": "git",
File renamed without changes.

scripts/build.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
33

44
PLATFORM=${1:-linux}
55
echo building ${PLATFORM} platform
6-
cp "${DIR}/../platform/syncthing-${PLATFORM}" "${DIR}/../helpers/syncthing/syncthing"
6+
cp "${DIR}/../platform/syncthing-${PLATFORM}" "${DIR}/../helpers/syncthing/syncthing"
7+
"${DIR}/../node_modules/.bin/pkg" -t ${PLATFORM} -o "${DIR}/../output/hkubectl-${PLATFORM}" "${DIR}/../"

0 commit comments

Comments
 (0)