tnp-helpers 13.0.38 → 13.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (223) hide show
  1. package/app.d.ts +1 -1
  2. package/app.js +6 -6
  3. package/app.js.map +1 -1
  4. package/browser/README.md +24 -24
  5. package/browser/esm2020/lib/base-component.mjs +48 -48
  6. package/browser/esm2020/lib/base-formly-component.mjs +126 -126
  7. package/browser/esm2020/lib/condition-wait.mjs +53 -53
  8. package/browser/esm2020/lib/constants.mjs +6 -6
  9. package/browser/esm2020/lib/dual-component-ctrl.mjs +120 -120
  10. package/browser/esm2020/lib/helpers-array-obj.mjs +80 -80
  11. package/browser/esm2020/lib/helpers-environment.mjs +30 -30
  12. package/browser/esm2020/lib/helpers-numbers.mjs +5 -5
  13. package/browser/esm2020/lib/helpers-strings-regexes.mjs +48 -48
  14. package/browser/esm2020/lib/helpers-strings.mjs +258 -256
  15. package/browser/esm2020/lib/helpers.mjs +276 -276
  16. package/browser/esm2020/lib/index.mjs +14 -14
  17. package/browser/esm2020/lib/long-press.directive.mjs +112 -112
  18. package/browser/esm2020/lib/project.mjs +413 -413
  19. package/browser/esm2020/lib/resize-service.mjs +20 -20
  20. package/browser/esm2020/public-api.mjs +1 -1
  21. package/browser/esm2020/tnp-helpers.mjs +4 -4
  22. package/browser/fesm2015/tnp-helpers.mjs +1535 -1534
  23. package/browser/fesm2015/tnp-helpers.mjs.map +1 -1
  24. package/browser/fesm2020/tnp-helpers.mjs +1527 -1526
  25. package/browser/fesm2020/tnp-helpers.mjs.map +1 -1
  26. package/browser/lib/base-component.d.ts +17 -17
  27. package/browser/lib/base-formly-component.d.ts +31 -31
  28. package/browser/lib/condition-wait.d.ts +8 -8
  29. package/browser/lib/constants.d.ts +6 -6
  30. package/browser/lib/dual-component-ctrl.d.ts +25 -25
  31. package/browser/lib/helpers-array-obj.d.ts +15 -15
  32. package/browser/lib/helpers-environment.d.ts +5 -5
  33. package/browser/lib/helpers-numbers.d.ts +3 -3
  34. package/browser/lib/helpers-strings-regexes.d.ts +28 -28
  35. package/browser/lib/helpers-strings.d.ts +50 -50
  36. package/browser/lib/helpers.d.ts +28 -28
  37. package/browser/lib/index.d.ts +9 -9
  38. package/browser/lib/long-press.directive.d.ts +25 -25
  39. package/browser/lib/project.d.ts +91 -91
  40. package/browser/lib/resize-service.d.ts +9 -9
  41. package/browser/public-api.d.ts +1 -1
  42. package/browser/tnp-helpers.d.ts +5 -5
  43. package/client/README.md +24 -24
  44. package/client/esm2020/lib/base-component.mjs +48 -48
  45. package/client/esm2020/lib/base-formly-component.mjs +126 -126
  46. package/client/esm2020/lib/condition-wait.mjs +53 -53
  47. package/client/esm2020/lib/constants.mjs +6 -6
  48. package/client/esm2020/lib/dual-component-ctrl.mjs +120 -120
  49. package/client/esm2020/lib/helpers-array-obj.mjs +80 -80
  50. package/client/esm2020/lib/helpers-environment.mjs +30 -30
  51. package/client/esm2020/lib/helpers-numbers.mjs +5 -5
  52. package/client/esm2020/lib/helpers-strings-regexes.mjs +48 -48
  53. package/client/esm2020/lib/helpers-strings.mjs +258 -256
  54. package/client/esm2020/lib/helpers.mjs +276 -276
  55. package/client/esm2020/lib/index.mjs +14 -14
  56. package/client/esm2020/lib/long-press.directive.mjs +112 -112
  57. package/client/esm2020/lib/project.mjs +413 -413
  58. package/client/esm2020/lib/resize-service.mjs +20 -20
  59. package/client/esm2020/public-api.mjs +1 -1
  60. package/client/esm2020/tnp-helpers.mjs +4 -4
  61. package/client/fesm2015/tnp-helpers.mjs +1535 -1534
  62. package/client/fesm2015/tnp-helpers.mjs.map +1 -1
  63. package/client/fesm2020/tnp-helpers.mjs +1527 -1526
  64. package/client/fesm2020/tnp-helpers.mjs.map +1 -1
  65. package/client/lib/base-component.d.ts +17 -17
  66. package/client/lib/base-formly-component.d.ts +31 -31
  67. package/client/lib/condition-wait.d.ts +8 -8
  68. package/client/lib/constants.d.ts +6 -6
  69. package/client/lib/dual-component-ctrl.d.ts +25 -25
  70. package/client/lib/helpers-array-obj.d.ts +15 -15
  71. package/client/lib/helpers-environment.d.ts +5 -5
  72. package/client/lib/helpers-numbers.d.ts +3 -3
  73. package/client/lib/helpers-strings-regexes.d.ts +28 -28
  74. package/client/lib/helpers-strings.d.ts +50 -50
  75. package/client/lib/helpers.d.ts +28 -28
  76. package/client/lib/index.d.ts +9 -9
  77. package/client/lib/long-press.directive.d.ts +25 -25
  78. package/client/lib/project.d.ts +91 -91
  79. package/client/lib/resize-service.d.ts +9 -9
  80. package/client/public-api.d.ts +1 -1
  81. package/client/tnp-helpers.d.ts +5 -5
  82. package/index.d.ts +1 -1
  83. package/index.js +5 -5
  84. package/index.js.map +1 -1
  85. package/lib/angular.helper.d.ts +22 -22
  86. package/lib/angular.helper.js +50 -50
  87. package/lib/angular.helper.js.map +1 -1
  88. package/lib/base-component.d.ts +1 -1
  89. package/lib/base-component.js +6 -6
  90. package/lib/base-component.js.map +1 -1
  91. package/lib/base-formly-component.d.ts +1 -1
  92. package/lib/base-formly-component.js +6 -6
  93. package/lib/base-formly-component.js.map +1 -1
  94. package/lib/condition-wait.d.ts +8 -8
  95. package/lib/condition-wait.js +94 -94
  96. package/lib/condition-wait.js.map +1 -1
  97. package/lib/constants.d.ts +6 -6
  98. package/lib/constants.js +10 -10
  99. package/lib/constants.js.map +1 -1
  100. package/lib/dual-component-ctrl.d.ts +1 -1
  101. package/lib/dual-component-ctrl.js +6 -6
  102. package/lib/dual-component-ctrl.js.map +1 -1
  103. package/lib/git-project.d.ts +44 -44
  104. package/lib/git-project.js +195 -191
  105. package/lib/git-project.js.map +1 -1
  106. package/lib/helpers-array-obj.d.ts +15 -15
  107. package/lib/helpers-array-obj.js +88 -88
  108. package/lib/helpers-array-obj.js.map +1 -1
  109. package/lib/helpers-cli-tool.backend.d.ts +45 -45
  110. package/lib/helpers-cli-tool.backend.js +293 -293
  111. package/lib/helpers-cli-tool.backend.js.map +1 -1
  112. package/lib/helpers-dependencies.backend.d.ts +11 -11
  113. package/lib/helpers-dependencies.backend.js +105 -105
  114. package/lib/helpers-dependencies.backend.js.map +1 -1
  115. package/lib/helpers-environment.d.ts +5 -5
  116. package/lib/helpers-environment.js +35 -35
  117. package/lib/helpers-environment.js.map +1 -1
  118. package/lib/helpers-file-folders.backend.d.ts +84 -73
  119. package/lib/helpers-file-folders.backend.js +736 -714
  120. package/lib/helpers-file-folders.backend.js.map +1 -1
  121. package/lib/helpers-git.backend.d.ts +35 -35
  122. package/lib/helpers-git.backend.js +545 -534
  123. package/lib/helpers-git.backend.js.map +1 -1
  124. package/lib/helpers-json5.backend.d.ts +16 -16
  125. package/lib/helpers-json5.backend.js +70 -70
  126. package/lib/helpers-json5.backend.js.map +1 -1
  127. package/lib/helpers-morphi-framework.backend.d.ts +4 -4
  128. package/lib/helpers-morphi-framework.backend.js +49 -49
  129. package/lib/helpers-morphi-framework.backend.js.map +1 -1
  130. package/lib/helpers-network.backend.d.ts +8 -8
  131. package/lib/helpers-network.backend.js +48 -48
  132. package/lib/helpers-network.backend.js.map +1 -1
  133. package/lib/helpers-npm.backend.d.ts +3 -3
  134. package/lib/helpers-npm.backend.js +17 -17
  135. package/lib/helpers-npm.backend.js.map +1 -1
  136. package/lib/helpers-numbers.d.ts +3 -3
  137. package/lib/helpers-numbers.js +11 -11
  138. package/lib/helpers-numbers.js.map +1 -1
  139. package/lib/helpers-path.backend.d.ts +7 -7
  140. package/lib/helpers-path.backend.js +36 -36
  141. package/lib/helpers-path.backend.js.map +1 -1
  142. package/lib/helpers-process.backend.d.ts +57 -51
  143. package/lib/helpers-process.backend.js +529 -523
  144. package/lib/helpers-process.backend.js.map +1 -1
  145. package/lib/helpers-strings-regexes.d.ts +28 -28
  146. package/lib/helpers-strings-regexes.js +60 -60
  147. package/lib/helpers-strings-regexes.js.map +1 -1
  148. package/lib/helpers-strings.d.ts +50 -50
  149. package/lib/helpers-strings.js +265 -263
  150. package/lib/helpers-strings.js.map +1 -1
  151. package/lib/helpers-system-terminal.backend.d.ts +5 -5
  152. package/lib/helpers-system-terminal.backend.js +53 -53
  153. package/lib/helpers-system-terminal.backend.js.map +1 -1
  154. package/lib/helpers.d.ts +67 -67
  155. package/lib/helpers.js +391 -391
  156. package/lib/helpers.js.map +1 -1
  157. package/lib/index.d.ts +6 -6
  158. package/lib/index.js +19 -19
  159. package/lib/index.js.map +1 -1
  160. package/lib/long-press.directive.d.ts +22 -22
  161. package/lib/long-press.directive.js +141 -141
  162. package/lib/long-press.directive.js.map +1 -1
  163. package/lib/merge-helpers.backend.d.ts +23 -23
  164. package/lib/merge-helpers.backend.js +108 -108
  165. package/lib/merge-helpers.backend.js.map +1 -1
  166. package/lib/project.d.ts +94 -94
  167. package/lib/project.js +422 -422
  168. package/lib/project.js.map +1 -1
  169. package/lib/resize-service.d.ts +6 -6
  170. package/lib/resize-service.js +24 -24
  171. package/lib/resize-service.js.map +1 -1
  172. package/lib/ts-code/index.d.ts +1 -1
  173. package/lib/ts-code/index.js +7 -7
  174. package/lib/ts-code/index.js.map +1 -1
  175. package/lib/ts-code/ts-code-extractor.d.ts +14 -14
  176. package/lib/ts-code/ts-code-extractor.js +46 -46
  177. package/lib/ts-code/ts-code-extractor.js.map +1 -1
  178. package/lib/ts-code/ts-code-modifier.backend.d.ts +12 -12
  179. package/lib/ts-code/ts-code-modifier.backend.js +70 -70
  180. package/lib/ts-code/ts-code-modifier.backend.js.map +1 -1
  181. package/package.json +3 -3
  182. package/package.json_devDependencies.json +222 -222
  183. package/package.json_tnp.json5 +41 -41
  184. package/tmp-environment.json +13 -13
  185. package/websql/README.md +24 -24
  186. package/websql/esm2020/lib/base-component.mjs +48 -48
  187. package/websql/esm2020/lib/base-formly-component.mjs +126 -126
  188. package/websql/esm2020/lib/condition-wait.mjs +53 -53
  189. package/websql/esm2020/lib/constants.mjs +6 -6
  190. package/websql/esm2020/lib/dual-component-ctrl.mjs +120 -120
  191. package/websql/esm2020/lib/helpers-array-obj.mjs +80 -80
  192. package/websql/esm2020/lib/helpers-environment.mjs +30 -30
  193. package/websql/esm2020/lib/helpers-numbers.mjs +5 -5
  194. package/websql/esm2020/lib/helpers-strings-regexes.mjs +48 -48
  195. package/websql/esm2020/lib/helpers-strings.mjs +258 -256
  196. package/websql/esm2020/lib/helpers.mjs +276 -276
  197. package/websql/esm2020/lib/index.mjs +14 -14
  198. package/websql/esm2020/lib/long-press.directive.mjs +112 -112
  199. package/websql/esm2020/lib/project.mjs +413 -413
  200. package/websql/esm2020/lib/resize-service.mjs +20 -20
  201. package/websql/esm2020/public-api.mjs +1 -1
  202. package/websql/esm2020/tnp-helpers.mjs +4 -4
  203. package/websql/fesm2015/tnp-helpers.mjs +1535 -1534
  204. package/websql/fesm2015/tnp-helpers.mjs.map +1 -1
  205. package/websql/fesm2020/tnp-helpers.mjs +1527 -1526
  206. package/websql/fesm2020/tnp-helpers.mjs.map +1 -1
  207. package/websql/lib/base-component.d.ts +17 -17
  208. package/websql/lib/base-formly-component.d.ts +31 -31
  209. package/websql/lib/condition-wait.d.ts +8 -8
  210. package/websql/lib/constants.d.ts +6 -6
  211. package/websql/lib/dual-component-ctrl.d.ts +25 -25
  212. package/websql/lib/helpers-array-obj.d.ts +15 -15
  213. package/websql/lib/helpers-environment.d.ts +5 -5
  214. package/websql/lib/helpers-numbers.d.ts +3 -3
  215. package/websql/lib/helpers-strings-regexes.d.ts +28 -28
  216. package/websql/lib/helpers-strings.d.ts +50 -50
  217. package/websql/lib/helpers.d.ts +28 -28
  218. package/websql/lib/index.d.ts +9 -9
  219. package/websql/lib/long-press.directive.d.ts +25 -25
  220. package/websql/lib/project.d.ts +91 -91
  221. package/websql/lib/resize-service.d.ts +9 -9
  222. package/websql/public-api.d.ts +1 -1
  223. 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
- (0, 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, (0, tslib_1.__spreadArray)([], (0, 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
- (0, tslib_1.__decorate)([
381
- morphi_1.Morphi.Orm.Column.Primary({ type: 'varchar', length: 400 }),
382
- (0, 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
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=C:/Users/darek/projects/npm/tnp-helpers/tmp-bundle-release/bundle/project/tnp-helpers/bundle-nocutsrc/lib/project.js.map