mirror of
https://github.com/cupcakearmy/autorestic.git
synced 2025-09-06 10:30:39 +00:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
190eca6f6e | |||
805bed7db1 | |||
6c59aa25db | |||
ff648f0017 | |||
c79b45308b | |||
43eabdb204 | |||
0ead9e0da1 | |||
d49e0d3836 | |||
2008ba2771 | |||
1f6c13a595 | |||
8e9b9dcebf |
1
.gitattributes
vendored
Normal file
1
.gitattributes
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
*.afdesign filter=lfs diff=lfs merge=lfs -text
|
21
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
21
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
<!-- A clear and concise description of what the bug is. -->
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
<!-- A clear and concise description of what you expected to happen. -->
|
||||||
|
|
||||||
|
**Environment**
|
||||||
|
- OS: [e.g. iOS]
|
||||||
|
- Version: [e.g. 22]
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
<!-- Add any other context about the problem here. -->
|
4
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
4
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
contact_links:
|
||||||
|
- name: Questions & Help
|
||||||
|
url: https://github.com/cupcakearmy/autorestic/discussions
|
||||||
|
about: Please ask and answer questions here.
|
14
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
14
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: ''
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
<!-- A clear and concise description of what you want to happen. -->
|
BIN
.github/logo.afdesign
(Stored with Git LFS)
vendored
Normal file
BIN
.github/logo.afdesign
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
@@ -1,3 +1,3 @@
|
|||||||
## 0.25
|
## 0.27
|
||||||
|
|
||||||
- disable color in CI mode
|
- fix locking issue
|
||||||
|
@@ -19,3 +19,7 @@
|
|||||||
### Why / What?
|
### Why / What?
|
||||||
|
|
||||||
Autorestic is a wrapper around the amazing [restic](https://restic.net/). While being amazing the restic cli can be a bit overwhelming and difficult to manage if you have many different location that you want to backup to multiple locations. This utility is aimed at making this easier 🙂
|
Autorestic is a wrapper around the amazing [restic](https://restic.net/). While being amazing the restic cli can be a bit overwhelming and difficult to manage if you have many different location that you want to backup to multiple locations. This utility is aimed at making this easier 🙂
|
||||||
|
|
||||||
|
### Questions / Support
|
||||||
|
|
||||||
|
Check the [discussions page](https://github.com/cupcakearmy/autorestic/discussions)
|
||||||
|
@@ -19,4 +19,4 @@ curl -s https://api.github.com/repos/cupcakearmy/autorestic/releases/latest \
|
|||||||
chmod +x ${OUT_FILE}
|
chmod +x ${OUT_FILE}
|
||||||
|
|
||||||
autorestic install
|
autorestic install
|
||||||
autorestic
|
autorestic --help
|
||||||
|
@@ -1,11 +1,10 @@
|
|||||||
{
|
{
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.26",
|
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "tsc",
|
"build": "tsc",
|
||||||
"dev": "tsc -w",
|
"dev": "tsc -w",
|
||||||
"move": "mv bin/index-linux bin/autorestic_linux_x64 && mv bin/index-macos bin/autorestic_macos_x64",
|
"move": "mv bin/index-linux bin/autorestic_linux_x64 && mv bin/index-macos bin/autorestic_macos_x64",
|
||||||
"bin": "yarn run build && pkg dist/src/index.js --targets latest-macos-x64,latest-linux-x64 --out-path bin && yarn run move",
|
"bin": "yarn run build && pkg dist/index.js --targets latest-macos-x64,latest-linux-x64 --out-path bin && yarn run move",
|
||||||
"docs:build": "codedoc install && codedoc build",
|
"docs:build": "codedoc install && codedoc build",
|
||||||
"docs:dev": "codedoc serve"
|
"docs:dev": "codedoc serve"
|
||||||
},
|
},
|
||||||
@@ -18,12 +17,14 @@
|
|||||||
"typescript": "^3.9"
|
"typescript": "^3.9"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@types/semver": "^7.3.4",
|
||||||
"axios": "^0.19",
|
"axios": "^0.19",
|
||||||
"clitastic": "^0.1.2",
|
"clitastic": "^0.1.2",
|
||||||
"colors": "^1",
|
"colors": "^1",
|
||||||
"commander": "^6.2",
|
"commander": "^6.2",
|
||||||
"cron-parser": "2.x.x",
|
"cron-parser": "2.x.x",
|
||||||
"js-yaml": "3.x.x",
|
"js-yaml": "3.x.x",
|
||||||
|
"semver": "^7.3.5",
|
||||||
"uhrwerk": "1.x.x"
|
"uhrwerk": "1.x.x"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -2,6 +2,7 @@ import { chmodSync } from 'fs'
|
|||||||
|
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { Writer } from 'clitastic'
|
import { Writer } from 'clitastic'
|
||||||
|
import semver from 'semver'
|
||||||
|
|
||||||
import { INSTALL_DIR, VERSION } from '..'
|
import { INSTALL_DIR, VERSION } from '..'
|
||||||
import { checkIfResticIsAvailable, downloadFile, exec } from '../utils'
|
import { checkIfResticIsAvailable, downloadFile, exec } from '../utils'
|
||||||
@@ -18,19 +19,25 @@ export async function upgrade() {
|
|||||||
responseType: 'json',
|
responseType: 'json',
|
||||||
})
|
})
|
||||||
|
|
||||||
if (json.tag_name != VERSION) {
|
const latest = semver.coerce(json.tag_name)
|
||||||
const platformMap: { [key: string]: string } = {
|
const current = semver.coerce(VERSION)
|
||||||
darwin: 'macos',
|
if (!latest || !current) throw new Error('Could not parse versions numbers.')
|
||||||
|
if (semver.gt(latest, current) && semver.major(latest) === semver.major(current)) {
|
||||||
|
// Update to compatible
|
||||||
|
if (json.tag_name != VERSION) {
|
||||||
|
const platformMap: { [key: string]: string } = {
|
||||||
|
darwin: 'macos',
|
||||||
|
}
|
||||||
|
|
||||||
|
const name = `autorestic_${platformMap[process.platform] || process.platform}_${process.arch}`
|
||||||
|
const dl = json.assets.find((asset: any) => asset.name === name)
|
||||||
|
|
||||||
|
const to = INSTALL_DIR + '/autorestic'
|
||||||
|
w.replaceLn('Downloading binary... 🌎')
|
||||||
|
await downloadFile(dl.browser_download_url, to)
|
||||||
|
|
||||||
|
chmodSync(to, 0o755)
|
||||||
}
|
}
|
||||||
|
|
||||||
const name = `autorestic_${platformMap[process.platform] || process.platform}_${process.arch}`
|
|
||||||
const dl = json.assets.find((asset: any) => asset.name === name)
|
|
||||||
|
|
||||||
const to = INSTALL_DIR + '/autorestic'
|
|
||||||
w.replaceLn('Downloading binary... 🌎')
|
|
||||||
await downloadFile(dl.browser_download_url, to)
|
|
||||||
|
|
||||||
chmodSync(to, 0o755)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
w.done('All up to date! 🚀')
|
w.done('All up to date! 🚀')
|
||||||
|
21
src/index.ts
21
src/index.ts
@@ -2,10 +2,9 @@ import colors from 'colors'
|
|||||||
import { program } from 'commander'
|
import { program } from 'commander'
|
||||||
import { setCIMode } from 'clitastic'
|
import { setCIMode } from 'clitastic'
|
||||||
|
|
||||||
import { unlock, readLock, writeLock } from './lock'
|
import { unlock, readLock, writeLock, lock } from './lock'
|
||||||
import { Config } from './types'
|
import { Config } from './types'
|
||||||
import { init } from './config'
|
import { init } from './config'
|
||||||
import { version } from '../package.json'
|
|
||||||
|
|
||||||
import info from './handlers/info'
|
import info from './handlers/info'
|
||||||
import check from './handlers/check'
|
import check from './handlers/check'
|
||||||
@@ -18,7 +17,7 @@ import install from './handlers/install'
|
|||||||
import { uninstall } from './handlers/uninstall'
|
import { uninstall } from './handlers/uninstall'
|
||||||
import { upgrade } from './handlers/upgrade'
|
import { upgrade } from './handlers/upgrade'
|
||||||
|
|
||||||
export const VERSION = version
|
export const VERSION = '0.28'
|
||||||
export const INSTALL_DIR = '/usr/local/bin'
|
export const INSTALL_DIR = '/usr/local/bin'
|
||||||
|
|
||||||
let requireConfig: boolean = true
|
let requireConfig: boolean = true
|
||||||
@@ -118,21 +117,19 @@ async function main() {
|
|||||||
try {
|
try {
|
||||||
if (requireConfig) {
|
if (requireConfig) {
|
||||||
config = init(configFile)
|
config = init(configFile)
|
||||||
const lock = readLock()
|
const { running } = readLock()
|
||||||
if (lock.running) throw new Error('An instance of autorestic is already running for this config file'.red)
|
if (running) {
|
||||||
|
console.log('An instance of autorestic is already running for this config file'.red)
|
||||||
writeLock({
|
process.exit(1)
|
||||||
...lock,
|
}
|
||||||
running: true,
|
lock()
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
await queue()
|
await queue()
|
||||||
if (error) process.exit(1)
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e.message)
|
console.error(e.message)
|
||||||
} finally {
|
} finally {
|
||||||
if (requireConfig) unlock()
|
if (requireConfig) unlock()
|
||||||
}
|
}
|
||||||
|
if (error) process.exit(1)
|
||||||
}
|
}
|
||||||
main()
|
main()
|
||||||
|
@@ -30,3 +30,10 @@ export const unlock = () => {
|
|||||||
running: false,
|
running: false,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const lock = () => {
|
||||||
|
writeLock({
|
||||||
|
...readLock(),
|
||||||
|
running: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
@@ -9,5 +9,5 @@
|
|||||||
"alwaysStrict": true,
|
"alwaysStrict": true,
|
||||||
"strictNullChecks": true
|
"strictNullChecks": true
|
||||||
},
|
},
|
||||||
"include": ["./src", "./package.json"]
|
"include": ["./src"]
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user