Commit 1b8a63c5 authored by laurent l's avatar laurent l

fix ns deprecation, comply to new ns architecture

parent bb5acbbf
......@@ -2,9 +2,6 @@
import 'nativescript-i18n';
import * as app from 'tns-core-modules/application';
import { Database, Manager, NSHTTPClient, BackgroundJobs } from './models';
import * as config from "./config/config";
import { AccountsController } from './controllers/accounts';
import * as Frames from 'tns-core-modules/ui/frame';
function myReloadPage() {
......@@ -28,18 +25,6 @@ function myReloadPage() {
}
global.__onLiveSyncCore = myReloadPage;
app.run({ moduleName: 'views/root-page' })
Database.open('prod');
new BackgroundJobs().setupScheduleJob(app)
let manager = new Manager(config.MANAGER_URL, new NSHTTPClient())
app.start({
moduleName: 'views/accounts/list-page',
bindingContext: new AccountsController(manager)
})
import { UpdateAccountsJob } from './models/background-jobs/update-accounts-job'
new UpdateAccountsJob().setup()
if ((global).TNS_WEBPACK) {
// Register custom modules
global.registerModule("nativescript-ui-sidedrawer", () => require("../node_modules/nativescript-ui-sidedrawer"));
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYnVuZGxlLWNvbmZpZy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImJ1bmRsZS1jb25maWcudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsSUFBSSxDQUFDLE1BQU0sQ0FBQyxDQUFDLFdBQVcsRUFBRTtJQUN4QiwwQkFBMEI7SUFDMUIsTUFBTSxDQUFDLGNBQWMsQ0FBQyw0QkFBNEIsRUFDaEQsR0FBRyxFQUFFLENBQUMsT0FBTyxDQUFDLDRDQUE0QyxDQUFDLENBQUMsQ0FBQztDQUNoRSIsInNvdXJjZXNDb250ZW50IjpbImlmICgoZ2xvYmFsKS5UTlNfV0VCUEFDSykge1xuICAvLyBSZWdpc3RlciBjdXN0b20gbW9kdWxlc1xuICBnbG9iYWwucmVnaXN0ZXJNb2R1bGUoXCJuYXRpdmVzY3JpcHQtdWktc2lkZWRyYXdlclwiLFxuICAgICgpID0+IHJlcXVpcmUoXCIuLi9ub2RlX21vZHVsZXMvbmF0aXZlc2NyaXB0LXVpLXNpZGVkcmF3ZXJcIikpO1xufVxuIl19
\ No newline at end of file
import { Database, Portal, Account } from '../../models/'
import { BackgroundFetch } from "nativescript-background-fetch"
import * as ApplicationSettings from "tns-core-modules/application-settings"
export class UpdateAccountsJob {
public setup() {
......@@ -19,6 +20,11 @@ export class UpdateAccountsJob {
public updateAccounts() {
if (!ApplicationSettings.getBoolean('background_refresh_on', false)) {
console.log('[BackgroundFetch] disabled by user setting');
return this;
}
let portal = new Portal()
let accounts = Database.current().findAll(Account)
......
......@@ -7,8 +7,7 @@ import { StubFrames } from './stub-frames';
describe('AccountsController with one account in database', () => {
let db: Database;
let accounts_controller: AccountsController;
let navigate_spy;
let goback_spy;
let navigate_spy: any;
let bibliofil: Account;
let manager: Manager;
......@@ -23,7 +22,6 @@ describe('AccountsController with one account in database', () => {
accounts_controller.frames = new StubFrames();
navigate_spy = chai.spy.on(accounts_controller.frames, 'navigate');
goback_spy = chai.spy.on(accounts_controller.frames, 'goBack');
});
......@@ -40,7 +38,7 @@ describe('AccountsController with one account in database', () => {
it('should navigate to account/add view when clicking addAccount', () => {
expect(navigate_spy).to.have.been.called.with({
moduleName: "views/accounts/add_account",
moduleName: "views/accounts/add_account-page",
bindingContext: accounts_controller,
backstackVisible: false
});
......@@ -110,7 +108,7 @@ describe('AccountsController with one account in database', () => {
accounts_controller.openAccountAction({ index: 0 });
let first_account = accounts_controller.get('accounts').getItem(0);
expect(navigate_spy).to.have.been.called.with({
moduleName: "views/library/items",
moduleName: "views/library/items-page",
bindingContext: new LibraryController(first_account, manager)
});
});
......
......@@ -38,7 +38,7 @@ describe('AccountsController with one account in database', () => {
it('on edit account should navigate to accounts/edit', () => {
expect(navigate_spy).to.have.been.called.with({
moduleName: 'views/accounts/edit',
moduleName: 'views/accounts/edit-page',
bindingContext: accounts_controller
});
});
......
import * as app from 'tns-core-modules/application';
import { AccountsController } from '../controllers/accounts';
import { Database, Manager, NSHTTPClient, BackgroundJobs } from '../models';
import * as config from "../config/config";
import { UpdateAccountsJob } from '../models/background-jobs/update-accounts-job'
export function onFrameLoaded(args): void {
if (Database.current())
return;
Database.open('prod');
new BackgroundJobs().setupScheduleJob(app)
new UpdateAccountsJob().setup()
let manager = new Manager(config.MANAGER_URL, new NSHTTPClient())
args.object.navigate({
moduleName: 'views/accounts/list-page',
bindingContext: new AccountsController(manager),
})
}
<Frame loaded="onFrameLoaded" />
module.exports = function(config) {
config.set({
module.exports = function (config) {
const options = {
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '',
......@@ -9,11 +9,9 @@ module.exports = function(config) {
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['mocha', 'chai-spies', 'chai'],
// list of files / patterns to load in the browser
files: [
'app/tests/bootstrap.js',
'app/**/*.js',
],
files: ['app/tests/**/*.ts'],
// list of files to exclude
......@@ -43,7 +41,7 @@ module.exports = function(config) {
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_ERROR,
logLevel: config.LOG_INFO,
// enable / disable watching file and executing tests whenever any file changes
......@@ -73,5 +71,36 @@ module.exports = function(config) {
// Continuous Integration mode
// if true, Karma captures browsers, runs the tests and exits
singleRun: false
})
};
setWebpackPreprocessor(config, options);
setWebpack(config, options);
config.set(options);
}
function setWebpackPreprocessor(config, options) {
if (config && config.bundle) {
if (!options.preprocessors) {
options.preprocessors = {};
}
options.files.forEach(file => {
if (!options.preprocessors[file]) {
options.preprocessors[file] = [];
}
options.preprocessors[file].push('webpack');
});
}
}
function setWebpack(config, options) {
if (config && config.bundle) {
const env = {};
env[config.platform] = true;
env.sourceMap = config.debugBrk;
options.webpack = require('./webpack.config')(env);
delete options.webpack.entry;
delete options.webpack.output.libraryTarget;
}
}
{
"useLegacyWorkflow": false
}
\ No newline at end of file
This diff is collapsed.
......@@ -12,7 +12,7 @@
"version": "5.4.0"
},
"tns-ios": {
"version": "5.4.0"
"version": "5.4.1"
}
},
"dependencies": {
......@@ -32,7 +32,7 @@
"nativescript-ui-core": "^2.0.1",
"nativescript-ui-listview": "^3.8.0",
"nativescript-ui-sidedrawer": "^5.1.0",
"nativescript-unit-test-runner": "^0.5.1",
"nativescript-unit-test-runner": "^0.6.3",
"nativescript-zxing": "git+https://github.com/Afibre/nativescript-zxing.git",
"papaparse": "^4.3.7",
"tns-core-modules": "^5.4.1",
......@@ -43,25 +43,28 @@
"xml-js": "^1.6.7"
},
"devDependencies": {
"chai": "^4.2.0",
"@types/karma-chai": "0.1.1",
"@types/mocha": "5.2.6",
"chai": "4.2.0",
"chai-spies": "^1.0.0",
"css-loader": "~0.28.7",
"karma": "^4.0.1",
"karma-chai": "^0.1.0",
"karma": "4.1.0",
"karma-chai": "0.1.0",
"karma-chai-spies": "^0.1.4",
"karma-mocha": "^1.3.0",
"karma-nativescript-launcher": "^0.4.0",
"karma-mocha": "1.3.0",
"karma-nativescript-launcher": "0.4.0",
"karma-webpack": "3.0.5",
"lazy": "1.0.11",
"mocha": "^6.0.2",
"nativescript-css-loader": "~0.26.0",
"nativescript-dev-sass": "^1.6.0",
"nativescript-dev-typescript": "^0.9.0",
"mocha": "6.1.4",
"nativescript-css-loader": "^0.26.1",
"nativescript-dev-sass": "^1.7.0",
"nativescript-dev-typescript": "^0.10.0",
"nativescript-dev-webpack": "0.24.0",
"nativescript-worker-loader": "~0.8.1",
"raw-loader": "~0.5.1",
"resolve-url-loader": "~2.1.0",
"sass-loader": "^7.1.0",
"typescript": "^3.3.4000",
"typescript": "^3.5.1",
"webpack": "^4.29.6"
},
"nativescript-i18n": {
......
{
"extends": "./tsconfig",
"compilerOptions": {
"module": "es2015",
"moduleResolution": "node"
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment