Merge pull request #1261 from balena-io/live-directives

Use livepush commands for copying and running dev specific steps
This commit is contained in:
CameronDiver 2020-04-14 22:10:26 +01:00 committed by GitHub
commit 90ca1757e5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 54 additions and 30 deletions

View File

@ -48,11 +48,10 @@ COPY package*.json ./
RUN npm ci --build-from-source --sqlite=/usr/lib
# TODO: Once we support live copies and live runs, convert
# these
# issue: https://github.com/balena-io-modules/livepush/issues/73
RUN apk add --no-cache ip6tables iptables
COPY entry.sh .
# We only run these commands when executing through
# livepush, so they are presented as livepush directives
#dev-run=apk add --no-cache ip6tables iptables
#dev-copy=entry.sh .
#dev-cmd-live=LIVEPUSH=1 ./entry.sh
COPY webpack.config.js fix-jsonstream.js hardcode-migrations.js tsconfig.json tsconfig.release.json ./

View File

@ -54,7 +54,7 @@ fi
modprobe ip6_tables || true
if [ "${LIVEPUSH}" -eq "1" ]; then
exec npx nodemon --watch src --watch typings --ignore tests \
exec npx nodemon --watch src --watch typings --ignore tests -e js,ts,json \
--exec node -r ts-node/register/transpile-only src/app.ts
else
exec node /usr/src/app/dist/app.js

59
package-lock.json generated
View File

@ -4956,7 +4956,8 @@
},
"safe-buffer": {
"version": "5.1.2",
"bundled": true
"bundled": true,
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
@ -5043,11 +5044,13 @@
},
"wrappy": {
"version": "1.0.2",
"bundled": true
"bundled": true,
"optional": true
},
"yallist": {
"version": "3.0.3",
"bundled": true
"bundled": true,
"optional": true
}
}
},
@ -7328,9 +7331,9 @@
}
},
"livepush": {
"version": "3.2.2",
"resolved": "https://registry.npmjs.org/livepush/-/livepush-3.2.2.tgz",
"integrity": "sha512-7+a/Ez3GJD3hgTSybZrzNApdcHZVrF0OaSl91i3uu1yHuKyQc8couzvfTNvua8CWy/Cup7cETWtfmM7ZAutZWQ==",
"version": "3.3.0",
"resolved": "https://registry.npmjs.org/livepush/-/livepush-3.3.0.tgz",
"integrity": "sha512-zXWc/W5VElTbfZncWNznakVKNNEJ+kSjkWIeeh8lXB+rs6a0JDOgCSiZNX0KhEerLRGHlNhu7Wc8zMhH8IFyKg==",
"dev": true,
"requires": {
"bluebird": "^3.7.2",
@ -11874,7 +11877,8 @@
"ansi-regex": {
"version": "2.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"aproba": {
"version": "1.2.0",
@ -11895,12 +11899,14 @@
"balanced-match": {
"version": "1.0.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"brace-expansion": {
"version": "1.1.11",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
@ -11915,17 +11921,20 @@
"code-point-at": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"concat-map": {
"version": "0.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"console-control-strings": {
"version": "1.1.0",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"core-util-is": {
"version": "1.0.2",
@ -12042,7 +12051,8 @@
"inherits": {
"version": "2.0.4",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"ini": {
"version": "1.3.5",
@ -12054,6 +12064,7 @@
"version": "1.0.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"number-is-nan": "^1.0.0"
}
@ -12068,6 +12079,7 @@
"version": "3.0.4",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"brace-expansion": "^1.1.7"
}
@ -12075,12 +12087,14 @@
"minimist": {
"version": "1.2.5",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"minipass": {
"version": "2.9.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"safe-buffer": "^5.1.2",
"yallist": "^3.0.0"
@ -12099,6 +12113,7 @@
"version": "0.5.3",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"minimist": "^1.2.5"
}
@ -12160,7 +12175,8 @@
"npm-normalize-package-bin": {
"version": "1.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"npm-packlist": {
"version": "1.4.8",
@ -12188,7 +12204,8 @@
"number-is-nan": {
"version": "1.0.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"object-assign": {
"version": "4.1.1",
@ -12200,6 +12217,7 @@
"version": "1.4.0",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"wrappy": "1"
}
@ -12277,7 +12295,8 @@
"safe-buffer": {
"version": "5.1.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"safer-buffer": {
"version": "2.1.2",
@ -12313,6 +12332,7 @@
"version": "1.0.2",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"code-point-at": "^1.0.0",
"is-fullwidth-code-point": "^1.0.0",
@ -12332,6 +12352,7 @@
"version": "3.0.1",
"bundled": true,
"dev": true,
"optional": true,
"requires": {
"ansi-regex": "^2.0.0"
}
@ -12375,12 +12396,14 @@
"wrappy": {
"version": "1.0.2",
"bundled": true,
"dev": true
"dev": true,
"optional": true
},
"yallist": {
"version": "3.1.1",
"bundled": true,
"dev": true
"dev": true,
"optional": true
}
}
},

View File

@ -94,7 +94,7 @@
"json-mask": "^0.3.9",
"knex": "^0.15.2",
"lint-staged": "^10.0.8",
"livepush": "^3.2.2",
"livepush": "^3.3.0",
"lockfile": "^1.0.4",
"lodash": "^4.17.15",
"log-timestamp": "^0.1.2",

View File

@ -40,16 +40,18 @@ export async function startLivepush(opts: {
ignored: /((^|[\/\\])\..|(node_modules|sync|test)\/.*)/,
ignoreInitial: opts.noinit,
})
.on('add', path => livepushExecutor(path))
.on('change', path => livepushExecutor(path))
.on('unlink', path => livepushExecutor(undefined, path));
.on('add', (path) => livepushExecutor(path))
.on('change', (path) => livepushExecutor(path))
.on('unlink', (path) => livepushExecutor(undefined, path));
}
const getExecutor = (livepush: Livepush) => {
const changedFiles: string[] = [];
const deletedFiles: string[] = [];
let changedFiles: string[] = [];
let deletedFiles: string[] = [];
const actualExecutor = _.debounce(async () => {
await livepush.performLivepush(changedFiles, deletedFiles);
changedFiles = [];
deletedFiles = [];
});
return (changed?: string, deleted?: string) => {
if (changed) {