Skip to content

Commit f232616

Browse files
authored
Merge pull request #30 from GeoTecINIT/migrate-ns8
Migrate to NS8
2 parents f36b4f6 + 880632f commit f232616

36 files changed

+7420
-14268
lines changed

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ steps:
5252
condition: succeededOrFailed()
5353
inputs:
5454
testResultsFormat: 'JUnit'
55-
testResultsFiles: 'demo/test-reports/**/report.xml'
55+
testResultsFiles: 'demo/app/test-reports/**/report.xml'

ci-tools/wait-for-emulator.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#!/usr/bin/env bash
22

33
# Install AVD files
4-
echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install 'system-images;android-30;google_apis;x86'
4+
echo "y" | $ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager --install 'system-images;android-27;google_apis;x86'
55

66
# Create emulator
7-
echo "no" | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n xamarin_android_emulator -k 'system-images;android-30;google_apis;x86' --force
7+
echo "no" | $ANDROID_HOME/cmdline-tools/latest/bin/avdmanager create avd -n xamarin_android_emulator -k 'system-images;android-27;google_apis;x86' --force
88

99
$ANDROID_HOME/emulator/emulator -list-avds
1010

demo/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ npm-debug.log*
1616
yarn-debug.log*
1717
yarn-error.log*
1818
test-reports
19+
coverage
1920

2021
# General
2122
.DS_Store

demo/app/App_Resources/Android/app.gradle

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@
1010
// create a file named before-plugins.gradle in the current directory and place it there
1111

1212
android {
13-
// todo: remove once ndk 23+ is supported
14-
ndkVersion "22.1.7171670"
15-
compileSdkVersion 30
1613
defaultConfig {
1714
minSdkVersion 22
18-
targetSdkVersion 30
1915
generatedDensities = []
2016
}
2117
aaptOptions {

demo/app/App_Resources/Android/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
android:name="com.tns.NativeScriptActivity"
3838
android:label="@string/title_activity_kimera"
3939
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|locale|uiMode"
40-
android:theme="@style/LaunchScreenTheme">
40+
android:theme="@style/LaunchScreenTheme"
41+
android:exported="true">
4142

4243
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
4344

demo/app/app.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
@import "~@nativescript/theme/css/core.css";
2-
@import "~@nativescript/theme/css/blue.css";
1+
@import "@nativescript/theme/css/core.css";
2+
@import "@nativescript/theme/css/blue.css";
33

44
/* Place any CSS rules you want to apply on both iOS and Android here.
55
This is where the vast majority of your CSS code goes. */

demo/app/home/home-page.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,39 +21,39 @@ export function onNavigatingTo(args: NavigatedData) {
2121

2222
page.bindingContext = new HomeViewModel();
2323

24+
let preparing = true;
2425
let locationSubscription: Subscription;
25-
2626
Application.on(Application.resumeEvent, () => {
27-
if (!_preparing) {
27+
if (!preparing) {
2828
printCurrentLocation().catch((err) => {
2929
console.error(`Could not print current location: ${err}`);
30-
});
31-
printLocationUpdates()
30+
}).then(() => printLocationUpdates()
3231
.then((subscription) => (locationSubscription = subscription))
3332
.catch(
3433
(err) =>
35-
`An error occurred while getting location updates: ${err}`
36-
);
34+
`An error occurred while getting location updates: ${err}`)
35+
).then(() => listenToActivityChanges());
3736
}
38-
listenToActivityChanges();
3937
});
4038

4139
Application.on(Application.suspendEvent, () => {
42-
if (locationSubscription) {
43-
locationSubscription.unsubscribe();
40+
if (!preparing) {
41+
if (locationSubscription) {
42+
locationSubscription.unsubscribe();
43+
}
44+
stopListeningToChanges();
4445
}
45-
stopListeningToChanges();
4646
});
4747

4848
printCurrentLocation().catch((err) => {
4949
console.error(`Could not print current location: ${err}`);
50-
});
51-
printLocationUpdates()
50+
}).then(() => printLocationUpdates()
5251
.then((subscription) => (locationSubscription = subscription))
5352
.catch(
5453
(err) => `An error occurred while getting location updates: ${err}`
55-
);
56-
listenToActivityChanges(true);
54+
)
55+
).then(() => listenToActivityChanges(true))
56+
.then(() => preparing = false);
5757
}
5858

5959
async function printCurrentLocation() {
@@ -90,14 +90,16 @@ async function printLocationUpdates(): Promise<Subscription> {
9090
});
9191
}
9292

