@jakubmazanec/changesets-changelog 2.0.0-unstable.e1ae458 → 2.0.0

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.
package/LICENSE.md CHANGED
@@ -1,7 +1,5 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2023 Jakub Mazanec
4
-
5
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
6
4
  associated documentation files (the "Software"), to deal in the Software without restriction,
7
5
  including without limitation the rights to use, copy, modify, merge, publish, distribute,
@@ -1,2 +1,2 @@
1
- import type { ModCompWithPackage, NewChangesetWithCommit } from '@changesets/types';
1
+ import { type ModCompWithPackage, type NewChangesetWithCommit } from '@changesets/types';
2
2
  export declare function getDependencyReleaseLine(changesets: NewChangesetWithCommit[], updatedDependencies: ModCompWithPackage[], options?: Record<string, unknown>): Promise<string>;
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var getDependencyReleaseLine_exports = {};
20
+ __export(getDependencyReleaseLine_exports, {
21
+ getDependencyReleaseLine: () => getDependencyReleaseLine
22
+ });
23
+ module.exports = __toCommonJS(getDependencyReleaseLine_exports);
24
+ var import_get_github_info = require("@changesets/get-github-info");
25
+ async function getDependencyReleaseLine(changesets, updatedDependencies, options) {
26
+ if (!options?.repository) {
27
+ throw new Error(
28
+ 'Please provide a repository in Changesets changelog setting, e.g.: "changelog": ["@jakubmazanec/changesets-changelog", { "repository": "org/repo" }]'
29
+ );
30
+ }
31
+ if (!updatedDependencies.length) {
32
+ return "";
33
+ }
34
+ const changesetLink = `- Updated dependencies [${(await Promise.all(
35
+ changesets.map(async (changeset) => {
36
+ if (changeset.commit) {
37
+ let { links } = await (0, import_get_github_info.getInfo)({
38
+ repo: String(options.repository),
39
+ commit: changeset.commit
40
+ });
41
+ return links.commit;
42
+ }
43
+ return void 0;
44
+ })
45
+ )).filter((_) => _).join(", ")}]:`;
46
+ let updatedDepenenciesLines = updatedDependencies.map(
47
+ (dependency) => ` - ${dependency.name}@${dependency.newVersion}`
48
+ );
49
+ return [changesetLink, ...updatedDepenenciesLines].join("\n");
50
+ }
51
+ // Annotate the CommonJS export names for ESM import in node:
52
+ 0 && (module.exports = {
53
+ getDependencyReleaseLine
54
+ });
55
+ //# sourceMappingURL=getDependencyReleaseLine.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../source/getDependencyReleaseLine.ts"],
4
+ "sourcesContent": ["import {getInfo} from '@changesets/get-github-info';\nimport {type ModCompWithPackage, type NewChangesetWithCommit} from '@changesets/types';\n\nexport async function getDependencyReleaseLine(\n changesets: NewChangesetWithCommit[],\n updatedDependencies: ModCompWithPackage[],\n options?: Record<string, unknown>,\n) {\n if (!options?.repository) {\n throw new Error(\n 'Please provide a repository in Changesets changelog setting, e.g.: \"changelog\": [\"@jakubmazanec/changesets-changelog\", { \"repository\": \"org/repo\" }]',\n );\n }\n\n if (!updatedDependencies.length) {\n return '';\n }\n\n const changesetLink = `- Updated dependencies [${(\n await Promise.all(\n changesets.map(async (changeset) => {\n if (changeset.commit) {\n let {links} = await getInfo({\n repo: String(options.repository),\n commit: changeset.commit,\n });\n\n return links.commit;\n }\n\n return undefined;\n }),\n )\n )\n .filter((_) => _)\n .join(', ')}]:`;\n\n let updatedDepenenciesLines = updatedDependencies.map(\n (dependency) => ` - ${dependency.name}@${dependency.newVersion}`,\n );\n\n return [changesetLink, ...updatedDepenenciesLines].join('\\n');\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAAsB;AAGtB,eAAsB,yBACpB,YACA,qBACA,SACA;AACA,MAAI,CAAC,SAAS,YAAY;AACxB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,MAAI,CAAC,oBAAoB,QAAQ;AAC/B,WAAO;AAAA,EACT;AAEA,QAAM,gBAAgB,4BACpB,MAAM,QAAQ;AAAA,IACZ,WAAW,IAAI,OAAO,cAAc;AAClC,UAAI,UAAU,QAAQ;AACpB,YAAI,EAAC,MAAK,IAAI,UAAM,gCAAQ;AAAA,UAC1B,MAAM,OAAO,QAAQ,UAAU;AAAA,UAC/B,QAAQ,UAAU;AAAA,QACpB,CAAC;AAED,eAAO,MAAM;AAAA,MACf;AAEA,aAAO;AAAA,IACT,CAAC;AAAA,EACH,GAEC,OAAO,CAAC,MAAM,CAAC,EACf,KAAK,IAAI,CAAC;AAEb,MAAI,0BAA0B,oBAAoB;AAAA,IAChD,CAAC,eAAe,OAAO,WAAW,IAAI,IAAI,WAAW,UAAU;AAAA,EACjE;AAEA,SAAO,CAAC,eAAe,GAAG,uBAAuB,EAAE,KAAK,IAAI;AAC9D;",
6
+ "names": []
7
+ }
@@ -0,0 +1,5 @@
1
+ import { type NewChangeset, type VersionType } from '@changesets/types';
2
+ export type GetReleaseLineChangeset = NewChangeset & {
3
+ commit?: string | undefined;
4
+ };
5
+ export declare function getReleaseLine(changeset: GetReleaseLineChangeset, type: VersionType, options?: Record<string, unknown>): Promise<string>;
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var getReleaseLine_exports = {};
20
+ __export(getReleaseLine_exports, {
21
+ getReleaseLine: () => getReleaseLine
22
+ });
23
+ module.exports = __toCommonJS(getReleaseLine_exports);
24
+ var import_get_github_info = require("@changesets/get-github-info");
25
+ async function getReleaseLine(changeset, type, options) {
26
+ if (!options?.repository) {
27
+ throw new Error(
28
+ 'Please provide a repository in Changesets changelog setting, e.g.: "changelog": ["@jakubmazanec/changesets-changelog", { "repository": "org/repo" }]'
29
+ );
30
+ }
31
+ let pullRequestFromSummary;
32
+ let commitFromSummary;
33
+ let usersFromSummary = [];
34
+ let replacedChangelog = changeset.summary.replace(/^\s*(?:pr|pull|pull\s+request):\s*#?(\d+)/gim, (_, rawPullRequest) => {
35
+ let pullRequest = Number(rawPullRequest);
36
+ if (!Number.isNaN(pullRequest)) {
37
+ pullRequestFromSummary = pullRequest;
38
+ }
39
+ return "";
40
+ }).replace(/^\s*commit:\s*(\S+)/gim, (_, commit) => {
41
+ commitFromSummary = commit;
42
+ return "";
43
+ }).replace(/^\s*(?:author|user):\s*@?(\S+)/gim, (_, user) => {
44
+ usersFromSummary.push(user);
45
+ return "";
46
+ }).trim();
47
+ let [firstLine, ...lines] = replacedChangelog.split("\n").map((line) => line.trimEnd());
48
+ let commitLink;
49
+ let pullRequestLink;
50
+ let usersLink;
51
+ if (pullRequestFromSummary === void 0) {
52
+ let commitToFetchFrom = commitFromSummary ?? changeset.commit;
53
+ if (commitToFetchFrom) {
54
+ try {
55
+ let { links } = await (0, import_get_github_info.getInfo)({
56
+ repo: String(options.repository),
57
+ commit: commitToFetchFrom
58
+ });
59
+ commitLink = links.commit;
60
+ pullRequestLink = links.pull ?? void 0;
61
+ usersLink = links.user ?? void 0;
62
+ } catch {
63
+ commitLink = void 0;
64
+ }
65
+ }
66
+ } else {
67
+ let { links } = await (0, import_get_github_info.getInfoFromPullRequest)({
68
+ repo: String(options.repository),
69
+ pull: pullRequestFromSummary
70
+ });
71
+ if (commitFromSummary) {
72
+ links = {
73
+ ...links,
74
+ commit: `[\`${commitFromSummary}\`](https://github.com/${options.repository}/commit/${commitFromSummary})`
75
+ };
76
+ }
77
+ commitLink = links.commit ?? void 0;
78
+ pullRequestLink = links.pull;
79
+ usersLink = links.user ?? void 0;
80
+ }
81
+ if (usersFromSummary.length) {
82
+ usersLink = usersFromSummary.map((userFromSummary) => `[@${userFromSummary}](https://github.com/${userFromSummary})`).join(", ");
83
+ }
84
+ let prefix = [
85
+ pullRequestLink ? ` ${pullRequestLink}` : "",
86
+ commitLink ? ` ${commitLink}` : "",
87
+ usersLink ? ` (${usersLink})` : ""
88
+ ].join("");
89
+ return `
90
+
91
+ -${prefix ? `${prefix} \u2013` : ""} ${firstLine}
92
+ ${lines.map((line) => ` ${line}`).join("\n")}`;
93
+ }
94
+ // Annotate the CommonJS export names for ESM import in node:
95
+ 0 && (module.exports = {
96
+ getReleaseLine
97
+ });
98
+ //# sourceMappingURL=getReleaseLine.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../source/getReleaseLine.ts"],
4
+ "sourcesContent": ["import {getInfo, getInfoFromPullRequest} from '@changesets/get-github-info';\nimport {type NewChangeset, type VersionType} from '@changesets/types';\n\nexport type GetReleaseLineChangeset = NewChangeset & {\n commit?: string | undefined;\n};\n\nexport async function getReleaseLine(\n changeset: GetReleaseLineChangeset,\n type: VersionType,\n options?: Record<string, unknown>,\n) {\n if (!options?.repository) {\n throw new Error(\n 'Please provide a repository in Changesets changelog setting, e.g.: \"changelog\": [\"@jakubmazanec/changesets-changelog\", { \"repository\": \"org/repo\" }]',\n );\n }\n\n let pullRequestFromSummary: number | undefined;\n let commitFromSummary: string | undefined;\n let usersFromSummary: string[] = [];\n let replacedChangelog = changeset.summary\n .replace(/^\\s*(?:pr|pull|pull\\s+request):\\s*#?(\\d+)/gim, (_, rawPullRequest) => {\n let pullRequest = Number(rawPullRequest);\n\n if (!Number.isNaN(pullRequest)) {\n pullRequestFromSummary = pullRequest;\n }\n\n return '';\n })\n .replace(/^\\s*commit:\\s*(\\S+)/gim, (_, commit: string) => {\n commitFromSummary = commit;\n\n return '';\n })\n .replace(/^\\s*(?:author|user):\\s*@?(\\S+)/gim, (_, user: string) => {\n usersFromSummary.push(user);\n\n return '';\n })\n .trim();\n let [firstLine, ...lines] = replacedChangelog.split('\\n').map((line) => line.trimEnd());\n let commitLink: string | undefined;\n let pullRequestLink: string | undefined;\n let usersLink: string | undefined;\n\n if (pullRequestFromSummary === undefined) {\n let commitToFetchFrom = commitFromSummary ?? changeset.commit;\n\n if (commitToFetchFrom) {\n try {\n let {links} = await getInfo({\n repo: String(options.repository),\n commit: commitToFetchFrom,\n });\n\n commitLink = links.commit;\n pullRequestLink = links.pull ?? undefined;\n usersLink = links.user ?? undefined;\n } catch {\n commitLink = undefined;\n }\n }\n } else {\n let {links} = await getInfoFromPullRequest({\n repo: String(options.repository),\n pull: pullRequestFromSummary,\n });\n\n if (commitFromSummary) {\n links = {\n ...links,\n commit: `[\\`${commitFromSummary}\\`](https://github.com/${options.repository}/commit/${commitFromSummary})`,\n };\n }\n\n commitLink = links.commit ?? undefined;\n pullRequestLink = links.pull;\n usersLink = links.user ?? undefined;\n }\n\n if (usersFromSummary.length) {\n usersLink = usersFromSummary\n .map((userFromSummary) => `[@${userFromSummary}](https://github.com/${userFromSummary})`)\n .join(', ');\n }\n\n let prefix = [\n pullRequestLink ? ` ${pullRequestLink}` : '',\n commitLink ? ` ${commitLink}` : '',\n usersLink ? ` (${usersLink})` : '',\n ].join('');\n\n return `\\n\\n-${prefix ? `${prefix} \u2013` : ''} ${firstLine}\\n${lines\n .map((line) => ` ${line}`)\n .join('\\n')}`;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,6BAA8C;AAO9C,eAAsB,eACpB,WACA,MACA,SACA;AACA,MAAI,CAAC,SAAS,YAAY;AACxB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,MAAI;AACJ,MAAI;AACJ,MAAI,mBAA6B,CAAC;AAClC,MAAI,oBAAoB,UAAU,QAC/B,QAAQ,gDAAgD,CAAC,GAAG,mBAAmB;AAC9E,QAAI,cAAc,OAAO,cAAc;AAEvC,QAAI,CAAC,OAAO,MAAM,WAAW,GAAG;AAC9B,+BAAyB;AAAA,IAC3B;AAEA,WAAO;AAAA,EACT,CAAC,EACA,QAAQ,0BAA0B,CAAC,GAAG,WAAmB;AACxD,wBAAoB;AAEpB,WAAO;AAAA,EACT,CAAC,EACA,QAAQ,qCAAqC,CAAC,GAAG,SAAiB;AACjE,qBAAiB,KAAK,IAAI;AAE1B,WAAO;AAAA,EACT,CAAC,EACA,KAAK;AACR,MAAI,CAAC,WAAW,GAAG,KAAK,IAAI,kBAAkB,MAAM,IAAI,EAAE,IAAI,CAAC,SAAS,KAAK,QAAQ,CAAC;AACtF,MAAI;AACJ,MAAI;AACJ,MAAI;AAEJ,MAAI,2BAA2B,QAAW;AACxC,QAAI,oBAAoB,qBAAqB,UAAU;AAEvD,QAAI,mBAAmB;AACrB,UAAI;AACF,YAAI,EAAC,MAAK,IAAI,UAAM,gCAAQ;AAAA,UAC1B,MAAM,OAAO,QAAQ,UAAU;AAAA,UAC/B,QAAQ;AAAA,QACV,CAAC;AAED,qBAAa,MAAM;AACnB,0BAAkB,MAAM,QAAQ;AAChC,oBAAY,MAAM,QAAQ;AAAA,MAC5B,QAAQ;AACN,qBAAa;AAAA,MACf;AAAA,IACF;AAAA,EACF,OAAO;AACL,QAAI,EAAC,MAAK,IAAI,UAAM,+CAAuB;AAAA,MACzC,MAAM,OAAO,QAAQ,UAAU;AAAA,MAC/B,MAAM;AAAA,IACR,CAAC;AAED,QAAI,mBAAmB;AACrB,cAAQ;AAAA,QACN,GAAG;AAAA,QACH,QAAQ,MAAM,iBAAiB,0BAA0B,QAAQ,UAAU,WAAW,iBAAiB;AAAA,MACzG;AAAA,IACF;AAEA,iBAAa,MAAM,UAAU;AAC7B,sBAAkB,MAAM;AACxB,gBAAY,MAAM,QAAQ;AAAA,EAC5B;AAEA,MAAI,iBAAiB,QAAQ;AAC3B,gBAAY,iBACT,IAAI,CAAC,oBAAoB,KAAK,eAAe,wBAAwB,eAAe,GAAG,EACvF,KAAK,IAAI;AAAA,EACd;AAEA,MAAI,SAAS;AAAA,IACX,kBAAkB,IAAI,eAAe,KAAK;AAAA,IAC1C,aAAa,IAAI,UAAU,KAAK;AAAA,IAChC,YAAY,KAAK,SAAS,MAAM;AAAA,EAClC,EAAE,KAAK,EAAE;AAET,SAAO;AAAA;AAAA,GAAQ,SAAS,GAAG,MAAM,YAAO,EAAE,IAAI,SAAS;AAAA,EAAK,MACzD,IAAI,CAAC,SAAS,KAAK,IAAI,EAAE,EACzB,KAAK,IAAI,CAAC;AACf;",
6
+ "names": []
7
+ }
package/build/main.js ADDED
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var main_exports = {};
17
+ module.exports = __toCommonJS(main_exports);
18
+ var import_dotenv = require("dotenv");
19
+ __reExport(main_exports, require("./getDependencyReleaseLine"), module.exports);
20
+ __reExport(main_exports, require("./getReleaseLine"), module.exports);
21
+ (0, import_dotenv.config)();
22
+ // Annotate the CommonJS export names for ESM import in node:
23
+ 0 && (module.exports = {
24
+ ...require("./getDependencyReleaseLine"),
25
+ ...require("./getReleaseLine")
26
+ });
27
+ //# sourceMappingURL=main.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../source/main.ts"],
4
+ "sourcesContent": ["import {config} from 'dotenv';\n\nconfig();\n\nexport * from './getDependencyReleaseLine';\nexport * from './getReleaseLine';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,oBAAqB;AAIrB,yBAAc,uCAJd;AAKA,yBAAc,6BALd;AAAA,IAEA,sBAAO;",
6
+ "names": []
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jakubmazanec/changesets-changelog",
3
- "version": "2.0.0-unstable.e1ae458",
3
+ "version": "2.0.0",
4
4
  "description": "Changelog for projects using Changesets.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -11,27 +11,35 @@
11
11
  "author": "Jakub Mazanec <jakub@mazanec.dev>",
12
12
  "sideEffects": false,
13
13
  "type": "commonjs",
14
- "exports": "./dist/main.js",
14
+ "exports": "./build/main.js",
15
15
  "files": [
16
- "dist",
17
- "src"
16
+ "build",
17
+ "source"
18
18
  ],
19
19
  "scripts": {
20
- "build": "swc src -d dist && tsc",
21
- "clean": "del-cli coverage dist *.tsbuildinfo",
22
- "format": "prettier . --write --ignore-unknown --ignore-path ../../.prettierignore",
20
+ "build": "del-cli build tsconfig.tsbuildinfo && esbuild \"source/**/*\" --platform=node --target=node20.8 --format=cjs --outdir=build --sourcemap && tsc",
21
+ "clean": "del-cli coverage build *.tsbuildinfo",
22
+ "format": "prettier . --write --ignore-unknown",
23
23
  "lint": "eslint .",
24
- "test": "jest --passWithNoTests",
24
+ "test": "del-cli coverage && vitest run --coverage --passWithNoTests",
25
25
  "typecheck": "tsc --project tsconfig.typecheck.json"
26
26
  },
27
27
  "dependencies": {
28
- "@changesets/get-github-info": "0.5.1",
29
- "dotenv": "^16.0.3"
28
+ "@changesets/get-github-info": "0.6.0",
29
+ "dotenv": "^16.4.1"
30
30
  },
31
31
  "devDependencies": {
32
- "@changesets/parse": "^0.3.15",
33
- "@changesets/types": "^5.2.0",
34
- "@types/node": "^20.8.5"
32
+ "@changesets/parse": "^0.4.0",
33
+ "@changesets/types": "^6.0.0",
34
+ "@types/node": "^20.8.5",
35
+ "@vitest/coverage-v8": "^1.2.2",
36
+ "del-cli": "^5.1.0",
37
+ "esbuild": "^0.20.0",
38
+ "eslint": "^8.56.0",
39
+ "prettier": "^3.2.5",
40
+ "prettier-plugin-packagejson": "^2.4.10",
41
+ "typescript": "^5.3.3",
42
+ "vitest": "^1.2.2"
35
43
  },
36
44
  "packageManager": "npm@10.1.0",
37
45
  "engines": {
@@ -1,5 +1,5 @@
1
1
  import {getInfo} from '@changesets/get-github-info';
2
- import type {ModCompWithPackage, NewChangesetWithCommit} from '@changesets/types';
2
+ import {type ModCompWithPackage, type NewChangesetWithCommit} from '@changesets/types';
3
3
 
4
4
  export async function getDependencyReleaseLine(
5
5
  changesets: NewChangesetWithCommit[],
@@ -1,8 +1,12 @@
1
1
  import {getInfo, getInfoFromPullRequest} from '@changesets/get-github-info';
2
- import type {VersionType, NewChangesetWithCommit} from '@changesets/types';
2
+ import {type NewChangeset, type VersionType} from '@changesets/types';
3
+
4
+ export type GetReleaseLineChangeset = NewChangeset & {
5
+ commit?: string | undefined;
6
+ };
3
7
 
4
8
  export async function getReleaseLine(
5
- changeset: NewChangesetWithCommit,
9
+ changeset: GetReleaseLineChangeset,
6
10
  type: VersionType,
7
11
  options?: Record<string, unknown>,
8
12
  ) {
@@ -1,33 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "getDependencyReleaseLine", {
3
- enumerable: true,
4
- get: function() {
5
- return getDependencyReleaseLine;
6
- }
7
- });
8
- const _getgithubinfo = require("@changesets/get-github-info");
9
- async function getDependencyReleaseLine(changesets, updatedDependencies, options) {
10
- if (!options?.repository) {
11
- throw new Error('Please provide a repository in Changesets changelog setting, e.g.: "changelog": ["@jakubmazanec/changesets-changelog", { "repository": "org/repo" }]');
12
- }
13
- if (!updatedDependencies.length) {
14
- return '';
15
- }
16
- const changesetLink = `- Updated dependencies [${(await Promise.all(changesets.map(async (changeset)=>{
17
- if (changeset.commit) {
18
- let { links } = await (0, _getgithubinfo.getInfo)({
19
- repo: String(options.repository),
20
- commit: changeset.commit
21
- });
22
- return links.commit;
23
- }
24
- return undefined;
25
- }))).filter((_)=>_).join(', ')}]:`;
26
- let updatedDepenenciesLines = updatedDependencies.map((dependency)=>` - ${dependency.name}@${dependency.newVersion}`);
27
- return [
28
- changesetLink,
29
- ...updatedDepenenciesLines
30
- ].join('\n');
31
- }
32
-
33
- //# sourceMappingURL=getDependencyReleaseLine.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/getDependencyReleaseLine.ts"],"sourcesContent":["import {getInfo} from '@changesets/get-github-info';\nimport type {ModCompWithPackage, NewChangesetWithCommit} from '@changesets/types';\n\nexport async function getDependencyReleaseLine(\n changesets: NewChangesetWithCommit[],\n updatedDependencies: ModCompWithPackage[],\n options?: Record<string, unknown>,\n) {\n if (!options?.repository) {\n throw new Error(\n 'Please provide a repository in Changesets changelog setting, e.g.: \"changelog\": [\"@jakubmazanec/changesets-changelog\", { \"repository\": \"org/repo\" }]',\n );\n }\n\n if (!updatedDependencies.length) {\n return '';\n }\n\n const changesetLink = `- Updated dependencies [${(\n await Promise.all(\n changesets.map(async (changeset) => {\n if (changeset.commit) {\n let {links} = await getInfo({\n repo: String(options.repository),\n commit: changeset.commit,\n });\n\n return links.commit;\n }\n\n return undefined;\n }),\n )\n )\n .filter((_) => _)\n .join(', ')}]:`;\n\n let updatedDepenenciesLines = updatedDependencies.map(\n (dependency) => ` - ${dependency.name}@${dependency.newVersion}`,\n );\n\n return [changesetLink, ...updatedDepenenciesLines].join('\\n');\n}\n"],"names":["getDependencyReleaseLine","changesets","updatedDependencies","options","repository","Error","length","changesetLink","Promise","all","map","changeset","commit","links","getInfo","repo","String","undefined","filter","_","join","updatedDepenenciesLines","dependency","name","newVersion"],"mappings":";+BAGsBA;;;eAAAA;;;+BAHA;AAGf,eAAeA,yBACpBC,UAAoC,EACpCC,mBAAyC,EACzCC,OAAiC;IAEjC,IAAI,CAACA,SAASC,YAAY;QACxB,MAAM,IAAIC,MACR;IAEJ;IAEA,IAAI,CAACH,oBAAoBI,MAAM,EAAE;QAC/B,OAAO;IACT;IAEA,MAAMC,gBAAgB,CAAC,wBAAwB,EAAE,AAC/C,CAAA,MAAMC,QAAQC,GAAG,CACfR,WAAWS,GAAG,CAAC,OAAOC;QACpB,IAAIA,UAAUC,MAAM,EAAE;YACpB,IAAI,EAACC,KAAK,EAAC,GAAG,MAAMC,IAAAA,sBAAO,EAAC;gBAC1BC,MAAMC,OAAOb,QAAQC,UAAU;gBAC/BQ,QAAQD,UAAUC,MAAM;YAC1B;YAEA,OAAOC,MAAMD,MAAM;QACrB;QAEA,OAAOK;IACT,GACF,EAECC,MAAM,CAAC,CAACC,IAAMA,GACdC,IAAI,CAAC,MAAM,EAAE,CAAC;IAEjB,IAAIC,0BAA0BnB,oBAAoBQ,GAAG,CACnD,CAACY,aAAe,CAAC,IAAI,EAAEA,WAAWC,IAAI,CAAC,CAAC,EAAED,WAAWE,UAAU,CAAC,CAAC;IAGnE,OAAO;QAACjB;WAAkBc;KAAwB,CAACD,IAAI,CAAC;AAC1D"}
@@ -1,2 +0,0 @@
1
- import type { VersionType, NewChangesetWithCommit } from '@changesets/types';
2
- export declare function getReleaseLine(changeset: NewChangesetWithCommit, type: VersionType, options?: Record<string, unknown>): Promise<string>;
@@ -1,74 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "getReleaseLine", {
3
- enumerable: true,
4
- get: function() {
5
- return getReleaseLine;
6
- }
7
- });
8
- const _getgithubinfo = require("@changesets/get-github-info");
9
- async function getReleaseLine(changeset, type, options) {
10
- if (!options?.repository) {
11
- throw new Error('Please provide a repository in Changesets changelog setting, e.g.: "changelog": ["@jakubmazanec/changesets-changelog", { "repository": "org/repo" }]');
12
- }
13
- let pullRequestFromSummary;
14
- let commitFromSummary;
15
- let usersFromSummary = [];
16
- let replacedChangelog = changeset.summary.replace(/^\s*(?:pr|pull|pull\s+request):\s*#?(\d+)/gim, (_, rawPullRequest)=>{
17
- let pullRequest = Number(rawPullRequest);
18
- if (!Number.isNaN(pullRequest)) {
19
- pullRequestFromSummary = pullRequest;
20
- }
21
- return '';
22
- }).replace(/^\s*commit:\s*(\S+)/gim, (_, commit)=>{
23
- commitFromSummary = commit;
24
- return '';
25
- }).replace(/^\s*(?:author|user):\s*@?(\S+)/gim, (_, user)=>{
26
- usersFromSummary.push(user);
27
- return '';
28
- }).trim();
29
- let [firstLine, ...lines] = replacedChangelog.split('\n').map((line)=>line.trimEnd());
30
- let commitLink;
31
- let pullRequestLink;
32
- let usersLink;
33
- if (pullRequestFromSummary === undefined) {
34
- let commitToFetchFrom = commitFromSummary ?? changeset.commit;
35
- if (commitToFetchFrom) {
36
- try {
37
- let { links } = await (0, _getgithubinfo.getInfo)({
38
- repo: String(options.repository),
39
- commit: commitToFetchFrom
40
- });
41
- commitLink = links.commit;
42
- pullRequestLink = links.pull ?? undefined;
43
- usersLink = links.user ?? undefined;
44
- } catch {
45
- commitLink = undefined;
46
- }
47
- }
48
- } else {
49
- let { links } = await (0, _getgithubinfo.getInfoFromPullRequest)({
50
- repo: String(options.repository),
51
- pull: pullRequestFromSummary
52
- });
53
- if (commitFromSummary) {
54
- links = {
55
- ...links,
56
- commit: `[\`${commitFromSummary}\`](https://github.com/${options.repository}/commit/${commitFromSummary})`
57
- };
58
- }
59
- commitLink = links.commit ?? undefined;
60
- pullRequestLink = links.pull;
61
- usersLink = links.user ?? undefined;
62
- }
63
- if (usersFromSummary.length) {
64
- usersLink = usersFromSummary.map((userFromSummary)=>`[@${userFromSummary}](https://github.com/${userFromSummary})`).join(', ');
65
- }
66
- let prefix = [
67
- pullRequestLink ? ` ${pullRequestLink}` : '',
68
- commitLink ? ` ${commitLink}` : '',
69
- usersLink ? ` (${usersLink})` : ''
70
- ].join('');
71
- return `\n\n-${prefix ? `${prefix} –` : ''} ${firstLine}\n${lines.map((line)=>` ${line}`).join('\n')}`;
72
- }
73
-
74
- //# sourceMappingURL=getReleaseLine.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/getReleaseLine.ts"],"sourcesContent":["import {getInfo, getInfoFromPullRequest} from '@changesets/get-github-info';\nimport type {VersionType, NewChangesetWithCommit} from '@changesets/types';\n\nexport async function getReleaseLine(\n changeset: NewChangesetWithCommit,\n type: VersionType,\n options?: Record<string, unknown>,\n) {\n if (!options?.repository) {\n throw new Error(\n 'Please provide a repository in Changesets changelog setting, e.g.: \"changelog\": [\"@jakubmazanec/changesets-changelog\", { \"repository\": \"org/repo\" }]',\n );\n }\n\n let pullRequestFromSummary: number | undefined;\n let commitFromSummary: string | undefined;\n let usersFromSummary: string[] = [];\n let replacedChangelog = changeset.summary\n .replace(/^\\s*(?:pr|pull|pull\\s+request):\\s*#?(\\d+)/gim, (_, rawPullRequest) => {\n let pullRequest = Number(rawPullRequest);\n\n if (!Number.isNaN(pullRequest)) {\n pullRequestFromSummary = pullRequest;\n }\n\n return '';\n })\n .replace(/^\\s*commit:\\s*(\\S+)/gim, (_, commit: string) => {\n commitFromSummary = commit;\n\n return '';\n })\n .replace(/^\\s*(?:author|user):\\s*@?(\\S+)/gim, (_, user: string) => {\n usersFromSummary.push(user);\n\n return '';\n })\n .trim();\n let [firstLine, ...lines] = replacedChangelog.split('\\n').map((line) => line.trimEnd());\n let commitLink: string | undefined;\n let pullRequestLink: string | undefined;\n let usersLink: string | undefined;\n\n if (pullRequestFromSummary === undefined) {\n let commitToFetchFrom = commitFromSummary ?? changeset.commit;\n\n if (commitToFetchFrom) {\n try {\n let {links} = await getInfo({\n repo: String(options.repository),\n commit: commitToFetchFrom,\n });\n\n commitLink = links.commit;\n pullRequestLink = links.pull ?? undefined;\n usersLink = links.user ?? undefined;\n } catch {\n commitLink = undefined;\n }\n }\n } else {\n let {links} = await getInfoFromPullRequest({\n repo: String(options.repository),\n pull: pullRequestFromSummary,\n });\n\n if (commitFromSummary) {\n links = {\n ...links,\n commit: `[\\`${commitFromSummary}\\`](https://github.com/${options.repository}/commit/${commitFromSummary})`,\n };\n }\n\n commitLink = links.commit ?? undefined;\n pullRequestLink = links.pull;\n usersLink = links.user ?? undefined;\n }\n\n if (usersFromSummary.length) {\n usersLink = usersFromSummary\n .map((userFromSummary) => `[@${userFromSummary}](https://github.com/${userFromSummary})`)\n .join(', ');\n }\n\n let prefix = [\n pullRequestLink ? ` ${pullRequestLink}` : '',\n commitLink ? ` ${commitLink}` : '',\n usersLink ? ` (${usersLink})` : '',\n ].join('');\n\n return `\\n\\n-${prefix ? `${prefix} –` : ''} ${firstLine}\\n${lines\n .map((line) => ` ${line}`)\n .join('\\n')}`;\n}\n"],"names":["getReleaseLine","changeset","type","options","repository","Error","pullRequestFromSummary","commitFromSummary","usersFromSummary","replacedChangelog","summary","replace","_","rawPullRequest","pullRequest","Number","isNaN","commit","user","push","trim","firstLine","lines","split","map","line","trimEnd","commitLink","pullRequestLink","usersLink","undefined","commitToFetchFrom","links","getInfo","repo","String","pull","getInfoFromPullRequest","length","userFromSummary","join","prefix"],"mappings":";+BAGsBA;;;eAAAA;;;+BAHwB;AAGvC,eAAeA,eACpBC,SAAiC,EACjCC,IAAiB,EACjBC,OAAiC;IAEjC,IAAI,CAACA,SAASC,YAAY;QACxB,MAAM,IAAIC,MACR;IAEJ;IAEA,IAAIC;IACJ,IAAIC;IACJ,IAAIC,mBAA6B,EAAE;IACnC,IAAIC,oBAAoBR,UAAUS,OAAO,CACtCC,OAAO,CAAC,gDAAgD,CAACC,GAAGC;QAC3D,IAAIC,cAAcC,OAAOF;QAEzB,IAAI,CAACE,OAAOC,KAAK,CAACF,cAAc;YAC9BR,yBAAyBQ;QAC3B;QAEA,OAAO;IACT,GACCH,OAAO,CAAC,0BAA0B,CAACC,GAAGK;QACrCV,oBAAoBU;QAEpB,OAAO;IACT,GACCN,OAAO,CAAC,qCAAqC,CAACC,GAAGM;QAChDV,iBAAiBW,IAAI,CAACD;QAEtB,OAAO;IACT,GACCE,IAAI;IACP,IAAI,CAACC,WAAW,GAAGC,MAAM,GAAGb,kBAAkBc,KAAK,CAAC,MAAMC,GAAG,CAAC,CAACC,OAASA,KAAKC,OAAO;IACpF,IAAIC;IACJ,IAAIC;IACJ,IAAIC;IAEJ,IAAIvB,2BAA2BwB,WAAW;QACxC,IAAIC,oBAAoBxB,qBAAqBN,UAAUgB,MAAM;QAE7D,IAAIc,mBAAmB;YACrB,IAAI;gBACF,IAAI,EAACC,KAAK,EAAC,GAAG,MAAMC,IAAAA,sBAAO,EAAC;oBAC1BC,MAAMC,OAAOhC,QAAQC,UAAU;oBAC/Ba,QAAQc;gBACV;gBAEAJ,aAAaK,MAAMf,MAAM;gBACzBW,kBAAkBI,MAAMI,IAAI,IAAIN;gBAChCD,YAAYG,MAAMd,IAAI,IAAIY;YAC5B,EAAE,OAAM;gBACNH,aAAaG;YACf;QACF;IACF,OAAO;QACL,IAAI,EAACE,KAAK,EAAC,GAAG,MAAMK,IAAAA,qCAAsB,EAAC;YACzCH,MAAMC,OAAOhC,QAAQC,UAAU;YAC/BgC,MAAM9B;QACR;QAEA,IAAIC,mBAAmB;YACrByB,QAAQ;gBACN,GAAGA,KAAK;gBACRf,QAAQ,CAAC,GAAG,EAAEV,kBAAkB,uBAAuB,EAAEJ,QAAQC,UAAU,CAAC,QAAQ,EAAEG,kBAAkB,CAAC,CAAC;YAC5G;QACF;QAEAoB,aAAaK,MAAMf,MAAM,IAAIa;QAC7BF,kBAAkBI,MAAMI,IAAI;QAC5BP,YAAYG,MAAMd,IAAI,IAAIY;IAC5B;IAEA,IAAItB,iBAAiB8B,MAAM,EAAE;QAC3BT,YAAYrB,iBACTgB,GAAG,CAAC,CAACe,kBAAoB,CAAC,EAAE,EAAEA,gBAAgB,qBAAqB,EAAEA,gBAAgB,CAAC,CAAC,EACvFC,IAAI,CAAC;IACV;IAEA,IAAIC,SAAS;QACXb,kBAAkB,CAAC,CAAC,EAAEA,gBAAgB,CAAC,GAAG;QAC1CD,aAAa,CAAC,CAAC,EAAEA,WAAW,CAAC,GAAG;QAChCE,YAAY,CAAC,EAAE,EAAEA,UAAU,CAAC,CAAC,GAAG;KACjC,CAACW,IAAI,CAAC;IAEP,OAAO,CAAC,KAAK,EAAEC,SAAS,CAAC,EAAEA,OAAO,EAAE,CAAC,GAAG,GAAG,CAAC,EAAEpB,UAAU,EAAE,EAAEC,MACzDE,GAAG,CAAC,CAACC,OAAS,CAAC,EAAE,EAAEA,KAAK,CAAC,EACzBe,IAAI,CAAC,MAAM,CAAC;AACjB"}
package/dist/main.js DELETED
@@ -1,20 +0,0 @@
1
- "use strict";
2
- const _dotenv = require("dotenv");
3
- _export_star(require("./getDependencyReleaseLine"), exports);
4
- _export_star(require("./getReleaseLine"), exports);
5
- function _export_star(from, to) {
6
- Object.keys(from).forEach(function(k) {
7
- if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) {
8
- Object.defineProperty(to, k, {
9
- enumerable: true,
10
- get: function() {
11
- return from[k];
12
- }
13
- });
14
- }
15
- });
16
- return from;
17
- }
18
- (0, _dotenv.config)();
19
-
20
- //# sourceMappingURL=main.js.map
package/dist/main.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/main.ts"],"sourcesContent":["import {config} from 'dotenv';\n\nconfig();\n\nexport * from './getDependencyReleaseLine';\nexport * from './getReleaseLine';\n"],"names":["config"],"mappings":";wBAAqB;qBAIP;qBACA;;;;;;;;;;;;;;AAHdA,IAAAA,cAAM"}
File without changes
File without changes