@rafads/cli 0.2.45

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/README.md ADDED
@@ -0,0 +1,9 @@
1
+ # @rafads/cli
2
+
3
+ Minimal command-line entrypoint for Executor projects.
4
+
5
+ Schema generation and migrations are owned by FumaDB now. Hosts should build a
6
+ FumaDB client from `collectTables(plugins)` and use FumaDB's adapter/migrator
7
+ APIs directly instead of generating Executor-specific storage adapters. Plugins
8
+ persist through Executor's host-owned storage facades rather than contributing
9
+ tables.
@@ -0,0 +1,2 @@
1
+ import { Command } from "commander";
2
+ export declare const schema: Command;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/index.ts
4
+ import { Command as Command2 } from "commander";
5
+
6
+ // src/commands/schema.ts
7
+ import { existsSync } from "fs";
8
+ import fs from "fs/promises";
9
+ import path from "path";
10
+ import { Command } from "commander";
11
+ import { collectTables } from "@rafads/sdk/core";
12
+ var schemaGenerateAction = async (opts) => {
13
+ const cwd = path.resolve(opts.cwd);
14
+ if (!existsSync(cwd)) {
15
+ console.error(`The directory "${cwd}" does not exist.`);
16
+ process.exit(1);
17
+ }
18
+ if (opts.adapter !== "drizzle") {
19
+ console.error(`Unsupported schema adapter "${opts.adapter}". Supported adapters: drizzle.`);
20
+ process.exit(1);
21
+ }
22
+ if (opts.provider !== "mysql" && opts.provider !== "postgresql" && opts.provider !== "sqlite") {
23
+ console.error(
24
+ `Unsupported drizzle provider "${opts.provider}". Supported providers: mysql, postgresql, sqlite.`
25
+ );
26
+ process.exit(1);
27
+ }
28
+ const [{ fumadb }, { drizzleAdapter }, { schema: fumaSchema }] = await Promise.all([
29
+ import("@rafads/fumadb"),
30
+ import("@rafads/fumadb/adapters/drizzle"),
31
+ import("@rafads/fumadb/schema")
32
+ ]);
33
+ const schema2 = fumaSchema({
34
+ version: opts.version,
35
+ tables: collectTables()
36
+ });
37
+ const factory = fumadb({
38
+ namespace: opts.namespace,
39
+ schemas: [schema2]
40
+ });
41
+ const generated = factory.client(
42
+ drizzleAdapter({
43
+ db: {},
44
+ provider: opts.provider
45
+ })
46
+ ).generateSchema("latest", opts.namespace);
47
+ const output = opts.output ?? generated.path;
48
+ const outPath = path.resolve(cwd, output);
49
+ await fs.mkdir(path.dirname(outPath), { recursive: true });
50
+ await fs.writeFile(outPath, generated.code);
51
+ console.log(`Schema generated: ${path.relative(cwd, outPath)}`);
52
+ };
53
+ var schema = new Command("schema").description("Database schema utilities").addCommand(
54
+ new Command("generate").description("Generate the ORM schema file for the executor's fixed table set").option("-c, --cwd <cwd>", "the working directory", process.cwd()).option("--output <output>", "output file path for the generated schema").option("--namespace <namespace>", "FumaDB namespace", "executor").option("--adapter <adapter>", "FumaDB adapter", "drizzle").option("--provider <provider>", "database provider", "postgresql").option("--version <version>", "FumaDB schema version", "1.0.0").action(schemaGenerateAction)
55
+ );
56
+
57
+ // src/index.ts
58
+ process.on("SIGINT", () => process.exit(0));
59
+ process.on("SIGTERM", () => process.exit(0));
60
+ var program = new Command2("raf-sdk").version("0.0.1").description("Executor SDK CLI").addCommand(schema).action(() => program.help());
61
+ await program.parseAsync();
62
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts","../src/commands/schema.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { Command } from \"commander\";\nimport { schema } from \"./commands/schema.js\";\n\nprocess.on(\"SIGINT\", () => process.exit(0));\nprocess.on(\"SIGTERM\", () => process.exit(0));\n\nconst program = new Command(\"raf-sdk\")\n .version(\"0.0.1\")\n .description(\"Executor SDK CLI\")\n .addCommand(schema)\n .action(() => program.help());\n\nawait program.parseAsync();\n","import { existsSync } from \"node:fs\";\nimport fs from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { Command } from \"commander\";\nimport { collectTables } from \"@rafads/sdk/core\";\n\n// The executor's table set is fixed and plugin-independent (`collectTables()`),\n// so schema generation needs no `executor.config.ts` — only the target ORM\n// namespace/adapter/provider. The same tables render per database via flags.\n\ntype SchemaGenerateOptions = {\n readonly cwd: string;\n readonly output?: string;\n readonly namespace: string;\n readonly adapter: string;\n readonly provider: string;\n readonly version: string;\n};\n\nconst schemaGenerateAction = async (opts: SchemaGenerateOptions) => {\n const cwd = path.resolve(opts.cwd);\n if (!existsSync(cwd)) {\n console.error(`The directory \"${cwd}\" does not exist.`);\n process.exit(1);\n }\n\n if (opts.adapter !== \"drizzle\") {\n console.error(`Unsupported schema adapter \"${opts.adapter}\". Supported adapters: drizzle.`);\n process.exit(1);\n }\n if (opts.provider !== \"mysql\" && opts.provider !== \"postgresql\" && opts.provider !== \"sqlite\") {\n console.error(\n `Unsupported drizzle provider \"${opts.provider}\". Supported providers: mysql, postgresql, sqlite.`,\n );\n process.exit(1);\n }\n\n const [{ fumadb }, { drizzleAdapter }, { schema: fumaSchema }] = await Promise.all([\n import(\"@rafads/fumadb\"),\n import(\"@rafads/fumadb/adapters/drizzle\"),\n import(\"@rafads/fumadb/schema\"),\n ]);\n\n const schema = fumaSchema({\n version: opts.version,\n tables: collectTables(),\n });\n const factory = fumadb({\n namespace: opts.namespace,\n schemas: [schema],\n });\n const generated = factory\n .client(\n drizzleAdapter({\n db: {},\n provider: opts.provider,\n }),\n )\n .generateSchema(\"latest\", opts.namespace);\n\n const output = opts.output ?? generated.path;\n const outPath = path.resolve(cwd, output);\n await fs.mkdir(path.dirname(outPath), { recursive: true });\n await fs.writeFile(outPath, generated.code);\n console.log(`Schema generated: ${path.relative(cwd, outPath)}`);\n};\n\nexport const schema = new Command(\"schema\")\n .description(\"Database schema utilities\")\n .addCommand(\n new Command(\"generate\")\n .description(\"Generate the ORM schema file for the executor's fixed table set\")\n .option(\"-c, --cwd <cwd>\", \"the working directory\", process.cwd())\n .option(\"--output <output>\", \"output file path for the generated schema\")\n .option(\"--namespace <namespace>\", \"FumaDB namespace\", \"executor\")\n .option(\"--adapter <adapter>\", \"FumaDB adapter\", \"drizzle\")\n .option(\"--provider <provider>\", \"database provider\", \"postgresql\")\n .option(\"--version <version>\", \"FumaDB schema version\", \"1.0.0\")\n .action(schemaGenerateAction),\n );\n"],"mappings":";;;AAEA,SAAS,WAAAA,gBAAe;;;ACFxB,SAAS,kBAAkB;AAC3B,OAAO,QAAQ;AACf,OAAO,UAAU;AACjB,SAAS,eAAe;AACxB,SAAS,qBAAqB;AAe9B,IAAM,uBAAuB,OAAO,SAAgC;AAClE,QAAM,MAAM,KAAK,QAAQ,KAAK,GAAG;AACjC,MAAI,CAAC,WAAW,GAAG,GAAG;AACpB,YAAQ,MAAM,kBAAkB,GAAG,mBAAmB;AACtD,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,MAAI,KAAK,YAAY,WAAW;AAC9B,YAAQ,MAAM,+BAA+B,KAAK,OAAO,iCAAiC;AAC1F,YAAQ,KAAK,CAAC;AAAA,EAChB;AACA,MAAI,KAAK,aAAa,WAAW,KAAK,aAAa,gBAAgB,KAAK,aAAa,UAAU;AAC7F,YAAQ;AAAA,MACN,iCAAiC,KAAK,QAAQ;AAAA,IAChD;AACA,YAAQ,KAAK,CAAC;AAAA,EAChB;AAEA,QAAM,CAAC,EAAE,OAAO,GAAG,EAAE,eAAe,GAAG,EAAE,QAAQ,WAAW,CAAC,IAAI,MAAM,QAAQ,IAAI;AAAA,IACjF,OAAO,gBAAgB;AAAA,IACvB,OAAO,iCAAiC;AAAA,IACxC,OAAO,uBAAuB;AAAA,EAChC,CAAC;AAED,QAAMC,UAAS,WAAW;AAAA,IACxB,SAAS,KAAK;AAAA,IACd,QAAQ,cAAc;AAAA,EACxB,CAAC;AACD,QAAM,UAAU,OAAO;AAAA,IACrB,WAAW,KAAK;AAAA,IAChB,SAAS,CAACA,OAAM;AAAA,EAClB,CAAC;AACD,QAAM,YAAY,QACf;AAAA,IACC,eAAe;AAAA,MACb,IAAI,CAAC;AAAA,MACL,UAAU,KAAK;AAAA,IACjB,CAAC;AAAA,EACH,EACC,eAAe,UAAU,KAAK,SAAS;AAE1C,QAAM,SAAS,KAAK,UAAU,UAAU;AACxC,QAAM,UAAU,KAAK,QAAQ,KAAK,MAAM;AACxC,QAAM,GAAG,MAAM,KAAK,QAAQ,OAAO,GAAG,EAAE,WAAW,KAAK,CAAC;AACzD,QAAM,GAAG,UAAU,SAAS,UAAU,IAAI;AAC1C,UAAQ,IAAI,qBAAqB,KAAK,SAAS,KAAK,OAAO,CAAC,EAAE;AAChE;AAEO,IAAM,SAAS,IAAI,QAAQ,QAAQ,EACvC,YAAY,2BAA2B,EACvC;AAAA,EACC,IAAI,QAAQ,UAAU,EACnB,YAAY,iEAAiE,EAC7E,OAAO,mBAAmB,yBAAyB,QAAQ,IAAI,CAAC,EAChE,OAAO,qBAAqB,2CAA2C,EACvE,OAAO,2BAA2B,oBAAoB,UAAU,EAChE,OAAO,uBAAuB,kBAAkB,SAAS,EACzD,OAAO,yBAAyB,qBAAqB,YAAY,EACjE,OAAO,uBAAuB,yBAAyB,OAAO,EAC9D,OAAO,oBAAoB;AAChC;;;AD1EF,QAAQ,GAAG,UAAU,MAAM,QAAQ,KAAK,CAAC,CAAC;AAC1C,QAAQ,GAAG,WAAW,MAAM,QAAQ,KAAK,CAAC,CAAC;AAE3C,IAAM,UAAU,IAAIC,SAAQ,SAAS,EAClC,QAAQ,OAAO,EACf,YAAY,kBAAkB,EAC9B,WAAW,MAAM,EACjB,OAAO,MAAM,QAAQ,KAAK,CAAC;AAE9B,MAAM,QAAQ,WAAW;","names":["Command","schema","Command"]}
@@ -0,0 +1,5 @@
1
+ import type { ExecutorCliConfig } from "@rafads/sdk/core";
2
+ export declare const getConfig: (opts: {
3
+ cwd: string;
4
+ configPath?: string;
5
+ }) => Promise<ExecutorCliConfig | null>;
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@rafads/cli",
3
+ "version": "0.2.45",
4
+ "description": "CLI for the executor SDK — schema generation, migrations",
5
+ "homepage": "https://github.com/UsefulSoftwareCo/executor/tree/main/packages/core/cli",
6
+ "bugs": {
7
+ "url": "https://github.com/UsefulSoftwareCo/executor/issues"
8
+ },
9
+ "license": "MIT",
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/UsefulSoftwareCo/executor.git",
13
+ "directory": "packages/core/cli"
14
+ },
15
+ "bin": {
16
+ "raf-sdk": "./dist/index.js"
17
+ },
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "type": "module",
22
+ "exports": {
23
+ ".": {
24
+ "import": {
25
+ "types": "./dist/index.d.ts",
26
+ "default": "./dist/index.js"
27
+ }
28
+ }
29
+ },
30
+ "publishConfig": {
31
+ "access": "public"
32
+ },
33
+ "scripts": {
34
+ "build": "tsup && tsc --declaration --emitDeclarationOnly --outDir dist --rootDir src",
35
+ "dev": "node --import jiti/register src/index.ts",
36
+ "test": "vitest run",
37
+ "typecheck": "tsc --noEmit"
38
+ },
39
+ "dependencies": {
40
+ "@rafads/fumadb": "1.5.7",
41
+ "@rafads/sdk": "1.5.38",
42
+ "commander": "^12.1.0",
43
+ "effect": "4.0.0-beta.59",
44
+ "jiti": "^2.6.1"
45
+ },
46
+ "devDependencies": {
47
+ "@effect/vitest": "4.0.0-beta.59",
48
+ "@types/node": "^24.3.1",
49
+ "tsup": "^8.5.0",
50
+ "typescript": "^5.9.3",
51
+ "vitest": "^4.1.4"
52
+ }
53
+ }