Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: refactor after core package intro #83

Merged
merged 8 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"code-pushup": "src/bin.js"
},
"dependencies": {
"bundle-require": "^4.0.1",
"chalk": "^5.3.0",
"yargs": "^17.7.2",
"@quality-metrics/models": "*",
"zod": "^3.22.1",
"@quality-metrics-cli/core": "*"
"@quality-metrics-cli/core": "*",
BioPhoton marked this conversation as resolved.
Show resolved Hide resolved
"@quality-metrics/utils": "*"
}
}
2 changes: 1 addition & 1 deletion packages/cli/src/lib/collect/command-object.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CommandModule } from 'yargs';
import { collectAndPersistReports } from '../implementation/collect-and-persist';
import { collectAndPersistReports } from '@quality-metrics/core';

export function yargsCollectCommandObject() {
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CoreConfig, coreConfigSchema } from '@quality-metrics/models';
import { stat } from 'fs/promises';
import { importModule } from './load-file';
import { importModule } from '@quality-metrics/utils';
import { ConfigParseError } from './config-middleware';

// @TODO [73] move into core
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export { logPersistedResults, persistReport } from './lib/persist';
export { executePlugins } from './lib/execute-plugin';
export { collect, CollectOptions } from './lib/collect';
export { collectAndPersistReports } from './lib/collect-and-persist';
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import {
collect,
CollectOptions,
logPersistedResults,
persistReport,
} from '@quality-metrics/core';
import { collect, CollectOptions } from './collect';
import { name, version } from '../../package.json';
BioPhoton marked this conversation as resolved.
Show resolved Hide resolved

import { pluginOutputSchema, Report } from '@quality-metrics/models';
import * as packageJson from '../../../package.json';
import { logPersistedResults, persistReport } from './persist';

// @TODO [73] move into core
export async function collectAndPersistReports(
config: CollectOptions,
): Promise<void> {
const collectReport = await collect(config);
const report: Report = {
...collectReport,
packageName: packageJson.name,
version: packageJson.version,
packageName: name,
version: version,
};

const persistResults = await persistReport(report, config);
Expand Down
3 changes: 2 additions & 1 deletion packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"dependencies": {
"@quality-metrics/models": "*",
"chalk": "^5.3.0",
"cliui": "^8.0.1"
"cliui": "^8.0.1",
"bundle-require": "^4.0.1"
}
}
1 change: 1 addition & 0 deletions packages/utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export {
export { calcDuration, formatBytes } from './lib/collect/implementation/utils';
export { reportToStdout } from './lib/collect/implementation/report-to-stdout';
export { reportToMd } from './lib/collect/implementation/report-to-md';
export { importModule } from './lib/collect/implementation/load-file';
BioPhoton marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { bundleRequire, Options } from 'bundle-require';

// @TODO [73] move into utils
export async function importModule<T = unknown>(
options: Options,
parse?: (d: unknown) => T,
Expand Down