@nstudio/xplat-utils 19.0.0 → 20.0.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 +0 -1
- package/package.json +1 -1
- package/src/utils/utils.js +19 -19
package/README.md
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
<p align="center"><img src="https://raw.githubusercontent.com/nstudio/xplat/master/xplat-logo.png" align="center" width="400"></p>
|
3
3
|
<div align="center">
|
4
4
|
|
5
|
-
[](https://travis-ci.org/nstudio/xplat)
|
6
5
|
[]()
|
7
6
|
[](https://www.npmjs.com/@nstudio/schematics)
|
8
7
|
|
package/package.json
CHANGED
package/src/utils/utils.js
CHANGED
@@ -1,6 +1,24 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.copy = exports.supportedFrameworks = exports.supportedPlatformsWithNx = exports.supportedNxExtraPlatforms = exports.supportedPlatforms = void 0;
|
4
|
+
exports.getNpmScope = getNpmScope;
|
5
|
+
exports.getPrefix = getPrefix;
|
6
|
+
exports.getFrontendFramework = getFrontendFramework;
|
7
|
+
exports.getGroupByName = getGroupByName;
|
8
|
+
exports.getAppName = getAppName;
|
9
|
+
exports.isXplatWorkspace = isXplatWorkspace;
|
10
|
+
exports.setTest = setTest;
|
11
|
+
exports.isTesting = isTesting;
|
12
|
+
exports.jsonParse = jsonParse;
|
13
|
+
exports.getJsonFromFile = getJsonFromFile;
|
14
|
+
exports.updateJsonFile = updateJsonFile;
|
15
|
+
exports.updateFile = updateFile;
|
16
|
+
exports.getRootTsConfigPath = getRootTsConfigPath;
|
17
|
+
exports.getAppPaths = getAppPaths;
|
18
|
+
exports.prerun = prerun;
|
19
|
+
exports.sanitizeCommaDelimitedArg = sanitizeCommaDelimitedArg;
|
20
|
+
exports.parseProjectNameFromPath = parseProjectNameFromPath;
|
21
|
+
exports.toFileName = toFileName;
|
4
22
|
const schematics_1 = require("@angular-devkit/schematics");
|
5
23
|
const devkit_1 = require("@nx/devkit");
|
6
24
|
exports.supportedPlatforms = [
|
@@ -43,37 +61,29 @@ function getNpmScope(tree) {
|
|
43
61
|
return npmScope;
|
44
62
|
}
|
45
63
|
}
|
46
|
-
exports.getNpmScope = getNpmScope;
|
47
64
|
function getPrefix() {
|
48
65
|
return prefix;
|
49
66
|
}
|
50
|
-
exports.getPrefix = getPrefix;
|
51
67
|
function getFrontendFramework() {
|
52
68
|
return frontendFramework;
|
53
69
|
}
|
54
|
-
exports.getFrontendFramework = getFrontendFramework;
|
55
70
|
function getGroupByName() {
|
56
71
|
return groupByName;
|
57
72
|
}
|
58
|
-
exports.getGroupByName = getGroupByName;
|
59
73
|
function getAppName(options, platform) {
|
60
74
|
return groupByName
|
61
75
|
? options.name.replace(`-${platform}`, '')
|
62
76
|
: options.name.replace(`${platform}-`, '');
|
63
77
|
}
|
64
|
-
exports.getAppName = getAppName;
|
65
78
|
function isXplatWorkspace() {
|
66
79
|
return usingXplatWorkspace;
|
67
80
|
}
|
68
|
-
exports.isXplatWorkspace = isXplatWorkspace;
|
69
81
|
function setTest() {
|
70
82
|
isTest = true;
|
71
83
|
}
|
72
|
-
exports.setTest = setTest;
|
73
84
|
function isTesting() {
|
74
85
|
return isTest;
|
75
86
|
}
|
76
|
-
exports.isTesting = isTesting;
|
77
87
|
function jsonParse(content) {
|
78
88
|
if (content) {
|
79
89
|
// ensure comments are stripped when parsing (otherwise will fail)
|
@@ -81,12 +91,10 @@ function jsonParse(content) {
|
|
81
91
|
}
|
82
92
|
return {};
|
83
93
|
}
|
84
|
-
exports.jsonParse = jsonParse;
|
85
94
|
function getJsonFromFile(tree, path) {
|
86
95
|
// console.log('getJsonFromFile:', path)
|
87
96
|
return jsonParse(tree.get(path).content.toString());
|
88
97
|
}
|
89
|
-
exports.getJsonFromFile = getJsonFromFile;
|
90
98
|
function updateJsonFile(tree, path, jsonData) {
|
91
99
|
try {
|
92
100
|
if (tree.exists(path)) {
|
@@ -102,7 +110,6 @@ function updateJsonFile(tree, path, jsonData) {
|
|
102
110
|
throw new schematics_1.SchematicsException(`${path}: ${err}`);
|
103
111
|
}
|
104
112
|
}
|
105
|
-
exports.updateJsonFile = updateJsonFile;
|
106
113
|
function updateFile(tree, path, content) {
|
107
114
|
try {
|
108
115
|
if (tree.exists(path)) {
|
@@ -118,7 +125,6 @@ function updateFile(tree, path, content) {
|
|
118
125
|
throw new schematics_1.SchematicsException(`${path}: ${err}`);
|
119
126
|
}
|
120
127
|
}
|
121
|
-
exports.updateFile = updateFile;
|
122
128
|
const copy = (tree, from, to) => {
|
123
129
|
const file = tree.get(from);
|
124
130
|
if (!file) {
|
@@ -130,7 +136,6 @@ exports.copy = copy;
|
|
130
136
|
function getRootTsConfigPath() {
|
131
137
|
return '/tsconfig.base.json';
|
132
138
|
}
|
133
|
-
exports.getRootTsConfigPath = getRootTsConfigPath;
|
134
139
|
function getAppPaths(tree, type // by default, will return all app paths (considering folder nesting)
|
135
140
|
) {
|
136
141
|
const appsDir = tree.getDir('apps');
|
@@ -201,7 +206,6 @@ function getAppPaths(tree, type // by default, will return all app paths (consid
|
|
201
206
|
}
|
202
207
|
return appPaths;
|
203
208
|
}
|
204
|
-
exports.getAppPaths = getAppPaths;
|
205
209
|
function prerun(options, init) {
|
206
210
|
return (tree) => {
|
207
211
|
npmScope = getNpmScope(tree) || 'workspace';
|
@@ -280,7 +284,6 @@ function prerun(options, init) {
|
|
280
284
|
return tree;
|
281
285
|
};
|
282
286
|
}
|
283
|
-
exports.prerun = prerun;
|
284
287
|
function sanitizeCommaDelimitedArg(input) {
|
285
288
|
if (input) {
|
286
289
|
return input
|
@@ -290,18 +293,15 @@ function sanitizeCommaDelimitedArg(input) {
|
|
290
293
|
}
|
291
294
|
return [];
|
292
295
|
}
|
293
|
-
exports.sanitizeCommaDelimitedArg = sanitizeCommaDelimitedArg;
|
294
296
|
function parseProjectNameFromPath(input) {
|
295
297
|
if (input && input.indexOf('/') > -1) {
|
296
298
|
input = input.split('/').pop();
|
297
299
|
}
|
298
300
|
return input;
|
299
301
|
}
|
300
|
-
exports.parseProjectNameFromPath = parseProjectNameFromPath;
|
301
302
|
function toFileName(s) {
|
302
303
|
return s
|
303
304
|
.replace(/([a-z\d])([A-Z])/g, '$1_$2')
|
304
305
|
.toLowerCase()
|
305
306
|
.replace(/[ _]/g, '-');
|
306
307
|
}
|
307
|
-
exports.toFileName = toFileName;
|