@@ -11,7 +11,6 @@ import {
1111 MergeStrategy ,
1212 Rule ,
1313 SchematicContext ,
14- SchematicsException ,
1514 Tree ,
1615 apply ,
1716 applyTemplates ,
@@ -28,7 +27,6 @@ import { Schema as ComponentOptions } from '../component/schema';
2827import { NodeDependencyType , addPackageJsonDependency } from '../utility/dependencies' ;
2928import { latestVersions } from '../utility/latest-versions' ;
3029import { relativePathToWorkspaceRoot } from '../utility/paths' ;
31- import { validateProjectName } from '../utility/validation' ;
3230import { getWorkspace , updateWorkspace } from '../utility/workspace' ;
3331import { Builders , ProjectType } from '../utility/workspace-models' ;
3432import { Schema as ApplicationOptions , Style } from './schema' ;
@@ -61,7 +59,11 @@ function addDependenciesToPackageJson(options: ApplicationOptions) {
6159 } ;
6260}
6361
64- function addAppToWorkspaceFile ( options : ApplicationOptions , appDir : string ) : Rule {
62+ function addAppToWorkspaceFile (
63+ options : ApplicationOptions ,
64+ appDir : string ,
65+ folderName : string ,
66+ ) : Rule {
6567 let projectRoot = appDir ;
6668 if ( projectRoot ) {
6769 projectRoot += '/' ;
@@ -151,7 +153,7 @@ function addAppToWorkspaceFile(options: ApplicationOptions, appDir: string): Rul
151153 builder : Builders . Browser ,
152154 defaultConfiguration : 'production' ,
153155 options : {
154- outputPath : `dist/${ options . name } ` ,
156+ outputPath : `dist/${ folderName } ` ,
155157 index : `${ sourceRoot } /index.html` ,
156158 main : `${ sourceRoot } /main.ts` ,
157159 polyfills : `${ sourceRoot } /polyfills.ts` ,
@@ -238,12 +240,6 @@ function minimalPathFilter(path: string): boolean {
238240
239241export default function ( options : ApplicationOptions ) : Rule {
240242 return async ( host : Tree ) => {
241- if ( ! options . name ) {
242- throw new SchematicsException ( `Invalid options, "name" is required.` ) ;
243- }
244-
245- validateProjectName ( options . name ) ;
246-
247243 const appRootSelector = `${ options . prefix } -root` ;
248244 const componentOptions : Partial < ComponentOptions > = ! options . minimal
249245 ? {
@@ -264,13 +260,20 @@ export default function (options: ApplicationOptions): Rule {
264260 const workspace = await getWorkspace ( host ) ;
265261 const newProjectRoot = ( workspace . extensions . newProjectRoot as string | undefined ) || '' ;
266262 const isRootApp = options . projectRoot !== undefined ;
263+
264+ // If scoped project (i.e. "@foo/bar"), convert dir to "foo/bar".
265+ let folderName = options . name . startsWith ( '@' ) ? options . name . substr ( 1 ) : options . name ;
266+ if ( / [ A - Z ] / . test ( folderName ) ) {
267+ folderName = strings . dasherize ( folderName ) ;
268+ }
269+
267270 const appDir = isRootApp
268271 ? normalize ( options . projectRoot || '' )
269- : join ( normalize ( newProjectRoot ) , strings . dasherize ( options . name ) ) ;
272+ : join ( normalize ( newProjectRoot ) , folderName ) ;
270273 const sourceDir = `${ appDir } /src/app` ;
271274
272275 return chain ( [
273- addAppToWorkspaceFile ( options , appDir ) ,
276+ addAppToWorkspaceFile ( options , appDir , folderName ) ,
274277 mergeWith (
275278 apply ( url ( './files' ) , [
276279 options . minimal ? filter ( minimalPathFilter ) : noop ( ) ,
@@ -280,6 +283,7 @@ export default function (options: ApplicationOptions): Rule {
280283 relativePathToWorkspaceRoot : relativePathToWorkspaceRoot ( appDir ) ,
281284 appName : options . name ,
282285 isRootApp,
286+ folderName,
283287 } ) ,
284288 move ( appDir ) ,
285289 ] ) ,
0 commit comments