@@ -27,10 +27,10 @@ import { Schema as ConvertRelativeImportsSchema } from '../convert-relative-impo
2727let extensions : Extensions ;
2828let projectSettings : AngularProjectSettings ;
2929
30- export default function ( options : MigrationOptions ) : Rule {
30+ export default function ( options : MigrationOptions ) : Rule {
3131 extensions = {
3232 ns : ( options . nsExtension . length > 0 ) ? '.' + options . nsExtension : '' ,
33- web : ( options . webExtension . length > 0 ) ? '.' + options . webExtension : ''
33+ web : ( options . webExtension . length > 0 ) ? '.' + options . webExtension : '' ,
3434 } ;
3535
3636 return chain ( [
@@ -72,7 +72,9 @@ export default function (options: MigrationOptions): Rule {
7272 */
7373const validateOptions = ( options : MigrationOptions ) => ( ) => {
7474 if ( options . nsExtension === options . webExtension ) {
75- throw new SchematicsException ( `nsExtension "${ options . nsExtension } " and webExtension "${ options . webExtension } " should have different values` ) ;
75+ throw new SchematicsException (
76+ `nsExtension "${ options . nsExtension } " and webExtension "${ options . webExtension } " should have different values` ,
77+ ) ;
7678 }
7779} ;
7880
@@ -98,10 +100,10 @@ ${JSON.stringify(angularJson.cli, null, 2)}
98100${ JSON . stringify ( angularJson . cli , null , 2 ) } `) ;
99101 }
100102
101- angularJson . cli = { 'defaultCollection' : defaultCollection } ;
103+ angularJson . cli = { defaultCollection } ;
102104
103105 tree . overwrite ( 'angular.json' , JSON . stringify ( angularJson , null , 2 ) ) ;
104- }
106+ } ;
105107
106108const addNsFiles = ( options : MigrationOptions ) => ( _tree : Tree , context : SchematicContext ) => {
107109 context . logger . info ( 'Adding {N} files' ) ;
@@ -126,11 +128,12 @@ const addNsFiles = (options: MigrationOptions) => (_tree: Tree, context: Schemat
126128 entryComponentName : projectSettings . entryComponentName ,
127129 entryComponentImportPath : projectSettings . entryComponentImportPath ,
128130
129- indexAppRootTag : projectSettings . indexAppRootTag
131+ indexAppRootTag : projectSettings . indexAppRootTag ,
130132 } ;
131133 const templateSource = apply ( url ( './_ns-files' ) , [
132- template ( templateOptions )
134+ template ( templateOptions ) ,
133135 ] ) ;
136+
134137 return mergeWith ( templateSource ) ;
135138} ;
136139
@@ -156,9 +159,10 @@ const addSampleFiles = () => (_tree: Tree, context: SchematicContext) => {
156159const addSampleComponent = ( nsExtension : string , webExtension : string , project : string ) =>
157160 ( _tree , context : SchematicContext ) => {
158161 context . logger . info ( 'Adding Sample Shared Component' ) ;
162+
159163 return schematic ( 'component' , {
160- nsExtension : nsExtension ,
161- webExtension : webExtension ,
164+ nsExtension,
165+ webExtension,
162166 web : true ,
163167 nativescript : true ,
164168 name : 'auto-generated' ,
@@ -171,8 +175,9 @@ const addSampleComponent = (nsExtension: string, webExtension: string, project:
171175
172176const addAppResources = ( ) => ( _tree : Tree , context : SchematicContext ) => {
173177 context . logger . info ( 'Adding App_Resources' ) ;
178+
174179 return schematic ( 'app-resources' , {
175- path : ''
180+ path : '' ,
176181 } ) ;
177182} ;
178183
@@ -195,7 +200,7 @@ const mergeGitIgnore = (tree: Tree, context: SchematicContext) => {
195200 'platforms/' ,
196201 'hooks/' ,
197202 `${ projectSettings . sourceRoot } /**/*.js` ,
198- ] . filter ( line => ! gitignore . includes ( line ) ) ;
203+ ] . filter ( ( line ) => ! gitignore . includes ( line ) ) ;
199204
200205 const nsGitignoreContent =
201206 `# NativeScript` +
@@ -207,7 +212,7 @@ const mergeGitIgnore = (tree: Tree, context: SchematicContext) => {
207212 recorder . insertLeft ( 0 , nsGitignoreContent ) ;
208213
209214 tree . commitUpdate ( recorder ) ;
210- }
215+ } ;
211216
212217/**
213218 * Adds {N} npm run scripts to package.json
@@ -223,24 +228,23 @@ const addRunScriptsToPackageJson = (tree: Tree, context: SchematicContext) => {
223228 android : 'tns run android --bundle' ,
224229 ios : 'tns run ios --bundle' ,
225230 mobile : 'tns run --bundle' ,
226- preview : 'tns preview --bundle'
231+ preview : 'tns preview --bundle' ,
227232 } ;
228- packageJson . scripts = Object . assign ( { } , scriptsToAdd , packageJson . scripts ) ;
233+ packageJson . scripts = { ... scriptsToAdd , ... packageJson . scripts } ;
229234
230235 overwritePackageJson ( tree , packageJson ) ;
231- }
236+ } ;
232237
233238const addNativeScriptProjectId = ( tree : Tree , context : SchematicContext ) => {
234239 context . logger . info ( 'Adding NativeScript Project ID to package.json' ) ;
235240 const packageJson : any = getJsonFile ( tree , 'package.json' ) ;
236241
237242 packageJson . nativescript = packageJson . nativescript || { } ;
238- packageJson . nativescript = Object . assign ( {
239- id : 'org.nativescript.ngsample'
240- } , packageJson . nativescript ) ;
243+ packageJson . nativescript = {
244+ id : 'org.nativescript.ngsample' , ...packageJson . nativescript } ;
241245
242246 tree . overwrite ( 'package.json' , JSON . stringify ( packageJson , null , 2 ) ) ;
243- }
247+ } ;
244248
245249/**
246250 * Add web-specific path mappings and files
@@ -264,42 +268,42 @@ const modifyWebTsconfig = (tree: Tree, context: SchematicContext) => {
264268
265269 // paths
266270 const webPaths = {
267- " @src/*" : [
271+ ' @src/*' : [
268272 `${ srcDir } /*.web` ,
269- `${ srcDir } /*` ]
273+ `${ srcDir } /*` ] ,
270274 } ;
271275 tsConfig . compilerOptions = tsConfig . compilerOptions || { } ;
272276 tsConfig . compilerOptions . paths = {
273277 ...tsConfig . compilerOptions . paths ,
274- ...webPaths
275- }
278+ ...webPaths ,
279+ } ;
276280
277281 tree . overwrite ( tsConfigPath , JSON . stringify ( tsConfig , null , 2 ) ) ;
278282
279283 if ( ! tsConfig . extends ) {
280- return
284+ return ;
281285 }
282286
283287 const baseTsConfigPath = join ( dirname ( tsConfigPath ) , tsConfig . extends ) ;
284288 const baseTsConfig : any = getJsonFile ( tree , baseTsConfigPath ) ;
285289
286290 const basePaths = {
287- " @src/*" : [
291+ ' @src/*' : [
288292 `${ srcDir } /*.android.ts` ,
289293 `${ srcDir } /*.ios.ts` ,
290294 `${ srcDir } /*.tns.ts` ,
291295 `${ srcDir } /*.web.ts` ,
292- `${ srcDir } /*` ]
296+ `${ srcDir } /*` ] ,
293297 } ;
294298
295299 baseTsConfig . compilerOptions = baseTsConfig . compilerOptions || { } ;
296300 baseTsConfig . compilerOptions . paths = {
297301 ...baseTsConfig . compilerOptions . paths ,
298- ...basePaths
299- }
302+ ...basePaths ,
303+ } ;
300304
301305 tree . overwrite ( baseTsConfigPath , JSON . stringify ( baseTsConfig , null , 2 ) ) ;
302- }
306+ } ;
303307
304308const addDependencies = ( ) => ( tree : Tree , context : SchematicContext ) => {
305309 context . logger . info ( 'Adding npm dependencies' ) ;
@@ -310,15 +314,15 @@ const addDependencies = () => (tree: Tree, context: SchematicContext) => {
310314 'nativescript-angular' : '~8.0.1' ,
311315 'nativescript-theme-core' : '~1.0.4' ,
312316 'reflect-metadata' : '~0.1.12' ,
313- 'tns-core-modules' : '~5.4.0'
317+ 'tns-core-modules' : '~5.4.0' ,
314318 } ;
315- packageJson . dependencies = Object . assign ( { } , depsToAdd , packageJson . dependencies ) ;
319+ packageJson . dependencies = { ... depsToAdd , ... packageJson . dependencies } ;
316320
317321 const devDepsToAdd = {
318322 'nativescript-dev-webpack' : '~0.24.0' ,
319323 '@nativescript/schematics' : '~0.6.0' ,
320324 } ;
321- packageJson . devDependencies = Object . assign ( { } , devDepsToAdd , packageJson . devDependencies ) ;
325+ packageJson . devDependencies = { ... devDepsToAdd , ... packageJson . devDependencies } ;
322326
323327 overwritePackageJson ( tree , packageJson ) ;
324- }
328+ } ;
0 commit comments