tnp-helpers 13.1.1 → 13.1.3
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/app.d.ts +1 -1
- package/app.js +6 -6
- package/browser/README.md +24 -24
- package/browser/esm2020/lib/base-component.mjs +47 -47
- package/browser/esm2020/lib/base-formly-component.mjs +125 -125
- package/browser/esm2020/lib/condition-wait.mjs +53 -53
- package/browser/esm2020/lib/constants.mjs +6 -6
- package/browser/esm2020/lib/dual-component-ctrl.mjs +120 -120
- package/browser/esm2020/lib/helpers-array-obj.mjs +80 -80
- package/browser/esm2020/lib/helpers-environment.mjs +30 -30
- package/browser/esm2020/lib/helpers-numbers.mjs +5 -5
- package/browser/esm2020/lib/helpers-strings-regexes.mjs +48 -48
- package/browser/esm2020/lib/helpers-strings.mjs +257 -257
- package/browser/esm2020/lib/helpers.mjs +276 -276
- package/browser/esm2020/lib/index.mjs +14 -14
- package/browser/esm2020/lib/long-press.directive.mjs +111 -111
- package/browser/esm2020/lib/project.mjs +413 -413
- package/browser/esm2020/lib/resize-service.mjs +19 -19
- package/browser/esm2020/public-api.mjs +1 -1
- package/browser/esm2020/tnp-helpers.mjs +4 -4
- package/browser/fesm2015/tnp-helpers.mjs +1535 -1535
- package/browser/fesm2020/tnp-helpers.mjs +1527 -1527
- package/browser/lib/base-component.d.ts +17 -17
- package/browser/lib/base-formly-component.d.ts +31 -31
- package/browser/lib/condition-wait.d.ts +8 -8
- package/browser/lib/constants.d.ts +6 -6
- package/browser/lib/dual-component-ctrl.d.ts +25 -25
- package/browser/lib/helpers-array-obj.d.ts +15 -15
- package/browser/lib/helpers-environment.d.ts +5 -5
- package/browser/lib/helpers-numbers.d.ts +3 -3
- package/browser/lib/helpers-strings-regexes.d.ts +28 -28
- package/browser/lib/helpers-strings.d.ts +50 -50
- package/browser/lib/helpers.d.ts +28 -28
- package/browser/lib/index.d.ts +9 -9
- package/browser/lib/long-press.directive.d.ts +25 -25
- package/browser/lib/project.d.ts +91 -91
- package/browser/lib/resize-service.d.ts +9 -9
- package/browser/public-api.d.ts +1 -1
- package/browser/tnp-helpers.d.ts +5 -5
- package/client/README.md +24 -24
- package/client/esm2020/lib/base-component.mjs +47 -47
- package/client/esm2020/lib/base-formly-component.mjs +125 -125
- package/client/esm2020/lib/condition-wait.mjs +53 -53
- package/client/esm2020/lib/constants.mjs +6 -6
- package/client/esm2020/lib/dual-component-ctrl.mjs +120 -120
- package/client/esm2020/lib/helpers-array-obj.mjs +80 -80
- package/client/esm2020/lib/helpers-environment.mjs +30 -30
- package/client/esm2020/lib/helpers-numbers.mjs +5 -5
- package/client/esm2020/lib/helpers-strings-regexes.mjs +48 -48
- package/client/esm2020/lib/helpers-strings.mjs +257 -257
- package/client/esm2020/lib/helpers.mjs +276 -276
- package/client/esm2020/lib/index.mjs +14 -14
- package/client/esm2020/lib/long-press.directive.mjs +111 -111
- package/client/esm2020/lib/project.mjs +413 -413
- package/client/esm2020/lib/resize-service.mjs +19 -19
- package/client/esm2020/public-api.mjs +1 -1
- package/client/esm2020/tnp-helpers.mjs +4 -4
- package/client/fesm2015/tnp-helpers.mjs +1535 -1535
- package/client/fesm2020/tnp-helpers.mjs +1527 -1527
- package/client/lib/base-component.d.ts +17 -17
- package/client/lib/base-formly-component.d.ts +31 -31
- package/client/lib/condition-wait.d.ts +8 -8
- package/client/lib/constants.d.ts +6 -6
- package/client/lib/dual-component-ctrl.d.ts +25 -25
- package/client/lib/helpers-array-obj.d.ts +15 -15
- package/client/lib/helpers-environment.d.ts +5 -5
- package/client/lib/helpers-numbers.d.ts +3 -3
- package/client/lib/helpers-strings-regexes.d.ts +28 -28
- package/client/lib/helpers-strings.d.ts +50 -50
- package/client/lib/helpers.d.ts +28 -28
- package/client/lib/index.d.ts +9 -9
- package/client/lib/long-press.directive.d.ts +25 -25
- package/client/lib/project.d.ts +91 -91
- package/client/lib/resize-service.d.ts +9 -9
- package/client/public-api.d.ts +1 -1
- package/client/tnp-helpers.d.ts +5 -5
- package/index.d.ts +1 -1
- package/index.js +5 -5
- package/lib/angular.helper.d.ts +22 -22
- package/lib/angular.helper.js +50 -50
- package/lib/base-component.d.ts +1 -1
- package/lib/base-component.js +6 -6
- package/lib/base-formly-component.d.ts +1 -1
- package/lib/base-formly-component.js +6 -6
- package/lib/condition-wait.d.ts +8 -8
- package/lib/condition-wait.js +94 -94
- package/lib/constants.d.ts +6 -6
- package/lib/constants.js +10 -10
- package/lib/dual-component-ctrl.d.ts +1 -1
- package/lib/dual-component-ctrl.js +6 -6
- package/lib/git-project.d.ts +44 -44
- package/lib/git-project.js +195 -195
- package/lib/helpers-array-obj.d.ts +15 -15
- package/lib/helpers-array-obj.js +88 -88
- package/lib/helpers-cli-tool.backend.d.ts +45 -45
- package/lib/helpers-cli-tool.backend.js +293 -293
- package/lib/helpers-dependencies.backend.d.ts +11 -11
- package/lib/helpers-dependencies.backend.js +105 -105
- package/lib/helpers-environment.d.ts +5 -5
- package/lib/helpers-environment.js +35 -35
- package/lib/helpers-file-folders.backend.d.ts +84 -84
- package/lib/helpers-file-folders.backend.js +736 -736
- package/lib/helpers-git.backend.d.ts +35 -35
- package/lib/helpers-git.backend.js +541 -545
- package/lib/helpers-git.backend.js.map +1 -1
- package/lib/helpers-json5.backend.d.ts +16 -16
- package/lib/helpers-json5.backend.js +70 -70
- package/lib/helpers-morphi-framework.backend.d.ts +4 -4
- package/lib/helpers-morphi-framework.backend.js +49 -49
- package/lib/helpers-network.backend.d.ts +8 -8
- package/lib/helpers-network.backend.js +48 -48
- package/lib/helpers-npm.backend.d.ts +3 -3
- package/lib/helpers-npm.backend.js +17 -17
- package/lib/helpers-numbers.d.ts +3 -3
- package/lib/helpers-numbers.js +11 -11
- package/lib/helpers-path.backend.d.ts +7 -7
- package/lib/helpers-path.backend.js +36 -36
- package/lib/helpers-process.backend.d.ts +57 -57
- package/lib/helpers-process.backend.js +529 -529
- package/lib/helpers-process.backend.js.map +1 -1
- package/lib/helpers-strings-regexes.d.ts +28 -28
- package/lib/helpers-strings-regexes.js +60 -60
- package/lib/helpers-strings.d.ts +50 -50
- package/lib/helpers-strings.js +265 -265
- package/lib/helpers-system-terminal.backend.d.ts +5 -5
- package/lib/helpers-system-terminal.backend.js +53 -53
- package/lib/helpers.d.ts +67 -67
- package/lib/helpers.js +391 -391
- package/lib/index.d.ts +6 -6
- package/lib/index.js +19 -19
- package/lib/long-press.directive.d.ts +22 -22
- package/lib/long-press.directive.js +141 -141
- package/lib/merge-helpers.backend.d.ts +23 -23
- package/lib/merge-helpers.backend.js +108 -108
- package/lib/project.d.ts +94 -94
- package/lib/project.js +422 -422
- package/lib/resize-service.d.ts +6 -6
- package/lib/resize-service.js +24 -24
- package/lib/ts-code/index.d.ts +1 -1
- package/lib/ts-code/index.js +7 -7
- package/lib/ts-code/ts-code-extractor.d.ts +14 -14
- package/lib/ts-code/ts-code-extractor.js +46 -46
- package/lib/ts-code/ts-code-modifier.backend.d.ts +12 -12
- package/lib/ts-code/ts-code-modifier.backend.js +70 -70
- package/package.json +5 -5
- package/package.json_devDependencies.json +222 -222
- package/package.json_tnp.json5 +41 -41
- package/tmp-environment.json +36 -35
- package/websql/README.md +24 -24
- package/websql/esm2020/lib/base-component.mjs +47 -47
- package/websql/esm2020/lib/base-formly-component.mjs +125 -125
- package/websql/esm2020/lib/condition-wait.mjs +53 -53
- package/websql/esm2020/lib/constants.mjs +6 -6
- package/websql/esm2020/lib/dual-component-ctrl.mjs +120 -120
- package/websql/esm2020/lib/helpers-array-obj.mjs +80 -80
- package/websql/esm2020/lib/helpers-environment.mjs +30 -30
- package/websql/esm2020/lib/helpers-numbers.mjs +5 -5
- package/websql/esm2020/lib/helpers-strings-regexes.mjs +48 -48
- package/websql/esm2020/lib/helpers-strings.mjs +257 -257
- package/websql/esm2020/lib/helpers.mjs +276 -276
- package/websql/esm2020/lib/index.mjs +14 -14
- package/websql/esm2020/lib/long-press.directive.mjs +111 -111
- package/websql/esm2020/lib/project.mjs +413 -413
- package/websql/esm2020/lib/resize-service.mjs +19 -19
- package/websql/esm2020/public-api.mjs +1 -1
- package/websql/esm2020/tnp-helpers.mjs +4 -4
- package/websql/fesm2015/tnp-helpers.mjs +1535 -1535
- package/websql/fesm2020/tnp-helpers.mjs +1527 -1527
- package/websql/lib/base-component.d.ts +17 -17
- package/websql/lib/base-formly-component.d.ts +31 -31
- package/websql/lib/condition-wait.d.ts +8 -8
- package/websql/lib/constants.d.ts +6 -6
- package/websql/lib/dual-component-ctrl.d.ts +25 -25
- package/websql/lib/helpers-array-obj.d.ts +15 -15
- package/websql/lib/helpers-environment.d.ts +5 -5
- package/websql/lib/helpers-numbers.d.ts +3 -3
- package/websql/lib/helpers-strings-regexes.d.ts +28 -28
- package/websql/lib/helpers-strings.d.ts +50 -50
- package/websql/lib/helpers.d.ts +28 -28
- package/websql/lib/index.d.ts +9 -9
- package/websql/lib/long-press.directive.d.ts +25 -25
- package/websql/lib/project.d.ts +91 -91
- package/websql/lib/resize-service.d.ts +9 -9
- package/websql/public-api.d.ts +1 -1
- package/websql/tnp-helpers.d.ts +5 -5
package/lib/project.js
CHANGED
|
@@ -1,422 +1,422 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Project = void 0;
|
|
4
|
-
var tslib_1 = require("tslib");
|
|
5
|
-
//#region @backend
|
|
6
|
-
var tnp_core_1 = require("tnp-core");
|
|
7
|
-
var git_project_1 = require("./git-project");
|
|
8
|
-
var tnp_cli_1 = require("tnp-cli");
|
|
9
|
-
var tnp_config_1 = require("tnp-config");
|
|
10
|
-
var tnp_core_2 = require("tnp-core");
|
|
11
|
-
var typescript_class_helpers_1 = require("typescript-class-helpers");
|
|
12
|
-
var morphi_1 = require("morphi");
|
|
13
|
-
var helpers_1 = require("./helpers");
|
|
14
|
-
var Helpers = helpers_1.HelpersTnp.Instance;
|
|
15
|
-
var Project = /** @class */ (function (_super) {
|
|
16
|
-
tslib_1.__extends(Project, _super);
|
|
17
|
-
function Project() {
|
|
18
|
-
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
19
|
-
//#region @backend
|
|
20
|
-
_this.cache = {};
|
|
21
|
-
_this.browser = {};
|
|
22
|
-
return _this;
|
|
23
|
-
}
|
|
24
|
-
Project.typeFrom = function (location) {
|
|
25
|
-
//#region @backendFunc
|
|
26
|
-
var PackageJSON = typescript_class_helpers_1.CLASS.getBy('PackageJSON');
|
|
27
|
-
location = (0, tnp_core_1.crossPlatformPath)(location);
|
|
28
|
-
if (!tnp_core_1.fse.existsSync(location)) {
|
|
29
|
-
return void 0;
|
|
30
|
-
}
|
|
31
|
-
var packageJson = PackageJSON && PackageJSON.fromLocation(location);
|
|
32
|
-
if (!tnp_core_2._.isObject(packageJson)) {
|
|
33
|
-
return void 0;
|
|
34
|
-
}
|
|
35
|
-
var type = packageJson.type;
|
|
36
|
-
return type;
|
|
37
|
-
//#endregion
|
|
38
|
-
};
|
|
39
|
-
Project.unload = function (project) {
|
|
40
|
-
Project.projects = Project.projects.filter(function (f) { return f !== project; });
|
|
41
|
-
};
|
|
42
|
-
Project.From = function (location) {
|
|
43
|
-
//#region @backendFunc
|
|
44
|
-
var PackageJSON = typescript_class_helpers_1.CLASS.getBy('PackageJSON');
|
|
45
|
-
if (!tnp_core_2._.isString(location)) {
|
|
46
|
-
Helpers.warn("[project.from] location is not a string");
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
if (tnp_core_1.path.basename(location) === 'dist') {
|
|
50
|
-
location = tnp_core_1.path.dirname(location);
|
|
51
|
-
}
|
|
52
|
-
location = (0, tnp_core_1.crossPlatformPath)(tnp_core_1.path.resolve(location));
|
|
53
|
-
if (Project.emptyLocations.includes(location)) {
|
|
54
|
-
if (location.search("/".concat(tnp_config_1.config.folder.bundle)) === -1) {
|
|
55
|
-
Helpers.log("[project.from] empty location ".concat(location), 2);
|
|
56
|
-
return;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
var alreadyExist = Project.projects.find(function (l) { return l.location.trim() === location.trim(); });
|
|
60
|
-
if (alreadyExist) {
|
|
61
|
-
return alreadyExist;
|
|
62
|
-
}
|
|
63
|
-
if (!tnp_core_1.fse.existsSync(location)) {
|
|
64
|
-
Helpers.log("[tnp-helpers][project.from] Cannot find project in location: ".concat(location), 1);
|
|
65
|
-
Project.emptyLocations.push(location);
|
|
66
|
-
return;
|
|
67
|
-
}
|
|
68
|
-
if (PackageJSON && !PackageJSON.fromLocation(location)) {
|
|
69
|
-
if (!isDockerProject(location)) {
|
|
70
|
-
Helpers.log("[tnp-helpers][project.from] Cannot find package.json in location: ".concat(location), 1);
|
|
71
|
-
Project.emptyLocations.push(location);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
;
|
|
76
|
-
var type = this.typeFrom(location);
|
|
77
|
-
PackageJSON && checkIfTypeIsNotCorrect(type, location);
|
|
78
|
-
// Helpers.log(`[tnp-helpers] Type "${type}" for ${location} `)
|
|
79
|
-
var resultProject;
|
|
80
|
-
if (type === 'isomorphic-lib') {
|
|
81
|
-
resultProject = new (getClassFunction('ProjectIsomorphicLib'))(location);
|
|
82
|
-
}
|
|
83
|
-
if (type === 'angular-lib') {
|
|
84
|
-
resultProject = new (getClassFunction('ProjectAngularLib'))(location);
|
|
85
|
-
}
|
|
86
|
-
if (type === 'electron-client') {
|
|
87
|
-
resultProject = new (getClassFunction('ProjectElectronClient'))(location);
|
|
88
|
-
}
|
|
89
|
-
if (type === 'vscode-ext') {
|
|
90
|
-
resultProject = new (getClassFunction('ProjectVscodeExt'))(location);
|
|
91
|
-
}
|
|
92
|
-
if (type === 'angular-client') {
|
|
93
|
-
resultProject = new (getClassFunction('ProjectAngularClient'))(location);
|
|
94
|
-
}
|
|
95
|
-
if (type === 'workspace') {
|
|
96
|
-
resultProject = new (getClassFunction('ProjectWorkspace'))(location);
|
|
97
|
-
}
|
|
98
|
-
if (type === 'docker') {
|
|
99
|
-
resultProject = new (getClassFunction('ProjectDocker'))(location);
|
|
100
|
-
}
|
|
101
|
-
if (type === 'ionic-client') {
|
|
102
|
-
resultProject = new (getClassFunction('ProjectIonicClient'))(location);
|
|
103
|
-
}
|
|
104
|
-
if (type === 'container') {
|
|
105
|
-
resultProject = new (getClassFunction('ProjectContainer'))(location);
|
|
106
|
-
}
|
|
107
|
-
if (type === 'navi') {
|
|
108
|
-
if (['tnp', 'firedev'].includes(tnp_config_1.config.frameworkName)) {
|
|
109
|
-
Helpers.error("\n!!!\n!!!\n THIS SHOULD NOT BE NAVI PROJECT: ".concat(location, "\n!!!\n!!!\n "), true, true);
|
|
110
|
-
}
|
|
111
|
-
resultProject = new (getClassFunction('ProjectNavi'))(location);
|
|
112
|
-
}
|
|
113
|
-
if (type === 'leaf') {
|
|
114
|
-
resultProject = new (getClassFunction('ProjectLeaf'))(location);
|
|
115
|
-
}
|
|
116
|
-
if (type === 'unknow-npm-project') {
|
|
117
|
-
resultProject = new (getClassFunction('ProjectUnknowNpm'))(location);
|
|
118
|
-
}
|
|
119
|
-
if (type === 'scenario') {
|
|
120
|
-
resultProject = new (getClassFunction('ProjectScenarioReqRes'))(location);
|
|
121
|
-
}
|
|
122
|
-
// log(resultProject ? (`PROJECT ${resultProject.type} in ${location}`)
|
|
123
|
-
// : ('NO PROJECT FROM LOCATION ' + location))
|
|
124
|
-
if (resultProject) {
|
|
125
|
-
Helpers.log("[tnp-helpers][project.from] ".concat(tnp_cli_1.CLI.chalk.bold(resultProject.name), " from ...").concat(location.substr(location.length - 100)), 1);
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
128
|
-
if (PackageJSON) {
|
|
129
|
-
Helpers.log("[tnp-helpers][project.from] project not found in ".concat(location), 1);
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
var packagejsonpath = tnp_core_1.path.join(location, 'package.json');
|
|
133
|
-
if (tnp_core_1.fse.existsSync(packagejsonpath)) {
|
|
134
|
-
var name_1 = Helpers.getValueFromJSON(packagejsonpath, 'name');
|
|
135
|
-
// if (name && name === path.basename(location)) { TODO think about it
|
|
136
|
-
if (name_1) {
|
|
137
|
-
resultProject = new Project();
|
|
138
|
-
resultProject.location = (0, tnp_core_1.crossPlatformPath)(location);
|
|
139
|
-
resultProject.name = name_1;
|
|
140
|
-
resultProject.type = Helpers.getValueFromJSON(tnp_core_1.path.join(location, 'package.json'), 'tnp.type');
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
return resultProject;
|
|
146
|
-
//#endregion
|
|
147
|
-
};
|
|
148
|
-
Project.nearestTo = function (absoluteLocation, options) {
|
|
149
|
-
//#region @backendFunc
|
|
150
|
-
options = options || {};
|
|
151
|
-
var type = options.type, findGitRoot = options.findGitRoot, onlyOutSideNodeModules = options.onlyOutSideNodeModules;
|
|
152
|
-
if (tnp_core_2._.isString(type) && !tnp_config_1.LibTypeArr.includes(type)) {
|
|
153
|
-
Helpers.error("[tnp-helpers][project.nearestTo] wrong type: ".concat(type), false, true);
|
|
154
|
-
}
|
|
155
|
-
if (tnp_core_1.fse.existsSync(absoluteLocation)) {
|
|
156
|
-
absoluteLocation = tnp_core_1.fse.realpathSync(absoluteLocation);
|
|
157
|
-
}
|
|
158
|
-
if (tnp_core_1.fse.existsSync(absoluteLocation) && !tnp_core_1.fse.lstatSync(absoluteLocation).isDirectory()) {
|
|
159
|
-
absoluteLocation = tnp_core_1.path.dirname(absoluteLocation);
|
|
160
|
-
}
|
|
161
|
-
var project;
|
|
162
|
-
var previousLocation;
|
|
163
|
-
while (true) {
|
|
164
|
-
if (onlyOutSideNodeModules && (tnp_core_1.path.basename(tnp_core_1.path.dirname(absoluteLocation)) === 'node_modules')) {
|
|
165
|
-
absoluteLocation = tnp_core_1.path.dirname(tnp_core_1.path.dirname(absoluteLocation));
|
|
166
|
-
}
|
|
167
|
-
project = Project.From(absoluteLocation);
|
|
168
|
-
if (tnp_core_2._.isString(type)) {
|
|
169
|
-
if (project === null || project === void 0 ? void 0 : project.typeIs(type)) {
|
|
170
|
-
if (findGitRoot) {
|
|
171
|
-
if (project.git.isGitRoot) {
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
else {
|
|
176
|
-
break;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
else {
|
|
181
|
-
if (project) {
|
|
182
|
-
if (findGitRoot) {
|
|
183
|
-
if (project.git.isGitRoot) {
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
else {
|
|
188
|
-
break;
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
previousLocation = absoluteLocation;
|
|
193
|
-
var newAbsLocation = tnp_core_1.path.join(absoluteLocation, '..');
|
|
194
|
-
if (!tnp_core_1.path.isAbsolute(newAbsLocation)) {
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
absoluteLocation = (0, tnp_core_1.crossPlatformPath)(tnp_core_1.path.resolve(newAbsLocation));
|
|
198
|
-
if (!tnp_core_1.fse.existsSync(absoluteLocation) && absoluteLocation.split('/').length < 2) {
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
if (previousLocation === absoluteLocation) {
|
|
202
|
-
return;
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
return project;
|
|
206
|
-
//#endregion
|
|
207
|
-
};
|
|
208
|
-
Project.allProjectFrom = function (absoluteLocation, stopOnCwd) {
|
|
209
|
-
if (stopOnCwd === void 0) { stopOnCwd = '/'; }
|
|
210
|
-
//#region @backendFunc
|
|
211
|
-
var projects = {};
|
|
212
|
-
var projectsList = [];
|
|
213
|
-
var previousAbsLocation;
|
|
214
|
-
while (absoluteLocation.startsWith(stopOnCwd)) {
|
|
215
|
-
if (previousAbsLocation === absoluteLocation) {
|
|
216
|
-
break;
|
|
217
|
-
}
|
|
218
|
-
var proj = Project.nearestTo(absoluteLocation);
|
|
219
|
-
if (proj) {
|
|
220
|
-
if (projects[proj.location]) {
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
|
-
projects[proj.location] = proj;
|
|
224
|
-
projectsList.push(proj);
|
|
225
|
-
previousAbsLocation = absoluteLocation;
|
|
226
|
-
absoluteLocation = tnp_core_1.path.dirname(proj.location);
|
|
227
|
-
continue;
|
|
228
|
-
}
|
|
229
|
-
break;
|
|
230
|
-
}
|
|
231
|
-
return projectsList;
|
|
232
|
-
//#endregion
|
|
233
|
-
};
|
|
234
|
-
Project.DefaultPortByType = function (type) {
|
|
235
|
-
if (type === 'workspace') {
|
|
236
|
-
return 5000;
|
|
237
|
-
}
|
|
238
|
-
if (type === 'angular-client') {
|
|
239
|
-
return 4300;
|
|
240
|
-
}
|
|
241
|
-
if (type === 'angular-lib') {
|
|
242
|
-
return 4250;
|
|
243
|
-
}
|
|
244
|
-
if (type === 'electron-client') {
|
|
245
|
-
return 4350;
|
|
246
|
-
}
|
|
247
|
-
if (type === 'ionic-client') {
|
|
248
|
-
return 8080;
|
|
249
|
-
}
|
|
250
|
-
if (type === 'docker') {
|
|
251
|
-
return 5000;
|
|
252
|
-
}
|
|
253
|
-
if (type === 'isomorphic-lib') {
|
|
254
|
-
return 4000;
|
|
255
|
-
}
|
|
256
|
-
if (type === 'container' || type === 'unknow-npm-project') {
|
|
257
|
-
return;
|
|
258
|
-
}
|
|
259
|
-
};
|
|
260
|
-
Object.defineProperty(Project, "isBundleMode", {
|
|
261
|
-
get: function () {
|
|
262
|
-
if (Helpers.isBrowser) {
|
|
263
|
-
return true;
|
|
264
|
-
}
|
|
265
|
-
//#region @backend
|
|
266
|
-
return !(!!global[tnp_core_2.CoreConfig.message.globalSystemToolMode]);
|
|
267
|
-
//#endregion
|
|
268
|
-
},
|
|
269
|
-
enumerable: false,
|
|
270
|
-
configurable: true
|
|
271
|
-
});
|
|
272
|
-
Object.defineProperty(Project, "Current", {
|
|
273
|
-
get: function () {
|
|
274
|
-
//#region @backendFunc
|
|
275
|
-
var current = Project.From(process.cwd());
|
|
276
|
-
if (!current) {
|
|
277
|
-
Helpers.warn("[tnp-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 }"));
|
|
278
|
-
return void 0;
|
|
279
|
-
}
|
|
280
|
-
return current;
|
|
281
|
-
//#endregion
|
|
282
|
-
},
|
|
283
|
-
enumerable: false,
|
|
284
|
-
configurable: true
|
|
285
|
-
});
|
|
286
|
-
Object.defineProperty(Project, "NaviCliLocation", {
|
|
287
|
-
//#region @backend
|
|
288
|
-
get: function () {
|
|
289
|
-
return tnp_core_1.path.resolve(tnp_core_1.path.join(Project.Tnp.location, '../navi-cli'));
|
|
290
|
-
},
|
|
291
|
-
enumerable: false,
|
|
292
|
-
configurable: true
|
|
293
|
-
});
|
|
294
|
-
Object.defineProperty(Project, "Tnp", {
|
|
295
|
-
//#endregion
|
|
296
|
-
get: function () {
|
|
297
|
-
//#region @backendFunc
|
|
298
|
-
var tnpPorject = Project.From(tnp_config_1.config.pathes.tnp_folder_location);
|
|
299
|
-
Helpers.log("Using ".concat(tnp_config_1.config.frameworkName, " path: ").concat(tnp_config_1.config.pathes.tnp_folder_location), 1);
|
|
300
|
-
if (!tnpPorject && !global.globalSystemToolMode) {
|
|
301
|
-
Helpers.error("Not able to find tnp project in \"".concat(tnp_config_1.config.pathes.tnp_folder_location, "\"."));
|
|
302
|
-
}
|
|
303
|
-
return tnpPorject;
|
|
304
|
-
//#endregion
|
|
305
|
-
},
|
|
306
|
-
enumerable: false,
|
|
307
|
-
configurable: true
|
|
308
|
-
});
|
|
309
|
-
Project.by = function (libraryType, version
|
|
310
|
-
//#endregion
|
|
311
|
-
) {
|
|
312
|
-
//#region @backendFunc
|
|
313
|
-
if (version === void 0) { version = tnp_config_1.config.defaultFrameworkVersion; }
|
|
314
|
-
if (libraryType === 'workspace') {
|
|
315
|
-
var workspaceProject = Project.From(tnp_config_1.config.pathes.projectsExamples(version).workspace);
|
|
316
|
-
return workspaceProject;
|
|
317
|
-
}
|
|
318
|
-
if (libraryType === 'container') {
|
|
319
|
-
var containerProject = Project.From(tnp_config_1.config.pathes.projectsExamples(version).container);
|
|
320
|
-
return containerProject;
|
|
321
|
-
}
|
|
322
|
-
if (libraryType === 'single-file-project') {
|
|
323
|
-
var singleFileProject = Project.From(tnp_config_1.config.pathes.projectsExamples(version).singlefileproject);
|
|
324
|
-
return singleFileProject;
|
|
325
|
-
}
|
|
326
|
-
var projectPath = tnp_config_1.config.pathes.projectsExamples(version).projectByType(libraryType);
|
|
327
|
-
if (!tnp_core_1.fse.existsSync(projectPath)) {
|
|
328
|
-
Helpers.error("\n ".concat(projectPath, "\n ").concat(projectPath.replace(/\//g, '\\\\'), "\n ").concat((0, tnp_core_1.crossPlatformPath)(projectPath), "\n [tnp-helpers] Bad library type \"").concat(libraryType, "\" for this framework version \"").concat(version, "\"\n\n "), false, false);
|
|
329
|
-
}
|
|
330
|
-
return Project.From(projectPath);
|
|
331
|
-
//#endregion
|
|
332
|
-
};
|
|
333
|
-
Project.prototype.defineProperty = function (variableName, classFn) {
|
|
334
|
-
//#region @backendFunc
|
|
335
|
-
var that = this;
|
|
336
|
-
var prefixedName = "__".concat(variableName);
|
|
337
|
-
Object.defineProperty(this, variableName, {
|
|
338
|
-
get: function () {
|
|
339
|
-
if (!that[prefixedName]) {
|
|
340
|
-
that[prefixedName] = new classFn(that);
|
|
341
|
-
}
|
|
342
|
-
return that[prefixedName];
|
|
343
|
-
},
|
|
344
|
-
set: function (v) {
|
|
345
|
-
that[prefixedName] = v;
|
|
346
|
-
},
|
|
347
|
-
});
|
|
348
|
-
//#endregion
|
|
349
|
-
};
|
|
350
|
-
Project.prototype.setType = function (type) {
|
|
351
|
-
// @ts-ignore
|
|
352
|
-
this._type = type;
|
|
353
|
-
};
|
|
354
|
-
Project.prototype.typeIs = function () {
|
|
355
|
-
var types = [];
|
|
356
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
357
|
-
types[_i] = arguments[_i];
|
|
358
|
-
}
|
|
359
|
-
return this._type && types.includes(this._type);
|
|
360
|
-
};
|
|
361
|
-
Project.prototype.typeIsNot = function () {
|
|
362
|
-
var types = [];
|
|
363
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
364
|
-
types[_i] = arguments[_i];
|
|
365
|
-
}
|
|
366
|
-
return !this.typeIs.apply(this, tslib_1.__spreadArray([], tslib_1.__read(types), false));
|
|
367
|
-
};
|
|
368
|
-
Project.prototype.forEmptyStructure = function () {
|
|
369
|
-
return [
|
|
370
|
-
{ relativePath: tnp_config_1.config.file.package_json, includeContent: true },
|
|
371
|
-
{ relativePath: tnp_config_1.config.folder.src },
|
|
372
|
-
];
|
|
373
|
-
};
|
|
374
|
-
Project.projects = [];
|
|
375
|
-
/**
|
|
376
|
-
* To speed up checking folder I am keeping pathes for alterdy checked folder
|
|
377
|
-
* This may break things that are creating new projects
|
|
378
|
-
*/
|
|
379
|
-
Project.emptyLocations = [];
|
|
380
|
-
tslib_1.__decorate([
|
|
381
|
-
morphi_1.Morphi.Orm.Column.Primary({ type: 'varchar', length: 400 }),
|
|
382
|
-
tslib_1.__metadata("design:type", Object)
|
|
383
|
-
], Project.prototype, "cache", void 0);
|
|
384
|
-
return Project;
|
|
385
|
-
}(git_project_1.ProjectGit
|
|
386
|
-
//#endregion
|
|
387
|
-
));
|
|
388
|
-
exports.Project = Project;
|
|
389
|
-
//#region @backend
|
|
390
|
-
function isDockerProject(location) {
|
|
391
|
-
if (tnp_core_1.fse.existsSync(tnp_core_1.path.join(location, 'Dockerfile'))) {
|
|
392
|
-
var packageJson = tnp_core_1.path.join(location, 'package.json');
|
|
393
|
-
if (!Helpers.exists(packageJson)) {
|
|
394
|
-
Helpers.writeFile(packageJson, {
|
|
395
|
-
"name": tnp_core_1.path.basename(location),
|
|
396
|
-
"version": "0.0.0"
|
|
397
|
-
});
|
|
398
|
-
}
|
|
399
|
-
var pj = Helpers.readJson(packageJson);
|
|
400
|
-
pj[tnp_config_1.config.frameworkName] = {
|
|
401
|
-
"type": "docker",
|
|
402
|
-
"version": "v2"
|
|
403
|
-
};
|
|
404
|
-
Helpers.writeFile(packageJson, pj);
|
|
405
|
-
return true;
|
|
406
|
-
}
|
|
407
|
-
return false;
|
|
408
|
-
}
|
|
409
|
-
function getClassFunction(className) {
|
|
410
|
-
var classFN = typescript_class_helpers_1.CLASS.getBy(className);
|
|
411
|
-
if (!classFN) {
|
|
412
|
-
Helpers.error("[tnp-helpers][Project.From] cannot find class function by name ".concat(className));
|
|
413
|
-
}
|
|
414
|
-
return classFN;
|
|
415
|
-
}
|
|
416
|
-
function checkIfTypeIsNotCorrect(type, location) {
|
|
417
|
-
if (tnp_core_2._.isString(type) && !tnp_config_1.LibTypeArr.includes(type)) {
|
|
418
|
-
Helpers.error("Incorrect type: \"".concat(type, "\"\n\n Please use one of this: ").concat(tnp_config_1.LibTypeArr.join(','), "\n\n in\n package.json > ").concat(tnp_config_1.config.frameworkName, ".type\n\n location: ").concat(location, "\n\n "), false, true);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
//#endregion
|
|
422
|
-
//# sourceMappingURL
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Project = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
//#region @backend
|
|
6
|
+
var tnp_core_1 = require("tnp-core");
|
|
7
|
+
var git_project_1 = require("./git-project");
|
|
8
|
+
var tnp_cli_1 = require("tnp-cli");
|
|
9
|
+
var tnp_config_1 = require("tnp-config");
|
|
10
|
+
var tnp_core_2 = require("tnp-core");
|
|
11
|
+
var typescript_class_helpers_1 = require("typescript-class-helpers");
|
|
12
|
+
var morphi_1 = require("morphi");
|
|
13
|
+
var helpers_1 = require("./helpers");
|
|
14
|
+
var Helpers = helpers_1.HelpersTnp.Instance;
|
|
15
|
+
var Project = /** @class */ (function (_super) {
|
|
16
|
+
tslib_1.__extends(Project, _super);
|
|
17
|
+
function Project() {
|
|
18
|
+
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
19
|
+
//#region @backend
|
|
20
|
+
_this.cache = {};
|
|
21
|
+
_this.browser = {};
|
|
22
|
+
return _this;
|
|
23
|
+
}
|
|
24
|
+
Project.typeFrom = function (location) {
|
|
25
|
+
//#region @backendFunc
|
|
26
|
+
var PackageJSON = typescript_class_helpers_1.CLASS.getBy('PackageJSON');
|
|
27
|
+
location = (0, tnp_core_1.crossPlatformPath)(location);
|
|
28
|
+
if (!tnp_core_1.fse.existsSync(location)) {
|
|
29
|
+
return void 0;
|
|
30
|
+
}
|
|
31
|
+
var packageJson = PackageJSON && PackageJSON.fromLocation(location);
|
|
32
|
+
if (!tnp_core_2._.isObject(packageJson)) {
|
|
33
|
+
return void 0;
|
|
34
|
+
}
|
|
35
|
+
var type = packageJson.type;
|
|
36
|
+
return type;
|
|
37
|
+
//#endregion
|
|
38
|
+
};
|
|
39
|
+
Project.unload = function (project) {
|
|
40
|
+
Project.projects = Project.projects.filter(function (f) { return f !== project; });
|
|
41
|
+
};
|
|
42
|
+
Project.From = function (location) {
|
|
43
|
+
//#region @backendFunc
|
|
44
|
+
var PackageJSON = typescript_class_helpers_1.CLASS.getBy('PackageJSON');
|
|
45
|
+
if (!tnp_core_2._.isString(location)) {
|
|
46
|
+
Helpers.warn("[project.from] location is not a string");
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
if (tnp_core_1.path.basename(location) === 'dist') {
|
|
50
|
+
location = tnp_core_1.path.dirname(location);
|
|
51
|
+
}
|
|
52
|
+
location = (0, tnp_core_1.crossPlatformPath)(tnp_core_1.path.resolve(location));
|
|
53
|
+
if (Project.emptyLocations.includes(location)) {
|
|
54
|
+
if (location.search("/".concat(tnp_config_1.config.folder.bundle)) === -1) {
|
|
55
|
+
Helpers.log("[project.from] empty location ".concat(location), 2);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
var alreadyExist = Project.projects.find(function (l) { return l.location.trim() === location.trim(); });
|
|
60
|
+
if (alreadyExist) {
|
|
61
|
+
return alreadyExist;
|
|
62
|
+
}
|
|
63
|
+
if (!tnp_core_1.fse.existsSync(location)) {
|
|
64
|
+
Helpers.log("[tnp-helpers][project.from] Cannot find project in location: ".concat(location), 1);
|
|
65
|
+
Project.emptyLocations.push(location);
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
if (PackageJSON && !PackageJSON.fromLocation(location)) {
|
|
69
|
+
if (!isDockerProject(location)) {
|
|
70
|
+
Helpers.log("[tnp-helpers][project.from] Cannot find package.json in location: ".concat(location), 1);
|
|
71
|
+
Project.emptyLocations.push(location);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
;
|
|
76
|
+
var type = this.typeFrom(location);
|
|
77
|
+
PackageJSON && checkIfTypeIsNotCorrect(type, location);
|
|
78
|
+
// Helpers.log(`[tnp-helpers] Type "${type}" for ${location} `)
|
|
79
|
+
var resultProject;
|
|
80
|
+
if (type === 'isomorphic-lib') {
|
|
81
|
+
resultProject = new (getClassFunction('ProjectIsomorphicLib'))(location);
|
|
82
|
+
}
|
|
83
|
+
if (type === 'angular-lib') {
|
|
84
|
+
resultProject = new (getClassFunction('ProjectAngularLib'))(location);
|
|
85
|
+
}
|
|
86
|
+
if (type === 'electron-client') {
|
|
87
|
+
resultProject = new (getClassFunction('ProjectElectronClient'))(location);
|
|
88
|
+
}
|
|
89
|
+
if (type === 'vscode-ext') {
|
|
90
|
+
resultProject = new (getClassFunction('ProjectVscodeExt'))(location);
|
|
91
|
+
}
|
|
92
|
+
if (type === 'angular-client') {
|
|
93
|
+
resultProject = new (getClassFunction('ProjectAngularClient'))(location);
|
|
94
|
+
}
|
|
95
|
+
if (type === 'workspace') {
|
|
96
|
+
resultProject = new (getClassFunction('ProjectWorkspace'))(location);
|
|
97
|
+
}
|
|
98
|
+
if (type === 'docker') {
|
|
99
|
+
resultProject = new (getClassFunction('ProjectDocker'))(location);
|
|
100
|
+
}
|
|
101
|
+
if (type === 'ionic-client') {
|
|
102
|
+
resultProject = new (getClassFunction('ProjectIonicClient'))(location);
|
|
103
|
+
}
|
|
104
|
+
if (type === 'container') {
|
|
105
|
+
resultProject = new (getClassFunction('ProjectContainer'))(location);
|
|
106
|
+
}
|
|
107
|
+
if (type === 'navi') {
|
|
108
|
+
if (['tnp', 'firedev'].includes(tnp_config_1.config.frameworkName)) {
|
|
109
|
+
Helpers.error("\n!!!\n!!!\n THIS SHOULD NOT BE NAVI PROJECT: ".concat(location, "\n!!!\n!!!\n "), true, true);
|
|
110
|
+
}
|
|
111
|
+
resultProject = new (getClassFunction('ProjectNavi'))(location);
|
|
112
|
+
}
|
|
113
|
+
if (type === 'leaf') {
|
|
114
|
+
resultProject = new (getClassFunction('ProjectLeaf'))(location);
|
|
115
|
+
}
|
|
116
|
+
if (type === 'unknow-npm-project') {
|
|
117
|
+
resultProject = new (getClassFunction('ProjectUnknowNpm'))(location);
|
|
118
|
+
}
|
|
119
|
+
if (type === 'scenario') {
|
|
120
|
+
resultProject = new (getClassFunction('ProjectScenarioReqRes'))(location);
|
|
121
|
+
}
|
|
122
|
+
// log(resultProject ? (`PROJECT ${resultProject.type} in ${location}`)
|
|
123
|
+
// : ('NO PROJECT FROM LOCATION ' + location))
|
|
124
|
+
if (resultProject) {
|
|
125
|
+
Helpers.log("[tnp-helpers][project.from] ".concat(tnp_cli_1.CLI.chalk.bold(resultProject.name), " from ...").concat(location.substr(location.length - 100)), 1);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
if (PackageJSON) {
|
|
129
|
+
Helpers.log("[tnp-helpers][project.from] project not found in ".concat(location), 1);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
var packagejsonpath = tnp_core_1.path.join(location, 'package.json');
|
|
133
|
+
if (tnp_core_1.fse.existsSync(packagejsonpath)) {
|
|
134
|
+
var name_1 = Helpers.getValueFromJSON(packagejsonpath, 'name');
|
|
135
|
+
// if (name && name === path.basename(location)) { TODO think about it
|
|
136
|
+
if (name_1) {
|
|
137
|
+
resultProject = new Project();
|
|
138
|
+
resultProject.location = (0, tnp_core_1.crossPlatformPath)(location);
|
|
139
|
+
resultProject.name = name_1;
|
|
140
|
+
resultProject.type = Helpers.getValueFromJSON(tnp_core_1.path.join(location, 'package.json'), 'tnp.type');
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return resultProject;
|
|
146
|
+
//#endregion
|
|
147
|
+
};
|
|
148
|
+
Project.nearestTo = function (absoluteLocation, options) {
|
|
149
|
+
//#region @backendFunc
|
|
150
|
+
options = options || {};
|
|
151
|
+
var type = options.type, findGitRoot = options.findGitRoot, onlyOutSideNodeModules = options.onlyOutSideNodeModules;
|
|
152
|
+
if (tnp_core_2._.isString(type) && !tnp_config_1.LibTypeArr.includes(type)) {
|
|
153
|
+
Helpers.error("[tnp-helpers][project.nearestTo] wrong type: ".concat(type), false, true);
|
|
154
|
+
}
|
|
155
|
+
if (tnp_core_1.fse.existsSync(absoluteLocation)) {
|
|
156
|
+
absoluteLocation = tnp_core_1.fse.realpathSync(absoluteLocation);
|
|
157
|
+
}
|
|
158
|
+
if (tnp_core_1.fse.existsSync(absoluteLocation) && !tnp_core_1.fse.lstatSync(absoluteLocation).isDirectory()) {
|
|
159
|
+
absoluteLocation = tnp_core_1.path.dirname(absoluteLocation);
|
|
160
|
+
}
|
|
161
|
+
var project;
|
|
162
|
+
var previousLocation;
|
|
163
|
+
while (true) {
|
|
164
|
+
if (onlyOutSideNodeModules && (tnp_core_1.path.basename(tnp_core_1.path.dirname(absoluteLocation)) === 'node_modules')) {
|
|
165
|
+
absoluteLocation = tnp_core_1.path.dirname(tnp_core_1.path.dirname(absoluteLocation));
|
|
166
|
+
}
|
|
167
|
+
project = Project.From(absoluteLocation);
|
|
168
|
+
if (tnp_core_2._.isString(type)) {
|
|
169
|
+
if (project === null || project === void 0 ? void 0 : project.typeIs(type)) {
|
|
170
|
+
if (findGitRoot) {
|
|
171
|
+
if (project.git.isGitRoot) {
|
|
172
|
+
break;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
break;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
if (project) {
|
|
182
|
+
if (findGitRoot) {
|
|
183
|
+
if (project.git.isGitRoot) {
|
|
184
|
+
break;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
else {
|
|
188
|
+
break;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
previousLocation = absoluteLocation;
|
|
193
|
+
var newAbsLocation = tnp_core_1.path.join(absoluteLocation, '..');
|
|
194
|
+
if (!tnp_core_1.path.isAbsolute(newAbsLocation)) {
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
absoluteLocation = (0, tnp_core_1.crossPlatformPath)(tnp_core_1.path.resolve(newAbsLocation));
|
|
198
|
+
if (!tnp_core_1.fse.existsSync(absoluteLocation) && absoluteLocation.split('/').length < 2) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
if (previousLocation === absoluteLocation) {
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
return project;
|
|
206
|
+
//#endregion
|
|
207
|
+
};
|
|
208
|
+
Project.allProjectFrom = function (absoluteLocation, stopOnCwd) {
|
|
209
|
+
if (stopOnCwd === void 0) { stopOnCwd = '/'; }
|
|
210
|
+
//#region @backendFunc
|
|
211
|
+
var projects = {};
|
|
212
|
+
var projectsList = [];
|
|
213
|
+
var previousAbsLocation;
|
|
214
|
+
while (absoluteLocation.startsWith(stopOnCwd)) {
|
|
215
|
+
if (previousAbsLocation === absoluteLocation) {
|
|
216
|
+
break;
|
|
217
|
+
}
|
|
218
|
+
var proj = Project.nearestTo(absoluteLocation);
|
|
219
|
+
if (proj) {
|
|
220
|
+
if (projects[proj.location]) {
|
|
221
|
+
break;
|
|
222
|
+
}
|
|
223
|
+
projects[proj.location] = proj;
|
|
224
|
+
projectsList.push(proj);
|
|
225
|
+
previousAbsLocation = absoluteLocation;
|
|
226
|
+
absoluteLocation = tnp_core_1.path.dirname(proj.location);
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
break;
|
|
230
|
+
}
|
|
231
|
+
return projectsList;
|
|
232
|
+
//#endregion
|
|
233
|
+
};
|
|
234
|
+
Project.DefaultPortByType = function (type) {
|
|
235
|
+
if (type === 'workspace') {
|
|
236
|
+
return 5000;
|
|
237
|
+
}
|
|
238
|
+
if (type === 'angular-client') {
|
|
239
|
+
return 4300;
|
|
240
|
+
}
|
|
241
|
+
if (type === 'angular-lib') {
|
|
242
|
+
return 4250;
|
|
243
|
+
}
|
|
244
|
+
if (type === 'electron-client') {
|
|
245
|
+
return 4350;
|
|
246
|
+
}
|
|
247
|
+
if (type === 'ionic-client') {
|
|
248
|
+
return 8080;
|
|
249
|
+
}
|
|
250
|
+
if (type === 'docker') {
|
|
251
|
+
return 5000;
|
|
252
|
+
}
|
|
253
|
+
if (type === 'isomorphic-lib') {
|
|
254
|
+
return 4000;
|
|
255
|
+
}
|
|
256
|
+
if (type === 'container' || type === 'unknow-npm-project') {
|
|
257
|
+
return;
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
Object.defineProperty(Project, "isBundleMode", {
|
|
261
|
+
get: function () {
|
|
262
|
+
if (Helpers.isBrowser) {
|
|
263
|
+
return true;
|
|
264
|
+
}
|
|
265
|
+
//#region @backend
|
|
266
|
+
return !(!!global[tnp_core_2.CoreConfig.message.globalSystemToolMode]);
|
|
267
|
+
//#endregion
|
|
268
|
+
},
|
|
269
|
+
enumerable: false,
|
|
270
|
+
configurable: true
|
|
271
|
+
});
|
|
272
|
+
Object.defineProperty(Project, "Current", {
|
|
273
|
+
get: function () {
|
|
274
|
+
//#region @backendFunc
|
|
275
|
+
var current = Project.From(process.cwd());
|
|
276
|
+
if (!current) {
|
|
277
|
+
Helpers.warn("[tnp-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 }"));
|
|
278
|
+
return void 0;
|
|
279
|
+
}
|
|
280
|
+
return current;
|
|
281
|
+
//#endregion
|
|
282
|
+
},
|
|
283
|
+
enumerable: false,
|
|
284
|
+
configurable: true
|
|
285
|
+
});
|
|
286
|
+
Object.defineProperty(Project, "NaviCliLocation", {
|
|
287
|
+
//#region @backend
|
|
288
|
+
get: function () {
|
|
289
|
+
return tnp_core_1.path.resolve(tnp_core_1.path.join(Project.Tnp.location, '../navi-cli'));
|
|
290
|
+
},
|
|
291
|
+
enumerable: false,
|
|
292
|
+
configurable: true
|
|
293
|
+
});
|
|
294
|
+
Object.defineProperty(Project, "Tnp", {
|
|
295
|
+
//#endregion
|
|
296
|
+
get: function () {
|
|
297
|
+
//#region @backendFunc
|
|
298
|
+
var tnpPorject = Project.From(tnp_config_1.config.pathes.tnp_folder_location);
|
|
299
|
+
Helpers.log("Using ".concat(tnp_config_1.config.frameworkName, " path: ").concat(tnp_config_1.config.pathes.tnp_folder_location), 1);
|
|
300
|
+
if (!tnpPorject && !global.globalSystemToolMode) {
|
|
301
|
+
Helpers.error("Not able to find tnp project in \"".concat(tnp_config_1.config.pathes.tnp_folder_location, "\"."));
|
|
302
|
+
}
|
|
303
|
+
return tnpPorject;
|
|
304
|
+
//#endregion
|
|
305
|
+
},
|
|
306
|
+
enumerable: false,
|
|
307
|
+
configurable: true
|
|
308
|
+
});
|
|
309
|
+
Project.by = function (libraryType, version
|
|
310
|
+
//#endregion
|
|
311
|
+
) {
|
|
312
|
+
//#region @backendFunc
|
|
313
|
+
if (version === void 0) { version = tnp_config_1.config.defaultFrameworkVersion; }
|
|
314
|
+
if (libraryType === 'workspace') {
|
|
315
|
+
var workspaceProject = Project.From(tnp_config_1.config.pathes.projectsExamples(version).workspace);
|
|
316
|
+
return workspaceProject;
|
|
317
|
+
}
|
|
318
|
+
if (libraryType === 'container') {
|
|
319
|
+
var containerProject = Project.From(tnp_config_1.config.pathes.projectsExamples(version).container);
|
|
320
|
+
return containerProject;
|
|
321
|
+
}
|
|
322
|
+
if (libraryType === 'single-file-project') {
|
|
323
|
+
var singleFileProject = Project.From(tnp_config_1.config.pathes.projectsExamples(version).singlefileproject);
|
|
324
|
+
return singleFileProject;
|
|
325
|
+
}
|
|
326
|
+
var projectPath = tnp_config_1.config.pathes.projectsExamples(version).projectByType(libraryType);
|
|
327
|
+
if (!tnp_core_1.fse.existsSync(projectPath)) {
|
|
328
|
+
Helpers.error("\n ".concat(projectPath, "\n ").concat(projectPath.replace(/\//g, '\\\\'), "\n ").concat((0, tnp_core_1.crossPlatformPath)(projectPath), "\n [tnp-helpers] Bad library type \"").concat(libraryType, "\" for this framework version \"").concat(version, "\"\n\n "), false, false);
|
|
329
|
+
}
|
|
330
|
+
return Project.From(projectPath);
|
|
331
|
+
//#endregion
|
|
332
|
+
};
|
|
333
|
+
Project.prototype.defineProperty = function (variableName, classFn) {
|
|
334
|
+
//#region @backendFunc
|
|
335
|
+
var that = this;
|
|
336
|
+
var prefixedName = "__".concat(variableName);
|
|
337
|
+
Object.defineProperty(this, variableName, {
|
|
338
|
+
get: function () {
|
|
339
|
+
if (!that[prefixedName]) {
|
|
340
|
+
that[prefixedName] = new classFn(that);
|
|
341
|
+
}
|
|
342
|
+
return that[prefixedName];
|
|
343
|
+
},
|
|
344
|
+
set: function (v) {
|
|
345
|
+
that[prefixedName] = v;
|
|
346
|
+
},
|
|
347
|
+
});
|
|
348
|
+
//#endregion
|
|
349
|
+
};
|
|
350
|
+
Project.prototype.setType = function (type) {
|
|
351
|
+
// @ts-ignore
|
|
352
|
+
this._type = type;
|
|
353
|
+
};
|
|
354
|
+
Project.prototype.typeIs = function () {
|
|
355
|
+
var types = [];
|
|
356
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
357
|
+
types[_i] = arguments[_i];
|
|
358
|
+
}
|
|
359
|
+
return this._type && types.includes(this._type);
|
|
360
|
+
};
|
|
361
|
+
Project.prototype.typeIsNot = function () {
|
|
362
|
+
var types = [];
|
|
363
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
364
|
+
types[_i] = arguments[_i];
|
|
365
|
+
}
|
|
366
|
+
return !this.typeIs.apply(this, tslib_1.__spreadArray([], tslib_1.__read(types), false));
|
|
367
|
+
};
|
|
368
|
+
Project.prototype.forEmptyStructure = function () {
|
|
369
|
+
return [
|
|
370
|
+
{ relativePath: tnp_config_1.config.file.package_json, includeContent: true },
|
|
371
|
+
{ relativePath: tnp_config_1.config.folder.src },
|
|
372
|
+
];
|
|
373
|
+
};
|
|
374
|
+
Project.projects = [];
|
|
375
|
+
/**
|
|
376
|
+
* To speed up checking folder I am keeping pathes for alterdy checked folder
|
|
377
|
+
* This may break things that are creating new projects
|
|
378
|
+
*/
|
|
379
|
+
Project.emptyLocations = [];
|
|
380
|
+
tslib_1.__decorate([
|
|
381
|
+
morphi_1.Morphi.Orm.Column.Primary({ type: 'varchar', length: 400 }),
|
|
382
|
+
tslib_1.__metadata("design:type", Object)
|
|
383
|
+
], Project.prototype, "cache", void 0);
|
|
384
|
+
return Project;
|
|
385
|
+
}(git_project_1.ProjectGit
|
|
386
|
+
//#endregion
|
|
387
|
+
));
|
|
388
|
+
exports.Project = Project;
|
|
389
|
+
//#region @backend
|
|
390
|
+
function isDockerProject(location) {
|
|
391
|
+
if (tnp_core_1.fse.existsSync(tnp_core_1.path.join(location, 'Dockerfile'))) {
|
|
392
|
+
var packageJson = tnp_core_1.path.join(location, 'package.json');
|
|
393
|
+
if (!Helpers.exists(packageJson)) {
|
|
394
|
+
Helpers.writeFile(packageJson, {
|
|
395
|
+
"name": tnp_core_1.path.basename(location),
|
|
396
|
+
"version": "0.0.0"
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
var pj = Helpers.readJson(packageJson);
|
|
400
|
+
pj[tnp_config_1.config.frameworkName] = {
|
|
401
|
+
"type": "docker",
|
|
402
|
+
"version": "v2"
|
|
403
|
+
};
|
|
404
|
+
Helpers.writeFile(packageJson, pj);
|
|
405
|
+
return true;
|
|
406
|
+
}
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
function getClassFunction(className) {
|
|
410
|
+
var classFN = typescript_class_helpers_1.CLASS.getBy(className);
|
|
411
|
+
if (!classFN) {
|
|
412
|
+
Helpers.error("[tnp-helpers][Project.From] cannot find class function by name ".concat(className));
|
|
413
|
+
}
|
|
414
|
+
return classFN;
|
|
415
|
+
}
|
|
416
|
+
function checkIfTypeIsNotCorrect(type, location) {
|
|
417
|
+
if (tnp_core_2._.isString(type) && !tnp_config_1.LibTypeArr.includes(type)) {
|
|
418
|
+
Helpers.error("Incorrect type: \"".concat(type, "\"\n\n Please use one of this: ").concat(tnp_config_1.LibTypeArr.join(','), "\n\n in\n package.json > ").concat(tnp_config_1.config.frameworkName, ".type\n\n location: ").concat(location, "\n\n "), false, true);
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
//#endregion
|
|
422
|
+
//# sourceMappingURL=/Users/dariusz/projects/npm/tnp-helpers/tmp-bundle-release/bundle/project/tnp-helpers/bundle-nocutsrc/lib/project.js.map
|