@openfairygui/cli 0.2.0 → 0.3.0-alpha.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openfairygui/cli",
3
- "version": "0.2.0",
3
+ "version": "0.3.0-alpha.2",
4
4
  "description": "FairyGUI Headless Authoring SDK — command-line interface.",
5
5
  "author": "OpenFairyGUI Contributors",
6
6
  "license": "MIT",
@@ -33,13 +33,13 @@
33
33
  "restore"
34
34
  ],
35
35
  "devDependencies": {
36
- "@openfairygui/core": "0.2.0",
37
- "@openfairygui/functions": "0.2.0"
36
+ "@openfairygui/functions": "0.3.0-alpha.2",
37
+ "@openfairygui/core": "0.3.0-alpha.2"
38
38
  },
39
39
  "dependencies": {
40
40
  "commander": "^14.0.2",
41
41
  "jiti": "^2.7.0",
42
- "@openfairygui/backend": "0.2.0"
42
+ "@openfairygui/backend": "0.3.0-alpha.2"
43
43
  },
44
44
  "optionalDependencies": {
45
45
  "sharp": ">=0.33.0"
package/src/cli.ts CHANGED
@@ -3,6 +3,7 @@ import { registerBackendCapabilitiesCommand } from './commands/backend-capabilit
3
3
  import { registerInspectCommand } from './commands/inspect.js';
4
4
  import { registerPublishCommand } from './commands/publish.js';
5
5
  import { registerRestoreCommand } from './commands/restore.js';
6
+ import { registerValidateCommand } from './commands/validate.js';
6
7
  import { readPackageVersion } from './utils/package-version.js';
7
8
 
8
9
  const PACKAGE_VERSION = readPackageVersion();
@@ -15,6 +16,7 @@ function createProgram(): Command {
15
16
  registerInspectCommand(program);
16
17
  registerPublishCommand(program);
17
18
  registerRestoreCommand(program);
19
+ registerValidateCommand(program);
18
20
  registerBackendCapabilitiesCommand(program);
19
21
 
20
22
  program.addHelpText(
@@ -0,0 +1,25 @@
1
+ import type { Command } from 'commander';
2
+ import { validateProjectNode } from '@openfairygui/functions/node';
3
+ import { resolveFairyPath } from '../utils/project-input.js';
4
+
5
+ export function registerValidateCommand(program: Command): void {
6
+ program
7
+ .command('validate')
8
+ .description('Validate project structure, references, and source files')
9
+ .argument('<project-dir>', 'Project root directory or .fairy file')
10
+ .option('--json', 'Print the machine-readable validation report')
11
+ .action(async (projectDir: string, options: { json?: boolean }) => {
12
+ const fairyPath = await resolveFairyPath(projectDir);
13
+ const report = await validateProjectNode(fairyPath);
14
+ if (options.json) {
15
+ console.log(JSON.stringify(report, null, 2));
16
+ } else {
17
+ console.log(`${report.status.toUpperCase()}: ${fairyPath}`);
18
+ for (const diagnostic of report.diagnostics) {
19
+ const source = diagnostic.sourcePath ? ` (${diagnostic.sourcePath})` : '';
20
+ console.log(`${diagnostic.severity.toUpperCase()} ${diagnostic.code} ${diagnostic.path}${source}: ${diagnostic.message}`);
21
+ }
22
+ }
23
+ process.exitCode = report.status === 'valid' ? 0 : report.status === 'invalid' ? 1 : 2;
24
+ });
25
+ }