Skip to content

Commit

Permalink
Move to different inquirer version
Browse files Browse the repository at this point in the history
  • Loading branch information
GenieTim committed Nov 28, 2023
1 parent 3c00fa5 commit d138480
Show file tree
Hide file tree
Showing 5 changed files with 298 additions and 168 deletions.
53 changes: 28 additions & 25 deletions bin/writePost.js → bin/writePost.mjs
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
#!/usr/bin/env node

const dateTime = require('date-and-time');
const fs = require("fs");
const inquirer = require('inquirer');
const markdownTranslate = require('markdown-translator')
const path = require("path");
const tmp = require('tmp');
const yaml = require('js-yaml');
import dateTime from 'date-and-time';
import fs from 'fs';
import { input, rawlist, editor } from '@inquirer/prompts';
import markdownTranslate from "markdown-translator";
import path from "path";
import tmp from "tmp";
import yaml from 'js-yaml';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);

const __dirname = path.dirname(__filename);

const subscriptionKey = getSubscriptionKey();

(async () => {
const languages = getLanguages();
inquirer.prompt([
{
type: "list",
name: "language",
try {
const languages = getLanguages();
let answers = {}
answers.language = await rawlist({
message: "Which language will you write in?",
choices: languages
}, {
type: "input",
name: "title",
choices: languages.map(language => { return { name: language, value: language } })
})
answers.title = await input({
message: "What is the title of the post?"
},
{
type: "editor",
name: "content",
})
answers.content = await editor({
message: "Enter the content of the post in the editor",
postfix: ".md"
}
]).then(async answers => {
})

// potential improvement: read from e.g. git config in case I get an extra author one day
const author = "Tim Bernhard";
const date = new Date();
Expand All @@ -55,7 +57,7 @@ const subscriptionKey = getSubscriptionKey();
}

// finally, save results
for (language in posts) {
for (let language in posts) {
let fileTarget = getFileName(language, date, posts[language].slug)
try {
fs.mkdirSync(path.dirname(fileTarget), { recursive: true });
Expand All @@ -64,12 +66,12 @@ const subscriptionKey = getSubscriptionKey();
}
fs.writeFileSync(fileTarget, getFileContent(author, date, language, posts), { encoding: "utf8" });
}
}).catch(error => {
} catch (error) {
// on error, log everything to prevent work loss
console.error(error);
console.log(posts);
console.log(answers);
});
}
})()

// -- MARK: Helper functions
Expand All @@ -79,6 +81,7 @@ const subscriptionKey = getSubscriptionKey();
function getLanguages() {
let fileContents = fs.readFileSync(__dirname + '/../global-config.yaml', 'utf8');
let data = yaml.load(fileContents);
console.log(data);
return data.languages;
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"extra-watch-webpack-plugin": "^1.0.3",
"fuse.js": "^7.0.0",
"hasbin": "^1.2.3",
"inquirer": "^9.2.12",
"instantclick": "^3.1.0-2",
"jimp": "^0.22.10",
"js-yaml": "^4.1.0",
Expand All @@ -46,6 +45,7 @@
"yargs": "^17.7.2"
},
"dependencies": {
"@inquirer/prompts": "^3.3.0",
"date-and-time": "^3.0.3"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
---
author: Tim Bernhard
categories:
cover_image: false
canonical_url: https://www.genieblog.ch/blog/de/2023/ein-funktionierendes-netatalk-setup-unter-debian-12
date: 2023-11-28 07:12:24
description: false
draft: false
extends: _layouts.post
language: de
layout: post
slug: ein-funktionierendes-netatalk-setup-unter-debian-12
social_image: false
template: post
title: "Ein funktionierendes Netatalk-Setup unter Debian 12"
translations:
en: a-working-netatalk-setup-on-debian-12
de: ein-funktionierendes-netatalk-setup-unter-debian-12
---

Dies ist ein weiterer der "Notizen für mein zukünftiges Ich"-Posts.

Dieses Wochenende habe ich (abgesehen vom Backen von Weihnachtsplätzchen) Zeit investiert, um meinen Backup-Server von Samba auf Netatalk zu migrieren. Ich hatte besondere Probleme mit der Einrichtung der Konfiguration, so dass die Anmeldung vom Mac aus funktionierte.

Am Ende habe ich die folgenden zwei Schlüsselzutaten gefunden:

* Installieren Sie eine (unter Debian) Testversion von libcrypt: `sudo apt-get install libgcrypt20-dev/testing` (Stellen Sie sicher, dass die Test-Repositories zu apt hinzugefügt wurden)
* Verwenden Sie eine funktionierende Konfiguration (`/etc/netatalk/afp.conf`):

```
;
; Netatalk 3.x configuration file
;
[Global]
; Global server settings
log level = default:warn
log file = /var/log/afpd.log
uam list = uams_passwd.so,uams_dhx_passwd.so,uams_dhx2_passwd.so
;,uams_guest.so
; guest account = tim
; [Homes]
; basedir regex = /xxxx
; [My AFP Volume]
; path = /path/to/volume
[MacMini Time Machine Volume]
path = /home/myuser/backup/netatalk-time-machine
time machine = yes
vol size limit = 2500000
valid users = myuser
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
author: Tim Bernhard
categories:
cover_image: false
canonical_url: https://www.genieblog.ch/blog/en/2023/a-working-netatalk-setup-on-debian-12
date: 2023-11-28 07:12:24
description: false
draft: false
extends: _layouts.post
language: en
layout: post
slug: a-working-netatalk-setup-on-debian-12
social_image: false
template: post
title: "A working Netatalk Setup on Debian 12"
translations:
en: a-working-netatalk-setup-on-debian-12
de: ein-funktionierendes-netatalk-setup-unter-debian-12
---

This is one more of the "notes for my future self" posts.

This weekend, I invested time (apart from baking christmas cookies) to migrate my backup server away from Samba to Netatalk. I had particular problems with the setup of the configuration such that the login would work from the Mac.

In the end, I found the following two key incredients:

- Install a (on Debian) testing version of libcrypt: `sudo apt-get install libgcrypt20-dev/testing` (make sure to have the testing repositories added to apt)
- Use a working configuration (`/etc/netatalk/afp.conf`):

```
;
; Netatalk 3.x configuration file
;
[Global]
; Global server settings
log level = default:warn
log file = /var/log/afpd.log
uam list = uams_passwd.so,uams_dhx_passwd.so,uams_dhx2_passwd.so
;,uams_guest.so
; guest account = tim
; [Homes]
; basedir regex = /xxxx
; [My AFP Volume]
; path = /path/to/volume
[MacMini Time Machine Volume]
path = /home/myuser/backup/netatalk-time-machine
time machine = yes
vol size limit = 2500000
valid users = myuser
```

Loading

0 comments on commit d138480

Please sign in to comment.