matterbridge-eve-motion 1.0.7 → 1.0.8

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.
Files changed (2) hide show
  1. package/create-release.js +81 -0
  2. package/package.json +17 -12
@@ -0,0 +1,81 @@
1
+ /* eslint-disable no-console */
2
+
3
+ /*
4
+ Add the following scripts to package.json file:
5
+ "prepublishOnly": "npm run lint && npm run test && npm run cleanBuild",
6
+ "npmPublish": "npm publish",
7
+ "gitPublish": "npm run lint && npm run test && npm run cleanBuild && node create-release.js",
8
+ "preversion": "npm run lint && npm run test && npm run cleanBuild",
9
+ "postversion": "git push && git push --tags && node create-release.js",
10
+ "version:patch": "npm version patch",
11
+ "version:minor": "npm version minor",
12
+ "version:major": "npm version major",
13
+ */
14
+
15
+ import { execSync } from 'child_process';
16
+ import { readFileSync, writeFileSync, unlinkSync } from 'fs';
17
+ import path from 'path';
18
+ import readline from 'readline';
19
+
20
+ // Get the latest tag
21
+ let tag = execSync('git describe --tags --abbrev=0').toString().trim();
22
+ if (tag.startsWith('v')) {
23
+ tag = tag.substring(1);
24
+ }
25
+
26
+ // Read the changelog file
27
+ const changelogPath = path.join(process.cwd(), 'CHANGELOG.md');
28
+ const changelog = readFileSync(changelogPath, 'utf8');
29
+
30
+ // Extract the relevant section from the changelog
31
+ const changelogSection = extractChangelogSection(changelog, tag);
32
+
33
+ const title = `Release ${tag}`;
34
+ const notes = `Release notes for version ${tag}\n\n## [${tag}] ${changelogSection}`;
35
+
36
+ // Log the release details
37
+ console.log(`Creating release ${tag} with the following details:\nTitle:\n${title}\nNotes:\n${notes}`);
38
+
39
+ // Write the release notes to a temporary file
40
+ const notesFilePath = path.join(process.cwd(), 'release-notes.md');
41
+ writeFileSync(notesFilePath, notes);
42
+
43
+ // Wait for user input before proceeding
44
+ await pressAnyKey();
45
+
46
+ // Create the release using the temporary file
47
+ execSync(`gh release create ${tag} -t "${title}" -F "${notesFilePath}"`, { stdio: 'inherit' });
48
+
49
+ // Clean up the temporary file
50
+ unlinkSync(notesFilePath);
51
+
52
+ /**
53
+ * Extracts the relevant section from the changelog for the given tag.
54
+ * Assumes that each version section in the changelog starts with a heading like "## [tag]".
55
+ * @param {string} changelog - The content of the changelog file.
56
+ * @param {string} tag - The tag for which to extract the changelog section.
57
+ * @returns {string} - The extracted changelog section.
58
+ */
59
+ function extractChangelogSection(changelog, tag) {
60
+ const regex = new RegExp(`## \\[${tag}\\](.*?)(## \\[|$)`, 's');
61
+ const match = changelog.match(regex);
62
+ return match ? match[1].trim() : 'No changelog entry found for this version.';
63
+ }
64
+
65
+ /**
66
+ * Waits for the user to press any key.
67
+ * @returns {Promise<void>}
68
+ */
69
+ function pressAnyKey() {
70
+ return new Promise((resolve) => {
71
+ const rl = readline.createInterface({
72
+ input: process.stdin,
73
+ output: process.stdout,
74
+ });
75
+
76
+ rl.question('Press any key to continue...', () => {
77
+ rl.close();
78
+ resolve();
79
+ });
80
+ });
81
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "matterbridge-eve-motion",
3
- "version": "1.0.7",
3
+ "version": "1.0.8",
4
4
  "description": "Matterbridge eve motion with history",
5
5
  "author": "https://github.com/Luligu",
6
6
  "license": "MIT",
@@ -42,9 +42,16 @@
42
42
  "format:check": "prettier --check \"**/*.{js,jsx,ts,tsx,json,css,md}\"",
43
43
  "clean": "rimraf tsconfig.tsbuildinfo ./dist",
44
44
  "cleanBuild": "npm run clean && tsc",
45
- "deepClean": "rimraf tsconfig.tsbuildinfo package-lock.json ./dist ./node_modulesI",
45
+ "deepClean": "rimraf tsconfig.tsbuildinfo package-lock.json ./dist ./node_modules",
46
46
  "deepCleanRebuild": "npm run deepClean && npm install && npm run build",
47
- "prepublishOnly": "npm run lint && npm run cleanBuild",
47
+ "prepublishOnly": "npm run lint && npm run test && npm run cleanBuild",
48
+ "npmPublish": "npm publish",
49
+ "gitPublish": "npm run lint && npm run test && npm run cleanBuild && node create-release.js",
50
+ "preversion": "npm run lint && npm run test && npm run cleanBuild",
51
+ "postversion": "git push && git push --tags && node create-release.js",
52
+ "version:patch": "npm version patch",
53
+ "version:minor": "npm version minor",
54
+ "version:major": "npm version major",
48
55
  "checkDependencies": "npx npm-check-updates",
49
56
  "updateDependencies": "npx npm-check-updates -u && npm install & npm run cleanBuild",
50
57
  "matterbridge:add": "matterbridge -add .\\",
@@ -57,26 +64,24 @@
57
64
  "dev:uninstall": "npm uninstall matterbridge && npm unlink matterbridge",
58
65
  "install": "node link-matterbridge-script.js"
59
66
  },
60
- "overrides": {
61
- "eslint": "latest"
62
- },
63
67
  "devDependencies": {
64
- "@eslint/js": "9.9.0",
68
+ "@eslint/js": "9.9.1",
65
69
  "@types/eslint__js": "8.42.3",
66
70
  "@types/jest": "29.5.12",
67
- "@types/node": "22.4.2",
71
+ "@types/node": "22.5.3",
72
+ "eslint": "9.9.1",
68
73
  "eslint-config-prettier": "9.1.0",
69
- "eslint-plugin-jest": "28.8.0",
74
+ "eslint-plugin-jest": "28.8.2",
70
75
  "eslint-plugin-prettier": "5.2.1",
71
76
  "jest": "29.7.0",
72
77
  "prettier": "3.3.3",
73
78
  "rimraf": "6.0.1",
74
- "ts-jest": "29.2.4",
79
+ "ts-jest": "29.2.5",
75
80
  "typescript": "5.5.4",
76
- "typescript-eslint": "8.2.0"
81
+ "typescript-eslint": "8.4.0"
77
82
  },
78
83
  "dependencies": {
79
84
  "node-ansi-logger": "3.0.0",
80
85
  "node-persist-manager": "1.0.8"
81
86
  }
82
- }
87
+ }