nix store log

This commit is contained in:
IDONTSUDO 2023-12-14 23:04:45 +03:00
parent 5d0e5f7f1c
commit 0d140e58ca
13 changed files with 81 additions and 46 deletions

View file

@ -13,6 +13,8 @@ declare global {
isEmpty(): boolean;
isNotEmpty(): boolean;
lastElement(): string;
hasPattern(pattern: string): boolean;
hasNoPattern(pattern: string): boolean;
}
}
export const extensions = () => {

View file

@ -16,4 +16,14 @@ export const StringExtensions = () => {
return this[this.length - 1];
};
}
if ("".hasPattern === undefined) {
String.prototype.hasPattern = function (pattern) {
return new RegExp(pattern).test(this);
};
}
if ("".hasNoPattern === undefined) {
String.prototype.hasNoPattern = function (pattern) {
return !this.hasPattern(pattern);
};
}
};

View file

@ -5,7 +5,7 @@ export interface Routes {
}
export interface IRouteModel {
validationModel: any;
validationModel?: any;
url: string;
databaseModel: any;
databaseModel?: any;
}

View file

@ -27,7 +27,7 @@ export class ExecutorProgramService
private async workerExecuted(command: string, workerType: WorkerType, args: Array<string> | undefined = undefined) {
cluster.setupPrimary({
exec: "./src/core/helper/worker_computed",
exec: "/Users/idontsudo/Desktop/testdeck-mocha-seed/server/build/src/core/helpers/worker_computed.js",
});
const worker = cluster.fork();

View file

@ -55,13 +55,13 @@ export class StackService extends TypedEvent<Iteration[]> implements IStackServi
}
async execStack(stackNumber: number, stackLayer: Iteration): Promise<void | boolean> {
const executorService = new ExecutorProgramService(this.path);
executorService.call(stackLayer.process.process.type, stackLayer.process.process.command);
const filesChangeNotifierService = new FilesChangeNotifierService(this.path);
filesChangeNotifierService.call();
const result = await this.waitEvent<Result<ExecError | SpawnError, ExecutorResult>>(executorService);
console.log(200);
await delay(100);
if (result.isSuccess()) {
this.callStack[stackNumber].result = result.value;

View file

@ -0,0 +1,58 @@
import { CallbackStrategyWithEmpty, CoreHttpController } from "../../core/controllers/http_controller";
import { Result } from "../../core/helpers/result";
import { EXEC_TYPE } from "../../core/models/exec_error_model";
import { ExecutorResult } from "../../core/models/executor_result";
import { IPipeline, IssueType, StackGenerateType } from "../../core/models/process_model";
import { StackService } from "../../core/services/stack_service";
import { TriggerType } from "../triggers/models/trigger_database_model";
class NixStoreModel {}
const getNixStoreFolderCommand: IPipeline[] = [
{
process: {
type: EXEC_TYPE.EXEC,
command: `ls /nix/store`,
isGenerating: true,
isLocaleCode: false,
issueType: IssueType.WARNING,
},
trigger: {
type: TriggerType.FILE,
value: ["context"],
},
env: null,
stackGenerateType: StackGenerateType.SINGLETON,
},
];
class GetNixStorePackagesUseCase extends CallbackStrategyWithEmpty {
call = async () => {
const stackService = new StackService(
getNixStoreFolderCommand,
"/Users/idontsudo/Desktop/testdeck-mocha-seed/server/build/test/"
);
stackService.call();
const promise = new Promise((resolve, _reject) => {
stackService.on((e) => {
const iteration = e[0];
if (iteration.result instanceof ExecutorResult) {
const nixPackage = iteration.result.data;
resolve(nixPackage.split("\n").filter((e) => e.hasNoPattern(".drv")));
} else {
return "GetNixStorePackagesUseCase unknown Error";
}
});
});
return Result.ok(await promise);
};
}
export class NixStoreManagerPresentation extends CoreHttpController<NixStoreModel> {
constructor() {
super({
url: "nix_store_api",
});
super.get(new GetNixStorePackagesUseCase().call);
}
}

View file

@ -9,6 +9,7 @@ import { ProcessPresentation } from "./features/process/process_presentation";
import { RealTimePresentation, pipelineRealTimeService } from "./features/realtime/realtime_presentation";
import { extensions } from "./core/extensions/extensions";
import { ProjectInstancePresentation } from "./features/project_instance/project_instance_presentation";
import { NixStoreManagerPresentation as NixStoreManagerPresentation } from "./features/nix_store_manager/nix_store_manager";
extensions();
@ -19,6 +20,7 @@ const httpRoutes: Routes[] = [
new PipelinePresentation(),
new RealTimePresentation(),
new ProjectInstancePresentation(),
new NixStoreManagerPresentation(),
].map((el) => el.call());
const socketSubscribers = [new SocketSubscriber(pipelineRealTimeService, "realtime")];

View file

@ -41,25 +41,3 @@ export const mockSimplePipeline: IPipeline[] = [
stackGenerateType: StackGenerateType.SINGLETON,
},
];
// const p: IPipeline[] = [
// {
// process: {
// type: EXEC_TYPE.EXEC,
// command: `nix run gitlab:robossembler/nix-robossembler-overlay#test-script '{
// "filesMeta":[
// {"type":"folder","name":"example", "path": null,"rewrite":true}
// ],
// "path":"$PATH"
// }'`,
// isGenerating: true,
// isLocaleCode: false,
// issueType: IssueType.WARNING,
// },
// trigger: {
// type: TriggerType.FILE,
// value: ["context"],
// },
// env: null,
// stackGenerateType: StackGenerateType.SINGLETON,
// },
// ]