diff --git a/.eslintignore b/.eslintignore
new file mode 100644
index 0000000..6ef5839
--- /dev/null
+++ b/.eslintignore
@@ -0,0 +1,2 @@
+node_modules/
+generator/templates/
\ No newline at end of file
diff --git a/.eslintrc.js b/.eslintrc.js
new file mode 100644
index 0000000..cc7dc36
--- /dev/null
+++ b/.eslintrc.js
@@ -0,0 +1,36 @@
+module.exports = {
+ "root": true,
+ "env": {
+ "node": true
+ },
+ "extends": [
+ "eslint:recommended",
+ "plugin:vue/recommended",
+ "@vue/airbnb",
+ "@vue/prettier"
+ ],
+ "rules": {
+ "import/extensions": 0,
+ "global-require": 0,
+ "eol-last": 0,
+ "no-param-reassign": 0,
+ "object-curly-newline": 0,
+ "no-plusplus": 0,
+ "max-len": [
+ 2,
+ {
+ "code": 160
+ }
+ ],
+ "prefer-destructuring": [
+ 2,
+ {
+ "object": true,
+ "array": false
+ }
+ ]
+ },
+ "parserOptions": {
+ "parser": "babel-eslint"
+ }
+}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 40b878d..18566ec 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-node_modules/
\ No newline at end of file
+node_modules/
+.vscode
\ No newline at end of file
diff --git a/.prettierignore b/.prettierignore
new file mode 100644
index 0000000..95668c3
--- /dev/null
+++ b/.prettierignore
@@ -0,0 +1 @@
+generator/templates/*
\ No newline at end of file
diff --git a/.prettierrc b/.prettierrc
new file mode 100644
index 0000000..f0f8e68
--- /dev/null
+++ b/.prettierrc
@@ -0,0 +1,10 @@
+{
+ "printWidth": 160,
+ "singleQuote": true,
+ "trailingComma": "none",
+ "tabWidth": 2,
+ "semicolons": true,
+ "bracketSpacing": true,
+ "arrowParens": "always",
+ "useTabs": false
+}
\ No newline at end of file
diff --git a/README.md b/README.md
index f80b854..0341b43 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,242 @@
-# nativescript-vue-cli-plugin
\ No newline at end of file
+# nativescript-vue-cli-plugin
+
+Nativescript-Vue Plugin for [vue-cli@3.0](https://github.com/vuejs/vue-cli)
+
+This plugin will integrate [Nativescript-Vue](https://nativescript-vue.org/) into new and existing Vue projects. Additionally, it will allow for the choice of developing for Native only environments or Native __and__ Web environments under a single project structure. In addition, choosing to integrate [Nativescript-Vue-Web](https://github.com/Nativescript-Vue-Web/Nativescript-Vue-Web), will allow for the development of Web components with a NativeScript-Vue like syntax that has the benefit of allowing for the sharing of components between the Native and Web sides of the project. This helps reduce the amount of code, maintenence needs, and the amount of time needed for development activities.
+
+## Sharing logic in a single Web and Native capable component
+The key feature of this plugin is that it will allow you to compose SFC's that contain both Web and Native structures in them. If your component has exactly the same logic (`
+
+
+```
+
+### Optional Separation of concerns for Web and Native SFC's
+If you want complete seperation of concerns between Web and Native for components, core logic and styling, you can also provide an alternate file naming scheme in your project. The name will dictate which mode (Web or Native) and platform (Android or IOS) the file will be used with. The same overall schema will work for `.vue`, `.js`, `.ts`, `.scss` and `.css` files.
+
+| File Type | Android __and__ IOS | Android only | IOS only | Web only |
+| ---------- | ------------------- | --------------- | --------------- | --------------- |
+| vue | *.native.vue | *.android.vue | *.ios.vue | *.vue |
+| js | *.native.js | *.android.js | *.ios.js | *.js |
+| ts | *.native.ts | *.android.ts | *.ios.ts | *.ts |
+| scss | *.native.scss | *.android.scss | *.ios.scss | *.scss |
+| css | *.native.css | *.android.css | *.ios.css | *.css |
+
+Webpack will handle figuring out which files to include based on the `npm run` command syntax you pass in. You can also mix and match this file naming schema with the `web` or `native` tag options mentioned above.
+
+At `serve` or `build` in conjunction with the mode such as `android` or `ios`, Webpack will filter which files are looked at. For instance, if you do `npm run serve:android`, then it will look for `*.native.vue` and `*.android.vue` files and ignore `*.ios.vue` files entirely. Conversely, it will do the same when you are working with `ios` and will ignore `*.android.vue` files.
+
+This will allow you to develop generic native components under the `*.native.vue` file extension, but in special cases, it may require you to do platform specific components, core logic and styling. Use the corrosponding file extension to allow this to happen.
+
+If you are building for web, then just `*.vue` will work and if you are building for a Native __only__ project, then `*.vue` will work as well as the previous options mentioned.
+
+## Sharing components and assets between Native and Web SFC's
+If you want to use common components and assets between `web`, `android` and `ios`, you can do that. For `assets`, place them in `src/assets` and for components, place them in `src/components`. At compile time, assets will be copied to the output directory's `assets` folder and can be universally accessed across environments via something like `~/assets/logo.png`. For components, they can be universally accessed via something similar to `components/HelloWorld`.
+
+## Install
+
+If vue-cli 3 is not yet installed, first follow the instructions here: https://github.com/vuejs/vue-cli
+
+**Tip**: If you don't want to overwrite your current vue-cli 2 setup because you still need `vue init`, [then try this](https://cli.vuejs.org/guide/creating-a-project.html#pulling-2-x-templates-legacy).
+
+Generate a project using vue-cli 3.0
+```
+vue create my-app
+```
+
+Before installing the Nativescript-Vue CLI 3 Plugin, make sure to commit or stash changes in case you need to revert.
+
+To install the Nativescript-Vue CLI 3 Plugin...
+```
+cd my-app
+npm install --save-dev git+https://github.com/jawa-the-hutt/vue-cli-plugin-nativescript-vue
+vue invoke vue-cli-plugin-nativescript-vue
+```
+
+## Invocation Prompts
+1. Enter a unique application identifier
+ * Accepting the default is fine for testing
+2. Use HTML5 history mode? (Default: hash mode)
+ * Required parameter for the cli core generator when vue-router is used
+3. Is this a brand new project? (Default: Yes)
+ * By choosing `No`, the plugin will try and be as non-destructive as possible to an existing project. It will do this by adding a folder into root named `ns-example` and add files into there to provide examples of how a project would change.
+ * These changes will factor in answers to the other questions and adjust accordingly. Regardless of the answer, the plugin will install packages and adjust `package.json` as necessary to prep the project.
+4. Dual Native AND Web development experience or a Native only? (Default: Dual)
+ * By default, the plugin will assume you want to develop for the Web and Native environments within the same project. As such, there will be two sides to the project where web environments will be actively developed within `/src` and Native environments will be developed within `/app` unless you choose to integrate `Nativescript-Vue-Web` and all files will be placed in `/src`.
+ * Warning: Choosing to develop for Native only will move the main entry point of the project and development folder to `/app`, it will copy the necessary files and then delete `/src`.
+ * By choosing `Dual`, you will be able to bring your own component framework into the web portion of the project. `NativeScript-Vue` [cannot use vue-router](https://nativescript-vue.org/en/docs/routing/vue-router/) currently, so you will have to provide your own manual routing. The templated options deployed with the plugin will show how to do basic manual routing.
+5. What type of template do you want to start with? (Default: Simple)
+ * Simple is just a simple setup with a header and basic routing.
+ * [Nativescript-Vue-Web](https://github.com/Nativescript-Vue-Web/Nativescript-Vue-Web) - The Simple template, but with NS-Vue like syntax for web components. This option should only appear if you have chosen to develop in the Dual Web and Native environments. This option will effecively integrate a web component framework that will allow you to develop components that can be used in the Web and Native side of the project. It uses `NativeScript-Vue` like syntax on components which will allow for the sharing of components between NativeScript and Web.
+ * Sidebar (currently disabled), will allow you to start with a project that includes a fixed header and pop-out sidebar menu.
+ * We expect to add more templates in the future as use cases come up.
+
+## Running the project
+You will have several options in serving and building the project:
+1. `npm run serve:web`
+2. `npm run serve:android`
+3. `npm run serve:ios`
+4. `npm run build:web`
+5. `npm run build:android`
+6. `npm run build:ios`
+
+
+The basic `serve` and `build` options should be similar to what is in a CLI 3 project except the added options to dictate which kind of environment you are using: `web`, `android` or `ios`. Please note that when building web projects, they will output to `dist` and when building native projects, they will output to `platforms\android` or `platforms\ios` depending on which you are building at the time.
+
+### Debugging your project
+You will have the standard options for debugging available to you as you would with just `tns`. You can do the following to debug Native versions of your app.
+1. `npm run debug:android`
+2. `npm run debug:ios`
+
+You should then be able to attach the Chrome debugger as you normally would via the [NativeScript docs](https://docs.nativescript.org/angular/tooling/debugging/chrome-devtools).
+
+You should also be able to debug directly in VSCode. The [NativeScript VSCode Extension docs](https://docs.nativescript.org/angular/tooling/visual-studio-code-extension) are a good place to start with understanding how to do this. However, you will need to modify your `launch.json` file to force `tns` to work properly with VUE CLI 3.
+
+Your `launch.json` file should look something like below. Notice the different in the `tnsArgs` line that is different than what is in the documentation link above.
+```
+{
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "Launch on iOS",
+ "type": "nativescript",
+ "request": "launch",
+ "platform": "ios",
+ "appRoot": "${workspaceRoot}",
+ "sourceMaps": true,
+ "watch": true,
+ "tnsArgs":[" --bundle --env.development cross-env-shell VUE_CLI_MODE=development.ios"]
+ },
+ {
+ "name": "Attach on iOS",
+ "type": "nativescript",
+ "request": "attach",
+ "platform": "ios",
+ "appRoot": "${workspaceRoot}",
+ "sourceMaps": true,
+ "watch": false
+ },
+ {
+ "name": "Launch on Android",
+ "type": "nativescript",
+ "request": "launch",
+ "platform": "android",
+ "appRoot": "${workspaceRoot}",
+ "sourceMaps": true,
+ "watch": true,
+ "tnsArgs":[" --bundle --env.development cross-env-shell VUE_CLI_MODE=development.android"]
+ },
+ {
+ "name": "Attach on Android",
+ "type": "nativescript",
+ "request": "attach",
+ "platform": "android",
+ "appRoot": "${workspaceRoot}",
+ "sourceMaps": true,
+ "watch": false
+ },
+ {
+ "type": "chrome",
+ "request": "launch",
+ "name": "web: chrome",
+ "url": "http://localhost:8080",
+ "webRoot": "${workspaceFolder}/src",
+ "breakOnLoad": true,
+ "sourceMapPathOverrides": {
+ "webpack:///src/*": "${webRoot}/*"
+ }
+ },
+ ]
+}
+```
+You will also need to modify your `vue.config.js` file to include a `webpack-chain` statement that will setup your source map. It should look something like this:
+```
+module.exports = {
+ chainWebpack: config => {
+ config
+ .devtool('inline-source-map')
+ }
+}
+```
+
+### Previewing your Project
+You should be able to use the NativeScript Playground and Preview Apps via the following npm statements:
+1. `npm run preview:android`
+2. `npm run preview:ios`
+
+#### --env command line recognition
+Basic support for passing the `env` command line option is in place, but has a slightly different syntax since we're working with the CLI 3 webpack infrastructure. To inject items into `env` at run-time, you will need to add `-- --env.option` Where option is one of the recognized options that Nativescript-Vue and this project supports.
+An example of this would be something like this: `npm run serve:android -- --env.production`. This would allow you to serve up a Production build of your Android app versus just running `npm run serve:android` which would serve a Development version of the same.
+
+#### Webpack related information
+The options passed in at `npm run` will dictate what webpack config is provided. The first choice webpack will make is if this is a `web` or `native` environment. Then, if it's a `native` environment, it will determine choices to be made between `ios` and `android`.
+
+Each time the project is built or served, the plugin will copy the latest webpack config from the cli to the root of your project. When you build a project, it will clean-up this file at the end, but just serving the project will not. This is an issue with [nativescript-dev-webpack](https://github.com/NativeScript/nativescript-dev-webpack) and cannot be overcome at this time.
+
+#### Inspecting the Webpack config
+If you'd like to see what the webpack config is doing then you can run one of the following:
+
+1. `vue inspect -- --env.android > out-android.js`
+2. `vue inspect -- --env.ios > out-ios.js`
+3. `vue inspect -- --env.web > out-web.js`
+
+These will default to showing you the Development version of the webpack config. You can pass in the `-- --env.production` option to see the Production version of the config. Subtitute `development.android` or `production.ios`, etc to see the different configs based on the environmental variables.
+
+#### Aliases
+Prebuilt in the webpack config are several aliases that you can use. Here is a table listing out the various alias and the folder they use based on the environment chosen:
+
+| Alias | Native | Web |
+| ---------- | --------------- | --------------- |
+| ~ | /app | /src |
+| @ | /app | /src |
+| src | /src | /src |
+| assets | /src/assets | /src/assets |
+| components | /src/components | /src/components |
+| fonts | /src/fonts | /src/fonts |
+| styles | /src/styles | /src/styles |
+| root | / | / |
+
+
+## For TypeScript enabled projects
+If your CLI 3 project has TypeScript enabled, then the plugin will attempt to give you a very basic TypeScript version of the template you choose. When you invoke the plugin and the template generator makes changes, you will notice the `*.d.ts` files that are usually in `src` will be moved to `/types`. The plugin's webpack integration will ensure these files are referenced correctly at compile and runtimes.
diff --git a/generator/README.md b/generator/README.md
new file mode 100644
index 0000000..3167cfc
--- /dev/null
+++ b/generator/README.md
@@ -0,0 +1,32 @@
+# nativescript-vue-cli-plugin - Generator Readme
+
+Want to submit a PR for a new template? Read below.
+
+It is __highly, highly, highly suggested__ that you copy/paste the `simple` template in its entirety and then rename the copied directory. It will make it much easier for you to get started using the existing logic in the generator. Modifications to the existing generator logic will be considered for PR, but will have to go through rigourous testing to ensure the changes do not break all pre-existing templates.
+
+If you want to add additional templates to the plugin, then here's the information on how to do it:
+
+1. Create a new option to the prompt question #5 concerning which template you'd like to deploy.
+ * The value for the template should be kept simple and easy.
+2. Create a new directory under `/generator/templates`.
+ * The directory name should __exactly match__ the value from #1. For example if the value from #1 is `simple`, then the directory structure would be `/generator/templates/simple`
+3. The new template directory __must__ have a single first-level subdirectory named `src`.
+4. Inside the `src` directory, you should add the following in an effort to give the template feature consistancy to the other templates:
+ * router.js
+ * main.js
+ * main.native.js (the NS-Vue project entry point)
+ * package.json (this is the standard NativeScript-Vue package.json file. Just copy/paste from the simple template)
+ * App.vue
+ * views/About.vue (optional)
+ * views/Home.vue (optional)
+ * components/HelloWorld.vue (optional)
+ * components/HelloWorld.native.vue (optional)
+ * components/HelloWorld.ios.vue (optional)
+ * components/HelloWorld.android.vue (optional)
+ * assets/logo.png (optional, but highly encouraged to prove images are loading)
+
+Within the \*.vue files you will find [ejs](https://github.com/mde/ejs) syntax that will enable you to differentiate between TypeScript and non-TypeScript projects. Any new templates added to the project __must__ demonstrate they work across these options or the PR to add the template will be rejected.
+
+### Word of warning concerning using EJS templates with Prettier
+Prettier does not support EJS templates and if you have Prettier automatically fix all issues in a `*.vue` template file, then you will run the risk of it overwriting sections of the template from one `if` statement to the `else` side of the statement. Pay close attention to this specifically in your `script` tags as it relates to the TypeScript vs. non-TypeScript parts of the template. Whichever one comes first in the `if` statement will overwrite the section after the `else` statement.
+
diff --git a/generator/index.js b/generator/index.js
index f376dc6..029df3e 100644
--- a/generator/index.js
+++ b/generator/index.js
@@ -1,44 +1,931 @@
-module.exports = (api, options, rootOptions) => {
- const fs = require('fs')
- const rimraf = require('rimraf')
+/* eslint-disable no-console */
+const path = require('path');
+const fs = require('fs-extra');
+const replace = require('replace-in-file');
- api.extendPackage({
- scripts: {
- 'watch:android': 'vue-cli-service tns --android',
- 'watch:ios': 'vue-cli-service tns --ios',
- },
- dependencies: {
- 'nativescript-vue': '^1.3.1'
+const newline = process.platform === 'win32' ? '\r\n' : '\n';
+
+module.exports = async (api, options, rootOptions) => {
+ const genConfig = {
+ // if it is a new project changes will be written as they normally would with any plugin
+ // if it is an existing project, changes will be added to the ./ns-example directory
+ dirPathPrefix: options.isNewProject === true ? './' : './ns-example/',
+
+ // simple typescript detection and then variable is passed to multiple templating functions
+ // to simply change the file's extension
+ jsOrTs: api.hasPlugin('typescript') ? '.ts' : '.js',
+
+ // A template type of 'simple' project will have a base template path that equals: ./templates/simple
+ // then we determine if the project is using Nativescript-Vue-Web and we append a subdirectory to the base path
+ templateTypePathModifer: options.templateType,
+
+ // Get the location to the native app directory
+ nativeAppPathModifier: options.isNativeOnly ? 'app/' : 'src/',
+
+ // Determine the path to App_Resources
+ get appResourcesPathModifier() {
+ return this.nativeAppPathModifier + 'App_Resources';
},
- devDependencies: {
- 'nativescript-vue-loader': '1.0.0',
- 'nativescript-vue-template-compiler': '^1.3.1',
- 'tns-core-modules': '^4.0.0'
- }
- })
- api.extendPackage(pkg => {
- delete pkg.dependencies['vue']
- delete pkg.devDependencies['vue-template-compiler']
- delete pkg.browserslist
- delete pkg.scripts['serve']
- })
+ // setup directories to exclude in the tsconfig.json file(s)
+ get tsExclusionArray() {
+ return ['node_modules', 'dist', 'platforms', 'hooks', this.appResourcesPathModifier];
+ }
+ };
- api.render('./templates/simple', {
+ // common render options to be passed to render functions
+ const commonRenderOptions = {
applicationName: api.generator.pkg.name,
applicationVersion: api.generator.pkg.version,
applicationAndroidVersionCode: api.generator.pkg.version.split('.').join('0'),
applicationDescription: api.generator.pkg.description || api.generator.pkg.name,
applicationLicense: api.generator.pkg.license || 'MIT',
applicationId: options.applicationId,
- historyMode: options.historyMode || false,
- })
+ historyMode: options.historyMode,
+ doesCompile: api.hasPlugin('babel') || api.hasPlugin('typescript') ? true : false,
+ usingBabel: api.hasPlugin('babel') ? true : false,
+ usingTS: api.hasPlugin('typescript') ? true : false
+ };
+
+ console.log('adding to package.json');
+
+ api.extendPackage({
+ nativescript: {
+ id: 'org.nativescript.application',
+ 'tns-ios': {
+ version: '5.2.0'
+ },
+ 'tns-android': {
+ version: '5.2.1'
+ }
+ },
+ scripts: {
+ 'build:android': 'npm run setup-webpack-config && tns build android --bundle --env.production && npm run remove-webpack-config',
+ 'build:ios': 'npm run setup-webpack-config && tns build ios --bundle --env.production && npm run remove-webpack-config',
+ 'remove-webpack-config': 'node ./node_modules/vue-cli-plugin-nativescript-vue/lib/scripts/webpack-maintenance post',
+ 'serve:android': 'npm run setup-webpack-config && tns run android --bundle --env.development',
+ 'serve:ios': 'npm run setup-webpack-config && tns run ios --bundle --env.development',
+ // 'inspect:android': 'npm run setup-webpack-config && vue inspect -- --env.android > out-android.js',
+ // 'inspect:ios': 'npm run setup-webpack-config && vue inspect -- --env.ios > out-ios.js',
+ 'debug:android': 'npm run setup-webpack-config && tns debug android --bundle --env.development',
+ 'debug:ios': 'npm run setup-webpack-config && tns debug ios --bundle --env.development',
+ 'preview:android': 'npm run setup-webpack-config && tns preview --bundle --env.development --env.android',
+ 'preview:ios': 'npm run setup-webpack-config && tns preview --bundle --env.development --env.ios',
+ 'setup-webpack-config': 'node ./node_modules/vue-cli-plugin-nativescript-vue/lib/scripts/webpack-maintenance pre',
+ 'clean:platforms': 'rimraf platforms',
+ 'clean:android': 'rimraf platforms/android',
+ 'clean:ios': 'rimraf platforms/ios'
+ },
+ dependencies: {
+ 'nativescript-vue': '^2.0.2',
+ 'tns-core-modules': '^5.2.1'
+ },
+ devDependencies: {
+ 'nativescript-dev-webpack': '^0.17.0',
+ 'nativescript-vue-template-compiler': '^2.0.2',
+ 'nativescript-worker-loader': '~0.9.1',
+ 'node-sass': '^4.11.0',
+ 'string-replace-loader': '^2.1.1',
+ rimraf: '^2.6.3',
+ webpack: '^4.29.6',
+ 'webpack-cli': '^3.2.3'
+ }
+ });
+
+ // add scripts when we are also developing for the web
+ if (!options.isNativeOnly) {
+ api.extendPackage({
+ scripts: {
+ 'serve:web': 'vue-cli-service serve --mode development.web',
+ 'build:web': 'vue-cli-service build --mode production.web'
+ //'inspect:web': 'npm run setup-webpack-config && vue inspect -- --env.web > out-web.js'
+ }
+ });
+
+ // if we are using NativeScript-Vue-Web then add the package
+ if (options.templateType == 'nvw') {
+ api.extendPackage({
+ dependencies: {
+ 'nativescript-vue-web': '^0.9.4'
+ }
+ });
+ }
+ } else {
+ //
+ }
+
+ if (api.hasPlugin('typescript')) {
+ api.extendPackage({
+ dependencies: {},
+ devDependencies: {
+ 'fork-ts-checker-webpack-plugin': '^0.4.15',
+ 'terser-webpack-plugin': '^1.2.3'
+ //'tns-platform-declarations': '^4.2.1'
+ }
+ });
+
+ // this means it's a typescript project and using babel
+ if (api.hasPlugin('babel')) {
+ api.extendPackage({
+ dependencies: {},
+ devDependencies: {
+ '@babel/types': '^7.1.3'
+ }
+ });
+ }
+ }
+
+ // if the project is using babel, then load appropriate packages
+ if (api.hasPlugin('babel')) {
+ api.extendPackage({
+ devDependencies: {
+ '@babel/core': '^7.3.4',
+ '@babel/preset-env': '^7.3.4',
+ 'babel-loader': '^8.0.5',
+ '@babel/traverse': '^7.3.4'
+ }
+ });
+
+ api.render(async () => {
+ fs.ensureFileSync(genConfig.dirPathPrefix + 'babel.config.js');
+ await applyBabelConfig(api, genConfig.dirPathPrefix + 'babel.config.js');
+ });
+ }
+
+ // if the project is using eslint, add some global variables
+ // to the eslintConfig in order to avoid no-def errors
+ if (api.hasPlugin('eslint')) {
+ api.extendPackage({
+ eslintConfig: {
+ globals: {
+ TNS_APP_MODE: true,
+ TNS_APP_PLATFORM: true
+ }
+ }
+ });
+ }
+
+ console.log('deleting from package.json');
+ api.extendPackage((pkg) => {
+ // if the project is using babel, then delete babel-core
+ if (api.hasPlugin('babel')) {
+ delete pkg.devDependencies['babel-core'];
+ }
+ // we will be replacing these
+ delete pkg.scripts['serve'], delete pkg.scripts['build'];
+
+ if (options.isNativeOnly) {
+ delete pkg.browserslist;
+ }
- // delete the "public" directory
- api.onCreateComplete(() => {
- const publicPath = api.resolve('public')
- if(fs.existsSync(publicPath)) {
- rimraf.sync(publicPath)
+ if (options.templateType !== 'nvw') {
+ delete pkg.dependencies['nativescript-vue-web'];
}
- })
-}
\ No newline at end of file
+ });
+
+ console.log('doing template rendering');
+
+ // render App_Resources folder
+ api.render(async () => {
+ // eslint-disable-next-line prettier/prettier
+ await renderDirectoryStructure(
+ api,
+ options,
+ rootOptions,
+ '.js',
+ commonRenderOptions,
+ './templates/App_Resources',
+ genConfig.dirPathPrefix + genConfig.appResourcesPathModifier
+ );
+ });
+
+ // If Native only or Dual Native and Web Project.
+ if (!options.isNativeOnly) {
+ api.render(async () => {
+ // render src directory
+ await renderDirectoryStructure(
+ api,
+ options,
+ rootOptions,
+ genConfig.jsOrTs,
+ commonRenderOptions,
+ path.join('templates', genConfig.templateTypePathModifer, 'src'),
+ genConfig.dirPathPrefix + 'src'
+ );
+
+ // add router statements to src/main.*s
+ await vueRouterSetup(api, genConfig.dirPathPrefix, genConfig.jsOrTs);
+
+ // add vuex statements to src/main.*s
+ await vuexSetup(api, options, genConfig.dirPathPrefix, genConfig.jsOrTs, genConfig.nativeAppPathModifier);
+ });
+ } else {
+ // Is Native Only
+ api.render(async () => {
+ // render app directory
+ await renderDirectoryStructure(
+ api,
+ options,
+ rootOptions,
+ genConfig.jsOrTs,
+ commonRenderOptions,
+ path.join('templates', genConfig.templateTypePathModifer, 'src'),
+ genConfig.dirPathPrefix + genConfig.nativeAppPathModifier.slice(0, -1)
+ );
+
+ // add vuex statements to app/main.*s
+ await vuexSetup(api, options, genConfig.dirPathPrefix, genConfig.jsOrTs);
+ });
+ }
+
+ api.onCreateComplete(async () => {
+ // make changes to .gitignore
+ gitignoreAdditions(api);
+
+ // create files in ./ or ./ns-example
+ writeRootFiles(api, options, genConfig.dirPathPrefix);
+
+ // create nsconfig.json in ./ or ./ns-example
+ nsconfigSetup(genConfig.dirPathPrefix, api.resolve('nsconfig.json'), genConfig.nativeAppPathModifier, genConfig.appResourcesPathModifier);
+
+ // copy over .vue with native.vue files
+ if (options.isNativeOnly) {
+ nativeOnlyRenameFiles(genConfig.dirPathPrefix + genConfig.nativeAppPathModifier.slice(0, -1));
+ }
+
+ // remove router config for projects that don't use vue-router
+ if (!rootOptions.router) {
+ fs.remove(genConfig.dirPathPrefix + genConfig.nativeAppPathModifier + 'router' + genConfig.jsOrTs, (err) => {
+ if (err) throw err;
+ });
+ }
+
+ if (api.hasPlugin('typescript')) {
+ // we need to edit the tsconfig.json file in /app
+ // for a Native only project to remove references to /src
+ await tsconfigSetup(options, genConfig.dirPathPrefix, genConfig.nativeAppPathModifier);
+
+ if (fs.existsSync(api.resolve('tslint.json'))) {
+ await tslintSetup(genConfig.dirPathPrefix, api.resolve('tslint.json'), genConfig.tsExclusionArray);
+
+ const baseDir = genConfig.nativeAppPathModifier;
+ require('../lib/tslint')({
+ '_': [`${baseDir}**/*.ts`, `${baseDir}**/*.vue`, `${baseDir}**/*.tsx`, 'tests/**/*.ts', 'tests/**/*.tsx']
+ }, api, false);
+ }
+ }
+
+ // the main difference between New and Existing for this section is
+ // that for New projects we are moving files around, but for
+ // existing projects we are copying files into ./ns-example
+ if (options.isNewProject) {
+ // move type files out of src to ./ or ./ns-example
+ if (api.hasPlugin('typescript')) {
+ // Do these synchronously so in the event we delete the ./src directory in a native only
+ // situation below we don't try and move a file that no longer exists
+ try {
+ fs.moveSync('./src/shims-tsx.d.ts', genConfig.dirPathPrefix + 'types/shims-tsx.d.ts', { overwrite: true });
+ fs.moveSync('./src/shims-vue.d.ts', genConfig.dirPathPrefix + 'types/shims-vue.d.ts', { overwrite: true });
+ } catch (err) {
+ throw err;
+ }
+ }
+
+ // for new projects that are native only, move files/dirs and delete others
+ if (options.isNativeOnly) {
+ // Do these synchronously so that when we delete the ./src directory below
+ // we don't try and move a file that no longer exists
+ try {
+ // move store.js file from ./src to ./app
+ if (api.hasPlugin('vuex')) {
+ fs.moveSync('./src/store' + genConfig.jsOrTs, genConfig.dirPathPrefix + genConfig.nativeAppPathModifier + 'store' + genConfig.jsOrTs, {
+ overwrite: true
+ });
+ }
+ } catch (err) {
+ throw err;
+ }
+ // remove src directory as we don't need it any longer
+ fs.remove('./src', (err) => {
+ if (err) throw err;
+ });
+ // remove public directory as we don't need it any longer
+ fs.remove('./public', (err) => {
+ if (err) throw err;
+ });
+ // rename main.native.js to main.js
+ fs.moveSync(
+ genConfig.dirPathPrefix + genConfig.nativeAppPathModifier + 'main.native' + genConfig.jsOrTs,
+ genConfig.dirPathPrefix + genConfig.nativeAppPathModifier + 'main' + genConfig.jsOrTs,
+ {
+ overwrite: true
+ }
+ );
+
+ nativeOnlyPackageJsonSetup(genConfig.dirPathPrefix + genConfig.nativeAppPathModifier + 'package.json');
+ }
+ } else if (!options.isNewProject) {
+ // copy type files from ./src to ./ns-example
+ if (api.hasPlugin('typescript')) {
+ fs.copy('./src/shims-tsx.d.ts', path.join(genConfig.dirPathPrefix, 'types/shims-tsx.d.ts'), (err) => {
+ if (err) throw err;
+ });
+
+ fs.copy('./src/shims-vue.d.ts', path.join(genConfig.dirPathPrefix, 'types/shims-vue.d.ts'), (err) => {
+ if (err) throw err;
+ });
+ }
+
+ if (options.isNativeOnly) {
+ // move store.js file from ./src to ./ns-example/app
+ if (api.hasPlugin('vuex')) {
+ fs.copy('./src/store' + genConfig.jsOrTs, genConfig.dirPathPrefix + genConfig.nativeAppPathModifier + 'store' + genConfig.jsOrTs, (err) => {
+ if (err) throw err;
+ });
+ }
+
+ // rename main.native.js to main.js
+ fs.moveSync(
+ genConfig.dirPathPrefix + genConfig.nativeAppPathModifier + 'main.native' + genConfig.jsOrTs,
+ genConfig.dirPathPrefix + genConfig.nativeAppPathModifier + 'main' + genConfig.jsOrTs,
+ {
+ overwrite: true
+ }
+ );
+
+ nativeOnlyPackageJsonSetup(genConfig.dirPathPrefix + genConfig.nativeAppPathModifier + 'package.json');
+ }
+ } else {
+ // nothing to do here
+ }
+ });
+};
+
+// setup vue-router options
+// will not setup any vue-router options for native app
+// for new projects it will write to changes as normal
+// and for existing projects it will write changes to the ./ns-example directory
+const vueRouterSetup = (module.exports.vueRouterSetup = async (api, filePathPrefix, jsOrTs) => {
+ try {
+ if (api.hasPlugin('vue-router')) {
+ api.injectImports(filePathPrefix.replace(/.\//, '') + 'src/main' + jsOrTs, `import router from './router';`);
+ api.injectRootOptions(filePathPrefix.replace(/.\//, '') + 'src/main' + jsOrTs, `router`);
+ }
+ } catch (err) {
+ throw err;
+ }
+});
+
+// setup Vuex options
+// for new projects it will write to changes as normal
+// and for existing projects it will write changes to the ./ns-example directory
+const vuexSetup = (module.exports.vuexSetup = async (api, options, filePathPrefix, jsOrTs, nativeAppPathModifier) => {
+ try {
+ if (api.hasPlugin('vuex')) {
+ if (!options.isNativeOnly) {
+ api.injectImports(filePathPrefix.replace(/.\//, '') + 'src/main' + jsOrTs, `import store from './store';`);
+ api.injectRootOptions(filePathPrefix.replace(/.\//, '') + 'src/main' + jsOrTs, `store`);
+
+ // if we're using Nativescript-Vue-Web, then we have to modify the main.native file
+ api.injectImports(filePathPrefix.replace(/.\//, '') + 'src/main.native' + jsOrTs, `import store from './store';`);
+ api.injectRootOptions(filePathPrefix.replace(/.\//, '') + 'src/main.native' + jsOrTs, `store`);
+ } else {
+ // if it's native only, it will not do anything in /src directory
+ api.injectImports(filePathPrefix.replace(/.\//, '') + nativeAppPathModifier + 'main' + jsOrTs, `import store from './store';`);
+ api.injectRootOptions(filePathPrefix.replace(/.\//, '') + nativeAppPathModifier + 'main' + jsOrTs, `store`);
+ }
+ }
+ } catch (err) {
+ throw err;
+ }
+});
+
+// write out babel.config.js options by adding options and replacing the base @vue/app
+// for new projects it will write to the root of the project
+// and for existing projects it will write it to the ./ns-example directory
+const applyBabelConfig = (module.exports.applyBabelConfig = async (api, filePath) => {
+ const babelReplaceOptions = {
+ files: '',
+ from: " '@vue/app'",
+ to: " process.env.VUE_PLATFORM === 'web' ? '@vue/app' : {}, " + newline + " ['@babel/env', { targets: { esmodules: true } }]"
+ };
+
+ try {
+ babelReplaceOptions.files = filePath;
+
+ api.render((files) => {
+ files[filePath] = api.genJSConfig({
+ plugins: ['@babel/plugin-syntax-dynamic-import'],
+ presets: ['@vue/app']
+ });
+ // eslint-disable-next-line no-unused-vars
+ replace(babelReplaceOptions, (err, changes) => {
+ if (err) throw err;
+ });
+ });
+ } catch (err) {
+ throw err;
+ }
+});
+
+// write out files in the root of the project
+// this includes the environment files as well as a global types file for
+// Typescript projects. for new projects it will write files to the root of the project
+// and for existing projects it will write it to the ./ns-example directory
+const writeRootFiles = (module.exports.writeRootFiles = async (api, options, filePathPrefix) => {
+ try {
+ const envDevelopmentAndroid = 'NODE_ENV=development' + newline + 'VUE_APP_PLATFORM=android' + newline + 'VUE_APP_MODE=native';
+ const envDevelopmentIOS = 'NODE_ENV=development' + newline + 'VUE_APP_PLATFORM=ios' + newline + 'VUE_APP_MODE=native';
+ const envProductionAndroid = 'NODE_ENV=production' + newline + 'VUE_APP_PLATFORM=android' + newline + 'VUE_APP_MODE=native';
+ const envProductionIOS = 'NODE_ENV=production' + newline + 'VUE_APP_PLATFORM=ios' + newline + 'VUE_APP_MODE=native';
+
+ fs.writeFileSync(
+ filePathPrefix + '.env.development.android',
+ envDevelopmentAndroid,
+ {
+ encoding: 'utf8'
+ },
+ (err) => {
+ if (err) throw err;
+ }
+ );
+ fs.writeFileSync(
+ filePathPrefix + '.env.development.ios',
+ envDevelopmentIOS,
+ {
+ encoding: 'utf8'
+ },
+ (err) => {
+ if (err) throw err;
+ }
+ );
+ fs.writeFileSync(
+ filePathPrefix + '.env.production.android',
+ envProductionAndroid,
+ {
+ encoding: 'utf8'
+ },
+ (err) => {
+ if (err) throw err;
+ }
+ );
+ fs.writeFileSync(
+ filePathPrefix + '.env.production.ios',
+ envProductionIOS,
+ {
+ encoding: 'utf8'
+ },
+ (err) => {
+ if (err) throw err;
+ }
+ );
+
+ // only write these out if we are also developing for the web
+ if (!options.isNativeOnly) {
+ console.log('dual components env files');
+ const envDevelopmentWeb = 'NODE_ENV=development' + newline + 'VUE_APP_PLATFORM=web' + newline + 'VUE_APP_MODE=web';
+ const envProductionWeb = 'NODE_ENV=production' + newline + 'VUE_APP_PLATFORM=web' + newline + 'VUE_APP_MODE=web';
+
+ fs.writeFileSync(
+ filePathPrefix + '.env.development.web',
+ envDevelopmentWeb,
+ {
+ encoding: 'utf8'
+ },
+ (err) => {
+ if (err) throw err;
+ }
+ );
+ fs.writeFileSync(
+ filePathPrefix + '.env.production.web',
+ envProductionWeb,
+ {
+ encoding: 'utf8'
+ },
+ (err) => {
+ if (err) throw err;
+ }
+ );
+ }
+
+ // only write this out if we are using typescript
+ if (api.hasPlugin('typescript')) {
+ // this file is ultimately optional if you don't use any process.env.VARIABLE_NAME references in your code
+ const globalTypes =
+ 'declare const TNS_ENV: string;' + newline + 'declare const TNS_APP_PLATFORM: string;' + newline + 'declare const TNS_APP_MODE: string;';
+ fs.outputFileSync(
+ filePathPrefix + 'types/globals.d.ts',
+ globalTypes,
+ {
+ encoding: 'utf8'
+ },
+ (err) => {
+ if (err) throw err;
+ }
+ );
+ }
+ } catch (err) {
+ throw err;
+ }
+});
+
+// write .gitignore additions for native app exemptions
+// will make changes to the root .gitignore file regardless of new or exisiting project
+const gitignoreAdditions = (module.exports.gitignoreAdditions = async (api) => {
+ try {
+ let gitignoreContent;
+ const gitignorePath = api.resolve('.gitignore');
+ const gitignoreAdditions = newline + '# NativeScript application' + newline + 'hooks' + newline + 'platforms' + newline + './webpack.config.js';
+
+ if (fs.existsSync(gitignorePath)) {
+ gitignoreContent = fs.readFileSync(gitignorePath, {
+ encoding: 'utf8'
+ });
+ } else {
+ gitignoreContent = '';
+ }
+
+ if (gitignoreContent.indexOf(gitignoreAdditions) === -1) {
+ gitignoreContent += gitignoreAdditions;
+
+ fs.writeFileSync(
+ gitignorePath,
+ gitignoreContent,
+ {
+ encoding: 'utf8'
+ },
+ (err) => {
+ if (err) throw err;
+ }
+ );
+ }
+ } catch (err) {
+ throw err;
+ }
+});
+
+// setup nsconfig.json file. for new projects it will write to the root of the project
+// and for existing projects it will write it to the ./ns-example directory
+const nsconfigSetup = (module.exports.nsconfigSetup = async (dirPathPrefix, nsconfigPath, nativeAppPathModifier, appResourcesPathModifier) => {
+ let nsconfigContent = '';
+
+ try {
+ if (fs.existsSync(nsconfigPath)) {
+ nsconfigContent = JSON.parse(
+ fs.readFileSync(nsconfigPath, {
+ encoding: 'utf8'
+ })
+ );
+ } else {
+ nsconfigContent = {};
+ }
+
+ nsconfigContent.appPath = nativeAppPathModifier.slice(0, -1);
+ nsconfigContent.appResourcesPath = appResourcesPathModifier;
+
+ fs.writeFileSync(
+ dirPathPrefix + 'nsconfig.json',
+ JSON.stringify(nsconfigContent, null, 2),
+ {
+ encoding: 'utf8'
+ },
+ (err) => {
+ if (err) console.error(err);
+ }
+ );
+ } catch (err) {
+ throw err;
+ }
+});
+
+// can be used to strip out template tags in native only project
+// currently unused in preference for EJS templating
+// eslint-disable-next-line no-unused-vars
+const stripTemplateTags = (module.exports.stripTemplateTags = async (srcPathPrefix) => {
+ try {
+ const files = await getAllFilesInDirStructure(srcPathPrefix, '');
+
+ for (const file of files) {
+ if (file.slice(-4) == '.vue') {
+ const options = {
+ files: path.join(srcPathPrefix, file),
+ from: [
+ new RegExp(`^(()[\\s\\S]*?(<\\/template>)`, `gim`),
+ new RegExp(`^(()`, `gim`)
+ ],
+ to: ['', '']
+ };
+
+ await replaceInFile(options);
+ }
+ }
+ } catch (err) {
+ throw err;
+ }
+});
+
+const nativeOnlyRenameFiles = (module.exports.nativeOnlyRenameFiles = async (srcPathPrefix) => {
+ try {
+ const _files = await getAllFilesInDirStructure(srcPathPrefix, '');
+ const files = new Array();
+ const match = '.native.vue';
+
+ for (const file of _files) {
+ if (file.slice(-11) == match) {
+ files.push(path.join(srcPathPrefix, file));
+ }
+ }
+
+ for (const file of files) {
+ const oldFile = file.replace(match, '.vue');
+ fs.moveSync(file, oldFile, { overwrite: true });
+ }
+ } catch (err) {
+ throw err;
+ }
+});
+
+// setup tslintSetup
+const nativeOnlyPackageJsonSetup = (module.exports.nativeOnlyPackageJsonSetup = async (filePath) => {
+ let fileContents = '';
+
+ try {
+ if (fs.existsSync(filePath)) {
+ fileContents = JSON.parse(
+ fs.readFileSync(filePath, {
+ encoding: 'utf8'
+ })
+ );
+ } else {
+ return;
+ }
+
+ fileContents.main = 'main';
+
+ fs.writeFileSync(
+ filePath,
+ JSON.stringify(fileContents, null, 2),
+ {
+ encoding: 'utf8'
+ },
+ (err) => {
+ if (err) console.error(err);
+ }
+ );
+ } catch (err) {
+ throw err;
+ }
+});
+
+// setup tslintSetup
+const tslintSetup = (module.exports.tslintSetup = async (dirPathPrefix, tslintPath, tsExclusionArray) => {
+ let tslintContent = '';
+
+ try {
+ if (fs.existsSync(tslintPath)) {
+ tslintContent = JSON.parse(
+ fs.readFileSync(tslintPath, {
+ encoding: 'utf8'
+ })
+ );
+ } else {
+ return;
+ }
+
+ // create arrays if they aren't already in tslint.json
+ if (tslintContent.linterOptions.exclude === undefined) tslintContent.linterOptions.exclude = new Array();
+ if (tslintContent.exclude === undefined) tslintContent.exclude = new Array();
+
+ // add items into exclude arrays, but only if they don't already exist
+ for (let item of tsExclusionArray) {
+ if (!tslintContent.linterOptions.exclude.includes(item + '/**')) tslintContent.linterOptions.exclude.push(item + '/**');
+
+ if (!tslintContent.exclude.includes(item)) tslintContent.exclude.push(item);
+ }
+
+ fs.writeFileSync(
+ dirPathPrefix + 'tslint.json',
+ JSON.stringify(tslintContent, null, 2),
+ {
+ encoding: 'utf8'
+ },
+ (err) => {
+ if (err) console.error(err);
+ }
+ );
+ } catch (err) {
+ throw err;
+ }
+});
+
+// setup tsconfig for native only projects
+const tsconfigSetup = (module.exports.tsconfigSetup = async (options, dirPathPrefix, nativeAppPathModifier) => {
+ try {
+ // setup the ability to edit the tsconfig.json file in the root of the project
+ let tsConfigContent = '';
+ let tsConfigPath = path.join(dirPathPrefix, 'tsconfig.json');
+
+ if (fs.existsSync(tsConfigPath)) {
+ tsConfigContent = fs.readJsonSync(tsConfigPath, {
+ encoding: 'utf8'
+ });
+ } else {
+ return;
+ }
+
+ tsConfigContent.compilerOptions.noImplicitAny = false;
+ // // // tsConfigContent.compilerOptions.types = [];
+
+ // edit types attribute to fix build
+ tsConfigContent.compilerOptions.types = ['node'];
+
+ // edit some of the options in compilerOptions.paths object array
+ tsConfigContent.compilerOptions.paths['@/*'] = [nativeAppPathModifier + '*'];
+ tsConfigContent.compilerOptions.paths['assets/*'] = [nativeAppPathModifier + 'assets/*'];
+ tsConfigContent.compilerOptions.paths['fonts/*'] = [nativeAppPathModifier + 'fonts/*'];
+ tsConfigContent.compilerOptions.paths['components/*'] = [nativeAppPathModifier + 'components/*'];
+ tsConfigContent.compilerOptions.paths['styles/*'] = [nativeAppPathModifier + 'styles/*'];
+
+ // add the types directory into the config
+ if (!tsConfigContent.include.includes('types/**/*.d.ts')) tsConfigContent.include.push('types/**/*.d.ts');
+
+ // add items into the include array
+ if (!tsConfigContent.include.includes(nativeAppPathModifier + '**/*.ts')) tsConfigContent.include.push(nativeAppPathModifier + '**/*.ts');
+ if (!tsConfigContent.include.includes(nativeAppPathModifier + '**/*.tsx')) tsConfigContent.include.push(nativeAppPathModifier + '**/*.tsx');
+ if (!tsConfigContent.include.includes(nativeAppPathModifier + '**/*.vue')) tsConfigContent.include.push(nativeAppPathModifier + '**/*.vue');
+
+ // add unit test directories into include array
+ if (fs.existsSync(path.join(dirPathPrefix, 'tests'))) {
+ if (!tsConfigContent.include.includes('tests/**/*.ts')) tsConfigContent.include.push('tests/**/*.ts');
+ if (!tsConfigContent.include.includes('tests/**/*.tsx')) tsConfigContent.include.push('tests/**/*.tsx');
+ }
+
+ if (options.isNativeOnly) {
+ // edit some of the options in compilerOptions.paths object array
+ tsConfigContent.compilerOptions.paths['src/*'] = [nativeAppPathModifier + '*'];
+
+ // remove some items from the include array
+ tsConfigContent.include = await removeFromArray(tsConfigContent.include, 'src/**/*.ts');
+ tsConfigContent.include = await removeFromArray(tsConfigContent.include, 'src/**/*.tsx');
+ tsConfigContent.include = await removeFromArray(tsConfigContent.include, 'src/**/*.vue');
+
+ fs.writeJsonSync(tsConfigPath, tsConfigContent, {
+ spaces: 2,
+ encoding: 'utf8'
+ });
+ } else {
+ tsConfigContent.compilerOptions.paths['src/*'] = [nativeAppPathModifier + '*'];
+
+ fs.writeJsonSync(tsConfigPath, tsConfigContent, {
+ spaces: 2,
+ encoding: 'utf8'
+ });
+ }
+ } catch (err) {
+ throw err;
+ }
+});
+
+// Use the generator's render function to render individual files passed in from an array.
+// Will iterate through the array and then construct and object that is passed to render()
+const renderFilesIndividually = (module.exports.renderFilesIndividually = async (
+ api,
+ options,
+ jsOrTs,
+ files,
+ commonRenderOptions,
+ srcPathPrefix,
+ destPathPrefix
+) => {
+ try {
+ const obj = {};
+
+ for (let file of files) {
+ let newFile = file;
+
+ // renames .js files to .ts
+ if (file.slice(-3) === '.js' || file.slice(-3) === '.ts') newFile = file.substring(0, file.length - 3) + jsOrTs;
+
+ if ((!api.hasPlugin('typescript') && file !== 'tsconfig.json') || api.hasPlugin('typescript'))
+ obj[path.join(destPathPrefix, newFile)] = path.join(srcPathPrefix, file);
+ }
+
+ api.render(obj, commonRenderOptions);
+ } catch (err) {
+ throw err;
+ }
+});
+
+// Good chunk of the following code comes from vue-cli/packages/@vue/cli/lib/GeneratorAPI.js
+// Specifically the render function. We want to render the entire directory, but passing just
+// the directory to render doesn't give us the ability to tell where to put it as the cli's render
+// function lacks a simple directory in and directory out option. So, we have to get the contents
+// of the passed in directory and then render each file individually to where we want it via
+// the render function's isObject(source) option that we use in our renderFilesIndividually function.
+
+// eslint-disable-next-line prettier/prettier
+// eslint-disable-next-line max-len
+const renderDirectoryStructure = (module.exports.renderDirectoryStructure = async (
+ api,
+ options,
+ rootOptions,
+ jsOrTs,
+ commonRenderOptions,
+ srcPathPrefix,
+ destPathPrefix
+) => {
+ try {
+ const files = new Array();
+ const baseDir = await extractCallDir();
+ const _files = await getAllFilesInDirStructure(srcPathPrefix, baseDir);
+
+ for (const rawPath of _files) {
+ // // // let filename = path.basename(rawPath);
+ // // // // dotfiles are ignored when published to npm, therefore in templates
+ // // // // we need to use underscore instead (e.g. "_gitignore")
+ // // // if (filename.charAt(0) === '_' && filename.charAt(1) !== '_') {
+ // // // filename = `.${filename.slice(1)}`;
+ // // // }
+ // // // if (filename.charAt(0) === '_' && filename.charAt(1) === '_') {
+ // // // filename = `${filename.slice(1)}`;
+ // // // }
+
+ // only import styles based on the type of preprocessor you do or do not have.
+ // Essentially acts as filter as you iterate through the list of files in a directory structure
+ if (
+ rawPath.slice(-4) == '.css' ||
+ rawPath.slice(-5) == '.scss' ||
+ rawPath.slice(-5) == '.sass' ||
+ rawPath.slice(-5) == '.less' ||
+ rawPath.slice(-5) == '.styl' ||
+ rawPath.slice(-7) == '.stylus'
+ ) {
+ if (rootOptions.cssPreprocessor) {
+ switch (rootOptions.cssPreprocessor) {
+ case 'scss':
+ if (rawPath.slice(-5) == '.scss' || rawPath.slice(-5) == '.sass') files.push(rawPath);
+ break;
+ case 'sass':
+ if (rawPath.slice(-5) == '.scss' || rawPath.slice(-5) == '.sass') files.push(rawPath);
+ break;
+ case 'less':
+ if (rawPath.slice(-5) == '.less') files.push(rawPath);
+ break;
+ case 'stylus':
+ if (rawPath.slice(-5) == '.styl' || rawPath.slice(-7) == '.stylus') files.push(rawPath);
+ break;
+ }
+ } else {
+ if (rawPath.slice(-4) == '.css') files.push(rawPath);
+ }
+ } else {
+ files.push(rawPath);
+ }
+ }
+ renderFilesIndividually(api, options, jsOrTs, files, commonRenderOptions, srcPathPrefix, destPathPrefix);
+ } catch (err) {
+ throw err;
+ }
+});
+
+// extract callsite file location using error stack
+const extractCallDir = (module.exports.extractCallDir = () => {
+ try {
+ const obj = {};
+ Error.captureStackTrace(obj);
+ return path.dirname(obj.stack.split('\n')[3].match(/\s\((.*):\d+:\d+\)$/)[1]);
+ } catch (err) {
+ throw err;
+ }
+});
+
+// utility function used to get all the files in a directory structure. is recursive in nature due to globby
+const getAllFilesInDirStructure = (module.exports.replaceInFile = async (srcPathPrefix, baseDir) => {
+ try {
+ const source = path.resolve(baseDir, srcPathPrefix);
+ const globby = require('globby');
+ const _files = await globby(['**/*'], {
+ cwd: source
+ });
+
+ return _files;
+ } catch (error) {
+ console.log(error);
+ }
+});
+
+// utility function used to remove sections of strings from files
+const replaceInFile = (module.exports.replaceInFile = async (options) => {
+ try {
+ await replace(options);
+ } catch (error) {
+ console.error('Error occurred:', error);
+ }
+});
+
+// utility function used to remove items from an array that match 'item'
+const removeFromArray = (module.exports.removeFromArray = async (array, item) => {
+ const index = array.indexOf(item);
+ if (index !== -1) array.splice(index, 1);
+ return array;
+});
diff --git a/generator/templates/simple/src/App_Resources/Android/AndroidManifest.xml b/generator/templates/App_Resources/Android/AndroidManifest.xml
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/AndroidManifest.xml
rename to generator/templates/App_Resources/Android/AndroidManifest.xml
diff --git a/generator/templates/simple/src/App_Resources/Android/app.gradle b/generator/templates/App_Resources/Android/app.gradle
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/app.gradle
rename to generator/templates/App_Resources/Android/app.gradle
diff --git a/generator/templates/simple/src/App_Resources/Android/drawable-hdpi/background.png b/generator/templates/App_Resources/Android/drawable-hdpi/background.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/drawable-hdpi/background.png
rename to generator/templates/App_Resources/Android/drawable-hdpi/background.png
diff --git a/generator/templates/simple/src/App_Resources/Android/drawable-hdpi/icon.png b/generator/templates/App_Resources/Android/drawable-hdpi/icon.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/drawable-hdpi/icon.png
rename to generator/templates/App_Resources/Android/drawable-hdpi/icon.png
diff --git a/generator/templates/simple/src/App_Resources/Android/drawable-hdpi/logo.png b/generator/templates/App_Resources/Android/drawable-hdpi/logo.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/drawable-hdpi/logo.png
rename to generator/templates/App_Resources/Android/drawable-hdpi/logo.png
diff --git a/generator/templates/simple/src/App_Resources/Android/drawable-ldpi/background.png b/generator/templates/App_Resources/Android/drawable-ldpi/background.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/drawable-ldpi/background.png
rename to generator/templates/App_Resources/Android/drawable-ldpi/background.png
diff --git a/generator/templates/simple/src/App_Resources/Android/drawable-ldpi/icon.png b/generator/templates/App_Resources/Android/drawable-ldpi/icon.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/drawable-ldpi/icon.png
rename to generator/templates/App_Resources/Android/drawable-ldpi/icon.png
diff --git a/generator/templates/simple/src/App_Resources/Android/drawable-ldpi/logo.png b/generator/templates/App_Resources/Android/drawable-ldpi/logo.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/drawable-ldpi/logo.png
rename to generator/templates/App_Resources/Android/drawable-ldpi/logo.png
diff --git a/generator/templates/simple/src/App_Resources/Android/drawable-mdpi/background.png b/generator/templates/App_Resources/Android/drawable-mdpi/background.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/drawable-mdpi/background.png
rename to generator/templates/App_Resources/Android/drawable-mdpi/background.png
diff --git a/generator/templates/simple/src/App_Resources/Android/drawable-mdpi/icon.png b/generator/templates/App_Resources/Android/drawable-mdpi/icon.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/drawable-mdpi/icon.png
rename to generator/templates/App_Resources/Android/drawable-mdpi/icon.png
diff --git a/generator/templates/simple/src/App_Resources/Android/drawable-mdpi/logo.png b/generator/templates/App_Resources/Android/drawable-mdpi/logo.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/drawable-mdpi/logo.png
rename to generator/templates/App_Resources/Android/drawable-mdpi/logo.png
diff --git a/generator/templates/simple/src/App_Resources/Android/drawable-nodpi/splash_screen.xml b/generator/templates/App_Resources/Android/drawable-nodpi/splash_screen.xml
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/drawable-nodpi/splash_screen.xml
rename to generator/templates/App_Resources/Android/drawable-nodpi/splash_screen.xml
diff --git a/generator/templates/simple/src/App_Resources/Android/drawable-xhdpi/background.png b/generator/templates/App_Resources/Android/drawable-xhdpi/background.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/drawable-xhdpi/background.png
rename to generator/templates/App_Resources/Android/drawable-xhdpi/background.png
diff --git a/generator/templates/simple/src/App_Resources/Android/drawable-xhdpi/icon.png b/generator/templates/App_Resources/Android/drawable-xhdpi/icon.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/drawable-xhdpi/icon.png
rename to generator/templates/App_Resources/Android/drawable-xhdpi/icon.png
diff --git a/generator/templates/simple/src/App_Resources/Android/drawable-xhdpi/logo.png b/generator/templates/App_Resources/Android/drawable-xhdpi/logo.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/drawable-xhdpi/logo.png
rename to generator/templates/App_Resources/Android/drawable-xhdpi/logo.png
diff --git a/generator/templates/simple/src/App_Resources/Android/drawable-xxhdpi/background.png b/generator/templates/App_Resources/Android/drawable-xxhdpi/background.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/drawable-xxhdpi/background.png
rename to generator/templates/App_Resources/Android/drawable-xxhdpi/background.png
diff --git a/generator/templates/simple/src/App_Resources/Android/drawable-xxhdpi/icon.png b/generator/templates/App_Resources/Android/drawable-xxhdpi/icon.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/drawable-xxhdpi/icon.png
rename to generator/templates/App_Resources/Android/drawable-xxhdpi/icon.png
diff --git a/generator/templates/simple/src/App_Resources/Android/drawable-xxhdpi/logo.png b/generator/templates/App_Resources/Android/drawable-xxhdpi/logo.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/drawable-xxhdpi/logo.png
rename to generator/templates/App_Resources/Android/drawable-xxhdpi/logo.png
diff --git a/generator/templates/simple/src/App_Resources/Android/drawable-xxxhdpi/background.png b/generator/templates/App_Resources/Android/drawable-xxxhdpi/background.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/drawable-xxxhdpi/background.png
rename to generator/templates/App_Resources/Android/drawable-xxxhdpi/background.png
diff --git a/generator/templates/simple/src/App_Resources/Android/drawable-xxxhdpi/icon.png b/generator/templates/App_Resources/Android/drawable-xxxhdpi/icon.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/drawable-xxxhdpi/icon.png
rename to generator/templates/App_Resources/Android/drawable-xxxhdpi/icon.png
diff --git a/generator/templates/simple/src/App_Resources/Android/drawable-xxxhdpi/logo.png b/generator/templates/App_Resources/Android/drawable-xxxhdpi/logo.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/drawable-xxxhdpi/logo.png
rename to generator/templates/App_Resources/Android/drawable-xxxhdpi/logo.png
diff --git a/generator/templates/simple/src/App_Resources/Android/values-v21/colors.xml b/generator/templates/App_Resources/Android/values-v21/colors.xml
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/values-v21/colors.xml
rename to generator/templates/App_Resources/Android/values-v21/colors.xml
diff --git a/generator/templates/simple/src/App_Resources/Android/values-v21/strings.xml b/generator/templates/App_Resources/Android/values-v21/strings.xml
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/values-v21/strings.xml
rename to generator/templates/App_Resources/Android/values-v21/strings.xml
diff --git a/generator/templates/simple/src/App_Resources/Android/values-v21/styles.xml b/generator/templates/App_Resources/Android/values-v21/styles.xml
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/values-v21/styles.xml
rename to generator/templates/App_Resources/Android/values-v21/styles.xml
diff --git a/generator/templates/simple/src/App_Resources/Android/values/colors.xml b/generator/templates/App_Resources/Android/values/colors.xml
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/values/colors.xml
rename to generator/templates/App_Resources/Android/values/colors.xml
diff --git a/generator/templates/simple/src/App_Resources/Android/values/strings.xml b/generator/templates/App_Resources/Android/values/strings.xml
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/values/strings.xml
rename to generator/templates/App_Resources/Android/values/strings.xml
diff --git a/generator/templates/simple/src/App_Resources/Android/values/styles.xml b/generator/templates/App_Resources/Android/values/styles.xml
similarity index 100%
rename from generator/templates/simple/src/App_Resources/Android/values/styles.xml
rename to generator/templates/App_Resources/Android/values/styles.xml
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json b/generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json
rename to generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/Contents.json
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-1024.png b/generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-1024.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-1024.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-1024.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png b/generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png b/generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@2x.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png b/generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-29@3x.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png b/generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png b/generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@2x.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png b/generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-40@3x.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png b/generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@2x.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png b/generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-60@3x.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png b/generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png b/generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-76@2x.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png b/generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/AppIcon.appiconset/icon-83.5@2x.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/Contents.json b/generator/templates/App_Resources/iOS/Assets.xcassets/Contents.json
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/Contents.json
rename to generator/templates/App_Resources/iOS/Assets.xcassets/Contents.json
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json b/generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json
rename to generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Contents.json
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-1125h.png b/generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-1125h.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-1125h.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-1125h.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png b/generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-568h@2x.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png b/generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-667h@2x.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png b/generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-736h@3x.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape-X.png b/generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape-X.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape-X.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape-X.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png b/generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png b/generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@2x.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png b/generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Landscape@3x.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png b/generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png b/generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default-Portrait@2x.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png b/generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png b/generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/LaunchImage.launchimage/Default@2x.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json b/generator/templates/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json
rename to generator/templates/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/Contents.json
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png b/generator/templates/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png b/generator/templates/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/LaunchScreen.AspectFill.imageset/LaunchScreen-AspectFill@2x.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json b/generator/templates/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json
rename to generator/templates/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/Contents.json
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png b/generator/templates/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png b/generator/templates/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png
rename to generator/templates/App_Resources/iOS/Assets.xcassets/LaunchScreen.Center.imageset/LaunchScreen-Center@2x.png
diff --git a/generator/templates/simple/src/App_Resources/iOS/Info.plist b/generator/templates/App_Resources/iOS/Info.plist
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/Info.plist
rename to generator/templates/App_Resources/iOS/Info.plist
diff --git a/generator/templates/simple/src/App_Resources/iOS/LaunchScreen.storyboard b/generator/templates/App_Resources/iOS/LaunchScreen.storyboard
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/LaunchScreen.storyboard
rename to generator/templates/App_Resources/iOS/LaunchScreen.storyboard
diff --git a/generator/templates/simple/src/App_Resources/iOS/build.xcconfig b/generator/templates/App_Resources/iOS/build.xcconfig
similarity index 100%
rename from generator/templates/simple/src/App_Resources/iOS/build.xcconfig
rename to generator/templates/App_Resources/iOS/build.xcconfig
diff --git a/generator/templates/nvw/src/App.vue b/generator/templates/nvw/src/App.vue
new file mode 100644
index 0000000..2243004
--- /dev/null
+++ b/generator/templates/nvw/src/App.vue
@@ -0,0 +1,215 @@
+<%_ if (rootOptions.router) { _%>
+<%# -------------------- IS Using vue-router -------------------- -%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<%_ } else { _%>
+<%# -------------------- IS NOT Using vue-router -------------------- -%>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<%_ } _%>
+<%_ if (!usingTS && rootOptions.router) { _%>
+<%# -------------------- IS NOT Using TypeScript AND IS Using vue-router -------------------- -%>
+
+<%_ } else if (!usingTS && !rootOptions.router) { _%>
+<%# -------------------- IS NOT Using TypeScript AND IS NOT Using vue-router -------------------- -%>
+
+<%_ } else if (usingTS && rootOptions.router) { _%>
+<%# -------------------- IS Using TypeScript AND IS Using vue-router -------------------- -%>
+
+<%_ } else if (usingTS && !rootOptions.router) { _%>
+<%# -------------------- IS Using TypeScript AND IS NOT Using vue-router -------------------- -%>
+
+<%_ } else { _%>
+<%# -------------------- don't do anything -------------------- -%>
+<%_ } _%>
+
+<%_ if (rootOptions.cssPreprocessor) { _%>
+<%_ if (rootOptions.cssPreprocessor == 'sass' || rootOptions.cssPreprocessor == 'scss') { _%>
+<%# -------------------- IS Using scss OR sass -------------------- -%>
+<%- rootOptions.cssPreprocessor
+ ? `
+<%- rootOptions.cssPreprocessor
+ ? `
+<%_ } else if (rootOptions.cssPreprocessor == 'stylus') { _%>
+<%# -------------------- IS Using stylus -------------------- -%>
+
+
+<%_ } else if (rootOptions.cssPreprocessor == 'less') { _%>
+<%# -------------------- IS Using Less -------------------- -%>
+
+
+<%_ } _%>
+<%_ } else { _%>
+<%# -------------------- IS Using standard CSS -------------------- -%>
+
+
+<%_ } _%>
\ No newline at end of file
diff --git a/generator/templates/nvw/src/assets/logo.png b/generator/templates/nvw/src/assets/logo.png
new file mode 100644
index 0000000..2ad8ed2
Binary files /dev/null and b/generator/templates/nvw/src/assets/logo.png differ
diff --git a/generator/templates/nvw/src/components/HelloWorld.android.vue b/generator/templates/nvw/src/components/HelloWorld.android.vue
new file mode 100644
index 0000000..9b87087
--- /dev/null
+++ b/generator/templates/nvw/src/components/HelloWorld.android.vue
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+<%_ if (!usingTS) { _%>
+<%# -------------------- Is Not Using TypeScript -------------------- -%>
+
+<%_ } else { _%>
+<%# -------------------- Is Using TypeScript -------------------- -%>
+
+<%_ } _%>
+
+<%_ if (rootOptions.cssPreprocessor) { _%>
+<%_ if (rootOptions.cssPreprocessor == 'sass' || rootOptions.cssPreprocessor == 'scss') { _%>
+<%# -------------------- IS Using scss OR sass -------------------- -%>
+<%- rootOptions.cssPreprocessor
+ ? `
+<%_ } else if (rootOptions.cssPreprocessor == 'stylus') { _%>
+<%# -------------------- IS Using stylus -------------------- -%>
+
+<%_ } else if (rootOptions.cssPreprocessor == 'less') { _%>
+<%# -------------------- IS Using Less -------------------- -%>
+
+<%_ } _%>
+<%_ } else { _%>
+<%# -------------------- IS Using standard CSS -------------------- -%>
+
+<%_ } _%>
\ No newline at end of file
diff --git a/generator/templates/nvw/src/components/HelloWorld.ios.vue b/generator/templates/nvw/src/components/HelloWorld.ios.vue
new file mode 100644
index 0000000..9b87087
--- /dev/null
+++ b/generator/templates/nvw/src/components/HelloWorld.ios.vue
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+<%_ if (!usingTS) { _%>
+<%# -------------------- Is Not Using TypeScript -------------------- -%>
+
+<%_ } else { _%>
+<%# -------------------- Is Using TypeScript -------------------- -%>
+
+<%_ } _%>
+
+<%_ if (rootOptions.cssPreprocessor) { _%>
+<%_ if (rootOptions.cssPreprocessor == 'sass' || rootOptions.cssPreprocessor == 'scss') { _%>
+<%# -------------------- IS Using scss OR sass -------------------- -%>
+<%- rootOptions.cssPreprocessor
+ ? `
+<%_ } else if (rootOptions.cssPreprocessor == 'stylus') { _%>
+<%# -------------------- IS Using stylus -------------------- -%>
+
+<%_ } else if (rootOptions.cssPreprocessor == 'less') { _%>
+<%# -------------------- IS Using Less -------------------- -%>
+
+<%_ } _%>
+<%_ } else { _%>
+<%# -------------------- IS Using standard CSS -------------------- -%>
+
+<%_ } _%>
\ No newline at end of file
diff --git a/generator/templates/nvw/src/components/HelloWorld.native.vue b/generator/templates/nvw/src/components/HelloWorld.native.vue
new file mode 100644
index 0000000..9b87087
--- /dev/null
+++ b/generator/templates/nvw/src/components/HelloWorld.native.vue
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+<%_ if (!usingTS) { _%>
+<%# -------------------- Is Not Using TypeScript -------------------- -%>
+
+<%_ } else { _%>
+<%# -------------------- Is Using TypeScript -------------------- -%>
+
+<%_ } _%>
+
+<%_ if (rootOptions.cssPreprocessor) { _%>
+<%_ if (rootOptions.cssPreprocessor == 'sass' || rootOptions.cssPreprocessor == 'scss') { _%>
+<%# -------------------- IS Using scss OR sass -------------------- -%>
+<%- rootOptions.cssPreprocessor
+ ? `
+<%_ } else if (rootOptions.cssPreprocessor == 'stylus') { _%>
+<%# -------------------- IS Using stylus -------------------- -%>
+
+<%_ } else if (rootOptions.cssPreprocessor == 'less') { _%>
+<%# -------------------- IS Using Less -------------------- -%>
+
+<%_ } _%>
+<%_ } else { _%>
+<%# -------------------- IS Using standard CSS -------------------- -%>
+
+<%_ } _%>
\ No newline at end of file
diff --git a/generator/templates/nvw/src/components/HelloWorld.vue b/generator/templates/nvw/src/components/HelloWorld.vue
new file mode 100644
index 0000000..cfee3f2
--- /dev/null
+++ b/generator/templates/nvw/src/components/HelloWorld.vue
@@ -0,0 +1,110 @@
+
+
+
+
+
+
+
+<%_ if (!usingTS) { _%>
+<%# -------------------- Is Not Using TypeScript -------------------- -%>
+
+<%_ } else { _%>
+<%# -------------------- Is Using TypeScript -------------------- -%>
+
+<%_ } _%>
+
+<%_ if (rootOptions.cssPreprocessor) { _%>
+<%_ if (rootOptions.cssPreprocessor == 'sass' || rootOptions.cssPreprocessor == 'scss') { _%>
+<%# -------------------- IS Using scss OR sass -------------------- -%>
+<%- rootOptions.cssPreprocessor
+ ? `
+<%_ } else if (rootOptions.cssPreprocessor == 'stylus') { _%>
+<%# -------------------- IS Using stylus -------------------- -%>
+
+<%_ } else if (rootOptions.cssPreprocessor == 'less') { _%>
+<%# -------------------- IS Using Less -------------------- -%>
+
+<%_ } _%>
+<%_ } else { _%>
+<%# -------------------- IS Using standard CSS -------------------- -%>
+
+<%_ } _%>
\ No newline at end of file
diff --git a/generator/templates/nvw/src/components/icon.png b/generator/templates/nvw/src/components/icon.png
new file mode 100644
index 0000000..117b444
Binary files /dev/null and b/generator/templates/nvw/src/components/icon.png differ
diff --git a/generator/templates/nvw/src/main.js b/generator/templates/nvw/src/main.js
new file mode 100644
index 0000000..5857247
--- /dev/null
+++ b/generator/templates/nvw/src/main.js
@@ -0,0 +1,38 @@
+---
+extend: '@vue/cli-service/generator/template/src/main.js'
+replace:
+ - !!js/regexp /import Vue from 'vue'/
+ - !!js/regexp /import App from './App.vue'/
+ - !!js/regexp /Vue.config.productionTip = false/
+ - !!js/regexp /h => h\(App\),/
+ - !!js/regexp /}\)\.\$mount\('#app'\)/
+---
+
+<%# REPLACE %>
+import Vue from 'vue';
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+import App from '~/App.vue';
+import { Page, ActionBar, GridLayout, Button, Img, Label } from 'nativescript-vue-web';
+
+Vue.component('Page', Page);
+Vue.component('ActionBar', ActionBar);
+Vue.component('GridLayout', GridLayout);
+Vue.component('Button', Button);
+Vue.component('Img', Img);
+Vue.component('Label', Label);
+
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+Vue.config.productionTip = false;
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+(h) => h(App),
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+}).$mount('#app');
+<%# END_REPLACE %>
\ No newline at end of file
diff --git a/generator/templates/nvw/src/main.native.js b/generator/templates/nvw/src/main.native.js
new file mode 100644
index 0000000..c7d645a
--- /dev/null
+++ b/generator/templates/nvw/src/main.native.js
@@ -0,0 +1,28 @@
+---
+extend: '@vue/cli-service/generator/template/src/main.js'
+replace:
+ - !!js/regexp /import Vue from 'vue'/
+ - !!js/regexp /Vue.config.productionTip = false/
+ - !!js/regexp /h => h\(App\),/
+ - !!js/regexp /}\)\.\$mount\('#app'\)/
+---
+
+<%# REPLACE %>
+import Vue from 'nativescript-vue';
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+// Set the following to `true` to hide the logs created by nativescript-vue
+Vue.config.silent = false;
+// Set the following to `false` to not colorize the logs created by nativescript-vue
+// disabled in template due to typing issue for Typescript projects....NEEDS TO BE FIXED
+// Vue.config.debug = true;
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+(h) => h('frame', [h(App)]),
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+}).$start();
+<%# END_REPLACE %>
\ No newline at end of file
diff --git a/generator/templates/nvw/src/package.json b/generator/templates/nvw/src/package.json
new file mode 100644
index 0000000..41f6a95
--- /dev/null
+++ b/generator/templates/nvw/src/package.json
@@ -0,0 +1,9 @@
+{
+ "android": {
+ "v8Flags": "--expose_gc",
+ "markingMode": "none"
+ },
+ "main": "main.native",
+ "name": "<%- applicationName %>",
+ "version": "<%- applicationVersion %>"
+}
diff --git a/generator/templates/nvw/src/router.js b/generator/templates/nvw/src/router.js
new file mode 100644
index 0000000..6830956
--- /dev/null
+++ b/generator/templates/nvw/src/router.js
@@ -0,0 +1,34 @@
+---
+extend: '@vue/cli-service/generator/router/template/src/router.js'
+replace:
+ - !!js/regexp /import Vue from 'vue'/
+ - !!js/regexp /import Router from 'vue-router'/
+ - !!js/regexp /Vue.use\(Router\)/
+ - !!js/regexp /import Home from './views/Home.vue'/
+ - !!js/regexp /'./views/About.vue'\)/
+ - !!js/regexp /\}\)/
+---
+
+<%# REPLACE %>
+import Vue from 'vue';
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+import Router from 'vue-router';
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+Vue.use(Router);
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+import Home from '~/views/Home.vue';
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+'~/views/About.vue'),
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+});
+<%# END_REPLACE %>
\ No newline at end of file
diff --git a/generator/templates/nvw/src/styles/style-one.css b/generator/templates/nvw/src/styles/style-one.css
new file mode 100644
index 0000000..aede169
--- /dev/null
+++ b/generator/templates/nvw/src/styles/style-one.css
@@ -0,0 +1,53 @@
+ActionBar {
+ color: #42b983;
+}
+
+.w-navbar {
+ color: #42b983;
+ position: fixed;
+ z-index: 10000;
+ height: 3em;
+ width: 100%;
+ top: 0px;
+ left: 0px;
+ margin: auto;
+ list-style: none;
+
+ display: flex;
+ align-items: center;
+ padding: 0 10px;
+
+ -webkit-box-shadow: -8px 8px 6px -7px #999;
+ -moz-box-shadow: -8px 8px 6px -7px #999;
+ box-shadow: -8px 8px 6px -7px #999;
+}
+
+.w-navbar .w-title {
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.w-container {
+ height: 100%;
+ width: 100%;
+ padding-top: 3em;
+ position: relative;
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+ justify-content: top;
+ align-items: center;
+}
+
+.w-container .w-button {
+ width: 50%;
+ height: 2em;
+ margin: .25em;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ background-color: #d7d7d7;
+ border-width: 0px;
+ font-weight: 600;
+ border-radius: 3px;
+}
\ No newline at end of file
diff --git a/generator/templates/nvw/src/styles/style-one.less b/generator/templates/nvw/src/styles/style-one.less
new file mode 100644
index 0000000..aede169
--- /dev/null
+++ b/generator/templates/nvw/src/styles/style-one.less
@@ -0,0 +1,53 @@
+ActionBar {
+ color: #42b983;
+}
+
+.w-navbar {
+ color: #42b983;
+ position: fixed;
+ z-index: 10000;
+ height: 3em;
+ width: 100%;
+ top: 0px;
+ left: 0px;
+ margin: auto;
+ list-style: none;
+
+ display: flex;
+ align-items: center;
+ padding: 0 10px;
+
+ -webkit-box-shadow: -8px 8px 6px -7px #999;
+ -moz-box-shadow: -8px 8px 6px -7px #999;
+ box-shadow: -8px 8px 6px -7px #999;
+}
+
+.w-navbar .w-title {
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.w-container {
+ height: 100%;
+ width: 100%;
+ padding-top: 3em;
+ position: relative;
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+ justify-content: top;
+ align-items: center;
+}
+
+.w-container .w-button {
+ width: 50%;
+ height: 2em;
+ margin: .25em;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ background-color: #d7d7d7;
+ border-width: 0px;
+ font-weight: 600;
+ border-radius: 3px;
+}
\ No newline at end of file
diff --git a/generator/templates/nvw/src/styles/style-one.scss b/generator/templates/nvw/src/styles/style-one.scss
new file mode 100644
index 0000000..a3453ff
--- /dev/null
+++ b/generator/templates/nvw/src/styles/style-one.scss
@@ -0,0 +1,55 @@
+ActionBar {
+ color: #42b983;
+}
+
+.w-navbar {
+ color: #42b983;
+ position: fixed;
+ z-index: 10000;
+ height: 3em;
+ width: 100%;
+ top: 0px;
+ left: 0px;
+ margin: auto;
+ list-style: none;
+
+ display: flex;
+ align-items: center;
+ padding: 0 10px;
+
+ -webkit-box-shadow: -8px 8px 6px -7px #999;
+ -moz-box-shadow: -8px 8px 6px -7px #999;
+ box-shadow: -8px 8px 6px -7px #999;
+
+ .w-title {
+ margin-left: auto;
+ margin-right: auto;
+ }
+}
+
+.w-container {
+ height: 100%;
+ width: 100%;
+ padding-top: 3em;
+ position: relative;
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+ justify-content: top;
+ align-items: center;
+
+
+ .w-button {
+ width: 50%;
+ height: 2em;
+ margin: .25em;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ background-color: #d7d7d7;
+ border-width: 0px;
+ font-weight: 600;
+ border-radius: 3px;
+ }
+
+}
\ No newline at end of file
diff --git a/generator/templates/nvw/src/styles/style-one.styl b/generator/templates/nvw/src/styles/style-one.styl
new file mode 100644
index 0000000..72959e9
--- /dev/null
+++ b/generator/templates/nvw/src/styles/style-one.styl
@@ -0,0 +1,46 @@
+ActionBar
+ color #42b983
+
+.w-navbar
+ color #42b983
+ position fixed
+ z-index 10000
+ height 3em
+ width 100%
+ top 0px
+ left 0px
+ margin auto
+ list-style none
+ display flex
+ align-items center
+ padding 0 10px
+ -webkit-box-shadow -8px 8px 6px -7px #999
+ -moz-box-shadow -8px 8px 6px -7px #999
+ box-shadow -8px 8px 6px -7px #999
+
+ .w-title
+ margin-left auto
+ margin-right auto
+
+.w-container
+ height 100%
+ width 100%
+ padding-top 3em
+ position relative
+ overflow hidden
+ display flex
+ flex-direction column
+ justify-content top
+ align-items center
+
+ .w-button
+ width 50%
+ height 2em
+ margin 0.25em
+ display flex
+ justify-content center
+ align-items center
+ background-color #d7d7d7
+ border-width 0px
+ font-weight 600
+ border-radius 3px
\ No newline at end of file
diff --git a/generator/templates/nvw/src/styles/style-two.css b/generator/templates/nvw/src/styles/style-two.css
new file mode 100644
index 0000000..3ee2f55
--- /dev/null
+++ b/generator/templates/nvw/src/styles/style-two.css
@@ -0,0 +1,7 @@
+ActionBar {
+ color: #000000;
+}
+
+.w-navbar {
+ color: #000000;
+}
\ No newline at end of file
diff --git a/generator/templates/nvw/src/styles/style-two.less b/generator/templates/nvw/src/styles/style-two.less
new file mode 100644
index 0000000..3ee2f55
--- /dev/null
+++ b/generator/templates/nvw/src/styles/style-two.less
@@ -0,0 +1,7 @@
+ActionBar {
+ color: #000000;
+}
+
+.w-navbar {
+ color: #000000;
+}
\ No newline at end of file
diff --git a/generator/templates/nvw/src/styles/style-two.scss b/generator/templates/nvw/src/styles/style-two.scss
new file mode 100644
index 0000000..9abd667
--- /dev/null
+++ b/generator/templates/nvw/src/styles/style-two.scss
@@ -0,0 +1,7 @@
+ActionBar {
+ color: #000000;
+}
+
+.w-navbar {
+ color: #000000;
+}
\ No newline at end of file
diff --git a/generator/templates/nvw/src/styles/style-two.styl b/generator/templates/nvw/src/styles/style-two.styl
new file mode 100644
index 0000000..a771955
--- /dev/null
+++ b/generator/templates/nvw/src/styles/style-two.styl
@@ -0,0 +1,5 @@
+ActionBar
+ color #000000
+
+.w-navbar
+ color #000000
\ No newline at end of file
diff --git a/generator/templates/nvw/src/views/About.vue b/generator/templates/nvw/src/views/About.vue
new file mode 100644
index 0000000..9eee8a9
--- /dev/null
+++ b/generator/templates/nvw/src/views/About.vue
@@ -0,0 +1,127 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<%_ if (!usingTS) { _%>
+<%# -------------------- Is Not Using TypeScript -------------------- -%>
+
+<%_ } else { _%>
+<%# -------------------- Is Using TypeScript -------------------- -%>
+
+<%_ } _%>
+
+<%_ if (rootOptions.cssPreprocessor) { _%>
+<%_ if (rootOptions.cssPreprocessor == 'sass' || rootOptions.cssPreprocessor == 'scss') { _%>
+<%# -------------------- IS Using scss OR sass -------------------- -%>
+<%- rootOptions.cssPreprocessor
+ ? `
+<%_ } else if (rootOptions.cssPreprocessor == 'stylus') { _%>
+<%# -------------------- IS Using stylus -------------------- -%>
+
+<%_ } else if (rootOptions.cssPreprocessor == 'less') { _%>
+<%# -------------------- IS Using Less -------------------- -%>
+
+<%_ } _%>
+<%_ } else { _%>
+<%# -------------------- IS Using standard CSS -------------------- -%>
+
+<%_ } _%>
+
+
+
diff --git a/generator/templates/nvw/src/views/Home.vue b/generator/templates/nvw/src/views/Home.vue
new file mode 100644
index 0000000..3738db4
--- /dev/null
+++ b/generator/templates/nvw/src/views/Home.vue
@@ -0,0 +1,140 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+<%_ if (!usingTS) { _%>
+<%# -------------------- Is Not Using TypeScript -------------------- -%>
+
+<%_ } else { _%>
+<%# -------------------- Is Using TypeScript -------------------- -%>
+
+<%_ } _%>
+
+<%_ if (rootOptions.cssPreprocessor) { _%>
+<%_ if (rootOptions.cssPreprocessor == 'sass' || rootOptions.cssPreprocessor == 'scss') { _%>
+<%# -------------------- IS Using scss OR sass -------------------- -%>
+<%- rootOptions.cssPreprocessor
+ ? `
+<%_ } else if (rootOptions.cssPreprocessor == 'stylus') { _%>
+<%# -------------------- IS Using stylus -------------------- -%>
+
+<%_ } else if (rootOptions.cssPreprocessor == 'less') { _%>
+<%# -------------------- IS Using Less -------------------- -%>
+
+<%_ } _%>
+<%_ } else { _%>
+<%# -------------------- IS Using standard CSS -------------------- -%>
+
+<%_ } _%>
diff --git a/generator/templates/simple/src/App.vue b/generator/templates/simple/src/App.vue
index bb33d20..d53edc5 100644
--- a/generator/templates/simple/src/App.vue
+++ b/generator/templates/simple/src/App.vue
@@ -1,55 +1,212 @@
-<%_ if (!rootOptions.router) { _%>
+<%_ if (rootOptions.router) { _%>
+<%# -------------------- IS Using vue-router -------------------- -%>
+<%_ if (!options.isNativeOnly) { _%>
+
+
+
+
+ Home
+
+
+
+
+
+
+
+<%_ } else { _%>
+<%_ } _%>
-
+
-
-
+
+
-
-
<%_ } else { _%>
+<%# -------------------- IS NOT Using vue-router -------------------- -%>
+<%_ if (!options.isNativeOnly) { _%>
+
+
+
+
+
+
+
+
+
+<%_ } else { _%>
+<%_ } _%>
-
-
-
-
-
-
+
+
+
<%_ } _%>
+<%_ if (!usingTS) { _%>
+<%# -------------------- IS NOT Using TypeScript -------------------- -%>
+
+<%_ } else { _%>
+<%# -------------------- IS Using TypeScript -------------------- -%>
+
+<%_ } _%>
+
+
+<%_ if (rootOptions.cssPreprocessor) { _%>
+<%_ if (rootOptions.cssPreprocessor == 'sass' || rootOptions.cssPreprocessor == 'scss') { _%>
+<%# -------------------- IS Using scss OR sass -------------------- -%>
+<%- rootOptions.cssPreprocessor
+ ? `
+<%- rootOptions.cssPreprocessor
+ ? `
+<%_ } else if (rootOptions.cssPreprocessor == 'stylus') { _%>
+<%# -------------------- IS Using stylus -------------------- -%>
+
+
+<%_ } else if (rootOptions.cssPreprocessor == 'less') { _%>
+<%# -------------------- IS Using Less -------------------- -%>
+
+
+<%_ } _%>
<%_ } else { _%>
-
-<%_ } _%>
+
+<%_ } _%>
\ No newline at end of file
diff --git a/generator/templates/simple/src/components/HelloWorld.android.vue b/generator/templates/simple/src/components/HelloWorld.android.vue
new file mode 100644
index 0000000..99d38c3
--- /dev/null
+++ b/generator/templates/simple/src/components/HelloWorld.android.vue
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+<%_ if (!usingTS) { _%>
+<%# -------------------- Is Not Using TypeScript -------------------- -%>
+
+<%_ } else { _%>
+<%# -------------------- Is Using TypeScript -------------------- -%>
+
+<%_ } _%>
+
+<%_ if (rootOptions.cssPreprocessor) { _%>
+<%_ if (rootOptions.cssPreprocessor == 'sass' || rootOptions.cssPreprocessor == 'scss') { _%>
+<%# -------------------- IS Using scss OR sass -------------------- -%>
+<%- rootOptions.cssPreprocessor
+ ? `
+<%_ } else if (rootOptions.cssPreprocessor == 'stylus') { _%>
+<%# -------------------- IS Using stylus -------------------- -%>
+
+<%_ } else if (rootOptions.cssPreprocessor == 'less') { _%>
+<%# -------------------- IS Using Less -------------------- -%>
+
+<%_ } _%>
+<%_ } else { _%>
+<%# -------------------- IS Using standard CSS -------------------- -%>
+
+<%_ } _%>
\ No newline at end of file
diff --git a/generator/templates/simple/src/components/HelloWorld.ios.vue b/generator/templates/simple/src/components/HelloWorld.ios.vue
new file mode 100644
index 0000000..99d38c3
--- /dev/null
+++ b/generator/templates/simple/src/components/HelloWorld.ios.vue
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+<%_ if (!usingTS) { _%>
+<%# -------------------- Is Not Using TypeScript -------------------- -%>
+
+<%_ } else { _%>
+<%# -------------------- Is Using TypeScript -------------------- -%>
+
+<%_ } _%>
+
+<%_ if (rootOptions.cssPreprocessor) { _%>
+<%_ if (rootOptions.cssPreprocessor == 'sass' || rootOptions.cssPreprocessor == 'scss') { _%>
+<%# -------------------- IS Using scss OR sass -------------------- -%>
+<%- rootOptions.cssPreprocessor
+ ? `
+<%_ } else if (rootOptions.cssPreprocessor == 'stylus') { _%>
+<%# -------------------- IS Using stylus -------------------- -%>
+
+<%_ } else if (rootOptions.cssPreprocessor == 'less') { _%>
+<%# -------------------- IS Using Less -------------------- -%>
+
+<%_ } _%>
+<%_ } else { _%>
+<%# -------------------- IS Using standard CSS -------------------- -%>
+
+<%_ } _%>
\ No newline at end of file
diff --git a/generator/templates/simple/src/components/HelloWorld.native.vue b/generator/templates/simple/src/components/HelloWorld.native.vue
new file mode 100644
index 0000000..99d38c3
--- /dev/null
+++ b/generator/templates/simple/src/components/HelloWorld.native.vue
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+
+<%_ if (!usingTS) { _%>
+<%# -------------------- Is Not Using TypeScript -------------------- -%>
+
+<%_ } else { _%>
+<%# -------------------- Is Using TypeScript -------------------- -%>
+
+<%_ } _%>
+
+<%_ if (rootOptions.cssPreprocessor) { _%>
+<%_ if (rootOptions.cssPreprocessor == 'sass' || rootOptions.cssPreprocessor == 'scss') { _%>
+<%# -------------------- IS Using scss OR sass -------------------- -%>
+<%- rootOptions.cssPreprocessor
+ ? `
+<%_ } else if (rootOptions.cssPreprocessor == 'stylus') { _%>
+<%# -------------------- IS Using stylus -------------------- -%>
+
+<%_ } else if (rootOptions.cssPreprocessor == 'less') { _%>
+<%# -------------------- IS Using Less -------------------- -%>
+
+<%_ } _%>
+<%_ } else { _%>
+<%# -------------------- IS Using standard CSS -------------------- -%>
+
+<%_ } _%>
\ No newline at end of file
diff --git a/generator/templates/simple/src/components/HelloWorld.vue b/generator/templates/simple/src/components/HelloWorld.vue
index f4f8b75..1ff4400 100644
--- a/generator/templates/simple/src/components/HelloWorld.vue
+++ b/generator/templates/simple/src/components/HelloWorld.vue
@@ -1,36 +1,107 @@
-
-
-
+
+
{{msg}}
+
+
-
+<%_ if (!usingTS) { _%>
+<%# -------------------- Is Not Using TypeScript -------------------- -%>
+<%_ } else { _%>
+<%# -------------------- Is Using TypeScript -------------------- -%>
+
+<%_ } _%>
-<%_ if (rootOptions.cssPreprocessor !== 'stylus') { _%>
-
-<%_ } else { _%>
+<%_ } else if (rootOptions.cssPreprocessor == 'stylus') { _%>
+<%# -------------------- IS Using stylus -------------------- -%>
+<%_ } else if (rootOptions.cssPreprocessor == 'less') { _%>
+<%# -------------------- IS Using Less -------------------- -%>
+
+<%_ } _%>
+<%_ } else { _%>
+<%# -------------------- IS Using standard CSS -------------------- -%>
+
<%_ } _%>
\ No newline at end of file
diff --git a/generator/templates/simple/src/components/icon.png b/generator/templates/simple/src/components/icon.png
new file mode 100644
index 0000000..117b444
Binary files /dev/null and b/generator/templates/simple/src/components/icon.png differ
diff --git a/generator/templates/simple/src/main.js b/generator/templates/simple/src/main.js
index dca820b..899cd19 100644
--- a/generator/templates/simple/src/main.js
+++ b/generator/templates/simple/src/main.js
@@ -2,21 +2,28 @@
extend: '@vue/cli-service/generator/template/src/main.js'
replace:
- !!js/regexp /import Vue from 'vue'/
+ - !!js/regexp /import App from './App.vue'/
- !!js/regexp /Vue.config.productionTip = false/
+ - !!js/regexp /h => h\(App\),/
- !!js/regexp /}\)\.\$mount\('#app'\)/
---
<%# REPLACE %>
-import Vue from 'nativescript-vue'
+import Vue from 'vue';
<%# END_REPLACE %>
<%# REPLACE %>
-// Set the following to `true` to hide the logs created by nativescript-vue
-Vue.config.silent = false
-// Set the following to `false` to not colorize the logs created by nativescript-vue
-Vue.config.debug = true
+import App from '~/App.vue';
<%# END_REPLACE %>
<%# REPLACE %>
-}).$start()
+Vue.config.productionTip = false;
<%# END_REPLACE %>
+
+<%# REPLACE %>
+(h) => h(App),
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+}).$mount('#app');
+<%# END_REPLACE %>
\ No newline at end of file
diff --git a/generator/templates/simple/src/main.native.js b/generator/templates/simple/src/main.native.js
new file mode 100644
index 0000000..9686265
--- /dev/null
+++ b/generator/templates/simple/src/main.native.js
@@ -0,0 +1,33 @@
+---
+extend: '@vue/cli-service/generator/template/src/main.js'
+replace:
+ - !!js/regexp /import Vue from 'vue'/
+ - !!js/regexp /import App from './App.vue'/
+ - !!js/regexp /Vue.config.productionTip = false/
+ - !!js/regexp /h => h\(App\),/
+ - !!js/regexp /}\)\.\$mount\('#app'\)/
+---
+
+<%# REPLACE %>
+import Vue from 'nativescript-vue';
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+import App from './App.vue';
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+// Set the following to `true` to hide the logs created by nativescript-vue
+Vue.config.silent = false;
+// Set the following to `false` to not colorize the logs created by nativescript-vue
+// disabled in template due to typing issue for Typescript projects....NEEDS TO BE FIXED
+// Vue.config.debug = true;
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+(h) => h('frame', [h(App)]),
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+}).$start();
+<%# END_REPLACE %>
\ No newline at end of file
diff --git a/generator/templates/simple/src/package.json b/generator/templates/simple/src/package.json
index 8f7b233..41f6a95 100644
--- a/generator/templates/simple/src/package.json
+++ b/generator/templates/simple/src/package.json
@@ -3,7 +3,7 @@
"v8Flags": "--expose_gc",
"markingMode": "none"
},
- "main": "main",
+ "main": "main.native",
"name": "<%- applicationName %>",
"version": "<%- applicationVersion %>"
}
diff --git a/generator/templates/simple/src/router.js b/generator/templates/simple/src/router.js
index 56d87a9..6830956 100644
--- a/generator/templates/simple/src/router.js
+++ b/generator/templates/simple/src/router.js
@@ -2,8 +2,33 @@
extend: '@vue/cli-service/generator/router/template/src/router.js'
replace:
- !!js/regexp /import Vue from 'vue'/
+ - !!js/regexp /import Router from 'vue-router'/
+ - !!js/regexp /Vue.use\(Router\)/
+ - !!js/regexp /import Home from './views/Home.vue'/
+ - !!js/regexp /'./views/About.vue'\)/
+ - !!js/regexp /\}\)/
---
<%# REPLACE %>
-import Vue from 'nativescript-vue'
+import Vue from 'vue';
<%# END_REPLACE %>
+
+<%# REPLACE %>
+import Router from 'vue-router';
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+Vue.use(Router);
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+import Home from '~/views/Home.vue';
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+'~/views/About.vue'),
+<%# END_REPLACE %>
+
+<%# REPLACE %>
+});
+<%# END_REPLACE %>
\ No newline at end of file
diff --git a/generator/templates/simple/src/store.js b/generator/templates/simple/src/store.js
deleted file mode 100644
index e5559de..0000000
--- a/generator/templates/simple/src/store.js
+++ /dev/null
@@ -1,9 +0,0 @@
----
-extend: '@vue/cli-service/generator/vuex/template/src/store.js'
-replace:
- - !!js/regexp /import Vue from 'vue'/
----
-
-<%# REPLACE %>
-import Vue from 'nativescript-vue'
-<%# END_REPLACE %>
diff --git a/generator/templates/simple/src/styles/style-one.css b/generator/templates/simple/src/styles/style-one.css
new file mode 100644
index 0000000..aede169
--- /dev/null
+++ b/generator/templates/simple/src/styles/style-one.css
@@ -0,0 +1,53 @@
+ActionBar {
+ color: #42b983;
+}
+
+.w-navbar {
+ color: #42b983;
+ position: fixed;
+ z-index: 10000;
+ height: 3em;
+ width: 100%;
+ top: 0px;
+ left: 0px;
+ margin: auto;
+ list-style: none;
+
+ display: flex;
+ align-items: center;
+ padding: 0 10px;
+
+ -webkit-box-shadow: -8px 8px 6px -7px #999;
+ -moz-box-shadow: -8px 8px 6px -7px #999;
+ box-shadow: -8px 8px 6px -7px #999;
+}
+
+.w-navbar .w-title {
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.w-container {
+ height: 100%;
+ width: 100%;
+ padding-top: 3em;
+ position: relative;
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+ justify-content: top;
+ align-items: center;
+}
+
+.w-container .w-button {
+ width: 50%;
+ height: 2em;
+ margin: .25em;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ background-color: #d7d7d7;
+ border-width: 0px;
+ font-weight: 600;
+ border-radius: 3px;
+}
\ No newline at end of file
diff --git a/generator/templates/simple/src/styles/style-one.less b/generator/templates/simple/src/styles/style-one.less
new file mode 100644
index 0000000..aede169
--- /dev/null
+++ b/generator/templates/simple/src/styles/style-one.less
@@ -0,0 +1,53 @@
+ActionBar {
+ color: #42b983;
+}
+
+.w-navbar {
+ color: #42b983;
+ position: fixed;
+ z-index: 10000;
+ height: 3em;
+ width: 100%;
+ top: 0px;
+ left: 0px;
+ margin: auto;
+ list-style: none;
+
+ display: flex;
+ align-items: center;
+ padding: 0 10px;
+
+ -webkit-box-shadow: -8px 8px 6px -7px #999;
+ -moz-box-shadow: -8px 8px 6px -7px #999;
+ box-shadow: -8px 8px 6px -7px #999;
+}
+
+.w-navbar .w-title {
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.w-container {
+ height: 100%;
+ width: 100%;
+ padding-top: 3em;
+ position: relative;
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+ justify-content: top;
+ align-items: center;
+}
+
+.w-container .w-button {
+ width: 50%;
+ height: 2em;
+ margin: .25em;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ background-color: #d7d7d7;
+ border-width: 0px;
+ font-weight: 600;
+ border-radius: 3px;
+}
\ No newline at end of file
diff --git a/generator/templates/simple/src/styles/style-one.scss b/generator/templates/simple/src/styles/style-one.scss
new file mode 100644
index 0000000..a3453ff
--- /dev/null
+++ b/generator/templates/simple/src/styles/style-one.scss
@@ -0,0 +1,55 @@
+ActionBar {
+ color: #42b983;
+}
+
+.w-navbar {
+ color: #42b983;
+ position: fixed;
+ z-index: 10000;
+ height: 3em;
+ width: 100%;
+ top: 0px;
+ left: 0px;
+ margin: auto;
+ list-style: none;
+
+ display: flex;
+ align-items: center;
+ padding: 0 10px;
+
+ -webkit-box-shadow: -8px 8px 6px -7px #999;
+ -moz-box-shadow: -8px 8px 6px -7px #999;
+ box-shadow: -8px 8px 6px -7px #999;
+
+ .w-title {
+ margin-left: auto;
+ margin-right: auto;
+ }
+}
+
+.w-container {
+ height: 100%;
+ width: 100%;
+ padding-top: 3em;
+ position: relative;
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+ justify-content: top;
+ align-items: center;
+
+
+ .w-button {
+ width: 50%;
+ height: 2em;
+ margin: .25em;
+ display: flex;
+ justify-content: center;
+ align-items: center;
+ background-color: #d7d7d7;
+ border-width: 0px;
+ font-weight: 600;
+ border-radius: 3px;
+ }
+
+}
\ No newline at end of file
diff --git a/generator/templates/simple/src/styles/style-one.styl b/generator/templates/simple/src/styles/style-one.styl
new file mode 100644
index 0000000..72959e9
--- /dev/null
+++ b/generator/templates/simple/src/styles/style-one.styl
@@ -0,0 +1,46 @@
+ActionBar
+ color #42b983
+
+.w-navbar
+ color #42b983
+ position fixed
+ z-index 10000
+ height 3em
+ width 100%
+ top 0px
+ left 0px
+ margin auto
+ list-style none
+ display flex
+ align-items center
+ padding 0 10px
+ -webkit-box-shadow -8px 8px 6px -7px #999
+ -moz-box-shadow -8px 8px 6px -7px #999
+ box-shadow -8px 8px 6px -7px #999
+
+ .w-title
+ margin-left auto
+ margin-right auto
+
+.w-container
+ height 100%
+ width 100%
+ padding-top 3em
+ position relative
+ overflow hidden
+ display flex
+ flex-direction column
+ justify-content top
+ align-items center
+
+ .w-button
+ width 50%
+ height 2em
+ margin 0.25em
+ display flex
+ justify-content center
+ align-items center
+ background-color #d7d7d7
+ border-width 0px
+ font-weight 600
+ border-radius 3px
\ No newline at end of file
diff --git a/generator/templates/simple/src/styles/style-two.css b/generator/templates/simple/src/styles/style-two.css
new file mode 100644
index 0000000..3ee2f55
--- /dev/null
+++ b/generator/templates/simple/src/styles/style-two.css
@@ -0,0 +1,7 @@
+ActionBar {
+ color: #000000;
+}
+
+.w-navbar {
+ color: #000000;
+}
\ No newline at end of file
diff --git a/generator/templates/simple/src/styles/style-two.less b/generator/templates/simple/src/styles/style-two.less
new file mode 100644
index 0000000..3ee2f55
--- /dev/null
+++ b/generator/templates/simple/src/styles/style-two.less
@@ -0,0 +1,7 @@
+ActionBar {
+ color: #000000;
+}
+
+.w-navbar {
+ color: #000000;
+}
\ No newline at end of file
diff --git a/generator/templates/simple/src/styles/style-two.scss b/generator/templates/simple/src/styles/style-two.scss
new file mode 100644
index 0000000..9abd667
--- /dev/null
+++ b/generator/templates/simple/src/styles/style-two.scss
@@ -0,0 +1,7 @@
+ActionBar {
+ color: #000000;
+}
+
+.w-navbar {
+ color: #000000;
+}
\ No newline at end of file
diff --git a/generator/templates/simple/src/styles/style-two.styl b/generator/templates/simple/src/styles/style-two.styl
new file mode 100644
index 0000000..a771955
--- /dev/null
+++ b/generator/templates/simple/src/styles/style-two.styl
@@ -0,0 +1,5 @@
+ActionBar
+ color #000000
+
+.w-navbar
+ color #000000
\ No newline at end of file
diff --git a/generator/templates/simple/src/views/About.vue b/generator/templates/simple/src/views/About.vue
index c491f2a..0f758f7 100644
--- a/generator/templates/simple/src/views/About.vue
+++ b/generator/templates/simple/src/views/About.vue
@@ -1,7 +1,87 @@
-<%_ if (rootOptions.router) { _%>
+<%_ if (!options.isNativeOnly) { _%>
+
+
+
+ This is an about page
+
+
+
+
+<%_ } else { _%>
+<%_ } _%>
+
+
-
+
+
+<%_ if (!usingTS) { _%>
+
+<%_ } else { _%>
+
+<%_ } _%>
+<%_ if (!usingTS) { _%>
+<%# -------------------- Is Not Using TypeScript -------------------- -%>
+<%# -------------------- Remove this line and Uncomment the next to use script tag - Prettier formatting bug removes all script tags if these are left in -------------------- -%>
+<%# -------------------- -------------------- -%>
+<%_ } else { _%>
+<%# -------------------- Is Using TypeScript -------------------- -%>
+<%# -------------------- Remove this line and Uncomment the next to use script tag - Prettier formatting bug removes all script tags if these are left in -------------------- -%>
+<%# -------------------- -------------------- -%>
<%_ } _%>
+
+<%_ if (rootOptions.cssPreprocessor) { _%>
+<%_ if (rootOptions.cssPreprocessor == 'sass' || rootOptions.cssPreprocessor == 'scss') { _%>
+<%# -------------------- IS Using scss OR sass -------------------- -%>
+<%- rootOptions.cssPreprocessor
+ ? `
+<%_ } else if (rootOptions.cssPreprocessor == 'stylus') { _%>
+<%# -------------------- IS Using stylus -------------------- -%>
+
+<%_ } else if (rootOptions.cssPreprocessor == 'less') { _%>
+<%# -------------------- IS Using Less -------------------- -%>
+
+<%_ } _%>
+<%_ } else { _%>
+<%# -------------------- IS Using standard CSS -------------------- -%>
+
+<%_ } _%>
\ No newline at end of file
diff --git a/generator/templates/simple/src/views/Home.vue b/generator/templates/simple/src/views/Home.vue
index 3dfdf21..ffb1c4e 100644
--- a/generator/templates/simple/src/views/Home.vue
+++ b/generator/templates/simple/src/views/Home.vue
@@ -1,20 +1,130 @@
-<%_ if (rootOptions.router) { _%>
+<%_ if (!options.isNativeOnly) { _%>
+
+
+
+
+
+
+
+
+
+<%_ } else { _%>
+<%_ } _%>
+
+
-
-
+
+
+
+
-
+<%_ if (!usingTS) { _%>
+<%# -------------------- Is Not Using TypeScript -------------------- -%>
+<%_ } else { _%>
+<%# -------------------- Is Using TypeScript -------------------- -%>
+
<%_ } _%>
+
+<%_ if (rootOptions.cssPreprocessor) { _%>
+<%_ if (rootOptions.cssPreprocessor == 'sass' || rootOptions.cssPreprocessor == 'scss') { _%>
+<%# -------------------- IS Using scss OR sass -------------------- -%>
+<%- rootOptions.cssPreprocessor
+ ? `
+<%_ } else if (rootOptions.cssPreprocessor == 'stylus') { _%>
+<%# -------------------- IS Using stylus -------------------- -%>
+
+<%_ } else if (rootOptions.cssPreprocessor == 'less') { _%>
+<%# -------------------- IS Using Less -------------------- -%>
+
+<%_ } _%>
+<%_ } else { _%>
+<%# -------------------- IS Using standard CSS -------------------- -%>
+
+<%_ } _%>
\ No newline at end of file
diff --git a/generator/templates/vue-sfc-template.vue b/generator/templates/vue-sfc-template.vue
new file mode 100644
index 0000000..b292641
--- /dev/null
+++ b/generator/templates/vue-sfc-template.vue
@@ -0,0 +1,76 @@
+<%_ if (rootOptions.router) { _%>
+<%# -------------------- IS Using vue-router -------------------- -%>
+<%_ if (!options.isNativeOnly) { _%>
+
+
+<%_ } else { _%>
+
+<%_ } _%>
+<%_ } else { _%>
+<%# -------------------- IS NOT Using vue-router -------------------- -%>
+<%_ if (!options.isNativeOnly) { _%>
+
+
+<%_ } else { _%>
+
+<%_ } _%>
+<%_ } _%>
+<%_ if (!usingTS && rootOptions.router) { _%>
+<%# -------------------- IS NOT Using TypeScript AND IS Using vue-router -------------------- -%>
+<%# Remove this line and Uncomment the next to use script tag - Prettier formatting bug removes all script tags if these are left in -%>
+<%# -%>
+<%_ } else if (!usingTS && !rootOptions.router) { _%>
+<%# -------------------- IS NOT Using TypeScript AND IS NOT Using vue-router -------------------- -%>
+<%# Remove this line and Uncomment the next to use script tag - Prettier formatting bug removes all script tags if these are left in -%>
+<%# -%>
+<%_ } else if (usingTS && rootOptions.router) { _%>
+<%# -------------------- IS Using TypeScript AND IS Using vue-router -------------------- -%>
+<%# -%>
+<%_ } else if (usingTS && !rootOptions.router) { _%>
+<%# -------------------- IS Using TypeScript AND IS NOT Using vue-router -------------------- -%>
+<%# -%>
+<%_ } else { _%>
+<%# -------------------- don't do anything -------------------- -%>
+<%_ } _%>
+
+<%_ if (rootOptions.cssPreprocessor) { _%>
+<%_ if (rootOptions.cssPreprocessor == 'sass' || rootOptions.cssPreprocessor == 'scss') { _%>
+<%# -------------------- IS Using scss OR sass -------------------- -%>
+<%- rootOptions.cssPreprocessor
+ ? `
+<%- rootOptions.cssPreprocessor
+ ? `
+<%_ } else if (rootOptions.cssPreprocessor == 'stylus') { _%>
+<%# -------------------- IS Using stylus -------------------- -%>
+
+
+<%_ } else if (rootOptions.cssPreprocessor == 'less') { _%>
+<%# -------------------- IS Using Less -------------------- -%>
+
+
+<%_ } _%>
+<%_ } else { _%>
+<%# -------------------- IS Using standard CSS -------------------- -%>
+
+
+<%_ } _%>
diff --git a/index.js b/index.js
index 716e821..c50c2d5 100644
--- a/index.js
+++ b/index.js
@@ -1,71 +1,1118 @@
-const path = require('path')
+/* eslint-disable no-console */
+/* eslint-disable import/no-extraneous-dependencies */
+const { relative, resolve, sep, join } = require('path');
+const fs = require('fs-extra');
+
+const webpack = require('webpack');
+const CleanWebpackPlugin = require('clean-webpack-plugin');
+const CopyWebpackPlugin = require('copy-webpack-plugin');
+const DefinePlugin = require('webpack/lib/DefinePlugin');
+
+// // // const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
+
+const BundleAnalyzerPlugin = require('webpack-bundle-analyzer');
+const TerserPlugin = require('terser-webpack-plugin');
+
+const nativescriptTarget = require('nativescript-dev-webpack/nativescript-target');
+const NsVueTemplateCompiler = require('nativescript-vue-template-compiler');
+const nsWebpack = require('nativescript-dev-webpack');
+
+// eslint-disable-next-line prefer-destructuring
+const PlatformFSPlugin = nsWebpack.PlatformFSPlugin;
+// eslint-disable-next-line prefer-destructuring
+const WatchStateLoggerPlugin = nsWebpack.WatchStateLoggerPlugin;
+const { NativeScriptWorkerPlugin } = require('nativescript-worker-loader/NativeScriptWorkerPlugin');
+
+const resolveExtensionsOptions = {
+ web: ['*', '.ts', '.tsx', '.js', '.jsx', '.vue', '.json', '.scss', '.styl', '.less', '.css'],
+ android: [
+ '*',
+ '.native.ts',
+ '.android.ts',
+ '.ts',
+ '.native.js',
+ '.android.js',
+ '.js',
+ '.native.vue',
+ '.android.vue',
+ '.vue',
+ '.json',
+ '.native.scss',
+ '.android.scss',
+ '.scss',
+ '.native.styl',
+ '.android.styl',
+ '.styl',
+ '.native.less',
+ '.android.less',
+ '.less',
+ '.native.css',
+ '.android.css',
+ '.css'
+ ],
+ ios: [
+ '*',
+ '.native.ts',
+ '.ios.ts',
+ '.ts',
+ '.native.js',
+ '.ios.js',
+ '.js',
+ '.native.vue',
+ '.ios.vue',
+ '.vue',
+ '.json',
+ '.native.scss',
+ '.ios.scss',
+ '.scss',
+ '.native.styl',
+ '.ios.styl',
+ '.styl',
+ '.native.less',
+ '.ios.less',
+ '.less',
+ '.native.css',
+ '.ios.css',
+ '.css'
+ ]
+};
+
+const getBlockRegex = (tag, mode) => {
+ //return `<${tag} ${mode}([\\s]+[\\S]+(="[\\S]+")?)*[\\s]*>[\\s\\S]*?<\/${tag}>`;
+ return `^((<${tag})(.+\\b${mode}\\b))([\\s\\S]*?>)[\\s\\S]*?(<\\/${tag}>)`;
+};
module.exports = (api, projectOptions) => {
- process.env.VUE_CLI_TARGET = 'nativescript'
+ const jsOrTs = api.hasPlugin('typescript') ? '.ts' : '.js';
+ let env = new Object();
+ let flags = new Array();
+
+ const addOption = (all, current) => {
+ all[current] = true;
+ return all;
+ };
+
+ // are we using the vue cli or not and if so are we passing in the correct options
+ if (api && api.service.mode && api.service.mode !== 'development') {
+ // will convert the --mode options into an array for later use
+ flags = api.service.mode.split('.');
+ } else {
+ // get the --env command line options and put them in the env variable
+ const [, , ...processArgs] = process.argv;
+ flags = [...processArgs].filter((f) => f.startsWith('--env.')).map((f) => f.substring(6));
+
+ // take advantage of the vue cli api to load the --env items into process.env.
+ // we are filtering out the items, by catching the '=' sign, brought in from nsconfig.json as those don't need loaded into process.env
+ api.service.loadEnv(flags.filter((o) => !o.includes('=')).join('.'));
+ }
+
+ // setup the traditional {N} webpack 'env' variable
+ env = flags.reduce(addOption, {});
+
+ const platform = env && ((env.android && 'android') || (env.ios && 'ios') || (env.web && 'web'));
+
+ // if (!platform) {
+ // throw new Error('You need to provide a target platform!');
+ // }
+
+ const projectRoot = api.service.context;
+ const appMode = platform === 'android' ? 'native' : platform === 'ios' ? 'native' : 'web';
+
+ // setup output directory depending on if we're building for web or native
+ projectOptions.outputDir = join(projectRoot, appMode === 'web' ? 'dist' : nsWebpack.getAppPath(platform, projectRoot));
- api.chainWebpack(config => {
- config.output.filename(`app.js`)
- .chunkFilename('vendor.js')
+ return appMode === 'web' ? webConfig(api, projectOptions, env, jsOrTs, projectRoot) : nativeConfig(api, projectOptions, env, jsOrTs, projectRoot, platform);
+};
- config.resolve.alias.delete('vue$');
+const resolveExtensions = (config, ext) => {
+ config.resolve.extensions.add(ext).end();
+};
- config.resolve.extensions.add('.android.js')
- config.resolve.extensions.add('.common.js')
+const nativeConfig = (api, projectOptions, env, jsOrTs, projectRoot, platform) => {
+ console.log('starting nativeConfig');
+ process.env.VUE_CLI_TARGET = 'nativescript';
+ const isNativeOnly = !fs.pathExistsSync(resolve(projectRoot, 'src'));
+ const tsconfigFileName = 'tsconfig.json';
- const tnsCorePath = api.resolve('node_modules/tns-core-modules')
- config.resolve.modules.add(tnsCorePath)
- config.resolveLoader.modules.add(tnsCorePath)
+ const appComponents = ['tns-core-modules/ui/frame', 'tns-core-modules/ui/frame/activity'];
+ const platforms = ['ios', 'android'];
- const vueRule = config.module.rule('vue').test(/\.vue$/)
+ // Default destination inside platforms//...
+ const dist = projectOptions.outputDir;
+ const appResourcesPlatformDir = platform === 'android' ? 'Android' : 'iOS';
- vueRule.use('vue-loader').tap(options => {
- options.compilerOptions.compiler = require('nativescript-vue-template-compiler')
- options.compilerOptions = options.compilerOpitons
- delete options.compilerOpitons;
- })
+ const {
+ // The 'appPath' and 'appResourcesPath' values are fetched from
+ // the nsconfig.json configuration file
+ // when bundling with `tns run android|ios --bundle`.
+ appPath = isNativeOnly === true ? 'app' : 'src',
+ appResourcesPath = join(appPath, 'App_Resources'),
- const addLoader = ({loader, options}) => {
- vueRule.use(loader).loader(loader).options(options)
+ // You can provide the following flags when running 'tns run android|ios'
+ snapshot, // --env.snapshot
+ production, // --env.production
+ report, // --env.report
+ hmr // --env.hmr
+ } = env;
+
+ // --env.externals
+ const externals = (env.externals || []).map((e) => {
+ return new RegExp(e + '.*');
+ });
+
+ const mode = production ? 'production' : 'development';
+
+ const appFullPath = resolve(projectRoot, appPath);
+ const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
+ const entryModule = nsWebpack.getEntryModule(appFullPath);
+ const entryPath = `.${sep}${entryModule}`;
+
+ console.log(`Bundling application for entryPath ${entryPath}...`);
+
+ api.chainWebpack((config) => {
+ config
+ .mode(mode)
+ .context(appFullPath)
+ .devtool('none')
+ .end();
+
+ config.externals(externals).end();
+
+ config
+ .watchOptions({
+ ignored: [
+ appResourcesFullPath,
+ // Don't watch hidden files
+ '**/.*'
+ ]
+ })
+ .target(nativescriptTarget)
+ .end();
+
+ config.entryPoints // clear out old config.entryPoints and install new
+ .clear()
+ .end()
+ .entry('bundle')
+ .add(entryPath)
+ .end();
+
+ // clear out old config.output and install new
+ config.output.clear().end();
+
+ config.output
+ .pathinfo(false)
+ .path(dist)
+ .libraryTarget('commonjs2')
+ .filename(`[name].js`)
+ .globalObject('global')
+ .end();
+
+ // next several use the resolveExtension function to easily
+ // add in resolve.extensions from an object array const
+ // or directly from a string
+ config.resolve.extensions.clear();
+
+ if (platform === 'android') {
+ for (let ext of resolveExtensionsOptions.android) {
+ resolveExtensions(config, ext);
+ }
+ } else {
+ for (let ext of resolveExtensionsOptions.ios) {
+ resolveExtensions(config, ext);
+ }
}
- addLoader({
- loader: 'nativescript-vue-loader',
- options: {}
- })
-
- config.plugins.delete('hmr')
- config.plugin('extract-css').tap(args => {
- if (!args.length) return args;
-
- args[0].filename = 'app.css'
- args[0].chunkFilename = 'vendor.css'
-
- return args;
- })
-
- const nodeModulesPath = api.resolve('node_modules')
- config.externals((context, request, callback) => {
- if (context.startsWith(nodeModulesPath)) {
- const module = context.replace(nodeModulesPath, '').split(path.sep).find(p => !!p)
- try {
- const pkg = require(path.resolve(nodeModulesPath, module, 'package.json'))
- if(pkg.nativescript) {
- return callback(null, 'commonjs ' + request)
+ // delete these out. we'll add them back in, but we do it
+ // this way to ensure that we get the exact path we need.
+ config.resolve.modules.delete('node_modules');
+ config.resolve.modules.delete(resolve(projectRoot, 'node_modules'));
+
+ config.resolve.modules // Resolve {N} system modules from tns-core-modules
+ .add(resolve(projectRoot, 'node_modules/tns-core-modules'))
+ .add(resolve(projectRoot, 'node_modules'))
+ .add('node_modules/tns-core-modules')
+ .add('node_modules')
+ .end()
+ .alias.delete('vue$')
+ .delete('@')
+ .set('~', appFullPath)
+ .set('@', appFullPath)
+ .set('src', api.resolve('src'))
+ .set('app', isNativeOnly ? api.resolve('app') : api.resolve('src'))
+ .set('assets', resolve(isNativeOnly ? api.resolve('app') : api.resolve('src'), 'assets'))
+ .set('components', resolve(isNativeOnly ? api.resolve('app') : api.resolve('src'), 'components'))
+ .set('fonts', resolve(isNativeOnly ? api.resolve('app') : api.resolve('src'), 'fonts'))
+ .set('styles', resolve(isNativeOnly ? api.resolve('app') : api.resolve('src'), 'styles'))
+ .set('root', projectRoot)
+ .set('vue$', 'nativescript-vue')
+ .end()
+ .symlinks(true) // don't resolve symlinks to symlinked modules
+ .end();
+
+ config.resolveLoader
+ .symlinks(false) // don't resolve symlinks to symlinked modules
+ .end();
+
+ config.node
+ .set('http', false)
+ .set('timers', false)
+ .set('setImmediate', false)
+ .set('fs', 'empty')
+ .set('__dirname', false)
+ .end();
+
+ config.optimization
+ .splitChunks({
+ cacheGroups: {
+ vendor: {
+ name: 'vendor',
+ chunks: 'all',
+ test: (module) => {
+ const moduleName = module.nameForCondition ? module.nameForCondition() : '';
+ return /[\\/]node_modules[\\/]/.test(moduleName) || appComponents.some((comp) => comp === moduleName);
+ },
+ enforce: true
}
- } catch (e) {
}
- }
- callback()
- })
- })
-
- api.registerCommand('tns', {
- description: 'run nativescript cli commands',
- usage: 'vue-cli-service tns [options]',
- options: {
- '--android': 'run in android emulator',
- '--ios': 'run in ios simulator',
- '--release': 'run in release mode',
+ })
+ .end();
+
+ config.optimization.minimize(Boolean(production));
+ config.optimization
+ .minimizer([
+ new TerserPlugin({
+ parallel: true,
+ cache: true,
+ terserOptions: {
+ output: {
+ comments: false
+ },
+ compress: {
+ // The Android SBG has problems parsing the output
+ // when these options are enabled
+ collapse_vars: platform !== 'android',
+ sequences: platform !== 'android'
+ }
+ }
+ })
+ ])
+ .end();
+
+ config.module
+ .rule('native-loaders')
+ .test(new RegExp(entryPath))
+ .use('nativescript-dev-webpack/bundle-config-loader')
+ .loader('nativescript-dev-webpack/bundle-config-loader')
+ .options({
+ registerPages: true, // applicable only for non-angular apps
+ loadCss: false //!snapshot // load the application css if in debug mode
+ })
+ .end();
+
+ config.when(platform === 'android', (config) => {
+ config.module
+ .rule('native-loaders')
+ .use('nativescript-dev-webpack/android-app-components-loader')
+ .loader('nativescript-dev-webpack/android-app-components-loader')
+ .options({
+ modules: appComponents
+ })
+ .before('nativescript-dev-webpack/bundle-config-loader')
+ .end();
+ });
+
+ // delete the vue loader rule and rebuild it
+ config.module.rules.delete('vue');
+ config.module
+ .rule('vue')
+ .test(/\.vue$/)
+ .use('vue-loader')
+ .loader('vue-loader')
+ .options(
+ Object.assign(
+ {
+ compiler: NsVueTemplateCompiler
+ },
+ {}
+ )
+ )
+ .before('string-replace-loader')
+ .end()
+ .use('string-replace-loader')
+ .loader('string-replace-loader')
+ .options(
+ Object.assign(
+ {
+ multiple: [
+ {
+ search: getBlockRegex('template', 'web'),
+ replace: '',
+ flags: 'gim',
+ strict: false
+ },
+ {
+ search: getBlockRegex('script', 'web'),
+ replace: '',
+ flags: 'gim',
+ strict: false
+ },
+ {
+ search: getBlockRegex('style', 'web'),
+ replace: '',
+ flags: 'gim',
+ strict: false
+ }
+ ]
+ },
+ {}
+ )
+ )
+ .end();
+
+ // delete the js loader rule and rebuil it
+ config.module.rules.delete('js');
+ config.module
+ .rule('js')
+ .test(/\.js$/)
+ .use('babel-loader')
+ .loader('babel-loader')
+ .end();
+
+ config.module
+ .rule('jsx')
+ .test(/\.jsx$/)
+ .use('babel-loader')
+ .loader('babel-loader')
+ .end();
+
+ // only adjust ts-loaders when we're using typescript in the project
+ if (api.hasPlugin('typescript')) {
+ config.module.rules.get('ts').uses.delete('cache-loader');
+ config.module.rules.get('ts').uses.delete('babel-loader');
+ if (mode === 'production') config.module.rules.get('ts').uses.delete('thread-loader');
+
+ const tsConfigOptions = config.module
+ .rule('ts')
+ .uses.get('ts-loader')
+ .get('options');
+
+ tsConfigOptions.configFile = resolve(projectRoot, tsconfigFileName);
+
+ config.module
+ .rule('ts')
+ .test(/\.ts$/)
+ .use('ts-loader')
+ .loader('ts-loader')
+ .options(tsConfigOptions)
+ .end();
+
+ config.module.rules.get('tsx').uses.delete('cache-loader');
+ config.module.rules.get('tsx').uses.delete('babel-loader');
+ if (mode === 'production') config.module.rules.get('tsx').uses.delete('thread-loader');
+
+ const tsxConfigOptions = config.module
+ .rule('tsx')
+ .uses.get('ts-loader')
+ .get('options');
+
+ tsxConfigOptions.configFile = resolve(projectRoot, tsconfigFileName);
+
+ config.module
+ .rule('tsx')
+ .test(/\.tsx$/)
+ .use('ts-loader')
+ .loader('ts-loader')
+ .options(tsxConfigOptions)
+ .end();
+ }
+
+ // remove most of the css rules and rebuild it for nativescript-vue
+ config.module.rules.get('css').oneOfs.delete('vue-modules');
+ config.module.rules.get('css').oneOfs.delete('normal-modules');
+ config.module.rules.get('css').oneOfs.delete('vue');
+ config.module.rules
+ .get('css')
+ .oneOfs.get('normal')
+ .uses.delete('extract-css-loader');
+ config.module.rules
+ .get('css')
+ .oneOfs.get('normal')
+ .uses.delete('vue-style-loader');
+ config.module.rules
+ .get('css')
+ .oneOfs.get('normal')
+ .uses.delete('postcss-loader');
+ config.module
+ .rule('css')
+ .oneOf('normal')
+ .use('nativescript-dev-webpack/apply-css-loader')
+ .loader('nativescript-dev-webpack/apply-css-loader')
+ .before('css-loader')
+ .end()
+ .use('nativescript-dev-webpack/style-hot-loader')
+ .loader('nativescript-dev-webpack/style-hot-loader')
+ .before('nativescript-dev-webpack/apply-css-loader')
+ .end()
+ .use('css-loader')
+ .loader('css-loader')
+ .options(
+ Object.assign(
+ config.module
+ .rule('css')
+ .oneOf('normal')
+ .uses.get('css-loader')
+ .get('options'),
+ {
+ minimize: false,
+ url: false,
+ importLoaders: 1
+ }
+ )
+ )
+ .end();
+
+ // remove most of the scss rules and rebuild it for nativescript-vue
+ config.module.rules.get('scss').oneOfs.delete('vue-modules');
+ config.module.rules.get('scss').oneOfs.delete('normal-modules');
+ config.module.rules.get('scss').oneOfs.delete('vue');
+ config.module.rules
+ .get('scss')
+ .oneOfs.get('normal')
+ .uses.delete('extract-css-loader');
+ config.module.rules
+ .get('scss')
+ .oneOfs.get('normal')
+ .uses.delete('vue-style-loader');
+ config.module.rules
+ .get('scss')
+ .oneOfs.get('normal')
+ .uses.delete('postcss-loader');
+ config.module
+ .rule('scss')
+ .oneOf('normal')
+ .use('nativescript-dev-webpack/apply-css-loader')
+ .loader('nativescript-dev-webpack/apply-css-loader')
+ .before('css-loader')
+ .end()
+ .use('nativescript-dev-webpack/style-hot-loader')
+ .loader('nativescript-dev-webpack/style-hot-loader')
+ .before('nativescript-dev-webpack/apply-css-loader')
+ .end()
+ .use('css-loader')
+ .loader('css-loader')
+ .options(
+ Object.assign(
+ config.module
+ .rule('scss')
+ .oneOf('normal')
+ .uses.get('css-loader')
+ .get('options'),
+ {
+ minimize: false,
+ url: false,
+ data: '$PLATFORM: ' + platform + ';'
+ }
+ )
+ )
+ .end()
+ .use('sass-loader')
+ .loader('sass-loader')
+ .options(
+ Object.assign(
+ config.module
+ .rule('scss')
+ .oneOf('normal')
+ .uses.get('sass-loader')
+ .get('options'),
+ {
+ minimize: false,
+ url: false,
+ data: '$PLATFORM: ' + platform + ';'
+ }
+ )
+ )
+ .end();
+
+ // remove most of the sass rules and rebuild it for nativescript-vue
+ config.module.rules.get('sass').oneOfs.delete('vue-modules');
+ config.module.rules.get('sass').oneOfs.delete('normal-modules');
+ config.module.rules.get('sass').oneOfs.delete('vue');
+ config.module.rules
+ .get('sass')
+ .oneOfs.get('normal')
+ .uses.delete('extract-css-loader');
+ config.module.rules
+ .get('sass')
+ .oneOfs.get('normal')
+ .uses.delete('vue-style-loader');
+ config.module.rules
+ .get('sass')
+ .oneOfs.get('normal')
+ .uses.delete('postcss-loader');
+ config.module
+ .rule('sass')
+ .oneOf('normal')
+ .use('nativescript-dev-webpack/apply-css-loader')
+ .loader('nativescript-dev-webpack/apply-css-loader')
+ .before('css-loader')
+ .end()
+ .use('nativescript-dev-webpack/style-hot-loader')
+ .loader('nativescript-dev-webpack/style-hot-loader')
+ .before('nativescript-dev-webpack/apply-css-loader')
+ .end()
+ .use('css-loader')
+ .loader('css-loader')
+ .options(
+ Object.assign(
+ config.module
+ .rule('sass')
+ .oneOf('normal')
+ .uses.get('css-loader')
+ .get('options'),
+ {
+ minimize: false,
+ url: false,
+ data: '$PLATFORM: ' + platform + ';'
+ }
+ )
+ )
+ .end()
+ .use('sass-loader')
+ .loader('sass-loader')
+ .options(
+ Object.assign(
+ config.module
+ .rule('sass')
+ .oneOf('normal')
+ .uses.get('sass-loader')
+ .get('options'),
+ {
+ minimize: false,
+ url: false,
+ data: '$PLATFORM: ' + platform + ';'
+ }
+ )
+ )
+ .end();
+
+ // remove most of the stylus rules and rebuild it for nativescript-vue
+ config.module.rules.get('stylus').oneOfs.delete('vue-modules');
+ config.module.rules.get('stylus').oneOfs.delete('normal-modules');
+ config.module.rules.get('stylus').oneOfs.delete('vue');
+ config.module.rules
+ .get('stylus')
+ .oneOfs.get('normal')
+ .uses.delete('vue-style-loader');
+ config.module.rules
+ .get('stylus')
+ .oneOfs.get('normal')
+ .uses.delete('postcss-loader');
+ config.module
+ .rule('stylus')
+ .oneOf('normal')
+ .use('nativescript-dev-webpack/apply-css-loader')
+ .loader('nativescript-dev-webpack/apply-css-loader')
+ .before('css-loader')
+ .end()
+ .use('nativescript-dev-webpack/style-hot-loader')
+ .loader('nativescript-dev-webpack/style-hot-loader')
+ .before('nativescript-dev-webpack/apply-css-loader')
+ .end()
+ .use('css-loader')
+ .loader('css-loader')
+ .options(
+ Object.assign(
+ config.module
+ .rule('stylus')
+ .oneOf('normal')
+ .uses.get('css-loader')
+ .get('options'),
+ {
+ minimize: false,
+ url: false
+ }
+ )
+ )
+ .end()
+ .use('stylus-loader')
+ .loader('stylus-loader')
+ .options(
+ Object.assign(
+ config.module
+ .rule('stylus')
+ .oneOf('normal')
+ .uses.get('stylus-loader')
+ .get('options'),
+ {
+ minimize: false,
+ url: false
+ }
+ )
+ )
+ .end();
+
+ // remove most of the less rules and rebuild it for nativescript-vue
+ config.module.rules.get('less').oneOfs.delete('vue-modules');
+ config.module.rules.get('less').oneOfs.delete('normal-modules');
+ config.module.rules.get('less').oneOfs.delete('vue');
+ config.module.rules
+ .get('less')
+ .oneOfs.get('normal')
+ .uses.delete('vue-style-loader');
+ config.module.rules
+ .get('less')
+ .oneOfs.get('normal')
+ .uses.delete('postcss-loader');
+ config.module
+ .rule('less')
+ .oneOf('normal')
+ .use('nativescript-dev-webpack/apply-css-loader')
+ .loader('nativescript-dev-webpack/apply-css-loader')
+ .before('css-loader')
+ .end()
+ .use('nativescript-dev-webpack/style-hot-loader')
+ .loader('nativescript-dev-webpack/style-hot-loader')
+ .before('nativescript-dev-webpack/apply-css-loader')
+ .end()
+ .use('css-loader')
+ .loader('css-loader')
+ .options(
+ Object.assign(
+ config.module
+ .rule('less')
+ .oneOf('normal')
+ .uses.get('css-loader')
+ .get('options'),
+ {
+ minimize: false,
+ url: false
+ }
+ )
+ )
+ .end()
+ .use('less-loader')
+ .loader('less-loader')
+ .options(
+ Object.assign(
+ config.module
+ .rule('less')
+ .oneOf('normal')
+ .uses.get('less-loader')
+ .get('options'),
+ {
+ minimize: false,
+ url: false
+ }
+ )
+ )
+ .end();
+
+ // delete these rules that come standard with CLI 3
+ // need to look at adding these back in after evaluating impact
+ config.module.rules.delete('images');
+ config.module.rules.delete('svg');
+ config.module.rules.delete('media');
+ config.module.rules.delete('fonts');
+ config.module.rules.delete('pug');
+ config.module.rules.delete('postcss');
+ // // config.module.rules.delete('less');
+ // // config.module.rules.delete('stylus');
+ config.module.rules.delete('eslint').end();
+
+ // delete these plugins that come standard with CLI 3
+ config.plugins.delete('hmr');
+ config.plugins.delete('html');
+ config.plugins.delete('preload');
+ config.plugins.delete('prefetch');
+ config.plugins.delete('pwa');
+ config.plugins.delete('progress');
+ config.plugins.delete('case-sensitive-paths');
+ config.plugins.delete('friendly-errors');
+ config.plugins.delete('no-emit-on-errors');
+ config.plugins.delete('copy').end();
+
+ if (mode === 'production') {
+ config.plugins.delete('extract-css');
+ config.plugins.delete('optimize-css');
+ config.plugins.delete('hash-module-ids');
+ config.plugins.delete('named-chunks');
+ }
+
+ // create new plugins
+
+ // Define useful constants like TNS_WEBPACK
+ // Merge DefinePlugin options that come in native from CLI 3
+ config
+ .plugin('define')
+ .use(DefinePlugin, [
+ Object.assign(config.plugin('define').get('args')[0], {
+ TNS_ENV: JSON.stringify(mode)
+ })
+ ])
+ .end();
+
+ // Remove all files from the out dir.
+ config
+ .plugin('clean')
+ .use(CleanWebpackPlugin, [
+ join(dist, '/**/*'),
+ {
+ root: dist
+ }
+ ])
+ .end();
+
+ // Copy native app resources to out dir.
+ config
+ .plugin('copy-native-resources')
+ .use(CopyWebpackPlugin, [
+ [
+ {
+ from: `${appResourcesFullPath}/${appResourcesPlatformDir}`,
+ to: `${dist}/App_Resources/${appResourcesPlatformDir}`,
+ context: projectRoot
+ }
+ ]
+ ])
+ .end();
+
+ // Copy assets to the out dir.
+ config
+ .plugin('copy-assets')
+ .use(CopyWebpackPlugin, [
+ [
+ {
+ from: {
+ glob: 'fonts/**'
+ }
+ },
+ {
+ from: {
+ glob: '**/*.+(jpg|png)'
+ }
+ },
+ {
+ from: {
+ glob: 'assets/**/*'
+ }
+ }
+ ],
+ {
+ context: resolve(isNativeOnly === true ? appFullPath : api.resolve('src')),
+ ignore: [`${relative(appPath, appResourcesFullPath)}/**`]
+ }
+ ])
+ .end();
+
+ // Generate a bundle starter script and activate it in package.json
+ config
+ .plugin('generate-bundle-starter')
+ .use(nsWebpack.GenerateBundleStarterPlugin, [['./vendor', './bundle']])
+ .end();
+
+ // For instructions on how to set up workers with webpack
+ // check out https://github.com/nativescript/worker-loader
+ config
+ .plugin('nativescript-worker')
+ .use(NativeScriptWorkerPlugin, [])
+ .end();
+
+ config
+ .plugin('platform-FS')
+ .use(PlatformFSPlugin, [
+ {
+ platform,
+ platforms
+ }
+ ])
+ .end();
+
+ // Does IPC communication with the {N} CLI to notify events when running in watch mode.
+ config
+ .plugin('watch-state-logger')
+ .use(WatchStateLoggerPlugin, [])
+ .end();
+
+ // Another only do this if we're using typescript. this code could have been put
+ // with the ts-loader section but left it here near the rest of the plugin config
+ if (api.hasPlugin('typescript')) {
+ // Next section is weird as we have to copy the plugin's config, edit the copy
+ // delete the plugin and then add the plugin back in with the saved config.
+ // This is all because webpack-chain cannot access the 'tslint' option of the plugin
+ // directly to edit it.
+ const forTSPluginConfig = config.plugin('fork-ts-checker').get('args')[0];
+
+ forTSPluginConfig.tsconfig = resolve(projectRoot, tsconfigFileName);
+ forTSPluginConfig.tslint = fs.pathExistsSync(resolve(projectRoot, 'tslint.json')) ? resolve(projectRoot, 'tslint.json') : false;
+ forTSPluginConfig.checkSyntacticErrors = false;
+
+ config.plugins.delete('fork-ts-checker').end();
+
+ config
+ .plugin('fork-ts-checker')
+ .use(require('fork-ts-checker-webpack-plugin'), [forTSPluginConfig])
+ .end();
+ }
+
+ // // // the next several items are disabled as they are mirrored from the nativescript-dev-webpack
+ // // // project. Need to figure out how to integrate some of that projects cli ability into this one.
+ // // config.when(report, (config) => {
+ // // config
+ // // .plugin('bundle-analyzer')
+ // // .use(BundleAnalyzerPlugin, [
+ // // {
+ // // analyzerMode: 'static',
+ // // openAnalyzer: false,
+ // // generateStatsFile: true,
+ // // reportFilename: resolve(projectRoot, 'report', `report.html`),
+ // // statsFilename: resolve(projectRoot, 'report', `stats.json`)
+ // // }
+ // // ])
+ // // .end();
+ // // });
+
+ // // config.when(snapshot, (config) => {
+ // // config
+ // // .plugin('snapshot')
+ // // .use(nsWebpack.NativeScriptSnapshotPlugin, [
+ // // {
+ // // chunk: 'vendor',
+ // // requireModules: ['tns-core-modules/bundle-entry-points'],
+ // // projectRoot,
+ // // webpackConfig: config
+ // // }
+ // // ])
+ // // .end();
+ // // });
+
+ // // config.when(hmr, (config) => {
+ // // config
+ // // .plugin('hmr')
+ // // .use(webpack.HotModuleReplacementPlugin(), [])
+ // // .end();
+ // // });
+ });
+};
+
+const webConfig = (api, projectOptions, env, jsOrTs, projectRoot) => {
+ console.log('starting webConfig');
+ const dist = projectOptions.outputDir;
+
+ const {
+ // The 'appPath' and 'appResourcesPath' values are fetched from
+ // the nsconfig.json configuration file
+ // when bundling with `tns run android|ios --bundle`.
+ appPath = 'src',
+ appResourcesPath = join(appPath, 'App_Resources'),
+
+ // You can provide the following flags when running 'tns run android|ios'
+ // snapshot, // --env.snapshot
+ production // --env.production
+ // report, // --env.report
+ // hmr // --env.hmr
+ } = env;
+
+ const mode = production ? 'production' : 'development';
+ const appResourcesFullPath = resolve(projectRoot, appResourcesPath);
+
+ api.chainWebpack((config) => {
+ config.entry('app').clear();
+ config.entry('app').add(resolve(api.resolve('src'), 'main' + jsOrTs));
+
+ config.output.path(dist).end();
+
+ config.resolve.alias
+ .delete('@')
+ .set('@', api.resolve('src'))
+ .set('~', api.resolve('src'))
+ .set('src', api.resolve('src'))
+ .set('assets', resolve(api.resolve('src'), 'assets'))
+ .set('components', resolve(api.resolve('src'), 'components'))
+ .set('fonts', resolve(api.resolve('src'), 'fonts'))
+ .set('styles', resolve(api.resolve('src'), 'styles'))
+ .set('root', projectRoot)
+ .end();
+
+ config.resolve.extensions.clear();
+
+ for (let ext of resolveExtensionsOptions.web) {
+ resolveExtensions(config, ext);
+ }
+
+ config.module
+ .rule('vue')
+ .use('cache-loader')
+ .loader('cache-loader')
+ .tap((options) => {
+ options.cacheDirectory = config.module
+ .rule('vue')
+ .uses.get('cache-loader')
+ .get('options').cacheDirectory;
+ return options;
+ })
+ .end()
+ .use('vue-loader')
+ .loader('vue-loader')
+ .options(
+ Object.assign(
+ {},
+ config.module
+ .rule('vue')
+ .uses.get('vue-loader')
+ .get('options')
+ )
+ )
+ .end()
+ .use('string-replace-loader')
+ .loader('string-replace-loader')
+ .options(
+ Object.assign(
+ {
+ multiple: [
+ {
+ search: getBlockRegex('template', 'native'),
+ replace: '',
+ flags: 'gim',
+ strict: false
+ },
+ {
+ search: getBlockRegex('script', 'native'),
+ replace: '',
+ flags: 'gim',
+ strict: false
+ },
+ {
+ search: getBlockRegex('style', 'native'),
+ replace: '',
+ flags: 'gim',
+ strict: false
+ }
+ ]
+ },
+ {}
+ )
+ )
+ .end();
+
+ const imageLoaderOptions = config.module
+ .rule('images')
+ .uses.get('url-loader')
+ .get('options');
+ imageLoaderOptions.fallback.options.name = 'assets/[name][hash:8].[ext]';
+ config.module.rules.delete('images');
+
+ config.module
+ .rule('images')
+ .test(/\.(png|jpe?g|gif|webp)(\?.*)?$/)
+ .use('url-loader')
+ .loader('url-loader')
+ .options(imageLoaderOptions)
+ .end();
+
+ // // // // Define useful constants like TNS_WEBPACK
+ // // // // Merge DefinePlugin options that come in native from CLI 3
+ // // // config
+ // // // .plugin('define')
+ // // // .use(DefinePlugin, [
+ // // // Object.assign(config.plugin('define').get('args')[0], {
+ // // // TNS_ENV: JSON.stringify(mode),
+ // // // TNS_APP_PLATFORM: JSON.stringify(process.env.VUE_APP_PLATFORM),
+ // // // TNS_APP_MODE: JSON.stringify(process.env.VUE_APP_MODE)
+ // // // })
+ // // // ])
+ // // // .end();
+
+ // Remove all files from the out dir.
+ config
+ .plugin('clean')
+ .use(CleanWebpackPlugin, [
+ join(dist, '/**/*'),
+ {
+ root: dist
+ }
+ ])
+ .end();
+
+ // Copy assets to out dir. Add your own globs as needed.
+ // if the project is native-only then we want to copy files
+ // from the app directory and not the src directory as at
+ // that point, the src directory should have been removed
+ // when the plugin was originally invoked.
+ config
+ .plugin('copy-assets')
+ .use(CopyWebpackPlugin, [
+ [
+ {
+ from: {
+ glob: 'fonts/**'
+ }
+ },
+ {
+ from: {
+ glob: '**/*.+(jpg|png)'
+ }
+ },
+ {
+ from: {
+ glob: 'assets/**/*',
+ ignore: ['**/*.+(jpg|png)']
+ }
+ }
+ ],
+ {
+ context: resolve(api.resolve('src')),
+ ignore: [`${relative(appPath, appResourcesFullPath)}/**`]
+ }
+ ])
+ .end();
+
+ // only adjust ts-loaders when we're using typescript in the project
+ if (api.hasPlugin('typescript')) {
+ const tsConfigOptions = config.module
+ .rule('ts')
+ .uses.get('ts-loader')
+ .get('options');
+
+ tsConfigOptions.configFile = resolve(projectRoot, 'tsconfig.json');
+
+ config.module
+ .rule('ts')
+ .test(/\.ts$/)
+ .use('ts-loader')
+ .loader('ts-loader')
+ .options(tsConfigOptions)
+ .end();
+
+ const tsxConfigOptions = config.module
+ .rule('ts')
+ .uses.get('ts-loader')
+ .get('options');
+
+ tsxConfigOptions.configFile = resolve(projectRoot, 'tsconfig.json');
+
+ config.module
+ .rule('tsx')
+ .test(/\.tsx$/)
+ .use('ts-loader')
+ .loader('ts-loader')
+ .options(tsxConfigOptions)
+ .end();
+
+ // Next section is weird as we have to copy the plugin's config, edit the copy
+ // delete the plugin and then add the plugin back in with the saved config.
+ // This is all because webpack chain cannot access the 'tslint' option of the plugin
+ // directly to edit it.
+ const forTSPluginConfig = config.plugin('fork-ts-checker').get('args')[0];
+
+ forTSPluginConfig.tsconfig = resolve(projectRoot, 'tsconfig.json');
+ forTSPluginConfig.tslint = fs.pathExistsSync(resolve(projectRoot, 'tslint.json')) ? resolve(projectRoot, 'tslint.json') : false;
+
+ config.plugins.delete('fork-ts-checker').end();
+
+ config
+ .plugin('fork-ts-checker')
+ .use(require('fork-ts-checker-webpack-plugin'), [forTSPluginConfig])
+ .end();
}
- }, require('./lib/commands/tns'))
-}
\ No newline at end of file
+ });
+};
diff --git a/lib/commands/tns.js b/lib/commands/tns.js
deleted file mode 100644
index 849b965..0000000
--- a/lib/commands/tns.js
+++ /dev/null
@@ -1,3 +0,0 @@
-module.exports = args => {
- console.log(args)
-}
\ No newline at end of file
diff --git a/lib/scripts/webpack-maintenance.js b/lib/scripts/webpack-maintenance.js
new file mode 100644
index 0000000..afe366f
--- /dev/null
+++ b/lib/scripts/webpack-maintenance.js
@@ -0,0 +1,44 @@
+const fs = require('fs');
+const replace = require('replace-in-file');
+
+const mode = process.argv[2];
+
+if (mode === 'pre') Pre();
+
+if (mode === 'post') Post();
+
+function Pre() {
+ console.log('copying CLI 3 version of webpack.config.js to project');
+ // setup string replacement options for webpack.config.js file
+ const replaceOptions = {
+ files: './webpack.config.js',
+ from: './lib/Service',
+ to: '@vue/cli-service/lib/Service'
+ };
+
+ // copy the dynamic webpack config from the cli-service.
+ fs.copyFile('./node_modules/@vue/cli-service/webpack.config.js', './webpack.config.js', (err) => {
+ //console.error('copyFile Error occurred:', err);
+ if (err) {
+ console.error('copyFile Error occurred:', err);
+ if (err) throw err;
+ }
+
+ // edit the file to correct a hard-coded path to be relative
+ replace(replaceOptions, (err, changes) => {
+ if (err) {
+ console.error('replace Error occurred:', err);
+ if (err) throw err;
+ }
+ });
+ });
+}
+
+function Post() {
+ console.log('starting Post');
+ if (fs.existsSync('./webpack.config.js')) {
+ fs.unlink('./webpack.config.js', (err) => {
+ if (err) throw err;
+ });
+ }
+}
diff --git a/lib/tslint.js b/lib/tslint.js
new file mode 100644
index 0000000..fcb7e3c
--- /dev/null
+++ b/lib/tslint.js
@@ -0,0 +1,143 @@
+// code taken from @vue/cli-plugin-typescript package
+
+module.exports = function lint(args = {}, api, silent) {
+ const cwd = api.resolve('.');
+ const fs = require('fs');
+ const path = require('path');
+ const globby = require('globby');
+ const tslint = require('tslint');
+ const ts = require('typescript');
+ /* eslint-disable-next-line node/no-extraneous-require */
+ const vueCompiler = require('vue-template-compiler');
+ const isVueFile = (file) => /\.vue(\.ts)?$/.test(file);
+
+ const options = {
+ fix: args['fix'] !== false,
+ formatter: args.format || 'codeFrame',
+ formattersDirectory: args['formatters-dir'],
+ rulesDirectory: args['rules-dir']
+ };
+
+ // hack to make tslint --fix work for *.vue files:
+ // we save the non-script parts to a cache right before
+ // linting the file, and patch fs.writeFileSync to combine the fixed script
+ // back with the non-script parts.
+ // this works because (luckily) tslint lints synchronously.
+ const vueFileCache = new Map();
+ const writeFileSync = fs.writeFileSync;
+
+ const patchWriteFile = () => {
+ fs.writeFileSync = (file, content, options) => {
+ if (isVueFile(file)) {
+ const parts = vueFileCache.get(path.normalize(file));
+ if (parts) {
+ const { before, after } = parts;
+ content = `${before}\n${content.trim()}\n${after}`;
+ }
+ }
+ return writeFileSync(file, content, options);
+ };
+ };
+
+ const restoreWriteFile = () => {
+ fs.writeFileSync = writeFileSync;
+ };
+
+ const parseTSFromVueFile = (file) => {
+ const content = fs.readFileSync(file, 'utf-8');
+ const { script } = vueCompiler.parseComponent(content, { pad: 'line' });
+ if (script && /^tsx?$/.test(script.lang)) {
+ vueFileCache.set(file, {
+ before: content.slice(0, script.start),
+ after: content.slice(script.end)
+ });
+ return script;
+ }
+ };
+
+ const program = tslint.Linter.createProgram(api.resolve('tsconfig.json'));
+
+ // patch getSourceFile for *.vue files
+ // so that it returns the