-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
49 changed files
with
9,929 additions
and
3,355 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"editor.codeActionsOnSave": { | ||
"source.fixAll": false, | ||
"source.fixAll.eslint": false | ||
"source.fixAll": "never", | ||
"source.fixAll.eslint": "never" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,19 @@ | ||
|
||
module.exports = { | ||
root: '/Users/ll/Desktop/work/deepexi/dxp-cdp-data-ui', | ||
extensions: ['.js', '.ts','.tsx','.vue', '.json', '.jsx'], | ||
ignore: ['**/node_modules/**', '**/dist/**', '**/static/**'], | ||
server: { | ||
port: 8088, | ||
}, | ||
alias: { | ||
'@@/': '/', | ||
'~~/': '/', | ||
'@/': '/examples/', | ||
'~/': '/examples/', | ||
'@p/': '/packages/', | ||
}, | ||
plugins: [] | ||
} | ||
// root: "/Users/ll/Desktop/work/deepexi/fastdataforflink_frontend", | ||
root: "/Users/ll/Desktop/work/deepexi/dxp-cdp-data-ui", | ||
// root: '/Users/ll/Desktop/work/deepexi/dxp-cdp-data-ui/packages/page-components/scene-module/daw-scene-detail.vue', | ||
extensions: [".js", ".ts", ".tsx", ".vue", ".json", ".jsx"], | ||
ignore: ["**/node_modules/**", "**/dist/**", "**/static/**"], | ||
server: { | ||
port: 8088, | ||
}, | ||
alias: { | ||
"@@/": "/", | ||
"~~/": "/", | ||
"@/": "/examples/", | ||
"~/": "/examples/", | ||
"@p/": "/packages/", | ||
"~@p/": "/packages/", | ||
}, | ||
plugins: [], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,111 @@ | ||
const path = require('path') | ||
const Koa = require('koa') | ||
const router = require("koa-router")() | ||
const koaStatic = require("koa-static") | ||
const cors = require('koa2-cors') | ||
const { koaBody } = require('koa-body') | ||
const launch = require('launch-editor') | ||
const open = require('open') | ||
const template = require('art-template') | ||
const fs = require('fs') | ||
const { JsAnalyzer } = require('@js-analyzer/core') | ||
// const { Analy } = require('../../core/dist/js-analyzer-core.cjs') | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const Koa = require("koa"); | ||
const router = require("koa-router")(); | ||
const open = require("open"); | ||
const koaStatic = require("koa-static"); | ||
const cors = require("koa2-cors"); | ||
const launch = require("launch-editor"); | ||
const template = require("art-template"); | ||
const portfinder = require("portfinder"); | ||
const { koaBody } = require("koa-body"); | ||
const { JsAnalyzer } = require("@js-analyzer/core"); | ||
|
||
const app = new Koa(); | ||
app.use(cors()) | ||
app.use(koaBody()) | ||
app.use(koaStatic( | ||
path.join( __dirname, '../public/') | ||
)); | ||
app.use(cors()); | ||
app.use(koaBody()); | ||
app.use(koaStatic(path.join(__dirname, "../public/"))); | ||
|
||
// index.html | ||
router.get("/", async ctx => { | ||
ctx.set('Content-Type', 'text/html;charset=UTF-8') | ||
const content = template(path.resolve(__dirname, '../public/index.html'), { | ||
TITLE: 'JsAnalyzer | 依赖分析工具', | ||
router.get("/", async (ctx) => { | ||
ctx.set("Content-Type", "text/html;charset=UTF-8"); | ||
const content = template(path.resolve(__dirname, "../public/index.html"), { | ||
TITLE: "JsAnalyzer | 依赖分析工具", | ||
ROOT: ctx.config.root, | ||
}) | ||
ctx.body = content | ||
}); | ||
ctx.body = content; | ||
}); | ||
|
||
router.get('/config', ctx => { | ||
ctx.body = ctx.config | ||
}) | ||
router.get("/config", (ctx) => { | ||
ctx.body = ctx.config; | ||
}); | ||
|
||
router.put('/config', async ctx => { | ||
router.put("/config", async (ctx) => { | ||
if (!ctx.request.body) { | ||
ctx.status = 500 | ||
ctx.body = 'config error or null' | ||
return | ||
ctx.status = 500; | ||
ctx.body = "config error or null"; | ||
return; | ||
} | ||
|
||
app.context.config = ctx.request.body | ||
const instance = new JsAnalyzer(ctx.request.body) | ||
await instance.init().then(() => { | ||
ctx.body = 'ok' | ||
}).catch(error => { | ||
console.log(error) | ||
ctx.status = 500 | ||
ctx.body = error.toString() | ||
}) | ||
}) | ||
app.context.config = ctx.request.body; | ||
const instance = new JsAnalyzer(ctx.request.body); | ||
await instance | ||
.init() | ||
.then(() => { | ||
ctx.body = "ok"; | ||
}) | ||
.catch((error) => { | ||
console.log(error); | ||
ctx.status = 500; | ||
ctx.body = error.toString(); | ||
}); | ||
}); | ||
|
||
// open file in editor | ||
router.get("/launch", async ctx => { | ||
const file = ctx.query.file | ||
launch(file, 'code', (name, error) => { | ||
ctx.body = error | ||
}) | ||
ctx.body = 'ok' | ||
router.get("/launch", async (ctx) => { | ||
const file = ctx.query.file; | ||
launch(file, "code", (name, error) => { | ||
ctx.body = error; | ||
}); | ||
ctx.body = "ok"; | ||
}); | ||
|
||
router.get("/code", async ctx => { | ||
ctx.set('Content-Type', 'text/text;charset=UTF-8') | ||
const file = ctx.query.file | ||
router.get("/code", async (ctx) => { | ||
ctx.set("Content-Type", "text/text;charset=UTF-8"); | ||
const file = ctx.query.file; | ||
try { | ||
const data = fs.readFileSync(file, 'utf-8') | ||
ctx.body = data | ||
const data = fs.readFileSync(file, "utf-8"); | ||
ctx.body = data; | ||
} catch (error) { | ||
ctx.body = error | ||
ctx.body = error; | ||
} | ||
}); | ||
|
||
app.use(router.routes()).use(router.allowedMethods()); | ||
|
||
function startServer (config) { | ||
const serverOpts = config.server = Object.assign({ | ||
function startListen(config) { | ||
portfinder.setBasePort(config.server.port); | ||
portfinder.getPort({ port: 8000, stopPort: 9000 }, function (err, port) { | ||
if (err) { | ||
console.log(err); | ||
} else { | ||
app.listen(port); | ||
const url = `http://${config.server.host}:${port}`; | ||
config.server.openBrowser && open(url); | ||
console.log("\033[32m Service started: \033[0m" + url); | ||
} | ||
}); | ||
} | ||
|
||
function startServer(c) { | ||
const config = { | ||
...c, | ||
server: { | ||
port: 8666, | ||
host: 'localhost', | ||
host: "localhost", | ||
openBrowser: true, | ||
}, config.server || {}) | ||
|
||
app.context.config = config | ||
|
||
const instance = new JsAnalyzer(config) | ||
...(c.server || {}), | ||
}, | ||
}; | ||
|
||
instance.init().then(() => { | ||
app.listen(serverOpts.port, () => { | ||
const url = `http://${serverOpts.host}:${serverOpts.port}` | ||
serverOpts.openBrowser && open(url) | ||
console.log('\033[32m Service started: \033[0m' + url) | ||
}) | ||
}) | ||
app.context.config = config; | ||
const instance = new JsAnalyzer(config); | ||
console.log("\033[32m Generating dependency information... \033[0m"); | ||
instance.init().then(() => { | ||
startListen(config); | ||
}); | ||
} | ||
|
||
module.exports = { | ||
start: startServer | ||
} | ||
start: startServer, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.