forked from microsoft/fluentui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(workspace-plugin): scaffold
split-library-in-two
generator (mi…
- Loading branch information
1 parent
32372c0
commit 24c704b
Showing
6 changed files
with
64 additions
and
0 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
1 change: 1 addition & 0 deletions
1
tools/workspace-plugin/src/generators/split-library-in-two/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 = "<%= name %>"; |
20 changes: 20 additions & 0 deletions
20
tools/workspace-plugin/src/generators/split-library-in-two/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 '@nx/devkit/testing'; | ||
import { Tree, readProjectConfiguration } from '@nx/devkit'; | ||
|
||
import { splitLibraryInTwoGenerator } from './generator'; | ||
import { SplitLibraryInTwoGeneratorSchema } from './schema'; | ||
|
||
describe('split-library-in-two generator', () => { | ||
let tree: Tree; | ||
const options: SplitLibraryInTwoGeneratorSchema = { name: 'test' }; | ||
|
||
beforeEach(() => { | ||
tree = createTreeWithEmptyWorkspace(); | ||
}); | ||
|
||
it('should run successfully', async () => { | ||
await splitLibraryInTwoGenerator(tree, options); | ||
const config = readProjectConfiguration(tree, 'test'); | ||
expect(config).toBeDefined(); | ||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
tools/workspace-plugin/src/generators/split-library-in-two/generator.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,17 @@ | ||
import { addProjectConfiguration, formatFiles, generateFiles, Tree } from '@nx/devkit'; | ||
import * as path from 'path'; | ||
import { SplitLibraryInTwoGeneratorSchema } from './schema'; | ||
|
||
export async function splitLibraryInTwoGenerator(tree: Tree, options: SplitLibraryInTwoGeneratorSchema) { | ||
const projectRoot = `libs/${options.name}`; | ||
addProjectConfiguration(tree, options.name, { | ||
root: projectRoot, | ||
projectType: 'library', | ||
sourceRoot: `${projectRoot}/src`, | ||
targets: {}, | ||
}); | ||
generateFiles(tree, path.join(__dirname, 'files'), projectRoot, options); | ||
await formatFiles(tree); | ||
} | ||
|
||
export default splitLibraryInTwoGenerator; |
3 changes: 3 additions & 0 deletions
3
tools/workspace-plugin/src/generators/split-library-in-two/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,3 @@ | ||
export interface SplitLibraryInTwoGeneratorSchema { | ||
name: string; | ||
} |
18 changes: 18 additions & 0 deletions
18
tools/workspace-plugin/src/generators/split-library-in-two/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,18 @@ | ||
{ | ||
"$schema": "https://json-schema.org/schema", | ||
"$id": "SplitLibraryInTwo", | ||
"title": "", | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"type": "string", | ||
"description": "", | ||
"$default": { | ||
"$source": "argv", | ||
"index": 0 | ||
}, | ||
"x-prompt": "What name would you like to use?" | ||
} | ||
}, | ||
"required": ["name"] | ||
} |