Skip to content

Commit 8ca3429

Browse files
authored
feat: standardize commands (#57)
1 parent 0327592 commit 8ca3429

37 files changed

+2066
-670
lines changed

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"scripts": {
66
"nx": "nx",
77
"start": "nx serve",
8-
"build": "nx build nx",
8+
"build": "nx prepare nx",
99
"test": "nx run-many --target=test --all --parallel",
1010
"lint": "nx workspace-lint && nx lint",
1111
"e2e": "nx e2e",
@@ -46,13 +46,14 @@
4646
"@types/jest": "29.5.13",
4747
"@types/node": "^20.0.0",
4848
"@types/plist": "^3.0.2",
49-
"@types/xml2js": "^0.4.9",
5049
"conventional-changelog-cli": "^5.0.0",
5150
"cz-conventional-changelog": "^3.3.0",
5251
"doctoc": "^2.0.0",
5352
"dotenv": "~16.4.0",
53+
"enquirer": "^2.4.1",
5454
"eslint": "8.57.0",
5555
"eslint-config-prettier": "9.1.0",
56+
"fast-xml-parser": "^4.5.0",
5657
"fs-extra": "^11.2.0",
5758
"jest": "29.7.0",
5859
"nx": "20.0.3",
@@ -62,8 +63,8 @@
6263
"ts-jest": "29.2.5",
6364
"ts-node": "10.9.2",
6465
"tslib": "^2.8.0",
65-
"typescript": "^5.6.0",
66-
"xml2js": "^0.6.2"
66+
"typescript": "^5.6.0"
6767
},
6868
"dependencies": {}
6969
}
70+

packages/nx/README.md

