From 48daa3f2cb9f187160822ff24b91ce8f993ad52d Mon Sep 17 00:00:00 2001 From: Amine Ben hammou Date: Sat, 7 Sep 2024 23:17:47 +0200 Subject: [PATCH] Export internal functions --- package.json | 2 +- src/index.ts | 6 ++++-- src/operations.ts | 7 ------- src/services/assertions.ts | 6 ------ src/services/index.ts | 2 +- src/services/tasks.ts | 6 ++++++ src/types.ts | 2 +- tests/utils/index.ts | 4 +++- 8 files changed, 16 insertions(+), 19 deletions(-) delete mode 100644 src/operations.ts delete mode 100644 src/services/assertions.ts create mode 100644 src/services/tasks.ts diff --git a/package.json b/package.json index 6fbeb72..eae6037 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hosty", - "version": "0.0.1-alpha.3", + "version": "0.0.1-alpha.4", "description": "A code based opinionated way to self-host and manage web apps.", "type": "module", "main": "dist/index.js", diff --git a/src/index.ts b/src/index.ts index 38d4f9a..d9252a5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,9 +1,11 @@ import { instance } from './instance.js' +import * as blocks from './blocks/index.js' +import * as ansible from './ansible/index.js' export * from './types.js' export * from './services/index.js' export { server } from './server.js' -export { assert } from './blocks/index.js' -export { instance } export const { deploy, destroy, playbook, write, run } = instance() + +export const internals = {ansible, blocks, instance} \ No newline at end of file diff --git a/src/operations.ts b/src/operations.ts deleted file mode 100644 index 754aa96..0000000 --- a/src/operations.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { AnyTask } from './ansible/types.js' - -export function add_condition(task: AnyTask, condition: string): AnyTask { - if (task.when) task.when = `(${condition}) and (${task.when})` - else task.when = condition - return task -} diff --git a/src/services/assertions.ts b/src/services/assertions.ts deleted file mode 100644 index 25382d7..0000000 --- a/src/services/assertions.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { Tasks } from '../ansible/types.js' -import { Assertions } from '../types.js' - -export function assertions(...tasks: Tasks): Assertions { - return { type: 'assertions', get_deploy_tasks: () => tasks, get_destroy_tasks: () => [] } -} diff --git a/src/services/index.ts b/src/services/index.ts index ff95c91..bc281d9 100644 --- a/src/services/index.ts +++ b/src/services/index.ts @@ -1,5 +1,5 @@ export * as app from './app/index.js' -export * from './assertions.js' +export * from './tasks.js' export * from './command.js' export * from './container.js' export * as db from './database/index.js' diff --git a/src/services/tasks.ts b/src/services/tasks.ts new file mode 100644 index 0000000..30fc320 --- /dev/null +++ b/src/services/tasks.ts @@ -0,0 +1,6 @@ +import { Tasks } from '../ansible/types.js' +import { TasksService } from '../types.js' + +export function assertions(...tasks: Tasks): TasksService { + return { type: 'tasks', get_deploy_tasks: () => tasks, get_destroy_tasks: () => [] } +} diff --git a/src/types.ts b/src/types.ts index 7eff248..d3fc893 100644 --- a/src/types.ts +++ b/src/types.ts @@ -129,7 +129,7 @@ export type CommandConfig = { export type Command = Service<'command'> & CommandConfig -export type Assertions = Service<'assertions'> +export type TasksService = Service<'tasks'> export type RunOptions = { playbook_path: string diff --git a/tests/utils/index.ts b/tests/utils/index.ts index f35c098..290ae22 100644 --- a/tests/utils/index.ts +++ b/tests/utils/index.ts @@ -1,6 +1,8 @@ import * as zx from 'zx' import { ChildProcess } from 'child_process' -import { HostyInstance, Server, Service, assert, assertions, instance, server } from '../../src/index.js' +import { HostyInstance, Server, Service, assertions, server, internals } from '../../src/index.js' + +const { instance, blocks: { assert } } = internals type Assert = { [K in keyof typeof assert]: (...args: Parameters<(typeof assert)[K]>) => void