@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/commands/package.ts
CHANGED
|
@@ -1,228 +1,225 @@
|
|
|
1
1
|
|
|
2
|
-
import path from
|
|
3
|
-
import fs, {Stats} from
|
|
4
|
-
import {resolvePaths} from
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import fs, { Stats } from 'fs'
|
|
4
|
+
import { resolvePaths } from '../lib/pathResolve'
|
|
5
5
|
|
|
6
|
-
import * as ac from
|
|
6
|
+
import * as ac from 'ansi-colors'
|
|
7
7
|
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {doBuildAsync} from "./build";
|
|
15
|
-
import {runMain} from "tap";
|
|
8
|
+
import { recurseDirectory } from '../lib/DirectoryUtils'
|
|
9
|
+
import { getLiftVersion, getProjectName, getProjectVersion } from '../lib/LiftVersion'
|
|
10
|
+
import { executeCommand } from '../lib/executeCommand'
|
|
11
|
+
import { isNewerFile } from '../lib/fileCompare'
|
|
12
|
+
import { doBuildAsync } from './build'
|
|
13
|
+
import { FolderToZip } from '../lib/utils'
|
|
16
14
|
|
|
17
15
|
// test then package
|
|
18
|
-
export async function doPackageAsync(
|
|
19
|
-
|
|
16
|
+
export async function doPackageAsync (
|
|
17
|
+
args: string[]
|
|
20
18
|
): Promise<number> {
|
|
19
|
+
const projectPaths = resolvePaths()
|
|
20
|
+
const workPath = path.join(projectPaths.basePath, '.package_temp')
|
|
21
|
+
|
|
22
|
+
if (fs.existsSync(workPath)) fs.rmSync(workPath, { recursive: true })
|
|
23
|
+
fs.mkdirSync(workPath)
|
|
24
|
+
|
|
25
|
+
const buildFunctionsPath = path.join(projectPaths.buildPath, 'functions')
|
|
26
|
+
|
|
27
|
+
const funcsToPackage: string[] = []
|
|
28
|
+
const options: string[] = []
|
|
29
|
+
for (const arg of args) {
|
|
30
|
+
if (arg.charAt(0) === '-') {
|
|
31
|
+
options.push(arg.toLowerCase())
|
|
32
|
+
} else funcsToPackage.push(arg)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const ret = await doBuildAsync(args)
|
|
36
|
+
if (ret !== 0) return ret
|
|
37
|
+
|
|
38
|
+
if (funcsToPackage.length === 0) {
|
|
39
|
+
let firstDepth = 0
|
|
40
|
+
recurseDirectory(buildFunctionsPath, (filepath, stats) => {
|
|
41
|
+
const depth = filepath.split(path.sep).length
|
|
42
|
+
if (firstDepth === 0) firstDepth = depth
|
|
43
|
+
if (stats.isDirectory() && depth === firstDepth) {
|
|
44
|
+
funcsToPackage.push(path.basename(filepath))
|
|
45
|
+
}
|
|
46
|
+
return false
|
|
47
|
+
})
|
|
48
|
+
}
|
|
21
49
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
if (fs.existsSync(workPath)) fs.rmSync(workPath, {recursive: true})
|
|
26
|
-
fs.mkdirSync(workPath)
|
|
27
|
-
|
|
28
|
-
const buildFunctionsPath = path.join(projectPaths.buildPath, 'functions')
|
|
50
|
+
const all: Array<Promise<any>> = []
|
|
51
|
+
const error = 0
|
|
29
52
|
|
|
53
|
+
for (const funcName of funcsToPackage) {
|
|
54
|
+
all.push(packageFunction(funcName))
|
|
55
|
+
}
|
|
56
|
+
return await Promise.all(all).then(() => {
|
|
57
|
+
return error
|
|
58
|
+
})
|
|
59
|
+
}
|
|
30
60
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
61
|
+
async function packageFunction (funcName: string): Promise<number> {
|
|
62
|
+
const projectPaths = resolvePaths()
|
|
63
|
+
const buildFunctionsPath = path.join(projectPaths.buildPath, 'functions')
|
|
64
|
+
const all: Array<Promise<any>> = []
|
|
65
|
+
const error = 0
|
|
66
|
+
const funcPath = path.join(buildFunctionsPath, funcName)
|
|
67
|
+
if (!fs.existsSync(funcPath)) {
|
|
68
|
+
console.error(ac.red.bold(`${funcName} does not exist`) + ', cannot package')
|
|
69
|
+
return -1
|
|
70
|
+
}
|
|
71
|
+
const zipdir = path.join(projectPaths.basePath, 'MistLift_Zips')
|
|
72
|
+
const zipFile = path.join(zipdir, funcName + '.zip')
|
|
73
|
+
|
|
74
|
+
if (!fs.existsSync(zipdir)) {
|
|
75
|
+
fs.mkdirSync(zipdir)
|
|
76
|
+
}
|
|
77
|
+
const zfx = fs.existsSync(zipFile)
|
|
78
|
+
if (zfx) {
|
|
79
|
+
if (!isNewerFile(funcPath, zipFile, '.js', '.zip')) {
|
|
80
|
+
return 0
|
|
37
81
|
}
|
|
82
|
+
fs.unlinkSync(zipFile)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const projectName = getProjectName() ?? ''
|
|
86
|
+
const projectVersion = getProjectVersion()?.toString() ?? ''
|
|
87
|
+
const liftVersion = getLiftVersion()?.toString() ?? ''
|
|
88
|
+
|
|
89
|
+
// the main package json that has all imports
|
|
90
|
+
const mainPkgJsonPath = path.join(projectPaths.packagePath)
|
|
91
|
+
const mainPkgSrc = fs.readFileSync(mainPkgJsonPath).toString()
|
|
92
|
+
const mainPkgJson = JSON.parse(mainPkgSrc)
|
|
93
|
+
const workPath = path.join(projectPaths.basePath, '.package_temp')
|
|
94
|
+
|
|
95
|
+
console.log(ac.green.italic('packaging ') + ac.green.bold(funcName))
|
|
96
|
+
|
|
97
|
+
// make a nominal package.json
|
|
98
|
+
const pkgjson = {
|
|
99
|
+
name: funcName,
|
|
100
|
+
description: 'Lambda function ' + funcName + ' for ' + projectName + ', created with MistLift ' + liftVersion,
|
|
101
|
+
version: projectVersion,
|
|
102
|
+
main: 'runmain.mjs',
|
|
103
|
+
scripts: {
|
|
104
|
+
test: 'echo "No Tests Defined" && exit 1'
|
|
105
|
+
},
|
|
106
|
+
dependencies: {},
|
|
107
|
+
keywords: [],
|
|
108
|
+
author: '',
|
|
109
|
+
license: 'MIT'
|
|
110
|
+
}
|
|
111
|
+
// find all the imports in the sources
|
|
112
|
+
const imports = findAllImports(funcPath)
|
|
113
|
+
pkgjson.dependencies = reconcileVersionImports(imports, mainPkgJson)
|
|
114
|
+
// - write out new package.json to workPath
|
|
115
|
+
// console.log("writing package.json", pkgjson)
|
|
116
|
+
fs.writeFileSync(path.join(workPath, 'package.json'), JSON.stringify(pkgjson, null, 2))
|
|
117
|
+
// - execute npm i at workpath, create node_modules
|
|
118
|
+
await executeCommand('npm i', [], workPath).then(() => {
|
|
119
|
+
// copy the lambda function
|
|
120
|
+
recurseDirectory(funcPath, (filepath: string, stats: Stats) => {
|
|
121
|
+
if (filepath.substring(0, funcPath.length) === funcPath) {
|
|
122
|
+
const endpath = filepath.substring(funcPath.length)
|
|
123
|
+
if (!endpath.toLowerCase().includes(`${funcName}-tests`.toLowerCase())) { // skip tests
|
|
124
|
+
const fromPath = path.join(funcPath, endpath)
|
|
125
|
+
const toPath = path.join(workPath, endpath)
|
|
126
|
+
if (stats.isDirectory() && !fs.existsSync(toPath)) {
|
|
127
|
+
fs.mkdirSync(toPath)
|
|
128
|
+
}
|
|
129
|
+
if (stats.isFile()) {
|
|
130
|
+
fs.copyFileSync(fromPath, toPath)
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
return false
|
|
135
|
+
})
|
|
38
136
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
let firstDepth = 0
|
|
44
|
-
recurseDirectory(buildFunctionsPath, (filepath, stats) => {
|
|
45
|
-
let depth = filepath.split(path.sep).length
|
|
46
|
-
if (!firstDepth) firstDepth = depth
|
|
47
|
-
if (stats.isDirectory() && depth == firstDepth) {
|
|
48
|
-
funcsToPackage.push(path.basename(filepath))
|
|
49
|
-
}
|
|
50
|
-
})
|
|
51
|
-
}
|
|
137
|
+
// put a runmain.mjs into place
|
|
138
|
+
const templatePath = path.join(__dirname, '..', '..', 'templateData', 'function-runmain-mjs')
|
|
139
|
+
const runmainPath = path.join(workPath, 'runmain.mjs')
|
|
140
|
+
fs.writeFileSync(runmainPath, fs.readFileSync(templatePath))
|
|
52
141
|
|
|
53
|
-
|
|
54
|
-
|
|
142
|
+
all.push(FolderToZip(workPath, zipFile))
|
|
143
|
+
// console.log("now zip it")
|
|
144
|
+
})
|
|
55
145
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return Promise.all(all).then(() => {
|
|
60
|
-
return error;
|
|
61
|
-
})
|
|
146
|
+
return await Promise.all(all).then(() => {
|
|
147
|
+
return error
|
|
148
|
+
})
|
|
62
149
|
}
|
|
63
150
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const zipFile = path.join(zipdir, funcName + '.zip')
|
|
77
|
-
|
|
78
|
-
if (!fs.existsSync(zipdir)) {
|
|
79
|
-
fs.mkdirSync(zipdir)
|
|
80
|
-
}
|
|
81
|
-
let zfx = fs.existsSync(zipFile)
|
|
82
|
-
if (!zfx) {
|
|
83
|
-
} else {
|
|
84
|
-
if (!isNewerFile(funcPath, zipFile, ".js", ".zip")) {
|
|
85
|
-
return 0;
|
|
151
|
+
function findAllImports (folder: string): string[] {
|
|
152
|
+
const imports: string[] = []
|
|
153
|
+
if (fs.existsSync(folder)) {
|
|
154
|
+
recurseDirectory(folder, (filepath, stats) => {
|
|
155
|
+
// console.log(`filepath = ${filepath}`);
|
|
156
|
+
if (!filepath.includes('__files__')) {
|
|
157
|
+
if (!stats.isDirectory()) {
|
|
158
|
+
const content = fs.readFileSync(filepath).toString()
|
|
159
|
+
for (const m of findImports(content)) {
|
|
160
|
+
// console.log(' import', m)
|
|
161
|
+
imports.push(m)
|
|
162
|
+
}
|
|
86
163
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
const projectName = getProjectName()
|
|
91
|
-
const projectVersion = getProjectVersion()
|
|
92
|
-
const liftVersion = getLiftVersion()
|
|
93
|
-
|
|
94
|
-
// the main package json that has all imports
|
|
95
|
-
const mainPkgJsonPath = path.join(projectPaths.packagePath)
|
|
96
|
-
const mainPkgSrc = fs.readFileSync(mainPkgJsonPath).toString()
|
|
97
|
-
const mainPkgJson = JSON.parse(mainPkgSrc)
|
|
98
|
-
const workPath = path.join(projectPaths.basePath, '.package_temp')
|
|
99
|
-
|
|
100
|
-
console.log(ac.green.italic("packaging ") + ac.green.bold(funcName));
|
|
101
|
-
|
|
102
|
-
// make a nominal package.json
|
|
103
|
-
const pkgjson = {
|
|
104
|
-
name: funcName,
|
|
105
|
-
description: "Lambda function " + funcName + " for " + projectName + ", created with MistLift " + liftVersion,
|
|
106
|
-
version: projectVersion,
|
|
107
|
-
main: "runmain.mjs",
|
|
108
|
-
scripts: {
|
|
109
|
-
test: "echo \"No Tests Defined\" && exit 1"
|
|
110
|
-
},
|
|
111
|
-
dependencies: {},
|
|
112
|
-
keywords: [],
|
|
113
|
-
author: "",
|
|
114
|
-
license: "ISC"
|
|
115
|
-
}
|
|
116
|
-
// find all the imports in the sources
|
|
117
|
-
const imports = findAllImports(funcPath);
|
|
118
|
-
pkgjson.dependencies = reconcileVersionImports(imports, mainPkgJson);
|
|
119
|
-
// - write out new package.json to workPath
|
|
120
|
-
// console.log("writing package.json", pkgjson)
|
|
121
|
-
fs.writeFileSync(path.join(workPath, 'package.json'), JSON.stringify(pkgjson, null, 2))
|
|
122
|
-
// - execute npm i at workpath, create node_modules
|
|
123
|
-
all.push(executeCommand('npm i', [], workPath).then(() => {
|
|
124
|
-
// copy the lambda function
|
|
125
|
-
recurseDirectory(funcPath, (filepath: string, stats: Stats) => {
|
|
126
|
-
if (filepath.substring(0, funcPath.length) == funcPath) {
|
|
127
|
-
const endpath = filepath.substring(funcPath.length)
|
|
128
|
-
if (endpath.toLowerCase().indexOf(`${funcName}-tests`.toLowerCase()) === -1) { // skip tests
|
|
129
|
-
const fromPath = path.join(funcPath, endpath);
|
|
130
|
-
const toPath = path.join(workPath, endpath)
|
|
131
|
-
if (stats.isDirectory() && !fs.existsSync(toPath)) {
|
|
132
|
-
fs.mkdirSync(toPath)
|
|
133
|
-
}
|
|
134
|
-
if(stats.isFile()) {
|
|
135
|
-
fs.copyFileSync(fromPath, toPath)
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
})
|
|
140
|
-
|
|
141
|
-
// put a runmain.mjs into place
|
|
142
|
-
const templatePath = path.join(__dirname, '..', '..', 'templateData', 'function-runmain-mjs')
|
|
143
|
-
const runmainPath = path.join(workPath, 'runmain.mjs')
|
|
144
|
-
fs.writeFileSync(runmainPath, fs.readFileSync(templatePath));
|
|
145
|
-
|
|
146
|
-
// ClogInfo("Zipping...")
|
|
147
|
-
all.push(FolderToZip( workPath, zipFile ));
|
|
148
|
-
// console.log("now zip it")
|
|
149
|
-
}))
|
|
150
|
-
|
|
151
|
-
return Promise.all(all).then(() => {
|
|
152
|
-
// remove temp folder when done
|
|
153
|
-
return error
|
|
164
|
+
}
|
|
165
|
+
return false
|
|
154
166
|
})
|
|
167
|
+
}
|
|
168
|
+
return imports
|
|
155
169
|
}
|
|
156
170
|
|
|
157
|
-
function
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const content = fs.readFileSync(filepath).toString();
|
|
166
|
-
for (const m of findImports(content)) {
|
|
167
|
-
// console.log(' import', m)
|
|
168
|
-
imports.push(m)
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
})
|
|
173
|
-
}
|
|
174
|
-
return imports
|
|
171
|
+
function findImports (content: string): string[] {
|
|
172
|
+
const imports: string[] = []
|
|
173
|
+
const regexp = /require\s*\(\s*["|'](.+)["|']/gm
|
|
174
|
+
const matches = content.matchAll(regexp)
|
|
175
|
+
for (const m of matches) {
|
|
176
|
+
imports.push(m[1])
|
|
177
|
+
}
|
|
178
|
+
return imports
|
|
175
179
|
}
|
|
176
180
|
|
|
177
|
-
function
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
function reconcileVersionImports (
|
|
182
|
+
imports: string[],
|
|
183
|
+
mainPkgJson: any
|
|
184
|
+
): any {
|
|
185
|
+
const dependencies = mainPkgJson.dependencies ?? {}
|
|
186
|
+
const devDependencies = mainPkgJson.devDependencies ?? {}
|
|
187
|
+
|
|
188
|
+
const builtins = [
|
|
189
|
+
'fs',
|
|
190
|
+
'path',
|
|
191
|
+
'process',
|
|
192
|
+
'crypto',
|
|
193
|
+
'http'
|
|
194
|
+
]
|
|
195
|
+
|
|
196
|
+
const depsOut: any = {}
|
|
197
|
+
|
|
198
|
+
for (const m of imports) {
|
|
199
|
+
let isDev = false
|
|
200
|
+
let r: string | undefined = dependencies[m]
|
|
201
|
+
if (r === undefined) {
|
|
202
|
+
isDev = true
|
|
203
|
+
r = devDependencies[m]
|
|
183
204
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const depsOut:any = {}
|
|
200
|
-
|
|
201
|
-
for(let m of imports) {
|
|
202
|
-
let isDev = false;
|
|
203
|
-
let r = dependencies[m]
|
|
204
|
-
if(!r) {
|
|
205
|
-
isDev = true;
|
|
206
|
-
r = devDependencies[m]
|
|
207
|
-
}
|
|
208
|
-
if(r) {
|
|
209
|
-
if(depsOut[m] && depsOut[m] !== r) {
|
|
210
|
-
console.error(ac.red.bold(` Version mismatch on ${m}: ${r} vs ${depsOut[m]}`))
|
|
211
|
-
}
|
|
212
|
-
if(isDev) {
|
|
213
|
-
console.error(ac.magenta(` ${m} import is dev-only, not migrated`))
|
|
214
|
-
} else {
|
|
215
|
-
if(!depsOut[m]) console.log(ac.blue.dim(` ${m} exported as ${r}`))
|
|
216
|
-
depsOut[m] = r;
|
|
217
|
-
}
|
|
218
|
-
} else {
|
|
219
|
-
// if not a builtin and not local..
|
|
220
|
-
if(builtins.indexOf(m) === -1) {
|
|
221
|
-
if (m.charAt(0) !== '.') {
|
|
222
|
-
console.error(ac.red.bold(" ERROR - Found no dependency reference for import"), m)
|
|
223
|
-
}
|
|
224
|
-
}
|
|
205
|
+
if (r !== undefined) {
|
|
206
|
+
if (depsOut[m] !== undefined && depsOut[m] !== r) {
|
|
207
|
+
console.error(ac.red.bold(` Version mismatch on ${m}: ${r} vs ${depsOut[m] as string}`))
|
|
208
|
+
}
|
|
209
|
+
if (isDev) {
|
|
210
|
+
console.error(ac.magenta(` ${m} import is dev-only, not migrated`))
|
|
211
|
+
} else {
|
|
212
|
+
if (depsOut[m] !== undefined) console.log(ac.blue.dim(` ${m} exported as ${r}`))
|
|
213
|
+
depsOut[m] = r
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
216
|
+
// if not a builtin and not local..
|
|
217
|
+
if (!builtins.includes(m)) {
|
|
218
|
+
if (m.charAt(0) !== '.') {
|
|
219
|
+
console.error(ac.red.bold(' ERROR - Found no dependency reference for import'), m)
|
|
225
220
|
}
|
|
221
|
+
}
|
|
226
222
|
}
|
|
227
|
-
|
|
228
|
-
|
|
223
|
+
}
|
|
224
|
+
return depsOut
|
|
225
|
+
}
|