Skip to content

Commit d980fb4

Browse files
committed
ACP2E-3864: Update copyrights for PB EE and fix static failures
1 parent 48f9c39 commit d980fb4

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

dev/dts-generator.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
const path = require('path');
77
const fs = require('fs');
8-
const prettier = require('prettier');
9-
const typesFile = 'page-builder-types/index.d.ts';
10-
const copyrightComment = `/**
8+
const prettier = require('prettier'),
9+
typesFile = 'page-builder-types/index.d.ts',
10+
copyrightComment = `/**
1111
* Copyright © Magento, Inc. All rights reserved.
1212
* See COPYING.txt for license details.
1313
*/`;
@@ -18,6 +18,7 @@ const copyrightComment = `/**
1818
* @param {string} currentModuleId
1919
* @returns {string}
2020
*/
21+
// eslint-disable-next-line strict
2122
function resolveModuleIdToMagentoPath(currentModuleId) {
2223
return currentModuleId.replace(
2324
'app/code/Magento/PageBuilder/view/adminhtml/web/ts/',
@@ -29,9 +30,11 @@ function resolveModuleIdToMagentoPath(currentModuleId) {
2930
require('dts-generator').default({
3031
project: './',
3132
out: typesFile,
33+
// eslint-disable-next-line strict
3234
resolveModuleId: (params) => {
3335
return resolveModuleIdToMagentoPath(params.currentModuleId);
3436
},
37+
// eslint-disable-next-line strict
3538
resolveModuleImport: (params) => {
3639
// Convert relative imports into their Magento counterparts
3740
if (params.importedModuleId.startsWith('../') || params.importedModuleId.startsWith('./')) {
@@ -48,11 +51,13 @@ require('dts-generator').default({
4851

4952
return params.importedModuleId;
5053
}
54+
// eslint-disable-next-line strict
5155
}).then(() => {
52-
const { exec } = require('child_process');
53-
// Lint the generated file
54-
const lint = exec(`./node_modules/tslint/bin/tslint --fix ${typesFile}`);
55-
lint.on("exit", () => {
56+
const { exec } = require('child_process'),
57+
// Lint the generated file
58+
lint = exec(`./node_modules/tslint/bin/tslint --fix ${typesFile}`);
59+
60+
lint.on('exit', () => {
5661
// Replace all tab characters with 4 spaces
5762
fs.readFile(typesFile, 'utf-8', (error, contents) => {
5863
if (error) {
@@ -61,9 +66,10 @@ require('dts-generator').default({
6166
let modifiedContents = contents
6267
.replace(/.*\/\*\*\n.*Copyright © Magento.*\n.*\n.*\*\//gm, '') // Strip all Magento copyright
6368
.replace(/.*\/\*\*\n.*@api.*\n.*\*\//gm, ''); // Strip all @api comments
69+
6470
modifiedContents = `${copyrightComment}\n${modifiedContents}`;
65-
fs.writeFile(typesFile, prettier.format(modifiedContents, {parser: "typescript"}), null, () => {
66-
console.log("Type definition generation completed.");
71+
fs.writeFile(typesFile, prettier.format(modifiedContents, {parser: 'typescript'}), null, () => {
72+
console.log('Type definition generation completed.');
6773
process.exit();
6874
});
6975
});

0 commit comments

Comments
 (0)