-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(ionic): feature/component generators
closes #152
- Loading branch information
1 parent
2690aa0
commit 816ae3b
Showing
7 changed files
with
110 additions
and
35 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
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
packages/ionic-angular/src/schematics/component/_index_files/index.ts__tmpl__
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,7 @@ | ||
import { <%= utils.classify(name) %>Component } from './<%= name %>/<%= name %>.component'; | ||
|
||
export const <%= subFolder ? utils.sanitize(subFolder).toUpperCase() : utils.sanitize(name).toUpperCase() %>_COMPONENTS = [ | ||
<%= utils.classify(name) %>Component | ||
]; | ||
|
||
export * from './<%= name %>/<%= name %>.component'; |
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,33 +1,96 @@ | ||
import { adjustSandbox, adjustRouting } from '@nstudio/angular'; | ||
import { chain, Tree, SchematicContext } from '@angular-devkit/schematics'; | ||
import { XplatFeatureHelpers, prerun } from '@nstudio/xplat'; | ||
import { | ||
XplatFeatureHelpers, | ||
PlatformTypes, | ||
XplatHelpers, | ||
prerun | ||
} from '@nstudio/xplat'; | ||
|
||
export default function(options: XplatFeatureHelpers.Schema) { | ||
const xplatChains = []; | ||
xplatChains.push((tree: Tree, context: SchematicContext) => | ||
XplatFeatureHelpers.addFiles(options, 'ionic', null, null, 'angular')( | ||
tree, | ||
context | ||
) | ||
); | ||
// update index | ||
xplatChains.push((tree: Tree, context: SchematicContext) => | ||
XplatFeatureHelpers.adjustBarrelIndex( | ||
options, | ||
`xplat/ionic/features/index.ts` | ||
)(tree, context) | ||
); | ||
// add starting component unless onlyModule | ||
if (!options.onlyModule) { | ||
xplatChains.push((tree: Tree, context: SchematicContext) => | ||
XplatFeatureHelpers.addFiles( | ||
options, | ||
const featureSettings = XplatFeatureHelpers.prepare(options); | ||
const chains = []; | ||
|
||
if (options.onlyProject) { | ||
for (const projectName of featureSettings.projectNames) { | ||
const projectParts = projectName.split('-'); | ||
const platPrefix = projectParts[0]; | ||
const platSuffix = projectParts.pop(); | ||
if (platPrefix === 'ionic' || platSuffix === 'ionic') { | ||
// check for 2 different naming conventions on routing modules | ||
const routingModulePathOptions = []; | ||
const appDirectory = `apps/${projectName}/src/app/`; | ||
routingModulePathOptions.push(`${appDirectory}app.routing.ts`); | ||
routingModulePathOptions.push(`${appDirectory}app-routing.module.ts`); | ||
|
||
chains.push((tree: Tree, context: SchematicContext) => { | ||
return XplatFeatureHelpers.addFiles(options, platPrefix, projectName)( | ||
tree, | ||
context | ||
); | ||
}); | ||
if (options.routing) { | ||
chains.push((tree: Tree, context: SchematicContext) => { | ||
return adjustRouting(options, routingModulePathOptions, platPrefix)( | ||
tree, | ||
context | ||
); | ||
}); | ||
if (options.adjustSandbox) { | ||
chains.push((tree: Tree, context: SchematicContext) => { | ||
return adjustSandbox( | ||
options, | ||
<PlatformTypes>platPrefix, | ||
appDirectory | ||
)(tree, context); | ||
}); | ||
} | ||
} | ||
if (!options.onlyModule) { | ||
chains.push((tree: Tree, context: SchematicContext) => { | ||
return XplatFeatureHelpers.addFiles( | ||
options, | ||
platPrefix, | ||
projectName, | ||
'_component' | ||
)(tree, context); | ||
}); | ||
} | ||
} | ||
} | ||
} else { | ||
// projectChains.push(noop()); | ||
|
||
chains.push((tree: Tree, context: SchematicContext) => | ||
XplatFeatureHelpers.addFiles(options, 'ionic', null, null, 'angular')( | ||
tree, | ||
context | ||
) | ||
); | ||
// update index | ||
chains.push((tree: Tree, context: SchematicContext) => { | ||
const xplatFolderName = XplatHelpers.getXplatFoldername( | ||
'ionic', | ||
null, | ||
'_component', | ||
'angular' | ||
)(tree, context) | ||
); | ||
); | ||
return XplatFeatureHelpers.adjustBarrelIndex( | ||
options, | ||
`xplat/${xplatFolderName}/features/index.ts` | ||
)(tree, context); | ||
}); | ||
// add starting component unless onlyModule | ||
if (!options.onlyModule) { | ||
chains.push((tree: Tree, context: SchematicContext) => | ||
XplatFeatureHelpers.addFiles( | ||
options, | ||
'ionic', | ||
null, | ||
'_component', | ||
'angular' | ||
)(tree, context) | ||
); | ||
} | ||
} | ||
|
||
return chain([prerun(), ...xplatChains]); | ||
return chain([prerun(), ...chains]); | ||
} |
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