Skip to content

Commit

Permalink
feat(service-navigation/toolchain): add logging to scripts
Browse files Browse the repository at this point in the history
OUI-3209
  • Loading branch information
gillerr authored and nina-egger committed Oct 1, 2024
1 parent dc24191 commit e37e512
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
3 changes: 3 additions & 0 deletions projects/service-navigation-web-component/scripts/lint.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import {hasFlag} from '../../../scripts/shared/utils';
import {Lint} from '../../../scripts/shared/lint';
import {Log} from '../../../scripts/shared/log';

Log.start('Lint Service Navigation Web Component project');
Lint.initialize(hasFlag('fix'))
.esLint('**/*.{ts,js,html}', '.eslintrc.local.yml')
.styleLint('**/*.{css,scss}')
.prettier('**/*.{ts,js,html,json,yml,md,css,scss}')
.finalize();
Log.success();
16 changes: 11 additions & 5 deletions projects/service-navigation-web-component/scripts/post-dist.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
import {readFileSync, readdirSync, rmSync, statSync, unlinkSync, writeFileSync} from 'fs';
import path from 'path';
import {PackageJson} from '../../../scripts/shared/package-json';
import {adaptReadmeLinks, listFiles} from '../../../scripts/shared/utils';
import {adaptReadmeLinks, humanizeList, listFiles} from '../../../scripts/shared/utils';
import {Banner} from '../../../scripts/shared/banner';
import {CopyFiles} from '../../../scripts/shared/copy-files';
import {StaticScript} from '../../../scripts/shared/static-script';
import {Log} from '../../../scripts/shared/log';

export class PostDist extends StaticScript {
static perform(): void {
Log.start('Finalize build');
PostDist.adaptPackageJson();
PostDist.pack();
PostDist.addBanner();
Expand All @@ -16,6 +18,7 @@ export class PostDist extends StaticScript {
.copyProjectRootFiles('README.md', 'CHANGELOG.md')
.finalize();
adaptReadmeLinks('service-navigation-web-component');
Log.success();
}

private static adaptPackageJson(): void {
Expand All @@ -39,20 +42,23 @@ export class PostDist extends StaticScript {
}

private static packJsFiles(directory: string, packFileName: string): void {
const content = ['runtime.js', 'polyfills.js', 'main.js']
const files = ['runtime.js', 'polyfills.js', 'main.js'];
Log.info(`Pack ${humanizeList(files)} files together`);
const content = files
.map(fileName => `${directory}/${fileName}`)
.map(filePath => readFileSync(filePath).toString())
.reduce((total, currentFile) => total + currentFile, '');
writeFileSync(path.join(directory, packFileName), content);
}

private static removeUnwantedFiles(directory: string, packFileName: string): void {
listFiles(directory)
.filter(filePath => !new RegExp(`${packFileName}|package.json$`).test(filePath))
.forEach(filePath => unlinkSync(filePath));
const files = listFiles(directory).filter(filePath => !new RegExp(`${packFileName}|package.json$`).test(filePath));
Log.info(`Remove unnecessary files`);
files.forEach(filePath => unlinkSync(filePath));
}

private static removeEmptyDirectories(directory: string): void {
Log.info(`Remove empty directories`);
readdirSync(directory)
.map(fileName => path.join(directory, fileName))
.filter(filePath => statSync(filePath).isDirectory())
Expand Down
3 changes: 3 additions & 0 deletions projects/service-navigation-web-component/scripts/release.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import {Changelog} from '../../../scripts/shared/changelog';
import {updatePackageJsonVersion, updateSonarPropertiesVersion} from '../../../scripts/shared/utils';
import {version} from '../../../package.json';
import {Log} from '../../../scripts/shared/log';

Log.start(`Release Service Navigation Web Component ${version}`);
Changelog.addRelease(version, 'service-navigation', 'oblique/service-navigation');
updatePackageJsonVersion(version);
updateSonarPropertiesVersion(version);
Log.success();

0 comments on commit e37e512

Please sign in to comment.