@nstudio/focus 12.7.0 → 13.4.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/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nstudio/focus",
|
3
|
-
"version": "
|
3
|
+
"version": "13.4.1",
|
4
4
|
"description": "Focus helpers for monorepos in various IDEs",
|
5
5
|
"homepage": "https://nstudio.io/xplat",
|
6
6
|
"repository": {
|
@@ -32,7 +32,7 @@
|
|
32
32
|
"dependencies": {
|
33
33
|
"@angular-devkit/core": "^12.0.0",
|
34
34
|
"@angular-devkit/schematics": "^12.0.0",
|
35
|
-
"@nstudio/xplat-utils": "
|
35
|
+
"@nstudio/xplat-utils": "13.4.1",
|
36
36
|
"xml2js": "~0.4.23"
|
37
37
|
}
|
38
38
|
}
|
@@ -8,7 +8,7 @@ let name;
|
|
8
8
|
function default_1(options) {
|
9
9
|
if (!options.name) {
|
10
10
|
name = 'fullstack';
|
11
|
-
const extraNote = xplat_utils_1.isXplatWorkspace()
|
11
|
+
const extraNote = (0, xplat_utils_1.isXplatWorkspace)()
|
12
12
|
? ` Currently supported: fullstack,${xplat_utils_1.supportedPlatformsWithNx}. Example: nx g mode nativescript`
|
13
13
|
: '';
|
14
14
|
console.warn(`Defaulting to 'fullstack' and showing everything since no focus was specified.${extraNote}`);
|
@@ -16,9 +16,9 @@ function default_1(options) {
|
|
16
16
|
else {
|
17
17
|
name = options.name;
|
18
18
|
}
|
19
|
-
return schematics_1.chain([
|
19
|
+
return (0, schematics_1.chain)([
|
20
20
|
// init xplat settings
|
21
|
-
xplat_utils_1.prerun(),
|
21
|
+
(0, xplat_utils_1.prerun)(),
|
22
22
|
// update tsconfig based on mode
|
23
23
|
// (tree: Tree) => {
|
24
24
|
// return isXplatWorkspace() ? updateExcludes(name)(tree) : noop();
|
@@ -26,7 +26,7 @@ function default_1(options) {
|
|
26
26
|
// update IDE settings
|
27
27
|
(tree, context) => {
|
28
28
|
// apps
|
29
|
-
const appPaths = xplat_utils_1.getAppPaths(tree);
|
29
|
+
const appPaths = (0, xplat_utils_1.getAppPaths)(tree);
|
30
30
|
const allApps = [];
|
31
31
|
for (const appPath of appPaths) {
|
32
32
|
allApps.push(`**${appPath}`);
|
@@ -54,7 +54,7 @@ function default_1(options) {
|
|
54
54
|
let focusOnApps = [];
|
55
55
|
if (name !== 'fullstack' && options.projects) {
|
56
56
|
focusOnApps = options.projects.split(',').map((p) => p.trim());
|
57
|
-
if (xplat_utils_1.isXplatWorkspace()) {
|
57
|
+
if ((0, xplat_utils_1.isXplatWorkspace)()) {
|
58
58
|
// allows for shorthand project/app names omitting platform from the app name
|
59
59
|
// just add platform to the name to be specific
|
60
60
|
for (let i = 0; i < focusOnApps.length; i++) {
|
package/src/utils/index.js
CHANGED
@@ -4,21 +4,21 @@ exports.FocusHelpers = void 0;
|
|
4
4
|
const xplat_utils_1 = require("@nstudio/xplat-utils");
|
5
5
|
const path_1 = require("path");
|
6
6
|
const fs_1 = require("fs");
|
7
|
-
const
|
7
|
+
const devkit_1 = require("@nrwl/devkit");
|
8
8
|
const xml2js = require("xml2js");
|
9
9
|
var FocusHelpers;
|
10
10
|
(function (FocusHelpers) {
|
11
11
|
function updateIDESettings(options) {
|
12
12
|
return (tree, context) => {
|
13
|
-
if (xplat_utils_1.isTesting()) {
|
13
|
+
if ((0, xplat_utils_1.isTesting)()) {
|
14
14
|
// ignore node file modifications when just testing
|
15
15
|
return tree;
|
16
16
|
}
|
17
17
|
try {
|
18
18
|
// console.log('workspace dir:', process.cwd());
|
19
19
|
// const dirName = process.cwd().split('/').slice(-1);
|
20
|
-
const groupByName = xplat_utils_1.getGroupByName();
|
21
|
-
const framework = xplat_utils_1.getFrontendFramework();
|
20
|
+
const groupByName = (0, xplat_utils_1.getGroupByName)();
|
21
|
+
const framework = (0, xplat_utils_1.getFrontendFramework)();
|
22
22
|
let frameworkSuffix = framework ? `-${framework}` : '';
|
23
23
|
let isFullstack = false;
|
24
24
|
let isExcluding = false;
|
@@ -27,7 +27,7 @@ var FocusHelpers;
|
|
27
27
|
if (!options.devMode || options.devMode === 'fullstack') {
|
28
28
|
// show all
|
29
29
|
isFullstack = true;
|
30
|
-
if (xplat_utils_1.isXplatWorkspace()) {
|
30
|
+
if ((0, xplat_utils_1.isXplatWorkspace)()) {
|
31
31
|
for (const p of xplat_utils_1.supportedPlatformsWithNx) {
|
32
32
|
const appFilter = groupByName ? `*-${p}` : `${p}*`;
|
33
33
|
userUpdates[`**/apps/${appFilter}`] = false;
|
@@ -50,8 +50,8 @@ var FocusHelpers;
|
|
50
50
|
}
|
51
51
|
}
|
52
52
|
else if (options.platforms) {
|
53
|
-
const platforms = xplat_utils_1.sanitizeCommaDelimitedArg(options.platforms);
|
54
|
-
if (xplat_utils_1.isXplatWorkspace()) {
|
53
|
+
const platforms = (0, xplat_utils_1.sanitizeCommaDelimitedArg)(options.platforms);
|
54
|
+
if ((0, xplat_utils_1.isXplatWorkspace)()) {
|
55
55
|
// switch on/off platforms
|
56
56
|
for (const p of xplat_utils_1.supportedPlatformsWithNx) {
|
57
57
|
const excluded = platforms.includes(p) ? false : true;
|
@@ -131,7 +131,7 @@ var FocusHelpers;
|
|
131
131
|
allPackages: options.allPackages,
|
132
132
|
isFullstack,
|
133
133
|
});
|
134
|
-
if (xplat_utils_1.isXplatWorkspace() && !options.devMode) {
|
134
|
+
if ((0, xplat_utils_1.isXplatWorkspace)() && !options.devMode) {
|
135
135
|
// only when not specifying a dev mode
|
136
136
|
const workspaceUpdates = {
|
137
137
|
'**/node_modules': true,
|
@@ -203,16 +203,18 @@ var FocusHelpers;
|
|
203
203
|
: '/var/local/Code/User/settings.json';
|
204
204
|
const windowsHome = process.env.APPDATA;
|
205
205
|
if (windowsHome) {
|
206
|
-
userSettingsVSCodePath = path_1.join(windowsHome, 'Code', 'User', 'settings.json');
|
206
|
+
userSettingsVSCodePath = (0, path_1.join)(windowsHome, 'Code', 'User', 'settings.json');
|
207
207
|
}
|
208
208
|
// console.log('userSettingsVSCodePath:',userSettingsVSCodePath);
|
209
|
-
isVsCode = fs_1.existsSync(userSettingsVSCodePath);
|
209
|
+
isVsCode = (0, fs_1.existsSync)(userSettingsVSCodePath);
|
210
210
|
let vscodeCreateSettingsNote = `It's possible you don't have a user settings.json yet. If so, open VS Code User settings and save any kind of setting to have it created.`;
|
211
211
|
// console.log('isVsCode:',isVsCode);
|
212
212
|
if (isVsCode) {
|
213
|
-
const userSettings = fs_1.readFileSync(userSettingsVSCodePath, {
|
213
|
+
const userSettings = (0, fs_1.readFileSync)(userSettingsVSCodePath, {
|
214
|
+
encoding: 'utf-8',
|
215
|
+
});
|
214
216
|
if (userSettings) {
|
215
|
-
const userSettingsJson = xplat_utils_1.jsonParse(userSettings);
|
217
|
+
const userSettingsJson = (0, xplat_utils_1.jsonParse)(userSettings);
|
216
218
|
let exclude = userSettingsJson['files.exclude'];
|
217
219
|
if (!exclude) {
|
218
220
|
exclude = {};
|
@@ -223,7 +225,7 @@ var FocusHelpers;
|
|
223
225
|
}
|
224
226
|
userSettingsJson['files.exclude'] = Object.assign(exclude, options.userUpdates);
|
225
227
|
userSettingsJson['search.exclude'] = Object.assign(searchExclude, options.userUpdates);
|
226
|
-
if (xplat_utils_1.isXplatWorkspace()) {
|
228
|
+
if ((0, xplat_utils_1.isXplatWorkspace)()) {
|
227
229
|
if (options.allApps.length) {
|
228
230
|
// always reset specific app filters
|
229
231
|
for (const app of options.allApps) {
|
@@ -269,7 +271,7 @@ var FocusHelpers;
|
|
269
271
|
}
|
270
272
|
}
|
271
273
|
}
|
272
|
-
fs_1.writeFileSync(userSettingsVSCodePath,
|
274
|
+
(0, fs_1.writeFileSync)(userSettingsVSCodePath, (0, devkit_1.serializeJson)(userSettingsJson));
|
273
275
|
// TODO: print out the updates made
|
274
276
|
// Example of how the updates are represented
|
275
277
|
// true === hidden
|
@@ -301,21 +303,23 @@ var FocusHelpers;
|
|
301
303
|
/**
|
302
304
|
* Workspace settings
|
303
305
|
*/
|
304
|
-
const workspaceSettingsPath = path_1.join(process.cwd(), '.vscode', 'settings.json');
|
306
|
+
const workspaceSettingsPath = (0, path_1.join)(process.cwd(), '.vscode', 'settings.json');
|
305
307
|
// console.log('workspaceSettingsPath:',workspaceSettingsPath);
|
306
308
|
let workspaceSettingsJson = {};
|
307
|
-
if (fs_1.existsSync(workspaceSettingsPath)) {
|
308
|
-
const workspaceSettings = fs_1.readFileSync(workspaceSettingsPath, {
|
309
|
-
|
309
|
+
if ((0, fs_1.existsSync)(workspaceSettingsPath)) {
|
310
|
+
const workspaceSettings = (0, fs_1.readFileSync)(workspaceSettingsPath, {
|
311
|
+
encoding: 'utf-8',
|
312
|
+
});
|
313
|
+
workspaceSettingsJson = (0, xplat_utils_1.jsonParse)(workspaceSettings);
|
310
314
|
const exclude = workspaceSettingsJson['files.exclude'];
|
311
315
|
workspaceSettingsJson['files.exclude'] = Object.assign(exclude, options.workspaceUpdates);
|
312
316
|
}
|
313
317
|
else {
|
314
318
|
// console.log('creating workspace settings...');
|
315
|
-
fs_1.mkdirSync('.vscode');
|
319
|
+
(0, fs_1.mkdirSync)('.vscode');
|
316
320
|
workspaceSettingsJson['files.exclude'] = options.workspaceUpdates;
|
317
321
|
}
|
318
|
-
fs_1.writeFileSync(workspaceSettingsPath,
|
322
|
+
(0, fs_1.writeFileSync)(workspaceSettingsPath, (0, devkit_1.serializeJson)(workspaceSettingsJson));
|
319
323
|
}
|
320
324
|
return isVsCode;
|
321
325
|
}
|