tnp-helpers 16.5.4 → 16.5.6
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/assets/shared/shared_folder_info.txt +1 -1
- package/browser/esm2022/lib/base-project-resolver.mjs +187 -0
- package/browser/esm2022/lib/base-project.mjs +65 -183
- package/browser/esm2022/lib/helpers.mjs +32 -35
- package/browser/esm2022/lib/index.mjs +2 -1
- package/browser/fesm2022/tnp-helpers.mjs +107 -43
- package/browser/fesm2022/tnp-helpers.mjs.map +1 -1
- package/browser/lib/base-project-resolver.d.ts +23 -0
- package/browser/lib/base-project.d.ts +29 -23
- package/browser/lib/helpers.d.ts +1 -0
- package/browser/lib/index.d.ts +1 -0
- package/client/esm2022/lib/base-project-resolver.mjs +187 -0
- package/client/esm2022/lib/base-project.mjs +65 -183
- package/client/esm2022/lib/helpers.mjs +32 -35
- package/client/esm2022/lib/index.mjs +2 -1
- package/client/fesm2022/tnp-helpers.mjs +107 -43
- package/client/fesm2022/tnp-helpers.mjs.map +1 -1
- package/client/lib/base-project-resolver.d.ts +23 -0
- package/client/lib/base-project.d.ts +29 -23
- package/client/lib/helpers.d.ts +1 -0
- package/client/lib/index.d.ts +1 -0
- package/client/package.json +32 -32
- package/lib/base-project-resolver.d.ts +23 -0
- package/lib/base-project-resolver.js +193 -0
- package/lib/base-project-resolver.js.map +1 -0
- package/lib/base-project.d.ts +29 -23
- package/lib/base-project.js +94 -183
- package/lib/base-project.js.map +1 -1
- package/lib/for-backend/helpers-file-folders.backend.d.ts +3 -0
- package/lib/for-backend/helpers-file-folders.backend.js +7 -3
- package/lib/for-backend/helpers-file-folders.backend.js.map +1 -1
- package/lib/for-browser/angular.helper.js +3 -3
- package/lib/helpers.js +0 -2
- package/lib/helpers.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/old/base-component.js +3 -3
- package/lib/old/base-formly-component.js +3 -3
- package/lib/old/dual-component-ctrl.js +3 -3
- package/package.json +4 -4
- package/tmp-environment.json +36 -36
- package/websql/esm2022/lib/base-project-resolver.mjs +187 -0
- package/websql/esm2022/lib/base-project.mjs +65 -174
- package/websql/esm2022/lib/helpers.mjs +32 -35
- package/websql/esm2022/lib/index.mjs +2 -1
- package/websql/fesm2022/tnp-helpers.mjs +109 -45
- package/websql/fesm2022/tnp-helpers.mjs.map +1 -1
- package/websql/lib/base-project-resolver.d.ts +23 -0
- package/websql/lib/base-project.d.ts +29 -23
- package/websql/lib/helpers.d.ts +1 -0
- package/websql/lib/index.d.ts +1 -0
|
@@ -1,26 +1,6 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
import { Models } from 'tnp-models/browser';
|
|
3
|
-
|
|
4
|
-
protected classFn: any;
|
|
5
|
-
protected readonly NPM_PROJECT_KEY = "npm";
|
|
6
|
-
protected projects: (T & BaseProject)[];
|
|
7
|
-
protected emptyLocations: string[];
|
|
8
|
-
constructor(classFn: any);
|
|
9
|
-
get allowedTypes(): string[];
|
|
10
|
-
get Current(): T;
|
|
11
|
-
/**
|
|
12
|
-
* override this
|
|
13
|
-
*/
|
|
14
|
-
typeFrom<T>(location: string): string;
|
|
15
|
-
From(locationOfProject: string | string[]): T;
|
|
16
|
-
nearestTo(absoluteLocation: string, options?: {
|
|
17
|
-
type?: (string | string[]);
|
|
18
|
-
findGitRoot?: boolean;
|
|
19
|
-
onlyOutSideNodeModules?: boolean;
|
|
20
|
-
}): T;
|
|
21
|
-
unload(project: T): void;
|
|
22
|
-
allProjectFrom(absoluteLocation: string, stopOnCwd?: string): any;
|
|
23
|
-
}
|
|
3
|
+
import { BaseProjectResolver } from './base-project-resolver';
|
|
24
4
|
export declare class BaseProject<T = any> {
|
|
25
5
|
static ins: BaseProjectResolver<BaseProject<any>>;
|
|
26
6
|
readonly ins: BaseProjectResolver<T>;
|
|
@@ -32,6 +12,30 @@ export declare class BaseProject<T = any> {
|
|
|
32
12
|
get name(): string;
|
|
33
13
|
readonly type: string;
|
|
34
14
|
get version(): string;
|
|
15
|
+
/**
|
|
16
|
+
* npm dependencies
|
|
17
|
+
*/
|
|
18
|
+
get dependencies(): Models.npm.DependenciesFromPackageJsonStyle;
|
|
19
|
+
/**
|
|
20
|
+
* peerDependencies dependencies
|
|
21
|
+
*/
|
|
22
|
+
get peerDependencies(): Models.npm.DependenciesFromPackageJsonStyle;
|
|
23
|
+
/**
|
|
24
|
+
* devDependencies dependencies
|
|
25
|
+
*/
|
|
26
|
+
get devDependencies(): Models.npm.DependenciesFromPackageJsonStyle;
|
|
27
|
+
/**
|
|
28
|
+
* resolutions dependencies
|
|
29
|
+
*/
|
|
30
|
+
get resolutions(): any;
|
|
31
|
+
/**
|
|
32
|
+
* object with all deps from package json
|
|
33
|
+
*/
|
|
34
|
+
get allDependencies(): {
|
|
35
|
+
[packageName: string]: string;
|
|
36
|
+
};
|
|
37
|
+
get tnp(): Models.npm.TnpData & Models.npm.TnpIPackageJSONOverride;
|
|
38
|
+
get firedev(): Models.npm.TnpData & Models.npm.TnpIPackageJSONOverride;
|
|
35
39
|
protected readonly packageJSON: Models.npm.IPackageJSON;
|
|
36
40
|
/**
|
|
37
41
|
* only available after executing *this.assignFreePort()*
|
|
@@ -46,10 +50,12 @@ export declare class BaseProject<T = any> {
|
|
|
46
50
|
* @returns
|
|
47
51
|
*/
|
|
48
52
|
tryRunSync(command: string): void;
|
|
49
|
-
pathFor(relativePath: string): any;
|
|
53
|
+
pathFor(relativePath: string | string[]): any;
|
|
50
54
|
writeJson(relativePath: string, json: object): any;
|
|
51
55
|
run(command: string): any;
|
|
52
56
|
outputFrom(command: string): any;
|
|
53
57
|
remove(relativePath: string, exactPath?: boolean): any;
|
|
54
|
-
|
|
58
|
+
linkNodeModulesTo(proj: Partial<BaseProject>): any;
|
|
59
|
+
reinstallNodeModules(forcerRemoveNodeModules?: boolean): any;
|
|
60
|
+
assignFreePort(startFrom?: number, howManyFreePortsAfterThatPort?: number): Promise<number>;
|
|
55
61
|
}
|
package/client/lib/helpers.d.ts
CHANGED
|
@@ -32,6 +32,7 @@ export declare class HelpersFiredev extends CoreHelpers {
|
|
|
32
32
|
static get Instance(): HelpersFiredev & CoreHelpers;
|
|
33
33
|
private constructor();
|
|
34
34
|
CLIWRAP(f: Function, name: string): Function;
|
|
35
|
+
urlParse(portOrHost: (number | string | URL), forceDomain?: boolean): URL;
|
|
35
36
|
isElevated(): Promise<void>;
|
|
36
37
|
mesureExectionInMs(description: string, functionToExecute: Function, ...functionArguments: any[]): Promise<number>;
|
|
37
38
|
mesureExectionInMsSync(description: string, functionToExecute: () => void): number;
|
package/client/lib/index.d.ts
CHANGED
package/client/package.json
CHANGED
|
@@ -38,11 +38,11 @@
|
|
|
38
38
|
"firedev-helpers"
|
|
39
39
|
]
|
|
40
40
|
},
|
|
41
|
-
"version": "16.5.
|
|
41
|
+
"version": "16.5.6",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"json10-writer": "~16.5.
|
|
43
|
+
"json10-writer": "~16.5.5",
|
|
44
44
|
"task.js": "0.1.5",
|
|
45
|
-
"tnp-models": "~16.5.
|
|
45
|
+
"tnp-models": "~16.5.5"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -134,9 +134,9 @@
|
|
|
134
134
|
"angular-material-css-vars": "5.0.2",
|
|
135
135
|
"angular-resize-event": "3.2.0",
|
|
136
136
|
"animate.css": "4.1.1 ",
|
|
137
|
-
"any-project-cli": "~16.5.
|
|
137
|
+
"any-project-cli": "~16.5.5",
|
|
138
138
|
"axios": "1.3.5",
|
|
139
|
-
"background-worker-process": "~16.5.
|
|
139
|
+
"background-worker-process": "~16.5.5",
|
|
140
140
|
"base32": "0.0.7",
|
|
141
141
|
"bcryptjs": "2.4.3",
|
|
142
142
|
"better-sqlite3": "7.6.2",
|
|
@@ -183,13 +183,13 @@
|
|
|
183
183
|
"file-saver": "2.0.5",
|
|
184
184
|
"file-type": "18.5.0",
|
|
185
185
|
"firedev": "^16",
|
|
186
|
-
"firedev-crud": "~16.5.
|
|
187
|
-
"firedev-crud-deamon": "~16.5.
|
|
188
|
-
"firedev-ports": "~16.5.
|
|
189
|
-
"firedev-storage": "~16.5.
|
|
190
|
-
"firedev-type-sql": "~16.5.
|
|
191
|
-
"firedev-typeorm": "~16.5.
|
|
192
|
-
"firedev-ui": "~16.5.
|
|
186
|
+
"firedev-crud": "~16.5.5",
|
|
187
|
+
"firedev-crud-deamon": "~16.5.5",
|
|
188
|
+
"firedev-ports": "~16.5.5",
|
|
189
|
+
"firedev-storage": "~16.5.5",
|
|
190
|
+
"firedev-type-sql": "~16.5.5",
|
|
191
|
+
"firedev-typeorm": "~16.5.6",
|
|
192
|
+
"firedev-ui": "~16.5.5",
|
|
193
193
|
"fkill": "6.1.0",
|
|
194
194
|
"font-awesome": "4.7.0",
|
|
195
195
|
"form-data": "4.0.0",
|
|
@@ -206,11 +206,11 @@
|
|
|
206
206
|
"image-focus": "1.2.1",
|
|
207
207
|
"immer": "10.0.2",
|
|
208
208
|
"immutable": "4.3.0",
|
|
209
|
-
"incremental-compiler": "~16.5.
|
|
209
|
+
"incremental-compiler": "~16.5.15",
|
|
210
210
|
"inquirer": "7.3.3",
|
|
211
211
|
"inquirer-autocomplete-prompt": "1.3.0",
|
|
212
212
|
"is-elevated": "3.0.0",
|
|
213
|
-
"isomorphic-region-loader": "~16.5.
|
|
213
|
+
"isomorphic-region-loader": "~16.5.5",
|
|
214
214
|
"istanbul-instrumenter-loader": "2.0.0",
|
|
215
215
|
"jest": "29.5.0",
|
|
216
216
|
"jest-date-mock": "1.0.8",
|
|
@@ -221,7 +221,7 @@
|
|
|
221
221
|
"joi": "17.9.2",
|
|
222
222
|
"jscodeshift": "0.6.3",
|
|
223
223
|
"json-stringify-safe": "5.0.1",
|
|
224
|
-
"json10": "~16.5.
|
|
224
|
+
"json10": "~16.5.5",
|
|
225
225
|
"json5": "2.2.1",
|
|
226
226
|
"json5-writer": "0.2.0",
|
|
227
227
|
"jszip": "3.10.1",
|
|
@@ -230,23 +230,23 @@
|
|
|
230
230
|
"localforage": "1.10.0",
|
|
231
231
|
"lockfile": "1.0.4",
|
|
232
232
|
"lodash": "4.17.20",
|
|
233
|
-
"lodash-walk-object": "~16.5.
|
|
233
|
+
"lodash-walk-object": "~16.5.5",
|
|
234
234
|
"lowdb": "1.0.0",
|
|
235
|
-
"magic-renamer": "~16.5.
|
|
235
|
+
"magic-renamer": "~16.5.5",
|
|
236
236
|
"material-design-icons": "3.0.1",
|
|
237
237
|
"method-override": "2.3.10",
|
|
238
238
|
"minimist": "1.2.0",
|
|
239
239
|
"mkdirp": "0.5.1",
|
|
240
240
|
"mocha": "10.2.0",
|
|
241
241
|
"moment": "2.29.3",
|
|
242
|
-
"morphi": "~16.5.
|
|
242
|
+
"morphi": "~16.5.5",
|
|
243
243
|
"ng-for-track-by-property": "16.0.1",
|
|
244
244
|
"ng-in-viewport": "15.0.2",
|
|
245
245
|
"ng-lock": "16.0.1",
|
|
246
246
|
"ng-packagr": "16.0.1",
|
|
247
|
-
"ng-talkback": "~16.5.
|
|
248
|
-
"ng2-logger": "~16.5.
|
|
249
|
-
"ng2-rest": "~16.5.
|
|
247
|
+
"ng-talkback": "~16.5.5",
|
|
248
|
+
"ng2-logger": "~16.5.5",
|
|
249
|
+
"ng2-rest": "~16.5.5",
|
|
250
250
|
"ngx-ace-wrapper": "14.0.0",
|
|
251
251
|
"ngx-editor": "15.3.0",
|
|
252
252
|
"ngx-highlightjs": "9.0.0",
|
|
@@ -259,7 +259,7 @@
|
|
|
259
259
|
"ngx-scrolltop": "6.0.0",
|
|
260
260
|
"ngx-store": "3.1.1",
|
|
261
261
|
"ngx-typed-js": "2.1.1",
|
|
262
|
-
"node-cli-tester": "~16.5.
|
|
262
|
+
"node-cli-tester": "~16.5.5",
|
|
263
263
|
"node-localstorage": "2.1.6",
|
|
264
264
|
"node-notifier": "6.0.0",
|
|
265
265
|
"node-polyfill-webpack-plugin": "2.0.1",
|
|
@@ -286,7 +286,7 @@
|
|
|
286
286
|
"q": "1.5.1",
|
|
287
287
|
"rallax.js": "2.0.4",
|
|
288
288
|
"randomcolor": "0.5.3",
|
|
289
|
-
"record-replay-req-res-scenario": "~16.5.
|
|
289
|
+
"record-replay-req-res-scenario": "~16.5.5",
|
|
290
290
|
"reflect-metadata": "0.1.10",
|
|
291
291
|
"rimraf": "2.6.2",
|
|
292
292
|
"rxjs": "~7.8.0",
|
|
@@ -297,18 +297,18 @@
|
|
|
297
297
|
"socket.io": "2.4.1",
|
|
298
298
|
"sort-package-json": "1.11.0",
|
|
299
299
|
"sql.js": "1.8.0",
|
|
300
|
-
"static-columns": "~16.5.
|
|
300
|
+
"static-columns": "~16.5.6",
|
|
301
301
|
"string-similarity": "4.0.2",
|
|
302
302
|
"sudo-block": "3.0.0",
|
|
303
303
|
"supertest": "6.3.3",
|
|
304
304
|
"sweetalert2": "11.7.12",
|
|
305
305
|
"systeminformation": "3.45.7",
|
|
306
306
|
"threads": "1.7.0",
|
|
307
|
-
"tnp-cli": "~16.5.
|
|
308
|
-
"tnp-config": "~16.5.
|
|
309
|
-
"tnp-core": "~16.5.
|
|
310
|
-
"tnp-db": "~16.5.
|
|
311
|
-
"tnp-helpers": "~16.5.
|
|
307
|
+
"tnp-cli": "~16.5.5",
|
|
308
|
+
"tnp-config": "~16.5.5",
|
|
309
|
+
"tnp-core": "~16.5.10",
|
|
310
|
+
"tnp-db": "~16.5.5",
|
|
311
|
+
"tnp-helpers": "~16.5.5",
|
|
312
312
|
"ts-debug": "1.3.0",
|
|
313
313
|
"ts-loader": "2.3.1",
|
|
314
314
|
"ts-node": "10.9.1",
|
|
@@ -317,16 +317,16 @@
|
|
|
317
317
|
"turndown": "7.1.2",
|
|
318
318
|
"typeorm": "~0.3.10",
|
|
319
319
|
"typescript": "~5.0.2",
|
|
320
|
-
"typescript-class-helpers": "~16.5.
|
|
320
|
+
"typescript-class-helpers": "~16.5.5",
|
|
321
321
|
"typescript-formatter": "~7.2.2",
|
|
322
322
|
"underscore": "1.9.1",
|
|
323
323
|
"uuid": "8.3.2",
|
|
324
324
|
"validator": "9.2.0",
|
|
325
325
|
"video.js": "8.3.0",
|
|
326
|
-
"vpn-split": "~16.5.
|
|
326
|
+
"vpn-split": "~16.5.6",
|
|
327
327
|
"watch": "1.0.2",
|
|
328
328
|
"yup": "1.1.1",
|
|
329
329
|
"zone.js": "~0.13.0"
|
|
330
330
|
},
|
|
331
|
-
"lastBuildTagHash": "
|
|
331
|
+
"lastBuildTagHash": "231b0506bac8114ed3073e0b90c70bff5abf41d7"
|
|
332
332
|
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { ChildProcess } from 'child_process';
|
|
2
|
+
import type { BaseProject } from './base-project';
|
|
3
|
+
export declare class BaseProjectResolver<T> {
|
|
4
|
+
protected classFn: any;
|
|
5
|
+
protected readonly NPM_PROJECT_KEY = "npm";
|
|
6
|
+
protected projects: (T & BaseProject)[];
|
|
7
|
+
protected emptyLocations: string[];
|
|
8
|
+
constructor(classFn: any);
|
|
9
|
+
get allowedTypes(): string[];
|
|
10
|
+
get Current(): T;
|
|
11
|
+
/**
|
|
12
|
+
* override this
|
|
13
|
+
*/
|
|
14
|
+
typeFrom(location: string): string;
|
|
15
|
+
From(locationOfProject: string | string[], options?: any): T;
|
|
16
|
+
nearestTo(absoluteLocation: string, options?: {
|
|
17
|
+
type?: (string | string[]);
|
|
18
|
+
findGitRoot?: boolean;
|
|
19
|
+
onlyOutSideNodeModules?: boolean;
|
|
20
|
+
}): T;
|
|
21
|
+
unload(project: T): void;
|
|
22
|
+
allProjectFrom(absoluteLocation: string, stopOnCwd?: string): T[];
|
|
23
|
+
}
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseProjectResolver = exports.ChildProcess = void 0;
|
|
4
|
+
var tnp_core_1 = require("tnp-core");
|
|
5
|
+
//#region @backend
|
|
6
|
+
var child_process_1 = require("child_process");
|
|
7
|
+
Object.defineProperty(exports, "ChildProcess", { enumerable: true, get: function () { return child_process_1.ChildProcess; } });
|
|
8
|
+
var tnp_cli_1 = require("tnp-cli");
|
|
9
|
+
//#endregion
|
|
10
|
+
var tnp_core_2 = require("tnp-core");
|
|
11
|
+
var tnp_config_1 = require("tnp-config");
|
|
12
|
+
var tnp_core_3 = require("tnp-core");
|
|
13
|
+
var BaseProjectResolver = /** @class */ (function () {
|
|
14
|
+
function BaseProjectResolver(classFn) {
|
|
15
|
+
this.classFn = classFn;
|
|
16
|
+
this.NPM_PROJECT_KEY = 'npm';
|
|
17
|
+
this.projects = [];
|
|
18
|
+
this.emptyLocations = [];
|
|
19
|
+
}
|
|
20
|
+
Object.defineProperty(BaseProjectResolver.prototype, "allowedTypes", {
|
|
21
|
+
get: function () {
|
|
22
|
+
//#region @websqlFunc
|
|
23
|
+
return [this.NPM_PROJECT_KEY];
|
|
24
|
+
// throw `Please override this getter [allowedTypes] in your child class or ${CLI.chalk.bold(config.frameworkName)}`;
|
|
25
|
+
//#endregion
|
|
26
|
+
},
|
|
27
|
+
enumerable: false,
|
|
28
|
+
configurable: true
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(BaseProjectResolver.prototype, "Current", {
|
|
31
|
+
get: function () {
|
|
32
|
+
//#region @backendFunc
|
|
33
|
+
var current = (this.classFn).From(process.cwd());
|
|
34
|
+
if (!current) {
|
|
35
|
+
tnp_core_1.Helpers.warn("[firedev-helpers] Current location is not a ".concat(tnp_cli_1.CLI.chalk.bold(tnp_config_1.config.frameworkName), " type project.\n\n location: \"").concat(process.cwd(), "\"\n\n }"));
|
|
36
|
+
return void 0;
|
|
37
|
+
}
|
|
38
|
+
return current;
|
|
39
|
+
//#endregion
|
|
40
|
+
},
|
|
41
|
+
enumerable: false,
|
|
42
|
+
configurable: true
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* override this
|
|
46
|
+
*/
|
|
47
|
+
BaseProjectResolver.prototype.typeFrom = function (location) {
|
|
48
|
+
//#region @backendFunc
|
|
49
|
+
if (tnp_core_1.Helpers.exists((0, tnp_core_2.crossPlatformPath)([location, tnp_config_1.config.file.package_json]))) {
|
|
50
|
+
return this.NPM_PROJECT_KEY;
|
|
51
|
+
}
|
|
52
|
+
// throw `Please override this function [typeFrom] in your child class or ${CLI.chalk.bold(config.frameworkName)}`;
|
|
53
|
+
//#endregion
|
|
54
|
+
};
|
|
55
|
+
BaseProjectResolver.prototype.From = function (locationOfProject, options) {
|
|
56
|
+
// console.log({
|
|
57
|
+
// locationOfProj
|
|
58
|
+
// })
|
|
59
|
+
//#region @websqlFunc
|
|
60
|
+
if (Array.isArray(locationOfProject)) {
|
|
61
|
+
locationOfProject = locationOfProject.join('/');
|
|
62
|
+
}
|
|
63
|
+
var location = (0, tnp_core_2.crossPlatformPath)(locationOfProject.replace(/\/\//g, '/'));
|
|
64
|
+
if (!tnp_core_3._.isString(location)) {
|
|
65
|
+
tnp_core_1.Helpers.warn("[project.from] location is not a string");
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (tnp_core_2.path.basename(location) === 'dist') {
|
|
69
|
+
location = tnp_core_2.path.dirname(location);
|
|
70
|
+
}
|
|
71
|
+
location = (0, tnp_core_2.crossPlatformPath)(tnp_core_2.path.resolve(location));
|
|
72
|
+
var alreadyExist = this.projects.find(function (l) { return l.location.trim() === location.trim(); });
|
|
73
|
+
if (alreadyExist) {
|
|
74
|
+
return alreadyExist;
|
|
75
|
+
}
|
|
76
|
+
//#region @backend
|
|
77
|
+
if (!tnp_core_1.fse.existsSync(location)) {
|
|
78
|
+
tnp_core_1.Helpers.log("[firedev-helpers][project.from] Cannot find project in location: ".concat(location), 1);
|
|
79
|
+
this.emptyLocations.push(location);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
var type = this.typeFrom(location);
|
|
83
|
+
if (type) {
|
|
84
|
+
var resultProject = new (this.classFn)();
|
|
85
|
+
var pj = tnp_core_1.Helpers.readJson((0, tnp_core_2.crossPlatformPath)([location, tnp_config_1.config.file.package_json]));
|
|
86
|
+
// @ts-ignore
|
|
87
|
+
resultProject.basename = tnp_core_2.path.basename(location);
|
|
88
|
+
// @ts-ignore
|
|
89
|
+
resultProject.location = location;
|
|
90
|
+
// @ts-ignore
|
|
91
|
+
resultProject.type = type;
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
resultProject.packageJSON = pj;
|
|
94
|
+
// @ts-ignore
|
|
95
|
+
resultProject.ins = this;
|
|
96
|
+
return resultProject;
|
|
97
|
+
}
|
|
98
|
+
//#endregion
|
|
99
|
+
//#endregion
|
|
100
|
+
};
|
|
101
|
+
BaseProjectResolver.prototype.nearestTo = function (absoluteLocation, options) {
|
|
102
|
+
//#region @backendFunc
|
|
103
|
+
options = options || {};
|
|
104
|
+
var type = options.type, findGitRoot = options.findGitRoot, onlyOutSideNodeModules = options.onlyOutSideNodeModules;
|
|
105
|
+
if (tnp_core_3._.isString(type) && !this.allowedTypes.includes(type)) {
|
|
106
|
+
tnp_core_1.Helpers.error("[firedev-helpers][project.nearestTo] wrong type: ".concat(type), false, true);
|
|
107
|
+
}
|
|
108
|
+
if (tnp_core_1.fse.existsSync(absoluteLocation)) {
|
|
109
|
+
absoluteLocation = tnp_core_1.fse.realpathSync(absoluteLocation);
|
|
110
|
+
}
|
|
111
|
+
if (tnp_core_1.fse.existsSync(absoluteLocation) && !tnp_core_1.fse.lstatSync(absoluteLocation).isDirectory()) {
|
|
112
|
+
absoluteLocation = tnp_core_2.path.dirname(absoluteLocation);
|
|
113
|
+
}
|
|
114
|
+
var project;
|
|
115
|
+
var previousLocation;
|
|
116
|
+
while (true) {
|
|
117
|
+
if (onlyOutSideNodeModules && (tnp_core_2.path.basename(tnp_core_2.path.dirname(absoluteLocation)) === 'node_modules')) {
|
|
118
|
+
absoluteLocation = tnp_core_2.path.dirname(tnp_core_2.path.dirname(absoluteLocation));
|
|
119
|
+
}
|
|
120
|
+
project = this.From(absoluteLocation, options);
|
|
121
|
+
if (tnp_core_3._.isString(type)) {
|
|
122
|
+
if (this.allowedTypes.includes(project === null || project === void 0 ? void 0 : project.type)) {
|
|
123
|
+
if (findGitRoot) {
|
|
124
|
+
if (project.git.isGitRoot) {
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
if (project) {
|
|
135
|
+
if (findGitRoot) {
|
|
136
|
+
if (project.git.isGitRoot) {
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
previousLocation = absoluteLocation;
|
|
146
|
+
var newAbsLocation = tnp_core_2.path.join(absoluteLocation, '..');
|
|
147
|
+
if (!tnp_core_2.path.isAbsolute(newAbsLocation)) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
absoluteLocation = (0, tnp_core_2.crossPlatformPath)(tnp_core_2.path.resolve(newAbsLocation));
|
|
151
|
+
if (!tnp_core_1.fse.existsSync(absoluteLocation) && absoluteLocation.split('/').length < 2) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (previousLocation === absoluteLocation) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return project;
|
|
159
|
+
//#endregion
|
|
160
|
+
};
|
|
161
|
+
BaseProjectResolver.prototype.unload = function (project) {
|
|
162
|
+
this.projects = this.projects.filter(function (f) { return f !== project; });
|
|
163
|
+
};
|
|
164
|
+
BaseProjectResolver.prototype.allProjectFrom = function (absoluteLocation, stopOnCwd) {
|
|
165
|
+
if (stopOnCwd === void 0) { stopOnCwd = '/'; }
|
|
166
|
+
//#region @backendFunc
|
|
167
|
+
var projects = {};
|
|
168
|
+
var projectsList = [];
|
|
169
|
+
var previousAbsLocation;
|
|
170
|
+
while (absoluteLocation.startsWith(stopOnCwd)) {
|
|
171
|
+
if (previousAbsLocation === absoluteLocation) {
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
var proj = this.nearestTo(absoluteLocation);
|
|
175
|
+
if (proj) {
|
|
176
|
+
if (projects[proj.location]) {
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
projects[proj.location] = proj;
|
|
180
|
+
projectsList.push(proj);
|
|
181
|
+
previousAbsLocation = absoluteLocation;
|
|
182
|
+
absoluteLocation = tnp_core_2.path.dirname(proj.location);
|
|
183
|
+
continue;
|
|
184
|
+
}
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
return projectsList;
|
|
188
|
+
//#endregion
|
|
189
|
+
};
|
|
190
|
+
return BaseProjectResolver;
|
|
191
|
+
}());
|
|
192
|
+
exports.BaseProjectResolver = BaseProjectResolver;
|
|
193
|
+
//# sourceMappingURL=base-project-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-project-resolver.js","sourceRoot":"","sources":[""],"names":[],"mappings":";;;AACA,qCAKkB;AAClB,kBAAkB;AAClB,+CAA6C;AAApC,6GAAA,YAAY,OAAA;AACrB,mCAA8B;AAC9B,YAAY;AACZ,qCAAmD;AACnD,yCAAoC;AACpC,qCAA6B;AAG7B;IAKE,6BAAsB,OAAY;QAAZ,YAAO,GAAP,OAAO,CAAK;QAHf,oBAAe,GAAG,KAAK,CAAC;QACjC,aAAQ,GAAwB,EAAE,CAAC;QACnC,mBAAc,GAAa,EAAE,CAAC;IACF,CAAC;IACvC,sBAAI,6CAAY;aAAhB;YACE,qBAAqB;YACrB,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAC9B,sHAAsH;YACtH,YAAY;QACd,CAAC;;;OAAA;IAED,sBAAI,wCAAO;aAAX;YAC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AE,CAAC;QACpB,IAAM,YAAY,GAAG,EAAE,CAAC;QACxB,IAAI,mBAA2B,CAAC;QAChC,OAAO,gBAAgB,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE;YAE7C,IAAI,mBAAmB,KAAK,gBAAgB,EAAE;gBAC5C,MAAM;aACP;YAID,IAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAuB,CAAC;YACpE,IAAI,IAAI,EAAE;gBACR,IAAI,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE;oBAC3B,MAAM;iBACP;gBACD,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,IAAI,CAAC;gBAC/B,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;gBACxB,mBAAmB,GAAG,gBAAgB,CAAC;gBACvC,gBAAgB,GAAG,eAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBAC/C,SAAS;aACV;YACD,MAAM;SACP;QACD,OAAO,YAAmB,CAAC;QAC3B,YAAY;IACd,CAAC;IAEH,0BAAC;AAAD,CAAC,AArMD,IAqMC;AArMY,kDAAmB"}
|
package/lib/base-project.d.ts
CHANGED
|
@@ -4,27 +4,7 @@ export { ChildProcess } from 'child_process';
|
|
|
4
4
|
import { ProjectGit } from './git-project';
|
|
5
5
|
import { CommandOutputOptions } from 'tnp-core';
|
|
6
6
|
import { Models } from 'tnp-models';
|
|
7
|
-
|
|
8
|
-
protected classFn: any;
|
|
9
|
-
protected readonly NPM_PROJECT_KEY = "npm";
|
|
10
|
-
protected projects: (T & BaseProject)[];
|
|
11
|
-
protected emptyLocations: string[];
|
|
12
|
-
constructor(classFn: any);
|
|
13
|
-
get allowedTypes(): string[];
|
|
14
|
-
get Current(): T;
|
|
15
|
-
/**
|
|
16
|
-
* override this
|
|
17
|
-
*/
|
|
18
|
-
typeFrom<T>(location: string): string;
|
|
19
|
-
From(locationOfProject: string | string[]): T;
|
|
20
|
-
nearestTo(absoluteLocation: string, options?: {
|
|
21
|
-
type?: (string | string[]);
|
|
22
|
-
findGitRoot?: boolean;
|
|
23
|
-
onlyOutSideNodeModules?: boolean;
|
|
24
|
-
}): T;
|
|
25
|
-
unload(project: T): void;
|
|
26
|
-
allProjectFrom(absoluteLocation: string, stopOnCwd?: string): T[];
|
|
27
|
-
}
|
|
7
|
+
import { BaseProjectResolver } from './base-project-resolver';
|
|
28
8
|
export declare class BaseProject<T = any> extends ProjectGit {
|
|
29
9
|
static ins: BaseProjectResolver<BaseProject<any>>;
|
|
30
10
|
readonly ins: BaseProjectResolver<T>;
|
|
@@ -36,6 +16,30 @@ export declare class BaseProject<T = any> extends ProjectGit {
|
|
|
36
16
|
get name(): string;
|
|
37
17
|
readonly type: string;
|
|
38
18
|
get version(): string;
|
|
19
|
+
/**
|
|
20
|
+
* npm dependencies
|
|
21
|
+
*/
|
|
22
|
+
get dependencies(): Models.npm.DependenciesFromPackageJsonStyle;
|
|
23
|
+
/**
|
|
24
|
+
* peerDependencies dependencies
|
|
25
|
+
*/
|
|
26
|
+
get peerDependencies(): Models.npm.DependenciesFromPackageJsonStyle;
|
|
27
|
+
/**
|
|
28
|
+
* devDependencies dependencies
|
|
29
|
+
*/
|
|
30
|
+
get devDependencies(): Models.npm.DependenciesFromPackageJsonStyle;
|
|
31
|
+
/**
|
|
32
|
+
* resolutions dependencies
|
|
33
|
+
*/
|
|
34
|
+
get resolutions(): any;
|
|
35
|
+
/**
|
|
36
|
+
* object with all deps from package json
|
|
37
|
+
*/
|
|
38
|
+
get allDependencies(): {
|
|
39
|
+
[packageName: string]: string;
|
|
40
|
+
};
|
|
41
|
+
get tnp(): Models.npm.TnpData & Models.npm.TnpIPackageJSONOverride;
|
|
42
|
+
get firedev(): Models.npm.TnpData & Models.npm.TnpIPackageJSONOverride;
|
|
39
43
|
protected readonly packageJSON: Models.npm.IPackageJSON;
|
|
40
44
|
/**
|
|
41
45
|
* only available after executing *this.assignFreePort()*
|
|
@@ -50,7 +54,7 @@ export declare class BaseProject<T = any> extends ProjectGit {
|
|
|
50
54
|
* @returns
|
|
51
55
|
*/
|
|
52
56
|
tryRunSync(command: string, options?: Omit<RunOptions, 'cwd'>): void;
|
|
53
|
-
pathFor(relativePath: string): string;
|
|
57
|
+
pathFor(relativePath: string | string[]): string;
|
|
54
58
|
writeJson(relativePath: string, json: object): void;
|
|
55
59
|
run(command: string, options?: Omit<RunOptions, 'cwd'>): {
|
|
56
60
|
sync(): string;
|
|
@@ -60,5 +64,7 @@ export declare class BaseProject<T = any> extends ProjectGit {
|
|
|
60
64
|
};
|
|
61
65
|
outputFrom(command: string, options?: CommandOutputOptions): string;
|
|
62
66
|
remove(relativePath: string, exactPath?: boolean): void;
|
|
63
|
-
|
|
67
|
+
linkNodeModulesTo(proj: Partial<BaseProject>): void;
|
|
68
|
+
reinstallNodeModules(forcerRemoveNodeModules?: boolean): void;
|
|
69
|
+
assignFreePort(startFrom?: number, howManyFreePortsAfterThatPort?: number): Promise<number>;
|
|
64
70
|
}
|