@haibun/core
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -13,2 +13,4 @@ import { TTag, WorkspaceBuilder } from './defs'; | ||
get(name: string): any; | ||
concat(name: string, value: any): void; | ||
unset(name: string): void; | ||
} | ||
@@ -15,0 +17,0 @@ export declare class DomainContext extends Context { |
@@ -18,2 +18,9 @@ "use strict"; | ||
} | ||
concat(name, value) { | ||
const t = this.values[name] || []; | ||
this.values[name] = [...t, value]; | ||
} | ||
unset(name) { | ||
delete this.values[name]; | ||
} | ||
} | ||
@@ -20,0 +27,0 @@ exports.Context = Context; |
import { DomainContext, WorkspaceContext, WorldContext } from './contexts'; | ||
import { ILogger } from './interfaces/logger'; | ||
import { Timer } from './Timer'; | ||
export declare type TSpecl = { | ||
@@ -63,2 +64,3 @@ steppers: string[]; | ||
domains: TModuleDomain[]; | ||
timer: Timer; | ||
}; | ||
@@ -157,2 +159,3 @@ export declare type TFeatureMeta = { | ||
ok: boolean; | ||
tag: TTag; | ||
results?: TFeatureResult[]; | ||
@@ -180,4 +183,20 @@ failure?: { | ||
}; | ||
export declare type TActionResult = TOKActionResult | TNotOKActionResult; | ||
export declare type TStepActionResult = TNotOkStepActionResult | TOKStepActionResult; | ||
export declare type TTrace = { | ||
[name: string]: { | ||
since: number; | ||
trace: any; | ||
}; | ||
}; | ||
export declare type TTraces = { | ||
start?: number; | ||
end?: number; | ||
traces?: TTrace; | ||
}; | ||
export declare type TTraceOptions = { | ||
[event: string]: { | ||
listener: any; | ||
}; | ||
}; | ||
export declare type TActionResult = (TOKActionResult | TNotOKActionResult); | ||
export declare type TStepActionResult = TNotOkStepActionResult | TOKStepActionResult & TTraces; | ||
declare type TNamedStepActionResult = { | ||
@@ -184,0 +203,0 @@ name: string; |
@@ -13,2 +13,3 @@ "use strict"; | ||
exports.OK = { ok: true }; | ||
; | ||
exports.HAIBUN = 'HAIBUN'; | ||
@@ -15,0 +16,0 @@ exports.BASE_DOMAINS = [{ name: 'string', resolve: (inp) => inp }]; |
@@ -60,3 +60,3 @@ "use strict"; | ||
const tag = messageContext?.tag ? util_1.descTag(messageContext.tag) : ''; | ||
console[level](`${ln}${Object.keys(tag)}: `.padStart(WIDTH), args, level.padStart(6)); | ||
console[level](`${ln}${tag}: `.padStart(WIDTH), args, level.padStart(6)); | ||
} | ||
@@ -63,0 +63,0 @@ } |
@@ -109,3 +109,3 @@ "use strict"; | ||
if (val === undefined) { | ||
throw Error(`no env value for "${namedValue}" from ${JSON.stringify({ env: Object.keys(process.env), type })}`); | ||
throw Error(`no env value for "${namedValue}" from ${JSON.stringify({ env: Object.keys(process.env).map(k => k.startsWith(defs_1.HAIBUN)), type })}`); | ||
} | ||
@@ -112,0 +112,0 @@ if (Array.isArray(val)) { |
@@ -24,2 +24,3 @@ "use strict"; | ||
async function runWith({ specl, world, features, backgrounds, addSteppers, protoOptions: protoOptions = { options: {}, extraOptions: {} }, }) { | ||
const { tag } = world; | ||
const steppers = await util_1.getSteppers({ steppers: specl.steppers, addSteppers, world }); | ||
@@ -30,3 +31,3 @@ try { | ||
catch (error) { | ||
return { result: { ok: false, failure: { stage: 'Options', error: { message: error.message, details: error } } } }; | ||
return { result: { ok: false, tag, failure: { stage: 'Options', error: { message: error.message, details: error } } } }; | ||
} | ||
@@ -37,3 +38,3 @@ try { | ||
catch (error) { | ||
return { result: { ok: false, failure: { stage: 'Domains', error: { message: error.message, details: { stack: error.stack } } } } }; | ||
return { result: { ok: false, tag, failure: { stage: 'Domains', error: { message: error.message, details: { stack: error.stack } } } } }; | ||
} | ||
@@ -45,3 +46,3 @@ let expandedFeatures; | ||
catch (error) { | ||
return { result: { ok: false, failure: { stage: 'Expand', error: { message: error.message, details: error } } } }; | ||
return { result: { ok: false, tag, failure: { stage: 'Expand', error: { message: error.message, details: error } } } }; | ||
} | ||
@@ -54,3 +55,3 @@ let mappedValidatedSteps; | ||
catch (error) { | ||
return { result: { ok: false, failure: { stage: 'Resolve', error: { message: error.message, details: { stack: error.stack, steppers, mappedValidatedSteps } } } } }; | ||
return { result: { ok: false, tag, failure: { stage: 'Resolve', error: { message: error.message, details: { stack: error.stack, steppers, mappedValidatedSteps } } } } }; | ||
} | ||
@@ -64,3 +65,3 @@ const builder = new Builder_1.default(world); | ||
console.error(error); | ||
return { result: { ok: false, failure: { stage: 'Build', error: { message: error.message, details: { stack: error.stack, steppers, mappedValidatedSteps } } } } }; | ||
return { result: { ok: false, tag, failure: { stage: 'Build', error: { message: error.message, details: { stack: error.stack, steppers, mappedValidatedSteps } } } } }; | ||
} | ||
@@ -70,3 +71,3 @@ const executor = new Executor_1.Executor(steppers, world); | ||
try { | ||
result = await executor.execute(mappedValidatedSteps); | ||
result = { ...await executor.execute(mappedValidatedSteps), tag }; | ||
if (!result.ok) { | ||
@@ -78,3 +79,4 @@ const message = result.results[0].stepResults.find(s => !s.ok)?.actionResults[0].message; | ||
catch (e) { | ||
result = { ok: false, failure: e }; | ||
console.log('XXXXXXX', e); | ||
result = { ok: false, tag, failure: e }; | ||
} | ||
@@ -81,0 +83,0 @@ return { result, steppers }; |
@@ -30,2 +30,3 @@ "use strict"; | ||
const Logger_1 = __importStar(require("./../Logger")); | ||
const Timer_1 = require("../Timer"); | ||
exports.HAIBUN_O_TESTSTEPSWITHOPTIONS_EXISTS = 'HAIBUN_O_TESTSTEPSWITHOPTIONS_EXISTS'; | ||
@@ -77,2 +78,3 @@ async function getTestEnv(useSteppers, test, world) { | ||
world: { | ||
timer: new Timer_1.Timer(), | ||
tag: { sequence: 0, loop: 0, member: 0 }, | ||
@@ -79,0 +81,0 @@ shared: new contexts_1.WorldContext(getDefaultTag(sequence)), |
@@ -45,2 +45,3 @@ import { WorldContext } from './contexts'; | ||
export declare function applyResShouldContinue(world: any, res: Partial<TActionResult>, vstep: TFound): boolean; | ||
export declare function writeTraceFile(tag: TTag, result: TResult): void; | ||
export declare function getCaptureDir(tag: TTag, app: string, fn?: string): string; | ||
@@ -47,0 +48,0 @@ export declare const getRunTag: (sequence: number, loop: number, member: number, params: any, trace: boolean) => { |
@@ -25,3 +25,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.descTag = exports.getIntOrError = exports.getRunTag = exports.getCaptureDir = exports.applyResShouldContinue = exports.getFromRuntime = exports.findStepper = exports.ensureDirectory = exports.getStepperOption = exports.getStepperOptions = exports.getPre = exports.applyExtraOptions = exports.applyEnvCollections = exports.processEnv = exports.sleep = exports.isLowerCase = exports.describeSteppers = exports.getActionable = exports.getOptionsOrDefault = exports.getDefaultOptions = exports.recurse = exports.debase = exports.getSteppers = exports.getStepper = exports.actionOK = exports.actionNotOK = exports.resultOutput = exports.use = void 0; | ||
exports.descTag = exports.getIntOrError = exports.getRunTag = exports.getCaptureDir = exports.writeTraceFile = exports.applyResShouldContinue = exports.getFromRuntime = exports.findStepper = exports.ensureDirectory = exports.getStepperOption = exports.getStepperOptions = exports.getPre = exports.applyExtraOptions = exports.applyEnvCollections = exports.processEnv = exports.sleep = exports.isLowerCase = exports.describeSteppers = exports.getActionable = exports.getOptionsOrDefault = exports.getDefaultOptions = exports.recurse = exports.debase = exports.getSteppers = exports.getStepper = exports.actionOK = exports.actionNotOK = exports.resultOutput = exports.use = void 0; | ||
const fs_1 = require("fs"); | ||
@@ -304,3 +304,3 @@ const path_1 = __importDefault(require("path")); | ||
catch (e) { | ||
console.error(`coudl not create ${base}/${folder}`, e); | ||
console.error(`could not create ${base}/${folder}`, e); | ||
throw e; | ||
@@ -332,2 +332,6 @@ } | ||
exports.applyResShouldContinue = applyResShouldContinue; | ||
function writeTraceFile(tag, result) { | ||
fs_1.writeFileSync(getCaptureDir(tag, 'trace', 'trace.json'), JSON.stringify(result, null, 2)); | ||
} | ||
exports.writeTraceFile = writeTraceFile; | ||
function getCaptureDir(tag, app, fn) { | ||
@@ -334,0 +338,0 @@ const dir = [process.cwd(), 'capture', tag.sequence, app].join('/'); |
@@ -25,3 +25,3 @@ "use strict"; | ||
await this.close(); | ||
return { ok, results: featureResults }; | ||
return { ok, results: featureResults, tag: this.world.tag }; | ||
} | ||
@@ -58,2 +58,3 @@ async doFeature(feature) { | ||
for (const a of vstep.actions) { | ||
const start = world.timer.since(); | ||
let res; | ||
@@ -68,3 +69,11 @@ try { | ||
} | ||
actionResults.push({ ...res, name: a.name }); | ||
let traces; | ||
if (world.shared.get('_trace')) { | ||
traces = world.shared.get('_trace'); | ||
world.shared.unset('_trace'); | ||
} | ||
const end = world.timer.since(); | ||
// FIXME | ||
const stepResult = { ...res, name: a.name, start, end, traces }; | ||
actionResults.push(stepResult); | ||
const shouldContinue = util_1.applyResShouldContinue(world, res, a); | ||
@@ -71,0 +80,0 @@ ok = ok && shouldContinue; |
{ | ||
"name": "@haibun/core", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "author": "", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
233961
133
3055