Skip to content

Commit 8173db0

Browse files
Merge pull request #40 from ngx-builders/feature/add-option-for-baseHref
added baseHref option
2 parents 80877ae + c19209a commit 8173db0

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

command-builder/deploy/index.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,36 @@
11
import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect';
2-
import { JsonObject } from '@angular-devkit/core';
2+
import { json } from '@angular-devkit/core';
33
import { Schema } from './schema';
44

55
const NetlifyAPI = require('netlify');
66

77
export default createBuilder<any>(
88
async (builderConfig: Schema, context: BuilderContext): Promise<BuilderOutput> => {
99
context.reportStatus(`Executing deploy...`);
10-
context.logger.info(`Executing deploy command ...... `);
10+
context.logger.info(`Executing netlify deploy command ...... `);
1111
let buildResult;
1212
if (builderConfig.noBuild) {
1313
context.logger.info(`📦 Skipping build`);
1414
buildResult = true;
1515
} else {
1616
const configuration = builderConfig.configuration ? builderConfig.configuration : 'production';
1717

18+
const overrides = {
19+
// this is an example how to override the workspace set of options
20+
...(builderConfig.baseHref && { baseHref: builderConfig.baseHref })
21+
};
22+
1823
if (!context.target) {
1924
throw new Error('Cannot deploy the application without a target');
2025
}
2126

27+
context.logger.info(`📦 Building "${context.target.project}". Configuration: "${configuration}".${builderConfig.baseHref ? ' Your base-href: "' + builderConfig.baseHref + '"' : ''}`);
28+
2229
const build = await context.scheduleTarget({
2330
target: 'build',
2431
project: context.target !== undefined ? context.target.project : '',
2532
configuration
26-
});
33+
}, overrides as json.JsonObject);
2734

2835
buildResult = await build.result;
2936
}

command-builder/deploy/schema.d.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
export interface Schema {
22
configuration?: string;
3-
noBuild? : boolean;
4-
outputPath? : boolean;
3+
noBuild?: boolean;
4+
outputPath?: boolean;
55
netlifyToken?: string;
66
siteId?: string;
7+
baseHref?: string;
78
}

command-builder/deploy/schema.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525
"siteId": {
2626
"type": "string",
2727
"description": "Every netlify app have a API ID which uniquly identify that app."
28+
},
29+
"baseHref": {
30+
"type": "string",
31+
"description": "This is an example how to override the workspace set of options. --- Base url for the application being built. Same as `ng build --base-href=/XXX/`."
2832
}
2933
}
3034
}

0 commit comments

Comments
 (0)