-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(cli): change default core ref to latest release (#712)
- Loading branch information
1 parent
5af4856
commit 8ad9d15
Showing
8 changed files
with
115 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@bigcommerce/create-catalyst": minor | ||
--- | ||
|
||
Change the default GitHub Ref that the CLI uses to clone `bigcommerce/catalyst-core` from `main` to latest published release (e.g., `@bigcommerce/[email protected]`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
module.exports = { | ||
transformIgnorePatterns: [], | ||
transform: { | ||
'^.+\\.(t|j)s?$': '@swc/jest', | ||
}, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
packages/create-catalyst/src/utils/get-latest-core-tag.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { http } from 'msw'; | ||
import { setupServer } from 'msw/node'; | ||
|
||
import { getLatestCoreTag } from './get-latest-core-tag'; | ||
|
||
const handlers = [ | ||
http.get( | ||
'https://raw.githubusercontent.com/bigcommerce/catalyst/main/apps/core/package.json', | ||
() => { | ||
return new Response('{ "name": "@bigcommerce/catalyst-core", "version": "0.1.0" }'); | ||
}, | ||
), | ||
]; | ||
|
||
const server = setupServer(...handlers); | ||
|
||
beforeAll(() => server.listen()); | ||
afterEach(() => server.resetHandlers()); | ||
afterAll(() => server.close()); | ||
|
||
describe('getLatestCoreTag', () => { | ||
it('should return the latest core tag', async () => { | ||
const latestTag = await getLatestCoreTag(); | ||
|
||
expect(latestTag).toBe('@bigcommerce/[email protected]'); | ||
}); | ||
|
||
it('should throw an error if the latest core tag is not found', async () => { | ||
server.use( | ||
http.get( | ||
'https://raw.githubusercontent.com/bigcommerce/catalyst/main/apps/core/package.json', | ||
() => { | ||
return new Response('{ "name": "@bigcommerce/catalyst-core" }'); | ||
}, | ||
), | ||
); | ||
|
||
await expect(getLatestCoreTag()).rejects.toThrow( | ||
'Unable to determine the latest valid Catalyst release', | ||
); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import * as z from 'zod'; | ||
|
||
export const getLatestCoreTag = async () => { | ||
const rawPackageJsonUrl = | ||
'https://raw.githubusercontent.com/bigcommerce/catalyst/main/apps/core/package.json'; | ||
|
||
const response = await fetch(rawPackageJsonUrl); | ||
|
||
try { | ||
const { version } = z.object({ version: z.string() }).parse(await response.json()); | ||
|
||
return `@bigcommerce/catalyst-core@${version}`; | ||
} catch (err) { | ||
throw new Error('Unable to determine the latest valid Catalyst release'); | ||
} | ||
}; |
Oops, something went wrong.