1- import {
2- apply ,
3- chain ,
4- Tree ,
5- Rule ,
6- url ,
7- move ,
8- template ,
9- mergeWith ,
10- branchAndMerge ,
11- SchematicContext ,
12- SchematicsException ,
13- schematic ,
14- noop ,
15- externalSchematic ,
16- } from '@angular-devkit/schematics' ;
17- import {
18- prerun ,
19- missingArgument ,
20- PluginHelpers ,
21- updatePackageScripts ,
22- getPrefix ,
23- updateWorkspace ,
24- updateNxProjects ,
25- getAppName ,
26- getDefaultTemplateOptions ,
27- getFrontendFramework ,
28- } from '../../utils' ;
1+ import { apply , branchAndMerge , chain , externalSchematic , mergeWith , move , noop , Rule , SchematicContext , SchematicsException , template , Tree , url } from '@angular-devkit/schematics' ;
2+ import { getAppName , getDefaultTemplateOptions , getFrontendFramework , getPrefix , missingArgument , PluginHelpers , prerun , updateNxProjects , updatePackageScripts , updateWorkspace } from '../../utils' ;
293import { nsWebpackVersion } from '../../utils/versions' ;
304import { Schema } from './schema' ;
315
326export default function ( options : Schema ) {
337 if ( ! options . name ) {
34- throw new SchematicsException (
35- missingArgument (
36- 'name' ,
37- 'Provide a name for your NativeScript app.' ,
38- 'nx g @nativescript/nx:app name'
39- )
40- ) ;
8+ throw new SchematicsException ( missingArgument ( 'name' , 'Provide a name for your NativeScript app.' , 'nx g @nativescript/nx:app name' ) ) ;
419 }
4210
4311 return chain ( [
4412 prerun ( options , true ) ,
4513 PluginHelpers . applyAppNamingConvention ( options , 'nativescript' ) ,
46- ( tree : Tree , context : SchematicContext ) =>
47- addAppFiles ( options , options . name ) ,
14+ ( tree : Tree , context : SchematicContext ) => addAppFiles ( options , options . name ) ,
4815 // add extra files per options
49- ( tree : Tree , context : SchematicContext ) =>
50- options . routing && [ 'angular' ] . includes ( options . framework )
51- ? addAppFiles ( options , options . name , 'routing' )
52- : noop ( ) ,
16+ ( tree : Tree , context : SchematicContext ) => ( options . routing && [ 'angular' ] . includes ( options . framework ) ? addAppFiles ( options , options . name , 'routing' ) : noop ( ) ) ,
5317 // add app resources
5418 ( tree : Tree , context : SchematicContext ) =>
5519 externalSchematic (
5620 '@nativescript/nx' ,
5721 'app-resources' ,
5822 {
59- path : `apps/${ options . directory ? options . directory + '/' : '' } ${
60- options . name
61- } `,
23+ path : `apps/${ options . directory ? options . directory + '/' : '' } ${ options . name } ` ,
6224 } ,
6325 { interactive : false }
6426 ) ( tree , context ) ,
@@ -67,9 +29,7 @@ export default function (options: Schema) {
6729 PluginHelpers . addPackageInstallTask ( options ) ,
6830 ( tree : Tree ) => {
6931 const scripts = { } ;
70- scripts [
71- `clean`
72- ] = `npx rimraf hooks node_modules package-lock.json && npm i` ;
32+ scripts [ `clean` ] = `npx rimraf hooks node_modules package-lock.json && npm i` ;
7333 return updatePackageScripts ( tree , scripts ) ;
7434 } ,
7535 ( tree : Tree , context : SchematicContext ) => {
@@ -106,19 +66,15 @@ export default function (options: Schema) {
10666 ios : {
10767 builder : '@nrwl/workspace:run-commands' ,
10868 options : {
109- commands : [
110- `ns debug ios --no-hmr --env.configuration={args.configuration} --env.projectName=${ options . name } ` ,
111- ] ,
69+ commands : [ `ns debug ios --no-hmr --env.configuration={args.configuration} --env.projectName=${ options . name } ` ] ,
11270 cwd : appPath ,
11371 parallel : false ,
11472 } ,
11573 } ,
11674 android : {
11775 builder : '@nrwl/workspace:run-commands' ,
11876 options : {
119- commands : [
120- `ns debug android --no-hmr --env.configuration={args.configuration} --env.projectName=${ options . name } ` ,
121- ] ,
77+ commands : [ `ns debug android --no-hmr --env.configuration={args.configuration} --env.projectName=${ options . name } ` ] ,
12278 cwd : appPath ,
12379 parallel : false ,
12480 } ,
@@ -173,7 +129,7 @@ function addAppFiles(options: Schema, appName: string, extra: string = ''): Rule
173129 appname,
174130 pathOffset : directory ? '../../../' : '../../' ,
175131 libFolderName : PluginHelpers . getLibFoldername ( 'nativescript' ) ,
176- nsWebpackVersion
132+ nsWebpackVersion,
177133 } ) ,
178134 move ( `apps/${ directory } ${ appName } ` ) ,
179135 ] )
0 commit comments