@tremho/mist-lift 1.1.2 → 1.1.4-pre-release.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 (169) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +66 -65
  3. package/build/QSTest/functions/IntegrationTest/integrationTest-tests/Sanity.test.js +14 -0
  4. package/build/QSTest/functions/IntegrationTest/integrationTest-tests/Sanity.test.js.map +1 -0
  5. package/build/QSTest/functions/IntegrationTest/src/local.js +33 -0
  6. package/build/QSTest/functions/IntegrationTest/src/local.js.map +1 -0
  7. package/build/QSTest/functions/IntegrationTest/src/main.js +29 -0
  8. package/build/QSTest/functions/IntegrationTest/src/main.js.map +1 -0
  9. package/build/{commands → src/commands}/actions/initQuestions.js +1 -1
  10. package/build/src/commands/actions/initQuestions.js.map +1 -0
  11. package/build/src/commands/actions/makePackageJson.js.map +1 -0
  12. package/build/src/commands/actions/setupPackageJson.js.map +1 -0
  13. package/build/{commands → src/commands}/build.js +7 -6
  14. package/build/src/commands/build.js.map +1 -0
  15. package/build/{commands → src/commands}/builtin/ApiDocMaker.js +9 -3
  16. package/build/src/commands/builtin/ApiDocMaker.js.map +1 -0
  17. package/build/src/commands/builtin/BuiltInHandler.js.map +1 -0
  18. package/build/src/commands/builtin/DeployBuiltInZip.js.map +1 -0
  19. package/build/src/commands/builtin/StageWebrootZip.js.map +1 -0
  20. package/build/src/commands/create.js.map +1 -0
  21. package/build/src/commands/deploy.js.map +1 -0
  22. package/build/{commands → src/commands}/doctor.js +2 -1
  23. package/build/src/commands/doctor.js.map +1 -0
  24. package/build/src/commands/help.js.map +1 -0
  25. package/build/src/commands/info.js.map +1 -0
  26. package/build/src/commands/init.js.map +1 -0
  27. package/build/src/commands/package.js.map +1 -0
  28. package/build/src/commands/publish.js.map +1 -0
  29. package/build/src/commands/settings.js.map +1 -0
  30. package/build/src/commands/start.js.map +1 -0
  31. package/build/src/commands/test.js.map +1 -0
  32. package/build/src/commands/user.js.map +1 -0
  33. package/build/src/expressRoutes/all.js.map +1 -0
  34. package/build/src/expressRoutes/api.js.map +1 -0
  35. package/build/src/expressRoutes/functionBinder.js.map +1 -0
  36. package/build/{integration-tests → src/integration-tests}/quickstart-scenario.test.js +13 -11
  37. package/build/src/integration-tests/quickstart-scenario.test.js.map +1 -0
  38. package/build/src/lib/CaseUtils.js.map +1 -0
  39. package/build/src/lib/DirectoryUtils.js.map +1 -0
  40. package/build/src/lib/LiftConfig.js.map +1 -0
  41. package/build/src/lib/LiftVersion.js.map +1 -0
  42. package/build/src/lib/Tests/fileCompare.test.js.map +1 -0
  43. package/build/src/lib/askQuestion.js.map +1 -0
  44. package/build/src/lib/executeCommand.js.map +1 -0
  45. package/build/src/lib/fileCompare.js.map +1 -0
  46. package/build/src/lib/openAPI/ApiBuildCollector.js.map +1 -0
  47. package/build/src/lib/openAPI/WebrootFileSupport.js.map +1 -0
  48. package/build/src/lib/openAPI/openApiConstruction.js.map +1 -0
  49. package/build/src/lib/pathResolve.js.map +1 -0
  50. package/build/src/lib/utils.js.map +1 -0
  51. package/build/{lift.js → src/lift.js} +0 -0
  52. package/build/src/lift.js.map +1 -0
  53. package/package.json +79 -75
  54. package/src/commands/actions/initQuestions.ts +133 -133
  55. package/src/commands/actions/setupPackageJson.ts +32 -32
  56. package/src/commands/build.ts +173 -170
  57. package/src/commands/builtin/ApiDocMaker.ts +106 -102
  58. package/src/commands/builtin/BuiltInHandler.ts +47 -47
  59. package/src/commands/builtin/DeployBuiltInZip.ts +25 -25
  60. package/src/commands/builtin/StageWebrootZip.ts +36 -36
  61. package/src/commands/create.ts +52 -52
  62. package/src/commands/deploy.ts +161 -161
  63. package/src/commands/doctor.ts +107 -106
  64. package/src/commands/help.ts +178 -178
  65. package/src/commands/info.ts +42 -42
  66. package/src/commands/init.ts +61 -61
  67. package/src/commands/package.ts +234 -234
  68. package/src/commands/publish.ts +330 -330
  69. package/src/commands/settings.ts +73 -73
  70. package/src/commands/start.ts +43 -43
  71. package/src/commands/test.ts +37 -37
  72. package/src/commands/user.ts +20 -20
  73. package/src/expressRoutes/all.ts +99 -99
  74. package/src/expressRoutes/api.ts +22 -22
  75. package/src/expressRoutes/functionBinder.ts +155 -155
  76. package/src/integration-tests/quickstart-scenario.test.ts +76 -74
  77. package/src/lib/CaseUtils.ts +63 -63
  78. package/src/lib/DirectoryUtils.ts +34 -34
  79. package/src/lib/LiftConfig.ts +74 -74
  80. package/src/lib/LiftVersion.ts +87 -87
  81. package/src/lib/Tests/fileCompare.test.ts +35 -35
  82. package/src/lib/askQuestion.ts +17 -17
  83. package/src/lib/executeCommand.ts +45 -45
  84. package/src/lib/fileCompare.ts +55 -55
  85. package/src/lib/openAPI/ApiBuildCollector.ts +47 -47
  86. package/src/lib/openAPI/WebrootFileSupport.ts +19 -19
  87. package/src/lib/openAPI/openApiConstruction.ts +196 -196
  88. package/src/lib/pathResolve.ts +26 -26
  89. package/src/lib/utils.ts +43 -43
  90. package/src/lift.ts +87 -87
  91. package/templateData/function-definition-template +20 -20
  92. package/templateData/function-local-ts +16 -16
  93. package/templateData/function-main-ts +16 -16
  94. package/templateData/function-runmain-mjs +6 -6
  95. package/templateData/function-test-template +11 -11
  96. package/templateData/swagger-ui-bundle.js +2 -2
  97. package/templateData/swagger-ui-standalone-preset.js +2 -2
  98. package/templateData/swagger-ui.css +2 -2
  99. package/tsconfig.json +28 -28
  100. package/build/commands/actions/initQuestions.js.map +0 -1
  101. package/build/commands/actions/makePackageJson.js.map +0 -1
  102. package/build/commands/actions/setupPackageJson.js.map +0 -1
  103. package/build/commands/build.js.map +0 -1
  104. package/build/commands/builtin/ApiDocMaker.js.map +0 -1
  105. package/build/commands/builtin/BuiltInHandler.js.map +0 -1
  106. package/build/commands/builtin/DeployBuiltInZip.js.map +0 -1
  107. package/build/commands/builtin/StageWebrootZip.js.map +0 -1
  108. package/build/commands/create.js.map +0 -1
  109. package/build/commands/deploy.js.map +0 -1
  110. package/build/commands/doctor.js.map +0 -1
  111. package/build/commands/help.js.map +0 -1
  112. package/build/commands/info.js.map +0 -1
  113. package/build/commands/init.js.map +0 -1
  114. package/build/commands/package.js.map +0 -1
  115. package/build/commands/publish.js.map +0 -1
  116. package/build/commands/settings.js.map +0 -1
  117. package/build/commands/start.js.map +0 -1
  118. package/build/commands/test.js.map +0 -1
  119. package/build/commands/user.js.map +0 -1
  120. package/build/expressRoutes/all.js.map +0 -1
  121. package/build/expressRoutes/api.js.map +0 -1
  122. package/build/expressRoutes/functionBinder.js.map +0 -1
  123. package/build/integration-tests/quickstart-scenario.test.js.map +0 -1
  124. package/build/lib/CaseUtils.js.map +0 -1
  125. package/build/lib/DirectoryUtils.js.map +0 -1
  126. package/build/lib/LiftConfig.js.map +0 -1
  127. package/build/lib/LiftVersion.js.map +0 -1
  128. package/build/lib/Tests/fileCompare.test.js.map +0 -1
  129. package/build/lib/askQuestion.js.map +0 -1
  130. package/build/lib/executeCommand.js.map +0 -1
  131. package/build/lib/fileCompare.js.map +0 -1
  132. package/build/lib/openAPI/ApiBuildCollector.js.map +0 -1
  133. package/build/lib/openAPI/WebrootFileSupport.js.map +0 -1
  134. package/build/lib/openAPI/openApiConstruction.js.map +0 -1
  135. package/build/lib/pathResolve.js.map +0 -1
  136. package/build/lib/utils.js.map +0 -1
  137. package/build/lift.js.map +0 -1
  138. /package/build/{commands → src/commands}/actions/makePackageJson.js +0 -0
  139. /package/build/{commands → src/commands}/actions/setupPackageJson.js +0 -0
  140. /package/build/{commands → src/commands}/builtin/BuiltInHandler.js +0 -0
  141. /package/build/{commands → src/commands}/builtin/DeployBuiltInZip.js +0 -0
  142. /package/build/{commands → src/commands}/builtin/StageWebrootZip.js +0 -0
  143. /package/build/{commands → src/commands}/create.js +0 -0
  144. /package/build/{commands → src/commands}/deploy.js +0 -0
  145. /package/build/{commands → src/commands}/help.js +0 -0
  146. /package/build/{commands → src/commands}/info.js +0 -0
  147. /package/build/{commands → src/commands}/init.js +0 -0
  148. /package/build/{commands → src/commands}/package.js +0 -0
  149. /package/build/{commands → src/commands}/publish.js +0 -0
  150. /package/build/{commands → src/commands}/settings.js +0 -0
  151. /package/build/{commands → src/commands}/start.js +0 -0
  152. /package/build/{commands → src/commands}/test.js +0 -0
  153. /package/build/{commands → src/commands}/user.js +0 -0
  154. /package/build/{expressRoutes → src/expressRoutes}/all.js +0 -0
  155. /package/build/{expressRoutes → src/expressRoutes}/api.js +0 -0
  156. /package/build/{expressRoutes → src/expressRoutes}/functionBinder.js +0 -0
  157. /package/build/{lib → src/lib}/CaseUtils.js +0 -0
  158. /package/build/{lib → src/lib}/DirectoryUtils.js +0 -0
  159. /package/build/{lib → src/lib}/LiftConfig.js +0 -0
  160. /package/build/{lib → src/lib}/LiftVersion.js +0 -0
  161. /package/build/{lib → src/lib}/Tests/fileCompare.test.js +0 -0
  162. /package/build/{lib → src/lib}/askQuestion.js +0 -0
  163. /package/build/{lib → src/lib}/executeCommand.js +0 -0
  164. /package/build/{lib → src/lib}/fileCompare.js +0 -0
  165. /package/build/{lib → src/lib}/openAPI/ApiBuildCollector.js +0 -0
  166. /package/build/{lib → src/lib}/openAPI/WebrootFileSupport.js +0 -0
  167. /package/build/{lib → src/lib}/openAPI/openApiConstruction.js +0 -0
  168. /package/build/{lib → src/lib}/pathResolve.js +0 -0
  169. /package/build/{lib → src/lib}/utils.js +0 -0
