Skip to content
代码片段 群组 项目
提交 f41fe742 编辑于 作者: Timotej Ecimovic's avatar Timotej Ecimovic
浏览文件

Make sure running `zap` out of the box works.

0.) Add ability to start without gen templates. They are not needed for UI.
1.) Properly locate zcl-builtin inside asar.
上级 e6c6062c
No related branches found
No related tags found
无相关合并请求
......@@ -115,10 +115,17 @@ function loadTemplates(db, genTemplatesJson) {
db: db,
path: path.resolve(genTemplatesJson),
}
env.logInfo(`Loading generation templates from: ${genTemplatesJson}`)
return loadGenTemplate(context).then((context) =>
recordTemplatesPackage(context)
)
return fsPromise
.access(context.path, fs.constants.R_OK)
.then(() => {
env.logInfo(`Loading generation templates from: ${context.path}`)
return loadGenTemplate(context)
})
.then((context) => recordTemplatesPackage(context))
.catch(() => {
env.logInfo(`Can not read templates from: ${context.path}`)
return context
})
}
/**
......@@ -295,8 +302,6 @@ function generateSingleFileForPreview(db, sessionId, outFileName) {
}
exports.loadTemplates = loadTemplates
exports.loadGenTemplate = loadGenTemplate
exports.recordTemplatesPackage = recordTemplatesPackage
exports.generate = generate
exports.generateAndWriteFiles = generateAndWriteFiles
exports.generateSingleFileForPreview = generateSingleFileForPreview
......
......@@ -88,6 +88,7 @@ function initHttpServer(db, port, studioPort) {
admin.registerAdminApi(db, app)
uc_integration.registerUcComponentApi(db, app)
env.logInfo(`HTTP static content location: ${env.httpStaticContent}`)
app.use(express.static(env.httpStaticContent))
httpServer = app.listen(port, () => {
......
......@@ -16,11 +16,14 @@
*/
const yargs = require('yargs')
const path = require('path')
const restApi = require(`../../src-shared/rest-api.js`)
// TODO how to handle relative pathing for things like properties file.
exports.zclPropertiesFile = './zcl-builtin/zcl-test.properties'
exports.zclPropertiesFile = path.join(
__dirname,
'../../zcl-builtin/zcl-test.properties'
)
exports.genTemplateJsonFile = './test/gen-template/gen-templates.json'
exports.httpPort = 9070
exports.studioHttpPort = 9000
......
......@@ -86,11 +86,7 @@ function iconsDirectory() {
}
function schemaFile() {
var p = path.join(__dirname, '../db/zap-schema.sql')
if (!fs.existsSync(p)) p = path.join(__dirname, '../zap-schema.sql')
if (!fs.existsSync(p))
throw new Error('Could not locate zap-schema.sql file.')
return p
return path.join(__dirname, '../db/zap-schema.sql')
}
function sqliteFile(filename = 'zap') {
......
......@@ -779,11 +779,11 @@ function parseOptions(db, ctx) {
* @returns a Promise that resolves with the db.
*/
function loadZcl(db, propertiesFile) {
env.logInfo(`Loading zcl file: ${propertiesFile}`)
var ctx = {
propertiesFile: path.resolve(propertiesFile),
db: db,
}
env.logInfo(`Loading zcl file: ${ctx.propertiesFile}`)
return dbApi
.dbBeginTransaction(db)
.then(() => readPropertiesFile(ctx))
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册