diff --git a/src/app.nativescript/_routing_files/app/features/home/components/home.component.ts b/src/app.nativescript/_routing_files/app/features/home/components/home.component.ts index a3209f8f..cbab843f 100644 --- a/src/app.nativescript/_routing_files/app/features/home/components/home.component.ts +++ b/src/app.nativescript/_routing_files/app/features/home/components/home.component.ts @@ -1,5 +1,5 @@ import { Component } from '@angular/core'; - +<% if (setupSandbox) { %>import { RouterExtensions } from 'nativescript-angular/router';<% } %> import { BaseComponent } from '@<%= npmScope %>/core'; @Component({ @@ -7,4 +7,15 @@ import { BaseComponent } from '@<%= npmScope %>/core'; selector: '<%= prefix %>-home', templateUrl: './home.component.html' }) -export class HomeComponent extends BaseComponent {} +export class HomeComponent extends BaseComponent { +<% if (setupSandbox) { %> + constructor(private _routerExt: RouterExtensions) { + + } + + // for quick sandbox feature creation + goTo(route: string) { + this._routerExt.navigate([route]); + } +<% } %> +} diff --git a/src/app.nativescript/index.ts b/src/app.nativescript/index.ts index c3a0e389..f57cfa98 100644 --- a/src/app.nativescript/index.ts +++ b/src/app.nativescript/index.ts @@ -47,9 +47,13 @@ export default function (options: ApplicationOptions) { (tree: Tree) => { const scripts = {}; const platformApp = options.name.replace('-', '.'); + // standard apps don't have hmr on by default since results can vary + // more reliable to leave off by default for now + // however, sandbox setup due to its simplicity uses hmr by default + let hmr = options.setupSandbox ? ' --hmr' : ''; scripts[`clean`] = `npx rimraf -- hooks node_modules package-lock.json && npm i`; - scripts[`start.${platformApp}.ios`] = `cd apps/${options.name} && tns run ios --emulator --bundle`; - scripts[`start.${platformApp}.android`] = `cd apps/${options.name} && tns run android --emulator --bundle`; + scripts[`start.${platformApp}.ios`] = `cd apps/${options.name} && tns run ios --emulator --bundle${hmr}`; + scripts[`start.${platformApp}.android`] = `cd apps/${options.name} && tns run android --emulator --bundle${hmr}`; scripts[`clean.${platformApp}`] = `cd apps/${options.name} && npx rimraf -- hooks node_modules platforms package-lock.json && npm i && npx rimraf -- package-lock.json`; return updatePackageScripts(tree, scripts); }, diff --git a/src/utils/general.ts b/src/utils/general.ts index 280171a7..64b25d41 100644 --- a/src/utils/general.ts +++ b/src/utils/general.ts @@ -980,11 +980,11 @@ export function updateIDESettings( : "/var/local/Code/User/settings.json"; const windowsHome = process.env.APPDATA; if (windowsHome) { - userSettingsVSCodePath = join(windowsHome, "Code/User/settings.json"); + userSettingsVSCodePath = join(windowsHome, "Code", "User", "settings.json"); } // console.log('userSettingsVSCodePath:',userSettingsVSCodePath); const isVsCode = fs.existsSync(userSettingsVSCodePath); - + let vscodeCreateSettingsNote = `It's possible you don't have a user settings.json yet. If so, open VS Code User settings and save any kind of setting to have it created.`; // console.log('isVsCode:',isVsCode); if (isVsCode) { const userSettings = fs.readFileSync(userSettingsVSCodePath, "UTF-8"); @@ -1035,90 +1035,94 @@ export function updateIDESettings( userSettingsVSCodePath, JSON.stringify(userSettingsJson, null, 2) ); + } else { + console.warn(`Warning: xplat could not read your VS Code settings.json file therefore development mode has not been set. ${vscodeCreateSettingsNote}`); } + } else { + console.log(`Note to VS Code users: no development mode set. xplat could not find any VS Code settings in the standard location: ${userSettingsVSCodePath} ${vscodeCreateSettingsNote}`) } // WebStorm support let isWebStorm = false; // list preferences to get correct webstorm prefs file - let preferencesFolder = isMac - ? process.env.HOME + - `/Library/Preferences` - : __dirname; - if (windowsHome) { - preferencesFolder = windowsHome; - } - const prefs = fs.readdirSync(preferencesFolder).filter(f => fs.statSync(join(preferencesFolder, f)).isDirectory()); + // let preferencesFolder = isMac + // ? process.env.HOME + + // `/Library/Preferences` + // : __dirname; + // if (windowsHome) { + // preferencesFolder = windowsHome; + // } + // const prefs = fs.readdirSync(preferencesFolder).filter(f => fs.statSync(join(preferencesFolder, f)).isDirectory()); // find first one // TODO: user may have multiple version installed (or at least older versions) so may need to handle if multiples - let webStormPrefFolderName = prefs.find(f => f.indexOf('WebStorm20') > -1); - if (webStormPrefFolderName) { - isWebStorm = true; - webStormPrefFolderName = webStormPrefFolderName.split('/').slice(-1)[0]; - // console.log('webStormPrefFolderName:',webStormPrefFolderName); + // let webStormPrefFolderName = prefs.find(f => f.indexOf('WebStorm20') > -1); + // if (webStormPrefFolderName) { + // isWebStorm = true; + // webStormPrefFolderName = webStormPrefFolderName.split('/').slice(-1)[0]; + // // console.log('webStormPrefFolderName:',webStormPrefFolderName); - // ensure folders are excluded from project view - let projectViewWebStormPath = - isMac - ? process.env.HOME + - `/Library/Preferences/${webStormPrefFolderName}/options/projectView.xml` - : join(__dirname, webStormPrefFolderName, 'config'); - if (windowsHome) { - projectViewWebStormPath = join(windowsHome, webStormPrefFolderName, 'config'); - } - - let projectView = fs.readFileSync(projectViewWebStormPath, "UTF-8"); - if (projectView) { - // console.log('projectView:', projectView); - xml2js.parseString(projectView, (err, settings) => { - // console.log(util.inspect(settings, false, null)); - if (settings && settings.application && settings.application.component && settings.application.component.length) { - const builder = new xml2js.Builder({ headless: true }); - - const sharedSettingsIndex = (>settings.application.component).findIndex(c => c.$.name === 'ProjectViewSharedSettings'); - if (sharedSettingsIndex > -1) { - const sharedSettings = settings.application.component[sharedSettingsIndex]; - if (sharedSettings.option && sharedSettings.option.length) { - const showExcludedFilesIndex = sharedSettings.option.findIndex(o => o.$.name === 'showExcludedFiles'); - if (showExcludedFilesIndex > -1) { - settings.application.component[sharedSettingsIndex].option[showExcludedFilesIndex].$.value = `${!isExcluding}`; - } else { - settings.application.component[sharedSettingsIndex].option.push(webStormExcludedViewNode(isExcluding)); - } - } else { - settings.application.component[sharedSettingsIndex].option = [ - webStormExcludedViewNode(isExcluding) - ]; - } - settings = builder.buildObject(settings); - } else { - (>settings.application.component).push({ - $: 'ProjectViewSharedSettings', - option: [ - webStormExcludedViewNode(isExcluding) - ] - }); - settings = builder.buildObject(settings); - } - } else { - // create projectView.xml - settings = createWebStormProjectView(isExcluding); - } - // modify projectView - // console.log('settings:', settings); - fs.writeFileSync( - projectViewWebStormPath, - settings - ); - }); - } else { - // create projectView.xml - fs.writeFileSync( - projectViewWebStormPath, - createWebStormProjectView(isExcluding) - ); - } - } + // // ensure folders are excluded from project view + // let projectViewWebStormPath = + // isMac + // ? process.env.HOME + + // `/Library/Preferences/${webStormPrefFolderName}/options/projectView.xml` + // : join(__dirname, webStormPrefFolderName, 'config'); + // if (windowsHome) { + // projectViewWebStormPath = join(windowsHome, webStormPrefFolderName, 'config'); + // } + + // let projectView = fs.readFileSync(projectViewWebStormPath, "UTF-8"); + // if (projectView) { + // // console.log('projectView:', projectView); + // xml2js.parseString(projectView, (err, settings) => { + // // console.log(util.inspect(settings, false, null)); + // if (settings && settings.application && settings.application.component && settings.application.component.length) { + // const builder = new xml2js.Builder({ headless: true }); + + // const sharedSettingsIndex = (>settings.application.component).findIndex(c => c.$.name === 'ProjectViewSharedSettings'); + // if (sharedSettingsIndex > -1) { + // const sharedSettings = settings.application.component[sharedSettingsIndex]; + // if (sharedSettings.option && sharedSettings.option.length) { + // const showExcludedFilesIndex = sharedSettings.option.findIndex(o => o.$.name === 'showExcludedFiles'); + // if (showExcludedFilesIndex > -1) { + // settings.application.component[sharedSettingsIndex].option[showExcludedFilesIndex].$.value = `${!isExcluding}`; + // } else { + // settings.application.component[sharedSettingsIndex].option.push(webStormExcludedViewNode(isExcluding)); + // } + // } else { + // settings.application.component[sharedSettingsIndex].option = [ + // webStormExcludedViewNode(isExcluding) + // ]; + // } + // settings = builder.buildObject(settings); + // } else { + // (>settings.application.component).push({ + // $: 'ProjectViewSharedSettings', + // option: [ + // webStormExcludedViewNode(isExcluding) + // ] + // }); + // settings = builder.buildObject(settings); + // } + // } else { + // // create projectView.xml + // settings = createWebStormProjectView(isExcluding); + // } + // // modify projectView + // // console.log('settings:', settings); + // fs.writeFileSync( + // projectViewWebStormPath, + // settings + // ); + // }); + // } else { + // // create projectView.xml + // fs.writeFileSync( + // projectViewWebStormPath, + // createWebStormProjectView(isExcluding) + // ); + // } + // } if (!devMode) { // only when not specifying a dev mode @@ -1168,7 +1172,7 @@ export function updateIDESettings( }; if (isVsCode) { - const workspaceSettingsPath = join(cwd, ".vscode/settings.json"); + const workspaceSettingsPath = join(cwd, ".vscode", "settings.json"); // console.log('workspaceSettingsPath:',workspaceSettingsPath); let workspaceSettingsJson: any = {}; if (fs.existsSync(workspaceSettingsPath)) {