-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #40 from ckeditor/ck/adjust-version-typing
Feature: Add testing versions support to injector.
- Loading branch information
Showing
13 changed files
with
162 additions
and
18 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
import { isSemanticVersion, type SemanticVersion } from '../../utils/version/isSemanticVersion.js'; | ||
|
||
/** | ||
* A version of the CKEditor that is used for testing purposes. | ||
*/ | ||
export type CKCdnTestingVersion = | ||
| 'nightly' | ||
| 'alpha' | ||
| 'internal'; | ||
|
||
/** | ||
* A version of a file on the CKEditor CDN. | ||
*/ | ||
export type CKCdnVersion = | ||
| SemanticVersion | ||
| CKCdnTestingVersion; | ||
|
||
/** | ||
* Checks if the given string is a version of a file on the CKEditor CDN. | ||
* | ||
* @param version - The string to check. | ||
* @returns `true` if the string is a version of a file on the CKEditor CDN, `false` otherwise. | ||
* @example | ||
* ```ts | ||
* isCKCdnTestingVersion( '1.2.3-nightly-abc' ); // -> true | ||
* isCKCdnTestingVersion( '1.2.3-internal-abc' ); // -> true | ||
* isCKCdnTestingVersion( '1.2.3-alpha.1' ); // -> true | ||
* isCKCdnTestingVersion( '1.2.3' ); // -> false | ||
* isCKCdnTestingVersion( 'nightly' ); // -> true | ||
* ``` | ||
*/ | ||
export function isCKCdnTestingVersion( version: string | undefined ): version is CKCdnTestingVersion { | ||
if ( !version ) { | ||
return false; | ||
} | ||
|
||
return [ 'nightly', 'alpha', 'internal' ].some( testVersion => version.includes( testVersion ) ); | ||
} | ||
|
||
/** | ||
* Checks if the given string is a version of a file on the CKEditor CDN. | ||
* | ||
* @param version - The string to check. | ||
* @returns `true` if the string is a version of a file on the CKEditor CDN, `false` otherwise. | ||
* @example | ||
* ```ts | ||
* isCKCdnVersion( 'nightly' ); // -> true | ||
* isCKCdnVersion( 'alpha' ); // -> true | ||
* isCKCdnVersion( 'rc-1.2.3' ); // -> true | ||
* isCKCdnVersion( '1.2.3' ); // -> true | ||
* ``` | ||
*/ | ||
export function isCKCdnVersion( version: string | undefined ): version is CKCdnVersion { | ||
return isSemanticVersion( version ) || isCKCdnTestingVersion( version ); | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @license Copyright (c) 2003-2024, CKSource Holding sp. z o.o. All rights reserved. | ||
* For licensing, see LICENSE.md. | ||
*/ | ||
|
||
import { describe, it, expect } from 'vitest'; | ||
import { isCKCdnVersion, isCKCdnTestingVersion } from '@/cdn/ck/isCKCdnVersion.js'; | ||
|
||
const testCases = [ | ||
{ version: 'alpha', isTesting: true, isVersion: true }, | ||
{ version: 'nightly', isTesting: true, isVersion: true }, | ||
{ version: 'rc-1.2.3', isTesting: false, isVersion: false }, | ||
{ version: '1.2.3', isTesting: false, isVersion: true }, | ||
{ version: 'beta', isTesting: false, isVersion: false }, | ||
{ version: '1.2', isTesting: false, isVersion: false }, | ||
{ version: '0.0.0-nightly-20241104.0', isTesting: true, isVersion: true }, | ||
{ version: '0.0.0-internal-20241104.0', isTesting: true, isVersion: true }, | ||
{ version: '43.3.0-alpha.12 ', isTesting: true, isVersion: true } | ||
]; | ||
|
||
describe( 'isCKCdnTestingVersion', () => { | ||
for ( const { version, isTesting } of testCases ) { | ||
it( `should return ${ isTesting } for "${ version }"`, () => { | ||
expect( isCKCdnTestingVersion( version ) ).toBe( isTesting ); | ||
} ); | ||
} | ||
} ); | ||
|
||
describe( 'isCKCdnVersion', () => { | ||
for ( const { version, isVersion } of testCases ) { | ||
it( `should return ${ isVersion } for "${ version }"`, () => { | ||
expect( isCKCdnVersion( version ) ).toBe( isVersion ); | ||
} ); | ||
} | ||
} ); |
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