@ldlework/workmark 1.2.0 → 1.3.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/dist/cli.js +3 -3
- package/dist/lib/jiti-options.d.ts +1 -1
- package/dist/lib/jiti-options.js +1 -1
- package/dist/lib/load.js +1 -1
- package/dist/lib/types.d.ts +1 -1
- package/dist/lib/workspace.js +13 -13
- package/package.json +2 -2
- package/src/cli.ts +3 -3
- package/src/lib/jiti-options.ts +1 -1
- package/src/lib/load.ts +1 -1
- package/src/lib/types.ts +2 -2
- package/src/lib/workspace.ts +13 -13
package/dist/cli.js
CHANGED
|
@@ -6,7 +6,7 @@ import { parseArgs } from "./lib/parse.js";
|
|
|
6
6
|
// Help
|
|
7
7
|
// ---------------------------------------------------------------------------
|
|
8
8
|
function printHelp(commands) {
|
|
9
|
-
console.log("Usage:
|
|
9
|
+
console.log("Usage: wm <command> [args...]\n");
|
|
10
10
|
// Group by group name
|
|
11
11
|
const groups = new Map();
|
|
12
12
|
for (const cmd of commands) {
|
|
@@ -43,7 +43,7 @@ function printHelp(commands) {
|
|
|
43
43
|
}
|
|
44
44
|
function printCommandHelp(cmd) {
|
|
45
45
|
const pos = cmd.positional.map((p) => `<${p}>`).join(" ");
|
|
46
|
-
console.log(`Usage:
|
|
46
|
+
console.log(`Usage: wm ${cmd.name} ${pos}\n`);
|
|
47
47
|
console.log(cmd.description);
|
|
48
48
|
const schema = cmd.inputSchema;
|
|
49
49
|
const props = schema.properties;
|
|
@@ -88,7 +88,7 @@ async function main() {
|
|
|
88
88
|
const cmd = cmdMap.get(command);
|
|
89
89
|
if (!cmd) {
|
|
90
90
|
console.error(`Unknown command: ${command}`);
|
|
91
|
-
console.error(`Run '
|
|
91
|
+
console.error(`Run 'wm --help' for available commands.`);
|
|
92
92
|
process.exit(1);
|
|
93
93
|
}
|
|
94
94
|
// Per-command help
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { JitiOptions } from "jiti";
|
|
2
2
|
/**
|
|
3
|
-
* Build jiti options that let
|
|
3
|
+
* Build jiti options that let wm.ts / command files import from
|
|
4
4
|
* `@ldlework/workmark/*` and from workmark's own dependencies (zod, etc.)
|
|
5
5
|
* regardless of how the package is installed or linked.
|
|
6
6
|
*/
|
package/dist/lib/jiti-options.js
CHANGED
|
@@ -4,7 +4,7 @@ import { fileURLToPath } from "node:url";
|
|
|
4
4
|
const PKG_ROOT = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
5
5
|
const SRC_LIB = join(PKG_ROOT, "src", "lib");
|
|
6
6
|
/**
|
|
7
|
-
* Build jiti options that let
|
|
7
|
+
* Build jiti options that let wm.ts / command files import from
|
|
8
8
|
* `@ldlework/workmark/*` and from workmark's own dependencies (zod, etc.)
|
|
9
9
|
* regardless of how the package is installed or linked.
|
|
10
10
|
*/
|
package/dist/lib/load.js
CHANGED
|
@@ -72,7 +72,7 @@ function resolve(def, workspace, group, sourceFile) {
|
|
|
72
72
|
return { name: def.name, label: def.label, group, description: def.description, inputSchema, positional, handler, sourceFile };
|
|
73
73
|
}
|
|
74
74
|
export async function loadCommands(workspace) {
|
|
75
|
-
const commandsDir = join(workspace.root, ".
|
|
75
|
+
const commandsDir = join(workspace.root, ".wm", "commands");
|
|
76
76
|
if (!existsSync(commandsDir))
|
|
77
77
|
return [];
|
|
78
78
|
const jiti = createJiti(commandsDir, jitiOptions());
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export type SchemaFields = Record<string, z.ZodType | Record<string, unknown>>;
|
|
|
7
7
|
export interface ProjectDef {
|
|
8
8
|
/** Unique identifier. */
|
|
9
9
|
name: string;
|
|
10
|
-
/** Project directory relative to the
|
|
10
|
+
/** Project directory relative to the wm.ts location. Defaults to ".". */
|
|
11
11
|
dir?: string;
|
|
12
12
|
/** Arbitrary string tags for grouping/filtering. */
|
|
13
13
|
tags?: string[];
|
package/dist/lib/workspace.js
CHANGED
|
@@ -44,8 +44,8 @@ function loadIgnore(root) {
|
|
|
44
44
|
}
|
|
45
45
|
return ig;
|
|
46
46
|
}
|
|
47
|
-
/** Recursively find all
|
|
48
|
-
function
|
|
47
|
+
/** Recursively find all wm.ts files, respecting .gitignore rules. */
|
|
48
|
+
function findWmFiles(root) {
|
|
49
49
|
const ig = loadIgnore(root);
|
|
50
50
|
const results = [];
|
|
51
51
|
function walk(dir) {
|
|
@@ -55,7 +55,7 @@ function findWsFiles(root) {
|
|
|
55
55
|
if (!ig.ignores(rel + "/"))
|
|
56
56
|
walk(join(dir, entry.name));
|
|
57
57
|
}
|
|
58
|
-
else if (entry.name === "
|
|
58
|
+
else if (entry.name === "wm.ts") {
|
|
59
59
|
results.push(join(dir, entry.name));
|
|
60
60
|
}
|
|
61
61
|
}
|
|
@@ -63,35 +63,35 @@ function findWsFiles(root) {
|
|
|
63
63
|
walk(root);
|
|
64
64
|
return results;
|
|
65
65
|
}
|
|
66
|
-
/** Find the workspace root by walking up from cwd looking for .
|
|
66
|
+
/** Find the workspace root by walking up from cwd looking for .wm/. */
|
|
67
67
|
function findRoot(from) {
|
|
68
68
|
let dir = from;
|
|
69
69
|
while (true) {
|
|
70
|
-
if (existsSync(join(dir, ".
|
|
70
|
+
if (existsSync(join(dir, ".wm"))) {
|
|
71
71
|
return dir;
|
|
72
72
|
}
|
|
73
73
|
const parent = dirname(dir);
|
|
74
74
|
if (parent === dir)
|
|
75
|
-
throw new Error("Could not find workspace root (.
|
|
75
|
+
throw new Error("Could not find workspace root (.wm/ directory)");
|
|
76
76
|
dir = parent;
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
export async function loadWorkspace(from) {
|
|
80
80
|
const root = from ?? process.env.WORKSPACE_ROOT ?? findRoot(process.cwd());
|
|
81
81
|
const jiti = createJiti(root, jitiOptions());
|
|
82
|
-
// Recursively find all
|
|
83
|
-
const
|
|
82
|
+
// Recursively find all wm.ts files
|
|
83
|
+
const wmFiles = findWmFiles(root);
|
|
84
84
|
// Import each and build Project instances
|
|
85
85
|
const projects = [];
|
|
86
|
-
for (const
|
|
87
|
-
const dir = dirname(
|
|
86
|
+
for (const wmFile of wmFiles) {
|
|
87
|
+
const dir = dirname(wmFile);
|
|
88
88
|
let exported;
|
|
89
89
|
try {
|
|
90
|
-
exported = await jiti.import(
|
|
90
|
+
exported = await jiti.import(wmFile);
|
|
91
91
|
}
|
|
92
92
|
catch (err) {
|
|
93
|
-
// Log import failures — helps debug bad
|
|
94
|
-
console.error(`[workspace] Skipping ${
|
|
93
|
+
// Log import failures — helps debug bad wm.ts files
|
|
94
|
+
console.error(`[workspace] Skipping ${wmFile}: ${err.message}`);
|
|
95
95
|
continue;
|
|
96
96
|
}
|
|
97
97
|
// jiti may return { default: ... } when interopDefault doesn't fully unwrap
|
package/package.json
CHANGED
package/src/cli.ts
CHANGED
|
@@ -10,7 +10,7 @@ import type { ResolvedCommand } from "./lib/types.js";
|
|
|
10
10
|
// ---------------------------------------------------------------------------
|
|
11
11
|
|
|
12
12
|
function printHelp(commands: ResolvedCommand[]): void {
|
|
13
|
-
console.log("Usage:
|
|
13
|
+
console.log("Usage: wm <command> [args...]\n");
|
|
14
14
|
|
|
15
15
|
// Group by group name
|
|
16
16
|
const groups = new Map<string, ResolvedCommand[]>();
|
|
@@ -51,7 +51,7 @@ function printHelp(commands: ResolvedCommand[]): void {
|
|
|
51
51
|
|
|
52
52
|
function printCommandHelp(cmd: ResolvedCommand): void {
|
|
53
53
|
const pos = cmd.positional.map((p) => `<${p}>`).join(" ");
|
|
54
|
-
console.log(`Usage:
|
|
54
|
+
console.log(`Usage: wm ${cmd.name} ${pos}\n`);
|
|
55
55
|
console.log(cmd.description);
|
|
56
56
|
|
|
57
57
|
const schema = cmd.inputSchema as {
|
|
@@ -103,7 +103,7 @@ async function main(): Promise<void> {
|
|
|
103
103
|
const cmd = cmdMap.get(command);
|
|
104
104
|
if (!cmd) {
|
|
105
105
|
console.error(`Unknown command: ${command}`);
|
|
106
|
-
console.error(`Run '
|
|
106
|
+
console.error(`Run 'wm --help' for available commands.`);
|
|
107
107
|
process.exit(1);
|
|
108
108
|
}
|
|
109
109
|
|
package/src/lib/jiti-options.ts
CHANGED
|
@@ -7,7 +7,7 @@ const PKG_ROOT = join(dirname(fileURLToPath(import.meta.url)), "..", "..");
|
|
|
7
7
|
const SRC_LIB = join(PKG_ROOT, "src", "lib");
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
* Build jiti options that let
|
|
10
|
+
* Build jiti options that let wm.ts / command files import from
|
|
11
11
|
* `@ldlework/workmark/*` and from workmark's own dependencies (zod, etc.)
|
|
12
12
|
* regardless of how the package is installed or linked.
|
|
13
13
|
*/
|
package/src/lib/load.ts
CHANGED
|
@@ -87,7 +87,7 @@ function resolve(def: CommandDef, workspace: IWorkspace, group: string, sourceFi
|
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
export async function loadCommands(workspace: IWorkspace): Promise<ResolvedCommand[]> {
|
|
90
|
-
const commandsDir = join(workspace.root, ".
|
|
90
|
+
const commandsDir = join(workspace.root, ".wm", "commands");
|
|
91
91
|
if (!existsSync(commandsDir)) return [];
|
|
92
92
|
|
|
93
93
|
const jiti = createJiti(commandsDir, jitiOptions());
|
package/src/lib/types.ts
CHANGED
|
@@ -7,12 +7,12 @@ export type InputSchema = z.ZodType | Record<string, unknown>;
|
|
|
7
7
|
/** A record of named Zod schemas or raw JSON Schema property objects. */
|
|
8
8
|
export type SchemaFields = Record<string, z.ZodType | Record<string, unknown>>;
|
|
9
9
|
|
|
10
|
-
// ---- Project definitions (used in
|
|
10
|
+
// ---- Project definitions (used in wm.ts files) ----
|
|
11
11
|
|
|
12
12
|
export interface ProjectDef {
|
|
13
13
|
/** Unique identifier. */
|
|
14
14
|
name: string;
|
|
15
|
-
/** Project directory relative to the
|
|
15
|
+
/** Project directory relative to the wm.ts location. Defaults to ".". */
|
|
16
16
|
dir?: string;
|
|
17
17
|
/** Arbitrary string tags for grouping/filtering. */
|
|
18
18
|
tags?: string[];
|
package/src/lib/workspace.ts
CHANGED
|
@@ -52,8 +52,8 @@ function loadIgnore(root: string): Ignore {
|
|
|
52
52
|
return ig;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
/** Recursively find all
|
|
56
|
-
function
|
|
55
|
+
/** Recursively find all wm.ts files, respecting .gitignore rules. */
|
|
56
|
+
function findWmFiles(root: string): string[] {
|
|
57
57
|
const ig = loadIgnore(root);
|
|
58
58
|
const results: string[] = [];
|
|
59
59
|
|
|
@@ -62,7 +62,7 @@ function findWsFiles(root: string): string[] {
|
|
|
62
62
|
const rel = relative(root, join(dir, entry.name));
|
|
63
63
|
if (entry.isDirectory()) {
|
|
64
64
|
if (!ig.ignores(rel + "/")) walk(join(dir, entry.name));
|
|
65
|
-
} else if (entry.name === "
|
|
65
|
+
} else if (entry.name === "wm.ts") {
|
|
66
66
|
results.push(join(dir, entry.name));
|
|
67
67
|
}
|
|
68
68
|
}
|
|
@@ -72,15 +72,15 @@ function findWsFiles(root: string): string[] {
|
|
|
72
72
|
return results;
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
/** Find the workspace root by walking up from cwd looking for .
|
|
75
|
+
/** Find the workspace root by walking up from cwd looking for .wm/. */
|
|
76
76
|
function findRoot(from: string): string {
|
|
77
77
|
let dir = from;
|
|
78
78
|
while (true) {
|
|
79
|
-
if (existsSync(join(dir, ".
|
|
79
|
+
if (existsSync(join(dir, ".wm"))) {
|
|
80
80
|
return dir;
|
|
81
81
|
}
|
|
82
82
|
const parent = dirname(dir);
|
|
83
|
-
if (parent === dir) throw new Error("Could not find workspace root (.
|
|
83
|
+
if (parent === dir) throw new Error("Could not find workspace root (.wm/ directory)");
|
|
84
84
|
dir = parent;
|
|
85
85
|
}
|
|
86
86
|
}
|
|
@@ -89,20 +89,20 @@ export async function loadWorkspace(from?: string): Promise<Workspace> {
|
|
|
89
89
|
const root = from ?? process.env.WORKSPACE_ROOT ?? findRoot(process.cwd());
|
|
90
90
|
const jiti = createJiti(root, jitiOptions());
|
|
91
91
|
|
|
92
|
-
// Recursively find all
|
|
93
|
-
const
|
|
92
|
+
// Recursively find all wm.ts files
|
|
93
|
+
const wmFiles = findWmFiles(root);
|
|
94
94
|
|
|
95
95
|
// Import each and build Project instances
|
|
96
96
|
const projects: Project[] = [];
|
|
97
97
|
|
|
98
|
-
for (const
|
|
99
|
-
const dir = dirname(
|
|
98
|
+
for (const wmFile of wmFiles) {
|
|
99
|
+
const dir = dirname(wmFile);
|
|
100
100
|
let exported: unknown;
|
|
101
101
|
try {
|
|
102
|
-
exported = await jiti.import(
|
|
102
|
+
exported = await jiti.import(wmFile);
|
|
103
103
|
} catch (err) {
|
|
104
|
-
// Log import failures — helps debug bad
|
|
105
|
-
console.error(`[workspace] Skipping ${
|
|
104
|
+
// Log import failures — helps debug bad wm.ts files
|
|
105
|
+
console.error(`[workspace] Skipping ${wmFile}: ${(err as Error).message}`);
|
|
106
106
|
continue;
|
|
107
107
|
}
|
|
108
108
|
|