Skip to content

Commit

Permalink
fix(core): add ng command args prod and port
Browse files Browse the repository at this point in the history
  • Loading branch information
why520crazy committed Sep 29, 2021
1 parent 334ed26 commit 14f410a
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 4 deletions.
3 changes: 1 addition & 2 deletions packages/cli/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ export const buildCommand: CommandModule = {
command: ['build'],
describe: 'Build documentation site',
builder: yargs => {
yargsOptionsGenerate(yargs, readNgBuildOptions());
yargs
yargsOptionsGenerate(yargs, readNgBuildOptions())
.option('skip-site', {
desc: `skip build site`,
boolean: true,
Expand Down
8 changes: 6 additions & 2 deletions packages/core/src/angular/utils.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ describe('#ng-utils', () => {
deployUrl: '/docgeni/',
['deploy-url']: '/docgeni/',
notFoundUrl: '/not-found/',
['not-found-url']: '/not-found/'
['not-found-url']: '/not-found/',
prod: true,
port: 1000
},
ngBuildOptions
);
expect(result).toEqual({
['deploy-url']: '/docgeni/'
['deploy-url']: '/docgeni/',
prod: true,
port: 1000
});
});

Expand Down
18 changes: 18 additions & 0 deletions packages/core/src/angular/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,23 @@ export interface NgOption {
required?: boolean;
}

const EXTRA_NG_OPTIONS = {
prod: {
name: 'prod',
description: 'Target to build.',
type: NgOptionType.Boolean,
required: false,
aliases: []
},
port: {
name: 'port',
description: 'Target to build.',
type: NgOptionType.String,
required: false,
aliases: []
}
};

export function readNgBuildOptions(): NgOption[] {
return toolkit.fs.readJSONSync(path.resolve(__dirname, './ng-build-options.json'));
}
Expand All @@ -45,6 +62,7 @@ export function readNgServeOptions() {

export function extractAngularCommandArgs(argv: any, options: NgOption[]): Record<string, string> {
const optionsNameMap = toolkit.utils.keyBy(options, 'name');
Object.assign(optionsNameMap, EXTRA_NG_OPTIONS);
return Object.keys(argv)
.filter(key => {
return optionsNameMap[key] || optionsNameMap[toolkit.strings.camelCase(key)];
Expand Down

0 comments on commit 14f410a

Please sign in to comment.