From 789f87c97e1bac5ec87e7ddf6f4ee4fa58ff7c26 Mon Sep 17 00:00:00 2001 From: EddyVerbruggen Date: Wed, 26 Jun 2019 11:51:44 +0200 Subject: [PATCH] Remove our custom activity because it's no longer needed (since NativeScript 5.4.0) #38 --- README.md | 16 +- .../App_Resources/Android/AndroidManifest.xml | 2 +- demo/package.json | 11 +- demo/webpack.config.js | 500 +++++++++--------- src/nfc-activity.android.ts | 53 -- src/nfc.android.ts | 6 + src/package.json | 38 +- src/plugin-hooks/after-prepare.js | 23 - src/plugin-hooks/before-prepare.js | 30 -- src/postinstall.js | 1 - src/preuninstall.js | 1 - 11 files changed, 295 insertions(+), 386 deletions(-) delete mode 100644 src/nfc-activity.android.ts delete mode 100755 src/plugin-hooks/after-prepare.js delete mode 100755 src/plugin-hooks/before-prepare.js delete mode 100755 src/postinstall.js delete mode 100755 src/preuninstall.js diff --git a/README.md b/README.md index c6e5583..faba5ff 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ The [demo app](demo) has this: ``` ## Android Setup +> ⚠️ Since plugin version 4.0.0 this section is no longer needed, but you HAVE to run NativeScript 5.4.0 or newer. If you need to support older NativeScript versions, please stick to plugin version < 4.0.0. + Update the `activity` entry in your `App_Resources/Android/AndroidManifest.xml` file: ```xml @@ -60,6 +62,13 @@ Update the `activity` entry in your `App_Resources/Android/AndroidManifest.xml` So replace `com.tns.NativeScriptActivity` with `com.tns.NativeScriptNfcActivity`. +#### Webpack (again, no longer needed from plugin version 4.0.0) +If you're using Webpack to bundle your app you'll need to add 1 line of configuration in case you're targeting Android. + +- Open `webpack.config.js` (it's in the root of your project). +- Look for an Array named `appComponents`, which likely contains stuff like `"tns-core-modules/ui/frame"`. +- Add `resolve(__dirname, "node_modules/nativescript-nfc/nfc-activity.android.js")` [as shown here](https://github.com/EddyVerbruggen/nativescript-nfc/blob/6dfa0ff4f77cab5ab7f494ac3055f728ce51d131/demo/webpack.config.js#L17). + ## Demo app (those screenshots above) Want to dive in quickly? Check out [the demo](https://github.com/EddyVerbruggen/nativescript-nfc/tree/master/demo)! @@ -67,13 +76,6 @@ You can run the demo app from the root of the project by typing `npm run demo.io > [This is what it looks like in action on iOS](https://twitter.com/eddyverbruggen/status/899617497741185025)! -## Webpack -If you're using Webpack to bundle your app you'll need to add 1 line of configuration in case you're targeting Android. - -- Open `webpack.config.js` (it's in the root of your project). -- Look for an Array named `appComponents`, which likely contains stuff like `"tns-core-modules/ui/frame"`. -- Add `resolve(__dirname, "node_modules/nativescript-nfc/nfc-activity.android.js")` [as shown here](https://github.com/EddyVerbruggen/nativescript-nfc/blob/6dfa0ff4f77cab5ab7f494ac3055f728ce51d131/demo/webpack.config.js#L17). - ## API ### `available` diff --git a/demo/app/App_Resources/Android/AndroidManifest.xml b/demo/app/App_Resources/Android/AndroidManifest.xml index 7496539..2a37039 100644 --- a/demo/app/App_Resources/Android/AndroidManifest.xml +++ b/demo/app/App_Resources/Android/AndroidManifest.xml @@ -26,7 +26,7 @@ android:theme="@style/AppTheme"> diff --git a/demo/package.json b/demo/package.json index d765220..e2aeeba 100644 --- a/demo/package.json +++ b/demo/package.json @@ -2,16 +2,16 @@ "nativescript": { "id": "org.nativescript.plugindemo.nfc", "tns-ios": { - "version": "5.3.1" + "version": "6.0.0-2019-06-10-154118-03" }, "tns-android": { - "version": "5.3.1" + "version": "6.0.0-2019-06-11-172137-01" } }, "dependencies": { "nativescript-nfc": "file:../src", "nativescript-theme-core": "~1.0.4", - "tns-core-modules": "~5.3.1" + "tns-core-modules": "6.0.0-next-2019-06-20-155941-01" }, "devDependencies": { "babel-traverse": "6.26.0", @@ -23,10 +23,9 @@ "karma-jasmine": "^1.0.2", "karma-nativescript-launcher": "^0.4.0", "lazy": "1.0.11", - "nativescript-dev-typescript": "next", "nativescript-dev-webpack": "next", "nativescript-unit-test-runner": "^0.3.4", - "tns-platform-declarations": "~5.3.1", - "typescript": "~3.2.2" + "tns-platform-declarations": "next", + "typescript": "3.4.1" } } diff --git a/demo/webpack.config.js b/demo/webpack.config.js index 7064e66..daf5a94 100644 --- a/demo/webpack.config.js +++ b/demo/webpack.config.js @@ -1,271 +1,299 @@ -const {join, relative, resolve, sep} = require("path"); +const { join, relative, resolve, sep } = require("path"); const webpack = require("webpack"); const nsWebpack = require("nativescript-dev-webpack"); const nativescriptTarget = require("nativescript-dev-webpack/nativescript-target"); const CleanWebpackPlugin = require("clean-webpack-plugin"); const CopyWebpackPlugin = require("copy-webpack-plugin"); -const {BundleAnalyzerPlugin} = require("webpack-bundle-analyzer"); -const {NativeScriptWorkerPlugin} = require("nativescript-worker-loader/NativeScriptWorkerPlugin"); -const UglifyJsPlugin = require("uglifyjs-webpack-plugin"); +const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin'); +const { BundleAnalyzerPlugin } = require("webpack-bundle-analyzer"); +const { NativeScriptWorkerPlugin } = require("nativescript-worker-loader/NativeScriptWorkerPlugin"); +const TerserPlugin = require("terser-webpack-plugin"); +const hashSalt = Date.now().toString(); module.exports = env => { - // Add your custom Activities, Services and other Android app components here. - const appComponents = [ - "tns-core-modules/ui/frame", - "tns-core-modules/ui/frame/activity", - resolve(__dirname, "node_modules/nativescript-nfc/nfc-activity.android.js") // ADD THIS! - ]; + // Add your custom Activities, Services and other Android app components here. + const appComponents = [ + "tns-core-modules/ui/frame", + "tns-core-modules/ui/frame/activity", + ]; - const platform = env && (env.android && "android" || env.ios && "ios"); - if (!platform) { - throw new Error("You need to provide a target platform!"); - } + const platform = env && (env.android && "android" || env.ios && "ios"); + if (!platform) { + throw new Error("You need to provide a target platform!"); + } - const platforms = ["ios", "android"]; - const projectRoot = __dirname; + const platforms = ["ios", "android"]; + const projectRoot = __dirname; - // Default destination inside platforms//... - const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot)); - const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS"; + // Default destination inside platforms//... + const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot)); + const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS"; - const { - // The 'appPath' and 'appResourcesPath' values are fetched from - // the nsconfig.json configuration file - // when bundling with `tns run android|ios --bundle`. - appPath = "app", - appResourcesPath = "app/App_Resources", + const { + // The 'appPath' and 'appResourcesPath' values are fetched from + // the nsconfig.json configuration file + // when bundling with `tns run android|ios --bundle`. + appPath = "app", + appResourcesPath = "app/App_Resources", - // You can provide the following flags when running 'tns run android|ios' - snapshot, // --env.snapshot - uglify, // --env.uglify - report, // --env.report - sourceMap, // --env.sourceMap - hmr, // --env.hmr, - } = env; - const externals = (env.externals || []).map((e) => { // --env.externals - return new RegExp(e + ".*"); - }); + // You can provide the following flags when running 'tns run android|ios' + snapshot, // --env.snapshot + production, // --env.production + uglify, // --env.uglify + report, // --env.report + sourceMap, // --env.sourceMap + hiddenSourceMap, // --env.hiddenSourceMap + hmr, // --env.hmr, + unitTesting, // --env.unitTesting, + verbose, // --env.verbose + } = env; + const isAnySourceMapEnabled = !!sourceMap || !!hiddenSourceMap; + const externals = nsWebpack.getConvertedExternals(env.externals); - const appFullPath = resolve(projectRoot, appPath); - const appResourcesFullPath = resolve(projectRoot, appResourcesPath); + const appFullPath = resolve(projectRoot, appPath); + const appResourcesFullPath = resolve(projectRoot, appResourcesPath); - const entryModule = nsWebpack.getEntryModule(appFullPath); - const entryPath = `.${sep}${entryModule}.ts`; + const entryModule = nsWebpack.getEntryModule(appFullPath, platform); + const entryPath = `.${sep}${entryModule}.ts`; + const entries = { bundle: entryPath }; - const config = { - mode: uglify ? "production" : "development", - context: appFullPath, - externals, - watchOptions: { - ignored: [ - appResourcesFullPath, - // Don't watch hidden files - "**/.*", - ] - }, - target: nativescriptTarget, - entry: { - bundle: entryPath, - // application: "./application.android" - }, - output: { - pathinfo: false, - path: dist, - libraryTarget: "commonjs2", - filename: "[name].js", - globalObject: "global", - }, - resolve: { - extensions: [".ts", ".js", ".scss", ".css"], - // Resolve {N} system modules from tns-core-modules - modules: [ - resolve(__dirname, "node_modules/tns-core-modules"), - resolve(__dirname, "node_modules"), - "node_modules/tns-core-modules", - "node_modules", - ], - alias: { - '~': appFullPath - }, - // resolve symlinks to symlinked modules - symlinks: true - }, - resolveLoader: { - // don't resolve symlinks to symlinked loaders - symlinks: false - }, - node: { - // Disable node shims that conflict with NativeScript - "http": false, - "timers": false, - "setImmediate": false, - "fs": "empty", - "__dirname": false, - }, - devtool: sourceMap ? "inline-source-map" : "none", - optimization: { - splitChunks: { - cacheGroups: { - vendor: { - name: "vendor", - chunks: "all", - test: (module, chunks) => { - const moduleName = module.nameForCondition ? module.nameForCondition() : ''; - return /[\\/]node_modules[\\/]/.test(moduleName) || - appComponents.some(comp => comp === moduleName); + const tsConfigPath = resolve(projectRoot, "tsconfig.tns.json"); - }, - enforce: true, - }, - } - }, - minimize: !!uglify, - minimizer: [ - new UglifyJsPlugin({ - parallel: true, - cache: true, - uglifyOptions: { - output: { - comments: false, - }, - compress: { - // The Android SBG has problems parsing the output - // when these options are enabled - 'collapse_vars': platform !== "android", - sequences: platform !== "android", - } - } - }) - ], - }, - module: { - rules: [ - { - test: new RegExp(entryPath), - use: [ - // Require all Android app components - platform === "android" && { - loader: "nativescript-dev-webpack/android-app-components-loader", - options: {modules: appComponents} - }, + const areCoreModulesExternal = Array.isArray(env.externals) && env.externals.some(e => e.indexOf("tns-core-modules") > -1); + if (platform === "ios" && !areCoreModulesExternal) { + entries["tns_modules/tns-core-modules/inspector_modules"] = "inspector_modules"; + }; + + let sourceMapFilename = nsWebpack.getSourceMapFilename(hiddenSourceMap, __dirname, dist); + + const itemsToClean = [`${dist}/**/*`]; + if (platform === "android") { + itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "src", "main", "assets", "snapshots")}`); + itemsToClean.push(`${join(projectRoot, "platforms", "android", "app", "build", "configurations", "nativescript-android-snapshot")}`); + } - { - loader: "nativescript-dev-webpack/bundle-config-loader", - options: { - loadCss: !snapshot, // load the application css if in debug mode - } + const config = { + mode: production ? "production" : "development", + context: appFullPath, + externals, + watchOptions: { + ignored: [ + appResourcesFullPath, + // Don't watch hidden files + "**/.*", + ] + }, + target: nativescriptTarget, + entry: entries, + output: { + pathinfo: false, + path: dist, + sourceMapFilename, + libraryTarget: "commonjs2", + filename: "[name].js", + globalObject: "global", + hashSalt + }, + resolve: { + extensions: [".ts", ".js", ".scss", ".css"], + // Resolve {N} system modules from tns-core-modules + modules: [ + resolve(__dirname, "node_modules/tns-core-modules"), + resolve(__dirname, "node_modules"), + "node_modules/tns-core-modules", + "node_modules", + ], + alias: { + '~': appFullPath }, - ].filter(loader => !!loader) + // resolve symlinks to symlinked modules + symlinks: true }, - - { - test: /-page\.ts$/, - use: "nativescript-dev-webpack/script-hot-loader" + resolveLoader: { + // don't resolve symlinks to symlinked loaders + symlinks: false }, - - { - test: /\.(css|scss)$/, - use: "nativescript-dev-webpack/style-hot-loader" + node: { + // Disable node shims that conflict with NativeScript + "http": false, + "timers": false, + "setImmediate": false, + "fs": "empty", + "__dirname": false, }, + devtool: hiddenSourceMap ? "hidden-source-map" : (sourceMap ? "inline-source-map" : "none"), + optimization: { + runtimeChunk: "single", + splitChunks: { + cacheGroups: { + vendor: { + name: "vendor", + chunks: "all", + test: (module, chunks) => { + const moduleName = module.nameForCondition ? module.nameForCondition() : ''; + return /[\\/]node_modules[\\/]/.test(moduleName) || + appComponents.some(comp => comp === moduleName); - { - test: /\.(html|xml)$/, - use: "nativescript-dev-webpack/markup-hot-loader" + }, + enforce: true, + }, + } + }, + minimize: !!uglify, + minimizer: [ + new TerserPlugin({ + parallel: true, + cache: true, + sourceMap: isAnySourceMapEnabled, + terserOptions: { + output: { + comments: false, + semicolons: !isAnySourceMapEnabled + }, + compress: { + // The Android SBG has problems parsing the output + // when these options are enabled + 'collapse_vars': platform !== "android", + sequences: platform !== "android", + } + } + }) + ], }, + module: { + rules: [ + { + test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath), + use: [ + // Require all Android app components + platform === "android" && { + loader: "nativescript-dev-webpack/android-app-components-loader", + options: { modules: appComponents } + }, - {test: /\.(html|xml)$/, use: "nativescript-dev-webpack/xml-namespace-loader"}, + { + loader: "nativescript-dev-webpack/bundle-config-loader", + options: { + loadCss: !snapshot, // load the application css if in debug mode + unitTesting, + appFullPath, + projectRoot, + } + }, + ].filter(loader => !!loader) + }, - { - test: /\.css$/, - use: {loader: "css-loader", options: {minimize: false, url: false}} - }, + { + test: /-page\.ts$/, + use: "nativescript-dev-webpack/script-hot-loader" + }, - { - test: /\.scss$/, - use: [ - {loader: "css-loader", options: {minimize: false, url: false}}, - "sass-loader" - ] - }, + { + test: /\.(css|scss)$/, + use: "nativescript-dev-webpack/style-hot-loader" + }, - { - test: /\.ts$/, - use: { - loader: "ts-loader", - options: { - configFile: "tsconfig.tns.json", - allowTsInNodeModules: true, - }, - } - }, - ] - }, - plugins: [ - // Define useful constants like TNS_WEBPACK - new webpack.DefinePlugin({ - "global.TNS_WEBPACK": "true", - "process": undefined, - }), - // Remove all files from the out dir. - new CleanWebpackPlugin([`${dist}/**/*`]), - // Copy native app resources to out dir. - new CopyWebpackPlugin([ - { - from: `${appResourcesFullPath}/${appResourcesPlatformDir}`, - to: `${dist}/App_Resources/${appResourcesPlatformDir}`, - context: projectRoot + { + test: /\.(html|xml)$/, + use: "nativescript-dev-webpack/markup-hot-loader" + }, + + { test: /\.(html|xml)$/, use: "nativescript-dev-webpack/xml-namespace-loader" }, + + { + test: /\.css$/, + use: { loader: "css-loader", options: { url: false } } + }, + + { + test: /\.scss$/, + use: [ + { loader: "css-loader", options: { url: false } }, + "sass-loader" + ] + }, + + { + test: /\.ts$/, + use: { + loader: "ts-loader", + options: { + configFile: tsConfigPath, + // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#faster-builds + // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#hot-module-replacement + transpileOnly: true, + allowTsInNodeModules: true, + compilerOptions: { + sourceMap: isAnySourceMapEnabled, + declaration: false + } + }, + } + }, + ] }, - ]), - // Copy assets to out dir. Add your own globs as needed. - new CopyWebpackPlugin([ - {from: {glob: "fonts/**"}}, - {from: {glob: "**/*.jpg"}}, - {from: {glob: "**/*.png"}}, - ], {ignore: [`${relative(appPath, appResourcesFullPath)}/**`]}), - // Generate a bundle starter script and activate it in package.json - new nsWebpack.GenerateBundleStarterPlugin([ - "./vendor", - "./bundle", - ]), - // For instructions on how to set up workers with webpack - // check out https://github.com/nativescript/worker-loader - new NativeScriptWorkerPlugin(), - new nsWebpack.PlatformFSPlugin({ - platform, - platforms, - }), - // Does IPC communication with the {N} CLI to notify events when running in watch mode. - new nsWebpack.WatchStateLoggerPlugin(), - ], - }; + plugins: [ + // Define useful constants like TNS_WEBPACK + new webpack.DefinePlugin({ + "global.TNS_WEBPACK": "true", + "process": undefined, + }), + // Remove all files from the out dir. + new CleanWebpackPlugin(itemsToClean, { verbose: !!verbose }), + // Copy assets to out dir. Add your own globs as needed. + new CopyWebpackPlugin([ + { from: { glob: "fonts/**" } }, + { from: { glob: "**/*.jpg" } }, + { from: { glob: "**/*.png" } }, + ], { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] }), + new nsWebpack.GenerateNativeScriptEntryPointsPlugin("bundle"), + // For instructions on how to set up workers with webpack + // check out https://github.com/nativescript/worker-loader + new NativeScriptWorkerPlugin(), + new nsWebpack.PlatformFSPlugin({ + platform, + platforms, + }), + // Does IPC communication with the {N} CLI to notify events when running in watch mode. + new nsWebpack.WatchStateLoggerPlugin(), + // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#faster-builds + // https://github.com/TypeStrong/ts-loader/blob/ea2fcf925ec158d0a536d1e766adfec6567f5fb4/README.md#hot-module-replacement + new ForkTsCheckerWebpackPlugin({ + tsconfig: tsConfigPath, + async: false, + useTypescriptIncrementalApi: true, + memoryLimit: 4096 + }) + ], + }; - if (report) { - // Generate report files for bundles content - config.plugins.push(new BundleAnalyzerPlugin({ - analyzerMode: "static", - openAnalyzer: false, - generateStatsFile: true, - reportFilename: resolve(projectRoot, "report", `report.html`), - statsFilename: resolve(projectRoot, "report", `stats.json`), - })); - } + if (report) { + // Generate report files for bundles content + config.plugins.push(new BundleAnalyzerPlugin({ + analyzerMode: "static", + openAnalyzer: false, + generateStatsFile: true, + reportFilename: resolve(projectRoot, "report", `report.html`), + statsFilename: resolve(projectRoot, "report", `stats.json`), + })); + } - if (snapshot) { - config.plugins.push(new nsWebpack.NativeScriptSnapshotPlugin({ - chunk: "vendor", - requireModules: [ - "tns-core-modules/bundle-entry-points", - ], - projectRoot, - webpackConfig: config, - })); - } + if (snapshot) { + config.plugins.push(new nsWebpack.NativeScriptSnapshotPlugin({ + chunk: "vendor", + requireModules: [ + "tns-core-modules/bundle-entry-points", + ], + projectRoot, + webpackConfig: config, + })); + } - if (hmr) { - config.plugins.push(new webpack.HotModuleReplacementPlugin()); - } + if (hmr) { + config.plugins.push(new webpack.HotModuleReplacementPlugin()); + } - return config; + return config; }; diff --git a/src/nfc-activity.android.ts b/src/nfc-activity.android.ts deleted file mode 100644 index 12ab584..0000000 --- a/src/nfc-activity.android.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { setActivityCallbacks, AndroidActivityCallbacks } from "tns-core-modules/ui/frame"; -import * as application from "tns-core-modules/application"; -import { nfcIntentHandler } from "./"; - -@JavaProxy("com.tns.NativeScriptNfcActivity") -class Activity extends android.support.v7.app.AppCompatActivity { - private _callbacks: AndroidActivityCallbacks; - - public onCreate(savedInstanceState: android.os.Bundle): void { - if (!this._callbacks) { - setActivityCallbacks(this); - } - this._callbacks.onCreate(this, savedInstanceState, super.onCreate); - } - - public onSaveInstanceState(outState: android.os.Bundle): void { - this._callbacks.onSaveInstanceState(this, outState, super.onSaveInstanceState); - } - - public onStart(): void { - this._callbacks.onStart(this, super.onStart); - } - - public onStop(): void { - this._callbacks.onStop(this, super.onStop); - } - - public onDestroy(): void { - this._callbacks.onDestroy(this, super.onDestroy); - } - - public onBackPressed(): void { - this._callbacks.onBackPressed(this, super.onBackPressed); - } - - public onRequestPermissionsResult(requestCode: number, permissions: any, grantResults: any): void { - this._callbacks.onRequestPermissionsResult(this, requestCode, permissions, grantResults, undefined /*TODO: Enable if needed*/); - } - - public onActivityResult(requestCode: number, resultCode: number, data: android.content.Intent): void { - this._callbacks.onActivityResult(this, requestCode, resultCode, data, super.onActivityResult); - } - - public onNewIntent(intent: android.content.Intent): void { - super.onNewIntent(intent); - const activity = application.android.foregroundActivity || application.android.startActivity; - if (activity) { - activity.setIntent(intent); - nfcIntentHandler.savedIntent = intent; - nfcIntentHandler.parseMessage(); - } - } -} diff --git a/src/nfc.android.ts b/src/nfc.android.ts index 5dd460c..3795564 100644 --- a/src/nfc.android.ts +++ b/src/nfc.android.ts @@ -296,6 +296,12 @@ export class Nfc implements NfcApi { } }); + // fired when a new tag is scanned + application.android.on(application.AndroidApplication.activityNewIntentEvent, (args: application.AndroidActivityNewIntentEventData) => { + nfcIntentHandler.savedIntent = intent; + nfcIntentHandler.parseMessage(); + }); + // on startup, we want to make sure the adapter is listening let startupNfcAdapter = android.nfc.NfcAdapter.getDefaultAdapter(activity); if (startupNfcAdapter !== null) { diff --git a/src/package.json b/src/package.json index 3c2c6dd..bef5ed2 100644 --- a/src/package.json +++ b/src/package.json @@ -1,32 +1,20 @@ { "name": "nativescript-nfc", - "version": "3.0.3", + "version": "4.0.0", "description": "NFC plugin for your NativeScript app", "main": "nfc", "typings": "index.d.ts", "nativescript": { "platforms": { - "android": "3.2.0", - "ios": "3.2.0" - }, - "hooks": [ - { - "type": "before-prepare", - "script": "plugin-hooks/before-prepare.js", - "inject": true - }, - { - "type": "after-prepare", - "script": "plugin-hooks/after-prepare.js", - "inject": true - } - ] + "android": "5.4.0", + "ios": "4.0.0" + } }, "scripts": { "build": "npm i && tsc --skipLibCheck", "demo.ios": "npm run build && cd ../demo && tns run ios", "demo.ios.bundle": "npm run build && cd ../demo && tns run ios --bundle", - "demo.android": "npm run build && cd ../demo && tns run android --syncAllFiles", + "demo.android": "npm run build && cd ../demo && tns run android", "demo.android.bundle": "npm run build && cd ../demo && tns run android --bundle", "test": "npm run tslint && npm run tslint.demo && cd ../demo && tns build ios && tns test android", "test.ios.device": "cd ../demo && tns platform remove ios && tns test ios", @@ -36,9 +24,7 @@ "tslint": "tslint --config '../tslint.json' '*.ts' --exclude '**/node_modules/**'", "tslint.demo": "tslint --config '../tslint.json' '../demo/app/*.ts' --exclude '**/node_modules/**'", "ci.tslint": "npm run tslint && npm run tslint.demo", - "prepublishOnly": "npm run build", - "postinstall": "node postinstall.js", - "preuninstall": "node preuninstall.js" + "prepublishOnly": "npm run build" }, "repository": { "type": "git", @@ -63,16 +49,12 @@ "homepage": "https://github.com/EddyVerbruggen/nativescript-nfc", "readmeFilename": "README.md", "devDependencies": { - "nativescript-dev-typescript": "~0.9.0", - "tns-core-modules": "~5.3.1", - "tns-platform-declarations": "~5.3.1", - "typescript": "~2.9.0", + "nativescript-dev-typescript": "next", + "tns-core-modules": "next", + "tns-platform-declarations": "next", + "typescript": "~3.4.1", "rimraf": "^2.5.0", "tslint": "^5.0.0" }, - "dependencies": { - "fs-promise": "^2.0.0", - "nativescript-hook": "~0.2.1" - }, "bootstrapper": "nativescript-plugin-seed" } diff --git a/src/plugin-hooks/after-prepare.js b/src/plugin-hooks/after-prepare.js deleted file mode 100755 index b029723..0000000 --- a/src/plugin-hooks/after-prepare.js +++ /dev/null @@ -1,23 +0,0 @@ -var fs = require('fs-promise'); -var path = require('path'); - -module.exports = function (logger, projectData, hookArgs) { - var platform = (hookArgs && (hookArgs.platform || (hookArgs.prepareData && hookArgs.prepareData.platform)) || '').toLowerCase(); - - if (platform == 'ios') { - var appResourcesDirectoryPath = projectData.appResourcesDirectoryPath; - var entitlementsFile = path.join(appResourcesDirectoryPath, 'iOS', 'app.entitlements'); - var entitlementsFileAlt = path.join(appResourcesDirectoryPath, 'iOS', projectData.projectName + '.entitlements'); - var projectRoot = path.join(projectData.platformsDir, 'ios'); - var project = path.join(projectRoot, projectData.projectName); - var dest = path.join(projectRoot, projectData.projectName + '.entitlements'); - var fileToCopy = fs.existsSync(entitlementsFile) ? entitlementsFile : entitlementsFileAlt; - return fs.copy(fileToCopy, dest) - .then(function () { - logger.info('Copied `' + fileToCopy + '` to `' + dest + '`'); - }); - } - - logger.info('Only iOS'); - return Promise.resolve(); -}; diff --git a/src/plugin-hooks/before-prepare.js b/src/plugin-hooks/before-prepare.js deleted file mode 100755 index 1cafb49..0000000 --- a/src/plugin-hooks/before-prepare.js +++ /dev/null @@ -1,30 +0,0 @@ -var fs = require('fs-promise'); -var path = require('path'); - -module.exports = function (logger, projectData, hookArgs) { - var platform = (hookArgs && (hookArgs.platform || (hookArgs.prepareData && hookArgs.prepareData.platform)) || '').toLowerCase(); - - if (platform == 'ios') { - var appResourcesDirectoryPath = projectData.appResourcesDirectoryPath; - var platformResourcesDirectory = path.join(appResourcesDirectoryPath, 'iOS'); - var target = path.join(platformResourcesDirectory, 'build.xcconfig'); - - return fs.readFile(target) - .then(function (data) { - return data.toString(); - }) - .then(function (buildData) { - if (!buildData.toString().match(/^\s*CODE_SIGN_ENTITLEMENTS/mg)) { - var entitlementsFile = projectData.projectName + '.entitlements'; - var entitlementsPath = path.join(projectData.projectName, entitlementsFile); - var codeSignProp = '\nCODE_SIGN_ENTITLEMENTS = ' + entitlementsPath; - logger.info('Add code sign prop: ' + codeSignProp); - return fs.appendFile(target, codeSignProp); - } - logger.warn('CODE_SIGN_ENTITLEMENTS already added'); - }); - } - logger.info('Only iOS'); - // skip android - return Promise.resolve(); -}; diff --git a/src/postinstall.js b/src/postinstall.js deleted file mode 100755 index 5ba5ddc..0000000 --- a/src/postinstall.js +++ /dev/null @@ -1 +0,0 @@ -require('nativescript-hook')(__dirname).postinstall(); diff --git a/src/preuninstall.js b/src/preuninstall.js deleted file mode 100755 index b72ac69..0000000 --- a/src/preuninstall.js +++ /dev/null @@ -1 +0,0 @@ -require('nativescript-hook')(__dirname).preuninstall();