Comparing version 3.1.0 to 3.1.1
import * as fs from "fs/promises"; | ||
import * as childprocess from "child_process"; | ||
import { parsePackageJSON } from "../utils/package.js"; | ||
import { parseGitHubGitRepositoryURL } from "../utils/github.js"; | ||
export async function generateScript() { | ||
@@ -10,2 +11,9 @@ const packageJSONFile = await fs.readFile("package.json"); | ||
const packageVersionSafe = metadata.version; | ||
let repository; | ||
try { | ||
repository = parseGitHubGitRepositoryURL(metadata.repository); | ||
} | ||
catch { | ||
throw new Error("Invalid GitHub repository URL"); | ||
} | ||
// TODO: Support line breaks in commit messages? | ||
@@ -27,3 +35,3 @@ const output = childprocess | ||
for (let i = 0; i < commitHashes.length; i++) { | ||
changeFile += `${metadata.repository}/commit/${commitHashes[i]}`; | ||
changeFile += `https://github.com/${repository.owner}/${repository.name}/commit/${commitHashes[i]}`; | ||
if (i !== commitHashes.length - 1) { | ||
@@ -30,0 +38,0 @@ changeFile += "\n"; |
@@ -6,2 +6,3 @@ import * as fs from "fs/promises"; | ||
import { parseSemver } from "../utils/semver.js"; | ||
import { parseGitHubGitRepositoryURL } from "../utils/github.js"; | ||
export async function publishScript() { | ||
@@ -28,3 +29,3 @@ const npmToken = env("AURI_NPM_TOKEN"); | ||
try { | ||
repository = parseGitHubRepositoryURL(metadata.repository); | ||
repository = parseGitHubGitRepositoryURL(metadata.repository); | ||
} | ||
@@ -148,18 +149,2 @@ catch { | ||
})(ReleaseTag || (ReleaseTag = {})); | ||
function parseGitHubRepositoryURL(url) { | ||
const parsed = new URL(url); | ||
if (parsed.origin !== "https://github.com") { | ||
throw new Error("Invalid GitHub repository URL"); | ||
} | ||
const pathnameParts = parsed.pathname.split("/").slice(1); | ||
if (pathnameParts.length < 2) { | ||
throw new Error("Invalid GitHub repository URL"); | ||
} | ||
const repository = { | ||
url, | ||
owner: pathnameParts[0], | ||
name: pathnameParts[1] | ||
}; | ||
return repository; | ||
} | ||
async function createGitHubRelease(token, repository, branch, version, releaseTag, body) { | ||
@@ -166,0 +151,0 @@ const requestBody = JSON.stringify({ |
@@ -31,3 +31,8 @@ export function parsePackageJSON(data) { | ||
typeof data.repository.url === "string") { | ||
repository = data.repository.url; | ||
if (data.repository.url.endsWith(".git")) { | ||
repository = data.repository.url; | ||
} | ||
else { | ||
repository = data.repository.url + ".git"; | ||
} | ||
} | ||
@@ -34,0 +39,0 @@ else { |
{ | ||
"name": "auri", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"description": "Organize package changes and releases", | ||
@@ -23,3 +23,3 @@ "type": "module", | ||
"type": "git", | ||
"url": "https://github.com/pilcrowonpaper/auri", | ||
"url": "https://github.com/pilcrowonpaper/auri.git", | ||
"directory": "/" | ||
@@ -26,0 +26,0 @@ }, |
18611
11
413