|
|
@ -47,9 +47,6 @@ const XC_PLUGIN_DET = 'XC_PLUGIN_DET'; |
|
|
|
|
|
|
|
|
|
|
|
const NOCO_RELEASE = 'NOCO_RELEASE'; |
|
|
|
const NOCO_RELEASE = 'NOCO_RELEASE'; |
|
|
|
|
|
|
|
|
|
|
|
const writeFileAsync = promisify(fs.writeFile); |
|
|
|
|
|
|
|
const readFileAsync = promisify(fs.readFile); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export default class NcMetaMgr { |
|
|
|
export default class NcMetaMgr { |
|
|
|
public projectConfigs = {}; |
|
|
|
public projectConfigs = {}; |
|
|
|
public readonly pluginMgr: NcPluginMgr; |
|
|
|
public readonly pluginMgr: NcPluginMgr; |
|
|
@ -440,9 +437,9 @@ export default class NcMetaMgr { |
|
|
|
await this.xcMetaTablesReset(args); |
|
|
|
await this.xcMetaTablesReset(args); |
|
|
|
|
|
|
|
|
|
|
|
for (const tn of META_TABLES[this.config.projectType.toLowerCase()]) { |
|
|
|
for (const tn of META_TABLES[this.config.projectType.toLowerCase()]) { |
|
|
|
if (fs.existsSync(path.join(metaFolder, `${tn}.json`))) { |
|
|
|
if (await promisify(fs.exists)(path.join(metaFolder, `${tn}.json`))) { |
|
|
|
const data = JSON.parse( |
|
|
|
const data = JSON.parse( |
|
|
|
await readFileAsync(path.join(metaFolder, `${tn}.json`), 'utf8') |
|
|
|
await promisify(fs.readFile)(path.join(metaFolder, `${tn}.json`), 'utf8') |
|
|
|
); |
|
|
|
); |
|
|
|
for (const row of data) { |
|
|
|
for (const row of data) { |
|
|
|
delete row.id; |
|
|
|
delete row.id; |
|
|
@ -491,14 +488,14 @@ export default class NcMetaMgr { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
// delete temporary upload file
|
|
|
|
// delete temporary upload file
|
|
|
|
fs.unlinkSync(file.path); |
|
|
|
await promisify(fs.unlink)(file.path); |
|
|
|
|
|
|
|
|
|
|
|
let projectId = this.getProjectId(args); |
|
|
|
let projectId = this.getProjectId(args); |
|
|
|
if (!projectConfigPath) { |
|
|
|
if (!projectConfigPath) { |
|
|
|
throw new Error('Missing project config file'); |
|
|
|
throw new Error('Missing project config file'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const projectDetailsJSON: any = await readFileAsync( |
|
|
|
const projectDetailsJSON: any = await promisify(fs.readFile)( |
|
|
|
path.join(this.config.toolDir, 'uploads', projectConfigPath), |
|
|
|
path.join(this.config.toolDir, 'uploads', projectConfigPath), |
|
|
|
'utf8' |
|
|
|
'utf8' |
|
|
|
); |
|
|
|
); |
|
|
@ -617,11 +614,11 @@ export default class NcMetaMgr { |
|
|
|
}, |
|
|
|
}, |
|
|
|
}); |
|
|
|
}); |
|
|
|
// delete temporary upload file
|
|
|
|
// delete temporary upload file
|
|
|
|
fs.unlinkSync(file.path); |
|
|
|
await promisify(fs.unlink)(file.path); |
|
|
|
|
|
|
|
|
|
|
|
if (projectConfigPath) { |
|
|
|
if (projectConfigPath) { |
|
|
|
// read project config and extract project id
|
|
|
|
// read project config and extract project id
|
|
|
|
let projectConfig: any = await readFileAsync( |
|
|
|
let projectConfig: any = await promisify(fs.readFile)( |
|
|
|
path.join(this.config?.toolDir, projectConfigPath), |
|
|
|
path.join(this.config?.toolDir, projectConfigPath), |
|
|
|
'utf8' |
|
|
|
'utf8' |
|
|
|
); |
|
|
|
); |
|
|
@ -712,7 +709,7 @@ export default class NcMetaMgr { |
|
|
|
for (const tn of META_TABLES[this.config.projectType.toLowerCase()]) { |
|
|
|
for (const tn of META_TABLES[this.config.projectType.toLowerCase()]) { |
|
|
|
// const metaData = await client.knex(tn).select();
|
|
|
|
// const metaData = await client.knex(tn).select();
|
|
|
|
const metaData = await this.xcMeta.metaList(projectId, dbAlias, tn); |
|
|
|
const metaData = await this.xcMeta.metaList(projectId, dbAlias, tn); |
|
|
|
await writeFileAsync( |
|
|
|
await promisify(fs.writeFile)( |
|
|
|
path.join(metaFolder, `${tn}.json`), |
|
|
|
path.join(metaFolder, `${tn}.json`), |
|
|
|
JSON.stringify(metaData, null, 2) |
|
|
|
JSON.stringify(metaData, null, 2) |
|
|
|
); |
|
|
|
); |
|
|
@ -723,7 +720,7 @@ export default class NcMetaMgr { |
|
|
|
true |
|
|
|
true |
|
|
|
); |
|
|
|
); |
|
|
|
projectMetaData.key = this.config?.auth?.jwt?.secret; |
|
|
|
projectMetaData.key = this.config?.auth?.jwt?.secret; |
|
|
|
await writeFileAsync( |
|
|
|
await promisify(fs.writeFile)( |
|
|
|
path.join(metaFolder, `nc_project.json`), |
|
|
|
path.join(metaFolder, `nc_project.json`), |
|
|
|
JSON.stringify(projectMetaData, null, 2) |
|
|
|
JSON.stringify(projectMetaData, null, 2) |
|
|
|
); |
|
|
|
); |
|
|
|