@stechquick/symphony-cli 0.2.271

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 (212) hide show
  1. package/README.md +378 -0
  2. package/bin/run +5 -0
  3. package/bin/run.cmd +3 -0
  4. package/lib/commands/mui-create.d.ts +14 -0
  5. package/lib/commands/mui-create.js +39 -0
  6. package/lib/commands/nc-addcomp.d.ts +11 -0
  7. package/lib/commands/nc-addcomp.js +22 -0
  8. package/lib/commands/nc-build.d.ts +9 -0
  9. package/lib/commands/nc-build.js +20 -0
  10. package/lib/commands/nc-create.d.ts +14 -0
  11. package/lib/commands/nc-create.js +38 -0
  12. package/lib/commands/qui-build.d.ts +6 -0
  13. package/lib/commands/qui-build.js +16 -0
  14. package/lib/commands/qui-create.d.ts +14 -0
  15. package/lib/commands/qui-create.js +39 -0
  16. package/lib/commands/qui-start.d.ts +9 -0
  17. package/lib/commands/qui-start.js +30 -0
  18. package/lib/commands/quick-serve.d.ts +17 -0
  19. package/lib/commands/quick-serve.js +73 -0
  20. package/lib/commands/sym-addfunc.d.ts +12 -0
  21. package/lib/commands/sym-addfunc.js +21 -0
  22. package/lib/commands/sym-build.d.ts +12 -0
  23. package/lib/commands/sym-build.js +56 -0
  24. package/lib/commands/sym-create-module.d.ts +14 -0
  25. package/lib/commands/sym-create-module.js +39 -0
  26. package/lib/commands/sym-create.d.ts +14 -0
  27. package/lib/commands/sym-create.js +39 -0
  28. package/lib/commands/sym-fn-deploy.d.ts +24 -0
  29. package/lib/commands/sym-fn-deploy.js +152 -0
  30. package/lib/commands/sym-nano-deploy.d.ts +11 -0
  31. package/lib/commands/sym-nano-deploy.js +50 -0
  32. package/lib/commands/sym-start.d.ts +14 -0
  33. package/lib/commands/sym-start.js +28 -0
  34. package/lib/commands/sym-test.d.ts +6 -0
  35. package/lib/commands/sym-test.js +12 -0
  36. package/lib/helpers/deploy/fnDeployHelper.d.ts +28 -0
  37. package/lib/helpers/deploy/fnDeployHelper.js +196 -0
  38. package/lib/helpers/deploy/nanoDeployHelper.d.ts +20 -0
  39. package/lib/helpers/deploy/nanoDeployHelper.js +83 -0
  40. package/lib/helpers/fnDownloadHelper.d.ts +11 -0
  41. package/lib/helpers/fnDownloadHelper.js +64 -0
  42. package/lib/helpers/initHelper.d.ts +22 -0
  43. package/lib/helpers/initHelper.js +78 -0
  44. package/lib/helpers/microUIHelper.d.ts +10 -0
  45. package/lib/helpers/microUIHelper.js +33 -0
  46. package/lib/helpers/namedComponent/ncHelper.d.ts +15 -0
  47. package/lib/helpers/namedComponent/ncHelper.js +60 -0
  48. package/lib/helpers/npmHelper.d.ts +23 -0
  49. package/lib/helpers/npmHelper.js +79 -0
  50. package/lib/helpers/packageHelper.d.ts +14 -0
  51. package/lib/helpers/packageHelper.js +32 -0
  52. package/lib/helpers/shellHelper.d.ts +25 -0
  53. package/lib/helpers/shellHelper.js +52 -0
  54. package/lib/helpers/socketServer/socketServerHelper.d.ts +14 -0
  55. package/lib/helpers/socketServer/socketServerHelper.js +106 -0
  56. package/lib/helpers/typeHelper.d.ts +3 -0
  57. package/lib/helpers/typeHelper.js +22 -0
  58. package/lib/helpers/ui/createuiHelper.d.ts +10 -0
  59. package/lib/helpers/ui/createuiHelper.js +33 -0
  60. package/lib/helpers/ui/quiBuilder.d.ts +13 -0
  61. package/lib/helpers/ui/quiBuilder.js +163 -0
  62. package/lib/helpers/utils.d.ts +8 -0
  63. package/lib/helpers/utils.js +20 -0
  64. package/lib/index.d.ts +1 -0
  65. package/lib/index.js +4 -0
  66. package/lib/pathFinder.d.ts +4 -0
  67. package/lib/pathFinder.js +13 -0
  68. package/lib/predeploy/src/fn/fnPostdeploy.d.ts +5 -0
  69. package/lib/predeploy/src/fn/fnPostdeploy.js +49 -0
  70. package/lib/predeploy/src/fn/fnPredeploy.d.ts +4 -0
  71. package/lib/predeploy/src/fn/fnPredeploy.js +30 -0
  72. package/lib/predeploy/src/nano/nanoPostdeploy.d.ts +5 -0
  73. package/lib/predeploy/src/nano/nanoPostdeploy.js +41 -0
  74. package/lib/predeploy/src/nano/nanoPredeploy.d.ts +4 -0
  75. package/lib/predeploy/src/nano/nanoPredeploy.js +25 -0
  76. package/lib/predeploy/src/paramReplacer.d.ts +7 -0
  77. package/lib/predeploy/src/paramReplacer.js +14 -0
  78. package/lib/predeploy/src/predeployCommon.d.ts +15 -0
  79. package/lib/predeploy/src/predeployCommon.js +83 -0
  80. package/oclif.manifest.json +1 -0
  81. package/package.json +76 -0
  82. package/templates/addModule/{{ModuleName}}/.jenkins/dev.yaml +43 -0
  83. package/templates/addModule/{{ModuleName}}/README.md +2 -0
  84. package/templates/addModule/{{ModuleName}}/index.ts +1 -0
  85. package/templates/addModule/{{ModuleName}}/src/implementation/object.ts +16 -0
  86. package/templates/addModule/{{ModuleName}}/src/module.ts +9 -0
  87. package/templates/addModule/{{ModuleName}}/tsconfig.json +66 -0
  88. package/templates/addModule/{{ModuleName}}/webpack.config.js +41 -0
  89. package/templates/addModule/{{ModuleName}}/{{remove}}.gitignore +6 -0
  90. package/templates/addModule/{{ModuleName}}/{{remove}}package.json +33 -0
  91. package/templates/addfunc/functions/{{FuncName}}/config.yaml +25 -0
  92. package/templates/addfunc/functions/{{FuncName}}/func.yaml +9 -0
  93. package/templates/addfunc/functions/{{FuncName}}/{{FuncName}}.ts +8 -0
  94. package/templates/addfunc/unitTest/{{FuncName}}.test.ts +18 -0
  95. package/templates/createmicroui/{{MicroUIName}}-ui/.babelrc +17 -0
  96. package/templates/createmicroui/{{MicroUIName}}-ui/.editorconfig +9 -0
  97. package/templates/createmicroui/{{MicroUIName}}-ui/.postcssrc.js +8 -0
  98. package/templates/createmicroui/{{MicroUIName}}-ui/README.md +45 -0
  99. package/templates/createmicroui/{{MicroUIName}}-ui/build/build.js +41 -0
  100. package/templates/createmicroui/{{MicroUIName}}-ui/build/check-versions.js +49 -0
  101. package/templates/createmicroui/{{MicroUIName}}-ui/build/dev-client.js +10 -0
  102. package/templates/createmicroui/{{MicroUIName}}-ui/build/dev-server.js +107 -0
  103. package/templates/createmicroui/{{MicroUIName}}-ui/build/utils.js +73 -0
  104. package/templates/createmicroui/{{MicroUIName}}-ui/build/vue-loader.conf.js +19 -0
  105. package/templates/createmicroui/{{MicroUIName}}-ui/build/webpack.base.conf.js +76 -0
  106. package/templates/createmicroui/{{MicroUIName}}-ui/build/webpack.dev.conf.js +39 -0
  107. package/templates/createmicroui/{{MicroUIName}}-ui/build/webpack.prod.conf.js +128 -0
  108. package/templates/createmicroui/{{MicroUIName}}-ui/build/webpack.test.conf.js +32 -0
  109. package/templates/createmicroui/{{MicroUIName}}-ui/build.gradle +251 -0
  110. package/templates/createmicroui/{{MicroUIName}}-ui/config/dev.env.js +7 -0
  111. package/templates/createmicroui/{{MicroUIName}}-ui/config/index.js +50 -0
  112. package/templates/createmicroui/{{MicroUIName}}-ui/config/prod.env.js +4 -0
  113. package/templates/createmicroui/{{MicroUIName}}-ui/config/test.env.js +7 -0
  114. package/templates/createmicroui/{{MicroUIName}}-ui/copyBundle.js +3 -0
  115. package/templates/createmicroui/{{MicroUIName}}-ui/gradle/base/repos.gradle +48 -0
  116. package/templates/createmicroui/{{MicroUIName}}-ui/gradle/wrapper/gradle-wrapper.jar +0 -0
  117. package/templates/createmicroui/{{MicroUIName}}-ui/gradle/wrapper/gradle-wrapper.properties +6 -0
  118. package/templates/createmicroui/{{MicroUIName}}-ui/gradlew +172 -0
  119. package/templates/createmicroui/{{MicroUIName}}-ui/index.html +11 -0
  120. package/templates/createmicroui/{{MicroUIName}}-ui/index.js +18 -0
  121. package/templates/createmicroui/{{MicroUIName}}-ui/indexCompNames.js +14 -0
  122. package/templates/createmicroui/{{MicroUIName}}-ui/indexInitial.js +8 -0
  123. package/templates/createmicroui/{{MicroUIName}}-ui/indexModuleName.js +1 -0
  124. package/templates/createmicroui/{{MicroUIName}}-ui/indexVCompNames.json +50 -0
  125. package/templates/createmicroui/{{MicroUIName}}-ui/package.json +84 -0
  126. package/templates/createmicroui/{{MicroUIName}}-ui/removeDist.js +2 -0
  127. package/templates/createmicroui/{{MicroUIName}}-ui/src/App.vue +54 -0
  128. package/templates/createmicroui/{{MicroUIName}}-ui/src/api/index.js +5 -0
  129. package/templates/createmicroui/{{MicroUIName}}-ui/src/components/index.js +6 -0
  130. package/templates/createmicroui/{{MicroUIName}}-ui/src/docker/nginx.conf +39 -0
  131. package/templates/createmicroui/{{MicroUIName}}-ui/src/localization/en/default.json +3 -0
  132. package/templates/createmicroui/{{MicroUIName}}-ui/src/localization/tr/default.json +3 -0
  133. package/templates/createmicroui/{{MicroUIName}}-ui/src/main.js +15 -0
  134. package/templates/createmicroui/{{MicroUIName}}-ui/src/mockserver/handlers/health.js +8 -0
  135. package/templates/createmicroui/{{MicroUIName}}-ui/src/mockserver/index.js +8 -0
  136. package/templates/createmicroui/{{MicroUIName}}-ui/src/mockserver/server.js +45 -0
  137. package/templates/createmicroui/{{MicroUIName}}-ui/src/pages/index.js +6 -0
  138. package/templates/createmicroui/{{MicroUIName}}-ui/src/router/index.js +5 -0
  139. package/templates/createmicroui/{{MicroUIName}}-ui/src/service/serviceConstants.js +1 -0
  140. package/templates/createmicroui/{{MicroUIName}}-ui/src/store/index.js +14 -0
  141. package/templates/createmicroui/{{MicroUIName}}-ui/src/worker/a9e657cbf4abb977edda.worker.js +60638 -0
  142. package/templates/createmicroui/{{MicroUIName}}-ui/static/.gitkeep +0 -0
  143. package/templates/createmicroui/{{MicroUIName}}-ui/webpack.config.js +257 -0
  144. package/templates/createui/{{UIName}}/Jenkinsfile +20 -0
  145. package/templates/createui/{{UIName}}/build.gradle +266 -0
  146. package/templates/createui/{{UIName}}/gradle/base/repos.gradle +93 -0
  147. package/templates/createui/{{UIName}}/gradle/wrapper/gradle-wrapper.jar +0 -0
  148. package/templates/createui/{{UIName}}/gradle/wrapper/gradle-wrapper.properties +6 -0
  149. package/templates/createui/{{UIName}}/gradlew +172 -0
  150. package/templates/createui/{{UIName}}/gradlew.bat +90 -0
  151. package/templates/createui/{{UIName}}/settings/globalLocalization.qjson +29 -0
  152. package/templates/createui/{{UIName}}/settings/localProxy.yaml +25 -0
  153. package/templates/createui/{{UIName}}/settings/qjson/alert.qjson +920 -0
  154. package/templates/createui/{{UIName}}/settings/qjson/loading.qjson +1486 -0
  155. package/templates/createui/{{UIName}}/settings/qjson/logHandler.qjson +65 -0
  156. package/templates/createui/{{UIName}}/settings/qjson/pipeline.qjson +116 -0
  157. package/templates/createui/{{UIName}}/settings/settings-proxy.js +120 -0
  158. package/templates/createui/{{UIName}}/settings/settings.yaml +85 -0
  159. package/templates/createui/{{UIName}}/settings.gradle +1 -0
  160. package/templates/createui/{{UIName}}/static/components/yourNamedCompHere.js +0 -0
  161. package/templates/createui/{{UIName}}/static/css/main.css +36 -0
  162. package/templates/createui/{{UIName}}/static/css/myDarkTheme.css +143 -0
  163. package/templates/createui/{{UIName}}/static/css/myHappyTheme1.css +140 -0
  164. package/templates/createui/{{UIName}}/static/css/myHappyTheme2.css +140 -0
  165. package/templates/createui/{{UIName}}/static/images/ahelogo.png +0 -0
  166. package/templates/createui/{{UIName}}/static/images/avatar.png +0 -0
  167. package/templates/createui/{{UIName}}/static/images/profile.png +0 -0
  168. package/templates/createui/{{UIName}}/static/images/profile2.png +0 -0
  169. package/templates/createui/{{UIName}}/static/images/yourImagesHere.png +0 -0
  170. package/templates/createui/{{UIName}}/static/js/componentList.ts +4452 -0
  171. package/templates/createui/{{UIName}}/static/qjsons/VDatatableConditionalRowColoring.qjson +158 -0
  172. package/templates/createui/{{UIName}}/static/qjsons/alertSamplePage.qjson +772 -0
  173. package/templates/createui/{{UIName}}/static/qjsons/complicatedSamplePage.qjson +10448 -0
  174. package/templates/createui/{{UIName}}/static/qjsons/customComponentSample.qjson +803 -0
  175. package/templates/createui/{{UIName}}/static/qjsons/customerInfoCustomComp.qjson +1451 -0
  176. package/templates/createui/{{UIName}}/static/qjsons/first.qjson +2180 -0
  177. package/templates/createui/{{UIName}}/static/qjsons/formatterSample.qjson +877 -0
  178. package/templates/createui/{{UIName}}/static/qjsons/localizationSample.qjson +1845 -0
  179. package/templates/createui/{{UIName}}/static/qjsons/pipelineSample.qjson +913 -0
  180. package/templates/createui/{{UIName}}/static/qjsons/validationSample.qjson +2371 -0
  181. package/templates/createui/{{UIName}}/static/qjsons/webDashboardSample.qjson +2993 -0
  182. package/templates/createui/{{UIName}}/{{remove}}.gitignore +3 -0
  183. package/templates/createui/{{UIName}}/{{remove}}package.json +22 -0
  184. package/templates/fnPredeploy/Dockerfile +22 -0
  185. package/templates/init/{{AppName}}/.vscode/launch.json +24 -0
  186. package/templates/init/{{AppName}}/Jenkinsfile +36 -0
  187. package/templates/init/{{AppName}}/app.yaml +1 -0
  188. package/templates/init/{{AppName}}/functions/qjsonfunc/func.yaml +9 -0
  189. package/templates/init/{{AppName}}/functions/qjsonfunc/qjsonfunc.ts +3 -0
  190. package/templates/init/{{AppName}}/functions/qjsonfunc/qjsons/test.qjson +180 -0
  191. package/templates/init/{{AppName}}/functions/samplefunc/config.yaml +46 -0
  192. package/templates/init/{{AppName}}/functions/samplefunc/func.yaml +9 -0
  193. package/templates/init/{{AppName}}/functions/samplefunc/samplefunc.ts +27 -0
  194. package/templates/init/{{AppName}}/jest.config.js +8 -0
  195. package/templates/init/{{AppName}}/local.ts +6 -0
  196. package/templates/init/{{AppName}}/sym-engine/config.yaml +7 -0
  197. package/templates/init/{{AppName}}/sym-engine/localization.yaml +5 -0
  198. package/templates/init/{{AppName}}/sym-engine/pipeline.ts +64 -0
  199. package/templates/init/{{AppName}}/test/qjson.http +29 -0
  200. package/templates/init/{{AppName}}/test/sample.http +24 -0
  201. package/templates/init/{{AppName}}/tsconfig.json +66 -0
  202. package/templates/init/{{AppName}}/unitTest/samplefunc.test.ts +55 -0
  203. package/templates/init/{{AppName}}/{{remove}}.gitignore +6 -0
  204. package/templates/init/{{AppName}}/{{remove}}package.json +40 -0
  205. package/templates/nanoPredeploy/Dockerfile +27 -0
  206. package/templates/nc-addComp/{{ComponentName}}.vue +29 -0
  207. package/templates/nc-create/{{ProjectName}}/shims/shims-vue.d.ts +4 -0
  208. package/templates/nc-create/{{ProjectName}}/src/namedComps/{{ProjectName}}.vue +29 -0
  209. package/templates/nc-create/{{ProjectName}}/tsconfig.json +66 -0
  210. package/templates/nc-create/{{ProjectName}}/webpack.config.js +2 -0
  211. package/templates/nc-create/{{ProjectName}}/{{remove}}.gitignore +3 -0
  212. package/templates/nc-create/{{ProjectName}}/{{remove}}package.json +28 -0
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FnDeployHelper = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fnPostdeploy_1 = require("../../predeploy/src/fn/fnPostdeploy");
6
+ const shellHelper_1 = require("../shellHelper");
7
+ const path = tslib_1.__importStar(require("path"));
8
+ const fs = tslib_1.__importStar(require("fs"));
9
+ const initHelper_1 = require("../initHelper");
10
+ const log_1 = require("@stechquick/symphony-common/lib/log");
11
+ const styling_1 = require("@stechquick/symphony-common/lib/styling");
12
+ const fnDownloadHelper_1 = require("../fnDownloadHelper");
13
+ const fnPredeploy_1 = require("../../predeploy/src/fn/fnPredeploy");
14
+ class FnDeployHelper {
15
+ constructor(settings) {
16
+ this.settings = settings;
17
+ }
18
+ async deploy() {
19
+ if (!initHelper_1.InitHelper.AssertInFolder()) {
20
+ log_1.Logger.log({ message: styling_1.Chalk.create("red.bold", "Command must be executed in app root!") });
21
+ return;
22
+ }
23
+ log_1.Logger.log({ message: styling_1.Chalk.create("green.bold", "Deploy starting..."), timeFormat: "datetime" });
24
+ let success = false;
25
+ try {
26
+ const fnFileName = await new fnDownloadHelper_1.FnDownloadHelepr().downloadFn();
27
+ if (this.settings.environment == "local") {
28
+ await this.fnContext("default", fnFileName);
29
+ }
30
+ else {
31
+ await this.fnPreRemote(fnFileName);
32
+ }
33
+ await fnPredeploy_1.FnPredeploy.execute(this.getReplaceWords());
34
+ await this.fnDeploy(fnFileName);
35
+ success = true;
36
+ }
37
+ finally {
38
+ fnPostdeploy_1.FnPostDeploy.execute();
39
+ if (!success) {
40
+ log_1.Logger.log({ message: styling_1.Chalk.create("red.bold", "Deploy failed, ^^ search for errors up ^^"), timeFormat: "datetime" });
41
+ }
42
+ else {
43
+ log_1.Logger.log({ message: styling_1.Chalk.create("green.bold", "Deploy complete"), timeFormat: "datetime" });
44
+ }
45
+ }
46
+ }
47
+ getReplaceWords() {
48
+ let data = { environmentalVars: "" };
49
+ if (this.settings.nodeEnv) {
50
+ data.environmentalVars = `ENV NODE_ENV=${this.settings.nodeEnv}`;
51
+ }
52
+ //!!! Orbay: Bu böyle yönetilmemeli! Geçici yazıldı. Sanki app'in içinden bir yerden almalı bu bilgiyi???
53
+ if (this.settings.environment == "remote") {
54
+ data.registryHostName = "nexus-service";
55
+ }
56
+ else {
57
+ data.registryHostName = "nexus.rally.softtech";
58
+ }
59
+ return data;
60
+ }
61
+ getDockerCommandArgs() {
62
+ let args = [
63
+ "login",
64
+ "--username",
65
+ this.settings.dockerSettings.username,
66
+ "--password",
67
+ this.settings.dockerSettings.password
68
+ ];
69
+ if (this.settings.environment == "remote") {
70
+ args.push(this.settings.dockerSettings.url);
71
+ }
72
+ return args;
73
+ }
74
+ getFnCommandArgs() {
75
+ return [
76
+ "create",
77
+ "context", "cloudemo",
78
+ "--provider", "default",
79
+ "--registry", "symphonydemo",
80
+ "--api-url",
81
+ this.settings.fnSettings.apiUrl
82
+ ];
83
+ }
84
+ async fnPreRemote(fnFileName) {
85
+ log_1.Logger.log({ message: "Docker command executing. Docker url", timeFormat: "datetime" });
86
+ await shellHelper_1.ShellHelper.ExecuteCommand("docker", this.getDockerCommandArgs());
87
+ //await ShellHelper.ExecuteCommand("docker", ["login", "--username", "symphonydemo", "--password", "f40ddfd4-aad6-4a6a-b3a9-fb54847fb60a"]);
88
+ let continueOnExitCode = 0;
89
+ // await ShellHelper.ExecuteCommand("fn", ["create", "context", "cloudemo", "--provider", "default", "--registry", "symphonydemo", "--api-url", "http://10.223.2.98:90"], {
90
+ log_1.Logger.log({ message: "Fn command executing", timeFormat: "datetime" });
91
+ await shellHelper_1.ShellHelper.ExecuteCommand(fnFileName, this.getFnCommandArgs(), {
92
+ stderr: (chunk) => {
93
+ if (chunk.indexOf("Fn: Context already exists") > -1) {
94
+ log_1.Logger.log({ message: styling_1.Chalk.create("red.bold", chunk), timeFormat: "datetime" });
95
+ continueOnExitCode = 1;
96
+ log_1.Logger.log({ message: styling_1.Chalk.create("green.bold", "we got it, context exits"), timeFormat: "datetime" });
97
+ return false;
98
+ }
99
+ return true;
100
+ },
101
+ exit: (code) => {
102
+ if (!code || !continueOnExitCode) {
103
+ return null;
104
+ }
105
+ return { code: null, signal: null };
106
+ }
107
+ });
108
+ if (continueOnExitCode == 1) {
109
+ await this.fnContext("default", fnFileName);
110
+ await this.fnContextDelete("cloudemo", fnFileName);
111
+ await this.fnPreRemote(fnFileName);
112
+ return;
113
+ }
114
+ log_1.Logger.log({ message: "fnContext step running...", timeFormat: "datetime" });
115
+ await this.fnContext("cloudemo", fnFileName);
116
+ log_1.Logger.log({ message: styling_1.Chalk.create("green.bold", "Pre Fn complete"), timeFormat: "datetime" });
117
+ }
118
+ async fnContextDelete(contextName, fnFileName) {
119
+ log_1.Logger.log({ message: "fnContext delete existing context...: " + contextName, timeFormat: "datetime" });
120
+ await shellHelper_1.ShellHelper.ExecuteCommand(fnFileName, ["delete", "context", contextName]);
121
+ log_1.Logger.log({ message: "fnContext deleted existing context: " + contextName, timeFormat: "datetime" });
122
+ }
123
+ async fnContext(contextName, fnFileName) {
124
+ let continueOnExitCode = false;
125
+ log_1.Logger.log({ message: styling_1.Chalk.create("green.bold", "context switching to...: " + contextName), timeFormat: "datetime" });
126
+ await shellHelper_1.ShellHelper.ExecuteCommand(fnFileName, ["use", "context", contextName], {
127
+ stderr: (chunk) => {
128
+ if (chunk.indexOf(`Fn: Context ${contextName} currently in use`) > -1) {
129
+ log_1.Logger.log({ message: styling_1.Chalk.create("red.bold", chunk), timeFormat: "datetime" });
130
+ continueOnExitCode = true;
131
+ log_1.Logger.log({ message: styling_1.Chalk.create("green.bold", "we got it context in place"), timeFormat: "datetime" });
132
+ return false;
133
+ }
134
+ if (chunk.indexOf("error replacing file with tempfile") > -1) {
135
+ log_1.Logger.log({ message: styling_1.Chalk.create("red.bold", chunk), timeFormat: "datetime" });
136
+ const homePath = process.env.HOME || process.env.HOMEPATH;
137
+ log_1.Logger.log({ message: `trying to fix fn. Home path: ${homePath}`, timeFormat: "datetime" });
138
+ const fnPath = path.join(homePath, '/.fn/');
139
+ const yamls = fs.readdirSync(fnPath).filter(item => item.startsWith("config.yaml") && item != "config.yaml").map(item => { const file = path.join(fnPath, item); return { file, ctime: fs.statSync(file) }; });
140
+ log_1.Logger.log({ message: yamls.map(yaml => yaml.file).join(","), timeFormat: "datetime" });
141
+ if (yamls.length < 1) {
142
+ return false;
143
+ }
144
+ const latestYaml = yamls.reduce((prev, cur, index) => cur.ctime > prev.ctime ? cur : prev, yamls[0]);
145
+ log_1.Logger.log({ message: "using yaml: " + latestYaml.file, timeFormat: "datetime" });
146
+ fs.unlinkSync(path.join(fnPath, "config.yaml"));
147
+ fs.renameSync(latestYaml.file, path.join(fnPath, "config.yaml"));
148
+ yamls.filter(yaml => yaml != latestYaml).forEach(yaml => fs.unlinkSync(yaml.file));
149
+ continueOnExitCode = true;
150
+ log_1.Logger.log({ message: styling_1.Chalk.create("green.bold", "symphony fixed fn context"), timeFormat: "datetime" });
151
+ return false;
152
+ }
153
+ return true;
154
+ },
155
+ exit: () => continueOnExitCode ? { code: null, signal: null } : null
156
+ });
157
+ log_1.Logger.log({ message: styling_1.Chalk.create("green.bold", "context switched to: " + contextName), timeFormat: "datetime" });
158
+ }
159
+ async fnDeploy(fnFileName) {
160
+ const args = ["--verbose", "deploy", "--create-app", "--all"];
161
+ if (this.settings.environment === "local") {
162
+ args.push("--local");
163
+ }
164
+ let finalYamlErrorThatShouldBeDiscarded = false;
165
+ let successFunctionCounter = 0;
166
+ await shellHelper_1.ShellHelper.ExecuteCommand(fnFileName, args, {
167
+ stdout: (chunkString) => {
168
+ if (chunkString.indexOf("Updating function") > -1) {
169
+ log_1.Logger.log({ message: styling_1.Chalk.create("green.bold", chunkString), timeFormat: "datetime" });
170
+ successFunctionCounter++;
171
+ }
172
+ else if (chunkString.indexOf("Step ") > -1) {
173
+ log_1.Logger.log({ message: styling_1.Chalk.create("green.bold", chunkString), timeFormat: "datetime" });
174
+ }
175
+ return true;
176
+ },
177
+ stderr: (chunkstring) => {
178
+ if (chunkstring.indexOf("connection attempt failed because the connected party did not properly respond") > -1) {
179
+ log_1.Logger.log({ message: styling_1.Chalk.create("yellow.bold", "Connection Issue, did you check VPN ?"), timeFormat: "datetime" });
180
+ }
181
+ if (successFunctionCounter > 0 && chunkstring.indexOf("Fn: yaml: unmarshal errors:") > -1 && chunkstring.indexOf("cannot unmarshal !!map into string") > -1) {
182
+ log_1.Logger.log({ message: "Skipping final yaml error that should be discarded", timeFormat: "datetime" });
183
+ finalYamlErrorThatShouldBeDiscarded = true;
184
+ }
185
+ return true;
186
+ },
187
+ exit: (code, signal) => {
188
+ if (finalYamlErrorThatShouldBeDiscarded) {
189
+ return { code: null, signal: null };
190
+ }
191
+ return null;
192
+ }
193
+ });
194
+ }
195
+ }
196
+ exports.FnDeployHelper = FnDeployHelper;
@@ -0,0 +1,20 @@
1
+ export interface IDockerSettings {
2
+ url: string;
3
+ username: string;
4
+ password: string;
5
+ }
6
+ export interface IFnSettings {
7
+ apiUrl: string;
8
+ }
9
+ export interface IDeploySettings {
10
+ nodeEnv?: string;
11
+ imageName: string;
12
+ }
13
+ export declare class NanoDeployHelper {
14
+ private settings;
15
+ constructor(settings: IDeploySettings);
16
+ deploy(): Promise<void>;
17
+ private getReplaceWords;
18
+ private fnContextDelete;
19
+ private nanoDeploy;
20
+ }
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NanoDeployHelper = void 0;
4
+ const nanoPredeploy_1 = require("../../predeploy/src/nano/nanoPredeploy");
5
+ const nanoPostdeploy_1 = require("../../predeploy/src/nano/nanoPostdeploy");
6
+ const shellHelper_1 = require("../shellHelper");
7
+ const initHelper_1 = require("../initHelper");
8
+ const log_1 = require("@stechquick/symphony-common/lib/log");
9
+ const styling_1 = require("@stechquick/symphony-common/lib/styling");
10
+ class NanoDeployHelper {
11
+ constructor(settings) {
12
+ this.settings = settings;
13
+ }
14
+ async deploy() {
15
+ if (!initHelper_1.InitHelper.AssertInFolder()) {
16
+ log_1.Logger.log({ message: styling_1.Chalk.create("red.bold", "Command must be executed in app root!") });
17
+ return;
18
+ }
19
+ log_1.Logger.log({ message: styling_1.Chalk.create("green.bold", "Deploy starting..."), timeFormat: "datetime" });
20
+ let success = false;
21
+ try {
22
+ await nanoPredeploy_1.NanoPredeploy.execute(this.getReplaceWords());
23
+ await this.nanoDeploy();
24
+ success = true;
25
+ }
26
+ finally {
27
+ nanoPostdeploy_1.NanoPostDeploy.execute();
28
+ if (!success) {
29
+ log_1.Logger.log({ message: styling_1.Chalk.create("red.bold", "Deploy failed, ^^ search for errors up ^^"), timeFormat: "datetime" });
30
+ }
31
+ else {
32
+ log_1.Logger.log({ message: styling_1.Chalk.create("green.bold", "Deploy complete"), timeFormat: "datetime" });
33
+ }
34
+ }
35
+ }
36
+ getReplaceWords() {
37
+ let data = { environmentalVars: "" };
38
+ if (this.settings.nodeEnv) {
39
+ data.environmentalVars = `ENV NODE_ENV=${this.settings.nodeEnv}`;
40
+ }
41
+ // //!!! Orbay: Bu böyle yönetilmemeli! Geçici yazıldı. Sanki app'in içinden bir yerden almalı bu bilgiyi???
42
+ // switch (this.settings.environment) {
43
+ // case "openvpn":
44
+ // data.npm_registry = `# registry=http://nexus-service/repository/rally-npm/ | http://nexus.rally.softtech/repository/rally-npm/
45
+ // # email=npm_upload_user@softtech.com.tr
46
+ // # //nexus.rally.softtech/repository/rally-npm/:_authToken=NpmToken.8bcac3c0-8431-37d7-8c79-3b734756bea1
47
+ // # //nexus.rally.softtech/repository/npm-hosted/:_authToken=NpmToken.1201c29d-4df1-3acd-a2c6-0a839a902c52
48
+ // registry=http://nexus.rally.softtech/repository/rally-npm/
49
+ // email=npm_upload_user@softtech.com.tr
50
+ // //nexus.rally.softtech/repository/rally-npm/:_authToken=NpmToken.8bcac3c0-8431-37d7-8c79-3b734756bea1
51
+ // //nexus.rally.softtech/repository/npm-hosted/:_authToken=NpmToken.1201c29d-4df1-3acd-a2c6-0a839a902c52`;
52
+ // break;
53
+ // case "pulsevpn":
54
+ // data.npm_registry = `registry=http://nexus.softtech:8081/repository/softtech`;
55
+ // break;
56
+ // // case "remote":
57
+ // // data.npm_registry = `# registry=http://nexus-service/repository/rally-npm/ | http://nexus.rally.softtech/repository/rally-npm/
58
+ // // # email=npm_upload_user@softtech.com.tr
59
+ // // # //nexus.rally.softtech/repository/rally-npm/:_authToken=NpmToken.8bcac3c0-8431-37d7-8c79-3b734756bea1
60
+ // // # //nexus.rally.softtech/repository/npm-hosted/:_authToken=NpmToken.1201c29d-4df1-3acd-a2c6-0a839a902c52
61
+ // // registry=http://nexus-service/repository/rally-npm/
62
+ // // email=npm_upload_user@softtech.com.tr
63
+ // // //nexus-service/repository/rally-npm/:_authToken=NpmToken.8bcac3c0-8431-37d7-8c79-3b734756bea1
64
+ // // //nexus-service/repository/npm-hosted/:_authToken=NpmToken.1201c29d-4df1-3acd-a2c6-0a839a902c52`;
65
+ // // break;
66
+ // }
67
+ return data;
68
+ }
69
+ async fnContextDelete(contextName, fnFileName) {
70
+ log_1.Logger.log({ message: "fnContext delete existing context...: " + contextName, timeFormat: "datetime" });
71
+ await shellHelper_1.ShellHelper.ExecuteCommand(fnFileName, ["delete", "context", contextName]);
72
+ log_1.Logger.log({ message: "fnContext deleted existing context: " + contextName, timeFormat: "datetime" });
73
+ }
74
+ async nanoDeploy() {
75
+ // const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
76
+ // //const ImageName="gcr.io/softtech-rally/symphony/isleasing:latest"
77
+ // const appName = packageJson.name || "symphony-app";
78
+ log_1.Logger.log({ message: styling_1.Chalk.create("green.bold", "docker build is starting"), timeFormat: "datetime" });
79
+ await shellHelper_1.ShellHelper.ExecuteCommand('docker', ['build', '-t', this.settings.imageName, '.']);
80
+ log_1.Logger.log({ message: styling_1.Chalk.create("green.bold", "docker build is finished"), timeFormat: "datetime" });
81
+ }
82
+ }
83
+ exports.NanoDeployHelper = NanoDeployHelper;
@@ -0,0 +1,11 @@
1
+ declare type PlatformType = "linux" | "win32";
2
+ export declare class FnDownloadHelepr {
3
+ private downloadPathUrl;
4
+ private fnFileName;
5
+ private platform;
6
+ private platformFnFileLookup;
7
+ constructor(platform?: PlatformType);
8
+ downloadFn(): Promise<string>;
9
+ private downloadFnInternal;
10
+ }
11
+ export {};
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FnDownloadHelepr = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const log_1 = require("@stechquick/symphony-common/lib/log");
6
+ const styling_1 = require("@stechquick/symphony-common/lib/styling");
7
+ const fs = tslib_1.__importStar(require("fs"));
8
+ const https = tslib_1.__importStar(require("https"));
9
+ const shellHelper_1 = require("./shellHelper");
10
+ class FnDownloadHelepr {
11
+ constructor(platform) {
12
+ this.downloadPathUrl = "https://github.com/fnproject/cli/releases/download/0.5.99/";
13
+ this.platformFnFileLookup = {
14
+ "win32": "fn.exe",
15
+ "linux": "fn_linux"
16
+ };
17
+ this.platform = platform || process.platform;
18
+ this.fnFileName = this.platformFnFileLookup[this.platform];
19
+ }
20
+ async downloadFn() {
21
+ const fileName = `./${this.fnFileName}`;
22
+ if (fs.existsSync(fileName)) {
23
+ log_1.Logger.log({ message: "Fn file is found. Not download", timeFormat: "datetime" });
24
+ return fileName;
25
+ }
26
+ await this.downloadFnInternal();
27
+ log_1.Logger.log({ message: `Running: chmod +x fileName`, timeFormat: "datetime" });
28
+ await shellHelper_1.ShellHelper.ExecuteCommand("chmod", ["+x", fileName]);
29
+ return fileName;
30
+ }
31
+ async downloadFnInternal() {
32
+ const fileName = `./${this.fnFileName}`;
33
+ log_1.Logger.log({ message: `downloading ${this.fnFileName} from fn project` });
34
+ const url = this.downloadPathUrl + this.fnFileName;
35
+ log_1.Logger.log({ message: "Fn is downloanding from: " + url, timeFormat: "datetime" });
36
+ return new Promise((res, rej) => {
37
+ const request = https.get(url, function (response) {
38
+ if (response.statusCode != 302 || !response.headers.location) {
39
+ rej({ message: "could not download fn, got http: " + response.statusCode + " " + response.statusMessage });
40
+ return;
41
+ }
42
+ const requestFnFile = https.get(response.headers.location, response => {
43
+ if (response.statusCode != 200) {
44
+ rej({ message: "could not download fn, got http: " + response.statusCode + " " + response.statusMessage });
45
+ }
46
+ const length = response.headers["content-length"];
47
+ log_1.Logger.log({ message: styling_1.Chalk.create("bold", "downloading length: " + length), timeFormat: "datetime" });
48
+ const file = fs.createWriteStream(fileName);
49
+ response.pipe(file);
50
+ file.on('finish', function () {
51
+ log_1.Logger.log({ message: "Got it", timeFormat: "datetime" });
52
+ file.close();
53
+ setTimeout(res, 1000); // I don't know if file closed, just wait;
54
+ });
55
+ log_1.Logger.log({ message: "Got response, writing file", timeFormat: "datetime" });
56
+ }).on('error', function (err) {
57
+ fs.unlinkSync(fileName); // Delete the file async. (But we don't check the result)
58
+ rej(err);
59
+ });
60
+ });
61
+ });
62
+ }
63
+ }
64
+ exports.FnDownloadHelepr = FnDownloadHelepr;
@@ -0,0 +1,22 @@
1
+ export declare enum CommandType {
2
+ createapp = 1,
3
+ addfunc = 2
4
+ }
5
+ export declare class InitHelper {
6
+ private subPath;
7
+ private replaceMap;
8
+ private funcNameRegExp;
9
+ private appNameRegExp;
10
+ private moduleNameRegExp;
11
+ private removeRegExp;
12
+ private appDescRegExp;
13
+ private moduleDescRegExp;
14
+ private addFuncSearchPath;
15
+ private initSearchPath;
16
+ private moduleSearchPath;
17
+ constructor();
18
+ static AssertInFolder(): boolean;
19
+ AddFunc(funcName: string): Promise<void>;
20
+ AddApp(appName: string, appDesc: string): Promise<void>;
21
+ AddModule(moduleName: string, moduleDesc: string): Promise<void>;
22
+ }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InitHelper = exports.CommandType = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs = tslib_1.__importStar(require("fs"));
6
+ const path = tslib_1.__importStar(require("path"));
7
+ const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
8
+ const fileHelper_1 = require("@stechquick/symphony-common/lib/helpers/fileHelper");
9
+ const log_1 = require("@stechquick/symphony-common/lib/log");
10
+ const styling_1 = require("@stechquick/symphony-common/lib/styling");
11
+ var CommandType;
12
+ (function (CommandType) {
13
+ CommandType[CommandType["createapp"] = 1] = "createapp";
14
+ CommandType[CommandType["addfunc"] = 2] = "addfunc";
15
+ })(CommandType = exports.CommandType || (exports.CommandType = {}));
16
+ class InitHelper {
17
+ constructor() {
18
+ this.subPath = "./";
19
+ this.replaceMap = new Map();
20
+ this.funcNameRegExp = /{{FuncName}}/g;
21
+ this.appNameRegExp = /{{AppName}}/g;
22
+ this.moduleNameRegExp = /{{ModuleName}}/g;
23
+ this.removeRegExp = /{{remove}}/g;
24
+ this.appDescRegExp = /{{AppDesc}}/g;
25
+ this.moduleDescRegExp = /{{ModuleDesc}}/g;
26
+ this.addFuncSearchPath = "/templates/addfunc";
27
+ this.initSearchPath = "/templates/init";
28
+ this.moduleSearchPath = "/templates/addModule";
29
+ this.replaceMap.set(this.removeRegExp, "");
30
+ }
31
+ static AssertInFolder() {
32
+ return fs.existsSync("./functions") && fs.existsSync("./package.json") && fs.existsSync("./local.ts");
33
+ }
34
+ async AddFunc(funcName) {
35
+ log_1.Logger.log({ message: styling_1.Chalk.create("green.bold", "Function " + funcName + " adding. Please wait..."), timeFormat: "datetime" });
36
+ this.replaceMap.set(this.funcNameRegExp, funcName);
37
+ if (!InitHelper.AssertInFolder()) {
38
+ log_1.Logger.log({ message: styling_1.Chalk.create("red.bold", "Command must be executed in app root!") });
39
+ return;
40
+ }
41
+ if (fs.existsSync("./functions/" + funcName)) {
42
+ const answer = await cli_ux_1.default.confirm("Function: " + funcName + " already exists. If you have any, you will lose your pending changes. Would you like to overwrite it? [Y/N]");
43
+ if (!answer) {
44
+ return;
45
+ }
46
+ }
47
+ const addFuncTemplatePath = path.join(path.resolve(__dirname), "../.." + this.addFuncSearchPath);
48
+ fileHelper_1.FileHelper.exportFiles({ sourcePath: addFuncTemplatePath, targetPath: "./", replaceMap: this.replaceMap });
49
+ log_1.Logger.log({ message: styling_1.Chalk.create("green.bold", "Function " + funcName + " added successfully."), timeFormat: "datetime" });
50
+ }
51
+ async AddApp(appName, appDesc) {
52
+ this.replaceMap.set(this.appNameRegExp, appName);
53
+ this.replaceMap.set(this.appDescRegExp, appDesc);
54
+ const existsSubPath = fs.existsSync(this.subPath + appName);
55
+ if (existsSubPath) {
56
+ const answer = await cli_ux_1.default.confirm("App: " + appName + " already exists. If you have any, you will lose your pending changes. Would you like to overwrite it?");
57
+ if (!answer) {
58
+ return;
59
+ }
60
+ }
61
+ const templatePath = path.join(path.resolve(__dirname), "../.." + this.initSearchPath);
62
+ fileHelper_1.FileHelper.exportFiles({ sourcePath: templatePath, targetPath: "./", replaceMap: this.replaceMap });
63
+ }
64
+ async AddModule(moduleName, moduleDesc) {
65
+ this.replaceMap.set(this.moduleNameRegExp, moduleName);
66
+ this.replaceMap.set(this.moduleDescRegExp, moduleDesc);
67
+ const existsSubPath = fs.existsSync(this.subPath + moduleName);
68
+ if (existsSubPath) {
69
+ const answer = await cli_ux_1.default.confirm("Module: " + moduleName + " already exists. If you have any, you will lose your pending changes. Would you like to overwrite it?");
70
+ if (!answer) {
71
+ return;
72
+ }
73
+ }
74
+ const templatePath = path.join(path.resolve(__dirname), "../.." + this.moduleSearchPath);
75
+ fileHelper_1.FileHelper.exportFiles({ sourcePath: templatePath, targetPath: "./", replaceMap: this.replaceMap });
76
+ }
77
+ }
78
+ exports.InitHelper = InitHelper;
@@ -0,0 +1,10 @@
1
+ export declare class MicroUIHelper {
2
+ private subPath;
3
+ private replaceMap;
4
+ private uiNameRegExp;
5
+ private uiDescRegExp;
6
+ private removeRegExp;
7
+ private createuiSearchPath;
8
+ constructor();
9
+ CreateMicroUI(microUIName: string, microUIDesc: string): Promise<void>;
10
+ }
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MicroUIHelper = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs = tslib_1.__importStar(require("fs"));
6
+ const path = tslib_1.__importStar(require("path"));
7
+ const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
8
+ const fileHelper_1 = require("@stechquick/symphony-common/lib/helpers/fileHelper");
9
+ class MicroUIHelper {
10
+ constructor() {
11
+ this.subPath = "./";
12
+ this.replaceMap = new Map();
13
+ this.uiNameRegExp = /{{MicroUIName}}/g;
14
+ this.uiDescRegExp = /{{MicroUIDesc}}/g;
15
+ this.removeRegExp = /{{remove}}/g;
16
+ this.createuiSearchPath = "/templates/createmicroui";
17
+ this.replaceMap.set(this.removeRegExp, "");
18
+ }
19
+ async CreateMicroUI(microUIName, microUIDesc) {
20
+ this.replaceMap.set(this.uiNameRegExp, microUIName);
21
+ this.replaceMap.set(this.uiDescRegExp, microUIDesc);
22
+ const existsSubPath = fs.existsSync(this.subPath + microUIName);
23
+ if (existsSubPath) {
24
+ const answer = await cli_ux_1.default.confirm("App: " + microUIName + " already exists. If you have any, you will lose your pending changes. Would you like to overwrite it?");
25
+ if (!answer) {
26
+ return;
27
+ }
28
+ }
29
+ const templatePath = path.join(path.resolve(__dirname), "../.." + this.createuiSearchPath);
30
+ fileHelper_1.FileHelper.exportFiles({ sourcePath: templatePath, targetPath: "./", replaceMap: this.replaceMap });
31
+ }
32
+ }
33
+ exports.MicroUIHelper = MicroUIHelper;
@@ -0,0 +1,15 @@
1
+ export declare class NCHelper {
2
+ private subPath;
3
+ private replaceMap;
4
+ private ncNameRegExp;
5
+ private ncDescRegExp;
6
+ private compNameRegExp;
7
+ private removeRegExp;
8
+ private createncSearchPath;
9
+ private addCompSearchPath;
10
+ constructor();
11
+ static AssertInFolder(): boolean;
12
+ CreateNC(ncName: string, ncDesc: string): Promise<void>;
13
+ AddComponent(componentName: string): Promise<void>;
14
+ BuildNC(watch: boolean): void;
15
+ }
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NCHelper = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const fs = tslib_1.__importStar(require("fs"));
6
+ const path = tslib_1.__importStar(require("path"));
7
+ const cli_ux_1 = tslib_1.__importDefault(require("cli-ux"));
8
+ const fileHelper_1 = require("@stechquick/symphony-common/lib/helpers/fileHelper");
9
+ const log_1 = require("@stechquick/symphony-common/lib/log");
10
+ const npmHelper_1 = require("../npmHelper");
11
+ const styling_1 = require("@stechquick/symphony-common/lib/styling");
12
+ class NCHelper {
13
+ constructor() {
14
+ this.subPath = "./";
15
+ this.replaceMap = new Map();
16
+ this.ncNameRegExp = /{{ProjectName}}/g;
17
+ this.ncDescRegExp = /{{ProjectDescription}}/g;
18
+ this.compNameRegExp = /{{ComponentName}}/g;
19
+ this.removeRegExp = /{{remove}}/g;
20
+ this.createncSearchPath = "../../../../templates/nc-create";
21
+ this.addCompSearchPath = "../../../../templates/nc-addComp";
22
+ this.replaceMap.set(this.removeRegExp, "");
23
+ }
24
+ static AssertInFolder() {
25
+ return fs.existsSync("./src/namedComps") && fs.existsSync("./package.json");
26
+ }
27
+ async CreateNC(ncName, ncDesc) {
28
+ this.replaceMap.set(this.ncNameRegExp, ncName);
29
+ this.replaceMap.set(this.ncDescRegExp, ncDesc);
30
+ const existsSubPath = fs.existsSync(this.subPath + ncName);
31
+ if (existsSubPath) {
32
+ const answer = await cli_ux_1.default.confirm("Named Component: " + ncName + " already exists. If you have any, you will lose your pending changes. Would you like to overwrite it?");
33
+ if (!answer) {
34
+ return;
35
+ }
36
+ }
37
+ const templatePath = path.join(path.resolve(__dirname), "../.." + this.createncSearchPath);
38
+ return fileHelper_1.FileHelper.exportFiles({ sourcePath: templatePath, targetPath: "./", replaceMap: this.replaceMap });
39
+ }
40
+ async AddComponent(componentName) {
41
+ this.replaceMap.set(this.compNameRegExp, componentName);
42
+ if (!NCHelper.AssertInFolder()) {
43
+ log_1.Logger.log({ message: styling_1.Chalk.create("red.bold", "Command must be executed in app root!") });
44
+ return;
45
+ }
46
+ const existsSubPath = fs.existsSync("./src/namedComps" + componentName);
47
+ if (existsSubPath) {
48
+ const answer = await cli_ux_1.default.confirm("Component: " + componentName + " already exists. If you have any, you will lose your pending changes. Would you like to overwrite it?");
49
+ if (!answer) {
50
+ return;
51
+ }
52
+ }
53
+ const templatePath = path.join(path.resolve(__dirname), "../.." + this.addCompSearchPath);
54
+ fileHelper_1.FileHelper.exportFiles({ sourcePath: templatePath, targetPath: "./src/namedComps", replaceMap: this.replaceMap });
55
+ }
56
+ BuildNC(watch) {
57
+ npmHelper_1.NpmHelper.buildWebpack({ watch });
58
+ }
59
+ }
60
+ exports.NCHelper = NCHelper;
@@ -0,0 +1,23 @@
1
+ export interface IInstallSettings {
2
+ folderName: string;
3
+ }
4
+ export interface IBuildSettings {
5
+ watch?: boolean;
6
+ }
7
+ export interface IRunSettings {
8
+ debug?: boolean;
9
+ build?: boolean;
10
+ httpPort?: number;
11
+ httpsPort?: number;
12
+ hostedPath?: string;
13
+ }
14
+ export declare class NpmHelper {
15
+ private static readonly BUILD_CMD;
16
+ private static readonly WEBPACK_CMD;
17
+ static install(settings: IInstallSettings): void;
18
+ static build(settings?: IBuildSettings): void;
19
+ static buildWebpack(settings?: IBuildSettings): void;
20
+ static run(environment: string, settings: IRunSettings): void;
21
+ static getCurrentPackageVersions(): Record<string, string>;
22
+ private static execCommand;
23
+ }