From 0a66bac43690470adf33068a319602a7b9a29d56 Mon Sep 17 00:00:00 2001 From: fatme Date: Wed, 10 Jul 2019 11:39:57 +0300 Subject: [PATCH 1/3] feat: move all the source code to app folder Till now `nativescript-dev-webpack` plugin requires automatically all (root|page)(.css|.xml|.js|.ts) files from the unit-test-runner. However, this behavior was changed and now `nativescript-dev-webpack` plugin requires automatically all files except the files from App_Resources and .d.ts files. This led to the problem that `preuninstall.js` and `postinstall.js` scripts are automatically required. These scripts require `nativescript-hook`. On the other side `nativescript-hook` has a dynamic require here https://github.com/NativeScript/nativescript-hook/blob/master/index.js#L56. As this dynamic require is not compatible with webpack's concept for dynamic requires, the following warning is shown: ``` WARNING in ../node_modules/nativescript-hook/index.js 56:27-51 Critical dependency: the request of a dependency is an expression @ ../node_modules/nativescript-unit-test-runner/postinstall.js @ ../node_modules/nativescript-unit-test-runner sync (? app/app-root.xml | 0 app.css => app/app.css | 0 app.ts => app/app.ts | 0 bundle-app-root.xml => app/bundle-app-root.xml | 0 bundle-app.ts => app/bundle-app.ts | 0 bundle-main-page.ts => app/bundle-main-page.ts | 0 bundle-main-page.xml => app/bundle-main-page.xml | 0 main-page.ts => app/main-page.ts | 0 main-page.xml => app/main-page.xml | 0 main-view-model.ts => app/main-view-model.ts | 6 +++--- nativescript.png => app/nativescript.png | Bin run-details.ts => app/run-details.ts | 0 run-details.xml => app/run-details.xml | 0 {services => app/services}/karma-files-service.ts | 0 {services => app/services}/karma-host-resolver.ts | 0 .../services}/test-execution-service.ts | 0 .../stop-process.android.ts | 0 stop-process.d.ts => app/stop-process.d.ts | 0 stop-process.ios.ts => app/stop-process.ios.ts | 0 test-run-page.ts => app/test-run-page.ts | 0 test-run-page.xml => app/test-run-page.xml | 0 21 files changed, 3 insertions(+), 3 deletions(-) rename app-root.xml => app/app-root.xml (100%) rename app.css => app/app.css (100%) rename app.ts => app/app.ts (100%) rename bundle-app-root.xml => app/bundle-app-root.xml (100%) rename bundle-app.ts => app/bundle-app.ts (100%) rename bundle-main-page.ts => app/bundle-main-page.ts (100%) rename bundle-main-page.xml => app/bundle-main-page.xml (100%) rename main-page.ts => app/main-page.ts (100%) rename main-page.xml => app/main-page.xml (100%) rename main-view-model.ts => app/main-view-model.ts (99%) rename nativescript.png => app/nativescript.png (100%) rename run-details.ts => app/run-details.ts (100%) rename run-details.xml => app/run-details.xml (100%) rename {services => app/services}/karma-files-service.ts (100%) rename {services => app/services}/karma-host-resolver.ts (100%) rename {services => app/services}/test-execution-service.ts (100%) rename stop-process.android.ts => app/stop-process.android.ts (100%) rename stop-process.d.ts => app/stop-process.d.ts (100%) rename stop-process.ios.ts => app/stop-process.ios.ts (100%) rename test-run-page.ts => app/test-run-page.ts (100%) rename test-run-page.xml => app/test-run-page.xml (100%) diff --git a/app-root.xml b/app/app-root.xml similarity index 100% rename from app-root.xml rename to app/app-root.xml diff --git a/app.css b/app/app.css similarity index 100% rename from app.css rename to app/app.css diff --git a/app.ts b/app/app.ts similarity index 100% rename from app.ts rename to app/app.ts diff --git a/bundle-app-root.xml b/app/bundle-app-root.xml similarity index 100% rename from bundle-app-root.xml rename to app/bundle-app-root.xml diff --git a/bundle-app.ts b/app/bundle-app.ts similarity index 100% rename from bundle-app.ts rename to app/bundle-app.ts diff --git a/bundle-main-page.ts b/app/bundle-main-page.ts similarity index 100% rename from bundle-main-page.ts rename to app/bundle-main-page.ts diff --git a/bundle-main-page.xml b/app/bundle-main-page.xml similarity index 100% rename from bundle-main-page.xml rename to app/bundle-main-page.xml diff --git a/main-page.ts b/app/main-page.ts similarity index 100% rename from main-page.ts rename to app/main-page.ts diff --git a/main-page.xml b/app/main-page.xml similarity index 100% rename from main-page.xml rename to app/main-page.xml diff --git a/main-view-model.ts b/app/main-view-model.ts similarity index 99% rename from main-view-model.ts rename to app/main-view-model.ts index 6160f79..076212c 100644 --- a/main-view-model.ts +++ b/app/main-view-model.ts @@ -1,4 +1,4 @@ -/// +/// import { Observable } from "tns-core-modules/data/observable"; import { ObservableArray } from "tns-core-modules/data/observable-array"; import * as http from "tns-core-modules/http"; @@ -21,7 +21,7 @@ function enableSocketIoDebugging() { global.window = global; } -var config: INetworkConfiguration = require('./config'); +var config: INetworkConfiguration = require('../config'); config.options = config.options || {}; if (!config.options.appDirectoryRelativePath) { config.options.appDirectoryRelativePath = "app"; @@ -207,7 +207,7 @@ export class TestBrokerViewModel extends Observable { }; this.updateView({ serverInfo: `connecting to ${this.baseUrl}`}); - let io = require('./socket.io'); + let io = require('../socket.io'); const socket = this.socket = io.connect(this.baseUrl, { forceBase64: true }); socket.on('connect', err => { diff --git a/nativescript.png b/app/nativescript.png similarity index 100% rename from nativescript.png rename to app/nativescript.png diff --git a/run-details.ts b/app/run-details.ts similarity index 100% rename from run-details.ts rename to app/run-details.ts diff --git a/run-details.xml b/app/run-details.xml similarity index 100% rename from run-details.xml rename to app/run-details.xml diff --git a/services/karma-files-service.ts b/app/services/karma-files-service.ts similarity index 100% rename from services/karma-files-service.ts rename to app/services/karma-files-service.ts diff --git a/services/karma-host-resolver.ts b/app/services/karma-host-resolver.ts similarity index 100% rename from services/karma-host-resolver.ts rename to app/services/karma-host-resolver.ts diff --git a/services/test-execution-service.ts b/app/services/test-execution-service.ts similarity index 100% rename from services/test-execution-service.ts rename to app/services/test-execution-service.ts diff --git a/stop-process.android.ts b/app/stop-process.android.ts similarity index 100% rename from stop-process.android.ts rename to app/stop-process.android.ts diff --git a/stop-process.d.ts b/app/stop-process.d.ts similarity index 100% rename from stop-process.d.ts rename to app/stop-process.d.ts diff --git a/stop-process.ios.ts b/app/stop-process.ios.ts similarity index 100% rename from stop-process.ios.ts rename to app/stop-process.ios.ts diff --git a/test-run-page.ts b/app/test-run-page.ts similarity index 100% rename from test-run-page.ts rename to app/test-run-page.ts diff --git a/test-run-page.xml b/app/test-run-page.xml similarity index 100% rename from test-run-page.xml rename to app/test-run-page.xml From 39cef6d89cc0f04fcf7f3e90faab1392ecab5a0a Mon Sep 17 00:00:00 2001 From: fatme Date: Wed, 10 Jul 2019 12:14:06 +0300 Subject: [PATCH 2/3] chore: bump the version to 0.7.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6e63bfd..77aca5a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nativescript-unit-test-runner", - "version": "0.6.4", + "version": "0.7.0", "description": "NativeScript unit test runner component.", "main": "app.js", "scripts": { From dd2df8dfd2cbb589c1cac49e6507d3f69c7e82ea Mon Sep 17 00:00:00 2001 From: fatme Date: Wed, 10 Jul 2019 12:43:15 +0300 Subject: [PATCH 3/3] feat: add before-liveSync hook in order to show an error that this version of runner is not compatible with old CLI --- lib/before-liveSync.ts | 13 +++++++++++++ package.json | 7 ++++++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 lib/before-liveSync.ts diff --git a/lib/before-liveSync.ts b/lib/before-liveSync.ts new file mode 100644 index 0000000..e3ef5f7 --- /dev/null +++ b/lib/before-liveSync.ts @@ -0,0 +1,13 @@ +module.exports = function ($staticConfig, $errors, hookArgs) { + var majorVersionMatch = ($staticConfig.version || '').match(/^(\d+)\./); + var majorVersion = majorVersionMatch && majorVersionMatch[1] && +majorVersionMatch[1]; + if (majorVersion && majorVersion < 6) { + var isUsingBundleWorkflow = hookArgs && + hookArgs.liveSyncData && + hookArgs.liveSyncData.bundle; + if (isUsingBundleWorkflow) { + var packageJsonData = require("../package.json"); + throw new Error("The current version of " + packageJsonData.name + " (" + packageJsonData.version + ") is not compatible with the used CLI: " + $staticConfig.version + ". Please upgrade your NativeScript CLI version (npm i -g nativescript)."); + } + } +}; diff --git a/package.json b/package.json index 77aca5a..51a8af8 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,12 @@ { "type": "after-prepare", "script": "./lib/after-prepare.js", - "inject": "true" + "inject": true + }, + { + "type": "before-liveSync", + "script": "lib/before-liveSync.js", + "inject": true } ] },