@tremho/mist-lift 1.1.4 → 1.1.6-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 +70 -66
  3. package/build/commands/actions/initQuestions.js.map +1 -0
  4. package/build/commands/actions/makePackageJson.js.map +1 -0
  5. package/build/commands/actions/setupPackageJson.js.map +1 -0
  6. package/build/commands/build.js.map +1 -0
  7. package/build/{src/commands → commands}/builtin/ApiDocMaker.js +0 -1
  8. package/build/commands/builtin/ApiDocMaker.js.map +1 -0
  9. package/build/commands/builtin/BuiltInHandler.js.map +1 -0
  10. package/build/commands/builtin/DeployBuiltInZip.js.map +1 -0
  11. package/build/commands/builtin/StageWebrootZip.js.map +1 -0
  12. package/build/commands/create.js.map +1 -0
  13. package/build/commands/deploy.js.map +1 -0
  14. package/build/{src/commands → commands}/doctor.js +12 -1
  15. package/build/commands/doctor.js.map +1 -0
  16. package/build/commands/help.js.map +1 -0
  17. package/build/commands/info.js.map +1 -0
  18. package/build/{src/commands → commands}/init.js +1 -2
  19. package/build/commands/init.js.map +1 -0
  20. package/build/commands/package.js.map +1 -0
  21. package/build/commands/publish.js.map +1 -0
  22. package/build/commands/settings.js.map +1 -0
  23. package/build/commands/start.js.map +1 -0
  24. package/build/commands/test.js.map +1 -0
  25. package/build/commands/user.js.map +1 -0
  26. package/build/expressRoutes/all.js.map +1 -0
  27. package/build/expressRoutes/api.js.map +1 -0
  28. package/build/expressRoutes/functionBinder.js.map +1 -0
  29. package/build/integration-tests/quickstart-scenario.test.js.map +1 -0
  30. package/build/lib/CaseUtils.js.map +1 -0
  31. package/build/lib/DirectoryUtils.js.map +1 -0
  32. package/build/lib/LiftConfig.js.map +1 -0
  33. package/build/{src/lib → lib}/LiftVersion.js +1 -1
  34. package/build/lib/LiftVersion.js.map +1 -0
  35. package/build/lib/Tests/fileCompare.test.js.map +1 -0
  36. package/build/lib/askQuestion.js.map +1 -0
  37. package/build/lib/executeCommand.js.map +1 -0
  38. package/build/lib/fileCompare.js.map +1 -0
  39. package/build/lib/openAPI/ApiBuildCollector.js.map +1 -0
  40. package/build/lib/openAPI/WebrootFileSupport.js.map +1 -0
  41. package/build/lib/openAPI/openApiConstruction.js.map +1 -0
  42. package/build/lib/pathResolve.js.map +1 -0
  43. package/build/lib/utils.js.map +1 -0
  44. package/build/{src/lift.js → lift.js} +0 -0
  45. package/build/lift.js.map +1 -0
  46. package/package.json +78 -79
  47. package/src/commands/actions/initQuestions.ts +133 -133
  48. package/src/commands/actions/setupPackageJson.ts +32 -32
  49. package/src/commands/build.ts +173 -173
  50. package/src/commands/builtin/ApiDocMaker.ts +105 -106
  51. package/src/commands/builtin/BuiltInHandler.ts +47 -47
  52. package/src/commands/builtin/DeployBuiltInZip.ts +25 -25
  53. package/src/commands/builtin/StageWebrootZip.ts +36 -36
  54. package/src/commands/create.ts +52 -52
  55. package/src/commands/deploy.ts +161 -161
  56. package/src/commands/doctor.ts +118 -107
  57. package/src/commands/help.ts +178 -178
  58. package/src/commands/info.ts +42 -42
  59. package/src/commands/init.ts +60 -61
  60. package/src/commands/package.ts +234 -234
  61. package/src/commands/publish.ts +330 -330
  62. package/src/commands/settings.ts +73 -73
  63. package/src/commands/start.ts +43 -43
  64. package/src/commands/test.ts +37 -37
  65. package/src/commands/user.ts +20 -20
  66. package/src/expressRoutes/all.ts +99 -99
  67. package/src/expressRoutes/api.ts +22 -22
  68. package/src/expressRoutes/functionBinder.ts +155 -155
  69. package/src/integration-tests/quickstart-scenario.test.ts +76 -76
  70. package/src/lib/CaseUtils.ts +63 -63
  71. package/src/lib/DirectoryUtils.ts +34 -34
  72. package/src/lib/LiftConfig.ts +74 -74
  73. package/src/lib/LiftVersion.ts +87 -87
  74. package/src/lib/Tests/fileCompare.test.ts +35 -35
  75. package/src/lib/askQuestion.ts +17 -17
  76. package/src/lib/executeCommand.ts +45 -45
  77. package/src/lib/fileCompare.ts +55 -55
  78. package/src/lib/openAPI/ApiBuildCollector.ts +47 -47
  79. package/src/lib/openAPI/WebrootFileSupport.ts +19 -19
  80. package/src/lib/openAPI/openApiConstruction.ts +196 -196
  81. package/src/lib/pathResolve.ts +26 -26
  82. package/src/lib/utils.ts +43 -43
  83. package/src/lift.ts +87 -87
  84. package/templateData/function-definition-template +20 -20
  85. package/templateData/function-local-ts +16 -16
  86. package/templateData/function-main-ts +16 -16
  87. package/templateData/function-runmain-mjs +6 -6
  88. package/templateData/function-test-template +11 -11
  89. package/templateData/swagger-ui-bundle.js +2 -2
  90. package/templateData/swagger-ui-standalone-preset.js +2 -2
  91. package/templateData/swagger-ui.css +2 -2
  92. package/tsconfig.json +28 -28
  93. package/build/QSTest/functions/IntegrationTest/integrationTest-tests/Sanity.test.js +0 -14
  94. package/build/QSTest/functions/IntegrationTest/integrationTest-tests/Sanity.test.js.map +0 -1
  95. package/build/QSTest/functions/IntegrationTest/src/local.js +0 -33
  96. package/build/QSTest/functions/IntegrationTest/src/local.js.map +0 -1
  97. package/build/QSTest/functions/IntegrationTest/src/main.js +0 -29
  98. package/build/QSTest/functions/IntegrationTest/src/main.js.map +0 -1
  99. package/build/src/commands/actions/initQuestions.js.map +0 -1
  100. package/build/src/commands/actions/makePackageJson.js.map +0 -1
  101. package/build/src/commands/actions/setupPackageJson.js.map +0 -1
  102. package/build/src/commands/build.js.map +0 -1
  103. package/build/src/commands/builtin/ApiDocMaker.js.map +0 -1
  104. package/build/src/commands/builtin/BuiltInHandler.js.map +0 -1
  105. package/build/src/commands/builtin/DeployBuiltInZip.js.map +0 -1
  106. package/build/src/commands/builtin/StageWebrootZip.js.map +0 -1
  107. package/build/src/commands/create.js.map +0 -1
  108. package/build/src/commands/deploy.js.map +0 -1
  109. package/build/src/commands/doctor.js.map +0 -1
  110. package/build/src/commands/help.js.map +0 -1
  111. package/build/src/commands/info.js.map +0 -1
  112. package/build/src/commands/init.js.map +0 -1
  113. package/build/src/commands/package.js.map +0 -1
  114. package/build/src/commands/publish.js.map +0 -1
  115. package/build/src/commands/settings.js.map +0 -1
  116. package/build/src/commands/start.js.map +0 -1
  117. package/build/src/commands/test.js.map +0 -1
  118. package/build/src/commands/user.js.map +0 -1
  119. package/build/src/expressRoutes/all.js.map +0 -1
  120. package/build/src/expressRoutes/api.js.map +0 -1
  121. package/build/src/expressRoutes/functionBinder.js.map +0 -1
  122. package/build/src/integration-tests/quickstart-scenario.test.js.map +0 -1
  123. package/build/src/lib/CaseUtils.js.map +0 -1
  124. package/build/src/lib/DirectoryUtils.js.map +0 -1
  125. package/build/src/lib/LiftConfig.js.map +0 -1
  126. package/build/src/lib/LiftVersion.js.map +0 -1
  127. package/build/src/lib/Tests/fileCompare.test.js.map +0 -1
  128. package/build/src/lib/askQuestion.js.map +0 -1
  129. package/build/src/lib/executeCommand.js.map +0 -1
  130. package/build/src/lib/fileCompare.js.map +0 -1
  131. package/build/src/lib/openAPI/ApiBuildCollector.js.map +0 -1
  132. package/build/src/lib/openAPI/WebrootFileSupport.js.map +0 -1
  133. package/build/src/lib/openAPI/openApiConstruction.js.map +0 -1
  134. package/build/src/lib/pathResolve.js.map +0 -1
  135. package/build/src/lib/utils.js.map +0 -1
  136. package/build/src/lift.js.map +0 -1
  137. /package/build/{src/commands → commands}/actions/initQuestions.js +0 -0
  138. /package/build/{src/commands → commands}/actions/makePackageJson.js +0 -0
  139. /package/build/{src/commands → commands}/actions/setupPackageJson.js +0 -0
  140. /package/build/{src/commands → commands}/build.js +0 -0
  141. /package/build/{src/commands → commands}/builtin/BuiltInHandler.js +0 -0
  142. /package/build/{src/commands → commands}/builtin/DeployBuiltInZip.js +0 -0
  143. /package/build/{src/commands → commands}/builtin/StageWebrootZip.js +0 -0
  144. /package/build/{src/commands → commands}/create.js +0 -0
  145. /package/build/{src/commands → commands}/deploy.js +0 -0
  146. /package/build/{src/commands → commands}/help.js +0 -0
  147. /package/build/{src/commands → commands}/info.js +0 -0
  148. /package/build/{src/commands → commands}/package.js +0 -0
  149. /package/build/{src/commands → commands}/publish.js +0 -0
  150. /package/build/{src/commands → commands}/settings.js +0 -0
  151. /package/build/{src/commands → commands}/start.js +0 -0
  152. /package/build/{src/commands → commands}/test.js +0 -0
  153. /package/build/{src/commands → commands}/user.js +0 -0
  154. /package/build/{src/expressRoutes → expressRoutes}/all.js +0 -0
  155. /package/build/{src/expressRoutes → expressRoutes}/api.js +0 -0
  156. /package/build/{src/expressRoutes → expressRoutes}/functionBinder.js +0 -0
  157. /package/build/{src/integration-tests → integration-tests}/quickstart-scenario.test.js +0 -0
  158. /package/build/{src/lib → lib}/CaseUtils.js +0 -0
  159. /package/build/{src/lib → lib}/DirectoryUtils.js +0 -0
  160. /package/build/{src/lib → lib}/LiftConfig.js +0 -0
  161. /package/build/{src/lib → lib}/Tests/fileCompare.test.js +0 -0
  162. /package/build/{src/lib → lib}/askQuestion.js +0 -0
  163. /package/build/{src/lib → lib}/executeCommand.js +0 -0
  164. /package/build/{src/lib → lib}/fileCompare.js +0 -0
  165. /package/build/{src/lib → lib}/openAPI/ApiBuildCollector.js +0 -0
  166. /package/build/{src/lib → lib}/openAPI/WebrootFileSupport.js +0 -0
  167. /package/build/{src/lib → lib}/openAPI/openApiConstruction.js +0 -0
  168. /package/build/{src/lib → lib}/pathResolve.js +0 -0
  169. /package/build/{src/lib → lib}/utils.js +0 -0
