Skip to content

Commit

Permalink
fix: consistently allow undefined as an app name for build command
Browse files Browse the repository at this point in the history
  • Loading branch information
iliazeus committed Jan 11, 2024
1 parent 258adc5 commit 179f9c7
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 16 deletions.
12 changes: 7 additions & 5 deletions actions/build.action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,11 @@ export class BuildAction extends AbstractAction {
const buildAll = commandOptions.find((opt) => opt.name === 'all')!
.value as boolean;

let appNames: string[];
// undefined represents the default project, since we don't know its name here
let appNames: (string | undefined)[];

if (buildAll) {
appNames = [undefined!]; // always include the default project
appNames = [undefined]; // always include the default project

if (configuration.projects) {
appNames.push(...Object.keys(configuration.projects));
Expand Down Expand Up @@ -175,7 +177,7 @@ export class BuildAction extends AbstractAction {

private async runSwc(
configuration: Required<Configuration>,
appName: string,
appName: string | undefined,
pathToTsconfig: string,
watchMode: boolean,
options: Input[],
Expand Down Expand Up @@ -212,7 +214,7 @@ export class BuildAction extends AbstractAction {

private async runWebpack(
configuration: Required<Configuration>,
appName: string,
appName: string | undefined,
commandOptions: Input[],
pathToTsconfig: string,
debug: boolean,
Expand Down Expand Up @@ -258,7 +260,7 @@ export class BuildAction extends AbstractAction {
options: Input[],
configuration: Required<Configuration>,
pathToTsconfig: string,
appName: string,
appName: string | undefined,
) {
if (watchMode) {
const { WatchCompiler } = await import('../lib/compiler/watch-compiler');
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/assets-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class AssetsManager {

public copyAssets(
configuration: Required<Configuration>,
appName: string,
appName: string | undefined,
outDir: string,
watchAssetsMode: boolean,
) {
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class Compiler extends BaseCompiler {
public run(
configuration: Required<Configuration>,
tsConfigPath: string,
appName: string,
appName: string | undefined,
_extras: any,
onSuccess?: () => void,
) {
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/helpers/get-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { getValueOrDefault } from './get-value-or-default';
export function getBuilder(
configuration: Required<Configuration>,
cmdOptions: Input[],
appName: string,
appName: string | undefined,
) {
const builderValue = getValueOrDefault<Builder>(
configuration,
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/helpers/get-tsc-config.path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { getValueOrDefault } from './get-value-or-default';
export function getTscConfigPath(
configuration: Required<Configuration>,
cmdOptions: Input[],
appName: string,
appName: string | undefined,
) {
let tsconfigPath = getValueOrDefault<string | undefined>(
configuration,
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/helpers/get-webpack-config-path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { getValueOrDefault } from './get-value-or-default';
export function getWebpackConfigPath(
configuration: Required<Configuration>,
cmdOptions: Input[],
appName: string,
appName: string | undefined,
) {
let webpackPath = getValueOrDefault<string | undefined>(
configuration,
Expand Down
6 changes: 3 additions & 3 deletions lib/compiler/swc/swc-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class SwcCompiler extends BaseCompiler {
public async run(
configuration: Required<Configuration>,
tsConfigPath: string,
appName: string,
appName: string | undefined,
extras: SwcCompilerExtras,
onSuccess?: () => void,
) {
Expand Down Expand Up @@ -79,13 +79,13 @@ export class SwcCompiler extends BaseCompiler {
private runTypeChecker(
configuration: Required<Configuration>,
tsConfigPath: string,
appName: string,
appName: string | undefined,
extras: SwcCompilerExtras,
) {
if (extras.watch) {
const args = [
tsConfigPath,
appName,
appName ?? 'undefined',
configuration.sourceRoot ?? 'src',
JSON.stringify(configuration.compilerOptions.plugins ?? []),
];
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/watch-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class WatchCompiler extends BaseCompiler<TypescriptWatchCompilerExtras> {
public run(
configuration: Required<Configuration>,
tsConfigPath: string,
appName: string,
appName: string | undefined,
extras: TypescriptWatchCompilerExtras,
onSuccess?: () => void,
) {
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/webpack-compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class WebpackCompiler extends BaseCompiler<WebpackCompilerExtras> {
public run(
configuration: Required<Configuration>,
tsConfigPath: string,
appName: string,
appName: string | undefined,
extras: WebpackCompilerExtras,
onSuccess?: () => void,
) {
Expand Down
2 changes: 1 addition & 1 deletion lib/compiler/workspace-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getValueOrDefault } from './helpers/get-value-or-default';
export class WorkspaceUtils {
public async deleteOutDirIfEnabled(
configuration: Required<Configuration>,
appName: string,
appName: string | undefined,
dirPath: string,
) {
const isDeleteEnabled = getValueOrDefault<boolean>(
Expand Down

0 comments on commit 179f9c7

Please sign in to comment.