• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ckeditor / ckeditor5-package-generator / 4c42dc7e-c078-4dd0-a5de-abdaf729fc09

09 Sep 2024 11:40AM UTC coverage: 100.0%. Remained the same
4c42dc7e-c078-4dd0-a5de-abdaf729fc09

push

circleci

web-flow
Merge pull request #187 from ckeditor/ci/3756

Other (generator): Replaced Karma with Vitest as the testing framework in the generated package.

Other (tools): Removed support for the `--coverage` (`-c`) and `--source-map` (`-s`) flags.

Other (tools): Removed `test` script from the tools, because unit tests in the generated package are executed now directly by Vitest.

MINOR BREAKING CHANGE (generator): The generated package no longer uses Karma as the test runner. Instead, Vitest is used.

MINOR BREAKING CHANGE (tools): The `test` script is removed, because unit tests in the generated package are executed directly by Vitest. Hence, the previous custom support for the `--coverage` (`-c`) and `--source-map` (`-s`) flags is no longer needed and has been also removed. The `yarn run test` (or `npm run test`) script is still available in the generated package, but it executes Vitest. See [CLI flags](https://vitest.dev/guide/cli.html) supported in Vitest.

120 of 120 branches covered (100.0%)

Branch coverage included in aggregate %.

393 of 393 relevant lines covered (100.0%)

9.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/packages/ckeditor5-package-generator/lib/utils/get-package-name-formats.js
1
/**
2
 * @license Copyright (c) 2020-2024, CKSource Holding sp. z o.o. All rights reserved.
3
 * For licensing, see LICENSE.md.
4
 */
5

6
'use strict';
7

8
const PARTS_REGEXP = /[0-9]+|[A-Za-z][a-z]*/g;
1✔
9

10
/**
11
 * This function returns an object with two properties: "package" and "plugin". Values of those properties
12
 * are object that contain the names formatted in different formats. If "pluginName" was not provided,
13
 * values for "plugin" will be the same as the "package" ones.
14
 *
15
 * @param {String} packageName
16
 * @param {String|undefined} pluginName
17
 * @returns {FormattedNames}
18
 */
19
module.exports = function getPackageNameFormats( packageName, pluginName ) {
1✔
20
        return {
10✔
21
                package: format( packageName ),
22
                plugin: format( pluginName || packageName )
16✔
23
        };
24
};
25

26
/**
27
 * @param {String} name
28
 * @returns {FormattedName}
29
 */
30
function format( name ) {
31
        // Removing the scope and prefix in case of the package name.
32
        const raw = name.split( 'ckeditor5-' ).pop();
20✔
33

34
        // Separating the name into its components.
35
        const parts = raw.match( PARTS_REGEXP )
20✔
36
                // Unifying letter size in case of the plugin name.
37
                .map( part => part.toLowerCase() );
47✔
38

39
        return {
20✔
40
                raw,
41
                fullName: name,
42
                spacedOut: toSpacedOut( parts ),
43
                camelCase: toCamelCase( parts ),
44
                pascalCase: toPascalCase( parts ),
45
                lowerCaseMerged: parts.join( '' )
46
        };
47
}
48

49
/**
50
 * @param {Array<String>} parts
51
 * @returns {String}
52
 */
53
function toPascalCase( parts ) {
54
        return parts.map( uppercaseFirstChar ).join( '' );
40✔
55
}
56

57
/**
58
 * @param {Array<String>} parts
59
 * @returns {String}
60
 */
61
function toCamelCase( parts ) {
62
        const pascalCase = toPascalCase( parts );
20✔
63

64
        return pascalCase.charAt( 0 ).toLowerCase() + pascalCase.slice( 1 );
20✔
65
}
66

67
/**
68
 * @param {Array<String>} parts
69
 * @returns {String}
70
 */
71
function toSpacedOut( parts ) {
72
        return uppercaseFirstChar( parts.join( ' ' ) );
20✔
73
}
74

75
/**
76
 * @param {String} string
77
 * @returns {String}
78
 */
79
function uppercaseFirstChar( string ) {
80
        return string.charAt( 0 ).toUpperCase() + string.slice( 1 );
114✔
81
}
82

83
/**
84
 * @typedef {Object} FormattedNames
85
 *
86
 * @property {FormattedName} package
87
 *
88
 * @property {FormattedName} plugin
89
 */
90

91
/**
92
 * @typedef {Object} FormattedName
93
 *
94
 * @property {String} raw super-feature-name
95
 *
96
 * @property {String} full @scope/ckeditor5-super-feature-name
97
 *
98
 * @property {String} spacedOut Super feature name
99
 *
100
 * @property {String} camelCase superFeatureName
101
 *
102
 * @property {String} pascalCase SuperFeatureName
103
 *
104
 * @property {String} lowerCaseMerged superfeaturename
105
 */
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc