Skip to content
This repository has been archived by the owner on Jan 18, 2023. It is now read-only.

Commit

Permalink
fix package scope
Browse files Browse the repository at this point in the history
  • Loading branch information
bradmartin committed Jul 17, 2019
1 parent 8a2aa3c commit bdda3c3
Show file tree
Hide file tree
Showing 65 changed files with 813 additions and 290 deletions.
37 changes: 17 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
<a align="center" href="https://www.npmjs.com/package/nativescript-cardview">
<a align="center" href="https://www.npmjs.com/package/@nstudio/nativescript-cardview">
<h3 align="center">NativeScript CardView</h3>
</a>
<h4 align="center">A NativeScript plugin to provide an XML widget to implement the Material Design CardView component.</h4>

<p align="center">
<a href="https://www.npmjs.com/package/nativescript-cardview">
<img src="https://img.shields.io/npm/v/nativescript-cardview.svg" alt="npm">
<a href="https://www.npmjs.com/package/@nstudio/nativescript-cardview">
<img src="https://img.shields.io/npm/v/@nstudio/nativescript-cardview.svg" alt="npm">
</a>
<a href="https://www.npmjs.com/package/nativescript-cardview">
<img src="https://img.shields.io/npm/dt/nativescript-cardview.svg?label=npm%20downloads" alt="npm">
<a href="https://www.npmjs.com/package/@nstudio/nativescript-cardview">
<img src="https://img.shields.io/npm/dt/@nstudio/nativescript-cardview.svg?label=npm%20downloads" alt="npm">
</a>
<a href="https://github.com/bradmartin/nativescript-cardview/stargazers">
<img src="https://img.shields.io/github/stars/bradmartin/nativescript-cardview.svg" alt="stars">
<a href="https://github.com/nstudio/nativescript-cardview/stargazers">
<img src="https://img.shields.io/github/stars/nstudio/nativescript-cardview.svg" alt="stars">
</a>
<a href="https://travis-ci.org/bradmartin/nativescript-cardview">
<img src="https://travis-ci.org/bradmartin/nativescript-cardview.svg?branch=master" alt="build status">
</a>
<a href="https://paypal.me/bradwayne88">
<img src="https://img.shields.io/badge/Donate-PayPal-green.svg" alt="donate">
<a href="https://travis-ci.org/nstudio/nativescript-cardview">
<img src="https://travis-ci.org/nstudio/nativescript-cardview.svg?branch=master" alt="build status">
</a>
<br />
<a href="http://nstudio.io">
<img src="./images/nstudio-banner.png" alt="nStudio banner">
<a href="https://nstudio.io">
<img src="https://github.com/nstudio/media/blob/master/images/nstudio-banner.png?raw=true" alt="nStudio banner">
</a>
<h5 align="center">Do you need assistance on your project or plugin? Contact the nStudio team anytime at <a href="mailto:[email protected]">[email protected]</a> to get up to speed with the best practices in mobile and web app development.
</h5>
Expand All @@ -31,7 +28,7 @@

## Installation

`tns plugin add nativescript-cardview`
`tns plugin add @nstudio/nativescript-cardview`

Be sure to run a new build after adding plugins to avoid any issues. Here is a post with some details: [Plugin Not Working after adding to project.](https://bradmartin.net/2016/07/20/ahhh-this-nativescript-plugin-doesnt-work)

Expand All @@ -47,12 +44,12 @@ _iOS note: Setting a background-color will help if you do not see the card on th

### NativeScript Plain

<span style="color:red">IMPORTANT: </span>_Make sure you include `xmlns:Card="nativescript-cardview"` on the Page element_
<span style="color:red">IMPORTANT: </span>_Make sure you include `xmlns:Card="@nstudio/nativescript-cardview"` on the Page element_

#### XML

```xml
<Page xmlns:Card="nativescript-cardview">
<Page xmlns:Card="@nstudio/nativescript-cardview">
<StackLayout>
<Card:CardView class="cardStyle" margin="10" elevation="40" radius="5">
<grid-layout rows="200, auto, auto" columns="auto, auto, *">
Expand Down Expand Up @@ -81,7 +78,7 @@ _iOS note: Setting a background-color will help if you do not see the card on th

```typescript
import { registerElement } from 'nativescript-angular/element-registry';
import { CardView } from 'nativescript-cardview';
import { CardView } from '@nstudio/nativescript-cardview';
registerElement('CardView', () => CardView);
```

Expand Down Expand Up @@ -146,14 +143,14 @@ registerElement('CardView', () => CardView);
import Vue from 'nativescript-vue';
Vue.registerElement(
'CardView',
() => require('nativescript-cardview').CardView
() => require('@nstudio/nativescript-cardview').CardView
);
```

```html
<card-view margin="10" elevation="40" radius="1">
<stack-layout>
<label text="Hello World" />
<label text="Hello World"></label>
</stack-layout>
</card-view>
```
Expand Down
2 changes: 1 addition & 1 deletion demo-angular/nsconfig.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"appResourcesPath": "App_Resources",
"appPath": "src"
}
}
30 changes: 15 additions & 15 deletions demo-angular/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,37 @@
"nativescript": {
"id": "org.nativescript.cardview.angular",
"tns-android": {
"version": "5.2.1"
"version": "6.0.0"
}
},
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"repository": "<fill-your-repository-here>",
"dependencies": {
"@angular/animations": "~7.2.0",
"@angular/common": "~7.2.0",
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/forms": "~7.2.0",
"@angular/http": "~7.2.0",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"nativescript-angular": "~7.2.1",
"nativescript-cardview": "file:../src",
"@angular/common": "8.0.0",
"@angular/compiler": "8.0.0",
"@angular/core": "8.0.0",
"@angular/forms": "8.0.0",
"@angular/http": "8.0.0-beta.10",
"@angular/platform-browser": "8.0.0",
"@angular/platform-browser-dynamic": "8.0.0",
"@angular/router": "8.0.0",
"nativescript-angular": "8.0.2",
"@nstudio/nativescript-cardview": "file:../src",
"nativescript-theme-core": "~1.0.4",
"reflect-metadata": "~0.1.12",
"rxjs": "~6.3.0",
"tns-core-modules": "~5.2.2",
"zone.js": "~0.8.26"
"tns-core-modules": "6.0.1",
"zone.js": "0.9.1"
},
"devDependencies": {
"@angular/compiler-cli": "~7.2.0",
"@nativescript/schematics": "~0.5.0",
"@ngtools/webpack": "~7.2.0",
"awesome-typescript-loader": "~5.2.1",
"nativescript-dev-typescript": "~0.8.0",
"nativescript-dev-webpack": "~0.20.2"
"nativescript-dev-webpack": "1.0.1",
"typescript": "3.4.5"
},
"gitHead": "f548ec926e75201ab1b7c4a3a7ceefe7a4db15af",
"readme": "NativeScript Application"
Expand Down
2 changes: 1 addition & 1 deletion demo-angular/src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component } from '@angular/core';
import { CardView } from 'nativescript-cardview';
import { CardView } from '@nstudio/nativescript-cardview';
import { registerElement } from 'nativescript-angular';

registerElement('CardView', () => CardView as any);
Expand Down
83 changes: 49 additions & 34 deletions demo-angular/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ 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 { AngularCompilerPlugin } = require("@ngtools/webpack");
const TerserPlugin = require("terser-webpack-plugin");
const { getAngularCompilerPlugin } = require("nativescript-dev-webpack/plugins/NativeScriptAngularCompilerPlugin");
const hashSalt = Date.now().toString();

module.exports = env => {
// Add your custom Activities, Services and other Android app components here.
Expand All @@ -26,11 +27,11 @@ module.exports = env => {
throw new Error("You need to provide a target platform!");
}

const AngularCompilerPlugin = getAngularCompilerPlugin(platform);
const projectRoot = __dirname;

// Default destination inside platforms/<platform>/...
const dist = resolve(projectRoot, nsWebpack.getAppPath(platform, projectRoot));
const appResourcesPlatformDir = platform === "android" ? "Android" : "iOS";

const {
// The 'appPath' and 'appResourcesPath' values are fetched from
Expand All @@ -41,19 +42,30 @@ module.exports = env => {

// You can provide the following flags when running 'tns run android|ios'
aot, // --env.aot
snapshot, // --env.snapshot
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 tsConfigName = "tsconfig.tns.json";
const entryModule = `${nsWebpack.getEntryModule(appFullPath)}.ts`;
const entryModule = `${nsWebpack.getEntryModule(appFullPath, platform)}.ts`;
const entryPath = `.${sep}${entryModule}`;
const entries = { bundle: entryPath };
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";
};

const ngCompilerTransformers = [];
const additionalLazyModuleResources = [];
if (aot) {
Expand All @@ -80,16 +92,25 @@ module.exports = env => {

const ngCompilerPlugin = new AngularCompilerPlugin({
hostReplacementPaths: nsWebpack.getResolver([platform, "tns"]),
platformTransformers: ngCompilerTransformers.map(t => t(() => ngCompilerPlugin, resolve(appFullPath, entryModule))),
mainPath: resolve(appPath, entryModule),
platformTransformers: ngCompilerTransformers.map(t => t(() => ngCompilerPlugin, resolve(appFullPath, entryModule), projectRoot)),
mainPath: join(appFullPath, entryModule),
tsConfigPath: join(__dirname, tsConfigName),
skipCodeGeneration: !aot,
sourceMap: !!sourceMap,
sourceMap: !!isAnySourceMapEnabled,
additionalLazyModuleResources: additionalLazyModuleResources
});

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")}`);
}

nsWebpack.processAppComponents(appComponents, platform);
const config = {
mode: uglify ? "production" : "development",
mode: production ? "production" : "development",
context: appFullPath,
externals,
watchOptions: {
Expand All @@ -100,15 +121,15 @@ module.exports = env => {
]
},
target: nativescriptTarget,
entry: {
bundle: entryPath,
},
entry: entries,
output: {
pathinfo: false,
path: dist,
sourceMapFilename,
libraryTarget: "commonjs2",
filename: "[name].js",
globalObject: "global",
hashSalt
},
resolve: {
extensions: [".ts", ".js", ".scss", ".css"],
Expand All @@ -135,8 +156,9 @@ module.exports = env => {
"fs": "empty",
"__dirname": false,
},
devtool: sourceMap ? "inline-source-map" : "none",
devtool: hiddenSourceMap ? "hidden-source-map" : (sourceMap ? "inline-source-map" : "none"),
optimization: {
runtimeChunk: "single",
splitChunks: {
cacheGroups: {
vendor: {
Expand All @@ -153,12 +175,14 @@ module.exports = env => {
},
minimize: !!uglify,
minimizer: [
new UglifyJsPlugin({
new TerserPlugin({
parallel: true,
cache: true,
uglifyOptions: {
sourceMap: isAnySourceMapEnabled,
terserOptions: {
output: {
comments: false,
semicolons: !isAnySourceMapEnabled
},
compress: {
// The Android SBG has problems parsing the output
Expand All @@ -173,7 +197,7 @@ module.exports = env => {
module: {
rules: [
{
test: new RegExp(entryPath),
test: nsWebpack.getEntryPathRegExp(appFullPath, entryPath),
use: [
// Require all Android app components
platform === "android" && {
Expand All @@ -186,6 +210,10 @@ module.exports = env => {
options: {
angular: true,
loadCss: !snapshot, // load the application css if in debug mode
unitTesting,
appFullPath,
projectRoot,
ignoredFiles: nsWebpack.getUserDefinedEntries(entries, platform)
}
},
].filter(loader => !!loader)
Expand All @@ -198,14 +226,14 @@ module.exports = env => {
test: /[\/|\\]app\.css$/,
use: [
"nativescript-dev-webpack/style-hot-loader",
{ loader: "css-loader", options: { minimize: false, url: false } }
{ loader: "css-loader", options: { url: false } }
]
},
{
test: /[\/|\\]app\.scss$/,
use: [
"nativescript-dev-webpack/style-hot-loader",
{ loader: "css-loader", options: { minimize: false, url: false } },
{ loader: "css-loader", options: { url: false } },
"sass-loader"
]
},
Expand Down Expand Up @@ -235,29 +263,17 @@ module.exports = env => {
// Define useful constants like TNS_WEBPACK
new webpack.DefinePlugin({
"global.TNS_WEBPACK": "true",
"process": undefined,
"process": "global.process",
}),
// 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
},
]),
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)}/**`] }),
// Generate a bundle starter script and activate it in package.json
new nsWebpack.GenerateBundleStarterPlugin([
"./vendor",
"./bundle",
]),
new nsWebpack.GenerateNativeScriptEntryPointsPlugin("bundle"),
// For instructions on how to set up workers with webpack
// check out https://github.com/nativescript/worker-loader
new NativeScriptWorkerPlugin(),
Expand All @@ -267,7 +283,6 @@ module.exports = env => {
],
};


if (report) {
// Generate report files for bundles content
config.plugins.push(new BundleAnalyzerPlugin({
Expand Down
19 changes: 19 additions & 0 deletions demo-vue/.migration_backup/Android-Pre-v4/app.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Add your native dependencies here:

// Uncomment to add recyclerview-v7 dependency
//dependencies {
// implementation 'com.android.support:recyclerview-v7:+'
//}

// If you want to add something to be applied before applying plugins' include.gradle files
// e.g. project.ext.googlePlayServicesVersion = "15.0.1"
// create a file named before-plugins.gradle in the current directory and place it there

android {
defaultConfig {
generatedDensities = []
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
}
Loading

0 comments on commit bdda3c3

Please sign in to comment.