93-
export function listenToActivityChanges(addListener = false) {
94-
activityRecognizers.forEach((recognizerType) => {
95-
listenToActivityChangesFor(recognizerType, addListener).catch((err) => {
93+
export async function listenToActivityChanges(addListener = false) {
94+
for (const recognizerType of activityRecognizers) {
95+
try {
96+
await listenToActivityChangesFor(recognizerType, addListener);
97+
} catch (err) {
9698
console.error(
9799
`An error occurred while listening to ${recognizerType} res activity changes: ${JSON.stringify(err)}`
98100
);
99-
});
100-
});
101+
}
102+
}
101103
}
102104

103105
function stopListeningToChanges() {

demo/app/package.json

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

demo/app/test.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { runTestApp } from "@nativescript/unit-test-runner";
2+
// import other polyfills here
3+
4+
declare let require: any;
5+
6+
runTestApp({
7+
runTests: () => {
8+
const tests = require.context("./", true, /\.spec\.ts$/);
9+
tests.keys().map(tests);
10+
},
11+
});

demo/karma.conf.js

Lines changed: 45 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,98 @@
11
module.exports = function (config) {
22
const options = {
3+
34
// base path that will be used to resolve all patterns (eg. files, exclude)
4-
basePath: "",
5+
basePath: 'app',
6+
57

68
// frameworks to use
79
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
8-
frameworks: ["jasmine"],
10+
frameworks: ['jasmine'],
11+
12+
13+
// list of files / patterns to load in the browser. Leave empty for webpack projects
14+
// files: [],
915

10-
// list of files / patterns to load in the browser
11-
files: ["app/tests/**/*.ts"],
1216

1317
// list of files to exclude
14-
exclude: [],
18+
exclude: [
19+
],
20+
1521

1622
// preprocess matching files before serving them to the browser
1723
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
18-
preprocessors: {},
24+
preprocessors: {
25+
},
26+
1927

2028
// test results reporter to use
2129
// possible values: 'dots', 'progress'
2230
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
23-
reporters: ["progress", "junit"],
31+
reporters: ['progress', 'junit'],
32+
33+
// configure optional coverage, enable via --env.codeCoverage
34+
coverageReporter: {
35+
dir: require('path').join(__dirname, './coverage'),
36+
subdir: '.',
37+
reporters: [
38+
{ type: 'html' },
39+
{ type: 'text-summary' }
40+
]
41+
},
42+
43+
// web server hostname
44+
hostname: '127.0.0.1',
2445

2546
// web server port
2647
port: 9876,
2748

49+
2850
// enable / disable colors in the output (reporters and logs)
2951
colors: true,
3052

53+
3154
// level of logging
3255
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
3356
logLevel: config.LOG_INFO,
3457

58+
3559
// enable / disable watching file and executing tests whenever any file changes
3660
autoWatch: true,
3761

62+
3863
// start these browsers
3964
// available browser launchers: https://npmjs.org/browse/keyword/karma-launcher
4065
browsers: [],
4166

4267
customLaunchers: {
4368
android: {
44-
base: "NS",
45-
platform: "android",
69+
base: 'NS',
70+
platform: 'android'
4671
},
4772
ios: {
48-
base: "NS",
49-
platform: "ios",
73+
base: 'NS',
74+
platform: 'ios'
5075
},
5176
ios_simulator: {
52-
base: "NS",
53-
platform: "ios",
54-
arguments: ["--emulator"],
55-
},
77+
base: 'NS',
78+
platform: 'ios',
79+
arguments: ['--emulator']
80+
}
5681
},
5782

5883
// Continuous Integration mode
5984
// if true, Karma captures browsers, runs the tests and exits
6085
singleRun: false,
6186

6287
junitReporter: {
63-
outputDir: "test-reports",
64-
outputFile: "report.xml",
88+
outputDir: 'test-reports',
89+
outputFile: 'report.xml',
6590
},
6691
};
6792

68-
setWebpackPreprocessor(config, options);
69-
setWebpack(config, options);
70-
71-
config.set(options);
72-
};
73-
74-
function setWebpackPreprocessor(config, options) {
75-
if (config && config.bundle) {
76-
if (!options.preprocessors) {
77-
options.preprocessors = {};
78-
}
79-
80-
options.files.forEach((file) => {
81-
if (!options.preprocessors[file]) {
82-
options.preprocessors[file] = [];
83-
}
84-
options.preprocessors[file].push("webpack");
85-
});
93+
if(config._NS && config._NS.env && config._NS.env.codeCoverage) {
94+
options.reporters = (options.reporters || []).concat(['coverage']);
8695
}
87-
}
8896

89-
function setWebpack(config, options) {
90-
if (config && config.bundle) {
91-
const env = {};
92-
env[config.platform] = true;
93-
env.sourceMap = config.debugBrk;
94-
env.appPath = config.appPath;
95-
options.webpack = require("./webpack.config")(env);
96-
delete options.webpack.entry;
97-
delete options.webpack.output.libraryTarget;
98-
const invalidPluginsForUnitTesting = [
99-
"GenerateBundleStarterPlugin",
100-
"GenerateNativeScriptEntryPointsPlugin",
101-
];
102-
options.webpack.plugins = options.webpack.plugins.filter(
103-
(p) => !invalidPluginsForUnitTesting.includes(p.constructor.name)
104-
);
105-
}
97+
config.set(options);
10698
}

demo/nativescript.config.ts

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,10 @@ import { NativeScriptConfig } from '@nativescript/core';
22

33
export default {
44
id: 'org.nativescript.demo',
5-
main: './app/app.js',
5+
appPath: 'app',
66
appResourcesPath: './app/App_Resources',
7-
webpackConfigPath: 'webpack.config.js',
8-
ios: {
9-
discardUncaughtJsExceptions: true
10-
},
117
android: {
12-
discardUncaughtJsExceptions: true,
138
v8Flags: '--nolazy --expose_gc',
14-
"markingMode": "none",
15-
"suppressCallJSMethodExceptions": false
9+
markingMode: 'none'
1610
}
1711
} as NativeScriptConfig;

0 commit comments

Comments
 (0)