Skip to content

Commit 8d913e7

Browse files
authored
chore: Angular 10.1 and NativeScript 7 (#296)
1 parent 605b24a commit 8d913e7

File tree

32 files changed

+196
-184
lines changed

32 files changed

+196
-184
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nativescript/schematics",
3-
"version": "10.0.2",
3+
"version": "10.1.0",
44
"description": "Schematics for NativeScript Angular apps.",
55
"scripts": {
66
"clean": "npx rimraf node_modules package-lock.json && npm i",
@@ -25,15 +25,15 @@
2525
},
2626
"schematics": "./src/collection.json",
2727
"dependencies": {
28-
"@angular-devkit/core": "~10.0.0",
29-
"@angular-devkit/schematics": "~10.0.0",
28+
"@angular-devkit/core": "~10.1.0",
29+
"@angular-devkit/schematics": "~10.1.0",
3030
"@nativescript/tslint-rules": "~0.0.5",
3131
"@phenomnomnominal/tsquery": "^4.1.0",
3232
"strip-json-comments": "~3.1.1"
3333
},
3434
"devDependencies": {
35-
"@angular/cli": "~10.0.0",
36-
"@schematics/angular": "~10.0.0",
35+
"@angular/cli": "~10.1.0",
36+
"@schematics/angular": "~10.1.0",
3737
"@types/jasmine": "~3.5.0",
3838
"@types/jasminewd2": "~2.0.3",
3939
"@types/node": "^12.11.1",

src/add-ns/_ns-files/__sourceDir__/package.json

Lines changed: 0 additions & 7 deletions
This file was deleted.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { NativeScriptConfig } from '@nativescript/core';
2+
3+
export default {
4+
id: 'org.nativescript.ngsample',
5+
appResourcesPath: 'App_Resources',
6+
android: {
7+
v8Flags: '--expose_gc',
8+
markingMode: 'none',
9+
},
10+
appPath: '<%= sourceDir %>'
11+
} as NativeScriptConfig;

src/add-ns/_ns-files/nsconfig.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

src/add-ns/index.ts

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export default function(options: MigrationOptions): Rule {
4949
addAppResources(),
5050
mergeGitIgnore,
5151
addRunScriptsToPackageJson,
52-
addNativeScriptProjectId,
52+
// addNativeScriptProjectId,
5353

5454
modifyWebTsconfig,
5555
modifyTsLintConfig,
@@ -223,12 +223,12 @@ const addRunScriptsToPackageJson = (tree: Tree, context: SchematicContext) => {
223223
const packageJson = getPackageJson(tree);
224224

225225
const scriptsToAdd = {
226-
android: 'tns run android --no-hmr',
227-
ios: 'tns run ios --no-hmr',
228-
mobile: 'tns run',
229-
preview: 'tns preview',
230-
ngcc: 'ngcc --properties es2015 module main --first-only',
231-
postinstall: 'npm run ngcc',
226+
android: 'ns run android --no-hmr',
227+
ios: 'ns run ios --no-hmr',
228+
mobile: 'ns run',
229+
// preview: 'ns preview',
230+
// ngcc: 'ngcc --properties es2015 module main --first-only',
231+
// postinstall: 'npm run ngcc',
232232
};
233233
packageJson.scripts = {...scriptsToAdd, ...packageJson.scripts};
234234

@@ -362,18 +362,21 @@ const addDependencies = () => (tree: Tree, context: SchematicContext) => {
362362
context.logger.info('Adding npm dependencies');
363363
const packageJson = getPackageJson(tree);
364364

365+
// add {N} 7 main key
366+
(<any>packageJson).main = 'main.tns.js';
367+
365368
// @UPGRADE: Update all versions whenever {N} version updates
366369
const depsToAdd = {
367-
'@nativescript/angular': '~10.0.0',
368-
'@nativescript/core': 'rc',
369-
'@nativescript/theme': '~2.2.1',
370+
'@nativescript/angular': '~10.1.0',
371+
'@nativescript/core': '~7.0.0',
372+
'@nativescript/theme': '~2.5.0',
370373
'reflect-metadata': '~0.1.12',
371374
tslib: '1.10.0',
372375
};
373376
packageJson.dependencies = {...depsToAdd, ...packageJson.dependencies};
374377

375378
const devDepsToAdd = {
376-
'@nativescript/webpack': '~2.0.0',
379+
'@nativescript/webpack': '~3.0.0',
377380
'@nativescript/tslint-rules': '~0.0.5',
378381
};
379382
packageJson.devDependencies = {...devDepsToAdd, ...packageJson.devDependencies};

src/add-ns/index_spec.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('Add {N} schematic', () => {
4545
it('should add {N} specific files', () => {
4646
const files = appTree.files;
4747

48-
expect(files).toContain('/nsconfig.json');
48+
expect(files).toContain('/nativescript.config.ts');
4949
expect(files).toContain('/tsconfig.tns.json');
5050
expect(files).toContain('/src/app.css');
5151
expect(files).toContain('/src/main.tns.ts');
@@ -94,22 +94,22 @@ describe('Add {N} schematic', () => {
9494
const packageJson = JSON.parse(stripJsonComments(getFileContent(appTree, packageJsonPath)));
9595
const { scripts } = packageJson;
9696
expect(scripts).toBeDefined();
97-
expect(scripts.android).toEqual('tns run android --no-hmr');
98-
expect(scripts.ios).toEqual('tns run ios --no-hmr');
99-
expect(scripts.ngcc).toEqual('ngcc --properties es2015 module main --first-only');
100-
expect(scripts.postinstall).toEqual('npm run ngcc');
97+
expect(scripts.android).toEqual('ns run android --no-hmr');
98+
expect(scripts.ios).toEqual('ns run ios --no-hmr');
99+
// expect(scripts.ngcc).toEqual('ngcc --properties es2015 module main --first-only');
100+
// expect(scripts.postinstall).toEqual('npm run ngcc');
101101
});
102102

103-
it('should add NativeScript key to the package json', () => {
104-
const packageJsonPath = '/package.json';
105-
expect(appTree.files).toContain(packageJsonPath);
103+
// it('should add NativeScript key to the package json', () => {
104+
// const packageJsonPath = '/package.json';
105+
// expect(appTree.files).toContain(packageJsonPath);
106106

107-
const packageJson = JSON.parse(stripJsonComments(getFileContent(appTree, packageJsonPath)));
108-
const { nativescript } = packageJson;
107+
// const packageJson = JSON.parse(stripJsonComments(getFileContent(appTree, packageJsonPath)));
108+
// const { nativescript } = packageJson;
109109

110-
expect(nativescript).toBeDefined();
111-
expect(nativescript.id).toEqual('org.nativescript.ngsample');
112-
});
110+
// expect(nativescript).toBeDefined();
111+
// expect(nativescript.id).toEqual('org.nativescript.ngsample');
112+
// });
113113

114114
it('should modify the tsconfig.app.json (web) to include files and path mappings', () => {
115115
const webTsConfigPath = '/tsconfig.app.json';
@@ -294,7 +294,7 @@ async function setupProject(
294294
'workspace',
295295
{
296296
name: 'workspace',
297-
version: '10.0.0',
297+
version: '10.1.0',
298298
newProjectRoot: '',
299299
},
300300
).toPromise();

src/angular-project-parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
1+
import * as ts from 'typescript';
22
import { basename } from 'path';
33
import { Tree, SchematicsException } from '@angular-devkit/schematics';
44
import { getWorkspace } from '@schematics/angular/utility/config';

src/convert-relative-imports/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
1+
import * as ts from 'typescript';
22
import { IRule, Replacement } from 'tslint';
33
import { tsquery } from '@phenomnomnominal/tsquery';
44
import { Tree, SchematicContext, isContentAction } from '@angular-devkit/schematics';

src/decorator-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as ts from '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript';
1+
import * as ts from 'typescript';
22
import { Tree } from '@angular-devkit/schematics';
33

44
import { findNode, findMatchingNodes, findImportPath, getSourceFile } from './ts-utils';

src/generate-template/master-detail/index.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ import {
1313
import { dasherize, classify } from '@angular-devkit/core/src/utils/strings';
1414

1515
import { Schema as MasterDetailSchema } from './schema';
16-
import { getNsConfig } from '../../utils';
16+
// import { getNsConfig } from '../../utils';
1717
import { join } from 'path';
1818
import { Schema as ConvertRelativeImportsSchema } from '../../convert-relative-imports/schema';
19+
import { DEFAULT_SHARED_EXTENSIONS } from '../../generate/utils';
1920

2021
let projectParams: ProjectInfo;
2122

@@ -69,13 +70,13 @@ interface ProjectInfo {
6970
nsext: string;
7071
}
7172
const getProjectInfo = (tree: Tree): ProjectInfo => {
72-
if (tree.exists('nsconfig.json')) {
73-
const nsconfig = getNsConfig(tree);
73+
if (tree.exists('nativescript.config.ts')) {
74+
// const nsconfig = getNsConfig(tree);
7475

7576
return {
76-
shared: nsconfig.shared,
77-
appPath: join(nsconfig.appPath, 'app'),
78-
nsext: nsconfig.nsext,
77+
shared: true,//nsconfig.shared,
78+
appPath: join(tree.exists('app') ? 'app' : 'src', 'app'), //join(nsconfig.appPath, 'app'),
79+
nsext: DEFAULT_SHARED_EXTENSIONS.ns,// nsconfig.nsext,
7980
};
8081
}
8182

0 commit comments

Comments
 (0)