@@ -1,106 +1,107 @@
1
-
2
- import * as ac from 'ansi-colors'
3
- import { VersionInfo, getLiftVersion, getProjectVersion, getProjectName } from '../lib/LiftVersion'
4
- import { executeCommand } from '../lib/executeCommand'
5
- import { resolvePaths } from '../lib/pathResolve'
6
- import { areSettingsAvailable } from '../lib/LiftConfig'
7
-
8
- export async function doDoctor (): Promise<boolean> {
9
- console.log(ac.blue.bold('Lift doctor'))
10
-
11
- const liftVersion = getLiftVersion()?.toString() ?? ''
12
- const projectVersion = getProjectVersion()?.toString() ?? ''
13
- const projectName = getProjectName() ?? ''
14
- const typescriptVersion = await fetchTypescriptVersion() ?? ''
15
- const nodeVersion = await fetchNodeVersion() ?? ''
16
- const npmVersion = await fetchNpmVersion() ?? ''
17
- const gitVersion = await fetchGitVersion() ?? ''
18
- const settingsAvail = areSettingsAvailable()
19
-
20
- console.log('Checking installed dependencies:')
21
- let ok = report('MistLift', liftVersion, '0.1.0')
22
- ok = ok && report('Typescript', typescriptVersion, '5.3.3')
23
- ok = ok && report('Node', nodeVersion, '20.11.0')
24
- ok = ok && report('Npm', npmVersion, '10.3.0')
25
- report('Git', gitVersion, '2.0.0')
26
- if (!settingsAvail) {
27
- console.log('')
28
- console.log(ac.yellow.dim.bold('Cloud Settings are not set. ') + ac.blue('run ' + ac.bold('lift settings')))
29
- }
30
- if (!ok) {
31
- console.log('')
32
- console.log(ac.red.bold('System needs updates before MistLift can be used.'))
33
- } else {
34
- console.log('')
35
- console.log(ac.green.bold('Ready for MistLift'))
36
- console.log('')
37
- if (resolvePaths().verified) {
38
- console.log(ac.blue.italic('Current project ' + projectName + ' ' + projectVersion))
39
- }
40
- }
41
- return ok
42
- }
43
-
44
- function versionTrim (vstr: string): string {
45
- vstr = vstr.trim()
46
- let i = -1
47
- while (++i < vstr.length) {
48
- const c = vstr.charAt(i)
49
- if (c >= '0' && c <= '9') break
50
- }
51
- return vstr.substring(i)
52
- }
53
-
54
- async function fetchTypescriptVersion (
55
-
56
- ): Promise<string> {
57
- const result = await executeCommand('tsc', ['-v'])
58
- if (result.retcode !== 0) return 'Typescript not found'
59
- const vstr = versionTrim(result.stdStr)
60
- return vstr
61
- }
62
-
63
- async function fetchNodeVersion (
64
-
65
- ): Promise<string> {
66
- const result = await executeCommand('node', ['-v'])
67
- if (result.retcode !== 0) return 'Node not found'
68
- const vstr = versionTrim(result.stdStr)
69
- return vstr
70
- }
71
-
72
- async function fetchNpmVersion (
73
-
74
- ): Promise<string> {
75
- const result = await executeCommand('npm', ['-v'])
76
- if (result.retcode !== 0) return 'npm not found'
77
- const vstr = versionTrim(result.stdStr)
78
- return vstr
79
- }
80
-
81
- async function fetchGitVersion (
82
-
83
- ): Promise<string> {
84
- const result = await executeCommand('git', ['-v'])
85
- if (result.retcode !== 0) return 'Git not found'
86
- const vstr = versionTrim(result.stdStr)
87
- return vstr
88
- }
89
-
90
- // compare to a minimum and report ok or error
91
-
92
- function report (
93
- name: string,
94
- version: string,
95
- minStr: string
96
- ): boolean {
97
- const ver = new VersionInfo(version)
98
- const minVer = new VersionInfo(minStr)
99
- const ok = (ver.isGreaterThan(minVer) || ver.equals(minVer))
100
- if (ok) {
101
- console.log(ac.green.bold('√ ') + ac.black.bold(name) + ' ' + ac.grey(version))
102
- } else {
103
- console.log(ac.red.bold('X ') + ac.black.bold(name) + ac.red.bold(' does not meet minimum version of ') + ac.blue(minStr))
104
- }
105
- return ok
106
- }
1
+
2
+ import * as ac from 'ansi-colors'
3
+ import { VersionInfo, getLiftVersion, getProjectVersion, getProjectName } from '../lib/LiftVersion'
4
+ import { executeCommand } from '../lib/executeCommand'
5
+ import { resolvePaths } from '../lib/pathResolve'
6
+ import { areSettingsAvailable } from '../lib/LiftConfig'
7
+
8
+ export async function doDoctor (): Promise<boolean> {
9
+ console.log(ac.blue.bold('Lift doctor'))
10
+
11
+ const liftVersion = getLiftVersion()?.toString() ?? ''
12
+ const projectVersion = getProjectVersion()?.toString() ?? ''
13
+ const projectName = getProjectName() ?? ''
14
+ const typescriptVersion = await fetchTypescriptVersion() ?? ''
15
+ const nodeVersion = await fetchNodeVersion() ?? ''
16
+ const npmVersion = await fetchNpmVersion() ?? ''
17
+ const gitVersion = await fetchGitVersion() ?? ''
18
+ const settingsAvail = areSettingsAvailable()
19
+
20
+ console.log('Checking installed dependencies:')
21
+ let ok = report('MistLift', liftVersion, '0.1.0')
22
+ ok = ok && report('Typescript', typescriptVersion, '5.3.3')
23
+ ok = ok && report('Node', nodeVersion, '20.11.0')
24
+ const isWin:boolean = process.platform === 'win32'
25
+ ok = ok && report('Npm', npmVersion, isWin ? '9.6.4' : '10.3.0')
26
+ report('Git', gitVersion, '2.0.0')
27
+ if (!settingsAvail) {
28
+ console.log('')
29
+ console.log(ac.yellow.dim.bold('Cloud Settings are not set. ') + ac.blue('run ' + ac.bold('lift settings')))
30
+ }
31
+ if (!ok) {
32
+ console.log('')
33
+ console.log(ac.red.bold('System needs updates before MistLift can be used.'))
34
+ } else {
35
+ console.log('')
36
+ console.log(ac.green.bold('Ready for MistLift'))
37
+ console.log('')
38
+ if (resolvePaths().verified) {
39
+ console.log(ac.blue.italic('Current project ' + projectName + ' ' + projectVersion))
40
+ }
41
+ }
42
+ return ok
43
+ }
44
+
45
+ function versionTrim (vstr: string): string {
46
+ vstr = vstr.trim()
47
+ let i = -1
48
+ while (++i < vstr.length) {
49
+ const c = vstr.charAt(i)
50
+ if (c >= '0' && c <= '9') break
51
+ }
52
+ return vstr.substring(i)
53
+ }
54
+
55
+ async function fetchTypescriptVersion (
56
+
57
+ ): Promise<string> {
58
+ const result = await executeCommand('tsc', ['-v'])
59
+ if (result.retcode !== 0) return 'Typescript not found'
60
+ const vstr = versionTrim(result.stdStr)
61
+ return vstr
62
+ }
63
+
64
+ async function fetchNodeVersion (
65
+
66
+ ): Promise<string> {
67
+ const result = await executeCommand('node', ['-v'])
68
+ if (result.retcode !== 0) return 'Node not found'
69
+ const vstr = versionTrim(result.stdStr)
70
+ return vstr
71
+ }
72
+
73
+ async function fetchNpmVersion (
74
+
75
+ ): Promise<string> {
76
+ const result = await executeCommand('npm', ['-v'])
77
+ if (result.retcode !== 0) return 'npm not found'
78
+ const vstr = versionTrim(result.stdStr)
79
+ return vstr
80
+ }
81
+
82
+ async function fetchGitVersion (
83
+
84
+ ): Promise<string> {
85
+ const result = await executeCommand('git', ['-v'])
86
+ if (result.retcode !== 0) return 'Git not found'
87
+ const vstr = versionTrim(result.stdStr)
88
+ return vstr
89
+ }
90
+
91
+ // compare to a minimum and report ok or error
92
+
93
+ function report (
94
+ name: string,
95
+ version: string,
96
+ minStr: string
97
+ ): boolean {
98
+ const ver = new VersionInfo(version)
99
+ const minVer = new VersionInfo(minStr)
100
+ const ok = (ver.isGreaterThan(minVer) || ver.equals(minVer))
101
+ if (ok) {
102
+ console.log(ac.green.bold('√ ') + ac.black.bold(name) + ' ' + ac.grey(version))
103
+ } else {
104
+ console.log(ac.red.bold('X ') + ac.black.bold(name) + ac.red.bold(' does not meet minimum version of ') + ac.blue(minStr))
105
+ }
106
+ return ok
107
+ }
@@ -1,178 +1,178 @@
1
- import * as ac from 'ansi-colors'
2
-
3
- export function doHelp (
4
- command: string
5
- ): void {
6
- switch (command) {
7
- case 'help':
8
- return helpHelp()
9
- case 'init':
10
- return helpInit()
11
- case 'create':
12
- return helpCreate()
13
- case 'build':
14
- return helpBuild()
15
- case 'test':
16
- return helpTest()
17
- case 'start':
18
- return helpStart()
19
- // case 'stop':
20
- // return helpStop()
21
- case 'package':
22
- return helpPackage()
23
- case 'deploy':
24
- return helpDeploy()
25
- case 'publish':
26
- return helpPublish()
27
- case 'settings':
28
- return helpSettings()
29
- case 'doctor':
30
- return helpDoctor()
31
- case 'info':
32
- return helpInfo()
33
- default:
34
- return helpDefault()
35
- }
36
- }
37
- function helpDefault (): void {
38
- console.log('lift is the command-line tool of the MistLift framework.')
39
- console.log('')
40
- console.log(ac.bold('Usage: ' + ac.grey('lift ' + ac.grey.dim('command [args]'))))
41
- console.log('where ' + ac.grey.dim('command') + ' is one of:')
42
- console.log(' ' + ac.blue.bold('help ' + ac.grey.dim('[command]')) + ' -- this list, or help on a given command')
43
- console.log(' ' + ac.blue.bold('init') + ' -- create or prepare a directory as a MistLift project')
44
- console.log(' ' + ac.blue.bold('create ' + ac.grey.italic('functionName')) + ' -- define and create a new API function')
45
- console.log(' ' + ac.green('build') + ' -- build the project')
46
- console.log(' ' + ac.green('test') + ' -- build, and run unit tests')
47
- console.log(' ' + ac.cyan.bold('start') + ' -- start the local express server')
48
- // console.log(" " + ac.cyan.bold("stop") + " -- stop the local express server");
49
- console.log(' ' + ac.green('package ' + ac.grey.italic('[functionName]')) + ' -- builds and packages functions into lambda-ready zips')
50
- console.log(' ' + ac.green('deploy ' + ac.grey.italic('[functionName]')) + ' -- builds, packages, and deploys function packages to AWS lambda')
51
- console.log(' ' + ac.blue.bold('publish') + ' -- publishes the API and binds to the deployed functions')
52
- console.log(' ' + ac.blue.bold('settings') + ' -- sets up cloud settings')
53
- console.log(' ' + ac.blue.bold('doctor') + ' -- checks MistLift installation and status')
54
- console.log(' ' + ac.blue.bold('info') + ' -- reports latest published API Url info')
55
- console.log('')
56
- console.log('use ' + ac.bold('lift help ' + ac.grey.dim('[command]')) + ' for command arguments and detals.')
57
- console.log(ac.italic('use ' + ac.bold('lift version ' + ac.grey.dim('or lift -v or lift --version') + ac.grey(' to see current running version of MistLift'))))
58
- }
59
- function printBanner (cmd: string): void {
60
- let out = ' ' + ac.green('╭───────────────────────────────────────────────────────────────╮') + '\n'
61
- out += ' ' + ac.green('| |') + '\n'
62
- out += ' ' + ac.green('| Lift |') + '\n'
63
- out += ' ' + ac.green('| |') + '\n'
64
- out += ' ' + ac.green('╰───────────────────────────────────────────────────────────────╯') + '\n'
65
- out += ' ' + ac.bold.green(cmd)
66
- out += '\n'
67
- console.log(out)
68
- }
69
- function helpHelp (): void {
70
- printBanner('help')
71
- console.log('use ' + ac.bold('lift help') + ' by itself to see a list of commands')
72
- console.log('use ' + ac.bold('lift help ' + ac.grey.dim('[command]')) + ' for help on a given command')
73
- console.log('')
74
- }
75
- export function helpInit (): void {
76
- printBanner('init')
77
- console.log('use ' + ac.bold('lift init .') + ' from within a directory to init the current directory as a MistLift project')
78
- console.log('use ' + ac.bold('lift init ' + ac.grey.dim('projectPath')) + ' to create a new directory at ' +
79
- ac.grey.dim('projectPath') + ' if it does not exist and init a MistLift project in that directory, if not already initialized')
80
- console.log('')
81
- console.log('This will begin an interactive session where you will be asked questions about the project you are creating.')
82
- console.log('The project will be complete and ready to run right away.')
83
- console.log('You can then modify the application to your needs.')
84
- }
85
-
86
- export function helpCreate (): void {
87
- printBanner('create')
88
- console.log('use ' + ac.bold('lift create') + ac.grey.dim(' functionName') + ' to create a new function for your API')
89
- console.log('')
90
- console.log('your project folder (set up with ' + ac.green.bold('init') + ') will have a new function template created as ' +
91
- ac.grey.dim('functionName') +
92
- ' in a folder named ' +
93
- ac.green.dim('functions') + ' within your project directory')
94
- console.log('')
95
- console.log(ac.grey("The default function will display a'Hello World!' message when built and run"))
96
- console.log(ac.grey('Modify the code to suit the needs of your function application'))
97
- }
98
- export function helpBuild (): void {
99
- printBanner('build')
100
- console.log('use ' + ac.bold('lift build') + ' to build all your functions of the project')
101
- console.log('use ' + ac.bold('lift build') + ' one or more function names to build these individually')
102
- console.log('')
103
- console.log('include ' + ac.bold('--clean') + ' to force a rebuild, bypassing file date compare')
104
- console.log('include ' + ac.bold('--failfast') + ' to stop after encountering an error')
105
- console.log('include ' + ac.bold('--deferfail') + ' to build all, then report any errors (the default)')
106
- console.log('')
107
- console.log("The build step compiles your typescript (.ts) files into executable javascript (.js) files within a folder named 'build' in your project directory.")
108
- console.log('Files that are not updated are not rebuilt.')
109
- console.log('The build step is automatically invoked by other actions that depend upon it as a prerequisite, so it does not need to be explicitly run in normal operation.')
110
- console.log('')
111
- }
112
- export function helpTest (): void {
113
- printBanner('test')
114
- console.log('use ' + ac.bold('lift test') + ' to invoke the testing framework and run unit tests for all functions')
115
- console.log('')
116
- console.log('Tests should be written in files within the named test folder for each created function. test files are given the suffix .test.ts')
117
- console.log("The test framework used is 'Tap' (https://node-tap.org)")
118
- console.log('')
119
- }
120
- export function helpStart (): void {
121
- printBanner('start')
122
- console.log('use ' + ac.bold('lift start') + " to start running the local 'Express' server for local execution")
123
- console.log('')
124
- console.log('Functions may be run and tested via a local http server powered by express.')
125
- console.log('By default, access is at ' + ac.blue('http://localhost:8081'))
126
- console.log('')
127
- }
128
- export function helpStop (): void {
129
- printBanner('stop')
130
- console.log('use ' + ac.bold('lift stop') + " to stop the running local 'Express' server")
131
- console.log('')
132
- console.log('This will shut down the local server')
133
- console.log('')
134
- }
135
- export function helpPackage (): void {
136
- printBanner('package')
137
- console.log('use ' + ac.bold('lift package') + ' to build and package functions for cloud deployment')
138
- console.log('')
139
- console.log('options such as ' + ac.bold('--clean') + ' may be specified to force a build prior to packaging')
140
- console.log('')
141
- console.log('Functions must be packaged into zip files before delivery to the cloud')
142
- console.log('The package command handles this by first insuring a fresh build and then packaging the function and its module dependencies')
143
- console.log(ac.grey('This action is invoked as part of deployment, and need not be invoked separately with this command'))
144
- console.log('')
145
- }
146
- export function helpDeploy (): void {
147
- printBanner('deploy')
148
- console.log('use ' + ac.bold('lift deploy') + ac.grey.dim(' functionName') + ' to package and deploy a function to the cloud')
149
- console.log('use ' + ac.bold('lift deploy') + ' with no argument to deploy all functions to the cloud')
150
- console.log('')
151
- console.log('options such as ' + ac.bold('--clean') + ' may be specified to force a build prior to packaging')
152
- console.log('the option ' + ac.bold('--no-package') + ' may be specified to deploy without repackaging')
153
- console.log('')
154
- console.log('functions will be built and packaged if necessary before deployment')
155
- }
156
- export function helpPublish (): void {
157
- printBanner('publish')
158
- console.log('use ' + ac.bold('lift publish') + ' to publish the API to an accessible cloud endpoint')
159
- console.log('')
160
- console.log('The base url for the cloud API will be returned by this operation.')
161
- console.log('')
162
- console.log('Once published, updates to functions may be made with ' + ac.bold('deploy') + ' without needing to republish.')
163
- console.log('Changes to webroot content or api definitions will require a new publish')
164
- console.log('Each publish operation returns a new URL. The previous URL is invalid.')
165
- }
166
- export function helpSettings (): void {
167
- printBanner('settings')
168
- console.log('use ' + ac.bold('lift settings') + ' to set or review the Cloud settings and configured options')
169
- }
170
- export function helpDoctor (): void {
171
- printBanner('doctor')
172
- console.log('use ' + ac.bold('lift doctor') + ' to report the status of your MistLift installation and dependencies')
173
- }
174
-
175
- export function helpInfo (): void {
176
- printBanner('info')
177
- console.log('use ' + ac.bold('lift info') + ' to report the last published url and the time of its publishing along with the associated deployed functions')
178
- }
1
+ import * as ac from 'ansi-colors'
2
+
3
+ export function doHelp (
4
+ command: string
5
+ ): void {
6
+ switch (command) {
7
+ case 'help':
8
+ return helpHelp()
9
+ case 'init':
10
+ return helpInit()
11
+ case 'create':
12
+ return helpCreate()
13
+ case 'build':
14
+ return helpBuild()
15
+ case 'test':
16
+ return helpTest()
17
+ case 'start':
18
+ return helpStart()
19
+ // case 'stop':
20
+ // return helpStop()
21
+ case 'package':
22
+ return helpPackage()
23
+ case 'deploy':
24
+ return helpDeploy()
25
+ case 'publish':
26
+ return helpPublish()
27
+ case 'settings':
28
+ return helpSettings()
29
+ case 'doctor':
30
+ return helpDoctor()
31
+ case 'info':
32
+ return helpInfo()
33
+ default:
34
+ return helpDefault()
35
+ }
36
+ }
37
+ function helpDefault (): void {
38
+ console.log('lift is the command-line tool of the MistLift framework.')
39
+ console.log('')
40
+ console.log(ac.bold('Usage: ' + ac.grey('lift ' + ac.grey.dim('command [args]'))))
41
+ console.log('where ' + ac.grey.dim('command') + ' is one of:')
42
+ console.log(' ' + ac.blue.bold('help ' + ac.grey.dim('[command]')) + ' -- this list, or help on a given command')
43
+ console.log(' ' + ac.blue.bold('init') + ' -- create or prepare a directory as a MistLift project')
44
+ console.log(' ' + ac.blue.bold('create ' + ac.grey.italic('functionName')) + ' -- define and create a new API function')
45
+ console.log(' ' + ac.green('build') + ' -- build the project')
46
+ console.log(' ' + ac.green('test') + ' -- build, and run unit tests')
47
+ console.log(' ' + ac.cyan.bold('start') + ' -- start the local express server')
48
+ // console.log(" " + ac.cyan.bold("stop") + " -- stop the local express server");
49
+ console.log(' ' + ac.green('package ' + ac.grey.italic('[functionName]')) + ' -- builds and packages functions into lambda-ready zips')
50
+ console.log(' ' + ac.green('deploy ' + ac.grey.italic('[functionName]')) + ' -- builds, packages, and deploys function packages to AWS lambda')
51
+ console.log(' ' + ac.blue.bold('publish') + ' -- publishes the API and binds to the deployed functions')
52
+ console.log(' ' + ac.blue.bold('settings') + ' -- sets up cloud settings')
53
+ console.log(' ' + ac.blue.bold('doctor') + ' -- checks MistLift installation and status')
54
+ console.log(' ' + ac.blue.bold('info') + ' -- reports latest published API Url info')
55
+ console.log('')
56
+ console.log('use ' + ac.bold('lift help ' + ac.grey.dim('[command]')) + ' for command arguments and detals.')
57
+ console.log(ac.italic('use ' + ac.bold('lift version ' + ac.grey.dim('or lift -v or lift --version') + ac.grey(' to see current running version of MistLift'))))
58
+ }
59
+ function printBanner (cmd: string): void {
60
+ let out = ' ' + ac.green('╭───────────────────────────────────────────────────────────────╮') + '\n'
61
+ out += ' ' + ac.green('| |') + '\n'
62
+ out += ' ' + ac.green('| Lift |') + '\n'
63
+ out += ' ' + ac.green('| |') + '\n'
64
+ out += ' ' + ac.green('╰───────────────────────────────────────────────────────────────╯') + '\n'
65
+ out += ' ' + ac.bold.green(cmd)
66
+ out += '\n'
67
+ console.log(out)
68
+ }
69
+ function helpHelp (): void {
70
+ printBanner('help')
71
+ console.log('use ' + ac.bold('lift help') + ' by itself to see a list of commands')
72
+ console.log('use ' + ac.bold('lift help ' + ac.grey.dim('[command]')) + ' for help on a given command')
73
+ console.log('')
74
+ }
75
+ export function helpInit (): void {
76
+ printBanner('init')
77
+ console.log('use ' + ac.bold('lift init .') + ' from within a directory to init the current directory as a MistLift project')
78
+ console.log('use ' + ac.bold('lift init ' + ac.grey.dim('projectPath')) + ' to create a new directory at ' +
79
+ ac.grey.dim('projectPath') + ' if it does not exist and init a MistLift project in that directory, if not already initialized')
80
+ console.log('')
81
+ console.log('This will begin an interactive session where you will be asked questions about the project you are creating.')
82
+ console.log('The project will be complete and ready to run right away.')
83
+ console.log('You can then modify the application to your needs.')
84
+ }
85
+
86
+ export function helpCreate (): void {
87
+ printBanner('create')
88
+ console.log('use ' + ac.bold('lift create') + ac.grey.dim(' functionName') + ' to create a new function for your API')
89
+ console.log('')
90
+ console.log('your project folder (set up with ' + ac.green.bold('init') + ') will have a new function template created as ' +
91
+ ac.grey.dim('functionName') +
92
+ ' in a folder named ' +
93
+ ac.green.dim('functions') + ' within your project directory')
94
+ console.log('')
95
+ console.log(ac.grey("The default function will display a'Hello World!' message when built and run"))
96
+ console.log(ac.grey('Modify the code to suit the needs of your function application'))
97
+ }
98
+ export function helpBuild (): void {
99
+ printBanner('build')
100
+ console.log('use ' + ac.bold('lift build') + ' to build all your functions of the project')
101
+ console.log('use ' + ac.bold('lift build') + ' one or more function names to build these individually')
102
+ console.log('')
103
+ console.log('include ' + ac.bold('--clean') + ' to force a rebuild, bypassing file date compare')
104
+ console.log('include ' + ac.bold('--failfast') + ' to stop after encountering an error')
105
+ console.log('include ' + ac.bold('--deferfail') + ' to build all, then report any errors (the default)')
106
+ console.log('')
107
+ console.log("The build step compiles your typescript (.ts) files into executable javascript (.js) files within a folder named 'build' in your project directory.")
108
+ console.log('Files that are not updated are not rebuilt.')
109
+ console.log('The build step is automatically invoked by other actions that depend upon it as a prerequisite, so it does not need to be explicitly run in normal operation.')
110
+ console.log('')
111
+ }
112
+ export function helpTest (): void {
113
+ printBanner('test')
114
+ console.log('use ' + ac.bold('lift test') + ' to invoke the testing framework and run unit tests for all functions')
115
+ console.log('')
116
+ console.log('Tests should be written in files within the named test folder for each created function. test files are given the suffix .test.ts')
117
+ console.log("The test framework used is 'Tap' (https://node-tap.org)")
118
+ console.log('')
119
+ }
120
+ export function helpStart (): void {
121
+ printBanner('start')
122
+ console.log('use ' + ac.bold('lift start') + " to start running the local 'Express' server for local execution")
123
+ console.log('')
124
+ console.log('Functions may be run and tested via a local http server powered by express.')
125
+ console.log('By default, access is at ' + ac.blue('http://localhost:8081'))
126
+ console.log('')
127
+ }
128
+ export function helpStop (): void {
129
+ printBanner('stop')
130
+ console.log('use ' + ac.bold('lift stop') + " to stop the running local 'Express' server")
131
+ console.log('')
132
+ console.log('This will shut down the local server')
133
+ console.log('')
134
+ }
135
+ export function helpPackage (): void {
136
+ printBanner('package')
137
+ console.log('use ' + ac.bold('lift package') + ' to build and package functions for cloud deployment')
138
+ console.log('')
139
+ console.log('options such as ' + ac.bold('--clean') + ' may be specified to force a build prior to packaging')
140
+ console.log('')
141
+ console.log('Functions must be packaged into zip files before delivery to the cloud')
142
+ console.log('The package command handles this by first insuring a fresh build and then packaging the function and its module dependencies')
143
+ console.log(ac.grey('This action is invoked as part of deployment, and need not be invoked separately with this command'))
144
+ console.log('')
145
+ }
146
+ export function helpDeploy (): void {
147
+ printBanner('deploy')
148
+ console.log('use ' + ac.bold('lift deploy') + ac.grey.dim(' functionName') + ' to package and deploy a function to the cloud')
149
+ console.log('use ' + ac.bold('lift deploy') + ' with no argument to deploy all functions to the cloud')
150
+ console.log('')
151
+ console.log('options such as ' + ac.bold('--clean') + ' may be specified to force a build prior to packaging')
152
+ console.log('the option ' + ac.bold('--no-package') + ' may be specified to deploy without repackaging')
153
+ console.log('')
154
+ console.log('functions will be built and packaged if necessary before deployment')
155
+ }
156
+ export function helpPublish (): void {
157
+ printBanner('publish')
158
+ console.log('use ' + ac.bold('lift publish') + ' to publish the API to an accessible cloud endpoint')
159
+ console.log('')
160
+ console.log('The base url for the cloud API will be returned by this operation.')
161
+ console.log('')
162
+ console.log('Once published, updates to functions may be made with ' + ac.bold('deploy') + ' without needing to republish.')
163
+ console.log('Changes to webroot content or api definitions will require a new publish')
164
+ console.log('Each publish operation returns a new URL. The previous URL is invalid.')
165
+ }
166
+ export function helpSettings (): void {
167
+ printBanner('settings')
168
+ console.log('use ' + ac.bold('lift settings') + ' to set or review the Cloud settings and configured options')
169
+ }
170
+ export function helpDoctor (): void {
171
+ printBanner('doctor')
172
+ console.log('use ' + ac.bold('lift doctor') + ' to report the status of your MistLift installation and dependencies')
173
+ }
174
+
175
+ export function helpInfo (): void {
176
+ printBanner('info')
177
+ console.log('use ' + ac.bold('lift info') + ' to report the last published url and the time of its publishing along with the associated deployed functions')
178
+ }