@nstudio/xplat 15.0.4-rc.0 → 16.2.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -13
- package/collection.json +1 -1
- package/package.json +5 -3
- package/src/schematics/application/index.spec.js +1 -1
- package/src/schematics/init/index.spec.js +2 -2
- package/src/utils/ast.d.ts +2 -2
- package/src/utils/ast.js +5 -7
- package/src/utils/general.d.ts +2 -2
- package/src/utils/general.js +1 -1
- package/src/utils/testing-utils.d.ts +1 -1
- package/src/utils/testing-utils.js +1 -1
- package/src/utils/versions.d.ts +1 -1
- package/src/utils/versions.js +2 -2
- package/src/utils/xplat.js +13 -13
package/README.md
CHANGED
@@ -24,13 +24,19 @@
|
|
24
24
|
|
25
25
|
```
|
26
26
|
npx create-nx-workspace@latest
|
27
|
-
```
|
28
27
|
|
29
|
-
|
28
|
+
// Choose "Integrated monorepo" at the prompt:
|
29
|
+
|
30
|
+
? Choose what to create …
|
31
|
+
> Integrated monorepo: Nx configures your favorite frameworks and lets you focus on shipping features.
|
30
32
|
|
31
|
-
|
33
|
+
// Choose "apps" at the prompt:
|
34
|
+
|
35
|
+
? What to create in the new workspace …
|
36
|
+
> apps [an empty monorepo with no plugins with a layout that works best for building apps]
|
37
|
+
```
|
32
38
|
|
33
|
-
|
39
|
+
Install the tools:
|
34
40
|
|
35
41
|
```
|
36
42
|
npm i @nstudio/xplat -D
|
@@ -39,7 +45,7 @@ npm i @nstudio/xplat -D
|
|
39
45
|
You are now ready to create apps:
|
40
46
|
|
41
47
|
```
|
42
|
-
nx g app
|
48
|
+
npx nx g @nstudio/xplat:app
|
43
49
|
```
|
44
50
|
|
45
51
|
**NOTE:** If you encounter any issue, you can try creating an Nx workspace with version specified, for example:
|
@@ -59,7 +65,7 @@ Electron app generator can use any web app in the workspace as it's target.
|
|
59
65
|
If you don't have a web app yet, create one first:
|
60
66
|
|
61
67
|
```
|
62
|
-
nx g app sample
|
68
|
+
npx nx g @nstudio/xplat:app sample
|
63
69
|
```
|
64
70
|
|
65
71
|
> choose `web`
|
@@ -67,7 +73,7 @@ nx g app sample
|
|
67
73
|
You can now use the web app as the Electron target:
|
68
74
|
|
69
75
|
```
|
70
|
-
nx g app desktop --target=web-sample
|
76
|
+
npx nx g @nstudio/xplat:app desktop --target=web-sample
|
71
77
|
```
|
72
78
|
|
73
79
|
> choose `electron`
|
@@ -81,7 +87,7 @@ npm run start.electron.desktop
|
|
81
87
|
### Ionic
|
82
88
|
|
83
89
|
```
|
84
|
-
nx g app sample
|
90
|
+
npx nx g @nstudio/xplat:app sample
|
85
91
|
```
|
86
92
|
|
87
93
|
> choose `ionic`
|
@@ -89,13 +95,13 @@ nx g app sample
|
|
89
95
|
Develop in browser with:
|
90
96
|
|
91
97
|
```
|
92
|
-
nx serve ionic-sample
|
98
|
+
npx nx serve ionic-sample
|
93
99
|
```
|
94
100
|
|
95
101
|
Build Ionic app:
|
96
102
|
|
97
103
|
```
|
98
|
-
nx build ionic-sample
|
104
|
+
npx nx build ionic-sample
|
99
105
|
```
|
100
106
|
|
101
107
|
A. **Capacitor iOS** - Prepare for development
|
@@ -125,7 +131,7 @@ npm run open.ionic.sample.android
|
|
125
131
|
### NativeScript
|
126
132
|
|
127
133
|
```
|
128
|
-
nx g app mobile
|
134
|
+
nx g @nstudio/xplat:app mobile
|
129
135
|
```
|
130
136
|
|
131
137
|
> choose `nativescript`
|
@@ -133,13 +139,13 @@ nx g app mobile
|
|
133
139
|
A. **iOS**
|
134
140
|
|
135
141
|
```
|
136
|
-
nx run nativescript-mobile:ios
|
142
|
+
npx nx run nativescript-mobile:ios
|
137
143
|
```
|
138
144
|
|
139
145
|
B. **Android**
|
140
146
|
|
141
147
|
```
|
142
|
-
nx run nativescript-mobile:android
|
148
|
+
npx nx run nativescript-mobile:android
|
143
149
|
```
|
144
150
|
|
145
151
|
## Documentation
|
package/collection.json
CHANGED
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nstudio/xplat",
|
3
|
-
"version": "
|
3
|
+
"version": "16.2.0-beta.0",
|
4
4
|
"description": "Cross-platform (xplat) tools for Nx workspaces.",
|
5
5
|
"homepage": "https://nstudio.io/xplat",
|
6
6
|
"repository": {
|
@@ -41,8 +41,10 @@
|
|
41
41
|
"postinstall": "node src/utils/postinstall.js"
|
42
42
|
},
|
43
43
|
"dependencies": {
|
44
|
-
"@
|
45
|
-
"@
|
44
|
+
"@nx/devkit": "^16.0.0",
|
45
|
+
"@nx/js": "^16.0.0",
|
46
|
+
"@nstudio/focus": "16.2.0-beta.0",
|
47
|
+
"@nstudio/xplat-utils": "16.2.0-beta.0"
|
46
48
|
},
|
47
49
|
"author": "Nathan Walker",
|
48
50
|
"license": "MIT",
|
@@ -13,7 +13,7 @@ const schematics_1 = require("@angular-devkit/schematics");
|
|
13
13
|
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
14
14
|
const testing_1 = require("@nstudio/xplat/testing");
|
15
15
|
const testing_2 = require("../../utils/testing");
|
16
|
-
const testing_3 = require("@
|
16
|
+
const testing_3 = require("@nx/workspace/testing");
|
17
17
|
(0, xplat_utils_1.setTest)();
|
18
18
|
describe('xplat schematic', () => {
|
19
19
|
let appTree;
|
@@ -14,7 +14,7 @@ const xplat_utils_1 = require("@nstudio/xplat-utils");
|
|
14
14
|
const testing_1 = require("@nstudio/xplat/testing");
|
15
15
|
const testing_2 = require("../../utils/testing");
|
16
16
|
const utils_1 = require("../../utils");
|
17
|
-
const testing_3 = require("@
|
17
|
+
const testing_3 = require("@nx/workspace/testing");
|
18
18
|
(0, xplat_utils_1.setTest)();
|
19
19
|
describe('xplat init', () => {
|
20
20
|
let appTree;
|
@@ -36,7 +36,7 @@ describe('xplat init', () => {
|
|
36
36
|
let packageJson = JSON.parse((0, testing_3.getFileContent)(tree, 'package.json'));
|
37
37
|
// console.log(packageJson);
|
38
38
|
const devDeps = [
|
39
|
-
'@
|
39
|
+
'@nx/angular',
|
40
40
|
'@nstudio/angular',
|
41
41
|
'@nstudio/web-angular',
|
42
42
|
'@nstudio/web',
|
package/src/utils/ast.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import * as ts from 'typescript';
|
2
|
-
import { Tree } from '@
|
2
|
+
import { Tree } from '@nx/devkit';
|
3
3
|
import { Tree as NgTree } from '@angular-devkit/schematics';
|
4
|
-
export declare function addGlobal(tree: Tree, source: ts.SourceFile, modulePath: string, statement: string, isExport?: boolean): ts.SourceFile
|
4
|
+
export declare function addGlobal(tree: Tree, source: ts.SourceFile, modulePath: string, statement: string, isExport?: boolean): ts.SourceFile;
|
5
5
|
export declare function insert(host: NgTree, modulePath: string, changes: any[]): void;
|
package/src/utils/ast.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.insert = exports.addGlobal = void 0;
|
4
|
-
const js_1 = require("@
|
4
|
+
const js_1 = require("@nx/js");
|
5
5
|
const typescript_1 = require("nx/src/utils/typescript");
|
6
6
|
const ts = require("typescript");
|
7
7
|
const general_1 = require("./general");
|
@@ -12,22 +12,20 @@ function addGlobal(tree, source, modulePath, statement, isExport) {
|
|
12
12
|
if (allExports.length > 0) {
|
13
13
|
const lastExport = allExports[allExports.length - 1];
|
14
14
|
// console.log('lastExport.end:', lastExport.end);
|
15
|
-
return
|
15
|
+
return (0, js_1.insertChange)(tree, source, modulePath, lastExport.end, `\n${statement}\n`);
|
16
16
|
}
|
17
17
|
else {
|
18
|
-
return
|
18
|
+
return (0, js_1.insertChange)(tree, source, modulePath, 0, `${statement}\n`);
|
19
19
|
}
|
20
20
|
}
|
21
21
|
else {
|
22
22
|
const allImports = (0, typescript_1.findNodes)(source, ts.SyntaxKind.ImportDeclaration);
|
23
23
|
if (allImports.length > 0) {
|
24
24
|
const lastImport = allImports[allImports.length - 1];
|
25
|
-
return
|
26
|
-
(0, js_1.insertChange)(tree, source, modulePath, lastImport.end + 1, `\n${statement}\n`),
|
27
|
-
];
|
25
|
+
return (0, js_1.insertChange)(tree, source, modulePath, lastImport.end + 1, `\n${statement}\n`);
|
28
26
|
}
|
29
27
|
else {
|
30
|
-
return
|
28
|
+
return (0, js_1.insertChange)(tree, source, modulePath, 0, `${statement}\n`);
|
31
29
|
}
|
32
30
|
}
|
33
31
|
}
|
package/src/utils/general.d.ts
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
import { Tree as NgTree } from '@angular-devkit/schematics';
|
4
4
|
import { PlatformTypes, FrameworkTypes, ITargetPlatforms } from '@nstudio/xplat-utils';
|
5
5
|
import type { Mode } from 'fs';
|
6
|
-
import
|
6
|
+
import { FileChange, Tree as DevKitTree } from '@nx/devkit';
|
7
7
|
export interface NodeDependency {
|
8
8
|
name: string;
|
9
9
|
version: string;
|
@@ -106,7 +106,7 @@ export declare class DevkitTreeFromAngularDevkitTree implements DevKitTree {
|
|
106
106
|
read(filePath: string): Buffer;
|
107
107
|
read(filePath: string, encoding: BufferEncoding): string;
|
108
108
|
rename(from: string, to: string): void;
|
109
|
-
write(filePath: string, content: Buffer | string, options?:
|
109
|
+
write(filePath: string, content: Buffer | string, options?: Parameters<DevKitTree['write']>[2]): void;
|
110
110
|
changePermissions(filePath: string, mode: Mode): void;
|
111
111
|
private warnUnsupportedFilePermissionsChange;
|
112
112
|
}
|
package/src/utils/general.js
CHANGED
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
10
10
|
};
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
12
12
|
exports.DevkitTreeFromAngularDevkitTree = exports.convertNgTreeToDevKit = exports.actionToFileChangeMap = exports.toNgModuleClassName = exports.toComponentClassName = exports.stringUtils = exports.sanitize = exports.getDefaultTemplateOptions = exports.getPrefixWarning = exports.readWorkspaceJson = exports.updatePackageScripts = exports.updateTsConfig = exports.updatePackageForNgrx = exports.hasWebPlatform = exports.hasFrontendPlatform = exports.supportedSandboxPlatforms = exports.supportedHelpers = void 0;
|
13
|
-
const workspace_1 = require("@
|
13
|
+
const workspace_1 = require("@nx/workspace");
|
14
14
|
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
15
15
|
const path_1 = require("path");
|
16
16
|
// list of all supported helpers
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Tree } from '@angular-devkit/schematics';
|
2
2
|
import { FrameworkTypes } from '@nstudio/xplat-utils';
|
3
|
-
export { getFileContent } from '@
|
3
|
+
export { getFileContent } from '@nx/workspace/testing';
|
4
4
|
export declare function createEmptyWorkspace(tree: Tree, framework?: FrameworkTypes): Tree;
|
5
5
|
export declare function createXplatWithAppsForElectron(tree: Tree): Tree;
|
6
6
|
export declare function createXplatWithApps(tree: Tree, framework?: FrameworkTypes): Tree;
|
@@ -1,7 +1,7 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.isInDecoratorMetadata = exports.isInComponentMetadata = exports.isInModuleMetadata = exports.createNativeScriptAngularApp = exports.createWebAngularApp = exports.createXplatWebAngular = exports.createXplatNativeScriptAngular = exports.createXplatLibs = exports.createNxLib = exports.createXplatWithNativeScriptWeb = exports.createXplatWithApps = exports.createXplatWithAppsForElectron = exports.createEmptyWorkspace = exports.getFileContent = void 0;
|
4
|
-
var testing_1 = require("@
|
4
|
+
var testing_1 = require("@nx/workspace/testing");
|
5
5
|
Object.defineProperty(exports, "getFileContent", { enumerable: true, get: function () { return testing_1.getFileContent; } });
|
6
6
|
function createEmptyWorkspace(tree, framework) {
|
7
7
|
tree.create('/.gitignore', '');
|
package/src/utils/versions.d.ts
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
export declare const xplatVersion = "*";
|
2
|
-
export declare const nxVersion = "^
|
2
|
+
export declare const nxVersion = "^16.0.0";
|
package/src/utils/versions.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
exports.nxVersion = exports.xplatVersion = void 0;
|
4
|
-
exports.xplatVersion = '
|
5
|
-
exports.nxVersion = '^
|
4
|
+
exports.xplatVersion = '16.2.0-beta.0';
|
5
|
+
exports.nxVersion = '^16.0.0';
|
package/src/utils/xplat.js
CHANGED
@@ -11,24 +11,24 @@ const tasks_1 = require("@angular-devkit/schematics/tasks");
|
|
11
11
|
const versions_1 = require("./versions");
|
12
12
|
const output_1 = require("./output");
|
13
13
|
exports.packageInnerDependencies = {
|
14
|
-
'@nstudio/angular': ['@
|
14
|
+
'@nstudio/angular': ['@nx/angular'],
|
15
15
|
'@nstudio/electron-angular': [
|
16
|
-
'@
|
16
|
+
'@nx/angular',
|
17
17
|
'@nstudio/electron',
|
18
18
|
'@nstudio/angular',
|
19
19
|
],
|
20
20
|
'@nstudio/ionic-angular': [
|
21
|
-
'@
|
21
|
+
'@nx/angular',
|
22
22
|
'@nstudio/ionic',
|
23
23
|
'@nstudio/angular',
|
24
24
|
'@nstudio/web-angular',
|
25
25
|
],
|
26
26
|
'@nstudio/nativescript-angular': [
|
27
|
-
'@
|
27
|
+
'@nx/angular',
|
28
28
|
'@nstudio/nativescript',
|
29
29
|
'@nstudio/angular',
|
30
30
|
],
|
31
|
-
'@nstudio/web-angular': ['@
|
31
|
+
'@nstudio/web-angular': ['@nx/angular', '@nstudio/web', '@nstudio/angular'],
|
32
32
|
};
|
33
33
|
var XplatHelpers;
|
34
34
|
(function (XplatHelpers) {
|
@@ -197,7 +197,7 @@ var XplatHelpers;
|
|
197
197
|
xplat_utils_1.supportedNxExtraPlatforms.includes(platform)) {
|
198
198
|
// platforms that are supported directly via Nx only right now
|
199
199
|
// 'app'/'application' is only schematic supported via xplat proxy at moment
|
200
|
-
const packageName = `@
|
200
|
+
const packageName = `@nx/${platform}`;
|
201
201
|
devDependencies[packageName] = versions_1.nxVersion;
|
202
202
|
packagesToRunXplat.push(packageName);
|
203
203
|
}
|
@@ -227,7 +227,7 @@ var XplatHelpers;
|
|
227
227
|
xplat_utils_1.supportedNxExtraPlatforms.includes(platform)) {
|
228
228
|
// platforms supported directly via Nx only right now
|
229
229
|
// 'app'/'application' is only schematic supported via xplat proxy at moment
|
230
|
-
const packageName = `@
|
230
|
+
const packageName = `@nx/${platform}`;
|
231
231
|
devDependencies[packageName] = versions_1.nxVersion;
|
232
232
|
packagesToRunXplat.push(packageName);
|
233
233
|
}
|
@@ -316,7 +316,7 @@ var XplatHelpers;
|
|
316
316
|
else if (xplat_utils_1.supportedNxExtraPlatforms.includes(platform)) {
|
317
317
|
// platforms supported directly via Nx only right now
|
318
318
|
// 'app'/'application' is only schematic supported via xplat proxy at moment
|
319
|
-
const packageName = `@
|
319
|
+
const packageName = `@nx/${platform}`;
|
320
320
|
devDependencies[packageName] = versions_1.nxVersion;
|
321
321
|
packagesToRun.push(packageName);
|
322
322
|
}
|
@@ -373,7 +373,7 @@ var XplatHelpers;
|
|
373
373
|
}
|
374
374
|
if (packagesToRun.length) {
|
375
375
|
for (const packageName of packagesToRun) {
|
376
|
-
const nxPlatform = (packageName.replace('@
|
376
|
+
const nxPlatform = (packageName.replace('@nx/', ''));
|
377
377
|
const { name, directory } = getAppNamingConvention(options, nxPlatform);
|
378
378
|
output_1.output.log({
|
379
379
|
title: 'Note:',
|
@@ -398,7 +398,7 @@ var XplatHelpers;
|
|
398
398
|
// console.log('devDependencies:', devDependencies);
|
399
399
|
// console.log('packagesToRunXplat:', packagesToRunXplat);
|
400
400
|
for (const packageName of packagesToRun) {
|
401
|
-
const nxPlatform = (packageName.replace('@
|
401
|
+
const nxPlatform = (packageName.replace('@nx/', ''));
|
402
402
|
const { name, directory } = getAppNamingConvention(options, nxPlatform);
|
403
403
|
output_1.output.log({
|
404
404
|
title: 'Note:',
|
@@ -452,7 +452,7 @@ var XplatHelpers;
|
|
452
452
|
directory = `${directory}-${framework}`;
|
453
453
|
}
|
454
454
|
if (tree.exists(`libs/${directory ? directory + '/' : ''}${libName}/tsconfig.json`)) {
|
455
|
-
// console.log(`externalSchematic('@
|
455
|
+
// console.log(`externalSchematic('@nx/workspace', 'lib') ALREADY EXISTS for:`, `libs/${directory ? directory + '/' : ''}${libName}`)
|
456
456
|
return (0, schematics_1.noop)()(tree, context);
|
457
457
|
}
|
458
458
|
const libOptions = {
|
@@ -464,8 +464,8 @@ var XplatHelpers;
|
|
464
464
|
if (libName === 'scss') {
|
465
465
|
libOptions.skipTsConfig = true;
|
466
466
|
}
|
467
|
-
// console.log(`CALLING externalSchematic('@
|
468
|
-
return (0, schematics_1.chain)([(0, schematics_1.externalSchematic)('@
|
467
|
+
// console.log(`CALLING externalSchematic('@nx/workspace', 'lib') for:`, `libs/${directory ? directory + '/' : ''}${libName}`)
|
468
|
+
return (0, schematics_1.chain)([(0, schematics_1.externalSchematic)('@nx/js', 'library', libOptions)]);
|
469
469
|
};
|
470
470
|
}
|
471
471
|
XplatHelpers.generateLib = generateLib;
|