implemented _id and linking
parent
885275d352
commit
775f16ab62
|
|
@ -40,11 +40,9 @@ async function cliCompile(args) {
|
|||
if(!path.isAbsolute(args.index)) args.index = path.join(process.cwd(), args.index);
|
||||
if(!path.isAbsolute(args.cache)) args.cache = path.join(process.cwd(), args.cache);
|
||||
|
||||
|
||||
let index = platformPrecompile(args);
|
||||
log.info('precompile completed');
|
||||
|
||||
|
||||
compile({
|
||||
index: index,
|
||||
cache: args.cache
|
||||
|
|
@ -63,6 +61,8 @@ function platformPrecompile(args) {
|
|||
|
||||
const index = args.index;
|
||||
|
||||
if(!('Parameters' in index)) return index;
|
||||
|
||||
for(const key in args) {
|
||||
if(key in index.Parameters) {
|
||||
index.Parameters[key] = args[key];
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
const {Cache} = require('./cache.js');
|
||||
const {retrieveModule} = require('./retrieveModule.js');
|
||||
const {Signale} = require('signale');
|
||||
const uuid = require('uuid');
|
||||
const log = new Signale({
|
||||
scope: 'COMPILER'
|
||||
});
|
||||
|
|
@ -57,17 +58,26 @@ function compileParameters (index) {
|
|||
}
|
||||
|
||||
function compileLinks (index) {
|
||||
// TODO implement links
|
||||
index = {...index};
|
||||
|
||||
let entities = index.Entities;
|
||||
|
||||
for(const key in index.Parameters) {
|
||||
entities = recursiveReplace(entities, `\$${key}`, index.Parameters[key]);
|
||||
//assign all _ids
|
||||
for(const symbol in index.Entities) {
|
||||
const ent = index.Entities[symbol];
|
||||
ent._id = uuid.v4();
|
||||
}
|
||||
|
||||
return {
|
||||
Entities: entities
|
||||
};
|
||||
// loopback and replace all #links in Data with _ids
|
||||
for(const symbol in index.Entities) {
|
||||
let data = index.Entities[symbol].Data;
|
||||
|
||||
for(const targetSymbol in index.Entities) {
|
||||
data = recursiveReplace(data, `#${targetSymbol}`, index.Entities[targetSymbol]._id)
|
||||
}
|
||||
|
||||
index.Entities[symbol].Data = data;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,17 +3,22 @@ const {Signale} = require('signale');
|
|||
const log = new Signale({
|
||||
scope: 'CLI'
|
||||
});
|
||||
let local = path.join(__dirname, './../modules/')
|
||||
|
||||
module.exports = {
|
||||
Parameters: {
|
||||
Source: path.join(__dirname, './../modules/')
|
||||
},
|
||||
Entities: {
|
||||
Tester: {
|
||||
A: {
|
||||
Name: 'module',
|
||||
From: '$Source',
|
||||
From: local,
|
||||
Data: {
|
||||
Thing: 5
|
||||
Thing: '#B'
|
||||
}
|
||||
},
|
||||
B: {
|
||||
Name: 'module',
|
||||
From: local,
|
||||
Data: {
|
||||
Thing: '#A'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue