@tremho/mist-lift 1.0.2-pre-release.4 → 1.0.2-pre-release.5
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/build/commands/actions/initQuestions.js +24 -22
- package/build/commands/actions/initQuestions.js.map +1 -1
- package/build/commands/actions/setupPackageJson.js +4 -4
- package/build/commands/actions/setupPackageJson.js.map +1 -1
- package/build/commands/build.js +31 -25
- package/build/commands/build.js.map +1 -1
- package/build/commands/builtin/ApiDocMaker.js +60 -23
- package/build/commands/builtin/ApiDocMaker.js.map +1 -1
- package/build/commands/builtin/BuiltInHandler.js +6 -6
- package/build/commands/builtin/BuiltInHandler.js.map +1 -1
- package/build/commands/builtin/DeployBuiltInZip.js +4 -4
- package/build/commands/builtin/DeployBuiltInZip.js.map +1 -1
- package/build/commands/builtin/StageWebrootZip.js +1 -0
- package/build/commands/builtin/StageWebrootZip.js.map +1 -1
- package/build/commands/create.js +10 -11
- package/build/commands/create.js.map +1 -1
- package/build/commands/deploy.js +38 -42
- package/build/commands/deploy.js.map +1 -1
- package/build/commands/doctor.js +38 -37
- package/build/commands/doctor.js.map +1 -1
- package/build/commands/help.js +93 -93
- package/build/commands/help.js.map +1 -1
- package/build/commands/init.js +7 -7
- package/build/commands/init.js.map +1 -1
- package/build/commands/package.js +50 -51
- package/build/commands/package.js.map +1 -1
- package/build/commands/publish.js +98 -102
- package/build/commands/publish.js.map +1 -1
- package/build/commands/settings.js +19 -18
- package/build/commands/settings.js.map +1 -1
- package/build/commands/start.js +4 -4
- package/build/commands/start.js.map +1 -1
- package/build/commands/test.js +3 -3
- package/build/commands/test.js.map +1 -1
- package/build/commands/user.js +1 -1
- package/build/commands/user.js.map +1 -1
- package/build/expressRoutes/all.js +27 -26
- package/build/expressRoutes/all.js.map +1 -1
- package/build/expressRoutes/api.js +9 -7
- package/build/expressRoutes/api.js.map +1 -1
- package/build/expressRoutes/functionBinder.js +38 -36
- package/build/expressRoutes/functionBinder.js.map +1 -1
- package/build/lib/CaseUtils.js +2 -2
- package/build/lib/CaseUtils.js.map +1 -1
- package/build/lib/DirectoryUtils.js +4 -3
- package/build/lib/DirectoryUtils.js.map +1 -1
- package/build/lib/LiftConfig.js +18 -20
- package/build/lib/LiftConfig.js.map +1 -1
- package/build/lib/LiftVersion.js +17 -12
- package/build/lib/LiftVersion.js.map +1 -1
- package/build/lib/Tests/fileCompare.test.js +11 -10
- package/build/lib/Tests/fileCompare.test.js.map +1 -1
- package/build/lib/askQuestion.js +3 -2
- package/build/lib/askQuestion.js.map +1 -1
- package/build/lib/executeCommand.js +46 -33
- package/build/lib/executeCommand.js.map +1 -1
- package/build/lib/fileCompare.js +9 -8
- package/build/lib/fileCompare.js.map +1 -1
- package/build/lib/openAPI/ApiBuildCollector.js +9 -8
- package/build/lib/openAPI/ApiBuildCollector.js.map +1 -1
- package/build/lib/openAPI/WebrootFileSupport.js +4 -3
- package/build/lib/openAPI/WebrootFileSupport.js.map +1 -1
- package/build/lib/openAPI/openApiConstruction.js +62 -61
- package/build/lib/openAPI/openApiConstruction.js.map +1 -1
- package/build/lib/pathResolve.js +4 -4
- package/build/lib/pathResolve.js.map +1 -1
- package/build/lib/utils.js +5 -4
- package/build/lib/utils.js.map +1 -1
- package/build/lift.js +14 -15
- package/build/lift.js.map +1 -1
- package/package.json +2 -1
- package/src/commands/actions/initQuestions.ts +112 -112
- package/src/commands/actions/setupPackageJson.ts +21 -25
- package/src/commands/build.ts +143 -146
- package/src/commands/builtin/ApiDocMaker.ts +86 -54
- package/src/commands/builtin/BuiltInHandler.ts +31 -35
- package/src/commands/builtin/DeployBuiltInZip.ts +15 -17
- package/src/commands/builtin/StageWebrootZip.ts +29 -32
- package/src/commands/create.ts +40 -47
- package/src/commands/deploy.ts +139 -152
- package/src/commands/doctor.ts +86 -82
- package/src/commands/help.ts +152 -153
- package/src/commands/init.ts +37 -39
- package/src/commands/package.ts +201 -204
- package/src/commands/publish.ts +277 -312
- package/src/commands/settings.ts +67 -70
- package/src/commands/start.ts +32 -37
- package/src/commands/test.ts +15 -16
- package/src/commands/user.ts +1 -1
- package/src/expressRoutes/all.ts +73 -78
- package/src/expressRoutes/api.ts +14 -16
- package/src/expressRoutes/functionBinder.ts +144 -151
- package/src/lib/CaseUtils.ts +49 -54
- package/src/lib/DirectoryUtils.ts +25 -27
- package/src/lib/LiftConfig.ts +46 -54
- package/src/lib/LiftVersion.ts +69 -77
- package/src/lib/Tests/fileCompare.test.ts +27 -26
- package/src/lib/askQuestion.ts +12 -13
- package/src/lib/executeCommand.ts +40 -33
- package/src/lib/fileCompare.ts +46 -37
- package/src/lib/openAPI/ApiBuildCollector.ts +36 -36
- package/src/lib/openAPI/WebrootFileSupport.ts +15 -17
- package/src/lib/openAPI/openApiConstruction.ts +169 -175
- package/src/lib/pathResolve.ts +22 -28
- package/src/lib/utils.ts +31 -33
- package/src/lift.ts +68 -67
package/src/lib/LiftVersion.ts
CHANGED
|
@@ -1,95 +1,87 @@
|
|
|
1
1
|
|
|
2
2
|
import * as path from 'path'
|
|
3
3
|
import * as fs from 'fs'
|
|
4
|
-
import {resolvePaths} from
|
|
4
|
+
import { resolvePaths } from './pathResolve'
|
|
5
5
|
|
|
6
|
-
export class VersionInfo
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
public suffix:string = "";
|
|
6
|
+
export class VersionInfo {
|
|
7
|
+
public major: number = 0
|
|
8
|
+
public minor: number = 0
|
|
9
|
+
public revision: number = 0
|
|
10
|
+
public suffix: string = ''
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
12
|
+
constructor (vstr: string) {
|
|
13
|
+
this.parse(vstr)
|
|
14
|
+
}
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this.major = parseInt(parts[0])
|
|
30
|
-
this.minor = parseInt(parts[1]);
|
|
31
|
-
this.revision = parseInt(parts[2]);
|
|
32
|
-
if(!isFinite(this.major)) this.major = 0;
|
|
33
|
-
if(!isFinite(this.minor)) this.minor = 0;
|
|
34
|
-
if(!isFinite(this.revision)) this.revision = 0;
|
|
35
|
-
this.suffix = suffix;
|
|
36
|
-
}
|
|
37
|
-
public equals(other: VersionInfo | string): boolean
|
|
38
|
-
{
|
|
39
|
-
// Note: not really a valid SemVer comparison
|
|
40
|
-
if(typeof other === 'string') other = new VersionInfo(other);
|
|
41
|
-
return this.major === other.major
|
|
42
|
-
&& this.minor === other.minor
|
|
43
|
-
&& this.revision === other.revision
|
|
44
|
-
}
|
|
45
|
-
public isGreaterThan(other:VersionInfo | string): boolean
|
|
46
|
-
{
|
|
47
|
-
// Note: not really a valid SemVer comparison
|
|
48
|
-
if(typeof other === 'string') other = new VersionInfo(other);
|
|
49
|
-
if(this.major > other.major) return true;
|
|
50
|
-
if(this.major < other.major) return false;
|
|
51
|
-
if(this.minor > other.minor) return true;
|
|
52
|
-
if(this.minor < other.minor) return false;
|
|
53
|
-
return (this.revision > other.revision);
|
|
16
|
+
public toString = (): string => {
|
|
17
|
+
let sfx = ''
|
|
18
|
+
if (this.suffix !== '') sfx = '-' + this.suffix
|
|
19
|
+
return `${this.major}.${this.minor}.${this.revision}${sfx}`
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public parse = (vstr: string): VersionInfo => {
|
|
23
|
+
const sn = vstr.indexOf('-')
|
|
24
|
+
let suffix = ''
|
|
25
|
+
if (sn !== -1) {
|
|
26
|
+
suffix = vstr.substring(sn + 1)
|
|
27
|
+
vstr = vstr.substring(0, sn)
|
|
54
28
|
}
|
|
29
|
+
const parts = vstr.split('.')
|
|
30
|
+
while (parts.length < 3) parts.push('0')
|
|
31
|
+
this.major = parseInt(parts[0])
|
|
32
|
+
this.minor = parseInt(parts[1])
|
|
33
|
+
this.revision = parseInt(parts[2])
|
|
34
|
+
if (!isFinite(this.major)) this.major = 0
|
|
35
|
+
if (!isFinite(this.minor)) this.minor = 0
|
|
36
|
+
if (!isFinite(this.revision)) this.revision = 0
|
|
37
|
+
this.suffix = suffix
|
|
38
|
+
return this
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public equals (other: VersionInfo | string): boolean {
|
|
42
|
+
// Note: not really a valid SemVer comparison
|
|
43
|
+
if (typeof other === 'string') other = new VersionInfo(other)
|
|
44
|
+
return this.major === other.major &&
|
|
45
|
+
this.minor === other.minor &&
|
|
46
|
+
this.revision === other.revision
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public isGreaterThan (other: VersionInfo | string): boolean {
|
|
50
|
+
// Note: not really a valid SemVer comparison
|
|
51
|
+
if (typeof other === 'string') other = new VersionInfo(other)
|
|
52
|
+
if (this.major > other.major) return true
|
|
53
|
+
if (this.major < other.major) return false
|
|
54
|
+
if (this.minor > other.minor) return true
|
|
55
|
+
if (this.minor < other.minor) return false
|
|
56
|
+
return (this.revision > other.revision)
|
|
57
|
+
}
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
// read version from Lift's package.json
|
|
58
|
-
export function getLiftVersion()
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
return readPackageVersion(pkg);
|
|
62
|
-
|
|
61
|
+
export function getLiftVersion (): VersionInfo {
|
|
62
|
+
const pkg = path.join(__dirname, '..', '..', 'package.json')
|
|
63
|
+
return readPackageVersion(pkg)
|
|
63
64
|
}
|
|
64
65
|
// read version from project's package.json
|
|
65
|
-
export function getProjectVersion()
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return readPackageVersion(projectPaths.packagePath)
|
|
69
|
-
|
|
66
|
+
export function getProjectVersion (): VersionInfo {
|
|
67
|
+
const projectPaths = resolvePaths()
|
|
68
|
+
return readPackageVersion(projectPaths.packagePath)
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
export function getProjectName()
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
catch(e) {}
|
|
80
|
-
return pkgJson.name;
|
|
71
|
+
export function getProjectName (): string {
|
|
72
|
+
const projectPaths = resolvePaths()
|
|
73
|
+
let pkgJson: { name?: string } = {}
|
|
74
|
+
try {
|
|
75
|
+
pkgJson = JSON.parse(fs.readFileSync(projectPaths.packagePath).toString())
|
|
76
|
+
} catch (e) {}
|
|
77
|
+
return pkgJson.name ?? ''
|
|
81
78
|
}
|
|
82
79
|
|
|
83
|
-
function readPackageVersion(pkgPath:string):VersionInfo
|
|
84
|
-
{
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
catch(e) {}
|
|
90
|
-
|
|
91
|
-
return new VersionInfo(pkgJson.version ?? "")
|
|
80
|
+
function readPackageVersion (pkgPath: string): VersionInfo {
|
|
81
|
+
let pkgJson: { version?: string } = {}
|
|
82
|
+
try {
|
|
83
|
+
pkgJson = JSON.parse(fs.readFileSync(pkgPath).toString())
|
|
84
|
+
} catch (e) {}
|
|
92
85
|
|
|
86
|
+
return new VersionInfo(pkgJson.version ?? '')
|
|
93
87
|
}
|
|
94
|
-
|
|
95
|
-
|
|
@@ -1,34 +1,35 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
2
|
+
/* eslint @typescript-eslint/no-floating-promises: "off" */
|
|
3
3
|
|
|
4
|
-
import
|
|
5
|
-
import {isNewer, isNewerFile} from "../fileCompare";
|
|
4
|
+
import Tap from 'tap'
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
import * as path from 'path'
|
|
7
|
+
import { isNewerFile } from '../fileCompare'
|
|
8
8
|
|
|
9
|
+
function test (t: any): void {
|
|
9
10
|
// ./dir1/file.1 551 < ./dir2/file.1 552
|
|
10
|
-
// ./dir1/file.2 553 > ./dir2/file.1 552
|
|
11
|
-
// ./dir1 553 > ./dir2 552
|
|
12
|
-
// .dir1 (.1) 552 < ./dir2 552
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
t.end()
|
|
11
|
+
// ./dir1/file.2 553 > ./dir2/file.1 552
|
|
12
|
+
// ./dir1 553 > ./dir2 552
|
|
13
|
+
// .dir1 (.1) 552 < ./dir2 552
|
|
14
|
+
|
|
15
|
+
const dir1 = path.join(__dirname, 'dir1')
|
|
16
|
+
const dir2 = path.join(__dirname, 'dir2')
|
|
17
|
+
const dir1File1 = path.join(dir1, 'file.1')
|
|
18
|
+
const dir1File2 = path.join(dir1, 'file.2')
|
|
19
|
+
const dir2File1 = path.join(dir2, 'file.1')
|
|
20
|
+
|
|
21
|
+
let newer = isNewerFile(dir1File1, dir2File1)
|
|
22
|
+
t.equal(newer, false, './dir1/file.1 < ./dir2/file.1')
|
|
23
|
+
newer = isNewerFile(dir1File2, dir2File1)
|
|
24
|
+
t.equal(newer, true, './dir1/file.2 > ./dir2/file.1')
|
|
25
|
+
newer = isNewerFile(dir1, dir2)
|
|
26
|
+
t.ok(newer, 'dir1 > dir2')
|
|
27
|
+
newer = isNewerFile(dir1, dir2, '.1')
|
|
28
|
+
t.ok(!newer, './dir1 (.1) < ./dir2')
|
|
29
|
+
|
|
30
|
+
t.end()
|
|
31
31
|
}
|
|
32
|
+
|
|
32
33
|
Tap.test('IsNewer', t => {
|
|
33
|
-
|
|
34
|
+
test(t)
|
|
34
35
|
})
|
package/src/lib/askQuestion.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
/** handles interaction for asking a question */
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/* eslint @typescript-eslint/no-var-requires: "off" */
|
|
4
|
+
import * as ac from 'ansi-colors'
|
|
5
|
+
const readlineSync = require('readline-sync')
|
|
5
6
|
|
|
6
|
-
export function ask(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
export function ask (
|
|
8
|
+
desc: string, // describes the context
|
|
9
|
+
query: string, // asks the actual question
|
|
10
|
+
def: string // default answer
|
|
10
11
|
|
|
11
|
-
)
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return answer
|
|
12
|
+
): string { // answer provided
|
|
13
|
+
console.log(ac.dim.blue.italic(desc))
|
|
14
|
+
let answer = readlineSync.question(ac.bold.green(query) + ac.dim.grey(` [${def}] `) + '? ')
|
|
15
|
+
if (answer === '') answer = def
|
|
16
|
+
return answer
|
|
17
17
|
}
|
|
18
|
-
|
|
@@ -1,38 +1,45 @@
|
|
|
1
1
|
|
|
2
|
-
import {exec} from 'child_process'
|
|
3
|
-
import * as path from 'path'
|
|
2
|
+
import { exec } from 'child_process'
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
interface StringObject {
|
|
5
|
+
toString: () => string
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export async function executeCommand (cmd: string, args: any[], cwd = '', consolePass = false, env: any = {}): Promise<any> {
|
|
9
|
+
const out = {
|
|
10
|
+
stdStr: '',
|
|
11
|
+
errStr: '',
|
|
12
|
+
retcode: 0
|
|
13
|
+
}
|
|
14
|
+
return await new Promise(resolve => {
|
|
15
|
+
const cmdstr = cmd + ' ' + args.join(' ')
|
|
16
|
+
// console.log('executing ', cmdstr, 'at', cwd)
|
|
17
|
+
const opts = {
|
|
18
|
+
cwd,
|
|
19
|
+
env: Object.assign(env, process.env)
|
|
20
|
+
}
|
|
21
|
+
const proc = exec(cmdstr, opts)
|
|
22
|
+
if (proc.stdout != null) {
|
|
23
|
+
proc.stdout.on('data', (data: StringObject) => {
|
|
24
|
+
out.stdStr += data.toString()
|
|
25
|
+
if (consolePass) process.stdout.write(data.toString())
|
|
26
|
+
})
|
|
10
27
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
})
|
|
27
|
-
proc.on('error', error => {
|
|
28
|
-
console.error(error)
|
|
29
|
-
if(!out.errStr) out.errStr = error.message
|
|
30
|
-
out.retcode = -1
|
|
31
|
-
resolve(out)
|
|
32
|
-
})
|
|
33
|
-
proc.on('close', code => {
|
|
34
|
-
out.retcode = code === null ? -1 : code
|
|
35
|
-
resolve(out)
|
|
36
|
-
})
|
|
28
|
+
if (proc.stderr != null) {
|
|
29
|
+
proc.stderr.on('data', (data: StringObject) => {
|
|
30
|
+
out.errStr += data.toString()
|
|
31
|
+
if (consolePass) process.stdout.write(data.toString())
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
proc.on('error', error => {
|
|
35
|
+
console.error(error)
|
|
36
|
+
if (out.errStr === '') out.errStr = error.message
|
|
37
|
+
out.retcode = -1
|
|
38
|
+
resolve(out)
|
|
39
|
+
})
|
|
40
|
+
proc.on('close', code => {
|
|
41
|
+
out.retcode = code === null ? -1 : code
|
|
42
|
+
resolve(out)
|
|
37
43
|
})
|
|
44
|
+
})
|
|
38
45
|
}
|
package/src/lib/fileCompare.ts
CHANGED
|
@@ -1,46 +1,55 @@
|
|
|
1
|
-
import path from
|
|
2
|
-
import fs from
|
|
3
|
-
import {recurseDirectory} from
|
|
1
|
+
import path from 'path'
|
|
2
|
+
import fs from 'fs'
|
|
3
|
+
import { recurseDirectory } from './DirectoryUtils'
|
|
4
4
|
|
|
5
5
|
// true if filepath > mapped file in outDir (i.e. .ts > .js)
|
|
6
|
-
export function isNewer(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
export function isNewer (
|
|
7
|
+
filepath: string,
|
|
8
|
+
outDir: string,
|
|
9
|
+
mappingObj: any = { '.ts': '.js' }
|
|
10
|
+
): boolean {
|
|
11
|
+
let basename = path.basename(filepath)
|
|
12
|
+
const ext = path.extname(filepath)
|
|
13
|
+
basename = basename.substring(0, basename.lastIndexOf(ext))
|
|
14
|
+
let newExt = ''
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
if (mappingObj[ext] !== undefined) newExt = mappingObj[ext]
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
const outfile = path.join(outDir, basename + newExt)
|
|
19
|
+
return isNewerFile(filepath, outfile)
|
|
17
20
|
}
|
|
18
21
|
|
|
19
22
|
// true if filepath is newer than destpath
|
|
20
|
-
export function isNewerFile(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
export function isNewerFile (
|
|
24
|
+
filepath: string,
|
|
25
|
+
destpath: string,
|
|
26
|
+
srcFilter: string = '',
|
|
27
|
+
dstFilter: string = ''
|
|
28
|
+
): boolean {
|
|
29
|
+
const sstat = fs.statSync(filepath)
|
|
30
|
+
const srcTime = sstat.isDirectory() ? latestInDirectory(filepath, srcFilter) : fs.statSync(filepath).mtime
|
|
31
|
+
let destTime = new Date(0)
|
|
32
|
+
if (fs.existsSync((destpath))) {
|
|
33
|
+
const dstat = fs.statSync(destpath)
|
|
34
|
+
destTime = dstat.isDirectory() ? latestInDirectory(destpath, dstFilter) : fs.statSync(destpath).mtime
|
|
35
|
+
}
|
|
36
|
+
return (srcTime >= destTime)
|
|
30
37
|
}
|
|
31
|
-
function latestInDirectory(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
38
|
+
function latestInDirectory (
|
|
39
|
+
dirPath: string,
|
|
40
|
+
extFilter: string = ''
|
|
41
|
+
): Date {
|
|
42
|
+
let newestTime = new Date(0)
|
|
43
|
+
recurseDirectory(dirPath, (filepath, stats) => {
|
|
44
|
+
if (stats.isFile()) {
|
|
45
|
+
const ext = path.extname(filepath)
|
|
46
|
+
if ((extFilter ?? '') === '' || ext === extFilter) {
|
|
47
|
+
if (stats.mtime > newestTime) {
|
|
48
|
+
newestTime = stats.mtime
|
|
42
49
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return false
|
|
53
|
+
})
|
|
54
|
+
return newestTime
|
|
55
|
+
}
|
|
@@ -5,43 +5,43 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import fs from 'fs'
|
|
7
7
|
import path from 'path'
|
|
8
|
-
import {recurseDirectory} from
|
|
9
|
-
import {resolvePaths} from
|
|
8
|
+
import { recurseDirectory } from '../DirectoryUtils'
|
|
9
|
+
import { resolvePaths } from '../pathResolve'
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
}
|
|
11
|
+
export function gatherFunctionDefinitions (): any[] {
|
|
12
|
+
const defs: any = []
|
|
13
|
+
try {
|
|
14
|
+
const projectPaths = resolvePaths()
|
|
15
|
+
if (!projectPaths.verified) return []
|
|
16
|
+
const funcNames: string[] = []
|
|
17
|
+
if (!fs.existsSync(projectPaths.functionPath)) return []
|
|
18
|
+
let firstDepth = 0
|
|
19
|
+
recurseDirectory(projectPaths.functionPath, (filepath, stats) => {
|
|
20
|
+
if (stats.isDirectory()) {
|
|
21
|
+
const depth = filepath.split(path.sep).length
|
|
22
|
+
if (firstDepth === 0) firstDepth = depth
|
|
23
|
+
if (firstDepth === depth) {
|
|
24
|
+
funcNames.push(path.basename(filepath))
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return false
|
|
28
|
+
})
|
|
29
|
+
if (projectPaths.functionPath.includes('functions')) {
|
|
30
|
+
for (const name of funcNames) {
|
|
31
|
+
const defPath = path.join(projectPaths.functionPath, name, 'src', 'definition.json')
|
|
32
|
+
if (fs.existsSync(defPath)) {
|
|
33
|
+
const content = fs.readFileSync(defPath).toString()
|
|
34
|
+
// const buildPath = path.join(projectPaths.buildPath, 'functions', name, 'src', 'definition.json')
|
|
35
|
+
// fs.writeFileSync(buildPath, content); // use this opportunity to copy to build folder before we use it.
|
|
36
|
+
defs.push(JSON.parse(content))
|
|
37
|
+
} else {
|
|
38
|
+
console.error(`Definition file not found at ${defPath}`)
|
|
39
|
+
return []
|
|
42
40
|
}
|
|
43
|
-
|
|
44
|
-
console.error("Exception in ApiBuildCollector", e)
|
|
41
|
+
}
|
|
45
42
|
}
|
|
46
|
-
|
|
43
|
+
} catch (e: any) {
|
|
44
|
+
console.error('Exception in ApiBuildCollector', e)
|
|
45
|
+
}
|
|
46
|
+
return defs
|
|
47
47
|
}
|
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
|
|
2
2
|
import * as path from 'path'
|
|
3
|
-
import {resolvePaths} from
|
|
4
|
-
import {recurseDirectory} from
|
|
3
|
+
import { resolvePaths } from '../pathResolve'
|
|
4
|
+
import { recurseDirectory } from '../DirectoryUtils'
|
|
5
5
|
|
|
6
|
+
export function GetWebrootServePaths (): string[] {
|
|
7
|
+
const projectPaths = resolvePaths()
|
|
8
|
+
const webroot = path.join(projectPaths.basePath, 'webroot')
|
|
6
9
|
|
|
7
|
-
|
|
8
|
-
{
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if(list.indexOf(relpath) === -1) list.push(relpath);
|
|
18
|
-
}
|
|
19
|
-
})
|
|
20
|
-
return list;
|
|
21
|
-
}
|
|
10
|
+
const list: string[] = ['']
|
|
11
|
+
recurseDirectory(webroot, (filepath, stats) => {
|
|
12
|
+
if (stats.isDirectory()) {
|
|
13
|
+
const relpath = filepath.substring(webroot.length)
|
|
14
|
+
if (!list.includes(relpath)) list.push(relpath)
|
|
15
|
+
}
|
|
16
|
+
return false
|
|
17
|
+
})
|
|
18
|
+
return list
|
|
19
|
+
}
|