@tremho/mist-lift 2.0.2 → 2.0.4
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/README.md +10 -0
- package/build/commands/builtin/prebuilt-zips/API.zip +0 -0
- package/build/commands/builtin/prebuilt-zips/FileServe.zip +0 -0
- package/build/commands/builtin/prebuilt-zips/Webroot.zip +0 -0
- package/build/commands/create.js +4 -6
- package/build/commands/create.js.map +1 -1
- package/build/commands/deploy.js.map +1 -1
- package/build/commands/help.js +5 -2
- package/build/commands/help.js.map +1 -1
- package/build/commands/init.js +1 -0
- package/build/commands/init.js.map +1 -1
- package/build/commands/start.js +32 -27
- package/build/commands/start.js.map +1 -1
- package/build/commands/test.js +1 -1
- package/build/commands/test.js.map +1 -1
- package/build/expressRoutes/all.js.map +1 -1
- package/build/expressRoutes/functionBinder.js +9 -5
- package/build/expressRoutes/functionBinder.js.map +1 -1
- package/build/integration-tests/quickstart-scenario.test.js +22 -17
- package/build/integration-tests/quickstart-scenario.test.js.map +1 -1
- package/build/lib/DirectoryUtils.js.map +1 -1
- package/build/lib/openAPI/openApiConstruction.js +3 -3
- package/build/lib/openAPI/openApiConstruction.js.map +1 -1
- package/package.json +5 -6
- package/src/commands/builtin/prebuilt-zips/API.zip +0 -0
- package/src/commands/builtin/prebuilt-zips/FileServe.zip +0 -0
- package/src/commands/builtin/prebuilt-zips/Webroot.zip +0 -0
- package/src/commands/create.ts +8 -9
- package/src/commands/deploy.ts +3 -3
- package/src/commands/help.ts +5 -3
- package/src/commands/init.ts +2 -1
- package/src/commands/start.ts +58 -66
- package/src/commands/test.ts +1 -1
- package/src/expressRoutes/all.ts +1 -1
- package/src/expressRoutes/functionBinder.ts +10 -7
- package/src/integration-tests/quickstart-scenario.test.ts +22 -17
- package/src/lib/DirectoryUtils.ts +5 -5
- package/src/lib/openAPI/openApiConstruction.ts +5 -5
- package/templateData/function-main-ts +1 -1
- package/templateData/function-test-template +29 -3
|
@@ -1 +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.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"description": "lift command line utility for MistLift development",
|
|
5
5
|
"main": "build/lift.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"lift": "build/lift.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
|
-
"prepublish": "run
|
|
11
|
-
"prepublish:nix": "npx rimraf build && npm run build && npm run indev",
|
|
12
|
-
"prepublish:windows": "npx rimraf build & npm run build & npm run indev",
|
|
10
|
+
"prepublish": "npx rimraf build && npm run build && npm run lint",
|
|
13
11
|
"clean": "npx rimraf build ; npx rimraf node_modules ; npm install",
|
|
14
12
|
"build": "run-script-os",
|
|
15
13
|
"build:windows": "tsc & npm run postbuild",
|
|
@@ -51,8 +49,8 @@
|
|
|
51
49
|
"@aws-sdk/client-api-gateway": "^3.598.0",
|
|
52
50
|
"@aws-sdk/client-lambda": "^3.598.0",
|
|
53
51
|
"@aws-sdk/credential-providers": "^3.598.0",
|
|
54
|
-
"@tremho/inverse-y": "^2.0.
|
|
55
|
-
"@tremho/session-tbd": "^2.0.
|
|
52
|
+
"@tremho/inverse-y": "^2.0.2-pre-prelease.4",
|
|
53
|
+
"@tremho/session-tbd": "^2.0.1-pre-release.3",
|
|
56
54
|
"ansi-colors": "^4.1.3",
|
|
57
55
|
"body-parser": "^1.20.2",
|
|
58
56
|
"clear-module": "^4.1.2",
|
|
@@ -67,6 +65,7 @@
|
|
|
67
65
|
"zip-dir": "^2.0.0"
|
|
68
66
|
},
|
|
69
67
|
"devDependencies": {
|
|
68
|
+
"@tremho/tap-assert": "^1.0.4-pre-release.2",
|
|
70
69
|
"@types/express": "^4.17.21",
|
|
71
70
|
"@types/express-ws": "^3.0.4",
|
|
72
71
|
"@types/md5": "^2.3.5",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/src/commands/create.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as fs from 'fs'
|
|
|
4
4
|
import * as path from 'path'
|
|
5
5
|
import * as ac from 'ansi-colors'
|
|
6
6
|
import { resolvePaths } from '../lib/pathResolve'
|
|
7
|
-
import {
|
|
7
|
+
import { pascalCase } from '../lib/CaseUtils'
|
|
8
8
|
import { helpCreate } from './help'
|
|
9
9
|
|
|
10
10
|
/// Create command
|
|
@@ -25,19 +25,18 @@ export function doCreate (
|
|
|
25
25
|
if (!fs.existsSync(funcPath)) fs.mkdirSync(funcPath)
|
|
26
26
|
const dataDir = path.join(__dirname, '..', '..', 'templateData')
|
|
27
27
|
|
|
28
|
-
const
|
|
29
|
-
if (!fs.existsSync(path.join(funcPath, testdirname))) fs.mkdirSync(path.join(funcPath, testdirname))
|
|
28
|
+
const testFileName = pascalCase(funcName) + '.test.ts'
|
|
30
29
|
if (!fs.existsSync(path.join(funcPath, 'src'))) fs.mkdirSync(path.join(funcPath, 'src'))
|
|
31
30
|
|
|
32
31
|
// create link to common lib
|
|
33
|
-
if(!fs.existsSync(path.join(funcPath, 'src', 'commonLib'))) {
|
|
32
|
+
if (!fs.existsSync(path.join(funcPath, 'src', 'commonLib'))) {
|
|
34
33
|
const funcSrc = path.join(funcPath, 'src')
|
|
35
34
|
const relPath = path.relative(funcSrc, projectPaths.basePath)
|
|
36
|
-
let from = path.join(relPath, 'commonLib')
|
|
35
|
+
let from = path.join(relPath, 'commonLib')
|
|
37
36
|
let to = path.join(funcSrc, 'lib')
|
|
38
|
-
if(path.sep !== '/') {
|
|
39
|
-
while(from.
|
|
40
|
-
while(to.
|
|
37
|
+
if (path.sep !== '/') {
|
|
38
|
+
while (from.includes('/')) from = from.replace('/', path.sep)
|
|
39
|
+
while (to.includes('/')) to = to.replace('/', path.sep)
|
|
41
40
|
}
|
|
42
41
|
|
|
43
42
|
fs.symlinkSync(from, to, 'dir')
|
|
@@ -60,7 +59,7 @@ export function doCreate (
|
|
|
60
59
|
mainsrc = mainsrc.replace('$$TemplateName$$', funcName)
|
|
61
60
|
}
|
|
62
61
|
fs.writeFileSync(path.join(funcPath, 'src', 'main.ts'), mainsrc)
|
|
63
|
-
fs.copyFileSync(path.join(dataDir, 'function-test-template'), path.join(funcPath,
|
|
62
|
+
fs.copyFileSync(path.join(dataDir, 'function-test-template'), path.join(funcPath, testFileName))
|
|
64
63
|
fs.copyFileSync(path.join(dataDir, 'function-runmain-mjs'), path.join(funcPath, 'runmain.mjs'))
|
|
65
64
|
}
|
|
66
65
|
}
|
package/src/commands/deploy.ts
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
LambdaClient,
|
|
4
4
|
CreateFunctionCommand,
|
|
5
5
|
DeleteFunctionCommand,
|
|
6
|
-
AddPermissionCommand
|
|
6
|
+
AddPermissionCommand
|
|
7
7
|
} from '@aws-sdk/client-lambda'
|
|
8
8
|
|
|
9
9
|
import md5 from 'md5'
|
|
@@ -95,10 +95,10 @@ export async function deployPackage (
|
|
|
95
95
|
projectPaths = resolvePaths()
|
|
96
96
|
zipFile ??= path.join(projectPaths.basePath, 'MistLift_Zips', funcName + '.zip')
|
|
97
97
|
const defFile = path.join(projectPaths.basePath, 'functions', funcName, 'src', 'definition.json')
|
|
98
|
-
let def:any = {}
|
|
98
|
+
let def: any = {}
|
|
99
99
|
try {
|
|
100
100
|
def = JSON.parse(fs.readFileSync(defFile).toString())
|
|
101
|
-
} catch(e:any) {}
|
|
101
|
+
} catch (e: any) {}
|
|
102
102
|
const timeout = def.timeoutSeconds ?? 0 // zero will mean default (3 seconds on AWS)
|
|
103
103
|
// funcname gets decorated with current instance identifier
|
|
104
104
|
const idsrc = md5((getProjectName() ?? '') + (getProjectVersion()?.toString() ?? ''))
|
package/src/commands/help.ts
CHANGED
|
@@ -96,7 +96,6 @@ export function helpCreate (): void {
|
|
|
96
96
|
console.log(ac.grey('Modify the code to suit the needs of your function application'))
|
|
97
97
|
console.log('')
|
|
98
98
|
console.log(ac.italic.blue('For Windows, this command must be issued in from a Command or Powershell window in Administrator mode'))
|
|
99
|
-
|
|
100
99
|
}
|
|
101
100
|
export function helpBuild (): void {
|
|
102
101
|
printBanner('build')
|
|
@@ -116,8 +115,11 @@ export function helpTest (): void {
|
|
|
116
115
|
printBanner('test')
|
|
117
116
|
console.log('use ' + ac.bold('lift test') + ' to invoke the testing framework and run unit tests for all functions')
|
|
118
117
|
console.log('')
|
|
119
|
-
console.log('Tests should be written in files
|
|
120
|
-
console.log(
|
|
118
|
+
console.log('Tests should be written in files for each created function. test files are given the suffix .test.ts.')
|
|
119
|
+
console.log('A placeholder is automatically created on create that successfully tests the "Hello, World!" placeholder function.')
|
|
120
|
+
console.log('Modify/replace this to suit your function.')
|
|
121
|
+
console.log("The test framework used is 'Tap' (https://node-tap.org).")
|
|
122
|
+
console.log("The 'TapAssert' (https://www.npmjs.com/package/@tremho/tap-assert) assertion library designed for this is also installed and used in example for your convenience.")
|
|
121
123
|
console.log('')
|
|
122
124
|
}
|
|
123
125
|
export function helpStart (): void {
|
package/src/commands/init.ts
CHANGED
|
@@ -45,7 +45,7 @@ export async function doInit (
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// make webroot with docs folder and placeholder yaml
|
|
48
|
-
const webroot = path.join(refPath, 'webroot')
|
|
48
|
+
const webroot = path.join(refPath, 'webroot')
|
|
49
49
|
const webrootDocs = path.join(webroot, 'docs')
|
|
50
50
|
if (!fs.existsSync(webrootDocs)) {
|
|
51
51
|
fs.mkdirSync(webrootDocs, { recursive: true })
|
|
@@ -70,5 +70,6 @@ export async function doInit (
|
|
|
70
70
|
await installDevPackage(refPath, '@types/node')
|
|
71
71
|
await installDevPackage(refPath, 'typescript')
|
|
72
72
|
await installDevPackage(refPath, 'tap')
|
|
73
|
+
await installDevPackage(refPath, '@tremho/tap-assert')
|
|
73
74
|
await installPackage(refPath, '@tremho/inverse-y')
|
|
74
75
|
}
|
package/src/commands/start.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import express from 'express'
|
|
3
3
|
|
|
4
4
|
import * as esbuild from 'esbuild'
|
|
5
|
-
import watch from 'node-watch'
|
|
5
|
+
import watch from 'node-watch'
|
|
6
6
|
import expressWS from 'express-ws'
|
|
7
7
|
|
|
8
8
|
import functionRouter, { functionBinder } from '../expressRoutes/functionBinder'
|
|
@@ -17,11 +17,9 @@ import * as ac from 'ansi-colors'
|
|
|
17
17
|
import path from 'path'
|
|
18
18
|
import fs from 'fs'
|
|
19
19
|
|
|
20
|
-
import {Log} from "@tremho/inverse-y"
|
|
21
|
-
|
|
22
20
|
const defaultPort = 8081
|
|
23
|
-
const serverConfig = readServerConfig()
|
|
24
|
-
let server:any = null
|
|
21
|
+
const serverConfig = readServerConfig()
|
|
22
|
+
let server: any = null
|
|
25
23
|
const app = express()
|
|
26
24
|
|
|
27
25
|
export async function startLocalServer (): Promise<void> {
|
|
@@ -44,117 +42,113 @@ export async function startLocalServer (): Promise<void> {
|
|
|
44
42
|
// app.use(bodyParser.json({limit: '50mb'}))
|
|
45
43
|
app.use(express.json())
|
|
46
44
|
// for form posts
|
|
47
|
-
app.use(express.urlencoded({extended: true}))
|
|
45
|
+
app.use(express.urlencoded({ extended: true }))
|
|
48
46
|
|
|
49
47
|
app.use('/', functionRouter)
|
|
50
48
|
app.use('/api', apiRouter)
|
|
51
49
|
app.use('*', allRouter)
|
|
52
50
|
|
|
53
|
-
|
|
54
51
|
startServers()
|
|
55
52
|
|
|
56
|
-
funcWatcher(path.join(projectPaths.basePath, 'functions'), path.join(projectPaths.basePath, 'webroot'))
|
|
53
|
+
void funcWatcher(path.join(projectPaths.basePath, 'functions'), path.join(projectPaths.basePath, 'webroot'))
|
|
57
54
|
// sleep(5000).then(() => esbuilder())
|
|
58
|
-
esbuilder()
|
|
59
|
-
|
|
55
|
+
void esbuilder()
|
|
60
56
|
}
|
|
61
|
-
function startServers() {
|
|
57
|
+
function startServers (): void {
|
|
62
58
|
startWebSocketConnection(app)
|
|
63
59
|
server = app.listen(serverConfig.port, function () {
|
|
64
|
-
|
|
60
|
+
const port: number = serverConfig?.port ?? defaultPort
|
|
61
|
+
console.log(`http listening on port ${port}`)
|
|
65
62
|
})
|
|
66
63
|
}
|
|
67
64
|
|
|
68
|
-
function readServerConfig() {
|
|
65
|
+
function readServerConfig (): any {
|
|
69
66
|
// console.log('readServerConfig...')
|
|
70
67
|
const projectPaths = resolvePaths()
|
|
71
68
|
const confFile = path.join(projectPaths.basePath, 'localServerConfig.json')
|
|
72
|
-
if(!fs.existsSync(confFile)) return {}
|
|
69
|
+
if (!fs.existsSync(confFile)) return {}
|
|
73
70
|
|
|
74
|
-
const conf:any = JSON.parse(fs.readFileSync(confFile).toString())
|
|
71
|
+
const conf: any = JSON.parse(fs.readFileSync(confFile).toString())
|
|
75
72
|
// console.log("server configuration", conf)
|
|
76
73
|
return conf
|
|
77
74
|
}
|
|
78
75
|
|
|
79
|
-
async function esbuilder() {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
return triggerRebuild() // forces real start
|
|
76
|
+
async function esbuilder (): Promise<void> {
|
|
77
|
+
if (serverConfig.esbuild !== true) {
|
|
78
|
+
return await triggerRebuild() // forces real start
|
|
83
79
|
}
|
|
84
80
|
|
|
85
81
|
const entryPoints = serverConfig.esbuild.entryPoints ?? []
|
|
86
82
|
const outDir = serverConfig.esbuild.outdir ?? 'webroot'
|
|
87
83
|
const watch = serverConfig.esbuild.watch ?? false
|
|
88
|
-
const breakOnError = serverConfig.esbuild.breakOnError ?? false
|
|
89
|
-
const breakOnWarn = serverConfig.esbuild.breakOnWarn ?? false
|
|
84
|
+
// const breakOnError = serverConfig.esbuild.breakOnError ?? false
|
|
85
|
+
// const breakOnWarn = serverConfig.esbuild.breakOnWarn ?? false
|
|
90
86
|
|
|
91
|
-
|
|
87
|
+
const ctx = await esbuild.context({
|
|
92
88
|
entryPoints,
|
|
93
89
|
bundle: true,
|
|
94
90
|
outdir: outDir
|
|
95
91
|
})
|
|
96
92
|
// console.log('esbuild...')
|
|
97
93
|
|
|
98
|
-
let result = await ctx.rebuild()
|
|
99
|
-
let more = watch
|
|
94
|
+
/* let result = */ await ctx.rebuild()
|
|
95
|
+
let more: boolean = watch === true
|
|
100
96
|
do {
|
|
101
97
|
await sleep(500)
|
|
102
|
-
result = await ctx.rebuild()
|
|
103
|
-
|
|
98
|
+
/* result = */ await ctx.rebuild()
|
|
99
|
+
more = watch === true
|
|
100
|
+
} while (more)
|
|
104
101
|
}
|
|
105
102
|
|
|
106
|
-
function sleep(ms:number)
|
|
107
|
-
{
|
|
108
|
-
return new Promise(resolve => {
|
|
103
|
+
async function sleep (ms: number): Promise<void> {
|
|
104
|
+
return await new Promise(resolve => {
|
|
109
105
|
setTimeout(resolve, ms)
|
|
110
106
|
})
|
|
111
107
|
}
|
|
112
108
|
|
|
113
|
-
async function funcWatcher(watchPath:string, webrootPath:string) {
|
|
114
|
-
|
|
115
|
-
if(serverConfig.rebuildFunctionsOnChange !== true) return;
|
|
109
|
+
async function funcWatcher (watchPath: string, webrootPath: string): Promise<void> {
|
|
110
|
+
if (serverConfig.rebuildFunctionsOnChange !== true) return
|
|
116
111
|
// console.log('watching for changes in functions')
|
|
117
|
-
watch(watchPath, {recursive:true}, onWatch1)
|
|
112
|
+
watch(watchPath, { recursive: true }, onWatch1)
|
|
118
113
|
|
|
119
|
-
if(serverConfig.refreshBrowserOnWebrootChange) {
|
|
114
|
+
if (serverConfig.refreshBrowserOnWebrootChange === true) {
|
|
120
115
|
// console.log('watching for webroot changes')
|
|
121
|
-
watch(webrootPath, {recursive: true}, onWatch2)
|
|
116
|
+
watch(webrootPath, { recursive: true }, onWatch2)
|
|
122
117
|
}
|
|
123
118
|
}
|
|
124
|
-
function onWatch1(evt:string, name:string) {
|
|
119
|
+
function onWatch1 (evt: string, name: string): void {
|
|
125
120
|
// console.log("funcWatch Event seen", {evt, name})
|
|
126
|
-
triggerRebuild()
|
|
121
|
+
void triggerRebuild()
|
|
127
122
|
}
|
|
128
|
-
function onWatch2(evt:string, name:string) {
|
|
123
|
+
function onWatch2 (evt: string, name: string): void {
|
|
129
124
|
// console.log("Webroot Watch Event seen", {evt, name})
|
|
130
|
-
triggerBrowserRestart()
|
|
125
|
+
void triggerBrowserRestart()
|
|
131
126
|
}
|
|
132
127
|
|
|
133
128
|
let alreadyBuilding = false
|
|
134
|
-
async function triggerRebuild() {
|
|
135
|
-
if(!alreadyBuilding) {
|
|
136
|
-
alreadyBuilding = true
|
|
137
|
-
const errRet = await doBuildAsync([])
|
|
138
|
-
if(errRet) {
|
|
129
|
+
async function triggerRebuild (): Promise<void> {
|
|
130
|
+
if (!alreadyBuilding) {
|
|
131
|
+
alreadyBuilding = true
|
|
132
|
+
const errRet: number = await doBuildAsync([])
|
|
133
|
+
if (errRet !== 0) {
|
|
139
134
|
process.exit(errRet)
|
|
140
135
|
}
|
|
141
|
-
alreadyBuilding = false
|
|
142
|
-
if(serverConfig.refreshBrowserOnFunctionChange)
|
|
143
|
-
triggerBrowserRestart()
|
|
136
|
+
alreadyBuilding = false
|
|
137
|
+
if (serverConfig.refreshBrowserOnFunctionChange === true) { void triggerBrowserRestart() }
|
|
144
138
|
}
|
|
145
139
|
}
|
|
146
140
|
|
|
147
141
|
let closing = false
|
|
148
142
|
|
|
149
|
-
async function triggerBrowserRestart() {
|
|
150
|
-
if(closing) {
|
|
143
|
+
async function triggerBrowserRestart (): Promise<void> {
|
|
144
|
+
if (closing) {
|
|
151
145
|
console.warn('restarting...')
|
|
152
146
|
return
|
|
153
147
|
}
|
|
154
|
-
if(server) {
|
|
155
|
-
closing = true
|
|
156
|
-
await socketClose()
|
|
157
|
-
await server.close()
|
|
148
|
+
if (server !== null) {
|
|
149
|
+
closing = true
|
|
150
|
+
await socketClose()
|
|
151
|
+
await server.close()
|
|
158
152
|
await sleep(1000)
|
|
159
153
|
closing = false
|
|
160
154
|
startServers()
|
|
@@ -163,37 +157,35 @@ async function triggerBrowserRestart() {
|
|
|
163
157
|
}
|
|
164
158
|
}
|
|
165
159
|
|
|
166
|
-
class WSConnection {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
160
|
+
// class WSConnection {
|
|
161
|
+
// on: any
|
|
162
|
+
// sendUTF: any
|
|
163
|
+
// remoteAddress: string = ''
|
|
164
|
+
// }
|
|
171
165
|
|
|
172
|
-
|
|
166
|
+
let socketClose: any = () => {}
|
|
173
167
|
|
|
174
|
-
function startWebSocketConnection(app:any)
|
|
175
|
-
{
|
|
168
|
+
function startWebSocketConnection (app: any): void {
|
|
176
169
|
// console.log("Starting WebSocket Connection Listener")
|
|
177
170
|
const ews = expressWS(app)
|
|
178
171
|
const wsapp = ews.app
|
|
179
172
|
|
|
180
|
-
socketClose = (e:any) => {
|
|
173
|
+
socketClose = (e: any) => {
|
|
181
174
|
// console.log("close wss", e)
|
|
182
175
|
ews.getWss().close()
|
|
183
176
|
}
|
|
184
177
|
|
|
185
|
-
|
|
186
178
|
// wsapp.use((err:any, req:any, res:any, next:any) => {
|
|
187
179
|
// console.error(err.stack);
|
|
188
180
|
// res.status(500).send('Something broke!');
|
|
189
181
|
// })
|
|
190
182
|
|
|
191
|
-
wsapp.get('/watch', (req:any, res:any, next:any) => {
|
|
183
|
+
wsapp.get('/watch', (req: any, res: any, next: any) => {
|
|
192
184
|
// console.log('get route', req.testing)
|
|
193
185
|
})
|
|
194
186
|
|
|
195
|
-
wsapp.ws('/watch', (ws:any, req:any) => {
|
|
196
|
-
ws.on('message', (msg:string)=> {
|
|
187
|
+
wsapp.ws('/watch', (ws: any, req: any) => {
|
|
188
|
+
ws.on('message', (msg: string) => {
|
|
197
189
|
// console.log('Received WS Message: ' + msg)
|
|
198
190
|
ws.send(msg)
|
|
199
191
|
})
|
package/src/commands/test.ts
CHANGED
|
@@ -7,7 +7,7 @@ export async function doTestAsync (args: string[]): Promise<number> {
|
|
|
7
7
|
let ret = 0
|
|
8
8
|
for (const funcName of args) {
|
|
9
9
|
const result = await executeCommand('tap', [
|
|
10
|
-
`build/functions/${funcName}
|
|
10
|
+
`build/functions/${funcName}/*.test.js`,
|
|
11
11
|
/*
|
|
12
12
|
- base -- looks a lot like terse
|
|
13
13
|
- terse -- pass/fail counts
|
package/src/expressRoutes/all.ts
CHANGED
|
@@ -18,14 +18,17 @@ export function functionBinder (): void {
|
|
|
18
18
|
const projectPaths = resolvePaths()
|
|
19
19
|
|
|
20
20
|
for (const def of defs) {
|
|
21
|
-
|
|
21
|
+
const name: string = def.name
|
|
22
|
+
const pathMap: string = def.pathMap
|
|
23
|
+
let method: string = def.method
|
|
22
24
|
let rpath = ''
|
|
23
25
|
try {
|
|
24
|
-
if(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
if (method === undefined) {
|
|
27
|
+
const nstr: string = name?.toString() ?? ''
|
|
28
|
+
console.log(ac.red(`no method defined for ${nstr}`))
|
|
29
|
+
if (def.allowedMethods !== undefined) {
|
|
30
|
+
console.log(ac.bgBlack.yellowBright('DEPRECATED') + ac.blue(' As of v1.1.8, The use of ') + ac.black.italic('allowedMethods') + ac.blue(' is replaced by the single' +
|
|
31
|
+
ac.black.italic(' method ') + ac.blue('property.') + ac.black.bold('Please update your definition file')))
|
|
29
32
|
method = def.allowedMethods.split(',')[0]
|
|
30
33
|
}
|
|
31
34
|
}
|
|
@@ -63,7 +66,7 @@ export function functionBinder (): void {
|
|
|
63
66
|
} catch (e: any) {
|
|
64
67
|
// Log.Error(ac.bold.red(e.message.split('\n')[0]))0
|
|
65
68
|
// throw new Error("Unable to load and bind function code at "+ rpath)
|
|
66
|
-
Log.Error(
|
|
69
|
+
Log.Error('Unable load and bind function code', rpath)
|
|
67
70
|
Log.Exception(e)
|
|
68
71
|
}
|
|
69
72
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/* eslint @typescript-eslint/no-floating-promises: "off" */
|
|
3
3
|
|
|
4
4
|
import Tap from 'tap'
|
|
5
|
+
import { TapAssert } from '@tremho/tap-assert'
|
|
5
6
|
|
|
6
7
|
import fs from 'fs'
|
|
7
8
|
import path from 'path'
|
|
@@ -15,6 +16,7 @@ import { doPublishAsync } from '../commands/publish'
|
|
|
15
16
|
import axios from 'axios'
|
|
16
17
|
|
|
17
18
|
async function test (t: any): Promise<void> {
|
|
19
|
+
const assert = new TapAssert(t)
|
|
18
20
|
const testMessage = `test on ${Date.now()}`
|
|
19
21
|
// start clean
|
|
20
22
|
if (fs.existsSync('QSTest')) {
|
|
@@ -24,30 +26,33 @@ async function test (t: any): Promise<void> {
|
|
|
24
26
|
await doInit('QSTest', true)
|
|
25
27
|
|
|
26
28
|
// verify project got made
|
|
27
|
-
|
|
29
|
+
assert.isTrue(fs.existsSync('QSTest'), 'created test project')
|
|
28
30
|
// verify we have a functions dir
|
|
29
|
-
|
|
31
|
+
assert.isTrue(fs.existsSync(path.join('QSTest', 'functions')), 'functions exist')
|
|
30
32
|
// verify we have a node_modules dir
|
|
31
|
-
|
|
33
|
+
assert.isTrue(fs.existsSync(path.join('QSTest', 'node_modules')), 'node_modules exist')
|
|
32
34
|
// verify we have a webroot dir
|
|
33
|
-
|
|
35
|
+
assert.isTrue(fs.existsSync(path.join('QSTest', 'webroot')), 'webroot exists')
|
|
34
36
|
// verify we have a package.json
|
|
35
|
-
|
|
37
|
+
assert.isTrue(fs.existsSync(path.join('QSTest', 'package.json')), 'package.json exists')
|
|
36
38
|
// verify we have webroot/docs
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
39
|
+
assert.isTrue(fs.existsSync(path.join('QSTest', 'webroot', 'docs', 'apidoc.yaml')), 'yaml exists')
|
|
40
|
+
assert.isTrue(fs.existsSync(path.join('QSTest', 'webroot', 'docs', 'swagger-ui-bundle.js')), 'js exists')
|
|
41
|
+
assert.isTrue(fs.existsSync(path.join('QSTest', 'webroot', 'docs', 'swagger-ui-standalone-preset.js')), 'js exists')
|
|
42
|
+
assert.isTrue(fs.existsSync(path.join('QSTest', 'webroot', 'docs', 'swagger-ui.css')), 'css exists')
|
|
41
43
|
|
|
42
44
|
// create
|
|
43
45
|
process.chdir('QSTest')
|
|
44
46
|
await doCreate('IntegrationTest')
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
assert.isTrue(fs.existsSync(path.join('functions', 'IntegrationTest')), 'function exists')
|
|
48
|
+
assert.isTrue(fs.existsSync(path.join('functions', 'IntegrationTest', 'src', 'definition.json')), 'definition.json exists')
|
|
49
|
+
assert.isTrue(fs.existsSync(path.join('functions', 'IntegrationTest', 'src', 'local.ts')), 'local.ts exists')
|
|
48
50
|
const maints = path.join('functions', 'IntegrationTest', 'src', 'main.ts')
|
|
49
|
-
|
|
50
|
-
|
|
51
|
+
assert.isTrue(fs.existsSync(maints), 'main.ts exists')
|
|
52
|
+
let content = fs.readFileSync(maints).toString()
|
|
53
|
+
assert.contains(content, 'Hello, World!', 'Content has expected Hello, World! to start with')
|
|
54
|
+
content = content.replace('Hello, World!', testMessage)
|
|
55
|
+
assert.contains(content, testMessage, 'Contents successfully replaced with test message')
|
|
51
56
|
fs.writeFileSync(maints, content)
|
|
52
57
|
|
|
53
58
|
// build
|
|
@@ -60,13 +65,13 @@ async function test (t: any): Promise<void> {
|
|
|
60
65
|
const publishedJson = fs.readFileSync('.published').toString()
|
|
61
66
|
const publishedInfo = JSON.parse(publishedJson)
|
|
62
67
|
const apiUrl: string = publishedInfo.url
|
|
63
|
-
|
|
68
|
+
assert.isTrue(apiUrl.length > 0, 'url exists')
|
|
64
69
|
const testUrl = apiUrl + '/integrationtest'
|
|
65
70
|
|
|
66
71
|
const resp: any = await axios.get(testUrl)
|
|
67
|
-
|
|
72
|
+
assert.isEqual(resp.status, 200, 'status is 200')
|
|
68
73
|
const data: string = resp.data.toString()
|
|
69
|
-
|
|
74
|
+
assert.isEqual(data, testMessage, 'saw expected data')
|
|
70
75
|
|
|
71
76
|
// clean up
|
|
72
77
|
process.chdir('..')
|
|
@@ -10,12 +10,12 @@ export function recurseDirectory (dirpath: string, callback?: RecurseCB): void {
|
|
|
10
10
|
fs.readdirSync(dirpath).forEach((file: string) => {
|
|
11
11
|
const fpath = path.join(dirpath, file)
|
|
12
12
|
// if(fpath.indexOf('node_modules') === -1) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
13
|
+
const stat = fs.statSync(fpath)
|
|
14
|
+
if ((callback != null) && !callback(fpath, stat)) {
|
|
15
|
+
if (stat.isDirectory()) {
|
|
16
|
+
recurseDirectory(fpath, callback)
|
|
18
17
|
}
|
|
18
|
+
}
|
|
19
19
|
// }
|
|
20
20
|
})
|
|
21
21
|
}
|
|
@@ -51,11 +51,11 @@ export async function buildOpenApi (
|
|
|
51
51
|
|
|
52
52
|
const parameters = def.parameters ?? []
|
|
53
53
|
let method = def.method
|
|
54
|
-
if(
|
|
55
|
-
console.log(ac.red(
|
|
56
|
-
if(def.allowedMethods) {
|
|
57
|
-
console.log(ac.bgBlack.yellowBright('DEPRECATED')+ac.blue(' As of v1.1.8, The use of ')+ac.black.italic('allowedMethods')+ac.blue(' is replaced by the single' +
|
|
58
|
-
ac.black.italic(' method ')+ac.blue('property.')+ac.black.bold('Please update your definition file')))
|
|
54
|
+
if (def.method === undefined) {
|
|
55
|
+
console.log(ac.red(`no method defined for ${def.name as string}`))
|
|
56
|
+
if (def.allowedMethods !== undefined) {
|
|
57
|
+
console.log(ac.bgBlack.yellowBright('DEPRECATED') + ac.blue(' As of v1.1.8, The use of ') + ac.black.italic('allowedMethods') + ac.blue(' is replaced by the single' +
|
|
58
|
+
ac.black.italic(' method ') + ac.blue('property.') + ac.black.bold('Please update your definition file')))
|
|
59
59
|
def.method = def.allowedMethods.split(',')[0]
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -8,7 +8,7 @@ const def = JSON.parse(fs.readFileSync(path.join(__dirname, "definition.json")).
|
|
|
8
8
|
const service = new LambdaApi<any>(def,
|
|
9
9
|
async (event:any) => {
|
|
10
10
|
Log.Info("Entering Main");
|
|
11
|
-
return Success("Hello,
|
|
11
|
+
return Success("Hello, World!")
|
|
12
12
|
}
|
|
13
13
|
)
|
|
14
14
|
export function start(e:any, c:any, cb:any) {
|
|
@@ -1,11 +1,37 @@
|
|
|
1
1
|
|
|
2
2
|
import Tap from "tap"
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
import {start} from './src/main'
|
|
4
|
+
import {TapAssert} from '@tremho/tap-assert'
|
|
5
|
+
import path from 'path'
|
|
6
|
+
|
|
7
|
+
async function test(t:any) {
|
|
8
|
+
|
|
9
|
+
const assert = new TapAssert(t);
|
|
10
|
+
|
|
11
|
+
// empty event defaults. change this if you want to pass other request values for testing
|
|
12
|
+
const event= {
|
|
13
|
+
request: {
|
|
14
|
+
originalUrl: ''
|
|
15
|
+
},
|
|
16
|
+
// stage: '',
|
|
17
|
+
cookies: {},
|
|
18
|
+
parameters: {},
|
|
19
|
+
headers: {}
|
|
20
|
+
// body: ''
|
|
21
|
+
}
|
|
22
|
+
const resp = await start(event, {}, null)
|
|
23
|
+
|
|
24
|
+
// Tests for the 'Hello, World!' placeholder response
|
|
25
|
+
assert.isType(resp, 'object', 'response is an object')
|
|
26
|
+
assert.isEqual(resp.statusCode, 200, 'Success response')
|
|
27
|
+
assert.isEqual(resp.headers['content-type'], 'text/plain', 'plain text content')
|
|
28
|
+
assert.isType(resp.body, 'string', 'Response has a body')
|
|
29
|
+
assert.isFalse(resp.isBase64Encoded, 'result not binary')
|
|
30
|
+
assert.meetsConstraints(resp.body, 'startsWith=Hello', 'content appears correct')
|
|
5
31
|
|
|
6
32
|
t.end()
|
|
7
33
|
|
|
8
34
|
}
|
|
9
|
-
Tap.test(
|
|
35
|
+
Tap.test(path.basename(__filename), t => {
|
|
10
36
|
test(t)
|
|
11
37
|
})
|