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