Skip to content

Commit 8175605

Browse files
committed
Continue fixing buildtools
1 parent d844e16 commit 8175605

File tree

7 files changed

+31
-309
lines changed

7 files changed

+31
-309
lines changed

docs/src/modules/2-bundle/2-creating/2-creating.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ The command should have creates a new folder `src/bundles/new_bundle` with all t
4242

4343
![](./new_bundle.png)
4444

45-
From there you can edit your bundle as necessary
45+
From there, you can edit your bundle as necessary.
4646

4747
## Naming your Bundle
4848

@@ -52,4 +52,4 @@ The name of your bundle is what Source users will import from to actually use yo
5252
import { func } from 'new_bundle';
5353
```
5454

55-
Your bundle's name should be concise and give be somewhat descriptive of what functionalities your bundle provides.
55+
Your bundle's name should be concise and be somewhat descriptive of what functionalities your bundle provides.

lib/buildtools/src/commands/build.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const getBuildBundleCommand = () => new Command('bundle')
3535
}
3636

3737
const results = await runBuilderWithPrebuild(builders.buildBundle, opts, result.bundle, outDir, 'bundle', false);
38-
console.log(formatResultObject(results));
38+
console.log(formatResultObject({ prebuild: results }));
3939
cmdUtils.processResult(results, opts.ci);
4040
});
4141

@@ -63,7 +63,7 @@ export const getBuildTabCommand = () => new Command('tab')
6363
}
6464

6565
const results = await runBuilderWithPrebuild(builders.buildTab, opts, tab, outDir, 'tab', false);
66-
console.log(formatResultObject(results));
66+
console.log(formatResultObject({ prebuild: results }));
6767
cmdUtils.processResult(results, opts.ci);
6868
});
6969

@@ -78,7 +78,7 @@ export const getBuildDocsCommand = () => new Command('docs')
7878
cmdUtils.logCommandErrorAndExit(`No bundle found at ${directory}!`);
7979
} else if (manifestResult.severity === 'success') {
8080
const docResult = await builders.buildSingleBundleDocs(manifestResult.bundle, outDir, logLevel);
81-
console.log(formatResultObject({ docs: docResult }));
81+
console.log(formatResultObject({ prebuild: { docs: docResult } }));
8282
cmdUtils.processResult({ results: docResult }, ci);
8383
} else {
8484
cmdUtils.logCommandErrorAndExit(manifestResult);
@@ -104,7 +104,7 @@ export const getBuildAllCommand = () => new Command('all')
104104
}
105105

106106
const result = await builders.buildAll(resolvedResult.asset, opts, outDir, opts.logLevel);
107-
console.log(formatResultObject(result));
107+
console.log(formatResultObject({ prebuild: result }));
108108
cmdUtils.processResult(result, opts.ci);
109109
});
110110

lib/buildtools/src/formatter.ts

Lines changed: 12 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@ import pathlib from 'path';
22
import chalk from 'chalk';
33
import partition from 'lodash/partition.js';
44
import ts from 'typescript';
5-
import type { OverallResultType, FormattableTscResult, JsonResult } from '@sourceacademy/modules-repotools/build';
5+
import type { OverallResultType, FormattableTscResult } from '@sourceacademy/modules-repotools/build';
6+
import type { LintResult } from '@sourceacademy/modules-repotools/prebuild/lint';
67

78
interface ResultsObject {
89
tsc?: FormattableTscResult;
910
lint: LintResult;
10-
results?: OverallResultType;
1111
}
1212

1313
export function formatLintResult({ severity, formatted, input }: LintResult): string {
@@ -23,27 +23,6 @@ export function formatLintResult({ severity, formatted, input }: LintResult): st
2323
}
2424
}
2525

26-
/**
27-
* Formats a single result object into a string
28-
*/
29-
export function formatResult(result: OverallResultType) {
30-
if (result.severity === 'error') {
31-
return result.errors.join('\n');
32-
}
33-
34-
const typeStr = type ?? 'output';
35-
const successStr = chalk.greenBright(`${typeStr} written to ${result.path}`);
36-
37-
if (result.severity === 'warn') {
38-
return [
39-
...result.warnings,
40-
successStr
41-
].join('\n');
42-
}
43-
44-
return successStr;
45-
}
46-
4726
export function formatTscResult(tscResult: FormattableTscResult): string {
4827
const prefix = chalk.cyanBright('tsc completed');
4928

@@ -80,18 +59,22 @@ export function formatTscResult(tscResult: FormattableTscResult): string {
8059
/**
8160
* Formats a larger result object, particularly one with prebuild results too.
8261
*/
83-
export function formatResultObject(results: ResultsObject): string {
62+
export function formatResultObject({ tsc, lint }: ResultsObject, result: OverallResultType): string {
8463
const args: string[] = [];
8564

86-
if (results.tsc) {
87-
args.push(formatTscResult(results.tsc));
65+
if (tsc) {
66+
args.push(formatTscResult(tsc));
8867
}
8968

90-
if (results.lint) {
91-
args.push(formatLintResult(results.lint));
69+
if (lint) {
70+
args.push(formatLintResult(lint));
71+
}
72+
73+
if (result.severity === 'error') {
74+
result.diagnostics !== undefined
9275
}
9376

94-
if (results.results !== undefined) {
77+
if (result.diagnostics !== undefined) {
9578
args.push(formatResult(results.results));
9679
}
9780

lib/buildtools/src/prebuild/index.ts

Lines changed: 0 additions & 76 deletions
This file was deleted.

lib/buildtools/src/prebuild/lint.ts

Lines changed: 0 additions & 189 deletions
This file was deleted.

0 commit comments

Comments
 (0)