@noforeignland/signalk-to-noforeignland 1.0.0 → 1.0.1-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,56 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+
4
+ function migrateConfig() {
5
+ try {
6
+ const configDir = process.env.SIGNALK_NODE_CONFIG_DIR ||
7
+ path.join(process.env.HOME || process.env.USERPROFILE, '.signalk');
8
+
9
+ const oldPluginId = 'signalk-to-noforeignland';
10
+ // SignalK speichert scoped packages ohne den Scope oder mit - statt /
11
+ const newPluginId = '@noforeignland-signalk-to-noforeignland'; // @ bleibt, / wird zu -
12
+
13
+ const configPath = path.join(configDir, 'plugin-config-data');
14
+
15
+ // Sicherstellen dass configPath existiert
16
+ if (!fs.existsSync(configPath)) {
17
+ console.log(`Config directory does not exist: ${configPath}`);
18
+ return;
19
+ }
20
+
21
+ const oldConfigFile = path.join(configPath, `${oldPluginId}.json`);
22
+ const newConfigFile = path.join(configPath, `${newPluginId}.json`);
23
+
24
+ console.log(`Looking for old config at: ${oldConfigFile}`);
25
+ console.log(`Will create new config at: ${newConfigFile}`);
26
+ console.log(`Old config exists: ${fs.existsSync(oldConfigFile)}`);
27
+ console.log(`New config exists: ${fs.existsSync(newConfigFile)}`);
28
+
29
+ // Prüfen ob alte Config existiert und neue noch nicht
30
+ if (fs.existsSync(oldConfigFile) && !fs.existsSync(newConfigFile)) {
31
+ console.log('Migrating configuration from old plugin...');
32
+
33
+ // Config kopieren
34
+ const oldConfig = fs.readFileSync(oldConfigFile, 'utf8');
35
+ fs.writeFileSync(newConfigFile, oldConfig);
36
+
37
+ console.log('Configuration migrated successfully!');
38
+ console.log('Old configuration file can be safely deleted after verification.');
39
+
40
+ // Backup erstellen
41
+ const backupFile = `${oldConfigFile}.backup`;
42
+ fs.copyFileSync(oldConfigFile, backupFile);
43
+ console.log(`Backup created at: ${backupFile}`);
44
+ } else if (fs.existsSync(newConfigFile)) {
45
+ console.log('New configuration already exists, no migration needed.');
46
+ } else if (!fs.existsSync(oldConfigFile)) {
47
+ console.log('No old configuration found to migrate.');
48
+ }
49
+
50
+ } catch (error) {
51
+ console.warn('Could not migrate configuration:', error.message);
52
+ console.warn('You may need to reconfigure the plugin manually.');
53
+ }
54
+ }
55
+
56
+ migrateConfig();
package/package.json CHANGED
@@ -1,31 +1,35 @@
1
- {
2
- "name": "@noforeignland/signalk-to-noforeignland",
3
- "version": "1.0.0",
4
- "description": "SignalK track logger to noforeignland.com",
5
- "main": "index.js",
6
- "keywords": [
7
- "signalk-node-server-plugin",
8
- "signalk-category-utility"
9
- ],
10
- "author": "Dirk Wahrheit",
11
- "license": "MIT",
12
- "homepage": "https://github.com/noforeignland/nfl-signalk",
13
- "bugs": {
14
- "url": "https://github.com/noforeignland/nfl-signalk/issues"
15
- },
16
- "repository": {
17
- "type": "git",
18
- "url": "git+https://github.com/noforeignland/nfl-signalk.git"
19
- },
20
- "engines": {
21
- "node": ">=18.0.0"
22
- },
23
- "scripts": {
24
- "test": "echo \"No tests specified\" && exit 0"
25
- },
26
- "dependencies": {
27
- "cron": "^2.1.0",
28
- "fs-extra": "^10.1.0",
29
- "node-fetch": "^2.6.7"
30
- }
31
- }
1
+ {
2
+ "name": "@noforeignland/signalk-to-noforeignland",
3
+ "signalk": {
4
+ "id": "@noforeignland/signalk-to-noforeignland"
5
+ },
6
+ "version": "1.0.1-beta.1",
7
+ "description": "SignalK track logger to noforeignland.com",
8
+ "main": "index.js",
9
+ "keywords": [
10
+ "signalk-node-server-plugin",
11
+ "signalk-category-utility"
12
+ ],
13
+ "author": "Dirk Wahrheit",
14
+ "license": "MIT",
15
+ "homepage": "https://github.com/noforeignland/nfl-signalk",
16
+ "bugs": {
17
+ "url": "https://github.com/noforeignland/nfl-signalk/issues"
18
+ },
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "git+https://github.com/noforeignland/nfl-signalk.git"
22
+ },
23
+ "engines": {
24
+ "node": ">=18.0.0"
25
+ },
26
+ "scripts": {
27
+ "test": "echo \"No tests specified\" && exit 0",
28
+ "postinstall": "node migrate-config.js && (npm uninstall signalk-to-noforeignland 2>/dev/null || rm -rf ../signalk-to-noforeignland || true)"
29
+ },
30
+ "dependencies": {
31
+ "cron": "^2.1.0",
32
+ "fs-extra": "^10.1.0",
33
+ "node-fetch": "^2.6.7"
34
+ }
35
+ }