Skip to content

Commit ab4f9f2

Browse files
authored
fix: CLI code generation in ng11.1+ NS-only projects (#314)
1 parent c087d48 commit ab4f9f2

File tree

3 files changed

+18
-28
lines changed

3 files changed

+18
-28
lines changed

adding-angular-CLI-to-NativeScript.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
"root": "",
1616
"sourceRoot": ".",
1717
"projectType": "application",
18-
"prefix": "app"
18+
"prefix": "app",
19+
"schematics": {
20+
"@schematics/angular:component": {
21+
"style": "scss"
22+
}
23+
}
1924
}
2025
},
2126
"defaultProject": "my-project-name"

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@
2929
"@angular-devkit/schematics": "~11.0.0",
3030
"@nativescript/tslint-rules": "~0.0.5",
3131
"@phenomnomnominal/tsquery": "^4.1.0",
32+
"@schematics/angular": "~11.0.0",
3233
"strip-json-comments": "~3.1.1"
3334
},
3435
"devDependencies": {
3536
"@angular/cli": "~11.0.0",
36-
"@schematics/angular": "~11.0.0",
3737
"@types/jasmine": "~3.5.0",
3838
"@types/jasminewd2": "~2.0.3",
3939
"@types/node": "^12.11.1",

src/generate/utils.ts

+11-26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { getPackageJson } from '../utils'; //getNsConfig
1+
import { getPackageJson } from '../utils';
22
import { Tree, SchematicsException } from '@angular-devkit/schematics';
3+
import { normalize } from '@angular-devkit/core';
34
import { extname } from 'path';
45
import { Schema as ComponentOptions } from './component/schema';
56
import { Schema as ModuleOptions } from './module/schema';
@@ -31,15 +32,7 @@ const isNs = (tree: Tree) => {
3132
};
3233

3334
const isWeb = (tree: Tree) => {
34-
if (!tree.exists('nativescript.config.ts')) {
35-
console.log(`nativescript.config.ts not found. Assuming this is a {N} only project`);
36-
37-
return false;
38-
}
39-
40-
// const config = getNsConfig(tree);
41-
42-
return true;//config.webext != null;
35+
return tree.exists(normalize('/src/main.tns.ts'));
4336
};
4437

4538
export interface PlatformUse {
@@ -77,24 +70,16 @@ export const getPlatformUse = (tree: Tree, options: Options): PlatformUse => {
7770
};
7871

7972
export const getExtensions = (tree: Tree, options: Options): Extensions => {
80-
// let ns = options.nsExtension;
81-
// let web = options.webExtension;
82-
83-
// if (isWeb(tree)) {
84-
// const nsconfig = getNsConfig(tree);
85-
86-
// ns = ns || nsconfig.nsext;
87-
// web = web || nsconfig.webext;
88-
89-
// if (ns === web) {
90-
// ns = DEFAULT_SHARED_EXTENSIONS.ns;
91-
// web = DEFAULT_SHARED_EXTENSIONS.web;
92-
// }
93-
// }
73+
if (isWeb(tree)) {
74+
return {
75+
ns: DEFAULT_SHARED_EXTENSIONS.ns,
76+
web: DEFAULT_SHARED_EXTENSIONS.web,
77+
};
78+
}
9479

9580
return {
96-
ns: DEFAULT_SHARED_EXTENSIONS.ns,// parseExtension(ns || ''),
97-
web: DEFAULT_SHARED_EXTENSIONS.web //parseExtension(web || ''),
81+
ns: '',
82+
web: '',
9883
};
9984
};
10085

0 commit comments

Comments
 (0)