Skip to content

Commit f68a209

Browse files
committed
Moved context to be it's own global object. Improved events
1 parent 0fab861 commit f68a209

7 files changed

Lines changed: 13 additions & 16 deletions

File tree

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
"tsx": "^4.7.3",
1515
"ink": "^4.4.1",
1616
"@inkjs/ui": "^1.0.0",
17-
"react": "^18.3.1",
18-
"eventemitter2": "^6.4.9"
17+
"react": "^18.3.1"
1918
},
2019
"description": "Codify is a set up as code tool for developers",
2120
"devDependencies": {
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { EventEmitter } from 'node:events';
22

3-
43
export enum Event {
54
STDOUT = 'stdout',
65
STDERR = 'stderr',
@@ -39,7 +38,11 @@ export const ctx = new class {
3938
}
4039

4140
debug(...args: unknown[]) {
42-
// Add filtering here to only allow debug events when in debug mode
41+
const debug = process.env.DEBUG;
42+
if (!debug?.toLowerCase().includes('codify') && !debug?.includes('*')) {
43+
return;
44+
}
45+
4346
this.emitter.emit(Event.DEBUG, ...args);
4447
}
4548

src/orchestrators/plan.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { PlanResponseData } from 'codify-schemas';
22

33
import { Project } from '../entities/project.js';
4+
import { ctx } from '../events/context.js';
45
import { Parser } from '../parser/index.js';
56
import { PluginCollection } from '../plugins/plugin-collection.js';
6-
import { ctx } from './context.js';
77

88
interface PlanOchestratorResponse {
99
plan: PlanResponseData[],
@@ -12,11 +12,11 @@ interface PlanOchestratorResponse {
1212
}
1313

1414
export enum PlanStatus {
15-
PLAN = 'plan',
16-
PARSE = 'parse',
15+
GENERATE_PLAN = 'generate_plan',
1716
INITIALIZE_PLUGINS = 'initalize_plugins',
17+
PARSE = 'parse',
18+
PLAN = 'plan',
1819
VALIDATE = 'validate',
19-
GENERATE_PLAN = 'generate_plan',
2020
}
2121

2222
export const PlanOrchestrator = {

src/plugins/plugin-process.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { IpcMessage, IpcMessageSchema } from 'codify-schemas';
22
import { ChildProcess, fork } from 'node:child_process';
33

4-
import { ctx } from '../orchestrators/context.js';
4+
import { ctx } from '../events/context.js';
55
import { ajv } from '../utils/ajv.js';
66
import { PluginMessage } from './message.js';
77

src/ui/components/plan-component.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,5 @@ export function PlanComponent({ eventTarget }: { eventTarget: EventEmitter }) {
4747
</Box>
4848
) ?? []
4949
}
50-
{
51-
staticOutput.flatMap((arr) => arr.split('\n')).slice(-5).map((item, i) =>
52-
<Text key={i}>{item}</Text>
53-
)
54-
}
5550
</Box>
5651
}

src/ui/reporters/default-reporter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { render } from 'ink';
22
import { EventEmitter } from 'node:events';
33
import React from 'react';
44

5-
import { ctx, Event } from '../../orchestrators/context.js';
5+
import { ctx, Event } from '../../events/context.js';
66
import { PlanComponent } from '../components/plan-component.js';
77
import { Reporter } from './reporter.js';
88

src/ui/reporters/plain-reporter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ctx, Event } from '../../orchestrators/context.js';
1+
import { ctx, Event } from '../../events/context.js';
22
import { Reporter } from './reporter.js';
33

44
export class PlainReporter implements Reporter {

0 commit comments

Comments
 (0)