-
Notifications
You must be signed in to change notification settings - Fork 991
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(studio): Add version checks when first running Studio (#9876)
* Only specify major version when installing Studio, so we always get the latest non-breaking features and bug fixes * Make sure the user's RW version is compatible with the version of Studio we're installing. Right now we're very specific with what version of RW we support, down to the canary version level. Reason is we need the new server-file stuff that was introduced in an earlier canary version
- Loading branch information
Showing
3 changed files
with
232 additions
and
10 deletions.
There are no files selected for viewing
149 changes: 149 additions & 0 deletions
149
packages/cli/src/commands/__tests__/studioHandler.test.js
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,149 @@ | ||
// Have to use `var` here to avoid "Temporal Dead Zone" issues | ||
// eslint-disable-next-line | ||
var mockedRedwoodVersion = '0.0.0' | ||
|
||
jest.mock('@redwoodjs/project-config', () => ({ | ||
getPaths: () => ({ base: '' }), | ||
})) | ||
|
||
jest.mock('fs-extra', () => ({ | ||
readJSONSync: () => ({ | ||
devDependencies: { | ||
'@redwoodjs/core': mockedRedwoodVersion, | ||
}, | ||
}), | ||
})) | ||
|
||
import { assertRedwoodVersion } from '../studioHandler' | ||
|
||
describe('studioHandler', () => { | ||
describe('assertRedwoodVersion', () => { | ||
const exitSpy = jest.spyOn(process, 'exit').mockImplementation((code) => { | ||
throw new Error(`process.exit(${code})`) | ||
}) | ||
|
||
jest.spyOn(console, 'error').mockImplementation() | ||
|
||
afterEach(() => { | ||
jest.clearAllMocks() | ||
}) | ||
|
||
afterAll(() => { | ||
jest.restoreAllMocks() | ||
}) | ||
|
||
const minVersions = ['7.0.0-canary.874', '7.x', '8.0.0-0'] | ||
|
||
it('exits on RW v6', () => { | ||
mockedRedwoodVersion = '6.6.2' | ||
|
||
expect(() => assertRedwoodVersion(minVersions)).toThrow() | ||
expect(exitSpy).toHaveBeenCalledWith(1) | ||
}) | ||
|
||
it('exits on RW v7.0.0-canary.785', () => { | ||
mockedRedwoodVersion = '7.0.0-canary.785' | ||
|
||
expect(() => assertRedwoodVersion(minVersions)).toThrow() | ||
expect(exitSpy).toHaveBeenCalledWith(1) | ||
}) | ||
|
||
it('exits on RW v7.0.0-canary.785+fcb9d66b5', () => { | ||
mockedRedwoodVersion = '7.0.0-canary.785+fcb9d66b5' | ||
|
||
expect(() => assertRedwoodVersion(minVersions)).toThrow() | ||
expect(exitSpy).toHaveBeenCalledWith(1) | ||
}) | ||
|
||
it('exits on RW v0.0.0-experimental.999', () => { | ||
mockedRedwoodVersion = '0.0.0-experimental.999' | ||
|
||
expect(() => assertRedwoodVersion(minVersions)).toThrow() | ||
expect(exitSpy).toHaveBeenCalledWith(1) | ||
}) | ||
|
||
it('exits on RW v7.0.0-alpha.999', () => { | ||
mockedRedwoodVersion = '7.0.0-alpha.999' | ||
|
||
expect(() => assertRedwoodVersion(minVersions)).toThrow() | ||
expect(exitSpy).toHaveBeenCalledWith(1) | ||
}) | ||
|
||
it('exits on RW v7.0.0-rc.999', () => { | ||
mockedRedwoodVersion = '7.0.0-rc.999' | ||
|
||
expect(() => assertRedwoodVersion(minVersions)).toThrow() | ||
expect(exitSpy).toHaveBeenCalledWith(1) | ||
}) | ||
|
||
it('allows RW v7.0.0-canary.874', () => { | ||
mockedRedwoodVersion = '7.0.0-canary.874' | ||
|
||
expect(() => assertRedwoodVersion(minVersions)).not.toThrow() | ||
expect(exitSpy).not.toHaveBeenCalled() | ||
}) | ||
|
||
it('allows RW v7.0.0-canary.874+fcb9d66b5', () => { | ||
mockedRedwoodVersion = '7.0.0-canary.874+fcb9d66b5' | ||
|
||
expect(() => assertRedwoodVersion(minVersions)).not.toThrow() | ||
expect(exitSpy).not.toHaveBeenCalled() | ||
}) | ||
|
||
it('allows RW v7.0.0', () => { | ||
mockedRedwoodVersion = '7.0.0' | ||
|
||
expect(() => assertRedwoodVersion(minVersions)).not.toThrow() | ||
expect(exitSpy).not.toHaveBeenCalled() | ||
}) | ||
|
||
it('allows RW v8.0.0', () => { | ||
mockedRedwoodVersion = '8.0.0' | ||
|
||
expect(() => assertRedwoodVersion(minVersions)).not.toThrow() | ||
expect(exitSpy).not.toHaveBeenCalled() | ||
}) | ||
|
||
it('allows RW v7.0.1', () => { | ||
mockedRedwoodVersion = '7.0.1' | ||
|
||
expect(() => assertRedwoodVersion(minVersions)).not.toThrow() | ||
expect(exitSpy).not.toHaveBeenCalled() | ||
}) | ||
|
||
it('allows RW v8.0.0-canary.1', () => { | ||
mockedRedwoodVersion = '8.0.0-canary.1' | ||
|
||
expect(() => assertRedwoodVersion(minVersions)).not.toThrow() | ||
expect(exitSpy).not.toHaveBeenCalled() | ||
}) | ||
|
||
it('allows RW v8.0.0-rc.1', () => { | ||
mockedRedwoodVersion = '8.0.0-rc.1' | ||
|
||
expect(() => assertRedwoodVersion(minVersions)).not.toThrow() | ||
expect(exitSpy).not.toHaveBeenCalled() | ||
}) | ||
|
||
it('allows RW v8.0.0', () => { | ||
mockedRedwoodVersion = '8.0.0' | ||
|
||
expect(() => assertRedwoodVersion(minVersions)).not.toThrow() | ||
expect(exitSpy).not.toHaveBeenCalled() | ||
}) | ||
|
||
it('allows RW v8.0.1', () => { | ||
mockedRedwoodVersion = '8.0.1' | ||
|
||
expect(() => assertRedwoodVersion(minVersions)).not.toThrow() | ||
expect(exitSpy).not.toHaveBeenCalled() | ||
}) | ||
|
||
it('allows RW v9.1.0', () => { | ||
mockedRedwoodVersion = '9.1.0' | ||
|
||
expect(() => assertRedwoodVersion(minVersions)).not.toThrow() | ||
expect(exitSpy).not.toHaveBeenCalled() | ||
}) | ||
}) | ||
}) |
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