diff --git a/adding-angular-CLI-to-NativeScript.md b/adding-angular-CLI-to-NativeScript.md index b1f215d..ecd5585 100644 --- a/adding-angular-CLI-to-NativeScript.md +++ b/adding-angular-CLI-to-NativeScript.md @@ -15,7 +15,12 @@ "root": "", "sourceRoot": ".", "projectType": "application", - "prefix": "app" + "prefix": "app", + "schematics": { + "@schematics/angular:component": { + "style": "scss" + } + } } }, "defaultProject": "my-project-name" diff --git a/package.json b/package.json index 8cd49e6..d75dcd6 100644 --- a/package.json +++ b/package.json @@ -29,11 +29,11 @@ "@angular-devkit/schematics": "~11.0.0", "@nativescript/tslint-rules": "~0.0.5", "@phenomnomnominal/tsquery": "^4.1.0", + "@schematics/angular": "~11.0.0", "strip-json-comments": "~3.1.1" }, "devDependencies": { "@angular/cli": "~11.0.0", - "@schematics/angular": "~11.0.0", "@types/jasmine": "~3.5.0", "@types/jasminewd2": "~2.0.3", "@types/node": "^12.11.1", diff --git a/src/generate/utils.ts b/src/generate/utils.ts index 6ea196f..4071eff 100644 --- a/src/generate/utils.ts +++ b/src/generate/utils.ts @@ -1,5 +1,6 @@ -import { getPackageJson } from '../utils'; //getNsConfig +import { getPackageJson } from '../utils'; import { Tree, SchematicsException } from '@angular-devkit/schematics'; +import { normalize } from '@angular-devkit/core'; import { extname } from 'path'; import { Schema as ComponentOptions } from './component/schema'; import { Schema as ModuleOptions } from './module/schema'; @@ -31,15 +32,7 @@ const isNs = (tree: Tree) => { }; const isWeb = (tree: Tree) => { - if (!tree.exists('nativescript.config.ts')) { - console.log(`nativescript.config.ts not found. Assuming this is a {N} only project`); - - return false; - } - - // const config = getNsConfig(tree); - - return true;//config.webext != null; + return tree.exists(normalize('/src/main.tns.ts')); }; export interface PlatformUse { @@ -77,24 +70,16 @@ export const getPlatformUse = (tree: Tree, options: Options): PlatformUse => { }; export const getExtensions = (tree: Tree, options: Options): Extensions => { - // let ns = options.nsExtension; - // let web = options.webExtension; - - // if (isWeb(tree)) { - // const nsconfig = getNsConfig(tree); - - // ns = ns || nsconfig.nsext; - // web = web || nsconfig.webext; - - // if (ns === web) { - // ns = DEFAULT_SHARED_EXTENSIONS.ns; - // web = DEFAULT_SHARED_EXTENSIONS.web; - // } - // } + if (isWeb(tree)) { + return { + ns: DEFAULT_SHARED_EXTENSIONS.ns, + web: DEFAULT_SHARED_EXTENSIONS.web, + }; + } return { - ns: DEFAULT_SHARED_EXTENSIONS.ns,// parseExtension(ns || ''), - web: DEFAULT_SHARED_EXTENSIONS.web //parseExtension(web || ''), + ns: '', + web: '', }; };