Skip to content

Commit

Permalink
fix: update SemanticRelease types import
Browse files Browse the repository at this point in the history
  • Loading branch information
ph-fritsche committed Mar 23, 2023
1 parent c8a9e50 commit fee1fe8
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as core from '@actions/core'
import type SemanticRelease from 'semantic-release'
import type * as SemanticRelease from 'semantic-release'
import defaultConfig from './defaultConfig'
import { install } from './util/install'
import { forceRelease, initialRelease } from './plugin'
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/forceRelease.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type SemanticRelease from 'semantic-release'
import type * as SemanticRelease from 'semantic-release'
import type { PluginConfig } from '../semantic-release'
import { getReleaseType, releaseTypes } from './shared/releaseTypes'

Expand Down
2 changes: 1 addition & 1 deletion src/plugin/initialRelease.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type SemanticRelease from 'semantic-release'
import type * as SemanticRelease from 'semantic-release'
import type { PluginConfig } from '../semantic-release'
import { releaseTypes } from './shared/releaseTypes'

Expand Down
2 changes: 1 addition & 1 deletion src/semantic-release.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import SemanticRelease from 'semantic-release'
import type * as SemanticRelease from 'semantic-release'

export type PluginConfig = {
[k: string]: unknown,
Expand Down
2 changes: 1 addition & 1 deletion test/_releaseResult.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import SemanticRelease from 'semantic-release'
import * as SemanticRelease from 'semantic-release'

// see https://github.com/semantic-release/semantic-release/blob/master/docs/developer-guide/js-api.md
export default {
Expand Down
2 changes: 1 addition & 1 deletion test/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ it('import with side-effect', async () => {
run = jest.fn(() => Promise.resolve())

return import('../src/action').then(() => {
expect(run).toBeCalled()
expect(run).toHaveBeenCalled()
})
})
16 changes: 8 additions & 8 deletions test/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type SemanticRelease from 'semantic-release'
import type * as SemanticRelease from 'semantic-release'
import run from '../src/index'
import { forceRelease, initialRelease } from '../src/plugin'
import defaultResult from './_releaseResult'
Expand Down Expand Up @@ -92,7 +92,7 @@ it('run with dry run option', () => {

return run.finally(() => {
expect(coreDebug).toEqual(expect.arrayContaining(['DRY RUN']))
expect(release).toBeCalledTimes(1)
expect(release).toHaveBeenCalledTimes(1)
expect(release.mock.calls[0][0]).toMatchObject({dryRun: true})
})
})
Expand All @@ -103,8 +103,8 @@ it('run with debug option', () => {
const run = exec({debug: 'true'})

return run.finally(() => {
expect(debugEnable).toBeCalled()
expect(release).toBeCalled()
expect(debugEnable).toHaveBeenCalled()
expect(release).toHaveBeenCalled()
})
})

Expand Down Expand Up @@ -135,7 +135,7 @@ it('setup forceRelease plugin', () => {
const run = exec({force: 'foobar'})

return run.finally(() => {
expect(release).toBeCalledTimes(1)
expect(release).toHaveBeenCalledTimes(1)
expect(release.mock.calls[0][0]).toMatchObject({
plugins: expect.arrayContaining([forceRelease]),
})
Expand All @@ -153,7 +153,7 @@ it('setup initialRelease plugin', () => {
const run = exec()

return run.finally(() => {
expect(release).toBeCalledTimes(1)
expect(release).toHaveBeenCalledTimes(1)
expect(release.mock.calls[0][0]).toMatchObject({
plugins: expect.arrayContaining([initialRelease]),
})
Expand Down Expand Up @@ -211,8 +211,8 @@ it('call updateTag', () => {
}})

return run.finally(() => {
expect(gitConfig).toBeCalled()
expect(updateTags).toBeCalledWith('HEAD', '1.2.3-foo.1', {
expect(gitConfig).toHaveBeenCalled()
expect(updateTags).toHaveBeenCalledWith('HEAD', '1.2.3-foo.1', {
major: '1',
minor: '2',
patch: '3',
Expand Down
6 changes: 3 additions & 3 deletions test/plugin/forceRelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ it('Return sanitized force release value', async () => {
const { exec, logger } = setup(forceRelease.analyzeCommits)

expect(await exec({}, {env: {RELEASE_FORCE: 'foo'}})).toBe('patch')
expect(logger.log).toBeCalledWith('Force release: %s', 'patch')
expect(logger.log).toHaveBeenCalledWith('Force release: %s', 'patch')

expect(await exec({}, {env: {RELEASE_FORCE: ''}})).toBe(null)
expect(logger.log).not.toBeCalled()
expect(logger.log).not.toHaveBeenCalled()

expect(await exec({}, {env: {RELEASE_FORCE: 'major'}})).toBe('major')
expect(logger.log).toBeCalledWith('Force release: %s', 'major')
expect(logger.log).toHaveBeenCalledWith('Force release: %s', 'major')
})
4 changes: 2 additions & 2 deletions test/plugin/initialRelease.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ it('Return "patch" for initial release', async () => {
const { exec, logger } = setup(initialRelease.analyzeCommits)

expect(await exec({}, {})).toBe('patch')
expect(logger.log).toBeCalledWith('Initial release')
expect(logger.log).toHaveBeenCalledWith('Initial release')

expect(await exec({}, {lastRelease: {gitHead: 'abcdef...', gitTag: 'v1.2.3', version: '1.2.3'}})).toBe(null)
expect(logger.log).not.toBeCalled()
expect(logger.log).not.toHaveBeenCalled()
})
6 changes: 3 additions & 3 deletions test/util/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test('skip present modules', async () => {

expect(resolveMock).toHaveBeenNthCalledWith(1, 'foo')
expect(resolveMock).toHaveBeenNthCalledWith(2, 'bar')
expect(spawnMock).not.toBeCalled()
expect(spawnMock).not.toHaveBeenCalled()
expect(log).toEqual(expect.arrayContaining([
expect.stringMatching('"foo" resolved'),
expect.stringMatching('"bar" resolved'),
Expand All @@ -37,7 +37,7 @@ test('install missing modules', async () => {

expect(resolveMock).toHaveBeenNthCalledWith(1, 'foo')
expect(resolveMock).toHaveBeenNthCalledWith(2, 'bar')
expect(spawnMock).toBeCalledTimes(1)
expect(spawnMock).toHaveBeenCalledTimes(1)
expect(spawnMock.mock.calls[0][0]).toBe('npm')
expect(spawnMock.mock.calls[0][1][0]).toBe('install')
expect(spawnMock.mock.calls[0][1]).toContain('foo')
Expand All @@ -50,7 +50,7 @@ test('install in dist', async () => {

await install(['foo'], () => undefined)

expect(spawnMock).toBeCalledTimes(1)
expect(spawnMock).toHaveBeenCalledTimes(1)
expect(spawnMock.mock.calls[0][2]).toEqual(expect.objectContaining({
// In test this should be the directory of the `install` util
cwd: path.resolve(__dirname, '../../src/util'),
Expand Down
4 changes: 2 additions & 2 deletions test/util/spawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ test('defer args and options', () => {

const child = spawn('foo', ['bar', 'baz'], {uid: 123456})

expect(spawnMock).toBeCalledWith('foo', ['bar', 'baz'], {uid: 123456})
expect(spawnMock).toHaveBeenCalledWith('foo', ['bar', 'baz'], {uid: 123456})

return expect(child).resolves.toBe('')
})
Expand All @@ -35,7 +35,7 @@ test('reject on spawn error', () => {

const child = spawn('foo', ['bar', 'baz'], {uid: 123456})

expect(spawnMock).toBeCalledWith('foo', ['bar', 'baz'], {uid: 123456})
expect(spawnMock).toHaveBeenCalledWith('foo', ['bar', 'baz'], {uid: 123456})

return expect(child).rejects.toMatch('ENOSUP')
})
Expand Down

0 comments on commit fee1fe8

Please sign in to comment.