@changesets/read
Advanced tools
| import { NewChangeset } from "@changesets/types"; | ||
| //#region src/index.d.ts | ||
| declare function readChangesets(rootDir: string, sinceRef?: string): Promise<Array<NewChangeset>>; | ||
| /** @deprecated Use named export `readChangesets` instead */ | ||
| declare const readChangesetsDefault: typeof readChangesets; | ||
| //#endregion | ||
| export { readChangesetsDefault as default, readChangesets }; |
| import fs from "node:fs/promises"; | ||
| import path from "node:path"; | ||
| import * as git from "@changesets/git"; | ||
| import { parseChangesetFile } from "@changesets/parse"; | ||
| //#region src/index.ts | ||
| async function filterChangesetsSinceRef(changesets, changesetBase, sinceRef) { | ||
| const newHashes = (await git.getChangedChangesetFilesSinceRef({ | ||
| cwd: changesetBase, | ||
| ref: sinceRef | ||
| })).map((c) => c.split("/").pop()); | ||
| return changesets.filter((dir) => newHashes.includes(dir)); | ||
| } | ||
| async function readChangesets(rootDir, sinceRef) { | ||
| const changesetBase = path.join(rootDir, ".changeset"); | ||
| let contents; | ||
| try { | ||
| contents = await fs.readdir(changesetBase); | ||
| } catch (err) { | ||
| if (err.code === "ENOENT") throw new Error("There is no .changeset directory in this project", { cause: err }); | ||
| throw err; | ||
| } | ||
| if (sinceRef != null) contents = await filterChangesetsSinceRef(contents, changesetBase, sinceRef); | ||
| const changesetContents = contents.filter((file) => !file.startsWith(".") && file.endsWith(".md") && !/^README\.md$/i.test(file)).map(async (file) => { | ||
| return { | ||
| ...parseChangesetFile(await fs.readFile(path.join(changesetBase, file), "utf8")), | ||
| id: file.replace(".md", "") | ||
| }; | ||
| }); | ||
| return await Promise.all(changesetContents); | ||
| } | ||
| /** @deprecated Use named export `readChangesets` instead */ | ||
| const readChangesetsDefault = readChangesets; | ||
| //#endregion | ||
| export { readChangesetsDefault as default, readChangesets }; |
| import { defineConfig } from "tsdown/config"; | ||
| import { baseConfig } from "../../tsdown.config.ts"; | ||
| export default defineConfig(baseConfig); |
+11
-0
| # @changesets/read | ||
| ## 1.0.0-next.4 | ||
| ### Patch Changes | ||
| - [#2004](https://github.com/changesets/changesets/pull/2004) [`169b128`](https://github.com/changesets/changesets/commit/169b128522f0e53ef228f3acd8118709b0f72156) Thanks [@ghostdevv](https://github.com/ghostdevv)! - Replace `picocolors` with `node:util`'s `styleText` | ||
| - Updated dependencies [[`062530b`](https://github.com/changesets/changesets/commit/062530b825d53abc9d8934f3a50cc61ff3ff82b8)]: | ||
| - @changesets/types@7.0.0-next.4 | ||
| - @changesets/git@4.0.0-next.4 | ||
| - @changesets/parse@1.0.0-next.4 | ||
| ## 1.0.0-next.3 | ||
@@ -4,0 +15,0 @@ |
+13
-10
| { | ||
| "name": "@changesets/read", | ||
| "version": "1.0.0-next.3", | ||
| "version": "1.0.0-next.4", | ||
| "description": "Read changesets from disc, and return the information as JSON", | ||
| "license": "MIT", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/changesets/changesets.git", | ||
| "directory": "packages/read" | ||
| }, | ||
| "type": "module", | ||
| "exports": { | ||
| ".": "./dist/changesets-read.js", | ||
| ".": "./dist/index.mjs", | ||
| "./package.json": "./package.json" | ||
| }, | ||
| "license": "MIT", | ||
| "repository": "https://github.com/changesets/changesets/tree/main/packages/read", | ||
| "dependencies": { | ||
| "picocolors": "^1.1.0", | ||
| "@changesets/git": "^4.0.0-next.3", | ||
| "@changesets/parse": "^1.0.0-next.3", | ||
| "@changesets/types": "^7.0.0-next.3" | ||
| "@changesets/git": "^4.0.0-next.4", | ||
| "@changesets/types": "^7.0.0-next.4", | ||
| "@changesets/parse": "^1.0.0-next.4" | ||
| }, | ||
| "devDependencies": { | ||
| "outdent": "^0.8.0", | ||
| "@changesets/test-utils": "0.0.9-next.3", | ||
| "@changesets/write": "1.0.0-next.3" | ||
| "@changesets/write": "1.0.0-next.4", | ||
| "@changesets/test-utils": "0.0.9-next.3" | ||
| }, | ||
@@ -23,0 +26,0 @@ "engines": { |
@@ -7,3 +7,3 @@ import fs from "node:fs/promises"; | ||
| import { describe, expect, it } from "vitest"; | ||
| import read from "./index.ts"; | ||
| import { readChangesets as read } from "./index.ts"; | ||
@@ -10,0 +10,0 @@ silenceLogsInBlock(); |
| export * from "./declarations/src/index.js"; | ||
| export { default } from "./declarations/src/index.js"; | ||
| //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2hhbmdlc2V0cy1yZWFkLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuL2RlY2xhcmF0aW9ucy9zcmMvaW5kZXguZC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSJ9 |
| import fs from 'node:fs/promises'; | ||
| import path from 'node:path'; | ||
| import * as git from '@changesets/git'; | ||
| import { parseChangesetFile } from '@changesets/parse'; | ||
| async function filterChangesetsSinceRef(changesets, changesetBase, sinceRef) { | ||
| const newChangesets = await git.getChangedChangesetFilesSinceRef({ | ||
| cwd: changesetBase, | ||
| ref: sinceRef | ||
| }); | ||
| const newHashes = newChangesets.map(c => c.split("/").pop()); | ||
| return changesets.filter(dir => newHashes.includes(dir)); | ||
| } | ||
| async function readChangesets(rootDir, sinceRef) { | ||
| const changesetBase = path.join(rootDir, ".changeset"); | ||
| let contents; | ||
| try { | ||
| contents = await fs.readdir(changesetBase); | ||
| } catch (err) { | ||
| if (err.code === "ENOENT") { | ||
| throw new Error("There is no .changeset directory in this project", { | ||
| cause: err | ||
| }); | ||
| } | ||
| throw err; | ||
| } | ||
| if (sinceRef != null) { | ||
| contents = await filterChangesetsSinceRef(contents, changesetBase, sinceRef); | ||
| } | ||
| const changesets = contents.filter(file => !file.startsWith(".") && file.endsWith(".md") && !/^README\.md$/i.test(file)); | ||
| const changesetContents = changesets.map(async file => { | ||
| const changeset = await fs.readFile(path.join(changesetBase, file), "utf8"); | ||
| return { | ||
| ...parseChangesetFile(changeset), | ||
| id: file.replace(".md", "") | ||
| }; | ||
| }); | ||
| return await Promise.all(changesetContents); | ||
| } | ||
| /** @deprecated Use named export `readChangesets` instead */ | ||
| const readChangesetsDefault = readChangesets; | ||
| export { readChangesetsDefault as default, readChangesets }; |
| import type { NewChangeset } from "@changesets/types"; | ||
| export declare function readChangesets(rootDir: string, sinceRef?: string): Promise<Array<NewChangeset>>; | ||
| /** @deprecated Use named export `readChangesets` instead */ | ||
| declare const readChangesetsDefault: typeof readChangesets; | ||
| export default readChangesetsDefault; |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
30584
0.97%3
-25%1
-50%308
-3.75%- Removed
- Removed