@@ -27,6 +27,7 @@ const pkgJsonOrder = [
27
27
'main' ,
28
28
'module' ,
29
29
'browser' ,
30
+ 'exports' ,
30
31
'man' ,
31
32
'preferGlobal' ,
32
33
'bin' ,
@@ -52,6 +53,8 @@ const pkgJsonOrder = [
52
53
'publishConfig' ,
53
54
] ;
54
55
56
+ const sortedValues = [ 'dependencies' , 'devDependencies' ] ;
57
+
55
58
/**
56
59
*
57
60
* @param {Function[] } mixins
@@ -328,13 +331,15 @@ export async function writeFilesToDisk() {
328
331
export function optionsToCommand ( options , generatorName = '@open-wc' ) {
329
332
let command = `npm init ${ generatorName } ` ;
330
333
Object . keys ( options ) . forEach ( key => {
331
- const value = options [ key ] ;
332
- if ( typeof value === 'string' || typeof value === 'number' ) {
333
- command += `--${ key } ${ value } ` ;
334
- } else if ( typeof value === 'boolean' && value === true ) {
335
- command += `--${ key } ` ;
336
- } else if ( Array . isArray ( value ) ) {
337
- command += `--${ key } ${ value . join ( ' ' ) } ` ;
334
+ if ( key !== '_scaffoldFilesFor' ) {
335
+ const value = options [ key ] ;
336
+ if ( typeof value === 'string' || typeof value === 'number' ) {
337
+ command += `--${ key } ${ value } ` ;
338
+ } else if ( typeof value === 'boolean' && value === true ) {
339
+ command += `--${ key } ` ;
340
+ } else if ( Array . isArray ( value ) ) {
341
+ command += `--${ key } ${ value . join ( ' ' ) } ` ;
342
+ }
338
343
}
339
344
} ) ;
340
345
return command ;
@@ -445,11 +450,20 @@ export function copyTemplateJsonInto(
445
450
const temp = { } ;
446
451
const indexOf = k => {
447
452
const i = pkgJsonOrder . indexOf ( k ) ;
448
- return i === - 1 ? Infinity : 0 ;
453
+ return i === - 1 ? Number . MAX_SAFE_INTEGER : i ;
449
454
} ;
450
455
const entries = Object . entries ( finalObj ) . sort ( ( [ a ] , [ b ] ) => indexOf ( a ) - indexOf ( b ) ) ;
451
456
for ( const [ k , v ] of entries ) {
452
- temp [ k ] = v ;
457
+ let finalV = v ;
458
+ if ( sortedValues . includes ( k ) ) {
459
+ const newV = { } ;
460
+ const vEntries = Object . entries ( v ) . sort ( ) ;
461
+ for ( const [ k2 , v2 ] of vEntries ) {
462
+ newV [ k2 ] = v2 ;
463
+ }
464
+ finalV = newV ;
465
+ }
466
+ temp [ k ] = finalV ;
453
467
}
454
468
finalObj = temp ;
455
469
}
0 commit comments