-
Notifications
You must be signed in to change notification settings - Fork 69
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8107355
commit 39dbd9a
Showing
23 changed files
with
243 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"$schema": "@angular-devkit/architect/src/builders-schema.json", | ||
"builders": { | ||
"xliffmerge": { | ||
"class": "./xliffmergebuilder/xliffmerge.builder.js", | ||
"schema": "./xliffmergebuilder//schema.json", | ||
"description": "Builder to run xliffmerge after the ng xi18n build" | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
projects/tooling/src/builders/src/xliffmergebuilder/schema.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import {IXliffMergeOptions} from '@ngx-i18nsupport/ngx-i18nsupport'; | ||
|
||
export interface XliffmergeBuilderSchema { | ||
xliffmergeOptions?: IXliffMergeOptions; | ||
profile?: string; | ||
} |
22 changes: 22 additions & 0 deletions
22
projects/tooling/src/builders/src/xliffmergebuilder/schema.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema#", | ||
"id": "https://github.com/martinroob/ngx-i18nsupport/configuration-schema.json", | ||
"title": "ngx-i18nsupport-configuration", | ||
"description": "config file for ngx-i18nsupport xliffmerge", | ||
"type": "object", | ||
"properties": { | ||
"xliffmergeOptions": { | ||
"description": "configuration options for xliffmerge, same schema as xliffmerge, see documentation for details", | ||
"type": "object", | ||
"properties": { | ||
}, | ||
"required": [], | ||
"additionalProperties": true | ||
}, | ||
"profile": { | ||
"description": "profile for xliffmerge (a file containing the options)", | ||
"type": "string" | ||
} | ||
}, | ||
"required": [] | ||
} |
48 changes: 48 additions & 0 deletions
48
projects/tooling/src/builders/src/xliffmergebuilder/xliffmerge.builder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
An Angular Builder to run xliffmerge. | ||
Work is based on nice blog article | ||
https://medium.com/dailyjs/angular-cli-6-under-the-hood-builders-demystified-f0690ebcf01 by Evgeny Barabanov | ||
**/ | ||
import {Observable, of} from 'rxjs'; | ||
import {catchError, map} from 'rxjs/operators'; | ||
import {getSystemPath} from '@angular-devkit/core'; | ||
import {Builder, BuilderConfiguration, BuilderContext, BuildEvent} from '@angular-devkit/architect'; | ||
import {XliffmergeBuilderSchema} from './schema'; | ||
import {XliffMerge, CommandOutput, WriterToString, ProgramOptions, IConfigFile} from '@ngx-i18nsupport/ngx-i18nsupport'; | ||
|
||
export default class XliffmergeBuilder implements Builder<XliffmergeBuilderSchema> { | ||
|
||
constructor(private context: BuilderContext) { | ||
} | ||
|
||
run(builderConfig: BuilderConfiguration<Partial<XliffmergeBuilderSchema>>): Observable<BuildEvent> { | ||
const {xliffmergeOptions, profile} = builderConfig.options; | ||
console.log('xliffmergeOptions, profile', xliffmergeOptions, profile); | ||
let programOptions: ProgramOptions = {}; | ||
let options: IConfigFile|undefined = {xliffmergeOptions: xliffmergeOptions}; | ||
if (profile) { | ||
const root = this.context.workspace.root; | ||
const profilePath = `${getSystemPath(root)}/${profile}`; | ||
programOptions = {profilePath: profilePath}; | ||
options = undefined; | ||
} | ||
const ws: WriterToString = new WriterToString(); | ||
const commandOutput: CommandOutput = new CommandOutput(ws); | ||
const xliffmerge = XliffMerge.createFromOptions(commandOutput, programOptions, options); | ||
return xliffmerge.runAsync().pipe( | ||
map((rc) => { | ||
if (rc !== 0) { | ||
this.context.logger.warn(`xliffmerge rc=${rc}`); | ||
} | ||
this.context.logger.info(ws.writtenData()); | ||
return {success: true}; | ||
}), | ||
catchError((error) => { | ||
this.context.logger.info(ws.writtenData()); | ||
this.context.logger.error('xliffmerge failed: ' + error); | ||
return of({success: false}); | ||
}) | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"extends": "../../tsconfig.lib.json", | ||
"compilerOptions": { | ||
"rootDir": ".", | ||
"outDir": "../../../../dist/tooling/builders", | ||
"lib": [ | ||
"es2017", | ||
"dom" | ||
], | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
"noEmitOnError": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noImplicitAny": true, | ||
"noImplicitThis": true, | ||
"noUnusedParameters": true, | ||
"noUnusedLocals": true, | ||
"skipDefaultLibCheck": true, | ||
"skipLibCheck": true, | ||
"strictNullChecks": true, | ||
"target": "es6", | ||
"types": [ | ||
"jasmine", | ||
"node" | ||
] | ||
}, | ||
"include": [ | ||
"src/**/*" | ||
], | ||
"exclude": [ | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.