Skip to content

Commit

Permalink
refactor: optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
mfranzke committed Feb 1, 2025
1 parent 49ac1a7 commit 467a9a6
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 23 deletions.
7 changes: 3 additions & 4 deletions packages/foundations/assets/fonts/generate-eu-fonts.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { exec } from 'node:child_process';
import { promisify } from 'node:util';
import { dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { glob } from 'glob';

import { dirname } from 'path';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename).replaceAll('\\', '/');

Check failure on line 8 in packages/foundations/assets/fonts/generate-eu-fonts.ts

View workflow job for this annotation

GitHub Actions / lint / Lint

Unsafe assignment of an error typed value.

Check failure on line 8 in packages/foundations/assets/fonts/generate-eu-fonts.ts

View workflow job for this annotation

GitHub Actions / lint / Lint

Unsafe call of an `error` type typed value.

Expand All @@ -14,7 +13,7 @@ const generateFonts = async () => {
console.log('Generating EU fonts...');

Check failure on line 13 in packages/foundations/assets/fonts/generate-eu-fonts.ts

View workflow job for this annotation

GitHub Actions / lint / Lint

Unexpected console statement.
try {
await execAsync('pyftsubset --help');
} catch (e) {
} catch {
console.warn(
'You need to install pyftsubset. Check packages/foundations/assets/fonts/README.md for more information.'
);
Expand Down
6 changes: 3 additions & 3 deletions packages/migration/src/data.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { ReplaceInFileConfig } from 'replace-in-file';
import type { ProgrammOptionsType } from './types';
import { colorQ32024 } from './migration/color-q32024';
import type { ReplaceInFileConfig } from 'replace-in-file';
import { iconQ32024 } from './migration/icon-q32024';
import { v005_v006 } from './migration/v0.0.5-v0.0.6';
import { v006_v007 } from './migration/v0.0.6-v0.0.7';
import { v005_v006 } from './migration/v0.0.5-v0.0.6.ts';
import { v006_v007 } from './migration/v0.0.6-v0.0.7.ts';

export const migrationTypes: Record<string, ReplaceInFileConfig[]> = {
colorQ32024,
Expand Down
9 changes: 7 additions & 2 deletions packages/migration/src/migration/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/usr/bin/env node
import { globSync } from 'glob';
import type { ReplaceInFileConfig, ReplaceResult } from 'replace-in-file';
import { replaceInFileSync } from 'replace-in-file';
import {
type ReplaceInFileConfig,
type ReplaceResult,
replaceInFileSync
} from 'replace-in-file';
import type { OptionsType } from '../types';
import { migrationTypes } from '../data';
import { AdditionalInformation } from './additional-information';
Expand Down Expand Up @@ -50,6 +54,7 @@ export const migrate = (
if (cli) {
console.log(result);
}

return result;
}
}
Expand Down
1 change: 1 addition & 0 deletions packages/migration/src/program.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#!/usr/bin/env node
import { program } from 'commander';
import type { OptionsType, ProgrammOptionsType } from './types';

Expand Down
7 changes: 5 additions & 2 deletions packages/migration/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { v005_v006 } from './migration/v0.0.5-v0.0.6';
#!/usr/bin/env node
import { v005_v006 } from './migration/v0.0.5-v0.0.6.ts';

export type ProgrammOptionsType = {
name: string;
Expand All @@ -12,6 +13,8 @@ export type ProgrammOptionsType = {

export type OptionsType = {
src: string;
type: (string | 'colorQ32024' | 'iconQ32024' | 'v005_v006' | 'v006_v007')[];
type: Array<
string | 'colorQ32024' | 'iconQ32024' | 'v005_v006' | 'v006_v007'
>;
dryRun?: string | boolean;
};
4 changes: 1 addition & 3 deletions packages/migration/test/color-q32024/color-q32024.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ describe('color-q32024', () => {

expect(result).not.undefined;

expect(
(result as ReplaceResult[]).filter((res) => res.hasChanged)
).toHaveLength(1);
expect(result!.filter((res) => res.hasChanged)).toHaveLength(1);
});
});
4 changes: 1 addition & 3 deletions packages/migration/test/icon-q32024/icon-q32024.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ describe('icon-q32024', () => {

expect(result).not.undefined;

expect(
(result as ReplaceResult[]).filter((res) => res.hasChanged)
).toHaveLength(1);
expect(result!.filter((res) => res.hasChanged)).toHaveLength(1);
});
});
4 changes: 1 addition & 3 deletions packages/migration/test/v0.0.5-v0.0.6/v005_v006.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ describe('v005_v006', () => {

expect(result).not.undefined;

expect(
(result as ReplaceResult[]).filter((res) => res.hasChanged)
).toHaveLength(1);
expect(result!.filter((res) => res.hasChanged)).toHaveLength(1);
});
});
4 changes: 1 addition & 3 deletions packages/migration/test/v0.0.6-v0.0.7/v006_v007.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ describe('v006_v007', () => {

expect(result).not.undefined;

expect(
(result as ReplaceResult[]).filter((res) => res.hasChanged)
).toHaveLength(1);
expect(result!.filter((res) => res.hasChanged)).toHaveLength(1);
});
});

0 comments on commit 467a9a6

Please sign in to comment.