Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
"enforceBuildableLibDependency": true,
"allow": [],
"depConstraints": [
{ "sourceTag": "*", "onlyDependOnLibsWithTags": ["*"] }
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
Expand All @@ -21,7 +24,6 @@
{
"files": ["*.ts", "*.tsx"],
"extends": ["plugin:@nrwl/nx/typescript"],
"parserOptions": { "project": "./tsconfig.*?.json" },
"rules": {}
},
{
Expand Down
525 changes: 326 additions & 199 deletions package-lock.json

Large diffs are not rendered by default.

19 changes: 11 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,23 @@
"private": true,
"dependencies": {},
"devDependencies": {
"@nrwl/cli": "11.3.0",
"@nrwl/eslint-plugin-nx": "11.3.0",
"@nrwl/jest": "11.3.0",
"@nrwl/nx-plugin": "11.3.0",
"@nrwl/tao": "11.3.0",
"@nrwl/workspace": "11.3.0",
"@angular-devkit/architect": "~0.1102.6",
"@angular-devkit/core": "^11.2.6",
"@angular-devkit/schematics": "^11.2.6",
"@nrwl/cli": "11.5.2",
"@nrwl/eslint-plugin-nx": "11.5.2",
"@nrwl/jest": "11.5.2",
"@nrwl/nx-plugin": "11.5.2",
"@nrwl/tao": "11.5.2",
"@nrwl/workspace": "11.5.2",
"@types/jest": "26.0.8",
"@types/node": "12.12.38",
"@typescript-eslint/eslint-plugin": "4.3.0",
"@typescript-eslint/parser": "4.3.0",
"doctoc": "^1.4.0",
"dotenv": "6.2.0",
"eslint": "7.10.0",
"eslint-config-prettier": "6.0.0",
"eslint-config-prettier": "8.1.0",
"jest": "26.2.2",
"prettier": "2.2.1",
"strip-json-comments": "^3.1.1",
Expand All @@ -51,4 +54,4 @@
"tslint": "6.1.3",
"typescript": "~4.0.3"
}
}
}
23 changes: 22 additions & 1 deletion packages/nx/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1 +1,22 @@
{ "extends": "../../.eslintrc.json", "ignorePatterns": ["!**/*"], "rules": {} }
{
"extends": "../../.eslintrc.json",
"ignorePatterns": ["!**/*"],
"rules": {},
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"parserOptions": {
"project": ["packages/nx/tsconfig.*?.json"]
},
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
136 changes: 122 additions & 14 deletions packages/nx/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@

</div>

**NOTE**: Under development right now. Not recommended to use yet.

## Table of Contents

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
Expand All @@ -23,9 +21,9 @@
- [Create an app](#create-an-app)
- [`--framework [angular]`](#--framework-angular)
- [`--groupByName`](#--groupbyname)
- [Develop on simulators and devices](#develop-on-simulators-and-devices)
- [Release build](#release-build)
- [Test/lint the app](#testlint-the-app)
- [Develop on simulators and devices](#develop-on-simulators-and-devices)
- [Configuration options](#configuration-options)
- [Clean](#clean)
- [Create NativeScript library](#create-nativescript-library)
- [`--groupByName`](#--groupbyname-1)

Expand Down Expand Up @@ -65,9 +63,9 @@ The NativeScript Nx plugin will prefix apps by default to help distinguish them

#### `--framework [angular]`

Use this option to create a specific frontend framework integration app.
You will be prompted to choose a framework when this flag is ommitted.

By default a "vanilla" NativeScript app will be generated using xml view files.
Use this option to explicitly choose a specific frontend framework integration app.

This setting will be saved with plugin settings the first time it's used to automatically choose this frontend framework integration for subsequent usages and with other generators without having to specify the flag again.

Expand All @@ -85,7 +83,7 @@ This will generate:
apps/<app-name>-nativescript
```

### Develop on simulators and devices
#### Develop on simulators and devices

**Android:**

Expand All @@ -99,26 +97,136 @@ npx nx run <app-name>:android
npx nx run <app-name>:ios
```

### Release build
#### Configuration options

A custom builder is provided via `@nativescript/nx:build` with the following options:

```
"debug": {
"type": "boolean",
"default": true,
"description": "Use 'ns debug' instead of 'ns run'. Defaults to true"
},
"device": {
"type": "string",
"description": "Device identifier to run app on.",
"alias": "d"
},
"emulator": {
"type": "boolean",
"default": false,
"description": "Explicitly run with an emulator or simulator"
},
"noHmr": {
"type": "boolean",
"default": false,
"description": "Disable HMR"
},
"uglify": {
"type": "boolean",
"default": false,
"description": "Enable uglify during the webpack build"
},
"release": {
"type": "boolean",
"default": false,
"description": "Enable release mode during build using the --release flag"
},
"forDevice": {
"type": "boolean",
"default": false,
"description": "Build in device mode using the --for-device flag"
},
"production": {
"type": "boolean",
"default": false,
"description": "Build in production mode using the --env.production flag"
}
```

The options follow the [NativeScript command line options]().

Here's an example app config:

```
"nativescript-mobile": {
"projectType": "application",
"root": "apps/nativescript-mobile/",
"sourceRoot": "apps/nativescript-mobile/src",
"prefix": "",
"targets": {
"build": {
"builder": "@nativescript/nx:build",
"options": {
"noHmr": true,
"production": true,
"uglify": true,
"release": true,
"forDevice": true
},
"configurations": {
"prod": {
"fileReplacements": [
{
"replace": "apps/nativescript-mobile/src/environments/environment.ts",
"with": "apps/nativescript-mobile/src/environments/environment.prod.ts"
}
]
}
}
},
"ios": {
"builder": "@nativescript/nx:build",
"options": {
"platform": "ios"
},
"configurations": {
"prod": {
"combineWithConfig": "build:prod"
}
}
},
"android": {
"builder": "@nativescript/nx:build",
"options": {
"platform": "android"
},
"configurations": {
"prod": {
"combineWithConfig": "build:prod"
}
}
},
"clean": {
"builder": "@nativescript/nx:build",
"options": {
"clean": true
}
}
}
}
```

Build with an environment configuration enabled (for example, with `prod`):

**Android:**

```sh
npx nx run <app-name>:android:build
npx nx run <app-name>:android:prod
```

**iOS:** (Mac only)

```sh
npx nx run <app-name>:ios:build
npx nx run <app-name>:ios:prod
```

#### Clean

### Test/lint the app
It can be helpful to clean the app at times. This will clear out old dependencies plus iOS/Android platform files to give your app a nice reset.

```sh
npx nx run <app-name>:test
npx nx run <app-name>:lint
npx nx run <app-name>:clean
```

## Create NativeScript library
Expand Down
2 changes: 1 addition & 1 deletion packages/nx/builders.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"build": {
"implementation": "./src/builders/build/builder",
"schema": "./src/builders/build/schema.json",
"description": "build builder"
"description": "NativeScript builder"
}
}
}
5 changes: 4 additions & 1 deletion packages/nx/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nativescript/nx",
"version": "1.0.0-rc.3",
"version": "1.0.1",
"description": "NativeScript Plugin for Nx",
"repository": {
"type": "git",
Expand Down Expand Up @@ -29,6 +29,9 @@
"migrations": "./migrations.json"
},
"dependencies": {
"@angular-devkit/architect": "~0.1102.6",
"@angular-devkit/core": "^11.2.6",
"@angular-devkit/schematics": "^11.2.6",
"metro-resolver": "~0.65.0",
"fs-extra": "~9.1.0",
"ignore": "^5.1.8",
Expand Down
47 changes: 36 additions & 11 deletions packages/nx/src/builders/build/builder.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,21 @@ import { TestingArchitectHost } from '@angular-devkit/architect/testing';
import { schema } from '@angular-devkit/core';
import { join } from 'path';
import { BuildBuilderSchema } from './schema';
import runBuilder from './builder';

const options: BuildBuilderSchema = {};
const options: BuildBuilderSchema = {
noHmr: true,
platform: 'ios',
};

describe('Command Runner Builder', () => {
xdescribe('Command Runner Builder', () => {
const context = {
logger: {
info: (args) => {
console.log(args);
},
},
} as any;
let architect: Architect;
let architectHost: TestingArchitectHost;

Expand All @@ -23,17 +34,31 @@ describe('Command Runner Builder', () => {
});

it('can run', async () => {
const exec = spyOn(require('child_process'), 'spawn').and.callThrough();

await runBuilder(
{
...options,
},
context
);
expect(exec).toHaveBeenCalledWith('ns', ['debug', 'ios', '--no-hmr'], {
// stdio: ["debug", "ios", "--no-hmr"],
cwd: undefined,
env: process.env,
// maxBuffer: LARGE_BUFFER,
});
// A "run" can have multiple outputs, and contains progress information.
const run = await architect.scheduleBuilder('@nativescript/nx:build', options);
// The "result" member (of type BuilderOutput) is the next output.
const output = await run.result;
// const run = await architect.scheduleBuilder('@nativescript/nx:build', options);
// // The "result" member (of type BuilderOutput) is the next output.
// const output = await run.result;

// Stop the builder from running. This stops Architect from keeping
// the builder-associated states in memory, since builders keep waiting
// to be scheduled.
await run.stop();
// // Stop the builder from running. This stops Architect from keeping
// // the builder-associated states in memory, since builders keep waiting
// // to be scheduled.
// await run.stop();

// Expect that it succeeded.
expect(output.success).toBe(true);
// // Expect that it succeeded.
// expect(output.success).toBe(true);
});
});
Loading