@@ -1,173 +1,173 @@
1
- /** handles building in the project directory */
2
-
3
- import * as path from 'path'
4
- import * as fs from 'fs'
5
- import * as ac from 'ansi-colors'
6
- import { resolvePaths } from '../lib/pathResolve'
7
- import { recurseDirectory } from '../lib/DirectoryUtils'
8
- import { isNewer } from '../lib/fileCompare'
9
- import { executeCommand } from '../lib/executeCommand'
10
- import { mkdirSync } from 'fs'
11
-
12
- let projectPaths:any = {}
13
-
14
- // Build command
15
- export async function doBuildAsync (
16
- args: string[] // zero or more functions to build. zero means build all
17
- ): Promise<number> {
18
- projectPaths = resolvePaths();
19
- if (!projectPaths.verified) {
20
- console.log(ac.bold.magenta('current directory is not at project root'))
21
- return -1
22
- }
23
- const funcsToBuild: string[] = []
24
- const options: string[] = []
25
- for (const arg of args) {
26
- if (arg.charAt(0) === '-') {
27
- options.push(arg.toLowerCase())
28
- } else funcsToBuild.push(arg)
29
- }
30
-
31
- if (funcsToBuild.length === 0) {
32
- let firstDepth = 0
33
- recurseDirectory(projectPaths.functionPath, (filepath, stats) => {
34
- const depth = filepath.split(path.sep).length
35
- if (firstDepth === 0) firstDepth = depth
36
- if (stats.isDirectory() && depth === firstDepth) {
37
- funcsToBuild.push(path.basename(filepath))
38
- }
39
- return false
40
- })
41
- }
42
-
43
- let failFast = options.includes('--failfast')
44
- if (options.includes('--deferfail')) failFast = false
45
-
46
- let fails = 0
47
-
48
- for (const func of funcsToBuild) {
49
- const funcDir = path.join(projectPaths.functionPath, func)
50
- if (fs.existsSync(funcDir)) {
51
- fails += await buildSingleFunction(funcDir, options)
52
- if (fails > 0 && failFast) break
53
- } else {
54
- console.log(ac.red.bold(`${func} does not exist as a function`))
55
- fails++
56
- if (failFast) break
57
- }
58
- }
59
- return fails
60
- }
61
-
62
- // build command for a single function
63
- async function buildSingleFunction (
64
- funcDir: string,
65
- options: string[]
66
- ): Promise<number> {
67
- const funcName = funcDir.substring(funcDir.lastIndexOf(path.sep) + 1)
68
- const buildPath = path.join(projectPaths.basePath, 'build', 'functions', funcName)
69
-
70
- if (options.includes('--clean')) {
71
- if (fs.existsSync(buildPath)) {
72
- fs.rmSync(buildPath, { recursive: true })
73
- }
74
- }
75
- // strategy here is to invoke tsc on a per-folder basis rather than letting tsc do the recurse because it is easier to control this way
76
- return await buildFunctionModules(funcName, funcDir, buildPath, options)
77
- }
78
-
79
- // build all the function modules in path
80
- async function buildFunctionModules (
81
- funcName: string,
82
- funcDir: string,
83
- buildPath: string,
84
- options: string[]
85
- ): Promise<number> {
86
- const announce = ac.blue.dim(`building ${funcName}...`)
87
- let announced = false
88
- let fails = 0
89
- // let builds = 0
90
- let failFast = options.includes('--failfast')
91
- if (options.includes('--deferfail')) failFast = false
92
- const all: Array<Promise<void>> = []
93
- recurseDirectory(funcDir, (filepath, stats) => {
94
- if (path.extname(filepath) === '.ts') {
95
- let relPath = filepath.substring(funcDir.length)
96
- relPath = relPath.substring(0, relPath.lastIndexOf(path.sep))
97
- const outDir = path.join(buildPath, relPath)
98
-
99
- if (!(fails > 0 && failFast)) {
100
- if (isNewer(filepath, outDir)) {
101
- if (!announced) {
102
- announced = true
103
- console.log(announce)
104
- }
105
- // builds++
106
- all.push(executeCommand('tsc', [
107
- '--esModuleInterop', 'true',
108
- '--target', 'ES2015',
109
- '--module', 'commonjs',
110
- '--lib', 'dom,es2015,scripthost,es2015.proxy',
111
- '--strict', 'true',
112
- '--noImplicitAny', 'false',
113
- '--skipLibCheck', 'true',
114
- '--forceConsistentCasingInFileNames', 'true',
115
- '--sourceMap', 'true',
116
- '--outdir', outDir,
117
- filepath
118
- ], '', true).then((result: { retcode: number | undefined, stdOut: string, stdErr: string }) => {
119
- if (result.retcode !== 0) {
120
- fails++
121
- // console.log("error detected", fails)
122
- const now = new Date()
123
- fs.utimesSync(filepath, now, now) // touch file so it is not skipped next build
124
- }
125
- }))
126
- }
127
- }
128
- }
129
- fails += doPostBuildSteps(funcDir, buildPath)
130
- return false
131
- })
132
- return await Promise.all(all).then(async () => {
133
- return fails
134
- })
135
- }
136
-
137
- // do the steps after the build (file copies, etc)
138
- function doPostBuildSteps (
139
- funcDir: string,
140
- buildPath: string
141
- ): number {
142
- // copy the definitions,json file over
143
- const srcdef = path.join(funcDir, 'src', 'definition.json')
144
- const dstdef = path.join(buildPath, 'src', 'definition.json')
145
- if (fs.existsSync(srcdef)) {
146
- const destFolder = path.dirname(dstdef)
147
- if (!fs.existsSync(destFolder)) mkdirSync(destFolder, { recursive: true })
148
- fs.copyFileSync(srcdef, dstdef)
149
- } else {
150
- console.error(ac.red.bold('no definition file found at ' + srcdef))
151
- return 1
152
- }
153
- // copy the resources folder if it exists
154
- const filedirPath = path.join(funcDir, 'resources')
155
- if (fs.existsSync(filedirPath)) {
156
- const bfiles = path.join(buildPath, 'resources')
157
- if (!fs.existsSync(bfiles)) fs.mkdirSync(bfiles, { recursive: true })
158
- recurseDirectory(filedirPath, (filepath, stats) => {
159
- let relPath = filepath.substring(funcDir.length)
160
- relPath = relPath.substring(0, relPath.lastIndexOf(path.sep))
161
- const outDir = path.join(buildPath, relPath)
162
- const target = path.join(outDir, path.basename(filepath))
163
- if (stats.isDirectory() && !fs.existsSync(target)) {
164
- fs.mkdirSync(target, { recursive: true })
165
- }
166
- if (stats.isFile()) {
167
- fs.copyFileSync(filepath, target)
168
- }
169
- return false
170
- })
171
- }
172
- return 0
173
- }
1
+ /** handles building in the project directory */
2
+
3
+ import * as path from 'path'
4
+ import * as fs from 'fs'
5
+ import * as ac from 'ansi-colors'
6
+ import { resolvePaths } from '../lib/pathResolve'
7
+ import { recurseDirectory } from '../lib/DirectoryUtils'
8
+ import { isNewer } from '../lib/fileCompare'
9
+ import { executeCommand } from '../lib/executeCommand'
10
+ import { mkdirSync } from 'fs'
11
+
12
+ let projectPaths:any = {}
13
+
14
+ // Build command
15
+ export async function doBuildAsync (
16
+ args: string[] // zero or more functions to build. zero means build all
17
+ ): Promise<number> {
18
+ projectPaths = resolvePaths();
19
+ if (!projectPaths.verified) {
20
+ console.log(ac.bold.magenta('current directory is not at project root'))
21
+ return -1
22
+ }
23
+ const funcsToBuild: string[] = []
24
+ const options: string[] = []
25
+ for (const arg of args) {
26
+ if (arg.charAt(0) === '-') {
27
+ options.push(arg.toLowerCase())
28
+ } else funcsToBuild.push(arg)
29
+ }
30
+
31
+ if (funcsToBuild.length === 0) {
32
+ let firstDepth = 0
33
+ recurseDirectory(projectPaths.functionPath, (filepath, stats) => {
34
+ const depth = filepath.split(path.sep).length
35
+ if (firstDepth === 0) firstDepth = depth
36
+ if (stats.isDirectory() && depth === firstDepth) {
37
+ funcsToBuild.push(path.basename(filepath))
38
+ }
39
+ return false
40
+ })
41
+ }
42
+
43
+ let failFast = options.includes('--failfast')
44
+ if (options.includes('--deferfail')) failFast = false
45
+
46
+ let fails = 0
47
+
48
+ for (const func of funcsToBuild) {
49
+ const funcDir = path.join(projectPaths.functionPath, func)
50
+ if (fs.existsSync(funcDir)) {
51
+ fails += await buildSingleFunction(funcDir, options)
52
+ if (fails > 0 && failFast) break
53
+ } else {
54
+ console.log(ac.red.bold(`${func} does not exist as a function`))
55
+ fails++
56
+ if (failFast) break
57
+ }
58
+ }
59
+ return fails
60
+ }
61
+
62
+ // build command for a single function
63
+ async function buildSingleFunction (
64
+ funcDir: string,
65
+ options: string[]
66
+ ): Promise<number> {
67
+ const funcName = funcDir.substring(funcDir.lastIndexOf(path.sep) + 1)
68
+ const buildPath = path.join(projectPaths.basePath, 'build', 'functions', funcName)
69
+
70
+ if (options.includes('--clean')) {
71
+ if (fs.existsSync(buildPath)) {
72
+ fs.rmSync(buildPath, { recursive: true })
73
+ }
74
+ }
75
+ // strategy here is to invoke tsc on a per-folder basis rather than letting tsc do the recurse because it is easier to control this way
76
+ return await buildFunctionModules(funcName, funcDir, buildPath, options)
77
+ }
78
+
79
+ // build all the function modules in path
80
+ async function buildFunctionModules (
81
+ funcName: string,
82
+ funcDir: string,
83
+ buildPath: string,
84
+ options: string[]
85
+ ): Promise<number> {
86
+ const announce = ac.blue.dim(`building ${funcName}...`)
87
+ let announced = false
88
+ let fails = 0
89
+ // let builds = 0
90
+ let failFast = options.includes('--failfast')
91
+ if (options.includes('--deferfail')) failFast = false
92
+ const all: Array<Promise<void>> = []
93
+ recurseDirectory(funcDir, (filepath, stats) => {
94
+ if (path.extname(filepath) === '.ts') {
95
+ let relPath = filepath.substring(funcDir.length)
96
+ relPath = relPath.substring(0, relPath.lastIndexOf(path.sep))
97
+ const outDir = path.join(buildPath, relPath)
98
+
99
+ if (!(fails > 0 && failFast)) {
100
+ if (isNewer(filepath, outDir)) {
101
+ if (!announced) {
102
+ announced = true
103
+ console.log(announce)
104
+ }
105
+ // builds++
106
+ all.push(executeCommand('tsc', [
107
+ '--esModuleInterop', 'true',
108
+ '--target', 'ES2015',
109
+ '--module', 'commonjs',
110
+ '--lib', 'dom,es2015,scripthost,es2015.proxy',
111
+ '--strict', 'true',
112
+ '--noImplicitAny', 'false',
113
+ '--skipLibCheck', 'true',
114
+ '--forceConsistentCasingInFileNames', 'true',
115
+ '--sourceMap', 'true',
116
+ '--outdir', outDir,
117
+ filepath
118
+ ], '', true).then((result: { retcode: number | undefined, stdOut: string, stdErr: string }) => {
119
+ if (result.retcode !== 0) {
120
+ fails++
121
+ // console.log("error detected", fails)
122
+ const now = new Date()
123
+ fs.utimesSync(filepath, now, now) // touch file so it is not skipped next build
124
+ }
125
+ }))
126
+ }
127
+ }
128
+ }
129
+ fails += doPostBuildSteps(funcDir, buildPath)
130
+ return false
131
+ })
132
+ return await Promise.all(all).then(async () => {
133
+ return fails
134
+ })
135
+ }
136
+
137
+ // do the steps after the build (file copies, etc)
138
+ function doPostBuildSteps (
139
+ funcDir: string,
140
+ buildPath: string
141
+ ): number {
142
+ // copy the definitions,json file over
143
+ const srcdef = path.join(funcDir, 'src', 'definition.json')
144
+ const dstdef = path.join(buildPath, 'src', 'definition.json')
145
+ if (fs.existsSync(srcdef)) {
146
+ const destFolder = path.dirname(dstdef)
147
+ if (!fs.existsSync(destFolder)) mkdirSync(destFolder, { recursive: true })
148
+ fs.copyFileSync(srcdef, dstdef)
149
+ } else {
150
+ console.error(ac.red.bold('no definition file found at ' + srcdef))
151
+ return 1
152
+ }
153
+ // copy the resources folder if it exists
154
+ const filedirPath = path.join(funcDir, 'resources')
155
+ if (fs.existsSync(filedirPath)) {
156
+ const bfiles = path.join(buildPath, 'resources')
157
+ if (!fs.existsSync(bfiles)) fs.mkdirSync(bfiles, { recursive: true })
158
+ recurseDirectory(filedirPath, (filepath, stats) => {
159
+ let relPath = filepath.substring(funcDir.length)
160
+ relPath = relPath.substring(0, relPath.lastIndexOf(path.sep))
161
+ const outDir = path.join(buildPath, relPath)
162
+ const target = path.join(outDir, path.basename(filepath))
163
+ if (stats.isDirectory() && !fs.existsSync(target)) {
164
+ fs.mkdirSync(target, { recursive: true })
165
+ }
166
+ if (stats.isFile()) {
167
+ fs.copyFileSync(filepath, target)
168
+ }
169
+ return false
170
+ })
171
+ }
172
+ return 0
173
+ }
@@ -1,106 +1,105 @@
1
- import { gatherFunctionDefinitions } from '../../lib/openAPI/ApiBuildCollector'
2
- import { buildOpenApi } from '../../lib/openAPI/openApiConstruction'
3
- import { GetWebrootServePaths } from '../../lib/openAPI/WebrootFileSupport'
4
-
5
- import path from 'path'
6
-
7
- export async function MakePublicApiDoc
8
- (
9
- ): Promise<Uint8Array> {
10
- const defs = gatherFunctionDefinitions()
11
- return await buildOpenApi(defs)
12
- }
13
-
14
- export async function MakeBuiltinApiDoc
15
- (
16
- yamlFile: string
17
-
18
- ): Promise<Uint8Array> {
19
- const defs = gatherFunctionDefinitions()
20
- addBuiltInDefinitions(defs)
21
- return await buildOpenApi(defs, false, yamlFile) //, true)
22
- }
23
-
24
- export function addBuiltInDefinitions (defs: any[]): void {
25
- // console.warn("NOT ADDING ANY BUILTIN API INTEGRATIONS")
26
- // console.log("ADDING apiDef");
27
- defs.push(apiDef)
28
- // console.log("ADDING webrootDef");
29
- defs.push(webrootDef)
30
-
31
- // console.warn("Adding webroot literals");
32
- // do just /docs and see how that goes
33
- const fsdef = Object.assign({}, fileServeDef) // copy
34
- fsdef.name = 'fileserve_docs'
35
- fsdef.pathMap = '/docs/{path}'
36
- defs.push(fsdef)
37
- const roots = GetWebrootServePaths()
38
- // console.log("roots", roots)
39
- for (const root of roots) {
40
- if (root !== '') {
41
- let rootName = root
42
- let rootPath = root.replace(path.sep, '/');
43
- while (rootName.includes(path.sep)) rootName = rootName.replace(path.sep, '').toLowerCase().trim()
44
- console.log("$$$$>> rootPath, rootName", rootPath, rootName)
45
- const fileserve = Object.assign({}, fileServeDef) // copy
46
- fileserve.name = 'fileserve_' + rootName
47
- fileserve.pathMap = `${rootPath}/{path}`
48
- defs.push(fileserve)
49
- }
50
- }
51
- }
52
-
53
- const apiDef = {
54
- name: 'API',
55
- description: '',
56
- version: '1.0.0',
57
- pathMap: '/api',
58
- allowedMethods: 'GET',
59
- logLevel: 'Debug',
60
- sessionRequired: false,
61
- userRequired: false,
62
- schemas: {},
63
- parameters: [],
64
- returns: {
65
- 200: { type: 'empty', description: 'successful response.' },
66
- 500: {
67
- type: 'string',
68
- description: 'Error details'
69
- }
70
- }
71
- }
72
-
73
- const fileServeDef = {
74
- name: 'FileServe',
75
- description: 'file service',
76
- version:
77
- '1.0.0',
78
- pathMap: '',
79
- allowedMethods: 'GET',
80
- logLevel: 'Debug',
81
- sessionRequired: false,
82
- userRequired: false,
83
- schemas: {},
84
- parameters: [{ name: 'path', in: 'path' }],
85
- returns: {
86
- 200: { type: 'empty', description: 'successful response.' },
87
- 500: { type: 'string', description: 'Error details' }
88
- }
89
- }
90
-
91
- const webrootDef = {
92
- name: 'Webroot',
93
- description: 'Serves files from the webroot /',
94
- version: '1.0.0',
95
- pathMap: '/{path}',
96
- allowedMethods: 'get',
97
- logLevel: 'Debug',
98
- sessionRequired: false,
99
- userRequired: false,
100
- schemas: {},
101
- parameters: [{ name: 'path', in: 'path' }],
102
- returns: {
103
- 200: { type: 'empty', description: 'successful response.' },
104
- 500: { type: 'string', description: 'Error details' }
105
- }
106
- }
1
+ import { gatherFunctionDefinitions } from '../../lib/openAPI/ApiBuildCollector'
2
+ import { buildOpenApi } from '../../lib/openAPI/openApiConstruction'
3
+ import { GetWebrootServePaths } from '../../lib/openAPI/WebrootFileSupport'
4
+
5
+ import path from 'path'
6
+
7
+ export async function MakePublicApiDoc
8
+ (
9
+ ): Promise<Uint8Array> {
10
+ const defs = gatherFunctionDefinitions()
11
+ return await buildOpenApi(defs)
12
+ }
13
+
14
+ export async function MakeBuiltinApiDoc
15
+ (
16
+ yamlFile: string
17
+
18
+ ): Promise<Uint8Array> {
19
+ const defs = gatherFunctionDefinitions()
20
+ addBuiltInDefinitions(defs)
21
+ return await buildOpenApi(defs, false, yamlFile) //, true)
22
+ }
23
+
24
+ export function addBuiltInDefinitions (defs: any[]): void {
25
+ // console.warn("NOT ADDING ANY BUILTIN API INTEGRATIONS")
26
+ // console.log("ADDING apiDef");
27
+ defs.push(apiDef)
28
+ // console.log("ADDING webrootDef");
29
+ defs.push(webrootDef)
30
+
31
+ // console.warn("Adding webroot literals");
32
+ // do just /docs and see how that goes
33
+ const fsdef = Object.assign({}, fileServeDef) // copy
34
+ fsdef.name = 'fileserve_docs'
35
+ fsdef.pathMap = '/docs/{path}'
36
+ defs.push(fsdef)
37
+ const roots = GetWebrootServePaths()
38
+ // console.log("roots", roots)
39
+ for (const root of roots) {
40
+ if (root !== '') {
41
+ let rootName = root
42
+ let rootPath = root.replace(path.sep, '/');
43
+ while (rootName.includes(path.sep)) rootName = rootName.replace(path.sep, '').toLowerCase().trim()
44
+ const fileserve = Object.assign({}, fileServeDef) // copy
45
+ fileserve.name = 'fileserve_' + rootName
46
+ fileserve.pathMap = `${rootPath}/{path}`
47
+ defs.push(fileserve)
48
+ }
49
+ }
50
+ }
51
+
52
+ const apiDef = {
53
+ name: 'API',
54
+ description: '',
55
+ version: '1.0.0',
56
+ pathMap: '/api',
57
+ allowedMethods: 'GET',
58
+ logLevel: 'Debug',
59
+ sessionRequired: false,
60
+ userRequired: false,
61
+ schemas: {},
62
+ parameters: [],
63
+ returns: {
64
+ 200: { type: 'empty', description: 'successful response.' },
65
+ 500: {
66
+ type: 'string',
67
+ description: 'Error details'
68
+ }
69
+ }
70
+ }
71
+
72
+ const fileServeDef = {
73
+ name: 'FileServe',
74
+ description: 'file service',
75
+ version:
76
+ '1.0.0',
77
+ pathMap: '',
78
+ allowedMethods: 'GET',
79
+ logLevel: 'Debug',
80
+ sessionRequired: false,
81
+ userRequired: false,
82
+ schemas: {},
83
+ parameters: [{ name: 'path', in: 'path' }],
84
+ returns: {
85
+ 200: { type: 'empty', description: 'successful response.' },
86
+ 500: { type: 'string', description: 'Error details' }
87
+ }
88
+ }
89
+
90
+ const webrootDef = {
91
+ name: 'Webroot',
92
+ description: 'Serves files from the webroot /',
93
+ version: '1.0.0',
94
+ pathMap: '/{path}',
95
+ allowedMethods: 'get',
96
+ logLevel: 'Debug',
97
+ sessionRequired: false,
98
+ userRequired: false,
99
+ schemas: {},
100
+ parameters: [{ name: 'path', in: 'path' }],
101
+ returns: {
102
+ 200: { type: 'empty', description: 'successful response.' },
103
+ 500: { type: 'string', description: 'Error details' }
104
+ }
105
+ }
@@ -1,47 +1,47 @@
1
- import { StageWebrootZip } from './StageWebrootZip'
2
- import { DeployBuiltInZip } from './DeployBuiltInZip'
3
- import { GetWebrootServePaths } from '../../lib/openAPI/WebrootFileSupport'
4
-
5
- import fs from 'fs'
6
- import path from 'path'
7
-
8
- export async function DeployWebrootBuiltIn
9
- (
10
- ): Promise<void> {
11
- const wrZip = await StageWebrootZip()
12
- // console.log("Deploy Webroot Builtin from "+wrZip)
13
- await DeployBuiltInZip('Webroot', wrZip)
14
- // remove temp zip when done
15
- fs.rmSync(wrZip, { recursive: true })
16
- }
17
-
18
- export async function DeployRootFileserves
19
- (
20
- ): Promise<void> {
21
- // console.log("Deploy Root Fileserves")
22
- // Get root paths
23
- const roots = GetWebrootServePaths()
24
- // for each, deploy under the name of each
25
- const fileserveZip = path.join(__dirname, 'prebuilt-zips', 'FileServe.zip')
26
- const all: Array<Promise<any>> = []
27
- for (let root of roots) {
28
- root = root.trim()
29
- let name = 'fileserve_' + root
30
- while (name.includes('/')) {
31
- name = name.replace('/', '')
32
- }
33
- all.push(DeployBuiltInZip(name, fileserveZip))
34
- }
35
- // console.log('wait all');
36
- await Promise.all(all)
37
- // console.log('all complete');
38
- }
39
-
40
- export async function DeployApiBuiltin
41
- (
42
- ): Promise<any> {
43
- console.log('Deploy API Builtin')
44
- // get the prebuilt zip location
45
- const apiZip = path.join(__dirname, 'prebuilt-zips', 'API.zip')
46
- await DeployBuiltInZip('api', apiZip)
47
- }
1
+ import { StageWebrootZip } from './StageWebrootZip'
2
+ import { DeployBuiltInZip } from './DeployBuiltInZip'
3
+ import { GetWebrootServePaths } from '../../lib/openAPI/WebrootFileSupport'
4
+
5
+ import fs from 'fs'
6
+ import path from 'path'
7
+
8
+ export async function DeployWebrootBuiltIn
9
+ (
10
+ ): Promise<void> {
11
+ const wrZip = await StageWebrootZip()
12
+ // console.log("Deploy Webroot Builtin from "+wrZip)
13
+ await DeployBuiltInZip('Webroot', wrZip)
14
+ // remove temp zip when done
15
+ fs.rmSync(wrZip, { recursive: true })
16
+ }
17
+
18
+ export async function DeployRootFileserves
19
+ (
20
+ ): Promise<void> {
21
+ // console.log("Deploy Root Fileserves")
22
+ // Get root paths
23
+ const roots = GetWebrootServePaths()
24
+ // for each, deploy under the name of each
25
+ const fileserveZip = path.join(__dirname, 'prebuilt-zips', 'FileServe.zip')
26
+ const all: Array<Promise<any>> = []
27
+ for (let root of roots) {
28
+ root = root.trim()
29
+ let name = 'fileserve_' + root
30
+ while (name.includes('/')) {
31
+ name = name.replace('/', '')
32
+ }
33
+ all.push(DeployBuiltInZip(name, fileserveZip))
34
+ }
35
+ // console.log('wait all');
36
+ await Promise.all(all)
37
+ // console.log('all complete');
38
+ }
39
+
40
+ export async function DeployApiBuiltin
41
+ (
42
+ ): Promise<any> {
43
+ console.log('Deploy API Builtin')
44
+ // get the prebuilt zip location
45
+ const apiZip = path.join(__dirname, 'prebuilt-zips', 'API.zip')
46
+ await DeployBuiltInZip('api', apiZip)
47
+ }