@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.
- package/LICENSE +21 -21
- package/README.md +70 -66
- package/build/commands/actions/initQuestions.js.map +1 -0
- package/build/commands/actions/makePackageJson.js.map +1 -0
- package/build/commands/actions/setupPackageJson.js.map +1 -0
- package/build/commands/build.js.map +1 -0
- package/build/{src/commands → commands}/builtin/ApiDocMaker.js +0 -1
- package/build/commands/builtin/ApiDocMaker.js.map +1 -0
- package/build/commands/builtin/BuiltInHandler.js.map +1 -0
- package/build/commands/builtin/DeployBuiltInZip.js.map +1 -0
- package/build/commands/builtin/StageWebrootZip.js.map +1 -0
- package/build/commands/create.js.map +1 -0
- package/build/commands/deploy.js.map +1 -0
- package/build/{src/commands → commands}/doctor.js +12 -1
- package/build/commands/doctor.js.map +1 -0
- package/build/commands/help.js.map +1 -0
- package/build/commands/info.js.map +1 -0
- package/build/{src/commands → commands}/init.js +1 -2
- package/build/commands/init.js.map +1 -0
- package/build/commands/package.js.map +1 -0
- package/build/commands/publish.js.map +1 -0
- package/build/commands/settings.js.map +1 -0
- package/build/commands/start.js.map +1 -0
- package/build/commands/test.js.map +1 -0
- package/build/commands/user.js.map +1 -0
- package/build/expressRoutes/all.js.map +1 -0
- package/build/expressRoutes/api.js.map +1 -0
- package/build/expressRoutes/functionBinder.js.map +1 -0
- package/build/integration-tests/quickstart-scenario.test.js.map +1 -0
- package/build/lib/CaseUtils.js.map +1 -0
- package/build/lib/DirectoryUtils.js.map +1 -0
- package/build/lib/LiftConfig.js.map +1 -0
- package/build/{src/lib → lib}/LiftVersion.js +1 -1
- package/build/lib/LiftVersion.js.map +1 -0
- package/build/lib/Tests/fileCompare.test.js.map +1 -0
- package/build/lib/askQuestion.js.map +1 -0
- package/build/lib/executeCommand.js.map +1 -0
- package/build/lib/fileCompare.js.map +1 -0
- package/build/lib/openAPI/ApiBuildCollector.js.map +1 -0
- package/build/lib/openAPI/WebrootFileSupport.js.map +1 -0
- package/build/lib/openAPI/openApiConstruction.js.map +1 -0
- package/build/lib/pathResolve.js.map +1 -0
- package/build/lib/utils.js.map +1 -0
- package/build/{src/lift.js → lift.js} +0 -0
- package/build/lift.js.map +1 -0
- package/package.json +78 -79
- package/src/commands/actions/initQuestions.ts +133 -133
- package/src/commands/actions/setupPackageJson.ts +32 -32
- package/src/commands/build.ts +173 -173
- package/src/commands/builtin/ApiDocMaker.ts +105 -106
- package/src/commands/builtin/BuiltInHandler.ts +47 -47
- package/src/commands/builtin/DeployBuiltInZip.ts +25 -25
- package/src/commands/builtin/StageWebrootZip.ts +36 -36
- package/src/commands/create.ts +52 -52
- package/src/commands/deploy.ts +161 -161
- package/src/commands/doctor.ts +118 -107
- package/src/commands/help.ts +178 -178
- package/src/commands/info.ts +42 -42
- package/src/commands/init.ts +60 -61
- package/src/commands/package.ts +234 -234
- package/src/commands/publish.ts +330 -330
- package/src/commands/settings.ts +73 -73
- package/src/commands/start.ts +43 -43
- package/src/commands/test.ts +37 -37
- package/src/commands/user.ts +20 -20
- package/src/expressRoutes/all.ts +99 -99
- package/src/expressRoutes/api.ts +22 -22
- package/src/expressRoutes/functionBinder.ts +155 -155
- package/src/integration-tests/quickstart-scenario.test.ts +76 -76
- package/src/lib/CaseUtils.ts +63 -63
- package/src/lib/DirectoryUtils.ts +34 -34
- package/src/lib/LiftConfig.ts +74 -74
- package/src/lib/LiftVersion.ts +87 -87
- package/src/lib/Tests/fileCompare.test.ts +35 -35
- package/src/lib/askQuestion.ts +17 -17
- package/src/lib/executeCommand.ts +45 -45
- package/src/lib/fileCompare.ts +55 -55
- package/src/lib/openAPI/ApiBuildCollector.ts +47 -47
- package/src/lib/openAPI/WebrootFileSupport.ts +19 -19
- package/src/lib/openAPI/openApiConstruction.ts +196 -196
- package/src/lib/pathResolve.ts +26 -26
- package/src/lib/utils.ts +43 -43
- package/src/lift.ts +87 -87
- package/templateData/function-definition-template +20 -20
- package/templateData/function-local-ts +16 -16
- package/templateData/function-main-ts +16 -16
- package/templateData/function-runmain-mjs +6 -6
- package/templateData/function-test-template +11 -11
- package/templateData/swagger-ui-bundle.js +2 -2
- package/templateData/swagger-ui-standalone-preset.js +2 -2
- package/templateData/swagger-ui.css +2 -2
- package/tsconfig.json +28 -28
- package/build/QSTest/functions/IntegrationTest/integrationTest-tests/Sanity.test.js +0 -14
- package/build/QSTest/functions/IntegrationTest/integrationTest-tests/Sanity.test.js.map +0 -1
- package/build/QSTest/functions/IntegrationTest/src/local.js +0 -33
- package/build/QSTest/functions/IntegrationTest/src/local.js.map +0 -1
- package/build/QSTest/functions/IntegrationTest/src/main.js +0 -29
- package/build/QSTest/functions/IntegrationTest/src/main.js.map +0 -1
- package/build/src/commands/actions/initQuestions.js.map +0 -1
- package/build/src/commands/actions/makePackageJson.js.map +0 -1
- package/build/src/commands/actions/setupPackageJson.js.map +0 -1
- package/build/src/commands/build.js.map +0 -1
- package/build/src/commands/builtin/ApiDocMaker.js.map +0 -1
- package/build/src/commands/builtin/BuiltInHandler.js.map +0 -1
- package/build/src/commands/builtin/DeployBuiltInZip.js.map +0 -1
- package/build/src/commands/builtin/StageWebrootZip.js.map +0 -1
- package/build/src/commands/create.js.map +0 -1
- package/build/src/commands/deploy.js.map +0 -1
- package/build/src/commands/doctor.js.map +0 -1
- package/build/src/commands/help.js.map +0 -1
- package/build/src/commands/info.js.map +0 -1
- package/build/src/commands/init.js.map +0 -1
- package/build/src/commands/package.js.map +0 -1
- package/build/src/commands/publish.js.map +0 -1
- package/build/src/commands/settings.js.map +0 -1
- package/build/src/commands/start.js.map +0 -1
- package/build/src/commands/test.js.map +0 -1
- package/build/src/commands/user.js.map +0 -1
- package/build/src/expressRoutes/all.js.map +0 -1
- package/build/src/expressRoutes/api.js.map +0 -1
- package/build/src/expressRoutes/functionBinder.js.map +0 -1
- package/build/src/integration-tests/quickstart-scenario.test.js.map +0 -1
- package/build/src/lib/CaseUtils.js.map +0 -1
- package/build/src/lib/DirectoryUtils.js.map +0 -1
- package/build/src/lib/LiftConfig.js.map +0 -1
- package/build/src/lib/LiftVersion.js.map +0 -1
- package/build/src/lib/Tests/fileCompare.test.js.map +0 -1
- package/build/src/lib/askQuestion.js.map +0 -1
- package/build/src/lib/executeCommand.js.map +0 -1
- package/build/src/lib/fileCompare.js.map +0 -1
- package/build/src/lib/openAPI/ApiBuildCollector.js.map +0 -1
- package/build/src/lib/openAPI/WebrootFileSupport.js.map +0 -1
- package/build/src/lib/openAPI/openApiConstruction.js.map +0 -1
- package/build/src/lib/pathResolve.js.map +0 -1
- package/build/src/lib/utils.js.map +0 -1
- package/build/src/lift.js.map +0 -1
- /package/build/{src/commands → commands}/actions/initQuestions.js +0 -0
- /package/build/{src/commands → commands}/actions/makePackageJson.js +0 -0
- /package/build/{src/commands → commands}/actions/setupPackageJson.js +0 -0
- /package/build/{src/commands → commands}/build.js +0 -0
- /package/build/{src/commands → commands}/builtin/BuiltInHandler.js +0 -0
- /package/build/{src/commands → commands}/builtin/DeployBuiltInZip.js +0 -0
- /package/build/{src/commands → commands}/builtin/StageWebrootZip.js +0 -0
- /package/build/{src/commands → commands}/create.js +0 -0
- /package/build/{src/commands → commands}/deploy.js +0 -0
- /package/build/{src/commands → commands}/help.js +0 -0
- /package/build/{src/commands → commands}/info.js +0 -0
- /package/build/{src/commands → commands}/package.js +0 -0
- /package/build/{src/commands → commands}/publish.js +0 -0
- /package/build/{src/commands → commands}/settings.js +0 -0
- /package/build/{src/commands → commands}/start.js +0 -0
- /package/build/{src/commands → commands}/test.js +0 -0
- /package/build/{src/commands → commands}/user.js +0 -0
- /package/build/{src/expressRoutes → expressRoutes}/all.js +0 -0
- /package/build/{src/expressRoutes → expressRoutes}/api.js +0 -0
- /package/build/{src/expressRoutes → expressRoutes}/functionBinder.js +0 -0
- /package/build/{src/integration-tests → integration-tests}/quickstart-scenario.test.js +0 -0
- /package/build/{src/lib → lib}/CaseUtils.js +0 -0
- /package/build/{src/lib → lib}/DirectoryUtils.js +0 -0
- /package/build/{src/lib → lib}/LiftConfig.js +0 -0
- /package/build/{src/lib → lib}/Tests/fileCompare.test.js +0 -0
- /package/build/{src/lib → lib}/askQuestion.js +0 -0
- /package/build/{src/lib → lib}/executeCommand.js +0 -0
- /package/build/{src/lib → lib}/fileCompare.js +0 -0
- /package/build/{src/lib → lib}/openAPI/ApiBuildCollector.js +0 -0
- /package/build/{src/lib → lib}/openAPI/WebrootFileSupport.js +0 -0
- /package/build/{src/lib → lib}/openAPI/openApiConstruction.js +0 -0
- /package/build/{src/lib → lib}/pathResolve.js +0 -0
- /package/build/{src/lib → lib}/utils.js +0 -0
package/src/commands/build.ts
CHANGED
|
@@ -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
|
-
|
|
45
|
-
|
|
46
|
-
fileserve.
|
|
47
|
-
fileserve
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
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
|
+
}
|