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

ckeditor / ckeditor5-package-generator / f4c99530-ae63-40a1-afbe-652cf7f886a6

19 Sep 2024 07:44AM UTC coverage: 100.0%. Remained the same
f4c99530-ae63-40a1-afbe-652cf7f886a6

Pull #189

circleci

web-flow
Bump express from 4.19.2 to 4.21.0

Bumps [express](https://github.com/expressjs/express) from 4.19.2 to 4.21.0.
- [Release notes](https://github.com/expressjs/express/releases)
- [Changelog](https://github.com/expressjs/express/blob/4.21.0/History.md)
- [Commits](https://github.com/expressjs/express/compare/4.19.2...4.21.0)

---
updated-dependencies:
- dependency-name: express
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #189: Bump express from 4.19.2 to 4.21.0

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/copy-files.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 chalk = require( 'chalk' );
13✔
9
const fs = require( 'fs' );
13✔
10
const glob = require( 'glob' );
13✔
11
const mkdirp = require( 'mkdirp' );
13✔
12
const path = require( 'path' );
13✔
13
const { template } = require( 'lodash' );
13✔
14

15
const TEMPLATE_PATH = path.join( __dirname, '..', 'templates' );
13✔
16

17
/**
18
 * If the package name is not valid, prints the error and exits the process.
19
 *
20
 * @param {Logger} logger
21
 * @param {Object} options
22
 * @param {String} options.packageName
23
 * @param {FormattedNames} options.formattedNames
24
 * @param {String} options.directoryPath
25
 * @param {String} options.packageManager
26
 * @param {String} options.programmingLanguage
27
 * @param {Object} options.packageVersions
28
 * @param {String} options.installationMethodOfPackage
29
 * @param {String} options.validatedGlobalName
30
 */
31
module.exports = function copyFiles( logger, options ) {
13✔
32
        logger.process( 'Copying files...' );
12✔
33

34
        const supportsLegacyMethods = options.installationMethodOfPackage !== 'current';
12✔
35
        const templatePatternToCopy = `${ options.programmingLanguage }${ supportsLegacyMethods ? '-legacy' : '' }/**/*`;
12✔
36

37
        const templateGlobs = [
12✔
38
                'common/**/*',
39
                templatePatternToCopy
40
        ];
41

42
        const templatesToCopy = templateGlobs.flatMap( globPattern => {
12✔
43
                return glob.sync( globPattern, {
24✔
44
                        cwd: TEMPLATE_PATH,
45
                        dot: true,
46
                        nodir: true
47
                } );
48
        } );
49

50
        for ( const templatePath of templatesToCopy ) {
12✔
51
                logger.verboseInfo( `* Copying "${ chalk.gray( templatePath ) }"...` );
50✔
52

53
                const data = {
50✔
54
                        cliSeparator: options.packageManager === 'npm' ? '-- ' : '',
50✔
55
                        now: new Date(),
56
                        ...options
57
                };
58

59
                copyTemplate( templatePath, options.directoryPath, data );
50✔
60
        }
61
};
62

63
/**
64
 * Copies all files into the package directory. If any file has any template placeholders, they are filled.
65
 *
66
 * @param {String} templatePath The relative path to the "templates/" directory of the file to copy.
67
 * @param {String} packagePath The destination directory where the new package is created.
68
 * @param {Object} data The data to fill in the template file.
69
 */
70
function copyTemplate( templatePath, packagePath, data ) {
71
        const rawFile = fs.readFileSync( path.join( TEMPLATE_PATH, templatePath ), 'utf-8' );
50✔
72
        const filledFile = template( rawFile )( data );
50✔
73

74
        const processedTemplatePath = templatePath
50✔
75
                // Remove sub-directory inside templates to merge results into one directory.
76
                .replace( /^(?:common|js|ts|js-legacy|ts-legacy)(?:\\|\/)/, '' )
77
                // We use the ".txt" file extension to circumvent syntax errors in templates and npm not publishing the ".gitignore" file.
78
                .replace( /\.txt$/, '' )
79
                // Replace placeholder filenames with the class name.
80
                .replace( /_PLACEHOLDER_/, data.formattedNames.plugin.lowerCaseMerged );
81

82
        const destinationPath = path.join( packagePath, processedTemplatePath );
50✔
83

84
        // Make sure that the destination directory exists.
85
        mkdirp.sync( path.dirname( destinationPath ) );
50✔
86
        fs.writeFileSync( destinationPath, filledFile );
50✔
87
}
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