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