Skip to content

Commit 714363a

Browse files
committed
Revert "access output file"
This reverts commit 576278f.
1 parent 576278f commit 714363a

File tree

9 files changed

+23
-109
lines changed

9 files changed

+23
-109
lines changed

__tests__/main.test.ts

-15
Original file line numberDiff line numberDiff line change
@@ -53,21 +53,6 @@ describe('action', () => {
5353

5454
it('completes when there is a changeset entry for every package', async () => {
5555
// Arrange
56-
jest.spyOn(utils, 'getChangesets').mockImplementation(
57-
async (): Promise<utils.Changesets> =>
58-
Promise.resolve({
59-
releases: [
60-
{
61-
name: '@owner/pkg1',
62-
type: 'patch'
63-
},
64-
{
65-
name: '@owner/pkgB',
66-
type: 'patch'
67-
}
68-
]
69-
})
70-
)
7156
Object.defineProperty(github, 'context', {
7257
value: {
7358
...originalContext,

badges/coverage.svg

+1-1
Loading

dist/index.js

+10-52
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

json

-4
This file was deleted.

mock-workspace/fakechange

Whitespace-only changes.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
"devDependencies": {
7373
"@changesets/cli": "^2.26.2",
7474
"@types/jest": "^29.5.5",
75-
"@types/node": "^20.6.5",
75+
"@types/node": "^20.6.3",
7676
"@typescript-eslint/eslint-plugin": "^6.7.2",
7777
"@typescript-eslint/parser": "^6.7.2",
7878
"@vercel/ncc": "^0.38.0",

src/main.ts

+10-13
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import * as core from '@actions/core'
22
import * as exec from '@actions/exec'
33
import * as github from '@actions/github'
4-
import { getBaseAndHead, getChangesets } from './utils'
4+
import { getBaseAndHead } from './utils'
55

66
/**
77
* The main function for the action.
@@ -77,10 +77,9 @@ export async function run(): Promise<void> {
7777

7878
// right now, the only way to access JSON output is to create a file,
7979
// so we are just going to work with the pretty-printed output
80-
const filePath = `${github.context.runId}.json`
8180
await exec.exec(`yarn add @changesets/cli@latest -W`)
8281
const changesetResult = await exec.getExecOutput(
83-
`yarn changeset status --since origin/${base} --output ${filePath}`,
82+
`yarn changeset status --since origin/${base}`,
8483
undefined,
8584
{ ignoreReturnCode: true }
8685
)
@@ -92,16 +91,14 @@ export async function run(): Promise<void> {
9291
}
9392

9493
// parse out the package names from the pretty-printed changeset output
95-
let changesetEntries: string[] = []
96-
if (changesetResult.exitCode !== 1) {
97-
try {
98-
const changesets = await getChangesets(filePath)
99-
changesetEntries = changesets.releases.map(release => release.name)
100-
} catch (error) {
101-
core.setFailed(`Error parsing changeset file: ${error}`)
102-
return
103-
}
104-
}
94+
const changesetEntries =
95+
changesetResult.exitCode === 1
96+
? []
97+
: changesetResult.stdout
98+
.split('\n')
99+
.map((line: string) => line.trim())
100+
.filter((line: string) => line.startsWith('🦋 - '))
101+
.map((line: string) => line.replace('🦋 - ', ''))
105102

106103
const changesetEntriesNeeded = packageNamesArray.filter(
107104
packageName => !changesetEntries.includes(packageName)

src/utils.ts

-17
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { Context } from '@actions/github/lib/context'
2-
import * as fs from 'fs/promises'
32

43
export const getBaseAndHead = (context: Context): string[] => {
54
switch (context.eventName) {
@@ -14,19 +13,3 @@ export const getBaseAndHead = (context: Context): string[] => {
1413
}
1514
return []
1615
}
17-
18-
type Release = {
19-
name: string
20-
type: 'major' | 'minor' | 'patch'
21-
oldVersion?: string
22-
changeSets?: string[]
23-
}
24-
25-
export type Changesets = {
26-
releases: Release[]
27-
}
28-
29-
export const getChangesets = async (path: string): Promise<Changesets> => {
30-
const changesetsFile = await fs.readFile(path, 'utf8')
31-
return JSON.parse(changesetsFile) as Changesets
32-
}

yarn.lock

+1-6
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@
11041104
resolved "https://registry.yarnpkg.com/@types/minimist/-/minimist-1.2.2.tgz#ee771e2ba4b3dc5b372935d549fd9617bf345b8c"
11051105
integrity sha512-jhuKLIRrhvCPLqwPcx6INqmKeiA5EWrsCOPhrlFSrbrmU4ZMPjj5Ul/oLCMDO98XRUIwVm78xICz4EPCektzeQ==
11061106

1107-
"@types/node@*":
1107+
"@types/node@*", "@types/node@^20.6.3":
11081108
version "20.6.3"
11091109
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.6.3.tgz#5b763b321cd3b80f6b8dde7a37e1a77ff9358dd9"
11101110
integrity sha512-HksnYH4Ljr4VQgEy2lTStbCKv/P590tmPe5HqOnv9Gprffgv5WXAY+Y5Gqniu0GGqeTCUdBnzC3QSrzPkBkAMA==
@@ -1114,11 +1114,6 @@
11141114
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240"
11151115
integrity sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==
11161116

1117-
"@types/node@^20.6.5":
1118-
version "20.6.5"
1119-
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.6.5.tgz#4c6a79adf59a8e8193ac87a0e522605b16587258"
1120-
integrity sha512-2qGq5LAOTh9izcc0+F+dToFigBWiK1phKPt7rNhOqJSr35y8rlIBjDwGtFSgAI6MGIhjwOVNSQZVdJsZJ2uR1w==
1121-
11221117
"@types/normalize-package-data@^2.4.0":
11231118
version "2.4.1"
11241119
resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301"

0 commit comments

Comments
 (0)