Lines changed: 72 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,27 @@ Here's an example app config:
246246
"executor": "@nativescript/nx:build",
247247
"options": {
248248
"noHmr": true,
249-
"production": true,
250249
"uglify": true,
250+
"forDevice": true,
251251
"release": true,
252-
"forDevice": true
252+
"android": {
253+
"copyTo": "./dist/app.apk",
254+
"keyStorePath": "/path/to/android.keystore",
255+
"keyStoreAlias": "app",
256+
"keyStorePassword": "pass",
257+
"keyStoreAliasPassword": "pass"
258+
},
259+
"ios": {
260+
"copyTo": "./dist/app.ipa"
261+
}
253262
},
254263
"configurations": {
255-
"prod": {
264+
"production": {
265+
"production": true,
266+
"release": true,
267+
"android": {
268+
"keyStorePassword": "productionpw"
269+
},
256270
"fileReplacements": [
257271
{
258272
"replace": "./src/environments/environment.ts",
@@ -262,56 +276,69 @@ Here's an example app config:
262276
}
263277
}
264278
},
265-
"ios": {
266-
"executor": "@nativescript/nx:build",
279+
"debug": {
280+
"executor": "@nativescript/nx:debug",
267281
"options": {
268-
"platform": "ios"
282+
"noHmr": true,
283+
"uglify": false,
284+
"release": false,
285+
"forDevice": false,
286+
"prepare": false
269287
},
270288
"configurations": {
271-
"build": {
272-
"provision": "AppStore Profile",
273-
"copyTo": "./dist/build.ipa"
274-
},
275289
"prod": {
276-
"combineWithConfig": "build:prod"
290+
"fileReplacements": [
291+
{
292+
"replace": "./src/environments/environment.ts",
293+
"with": "./src/environments/environment.prod.ts"
294+
}
295+
]
277296
}
278297
}
279298
},
280-
"android": {
281-
"executor": "@nativescript/nx:build",
299+
"prepare": {
300+
"executor": "@nativescript/nx:prepare",
282301
"options": {
283-
"platform": "android"
302+
"noHmr": true,
303+
"production": true,
304+
"uglify": true,
305+
"release": true,
306+
"forDevice": true,
307+
"prepare": true
284308
},
285309
"configurations": {
286-
"build": {
287-
"aab": true,
288-
"keyStorePath": "./tools/keystore.jks",
289-
"keyStorePassword": "your-password",
290-
"keyStoreAlias": "keystore-alias",
291-
"keyStoreAliasPassword": "keystore-alias-password",
292-
"copyTo": "./dist/build.aab"
293-
},
294310
"prod": {
295-
"combineWithConfig": "build:prod"
311+
"fileReplacements": [
312+
{
313+
"replace": "./src/environments/environment.ts",
314+
"with": "./src/environments/environment.prod.ts"
315+
}
316+
]
296317
}
297318
}
298319
},
299-
"test": {
300-
"executor": "@nativescript/nx:test",
301-
"outputs": ["coverage/apps/nativescript-mobile"],
320+
"clean": {
321+
"executor": "@nativescript/nx:clean",
322+
"options": {}
323+
},
324+
"lint": {
325+
"executor": "@nx/linter:eslint",
302326
"options": {
303-
"coverage": false
304-
},
305-
"configurations": {
306-
"android": {},
307-
"ios": {}
327+
"lintFilePatterns": [
328+
"apps/nativescript-app/**/*.ts",
329+
"apps/nativescript-app/src/**/*.html"
330+
]
308331
}
309332
},
310-
"clean": {
311-
"executor": "@nativescript/nx:build",
333+
"test": {
334+
"executor": "@nativescript/nx:test",
335+
"outputs": [
336+
"coverage/apps/nativescript-app"
337+
],
312338
"options": {
313-
"clean": true
314-
}
339+
"coverage": true
340+
},
341+
"configurations": {}
315342
}
316343
}
317344
}
@@ -322,33 +349,33 @@ Here's an example app config:
322349
**Android:**
323350

324351
```sh
325-
npx nx run <app-name>:android:prod
352+
npx nx debug <app-name> android -c=prod
326353
```
327354

328355
**iOS:** (Mac only)
329356

330357
```sh
331-
npx nx run <app-name>:ios:prod
358+
npx nx debug <app-name> ios -c=prod
332359
```
333360

334361
#### Run tests
335362

336363
**Android:**
337364

338365
```sh
339-
npx nx run <app-name>:test:android
366+
npx nx test <app-name> android
340367
```
341368

342369
**iOS:** (Mac only)
343370

344371
```sh
345-
npx nx run <app-name>:test:ios
372+
npx nx test <app-name> ios
346373
```
347374

348375
You can generate coverage reports by using the flag with iOS or Android, for example:
349376

350377
```sh
351-
npx nx run <app-name>:test:ios --coverage
378+
npx nx test <app-name> ios --coverage
352379
```
353380

354381
You can also set this option in the config, for example:
@@ -380,15 +407,15 @@ Build with an environment configuration enabled (for example, with `prod`):
380407
**Android:**
381408

382409
```sh
383-
npx nx run <app-name>:build:prod --platform=android
410+
npx nx build <app-name> android --c=prod
384411
```
385412

386413
You can pass additional NativeScript CLI options as flags on the end of you build command.
387414

388415
* example of building AAB bundle for upload to Google Play:
389416

390417
```
391-
npx nx run <app-name>:build:prod --platform=android \
418+
npx nx build <app-name> android --c=prod \
392419
--aab \
393420
--key-store-path=<path-to-your-keystore> \
394421
--key-store-password=<your-key-store-password> \
@@ -400,15 +427,15 @@ npx nx run <app-name>:build:prod --platform=android \
400427
**iOS:** (Mac only)
401428

402429
```sh
403-
npx nx run <app-name>:build:prod --platform=ios
430+
npx nx build <app-name> iod --c=prod
404431
```
405432

406433
As mentioned, you can pass any additional NativeScript CLI options as flags on the end of your nx build command:
407434

408435
* example of building IPA for upload to iOS TestFlight:
409436

410437
```
411-
npx nx run <app-name>:build:prod --platform=ios \
438+
npx nx build <app-name> ios --c=prod \
412439
--provision <provisioning-profile-name> \
413440
--copy-to ./dist/build.ipa
414441
```
@@ -418,7 +445,7 @@ npx nx run <app-name>:build:prod --platform=ios \
418445
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.
419446

420447
```sh
421-
npx nx run <app-name>:clean
448+
npx nx clean <app-name>
422449
```
423450

424451
## Create NativeScript library

packages/nx/executors.json

Lines changed: 49 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,65 @@
33
"executors": {
44
"build": {
55
"implementation": "./src/executors/build/executor",
6-
"schema": "./src/executors/build/schema.json",
7-
"description": "NativeScript builder"
6+
"schema": "./src/executors/build/build.schema.json",
7+
"description": "NativeScript executor"
8+
},
9+
"debug": {
10+
"implementation": "./src/executors/build/executor",
11+
"schema": "./src/executors/build/debug.schema.json",
12+
"description": "NativeScript debug executor"
13+
},
14+
"run": {
15+
"implementation": "./src/executors/build/executor",
16+
"schema": "./src/executors/build/run.schema.json",
17+
"description": "NativeScript run executor"
18+
},
19+
"prepare": {
20+
"implementation": "./src/executors/build/executor",
21+
"schema": "./src/executors/build/prepare.schema.json",
22+
"description": "NativeScript prepare executor"
823
},
924
"test": {
10-
"implementation": "./src/executors/test/executor",
11-
"schema": "./src/executors/test/schema.json",
25+
"implementation": "./src/executors/build/executor",
26+
"schema": "./src/executors/build/test.schema.json",
1227
"description": "Start the NativeScript unit test runner"
28+
},
29+
"clean": {
30+
"implementation": "./src/executors/build/executor",
31+
"schema": "./src/executors/build/clean.schema.json",
32+
"description": "NativeScript clean executor"
1333
}
1434
},
1535
"builders": {
1636
"build": {
1737
"implementation": "./src/executors/build/builder",
18-
"schema": "./src/executors/build/schema.json",
19-
"description": "build executor"
38+
"schema": "./src/executors/build/build.schema.json",
39+
"description": "NativeScript build builder"
40+
},
41+
"debug": {
42+
"implementation": "./src/executors/build/builder",
43+
"schema": "./src/executors/build/debug.schema.json",
44+
"description": "NativeScript debug builder"
45+
},
46+
"run": {
47+
"implementation": "./src/executors/build/builder",
48+
"schema": "./src/executors/build/run.schema.json",
49+
"description": "NativeScript run builder"
50+
},
51+
"prepare": {
52+
"implementation": "./src/executors/build/builder",
53+
"schema": "./src/executors/build/prepare.schema.json",
54+
"description": "NativeScript prepare builder"
2055
},
2156
"test": {
22-
"implementation": "./src/executors/test/builder",
23-
"schema": "./src/executors/test/schema.json",
24-
"description": "test executor"
57+
"implementation": "./src/executors/build/builder",
58+
"schema": "./src/executors/build/test.schema.json",
59+
"description": "NativeScript test builder"
60+
},
61+
"clean": {
62+
"implementation": "./src/executors/build/builder",
63+
"schema": "./src/executors/build/clean.schema.json",
64+
"description": "NativeScript clean builder"
2565
}
2666
}
2767
}

packages/nx/project.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,19 @@
2020
"jestConfig": "packages/nx/jest.config.ts"
2121
}
2222
},
23+
"prepare": {
24+
"executor": "nx:run-commands",
25+
"options": {
26+
"commands": [
27+
{
28+
"command": "ts-node -P ./packages/nx/tsconfig.lib.json ./packages/nx/src/utils/generate-schemas.ts"
29+
},
30+
{
31+
"command": "nx build nx"
32+
}
33+
]
34+
}
35+
},
2336
"build": {
2437
"executor": "@nx/js:tsc",
2538
"outputs": ["{options.outputPath}"],

0 commit comments

Comments
 (0)