tnp-helpers 16.5.3 → 16.5.5
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 +59 -186
- package/browser/esm2022/lib/for-browser/helpers-browser.mjs +1 -3
- package/browser/esm2022/lib/helpers-strings.mjs +1 -8
- package/browser/esm2022/lib/helpers.mjs +32 -35
- package/browser/esm2022/lib/index.mjs +2 -1
- package/browser/fesm2022/tnp-helpers.mjs +101 -55
- 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 +59 -186
- package/client/esm2022/lib/for-browser/helpers-browser.mjs +1 -3
- package/client/esm2022/lib/helpers-strings.mjs +1 -8
- package/client/esm2022/lib/helpers.mjs +32 -35
- package/client/esm2022/lib/index.mjs +2 -1
- package/client/fesm2022/tnp-helpers.mjs +101 -55
- 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 -190
- 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 +59 -178
- package/websql/esm2022/lib/for-browser/helpers-browser.mjs +1 -3
- package/websql/esm2022/lib/helpers-strings.mjs +1 -8
- package/websql/esm2022/lib/helpers.mjs +32 -35
- package/websql/esm2022/lib/index.mjs +2 -1
- package/websql/fesm2022/tnp-helpers.mjs +103 -58
- 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
|
@@ -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,G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CAAC,IAAI,OAAA,CAAC,KAAK,OAAO,EAAb,CAAa,CAAC,CAAC;IAC3D,CAAC;IAGD,4CAAc,GAAd,UAAe,gBAAwB,EAAE,SAAuB;QAAvB,0BAAA,EAAA,eAAuB;QAC9D,sBAAsB;QACtB,IAAM,QAAQ,GAAG,EAAE,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
|
}
|
package/lib/base-project.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseProject = exports.
|
|
3
|
+
exports.BaseProject = exports.ChildProcess = void 0;
|
|
4
4
|
var tslib_1 = require("tslib");
|
|
5
5
|
//#region import
|
|
6
6
|
//#region @backend
|
|
@@ -14,207 +14,93 @@ var tnp_core_2 = require("tnp-core");
|
|
|
14
14
|
var tnp_config_1 = require("tnp-config");
|
|
15
15
|
var tnp_core_3 = require("tnp-core");
|
|
16
16
|
var helpers_1 = require("./helpers");
|
|
17
|
+
var base_project_resolver_1 = require("./base-project-resolver");
|
|
17
18
|
var Helpers = helpers_1.HelpersFiredev.Instance;
|
|
18
19
|
//#endregion
|
|
19
20
|
var takenPorts = [];
|
|
20
|
-
var
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
this.NPM_PROJECT_KEY = 'npm';
|
|
25
|
-
this.projects = [];
|
|
26
|
-
this.emptyLocations = [];
|
|
21
|
+
var BaseProject = exports.BaseProject = /** @class */ (function (_super) {
|
|
22
|
+
tslib_1.__extends(BaseProject, _super);
|
|
23
|
+
function BaseProject() {
|
|
24
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
27
25
|
}
|
|
28
|
-
Object.defineProperty(
|
|
26
|
+
Object.defineProperty(BaseProject.prototype, "name", {
|
|
29
27
|
get: function () {
|
|
30
|
-
|
|
31
|
-
return
|
|
32
|
-
// throw `Please override this getter [allowedTypes] in your child class or ${CLI.chalk.bold(config.frameworkName)}`;
|
|
33
|
-
//#endregion
|
|
28
|
+
var _a;
|
|
29
|
+
return (_a = this.packageJSON) === null || _a === void 0 ? void 0 : _a.name;
|
|
34
30
|
},
|
|
35
31
|
enumerable: false,
|
|
36
32
|
configurable: true
|
|
37
33
|
});
|
|
38
|
-
Object.defineProperty(
|
|
34
|
+
Object.defineProperty(BaseProject.prototype, "version", {
|
|
39
35
|
get: function () {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (!current) {
|
|
43
|
-
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 }"));
|
|
44
|
-
return void 0;
|
|
45
|
-
}
|
|
46
|
-
return current;
|
|
47
|
-
//#endregion
|
|
36
|
+
var _a;
|
|
37
|
+
return (_a = this.packageJSON) === null || _a === void 0 ? void 0 : _a.version;
|
|
48
38
|
},
|
|
49
39
|
enumerable: false,
|
|
50
40
|
configurable: true
|
|
51
41
|
});
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
this.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
resultProject.ins = this;
|
|
104
|
-
return resultProject;
|
|
105
|
-
}
|
|
106
|
-
//#endregion
|
|
107
|
-
//#endregion
|
|
108
|
-
};
|
|
109
|
-
BaseProjectResolver.prototype.nearestTo = function (absoluteLocation, options) {
|
|
110
|
-
//#region @backendFunc
|
|
111
|
-
options = options || {};
|
|
112
|
-
var type = options.type, findGitRoot = options.findGitRoot, onlyOutSideNodeModules = options.onlyOutSideNodeModules;
|
|
113
|
-
if (tnp_core_3._.isString(type) && !this.allowedTypes.includes(type)) {
|
|
114
|
-
Helpers.error("[firedev-helpers][project.nearestTo] wrong type: ".concat(type), false, true);
|
|
115
|
-
}
|
|
116
|
-
if (tnp_core_1.fse.existsSync(absoluteLocation)) {
|
|
117
|
-
absoluteLocation = tnp_core_1.fse.realpathSync(absoluteLocation);
|
|
118
|
-
}
|
|
119
|
-
if (tnp_core_1.fse.existsSync(absoluteLocation) && !tnp_core_1.fse.lstatSync(absoluteLocation).isDirectory()) {
|
|
120
|
-
absoluteLocation = tnp_core_2.path.dirname(absoluteLocation);
|
|
121
|
-
}
|
|
122
|
-
var project;
|
|
123
|
-
var previousLocation;
|
|
124
|
-
while (true) {
|
|
125
|
-
if (onlyOutSideNodeModules && (tnp_core_2.path.basename(tnp_core_2.path.dirname(absoluteLocation)) === 'node_modules')) {
|
|
126
|
-
absoluteLocation = tnp_core_2.path.dirname(tnp_core_2.path.dirname(absoluteLocation));
|
|
127
|
-
}
|
|
128
|
-
project = this.From(absoluteLocation);
|
|
129
|
-
if (tnp_core_3._.isString(type)) {
|
|
130
|
-
if (this.allowedTypes.includes(project === null || project === void 0 ? void 0 : project.type)) {
|
|
131
|
-
if (findGitRoot) {
|
|
132
|
-
if (project.git.isGitRoot) {
|
|
133
|
-
break;
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
break;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
else {
|
|
142
|
-
if (project) {
|
|
143
|
-
if (findGitRoot) {
|
|
144
|
-
if (project.git.isGitRoot) {
|
|
145
|
-
break;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
else {
|
|
149
|
-
break;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
previousLocation = absoluteLocation;
|
|
154
|
-
var newAbsLocation = tnp_core_2.path.join(absoluteLocation, '..');
|
|
155
|
-
if (!tnp_core_2.path.isAbsolute(newAbsLocation)) {
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
absoluteLocation = (0, tnp_core_2.crossPlatformPath)(tnp_core_2.path.resolve(newAbsLocation));
|
|
159
|
-
if (!tnp_core_1.fse.existsSync(absoluteLocation) && absoluteLocation.split('/').length < 2) {
|
|
160
|
-
return;
|
|
161
|
-
}
|
|
162
|
-
if (previousLocation === absoluteLocation) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return project;
|
|
167
|
-
//#endregion
|
|
168
|
-
};
|
|
169
|
-
BaseProjectResolver.prototype.unload = function (project) {
|
|
170
|
-
this.projects = this.projects.filter(function (f) { return f !== project; });
|
|
171
|
-
};
|
|
172
|
-
BaseProjectResolver.prototype.allProjectFrom = function (absoluteLocation, stopOnCwd) {
|
|
173
|
-
if (stopOnCwd === void 0) { stopOnCwd = '/'; }
|
|
174
|
-
//#region @backendFunc
|
|
175
|
-
var projects = {};
|
|
176
|
-
var projectsList = [];
|
|
177
|
-
var previousAbsLocation;
|
|
178
|
-
while (absoluteLocation.startsWith(stopOnCwd)) {
|
|
179
|
-
if (previousAbsLocation === absoluteLocation) {
|
|
180
|
-
break;
|
|
181
|
-
}
|
|
182
|
-
var proj = this.nearestTo(absoluteLocation);
|
|
183
|
-
if (proj) {
|
|
184
|
-
if (projects[proj.location]) {
|
|
185
|
-
break;
|
|
186
|
-
}
|
|
187
|
-
projects[proj.location] = proj;
|
|
188
|
-
projectsList.push(proj);
|
|
189
|
-
previousAbsLocation = absoluteLocation;
|
|
190
|
-
absoluteLocation = tnp_core_2.path.dirname(proj.location);
|
|
191
|
-
continue;
|
|
192
|
-
}
|
|
193
|
-
break;
|
|
194
|
-
}
|
|
195
|
-
return projectsList;
|
|
196
|
-
//#endregion
|
|
197
|
-
};
|
|
198
|
-
return BaseProjectResolver;
|
|
199
|
-
}());
|
|
200
|
-
exports.BaseProjectResolver = BaseProjectResolver;
|
|
201
|
-
var BaseProject = exports.BaseProject = /** @class */ (function (_super) {
|
|
202
|
-
tslib_1.__extends(BaseProject, _super);
|
|
203
|
-
function BaseProject() {
|
|
204
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
205
|
-
}
|
|
206
|
-
Object.defineProperty(BaseProject.prototype, "name", {
|
|
42
|
+
Object.defineProperty(BaseProject.prototype, "dependencies", {
|
|
43
|
+
/**
|
|
44
|
+
* npm dependencies
|
|
45
|
+
*/
|
|
46
|
+
get: function () {
|
|
47
|
+
return (this.packageJSON ? this.packageJSON.dependencies : {}) || {};
|
|
48
|
+
},
|
|
49
|
+
enumerable: false,
|
|
50
|
+
configurable: true
|
|
51
|
+
});
|
|
52
|
+
Object.defineProperty(BaseProject.prototype, "peerDependencies", {
|
|
53
|
+
/**
|
|
54
|
+
* peerDependencies dependencies
|
|
55
|
+
*/
|
|
56
|
+
get: function () {
|
|
57
|
+
return (this.packageJSON ? this.packageJSON.peerDependencies : {}) || {};
|
|
58
|
+
},
|
|
59
|
+
enumerable: false,
|
|
60
|
+
configurable: true
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(BaseProject.prototype, "devDependencies", {
|
|
63
|
+
/**
|
|
64
|
+
* devDependencies dependencies
|
|
65
|
+
*/
|
|
66
|
+
get: function () {
|
|
67
|
+
return (this.packageJSON ? this.packageJSON.devDependencies : {}) || {};
|
|
68
|
+
},
|
|
69
|
+
enumerable: false,
|
|
70
|
+
configurable: true
|
|
71
|
+
});
|
|
72
|
+
Object.defineProperty(BaseProject.prototype, "resolutions", {
|
|
73
|
+
/**
|
|
74
|
+
* resolutions dependencies
|
|
75
|
+
*/
|
|
76
|
+
get: function () {
|
|
77
|
+
return (this.packageJSON ? this.packageJSON['resolutions'] : {}) || {};
|
|
78
|
+
},
|
|
79
|
+
enumerable: false,
|
|
80
|
+
configurable: true
|
|
81
|
+
});
|
|
82
|
+
Object.defineProperty(BaseProject.prototype, "allDependencies", {
|
|
83
|
+
/**
|
|
84
|
+
* object with all deps from package json
|
|
85
|
+
*/
|
|
86
|
+
get: function () {
|
|
87
|
+
return tnp_core_3._.merge(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign(tslib_1.__assign({}, this.devDependencies), this.peerDependencies), this.dependencies), this.resolutions));
|
|
88
|
+
},
|
|
89
|
+
enumerable: false,
|
|
90
|
+
configurable: true
|
|
91
|
+
});
|
|
92
|
+
Object.defineProperty(BaseProject.prototype, "tnp", {
|
|
207
93
|
get: function () {
|
|
208
94
|
var _a;
|
|
209
|
-
return (_a = this.packageJSON) === null || _a === void 0 ? void 0 : _a.
|
|
95
|
+
return (_a = this.packageJSON) === null || _a === void 0 ? void 0 : _a.tnp;
|
|
210
96
|
},
|
|
211
97
|
enumerable: false,
|
|
212
98
|
configurable: true
|
|
213
99
|
});
|
|
214
|
-
Object.defineProperty(BaseProject.prototype, "
|
|
100
|
+
Object.defineProperty(BaseProject.prototype, "firedev", {
|
|
215
101
|
get: function () {
|
|
216
102
|
var _a;
|
|
217
|
-
return (_a = this.packageJSON) === null || _a === void 0 ? void 0 : _a.
|
|
103
|
+
return (_a = this.packageJSON) === null || _a === void 0 ? void 0 : _a.firedev;
|
|
218
104
|
},
|
|
219
105
|
enumerable: false,
|
|
220
106
|
configurable: true
|
|
@@ -269,6 +155,9 @@ var BaseProject = exports.BaseProject = /** @class */ (function (_super) {
|
|
|
269
155
|
};
|
|
270
156
|
BaseProject.prototype.pathFor = function (relativePath) {
|
|
271
157
|
//#region @backendFunc
|
|
158
|
+
if (Array.isArray(relativePath)) {
|
|
159
|
+
relativePath = relativePath.join('/');
|
|
160
|
+
}
|
|
272
161
|
if (tnp_core_2.path.isAbsolute(relativePath)) {
|
|
273
162
|
Helpers.error("Cannot join relative path with absolute: ".concat(relativePath));
|
|
274
163
|
}
|
|
@@ -314,21 +203,37 @@ var BaseProject = exports.BaseProject = /** @class */ (function (_super) {
|
|
|
314
203
|
return Helpers.remove([this.location, relativePath], exactPath);
|
|
315
204
|
//#endregion
|
|
316
205
|
};
|
|
317
|
-
BaseProject.prototype.
|
|
318
|
-
|
|
206
|
+
BaseProject.prototype.linkNodeModulesTo = function (proj) {
|
|
207
|
+
//#region @backendFunc
|
|
208
|
+
var source = this.pathFor(tnp_config_1.config.folder.node_modules);
|
|
209
|
+
var dest = proj.pathFor(tnp_config_1.config.folder.node_modules);
|
|
210
|
+
Helpers.remove(dest, true);
|
|
211
|
+
Helpers.createSymLink(source, dest);
|
|
212
|
+
//#endregion
|
|
213
|
+
};
|
|
214
|
+
BaseProject.prototype.reinstallNodeModules = function (forcerRemoveNodeModules) {
|
|
215
|
+
if (forcerRemoveNodeModules === void 0) { forcerRemoveNodeModules = false; }
|
|
216
|
+
//#region @backendFunc
|
|
217
|
+
Helpers.taskStarted("Reinstalling node_modules in ".concat(this.genericName));
|
|
218
|
+
var source = this.pathFor(tnp_config_1.config.folder.node_modules);
|
|
219
|
+
if (forcerRemoveNodeModules) {
|
|
220
|
+
Helpers.remove(source, true);
|
|
221
|
+
}
|
|
222
|
+
this.run('yarn install').sync();
|
|
223
|
+
Helpers.taskDone("Reinstalling done for ".concat(this.genericName));
|
|
224
|
+
//#endregion
|
|
225
|
+
};
|
|
226
|
+
BaseProject.prototype.assignFreePort = function (startFrom, howManyFreePortsAfterThatPort) {
|
|
227
|
+
if (howManyFreePortsAfterThatPort === void 0) { howManyFreePortsAfterThatPort = 0; }
|
|
319
228
|
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
320
229
|
var max, i, port, err_1;
|
|
321
230
|
return tslib_1.__generator(this, function (_a) {
|
|
322
231
|
switch (_a.label) {
|
|
323
232
|
case 0:
|
|
324
|
-
//#region @backendFunc
|
|
325
|
-
if (tnp_core_3._.isNumber(this.port) && this.port >= startFrom) {
|
|
326
|
-
return [2 /*return*/, startFrom];
|
|
327
|
-
}
|
|
328
233
|
max = 2000;
|
|
329
234
|
i = 0;
|
|
330
235
|
while (takenPorts.includes(startFrom)) {
|
|
331
|
-
startFrom += 1;
|
|
236
|
+
startFrom += (1 + howManyFreePortsAfterThatPort);
|
|
332
237
|
}
|
|
333
238
|
_a.label = 1;
|
|
334
239
|
case 1:
|
|
@@ -340,11 +245,10 @@ var BaseProject = exports.BaseProject = /** @class */ (function (_super) {
|
|
|
340
245
|
case 3:
|
|
341
246
|
port = _a.sent();
|
|
342
247
|
takenPorts.push(port);
|
|
343
|
-
// @ts-ignore
|
|
344
|
-
this.port = port;
|
|
345
248
|
return [2 /*return*/, port];
|
|
346
249
|
case 4:
|
|
347
250
|
err_1 = _a.sent();
|
|
251
|
+
console.log(err_1);
|
|
348
252
|
Helpers.warn("Trying to assign port :".concat(startFrom, " but already in use."), false);
|
|
349
253
|
return [3 /*break*/, 5];
|
|
350
254
|
case 5:
|
|
@@ -358,7 +262,7 @@ var BaseProject = exports.BaseProject = /** @class */ (function (_super) {
|
|
|
358
262
|
});
|
|
359
263
|
});
|
|
360
264
|
};
|
|
361
|
-
BaseProject.ins = new BaseProjectResolver(BaseProject);
|
|
265
|
+
BaseProject.ins = new base_project_resolver_1.BaseProjectResolver(BaseProject);
|
|
362
266
|
return BaseProject;
|
|
363
267
|
}(git_project_1.ProjectGit
|
|
364
268
|
//#endregion
|