@flowscripter/flowscripter-io-cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/cli.ts ADDED
@@ -0,0 +1,35 @@
1
+ import { launchMultiCommandCLI } from "@flowscripter/dynamic-cli-framework";
2
+ import copy from "./commands/copy.ts";
3
+ import deleteCommand from "./commands/delete.ts";
4
+ import getProperties from "./commands/get-properties.ts";
5
+ import hash from "./commands/hash.ts";
6
+ import list from "./commands/list.ts";
7
+ import move from "./commands/move.ts";
8
+ import setProperties from "./commands/set-properties.ts";
9
+ import {
10
+ PLUGGABLE_IO_FRAMEWORK_PACKAGE_JSON_NAMESPACE,
11
+ getPluginsNodeModulesPath,
12
+ } from "./pluginsDir.ts";
13
+ import packageJson from "../package.json";
14
+
15
+ export async function cli(): Promise<void> {
16
+ await launchMultiCommandCLI(
17
+ [list, getProperties, setProperties, deleteCommand, copy, move, hash],
18
+ "Example CLI for pluggable-io-framework.",
19
+ "flowscripter-io-cli",
20
+ packageJson.version,
21
+ undefined,
22
+ {
23
+ pluginServiceEnabled: true,
24
+ pluginServiceRemoteConfig: {
25
+ name: "npmjs",
26
+ registryUrl: "https://registry.npmjs.org",
27
+ packageJsonNamespace: PLUGGABLE_IO_FRAMEWORK_PACKAGE_JSON_NAMESPACE,
28
+ },
29
+ pluginServiceLocalConfig: {
30
+ nodeModulesPath: getPluginsNodeModulesPath(),
31
+ packageJsonNamespace: PLUGGABLE_IO_FRAMEWORK_PACKAGE_JSON_NAMESPACE,
32
+ },
33
+ },
34
+ );
35
+ }
@@ -0,0 +1,59 @@
1
+ import {
2
+ PRINTER_SERVICE_ID,
3
+ type Context,
4
+ type PrinterService,
5
+ type SubCommand,
6
+ type Values,
7
+ ValueTypeName,
8
+ } from "@flowscripter/dynamic-cli-framework";
9
+ import { copy as copyProvider } from "@flowscripter/pluggable-io-framework";
10
+ import { getFilesystemProvider } from "../filesystemProvider.ts";
11
+
12
+ const copy: SubCommand = {
13
+ name: "copy",
14
+ description: "Copy a file, using a direct provider copy when possible",
15
+ positionals: [
16
+ {
17
+ name: "source",
18
+ description: "Source path",
19
+ type: ValueTypeName.STRING,
20
+ },
21
+ {
22
+ name: "destination",
23
+ description: "Destination path",
24
+ type: ValueTypeName.STRING,
25
+ },
26
+ ],
27
+ options: [],
28
+ async execute(context: Context, argumentValues: Values): Promise<void> {
29
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
30
+ const source = argumentValues.source as string;
31
+ const destination = argumentValues.destination as string;
32
+
33
+ const provider = await getFilesystemProvider("");
34
+ try {
35
+ const { size } = await provider.getProperties(source);
36
+ const handle = await printerService.showProgressBar(
37
+ "bytes",
38
+ `Copying ${source}`,
39
+ size ?? 100,
40
+ );
41
+ try {
42
+ await copyProvider(provider, source, provider, destination, {
43
+ telemetry: {
44
+ onProgress: (event) => {
45
+ printerService.updateProgressBar(handle, event.bytesProcessed);
46
+ },
47
+ },
48
+ });
49
+ } finally {
50
+ await printerService.hideProgressBar(handle);
51
+ }
52
+ await printerService.print(`Copied ${source} to ${destination}\n`);
53
+ } finally {
54
+ await provider[Symbol.asyncDispose]();
55
+ }
56
+ },
57
+ };
58
+
59
+ export default copy;
@@ -0,0 +1,36 @@
1
+ import {
2
+ PRINTER_SERVICE_ID,
3
+ type Context,
4
+ type PrinterService,
5
+ type SubCommand,
6
+ type Values,
7
+ ValueTypeName,
8
+ } from "@flowscripter/dynamic-cli-framework";
9
+ import { getFilesystemProvider } from "../filesystemProvider.ts";
10
+
11
+ const deleteCommand: SubCommand = {
12
+ name: "delete",
13
+ description: "Delete a file/folder",
14
+ positionals: [
15
+ {
16
+ name: "path",
17
+ description: "Path to delete",
18
+ type: ValueTypeName.STRING,
19
+ },
20
+ ],
21
+ options: [],
22
+ async execute(context: Context, argumentValues: Values): Promise<void> {
23
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
24
+ const path = argumentValues.path as string;
25
+
26
+ const provider = await getFilesystemProvider("");
27
+ try {
28
+ await provider.delete(path);
29
+ await printerService.print(`Deleted ${path}\n`);
30
+ } finally {
31
+ await provider[Symbol.asyncDispose]();
32
+ }
33
+ },
34
+ };
35
+
36
+ export default deleteCommand;
@@ -0,0 +1,36 @@
1
+ import {
2
+ PRINTER_SERVICE_ID,
3
+ type Context,
4
+ type PrinterService,
5
+ type SubCommand,
6
+ type Values,
7
+ ValueTypeName,
8
+ } from "@flowscripter/dynamic-cli-framework";
9
+ import { getFilesystemProvider } from "../filesystemProvider.ts";
10
+
11
+ const getProperties: SubCommand = {
12
+ name: "get-properties",
13
+ description: "Get properties of a file/folder",
14
+ positionals: [
15
+ {
16
+ name: "path",
17
+ description: "Path to inspect",
18
+ type: ValueTypeName.STRING,
19
+ },
20
+ ],
21
+ options: [],
22
+ async execute(context: Context, argumentValues: Values): Promise<void> {
23
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
24
+ const path = argumentValues.path as string;
25
+
26
+ const provider = await getFilesystemProvider("");
27
+ try {
28
+ const properties = await provider.getProperties(path);
29
+ await printerService.print(`${JSON.stringify(properties, null, 2)}\n`);
30
+ } finally {
31
+ await provider[Symbol.asyncDispose]();
32
+ }
33
+ },
34
+ };
35
+
36
+ export default getProperties;
@@ -0,0 +1,60 @@
1
+ import {
2
+ PRINTER_SERVICE_ID,
3
+ type Context,
4
+ type PrinterService,
5
+ type SubCommand,
6
+ type Values,
7
+ ValueTypeName,
8
+ } from "@flowscripter/dynamic-cli-framework";
9
+ import { ChunkKind, type ChunkRef } from "@flowscripter/pluggable-io-framework-api";
10
+ import { getFilesystemProvider } from "../filesystemProvider.ts";
11
+
12
+ const hash: SubCommand = {
13
+ name: "hash",
14
+ description: "Hash a file by piping its readable stream through a hasher",
15
+ positionals: [
16
+ {
17
+ name: "path",
18
+ description: "Path to hash",
19
+ type: ValueTypeName.STRING,
20
+ },
21
+ ],
22
+ options: [
23
+ {
24
+ name: "algorithm",
25
+ description: "Hash algorithm",
26
+ type: ValueTypeName.STRING,
27
+ shortAlias: "a",
28
+ isOptional: true,
29
+ defaultValue: "sha256",
30
+ },
31
+ ],
32
+ async execute(context: Context, argumentValues: Values): Promise<void> {
33
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
34
+ const path = argumentValues.path as string;
35
+ const algorithm = argumentValues.algorithm as string;
36
+
37
+ const provider = await getFilesystemProvider("");
38
+ try {
39
+ const handle = await provider.getReadableStream(path);
40
+ const reader = (handle.stream as ReadableStream<ChunkRef>).getReader();
41
+ const hasher = new Bun.CryptoHasher(
42
+ algorithm as ConstructorParameters<typeof Bun.CryptoHasher>[0],
43
+ );
44
+ for (;;) {
45
+ const { done, value } = await reader.read();
46
+ if (done) break;
47
+ if (value.kind === ChunkKind.Js) {
48
+ hasher.update(value.data);
49
+ } else {
50
+ throw new Error("hash command only supports js-kind chunks in this version");
51
+ }
52
+ }
53
+ await printerService.print(`${hasher.digest("hex")} ${path}\n`);
54
+ } finally {
55
+ await provider[Symbol.asyncDispose]();
56
+ }
57
+ },
58
+ };
59
+
60
+ export default hash;
@@ -0,0 +1,58 @@
1
+ import {
2
+ PRINTER_SERVICE_ID,
3
+ type Context,
4
+ type PrinterService,
5
+ type SubCommand,
6
+ type Values,
7
+ ValueTypeName,
8
+ } from "@flowscripter/dynamic-cli-framework";
9
+ import { getFilesystemProvider } from "../filesystemProvider.ts";
10
+
11
+ const list: SubCommand = {
12
+ name: "list",
13
+ description: "List files/folders, optionally recursive and filtered by regex",
14
+ positionals: [
15
+ {
16
+ name: "path",
17
+ description: "Path to list",
18
+ type: ValueTypeName.STRING,
19
+ },
20
+ ],
21
+ options: [
22
+ {
23
+ name: "recursive",
24
+ description: "List recursively",
25
+ type: ValueTypeName.BOOLEAN,
26
+ shortAlias: "r",
27
+ isOptional: true,
28
+ defaultValue: false,
29
+ },
30
+ {
31
+ name: "regex",
32
+ description: "Only list items whose path matches this regex",
33
+ type: ValueTypeName.STRING,
34
+ shortAlias: "e",
35
+ isOptional: true,
36
+ },
37
+ ],
38
+ async execute(context: Context, argumentValues: Values): Promise<void> {
39
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
40
+ const path = argumentValues.path as string;
41
+ const recursive = argumentValues.recursive as boolean | undefined;
42
+ const regex = argumentValues.regex as string | undefined;
43
+
44
+ const provider = await getFilesystemProvider("");
45
+ try {
46
+ for await (const item of provider.list(path, {
47
+ recursive,
48
+ regex: regex ? new RegExp(regex) : undefined,
49
+ })) {
50
+ await printerService.print(`${JSON.stringify({ path: item.path, ...item.properties })}\n`);
51
+ }
52
+ } finally {
53
+ await provider[Symbol.asyncDispose]();
54
+ }
55
+ },
56
+ };
57
+
58
+ export default list;
@@ -0,0 +1,55 @@
1
+ import {
2
+ PRINTER_SERVICE_ID,
3
+ type Context,
4
+ type PrinterService,
5
+ type SubCommand,
6
+ type Values,
7
+ ValueTypeName,
8
+ } from "@flowscripter/dynamic-cli-framework";
9
+ import { move as moveProvider } from "@flowscripter/pluggable-io-framework";
10
+ import { getFilesystemProvider } from "../filesystemProvider.ts";
11
+
12
+ const move: SubCommand = {
13
+ name: "move",
14
+ description: "Move a file, using a direct provider move when possible",
15
+ positionals: [
16
+ {
17
+ name: "source",
18
+ description: "Source path",
19
+ type: ValueTypeName.STRING,
20
+ },
21
+ {
22
+ name: "destination",
23
+ description: "Destination path",
24
+ type: ValueTypeName.STRING,
25
+ },
26
+ ],
27
+ options: [],
28
+ async execute(context: Context, argumentValues: Values): Promise<void> {
29
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
30
+ const source = argumentValues.source as string;
31
+ const destination = argumentValues.destination as string;
32
+
33
+ const provider = await getFilesystemProvider("");
34
+ try {
35
+ const { size } = await provider.getProperties(source);
36
+ const handle = await printerService.showProgressBar("bytes", `Moving ${source}`, size ?? 100);
37
+ try {
38
+ await moveProvider(provider, source, provider, destination, {
39
+ telemetry: {
40
+ onProgress: (event) => {
41
+ printerService.updateProgressBar(handle, event.bytesProcessed);
42
+ },
43
+ },
44
+ });
45
+ } finally {
46
+ await printerService.hideProgressBar(handle);
47
+ }
48
+ await printerService.print(`Moved ${source} to ${destination}\n`);
49
+ } finally {
50
+ await provider[Symbol.asyncDispose]();
51
+ }
52
+ },
53
+ };
54
+
55
+ export default move;
@@ -0,0 +1,45 @@
1
+ import {
2
+ PRINTER_SERVICE_ID,
3
+ type Context,
4
+ type PrinterService,
5
+ type SubCommand,
6
+ type Values,
7
+ ValueTypeName,
8
+ } from "@flowscripter/dynamic-cli-framework";
9
+ import { getFilesystemProvider } from "../filesystemProvider.ts";
10
+
11
+ const setProperties: SubCommand = {
12
+ name: "set-properties",
13
+ description: "Set properties of a file/folder",
14
+ positionals: [
15
+ {
16
+ name: "path",
17
+ description: "Path to modify",
18
+ type: ValueTypeName.STRING,
19
+ },
20
+ ],
21
+ options: [
22
+ {
23
+ name: "mode",
24
+ description: "Unix file mode to apply e.g. 384 for 0o600 (ignored on Windows)",
25
+ type: ValueTypeName.NUMBER,
26
+ shortAlias: "m",
27
+ isOptional: true,
28
+ },
29
+ ],
30
+ async execute(context: Context, argumentValues: Values): Promise<void> {
31
+ const printerService = context.getServiceById(PRINTER_SERVICE_ID) as PrinterService;
32
+ const path = argumentValues.path as string;
33
+ const mode = argumentValues.mode as number | undefined;
34
+
35
+ const provider = await getFilesystemProvider("");
36
+ try {
37
+ await provider.setProperties(path, mode !== undefined ? { mode } : {});
38
+ await printerService.print(`Updated properties for ${path}\n`);
39
+ } finally {
40
+ await provider[Symbol.asyncDispose]();
41
+ }
42
+ },
43
+ };
44
+
45
+ export default setProperties;
@@ -0,0 +1,40 @@
1
+ import { DefaultPluginManager, NpmPluginRepository } from "@flowscripter/dynamic-plugin-framework";
2
+ import {
3
+ PLUGGABLE_IO_FRAMEWORK_PROVIDER_FACTORY_EXTENSION_POINT,
4
+ type IOProvider,
5
+ type IOProviderFactory,
6
+ } from "@flowscripter/pluggable-io-framework-api";
7
+ import {
8
+ PLUGGABLE_IO_FRAMEWORK_PACKAGE_JSON_NAMESPACE,
9
+ getPluginsNodeModulesPath,
10
+ } from "./pluginsDir.ts";
11
+
12
+ /**
13
+ * Discovers and instantiates the filesystem provider (`io-plugin-filesystem`
14
+ * or any other installed provider-factory plugin) purely via
15
+ * `dynamic-plugin-framework`'s `NpmPluginRepository`, scanning the same
16
+ * local plugin store the CLI's `plugin:add` command installs into (see
17
+ * cli.ts) - this package has no direct npm dependency on any provider
18
+ * plugin; it must be installed by the user first, e.g.
19
+ * `flowscripter-io-cli plugin:add @flowscripter/io-plugin-filesystem`.
20
+ */
21
+ export async function getFilesystemProvider(rootPath: string): Promise<IOProvider> {
22
+ const repository = new NpmPluginRepository({
23
+ nodeModulesPath: getPluginsNodeModulesPath(),
24
+ packageJsonNamespace: PLUGGABLE_IO_FRAMEWORK_PACKAGE_JSON_NAMESPACE,
25
+ });
26
+
27
+ const pluginManager = new DefaultPluginManager([repository]);
28
+ await pluginManager.registerExtensions(PLUGGABLE_IO_FRAMEWORK_PROVIDER_FACTORY_EXTENSION_POINT);
29
+ const [extension] = await pluginManager.getRegisteredExtensions(
30
+ PLUGGABLE_IO_FRAMEWORK_PROVIDER_FACTORY_EXTENSION_POINT,
31
+ );
32
+ if (!extension) {
33
+ throw new Error(
34
+ "No pluggable-io-framework provider plugin installed - run: " +
35
+ "flowscripter-io-cli plugin:add @flowscripter/io-plugin-filesystem",
36
+ );
37
+ }
38
+ const factory = (await pluginManager.instantiate(extension.extensionHandle)) as IOProviderFactory;
39
+ return factory.createProvider(factory.configSchema.parse({ rootPath }));
40
+ }
@@ -0,0 +1,21 @@
1
+ import { homedir } from "node:os";
2
+ import { join } from "node:path";
3
+
4
+ export const PLUGGABLE_IO_FRAMEWORK_PACKAGE_JSON_NAMESPACE = "pluggable-io-framework";
5
+
6
+ /**
7
+ * Local plugin install directory shared between the CLI's built-in plugin
8
+ * service (`plugin add`/`plugin list`, see cli.ts) and our own
9
+ * NpmPluginRepository scan for provider-factory extensions (see
10
+ * filesystemProvider.ts) - both must point at the same install location.
11
+ *
12
+ * Overridable via FLOWSCRIPTER_IO_CLI_PLUGINS_PATH so tests can point at a
13
+ * temp directory instead of the real home directory. Read at call time (not
14
+ * cached at module load) so a test can set the env var in `beforeAll`.
15
+ */
16
+ export function getPluginsNodeModulesPath(): string {
17
+ return (
18
+ process.env.FLOWSCRIPTER_IO_CLI_PLUGINS_PATH ??
19
+ join(homedir(), ".flowscripter-io-cli", "plugins", "node_modules")
20
+ );
21
+ }
@@ -0,0 +1,135 @@
1
+ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from "bun:test";
2
+ import { mkdir, mkdtemp, rm, symlink, writeFile } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import { join, resolve } from "node:path";
5
+ import copy from "../src/commands/copy.ts";
6
+ import deleteCommand from "../src/commands/delete.ts";
7
+ import getProperties from "../src/commands/get-properties.ts";
8
+ import hash from "../src/commands/hash.ts";
9
+ import list from "../src/commands/list.ts";
10
+ import move from "../src/commands/move.ts";
11
+ import setProperties from "../src/commands/set-properties.ts";
12
+ import { createStubContext } from "./testContext.ts";
13
+
14
+ let root: string;
15
+ let pluginsPath: string;
16
+
17
+ beforeAll(async () => {
18
+ // Simulate `flowscripter-io-cli plugin:add @flowscripter/io-plugin-filesystem`
19
+ // by symlinking the real published package (a devDependency here purely
20
+ // for test setup - never a runtime dependency of this CLI) into a temp
21
+ // plugin store, discovered purely via NpmPluginRepository.
22
+ pluginsPath = await mkdtemp(join(tmpdir(), "flowscripter-io-cli-plugins-test-"));
23
+ await mkdir(join(pluginsPath, "@flowscripter"), { recursive: true });
24
+ await symlink(
25
+ resolve(import.meta.dir, "..", "node_modules", "@flowscripter", "io-plugin-filesystem"),
26
+ join(pluginsPath, "@flowscripter", "io-plugin-filesystem"),
27
+ "junction",
28
+ );
29
+ process.env.FLOWSCRIPTER_IO_CLI_PLUGINS_PATH = pluginsPath;
30
+ });
31
+
32
+ afterAll(async () => {
33
+ delete process.env.FLOWSCRIPTER_IO_CLI_PLUGINS_PATH;
34
+ await rm(pluginsPath, { recursive: true, force: true });
35
+ });
36
+
37
+ beforeEach(async () => {
38
+ root = await mkdtemp(join(tmpdir(), "flowscripter-io-cli-test-"));
39
+ });
40
+
41
+ afterEach(async () => {
42
+ await rm(root, { recursive: true, force: true });
43
+ });
44
+
45
+ describe("list", () => {
46
+ test("prints one JSON line per item", async () => {
47
+ await writeFile(join(root, "a.txt"), "hello");
48
+ const { lines, context } = createStubContext();
49
+
50
+ await list.execute(context, { path: root });
51
+
52
+ expect(lines.length).toBe(1);
53
+ expect(JSON.parse(lines[0]!).path).toBe("a.txt");
54
+ });
55
+ });
56
+
57
+ describe("get-properties", () => {
58
+ test("prints properties as JSON", async () => {
59
+ await writeFile(join(root, "a.txt"), "hello");
60
+ const { lines, context } = createStubContext();
61
+
62
+ await getProperties.execute(context, { path: join(root, "a.txt") });
63
+
64
+ expect(JSON.parse(lines[0]!).size).toBe(5);
65
+ });
66
+ });
67
+
68
+ describe("set-properties", () => {
69
+ test("applies mode", async () => {
70
+ await writeFile(join(root, "a.txt"), "hello");
71
+ const { context } = createStubContext();
72
+
73
+ await setProperties.execute(context, { path: join(root, "a.txt"), mode: 0o600 });
74
+
75
+ const { lines, context: getPropertiesContext } = createStubContext();
76
+ await getProperties.execute(getPropertiesContext, { path: join(root, "a.txt") });
77
+ const properties = JSON.parse(lines[0]!);
78
+ if (process.platform !== "win32") {
79
+ expect(properties.properties.mode & 0o777).toBe(0o600);
80
+ }
81
+ });
82
+ });
83
+
84
+ describe("delete", () => {
85
+ test("removes a file", async () => {
86
+ await writeFile(join(root, "a.txt"), "hello");
87
+ const { context } = createStubContext();
88
+
89
+ await deleteCommand.execute(context, { path: join(root, "a.txt") });
90
+
91
+ const { lines, context: listContext } = createStubContext();
92
+ await list.execute(listContext, { path: root });
93
+ expect(lines.length).toBe(0);
94
+ });
95
+ });
96
+
97
+ describe("copy", () => {
98
+ test("copies a file", async () => {
99
+ await writeFile(join(root, "a.txt"), "hello");
100
+ const { context } = createStubContext();
101
+
102
+ await copy.execute(context, { source: join(root, "a.txt"), destination: join(root, "b.txt") });
103
+
104
+ const { lines } = createStubContext();
105
+ const { context: getPropsContext, lines: getPropsLines } = createStubContext();
106
+ await getProperties.execute(getPropsContext, { path: join(root, "b.txt") });
107
+ expect(JSON.parse(getPropsLines[0]!).size).toBe(5);
108
+ expect(lines).toEqual([]);
109
+ });
110
+ });
111
+
112
+ describe("move", () => {
113
+ test("moves a file", async () => {
114
+ await writeFile(join(root, "a.txt"), "hello");
115
+ const { context } = createStubContext();
116
+
117
+ await move.execute(context, { source: join(root, "a.txt"), destination: join(root, "b.txt") });
118
+
119
+ const { lines, context: listContext } = createStubContext();
120
+ await list.execute(listContext, { path: root });
121
+ expect(lines.map((line) => JSON.parse(line).path)).toEqual(["b.txt"]);
122
+ });
123
+ });
124
+
125
+ describe("hash", () => {
126
+ test("hashes a file with the default algorithm", async () => {
127
+ await writeFile(join(root, "a.txt"), "hello");
128
+ const { lines, context } = createStubContext();
129
+
130
+ await hash.execute(context, { path: join(root, "a.txt"), algorithm: "sha256" });
131
+
132
+ const expected = new Bun.CryptoHasher("sha256").update("hello").digest("hex");
133
+ expect(lines[0]).toBe(`${expected} ${join(root, "a.txt")}\n`);
134
+ });
135
+ });
@@ -0,0 +1,35 @@
1
+ import {
2
+ PRINTER_SERVICE_ID,
3
+ type Context,
4
+ type PrinterService,
5
+ } from "@flowscripter/dynamic-cli-framework";
6
+
7
+ export interface StubPrinter {
8
+ lines: string[];
9
+ context: Context;
10
+ }
11
+
12
+ /**
13
+ * Minimal Context/PrinterService stub - only the PrinterService members our
14
+ * commands actually call are implemented; everything else would throw if
15
+ * invoked, which is intentional (a test relying on it should fail loudly).
16
+ */
17
+ export function createStubContext(): StubPrinter {
18
+ const lines: string[] = [];
19
+ const printerService = {
20
+ print: async (message: string) => {
21
+ lines.push(message);
22
+ },
23
+ showProgressBar: async () => 0,
24
+ updateProgressBar: () => {},
25
+ hideProgressBar: async () => {},
26
+ } as unknown as PrinterService;
27
+
28
+ const context: Context = {
29
+ cliConfig: { name: "test", version: "0.0.0" },
30
+ getServiceById: (id: string) => (id === PRINTER_SERVICE_ID ? printerService : undefined),
31
+ doesServiceExist: (id: string) => id === PRINTER_SERVICE_ID,
32
+ };
33
+
34
+ return { lines, context };
35
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "compilerOptions": {
3
+ // Enable latest features
4
+ "lib": ["ESNext", "DOM"],
5
+ "target": "ESNext",
6
+ "module": "ESNext",
7
+ "moduleDetection": "force",
8
+ "jsx": "react-jsx",
9
+ "allowJs": true,
10
+
11
+ "types": ["bun", "node"],
12
+
13
+ // Bundler mode
14
+ "moduleResolution": "bundler",
15
+ "allowImportingTsExtensions": true,
16
+ "verbatimModuleSyntax": true,
17
+ "noEmit": true,
18
+
19
+ // Best practices
20
+ "strict": true,
21
+ "skipLibCheck": true,
22
+ "noFallthroughCasesInSwitch": true,
23
+
24
+ // Some stricter flags (disabled by default)
25
+ "noUnusedLocals": false,
26
+ "noUnusedParameters": false,
27
+ "noPropertyAccessFromIndexSignature": false
28
+ },
29
+ "exclude": ["dist"]
30
+ }