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

ckeditor / ckeditor5-package-generator / 983

pending completion
983

cron

travis-ci-com

web-flow
Merge pull request #134 from ckeditor/ci/2269

Internal: Use `ckeditor5-dev-ci-notify-travis-status` script from new package `ckeditor5-dev-ci`.

111 of 111 branches covered (100.0%)

Branch coverage included in aggregate %.

412 of 412 relevant lines covered (100.0%)

8.13 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-2022, 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
                spacedOut: toSpacedOut( parts ),
42
                camelCase: toCamelCase( parts ),
43
                pascalCase: toPascalCase( parts ),
44
                lowerCaseMerged: parts.join( '' )
45
        };
46
}
47

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

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

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

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

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

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

90
/**
91
 * @typedef {Object} FormattedName
92
 *
93
 * @property {String} raw: super-feature-name
94
 *
95
 * @property {String} spacedOut Super plugin name
96
 *
97
 * @property {String} camelCase superPluginName
98
 *
99
 * @property {String} pascalCase SuperPluginName
100
 *
101
 * @property {String} lowerCaseMerged superpluginname
102
 */
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