@nstudio/xplat-utils 16.5.0 → 16.5.1
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 +8 -6
- package/package.json +1 -1
- package/src/utils/utils.d.ts +1 -2
- package/src/utils/utils.js +18 -19
package/README.md
CHANGED
@@ -25,15 +25,17 @@
|
|
25
25
|
```
|
26
26
|
npx create-nx-workspace@latest
|
27
27
|
|
28
|
-
|
28
|
+
✔ Where would you like to create your workspace? · {your-workspace-name}
|
29
29
|
|
30
|
-
|
31
|
-
> Integrated monorepo: Nx configures your favorite frameworks and lets you focus on shipping features.
|
30
|
+
// 1. Choose "None" at the prompt:
|
32
31
|
|
33
|
-
|
32
|
+
? Which stack do you want to use? …
|
33
|
+
None: Configures a minimal structure without specific frameworks or technologies.
|
34
34
|
|
35
|
-
|
36
|
-
|
35
|
+
// 2. Choose "Integrated" at the prompt:
|
36
|
+
|
37
|
+
? Package-based or integrated? …
|
38
|
+
Integrated: Nx creates a workspace structure most suitable for building apps.
|
37
39
|
```
|
38
40
|
|
39
41
|
Install the tools:
|
package/package.json
CHANGED
package/src/utils/utils.d.ts
CHANGED
@@ -4,7 +4,7 @@ export declare const supportedPlatforms: Array<PlatformTypes>;
|
|
4
4
|
export declare const supportedNxExtraPlatforms: Array<PlatformNxExtraTypes>;
|
5
5
|
export declare const supportedPlatformsWithNx: Array<PlatformWithNxTypes>;
|
6
6
|
export declare const supportedFrameworks: Array<FrameworkTypes>;
|
7
|
-
export declare function getNpmScope(): string;
|
7
|
+
export declare function getNpmScope(tree?: NgTree): string;
|
8
8
|
export declare function getPrefix(): string;
|
9
9
|
export declare function getFrontendFramework(): "angular";
|
10
10
|
export declare function getGroupByName(): boolean;
|
@@ -16,7 +16,6 @@ export declare function jsonParse(content: string): any;
|
|
16
16
|
export declare function getJsonFromFile(tree: NgTree, path: string): any;
|
17
17
|
export declare function updateJsonFile(tree: NgTree, path: string, jsonData: any): import("@angular-devkit/schematics/src/tree/interface").Tree;
|
18
18
|
export declare function updateFile(tree: NgTree, path: string, content: string): import("@angular-devkit/schematics/src/tree/interface").Tree;
|
19
|
-
export declare function getNxWorkspaceConfig(tree: NgTree): any;
|
20
19
|
export declare const copy: (tree: NgTree, from: string, to: string) => void;
|
21
20
|
export declare function getRootTsConfigPath(): string;
|
22
21
|
export declare function getAppPaths(tree: NgTree, type?: PlatformTypes): Array<string>;
|
package/src/utils/utils.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.toFileName = exports.parseProjectNameFromPath = exports.sanitizeCommaDelimitedArg = exports.prerun = exports.getAppPaths = exports.getRootTsConfigPath = exports.copy = exports.
|
3
|
+
exports.toFileName = exports.parseProjectNameFromPath = exports.sanitizeCommaDelimitedArg = exports.prerun = exports.getAppPaths = exports.getRootTsConfigPath = exports.copy = exports.updateFile = exports.updateJsonFile = exports.getJsonFromFile = exports.jsonParse = exports.isTesting = exports.setTest = exports.isXplatWorkspace = exports.getAppName = exports.getGroupByName = exports.getFrontendFramework = exports.getPrefix = exports.getNpmScope = exports.supportedFrameworks = exports.supportedPlatformsWithNx = exports.supportedNxExtraPlatforms = exports.supportedPlatforms = void 0;
|
4
4
|
const schematics_1 = require("@angular-devkit/schematics");
|
5
5
|
const devkit_1 = require("@nx/devkit");
|
6
6
|
exports.supportedPlatforms = [
|
@@ -26,8 +26,22 @@ let frontendFramework;
|
|
26
26
|
let groupByName = false;
|
27
27
|
let isTest = false;
|
28
28
|
let usingXplatWorkspace = false;
|
29
|
-
function getNpmScope() {
|
30
|
-
|
29
|
+
function getNpmScope(tree) {
|
30
|
+
var _a;
|
31
|
+
if (npmScope) {
|
32
|
+
return npmScope;
|
33
|
+
}
|
34
|
+
const nxJson = getJsonFromFile(tree, 'nx.json');
|
35
|
+
// TODO(v17): Remove reading this from nx.json
|
36
|
+
if (nxJson.npmScope) {
|
37
|
+
npmScope = nxJson.npmScope;
|
38
|
+
return npmScope;
|
39
|
+
}
|
40
|
+
const packageJson = getJsonFromFile(tree, 'package.json');
|
41
|
+
if ((_a = packageJson === null || packageJson === void 0 ? void 0 : packageJson.name) === null || _a === void 0 ? void 0 : _a.startsWith('@')) {
|
42
|
+
npmScope = packageJson.name.split('/')[0].substring(1);
|
43
|
+
return npmScope;
|
44
|
+
}
|
31
45
|
}
|
32
46
|
exports.getNpmScope = getNpmScope;
|
33
47
|
function getPrefix() {
|
@@ -105,18 +119,6 @@ function updateFile(tree, path, content) {
|
|
105
119
|
}
|
106
120
|
}
|
107
121
|
exports.updateFile = updateFile;
|
108
|
-
function getNxWorkspaceConfig(tree) {
|
109
|
-
const nxConfig = getJsonFromFile(tree, 'nx.json');
|
110
|
-
const hasWorkspaceDirs = tree.exists('apps') && tree.exists('libs');
|
111
|
-
// determine if Nx workspace
|
112
|
-
if (nxConfig) {
|
113
|
-
if (nxConfig.npmScope || hasWorkspaceDirs) {
|
114
|
-
return nxConfig;
|
115
|
-
}
|
116
|
-
}
|
117
|
-
throw new schematics_1.SchematicsException('@nstudio/xplat must be used inside an Nx workspace. Create a workspace first. https://nx.dev');
|
118
|
-
}
|
119
|
-
exports.getNxWorkspaceConfig = getNxWorkspaceConfig;
|
120
122
|
const copy = (tree, from, to) => {
|
121
123
|
const file = tree.get(from);
|
122
124
|
if (!file) {
|
@@ -202,10 +204,7 @@ function getAppPaths(tree, type // by default, will return all app paths (consid
|
|
202
204
|
exports.getAppPaths = getAppPaths;
|
203
205
|
function prerun(options, init) {
|
204
206
|
return (tree) => {
|
205
|
-
|
206
|
-
if (nxJson) {
|
207
|
-
npmScope = nxJson.npmScope || 'workspace';
|
208
|
-
}
|
207
|
+
npmScope = getNpmScope(tree) || 'workspace';
|
209
208
|
// console.log('npmScope:', npmScope);
|
210
209
|
const packageJson = getJsonFromFile(tree, 'package.json');
|
211
210
|
let frameworkChoice;
|