@nstudio/xplat-utils 16.5.0 → 16.5.2

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 CHANGED
@@ -22,24 +22,40 @@
22
22
 
23
23
  ## Quickstart
24
24
 
25
- ```
25
+ ```sh
26
26
  npx create-nx-workspace@latest
27
27
 
28
- // Choose "Integrated monorepo" at the prompt:
28
+ Where would you like to create your workspace? · {your-workspace-name}
29
+
30
+ # Choose "None"
31
+
32
+ ? Which stack do you want to use? …
33
+ None: Configures a minimal structure without specific frameworks or technologies.
29
34
 
30
- ? Choose what to create …
31
- > Integrated monorepo: Nx configures your favorite frameworks and lets you focus on shipping features.
35
+ # Choose "Integrated"
36
+
37
+ ? Package-based or integrated? …
38
+ Integrated: Nx creates a workspace structure most suitable for building apps.
39
+ ```
40
+
41
+ ### Init workspace
42
+
43
+ Install the @nx/js plugin.
44
+
45
+ ```sh
46
+ npm install @nx/js -D
47
+ ```
32
48
 
33
- // Choose "apps" at the prompt:
49
+ Now initialize -- This will ensure a `tsconfig.base.json` is created to begin building your workspace.
34
50
 
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]
51
+ ```sh
52
+ npx nx g @nx/js:init
37
53
  ```
38
54
 
39
- Install the tools:
55
+ ### Install the tools:
40
56
 
41
57
  ```
42
- npm i @nstudio/xplat -D
58
+ npm install @nstudio/xplat -D
43
59
  ```
44
60
 
45
61
  You are now ready to create apps:
@@ -51,7 +67,7 @@ npx nx g @nstudio/xplat:app
51
67
  **NOTE:** If you encounter any issue, you can try creating an Nx workspace with version specified, for example:
52
68
 
53
69
  ```
54
- npx create-nx-workspace@14.1.7
70
+ npx create-nx-workspace@16.5.0
55
71
  ```
56
72
 
57
73
  ## App generation examples
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nstudio/xplat-utils",
3
- "version": "16.5.0",
3
+ "version": "16.5.2",
4
4
  "description": "Utilities for xplat tooling.",
5
5
  "homepage": "https://nstudio.io/xplat",
6
6
  "repository": {
@@ -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>;
@@ -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.getNxWorkspaceConfig = 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;
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
- return npmScope;
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
- const nxJson = getNxWorkspaceConfig(tree);
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;