-
-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nx-spring-boot): add builders for run, buildJar/War, buildImage …
…and buildInfo commands
- Loading branch information
Showing
28 changed files
with
427 additions
and
32 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export function execSync(command, options) { | ||
const msg = `Executed command '${command}' with options '${JSON.stringify(options)}'`; | ||
console.log(msg); | ||
return msg; | ||
} |
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 |
---|---|---|
@@ -1,10 +1,30 @@ | ||
{ | ||
"$schema": "../../node_modules/@angular-devkit/architect/src/builders-schema.json", | ||
"builders": { | ||
"build": { | ||
"implementation": "./src/builders/build/builder", | ||
"schema": "./src/builders/build/schema.json", | ||
"description": "build builder" | ||
"run": { | ||
"implementation": "./src/builders/run/builder", | ||
"schema": "./src/builders/run/schema.json", | ||
"description": "run builder" | ||
}, | ||
"buildJar": { | ||
"implementation": "./src/builders/build-jar/builder", | ||
"schema": "./src/builders/build-jar/schema.json", | ||
"description": "buildJar builder" | ||
}, | ||
"buildWar": { | ||
"implementation": "./src/builders/build-war/builder", | ||
"schema": "./src/builders/build-war/schema.json", | ||
"description": "buildWar builder" | ||
}, | ||
"buildImage": { | ||
"implementation": "./src/builders/build-image/builder", | ||
"schema": "./src/builders/build-image/schema.json", | ||
"description": "buildImage builder" | ||
}, | ||
"buildInfo": { | ||
"implementation": "./src/builders/build-info/builder", | ||
"schema": "./src/builders/build-info/schema.json", | ||
"description": "buildInfo builder" | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/nx-spring-boot/src/builders/build-image/builder.spec.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,44 @@ | ||
import { Architect } from '@angular-devkit/architect'; | ||
import { TestingArchitectHost } from '@angular-devkit/architect/testing'; | ||
import { schema } from '@angular-devkit/core'; | ||
import { join } from 'path'; | ||
import { BuildImageBuilderSchema } from './schema'; | ||
|
||
jest.mock('child_process'); // we need to mock 'execSync' (see __mocks__/child_process.js) | ||
|
||
const options: BuildImageBuilderSchema = {}; | ||
|
||
describe('Command Runner Builder', () => { | ||
let architect: Architect; | ||
let architectHost: TestingArchitectHost; | ||
|
||
beforeEach(async () => { | ||
const registry = new schema.CoreSchemaRegistry(); | ||
registry.addPostTransform(schema.transforms.addUndefinedDefaults); | ||
|
||
architectHost = new TestingArchitectHost('/root', '/root'); | ||
architect = new Architect(architectHost, registry); | ||
|
||
// This will either take a Node package name, or a path to the directory | ||
// for the package.json file. | ||
await architectHost.addBuilderFromPackage(join(__dirname, '../../..')); | ||
}); | ||
|
||
it('can run', async () => { | ||
// A "run" can have multiple outputs, and contains progress information. | ||
const run = await architect.scheduleBuilder( | ||
'@nxrocks/nx-spring-boot:buildImage', | ||
options | ||
); | ||
// The "result" member (of type BuilderOutput) is the next output. | ||
const output = await run.result; | ||
|
||
// Stop the builder from running. This stops Architect from keeping | ||
// the builder-associated states in memory, since builders keep waiting | ||
// to be scheduled. | ||
await run.stop(); | ||
|
||
// Expect that it succeeded. | ||
expect(output.success).toBe(true); | ||
}); | ||
}); |
10 changes: 10 additions & 0 deletions
10
packages/nx-spring-boot/src/builders/build-image/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,10 @@ | ||
import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect' | ||
import { of, Observable } from 'rxjs' | ||
import { BuildImageBuilderSchema } from './schema' | ||
import { runBootPluginCommand } from '../../utils/boot-utils' | ||
|
||
export function runBuilder(options: BuildImageBuilderSchema, context: BuilderContext): Observable<BuilderOutput> { | ||
return of(runBootPluginCommand(context, 'buildImage', [])); | ||
} | ||
|
||
export default createBuilder(runBuilder); |
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,3 @@ | ||
import { JsonObject } from '@angular-devkit/core'; | ||
|
||
export interface BuildImageBuilderSchema extends JsonObject {} // eslint-disable-line |
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,9 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft-07/schema", | ||
"$id": "https://json-schema.org/draft-07/schema", | ||
"title": "Build Image builder", | ||
"description": "", | ||
"type": "object", | ||
"properties": {}, | ||
"required": [] | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/nx-spring-boot/src/builders/build-info/builder.spec.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,44 @@ | ||
import { Architect } from '@angular-devkit/architect'; | ||
import { TestingArchitectHost } from '@angular-devkit/architect/testing'; | ||
import { schema } from '@angular-devkit/core'; | ||
import { join } from 'path'; | ||
import { BuildInfoBuilderSchema } from './schema'; | ||
|
||
jest.mock('child_process'); // we need to mock 'execSync' (see __mocks__/child_process.js) | ||
|
||
const options: BuildInfoBuilderSchema = {}; | ||
|
||
describe('Command Runner Builder', () => { | ||
let architect: Architect; | ||
let architectHost: TestingArchitectHost; | ||
|
||
beforeEach(async () => { | ||
const registry = new schema.CoreSchemaRegistry(); | ||
registry.addPostTransform(schema.transforms.addUndefinedDefaults); | ||
|
||
architectHost = new TestingArchitectHost('/root', '/root'); | ||
architect = new Architect(architectHost, registry); | ||
|
||
// This will either take a Node package name, or a path to the directory | ||
// for the package.json file. | ||
await architectHost.addBuilderFromPackage(join(__dirname, '../../..')); | ||
}); | ||
|
||
it('can run', async () => { | ||
// A "run" can have multiple outputs, and contains progress information. | ||
const run = await architect.scheduleBuilder( | ||
'@nxrocks/nx-spring-boot:buildInfo', | ||
options | ||
); | ||
// The "result" member (of type BuilderOutput) is the next output. | ||
const output = await run.result; | ||
|
||
// Stop the builder from running. This stops Architect from keeping | ||
// the builder-associated states in memory, since builders keep waiting | ||
// to be scheduled. | ||
await run.stop(); | ||
|
||
// Expect that it succeeded. | ||
expect(output.success).toBe(true); | ||
}); | ||
}); |
10 changes: 10 additions & 0 deletions
10
packages/nx-spring-boot/src/builders/build-info/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,10 @@ | ||
import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect' | ||
import { of, Observable } from 'rxjs' | ||
import { BuildInfoBuilderSchema } from './schema' | ||
import { runBootPluginCommand } from '../../utils/boot-utils' | ||
|
||
export function runBuilder(options: BuildInfoBuilderSchema, context: BuilderContext): Observable<BuilderOutput> { | ||
return of(runBootPluginCommand(context, 'buildInfo', [])); | ||
} | ||
|
||
export default createBuilder(runBuilder); |
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,3 @@ | ||
import { JsonObject } from '@angular-devkit/core'; | ||
|
||
export interface BuildInfoBuilderSchema extends JsonObject {} // eslint-disable-line |
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,9 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft-07/schema", | ||
"$id": "https://json-schema.org/draft-07/schema", | ||
"title": "Build Info builder", | ||
"description": "", | ||
"type": "object", | ||
"properties": {}, | ||
"required": [] | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/nx-spring-boot/src/builders/build-jar/builder.spec.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,44 @@ | ||
import { Architect } from '@angular-devkit/architect'; | ||
import { TestingArchitectHost } from '@angular-devkit/architect/testing'; | ||
import { schema } from '@angular-devkit/core'; | ||
import { join } from 'path'; | ||
import { BuildJarBuilderSchema } from './schema'; | ||
|
||
jest.mock('child_process'); // we need to mock 'execSync' (see __mocks__/child_process.js) | ||
|
||
const options: BuildJarBuilderSchema = {}; | ||
|
||
describe('Command Runner Builder', () => { | ||
let architect: Architect; | ||
let architectHost: TestingArchitectHost; | ||
|
||
beforeEach(async () => { | ||
const registry = new schema.CoreSchemaRegistry(); | ||
registry.addPostTransform(schema.transforms.addUndefinedDefaults); | ||
|
||
architectHost = new TestingArchitectHost('/root', '/root'); | ||
architect = new Architect(architectHost, registry); | ||
|
||
// This will either take a Node package name, or a path to the directory | ||
// for the package.json file. | ||
await architectHost.addBuilderFromPackage(join(__dirname, '../../..')); | ||
}); | ||
|
||
it('can run', async () => { | ||
// A "run" can have multiple outputs, and contains progress information. | ||
const run = await architect.scheduleBuilder( | ||
'@nxrocks/nx-spring-boot:buildJar', | ||
options | ||
); | ||
// The "result" member (of type BuilderOutput) is the next output. | ||
const output = await run.result; | ||
|
||
// Stop the builder from running. This stops Architect from keeping | ||
// the builder-associated states in memory, since builders keep waiting | ||
// to be scheduled. | ||
await run.stop(); | ||
|
||
// Expect that it succeeded. | ||
expect(output.success).toBe(true); | ||
}); | ||
}); |
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 @@ | ||
import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect' | ||
import { of, Observable } from 'rxjs' | ||
import { BuildJarBuilderSchema } from './schema' | ||
import { runBootPluginCommand } from '../../utils/boot-utils' | ||
|
||
export function runBuilder(options: BuildJarBuilderSchema, context: BuilderContext): Observable<BuilderOutput> { | ||
return of(runBootPluginCommand(context, 'buildJar', [])); | ||
} | ||
|
||
export default createBuilder(runBuilder); |
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,3 @@ | ||
import { JsonObject } from '@angular-devkit/core'; | ||
|
||
export interface BuildJarBuilderSchema extends JsonObject {} // eslint-disable-line |
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,9 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft-07/schema", | ||
"$id": "https://json-schema.org/draft-07/schema", | ||
"title": "Build Jar builder", | ||
"description": "", | ||
"type": "object", | ||
"properties": {}, | ||
"required": [] | ||
} |
44 changes: 44 additions & 0 deletions
44
packages/nx-spring-boot/src/builders/build-war/builder.spec.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,44 @@ | ||
import { Architect } from '@angular-devkit/architect'; | ||
import { TestingArchitectHost } from '@angular-devkit/architect/testing'; | ||
import { schema } from '@angular-devkit/core'; | ||
import { join } from 'path'; | ||
import { BuildWarBuilderSchema } from './schema'; | ||
|
||
jest.mock('child_process'); // we need to mock 'execSync' (see __mocks__/child_process.js) | ||
|
||
const options: BuildWarBuilderSchema = {}; | ||
|
||
describe('Command Runner Builder', () => { | ||
let architect: Architect; | ||
let architectHost: TestingArchitectHost; | ||
|
||
beforeEach(async () => { | ||
const registry = new schema.CoreSchemaRegistry(); | ||
registry.addPostTransform(schema.transforms.addUndefinedDefaults); | ||
|
||
architectHost = new TestingArchitectHost('/root', '/root'); | ||
architect = new Architect(architectHost, registry); | ||
|
||
// This will either take a Node package name, or a path to the directory | ||
// for the package.json file. | ||
await architectHost.addBuilderFromPackage(join(__dirname, '../../..')); | ||
}); | ||
|
||
it('can run', async () => { | ||
// A "run" can have multiple outputs, and contains progress information. | ||
const run = await architect.scheduleBuilder( | ||
'@nxrocks/nx-spring-boot:buildWar', | ||
options | ||
); | ||
// The "result" member (of type BuilderOutput) is the next output. | ||
const output = await run.result; | ||
|
||
// Stop the builder from running. This stops Architect from keeping | ||
// the builder-associated states in memory, since builders keep waiting | ||
// to be scheduled. | ||
await run.stop(); | ||
|
||
// Expect that it succeeded. | ||
expect(output.success).toBe(true); | ||
}); | ||
}); |
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 @@ | ||
import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect' | ||
import { of, Observable } from 'rxjs' | ||
import { BuildWarBuilderSchema as BuildWarBuilderSchema } from './schema' | ||
import { runBootPluginCommand } from '../../utils/boot-utils' | ||
|
||
export function runBuilder(options: BuildWarBuilderSchema, context: BuilderContext): Observable<BuilderOutput> { | ||
return of(runBootPluginCommand(context, 'buildWar', [])); | ||
} | ||
|
||
export default createBuilder(runBuilder); |
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,3 @@ | ||
import { JsonObject } from '@angular-devkit/core'; | ||
|
||
export interface BuildWarBuilderSchema extends JsonObject {} // eslint-disable-line |
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,9 @@ | ||
{ | ||
"$schema": "https://json-schema.org/draft-07/schema", | ||
"$id": "https://json-schema.org/draft-07/schema", | ||
"title": "Build War builder", | ||
"description": "", | ||
"type": "object", | ||
"properties": {}, | ||
"required": [] | ||
} |
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { BuilderContext, BuilderOutput, createBuilder } from '@angular-devkit/architect' | ||
import { of, Observable } from 'rxjs' | ||
import { RunBuilderSchema } from './schema' | ||
import { runBootPluginCommand } from '../../utils/boot-utils' | ||
|
||
export function runBuilder(options: RunBuilderSchema, context: BuilderContext): Observable<BuilderOutput> { | ||
return of(runBootPluginCommand(context, 'run', [])); | ||
} | ||
|
||
export default createBuilder(runBuilder); |
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,3 @@ | ||
import { JsonObject } from '@angular-devkit/core'; | ||
|
||
export interface RunBuilderSchema extends JsonObject {} // eslint-disable-line |
2 changes: 1 addition & 1 deletion
2
...pring-boot/src/builders/build/schema.json → ...-spring-boot/src/builders/run/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
Oops, something went wrong.