22
33const path = require ( 'path' ) ;
44const fs = require ( 'fs-extra' ) ;
5+ const SilentError = require ( 'silent-error' ) ;
56const existsSync = fs . existsSync ;
67
7- const fastbootInitializerTypes = [ 'initializers' , 'instance-initializers' ] ;
8- const FASTBOOT_DIR = 'fastboot' ;
8+ const fastbootInitializerTypes = [ 'initializers' , 'instance-initializers' ] ;
99
1010/**
1111 * Helper function to check if there are any `(instance-)?intializers/[browser|fastboot]/` path under the
@@ -36,7 +36,7 @@ function _checkBrowserInitializers(rootPath) {
3636 if ( isBrowserInitializersPresent ) {
3737 const errorMsg = `FastBoot build no longer supports ${ rootPath } /app/(instance-)?initializers/browser structure. ` +
3838 `Please refer to http://ember-fastboot.com/docs/addon-author-guide#browser-only-or-node-only-initializers for a migration path.` ;
39- throw new Error ( errorMsg ) ;
39+ throw new SilentError ( errorMsg ) ;
4040 }
4141}
4242
@@ -45,41 +45,11 @@ function _checkBrowserInitializers(rootPath) {
4545 * @param {Object } project
4646 * @param {String } rootPath
4747 */
48- function _moveFastBootInitializers ( project , rootPath ) {
49-
48+ function _checkFastBootInitializers ( project , rootPath ) {
5049 // check to see if it is a fastboot complaint addon
5150 const isFastbootAddon = _checkInitializerTypeExists ( rootPath , 'fastboot' ) ;
5251 if ( isFastbootAddon ) {
53- project . ui . writeDeprecateLine ( `Having fastboot specific code in app directory of ${ rootPath } is deprecated. Please move it to fastboot/app directory.` ) ;
54-
55- const fastbootDirPath = path . join ( rootPath , FASTBOOT_DIR ) ;
56- // check if fastboot/app exists
57- if ( ! existsSync ( fastbootDirPath ) ) {
58- fs . mkdirsSync ( fastbootDirPath ) ;
59- }
60-
61- // copy over app/initializers/fastboot and app/instance/initializers/fastboot
62- fastbootInitializerTypes . forEach ( ( fastbootInitializerType ) => {
63- const srcFastbootPath = path . join ( rootPath , 'app' , fastbootInitializerType , 'fastboot' ) ;
64-
65- if ( existsSync ( srcFastbootPath ) ) {
66- const destFastbootPath = path . join ( fastbootDirPath , fastbootInitializerType ) ;
67- if ( ! existsSync ( destFastbootPath ) ) {
68- fs . mkdirSync ( destFastbootPath ) ;
69- }
70-
71- // fastboot initializer type exists so we need to move this fastboot/app
72- const fastbootFiles = fs . readdirSync ( srcFastbootPath ) ;
73- fastbootFiles . forEach ( ( fastbootFile ) => {
74- const srcPath = path . join ( srcFastbootPath , fastbootFile ) ;
75- const destPath = path . join ( destFastbootPath , fastbootFile ) ;
76- fs . copySync ( srcPath , destPath ) ;
77-
78- // delete the original path files so that there are no two initializers with the same name
79- fs . unlinkSync ( srcPath ) ;
80- } ) ;
81- }
82- } ) ;
52+ throw new SilentError ( `Having fastboot specific code in app directory of ${ rootPath } is deprecated. Please move it to fastboot/app directory.` ) ;
8353 }
8454}
8555
@@ -93,7 +63,7 @@ function _migrateAddonInitializers(project) {
9363 const currentAddonPath = addon . root ;
9464
9565 _checkBrowserInitializers ( currentAddonPath ) ;
96- _moveFastBootInitializers ( project , currentAddonPath ) ;
66+ _checkFastBootInitializers ( project , currentAddonPath ) ;
9767 } ) ;
9868}
9969
@@ -106,7 +76,7 @@ function _migrateHostAppInitializers(project) {
10676 const hostAppPath = path . join ( project . root ) ;
10777
10878 _checkBrowserInitializers ( hostAppPath ) ;
109- _moveFastBootInitializers ( project , hostAppPath ) ;
79+ _checkFastBootInitializers ( project , hostAppPath ) ;
11080}
11181
11282/**
0 commit comments