-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(nx-plugin): add nx-plugin preset generator
- Loading branch information
1 parent
a8261e8
commit 6c0bdcb
Showing
7 changed files
with
74 additions
and
9 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
1 change: 1 addition & 0 deletions
1
packages/nx-plugin/src/generators/preset/files/src/index.ts__template__
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 @@ | ||
const variable = "<%= projectName %>"; |
20 changes: 20 additions & 0 deletions
20
packages/nx-plugin/src/generators/preset/generator.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,20 @@ | ||
import { createTreeWithEmptyWorkspace } from '@nrwl/devkit/testing'; | ||
import { Tree, readProjectConfiguration } from '@nrwl/devkit'; | ||
|
||
import generator from './generator'; | ||
import { PresetGeneratorSchema } from './schema'; | ||
|
||
describe('preset generator', () => { | ||
let appTree: Tree; | ||
const options: PresetGeneratorSchema = { name: 'test' }; | ||
|
||
beforeEach(() => { | ||
appTree = createTreeWithEmptyWorkspace({layout: 'apps-libs'}); | ||
}); | ||
|
||
it('should run successfully', async () => { | ||
await generator(appTree, options); | ||
const config = readProjectConfiguration(appTree, 'test'); | ||
expect(config).toBeDefined(); | ||
}); | ||
}); |
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,16 @@ | ||
import { Tree } from '@nrwl/devkit'; | ||
import { Linter } from '@nrwl/linter'; | ||
import { pluginGenerator } from '../plugin/plugin'; | ||
import { PresetGeneratorSchema } from './schema'; | ||
|
||
export default async function (tree: Tree, options: PresetGeneratorSchema) { | ||
return pluginGenerator(tree, { | ||
compiler: 'tsc', | ||
linter: Linter.EsLint, | ||
name: options.pluginName, | ||
skipFormat: false, | ||
skipLintChecks: false, | ||
skipTsConfig: false, | ||
unitTestRunner: 'jest', | ||
}); | ||
} |
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 @@ | ||
export interface PresetGeneratorSchema { | ||
pluginName: string; | ||
} |
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,16 @@ | ||
{ | ||
"$schema": "http://json-schema.org/schema", | ||
"cli": "nx", | ||
"$id": "NxPluginPreset", | ||
"title": "Preset for @nrwl/nx-plugin", | ||
"description": "Initializes a workspace with an nx-plugin inside of it. Use as: `create-nx-workspace --preset @nrwl/nx-plugin`", | ||
"type": "object", | ||
"properties": { | ||
"pluginName": { | ||
"type": "string", | ||
"description": "Plugin name", | ||
"aliases": ["name"] | ||
} | ||
}, | ||
"required": ["pluginName"] | ||
} |