Skip to content

Commit

Permalink
chore: add version checker
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaud-ritti committed Oct 3, 2022
1 parent d2b7299 commit 7839847
Show file tree
Hide file tree
Showing 6 changed files with 84 additions and 9 deletions.
2 changes: 1 addition & 1 deletion docs/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Note that you can put your configuration files anywhere inside your application
**Landofile using custom lamp config**

```yaml
recipe: lamp
recipe: adeliom
config:
config:
database: config/my-custom.cnf
Expand Down
65 changes: 57 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"author": "Francois van der Ven (francois@vanderven.dev)",
"license": "MIT",
"dependencies": {
"github-version-checker": "^2.3.0",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21"
},
Expand Down
23 changes: 23 additions & 0 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Logger } from "./lib/Logger";
import { Mutagen, MutagenProcessError } from "./lib/Mutagen";
import { MutagenConfigInvalidError, MutagenConfigManipulator, MutagenConfigNotFoundError, MutagenConfigWriteError } from "./lib/Mutagen/ConfigManipulator";
import { platform } from 'process';
import * as versionCheck from 'github-version-checker';

const handleError = (e: BaseError, logger: Logger) => {
if (e instanceof MutagenConfigNotFoundError) {
Expand Down Expand Up @@ -47,6 +48,28 @@ export = (app: App) => {
return true;
};

app.events.on('post-start', () => {

const options = {
repo: 'lando-adeliom',
owner: 'agence-adeliom',
currentVersion: require('./package.json').version // eslint-disable-line
};
versionCheck(options, function (error, update) {
if (update) {
// @ts-ingore
app.addWarning({
title: `A new version of the plugin 'lando-adeliom' is available`,
detail: [
`You have version v${options.currentVersion} but Lando Adeliom released ${update.name}`,
'Please proceed to update with the instructions from the README in our repository'
],
url: 'https://github.com/agence-adeliom/lando-adeliom',
}, error)
}
});
});

app.events.on('post-start', () => {
if (canStartMutagen() !== true) {
return;
Expand Down
1 change: 1 addition & 0 deletions src/types/lando.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ declare module 'lando' {
events: {
on: (eventName: string, handler: () => void) => void;
};
addWarning: (message, error) => void
root: string;
}
class Lando {
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"strictFunctionTypes": true,
"sourceMap": false,
"outDir": "dist",
"resolveJsonModule": true,
"typeRoots": [
"src/types",
"node_modules/@types"
Expand Down

0 comments on commit 7839847

Please sign in to comment.