@workflow/cli 5.0.0-beta.2 → 5.0.0-beta.4
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.
|
@@ -4,7 +4,7 @@ import { Args, Flags } from '@oclif/core';
|
|
|
4
4
|
import { analyzeSerdeCompliance, applySwcTransform, detectWorkflowPatterns, } from '@workflow/builders';
|
|
5
5
|
import chalk from 'chalk';
|
|
6
6
|
import { BaseCommand } from '../base.js';
|
|
7
|
-
const ALL_MODES = ['workflow', 'step'
|
|
7
|
+
const ALL_MODES = ['workflow', 'step'];
|
|
8
8
|
export default class Transform extends BaseCommand {
|
|
9
9
|
static description = 'Show SWC transform output for a workflow file. Useful for inspecting what code runs in each execution context.';
|
|
10
10
|
static examples = [
|
|
@@ -23,9 +23,9 @@ export default class Transform extends BaseCommand {
|
|
|
23
23
|
static flags = {
|
|
24
24
|
mode: Flags.string({
|
|
25
25
|
char: 'm',
|
|
26
|
-
description: 'Transform mode (workflow, step,
|
|
26
|
+
description: 'Transform mode (workflow, step, or all)',
|
|
27
27
|
default: 'all',
|
|
28
|
-
options: ['workflow', 'step', '
|
|
28
|
+
options: ['workflow', 'step', 'all'],
|
|
29
29
|
}),
|
|
30
30
|
'check-serde': Flags.boolean({
|
|
31
31
|
description: 'Run serde compliance analysis on the transformed output',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/commands/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,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IAAI,CAAC,OAAO,CACV,KAAK,CAAC,MAAM,CACV,yDAAyD,CAC1D,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC","sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport { Args, Flags } from '@oclif/core';\nimport {\n analyzeSerdeCompliance,\n applySwcTransform,\n detectWorkflowPatterns,\n} from '@workflow/builders';\nimport chalk from 'chalk';\nimport { BaseCommand } from '../base.js';\n\ntype TransformMode = 'workflow' | 'step' | 'client';\n\nconst ALL_MODES: TransformMode[] = ['workflow', 'step', 'client'];\n\nexport default class Transform extends BaseCommand {\n static description =\n 'Show SWC transform output for a workflow file. Useful for inspecting what code runs in each execution context.';\n\n static examples = [\n '$ workflow transform src/MyClass.ts',\n '$ workflow transform src/MyClass.ts --mode workflow',\n '$ workflow transform src/MyClass.ts --mode step',\n '$ workflow transform src/MyClass.ts --check-serde',\n '$ workflow transform src/MyClass.ts --json',\n ];\n\n static args = {\n file: Args.string({\n description: 'The file to transform',\n required: true,\n }),\n };\n\n static flags = {\n mode: Flags.string({\n char: 'm',\n description: 'Transform mode (workflow, step, client, or all)',\n default: 'all',\n options: ['workflow', 'step', 'client', 'all'],\n }),\n 'check-serde': Flags.boolean({\n description: 'Run serde compliance analysis on the transformed output',\n default: false,\n }),\n };\n\n public async run(): Promise<Record<string, unknown>> {\n const { args, flags } = await this.parse(Transform);\n const filePath = resolve(args.file);\n const relPath = relative(process.cwd(), filePath);\n\n let source: string;\n try {\n source = await readFile(filePath, 'utf-8');\n } catch {\n this.error(`Could not read file: ${filePath}`);\n }\n\n // Detect if this file has workflow patterns\n const patterns = detectWorkflowPatterns(source);\n if (!patterns.hasDirective && !patterns.hasSerde) {\n this.logInfo(\n chalk.yellow(\n `Warning: ${relPath} does not contain \"use workflow\", \"use step\", or serde patterns.`\n )\n );\n }\n\n const modes: TransformMode[] =\n flags.mode === 'all' ? ALL_MODES : [flags.mode as TransformMode];\n\n const results: Record<string, { code: string; error?: string }> = {};\n\n for (const mode of modes) {\n try {\n const { code } = await applySwcTransform(\n relPath,\n source,\n mode,\n filePath\n );\n results[mode] = { code };\n } catch (err) {\n results[mode] = {\n code: '',\n error: err instanceof Error ? err.message : 'Transform failed',\n };\n }\n }\n\n // Serde analysis\n let serdeAnalysis = null;\n if (flags['check-serde'] || patterns.hasSerde) {\n // Ensure we have workflow mode output for serde analysis\n let workflowCode = results.workflow?.code;\n let workflowManifest = null;\n\n if (!workflowCode) {\n try {\n const result = await applySwcTransform(\n relPath,\n source,\n 'workflow',\n filePath\n );\n workflowCode = result.code;\n workflowManifest = result.workflowManifest;\n } catch {\n workflowCode = '';\n }\n } else {\n // Re-run to get the manifest\n try {\n const result = await applySwcTransform(\n relPath,\n source,\n 'workflow',\n filePath\n );\n workflowManifest = result.workflowManifest;\n } catch {\n // ignore\n }\n }\n\n if (workflowCode && workflowManifest) {\n serdeAnalysis = analyzeSerdeCompliance({\n sourceCode: source,\n workflowCode,\n manifest: workflowManifest,\n });\n }\n }\n\n // JSON output\n if (flags.json) {\n return {\n file: relPath,\n patterns: {\n hasUseWorkflow: patterns.hasUseWorkflow,\n hasUseStep: patterns.hasUseStep,\n hasSerde: patterns.hasSerde,\n },\n transforms: results,\n ...(serdeAnalysis\n ? {\n serdeAnalysis: {\n hasSerdeClasses: serdeAnalysis.hasSerdeClasses,\n globalNodeImports: serdeAnalysis.globalNodeImports,\n classes: serdeAnalysis.classes,\n },\n }\n : {}),\n };\n }\n\n // Human-readable output\n for (const mode of modes) {\n const result = results[mode];\n this.logInfo('');\n this.logInfo(chalk.bold.cyan(`═══ ${mode.toUpperCase()} MODE ═══`));\n if (result.error) {\n this.logInfo(chalk.red(`Error: ${result.error}`));\n } else {\n this.logInfo(result.code);\n }\n }\n\n // Serde analysis output\n if (serdeAnalysis) {\n this.logInfo('');\n this.logInfo(chalk.bold.cyan('═══ SERDE ANALYSIS ═══'));\n\n if (\n !serdeAnalysis.hasSerdeClasses &&\n serdeAnalysis.classes.length === 0\n ) {\n this.logInfo(chalk.gray('No serde-enabled classes detected.'));\n } else {\n for (const cls of serdeAnalysis.classes) {\n this.logInfo('');\n this.logInfo(\n cls.compliant\n ? chalk.green(`✓ Class \"${cls.className}\" is serde-compliant`)\n : chalk.red(`✗ Class \"${cls.className}\" is NOT serde-compliant`)\n );\n\n if (cls.classId) {\n this.logInfo(chalk.gray(` classId: ${cls.classId}`));\n }\n this.logInfo(\n ` Detected by SWC: ${cls.detected ? chalk.green('yes') : chalk.red('no')}`\n );\n this.logInfo(\n ` Registration IIFE: ${cls.registered ? chalk.green('yes') : chalk.red('no')}`\n );\n\n if (cls.nodeImports.length > 0) {\n this.logInfo(\n chalk.yellow(\n ` Node.js imports in workflow bundle: ${cls.nodeImports.join(', ')}`\n )\n );\n }\n\n for (const issue of cls.issues) {\n this.logInfo(chalk.yellow(` ⚠ ${issue}`));\n }\n }\n\n if (serdeAnalysis.globalNodeImports.length > 0) {\n this.logInfo('');\n this.logInfo(\n chalk.yellow(\n `Node.js built-in imports found in workflow output: ${serdeAnalysis.globalNodeImports.join(', ')}`\n )\n );\n this.logInfo(\n chalk.yellow(\n 'Add \"use step\" to methods that depend on these modules.'\n )\n );\n }\n }\n }\n\n return {};\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"transform.js","sourceRoot":"","sources":["../../src/commands/transform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,C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,CACF,CAAC;gBACJ,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC","sourcesContent":["import { readFile } from 'node:fs/promises';\nimport { relative, resolve } from 'node:path';\nimport { Args, Flags } from '@oclif/core';\nimport {\n analyzeSerdeCompliance,\n applySwcTransform,\n detectWorkflowPatterns,\n} from '@workflow/builders';\nimport chalk from 'chalk';\nimport { BaseCommand } from '../base.js';\n\ntype TransformMode = 'workflow' | 'step';\n\nconst ALL_MODES: TransformMode[] = ['workflow', 'step'];\n\nexport default class Transform extends BaseCommand {\n static description =\n 'Show SWC transform output for a workflow file. Useful for inspecting what code runs in each execution context.';\n\n static examples = [\n '$ workflow transform src/MyClass.ts',\n '$ workflow transform src/MyClass.ts --mode workflow',\n '$ workflow transform src/MyClass.ts --mode step',\n '$ workflow transform src/MyClass.ts --check-serde',\n '$ workflow transform src/MyClass.ts --json',\n ];\n\n static args = {\n file: Args.string({\n description: 'The file to transform',\n required: true,\n }),\n };\n\n static flags = {\n mode: Flags.string({\n char: 'm',\n description: 'Transform mode (workflow, step, or all)',\n default: 'all',\n options: ['workflow', 'step', 'all'],\n }),\n 'check-serde': Flags.boolean({\n description: 'Run serde compliance analysis on the transformed output',\n default: false,\n }),\n };\n\n public async run(): Promise<Record<string, unknown>> {\n const { args, flags } = await this.parse(Transform);\n const filePath = resolve(args.file);\n const relPath = relative(process.cwd(), filePath);\n\n let source: string;\n try {\n source = await readFile(filePath, 'utf-8');\n } catch {\n this.error(`Could not read file: ${filePath}`);\n }\n\n // Detect if this file has workflow patterns\n const patterns = detectWorkflowPatterns(source);\n if (!patterns.hasDirective && !patterns.hasSerde) {\n this.logInfo(\n chalk.yellow(\n `Warning: ${relPath} does not contain \"use workflow\", \"use step\", or serde patterns.`\n )\n );\n }\n\n const modes: TransformMode[] =\n flags.mode === 'all' ? ALL_MODES : [flags.mode as TransformMode];\n\n const results: Record<string, { code: string; error?: string }> = {};\n\n for (const mode of modes) {\n try {\n const { code } = await applySwcTransform(\n relPath,\n source,\n mode,\n filePath\n );\n results[mode] = { code };\n } catch (err) {\n results[mode] = {\n code: '',\n error: err instanceof Error ? err.message : 'Transform failed',\n };\n }\n }\n\n // Serde analysis\n let serdeAnalysis = null;\n if (flags['check-serde'] || patterns.hasSerde) {\n // Ensure we have workflow mode output for serde analysis\n let workflowCode = results.workflow?.code;\n let workflowManifest = null;\n\n if (!workflowCode) {\n try {\n const result = await applySwcTransform(\n relPath,\n source,\n 'workflow',\n filePath\n );\n workflowCode = result.code;\n workflowManifest = result.workflowManifest;\n } catch {\n workflowCode = '';\n }\n } else {\n // Re-run to get the manifest\n try {\n const result = await applySwcTransform(\n relPath,\n source,\n 'workflow',\n filePath\n );\n workflowManifest = result.workflowManifest;\n } catch {\n // ignore\n }\n }\n\n if (workflowCode && workflowManifest) {\n serdeAnalysis = analyzeSerdeCompliance({\n sourceCode: source,\n workflowCode,\n manifest: workflowManifest,\n });\n }\n }\n\n // JSON output\n if (flags.json) {\n return {\n file: relPath,\n patterns: {\n hasUseWorkflow: patterns.hasUseWorkflow,\n hasUseStep: patterns.hasUseStep,\n hasSerde: patterns.hasSerde,\n },\n transforms: results,\n ...(serdeAnalysis\n ? {\n serdeAnalysis: {\n hasSerdeClasses: serdeAnalysis.hasSerdeClasses,\n globalNodeImports: serdeAnalysis.globalNodeImports,\n classes: serdeAnalysis.classes,\n },\n }\n : {}),\n };\n }\n\n // Human-readable output\n for (const mode of modes) {\n const result = results[mode];\n this.logInfo('');\n this.logInfo(chalk.bold.cyan(`═══ ${mode.toUpperCase()} MODE ═══`));\n if (result.error) {\n this.logInfo(chalk.red(`Error: ${result.error}`));\n } else {\n this.logInfo(result.code);\n }\n }\n\n // Serde analysis output\n if (serdeAnalysis) {\n this.logInfo('');\n this.logInfo(chalk.bold.cyan('═══ SERDE ANALYSIS ═══'));\n\n if (\n !serdeAnalysis.hasSerdeClasses &&\n serdeAnalysis.classes.length === 0\n ) {\n this.logInfo(chalk.gray('No serde-enabled classes detected.'));\n } else {\n for (const cls of serdeAnalysis.classes) {\n this.logInfo('');\n this.logInfo(\n cls.compliant\n ? chalk.green(`✓ Class \"${cls.className}\" is serde-compliant`)\n : chalk.red(`✗ Class \"${cls.className}\" is NOT serde-compliant`)\n );\n\n if (cls.classId) {\n this.logInfo(chalk.gray(` classId: ${cls.classId}`));\n }\n this.logInfo(\n ` Detected by SWC: ${cls.detected ? chalk.green('yes') : chalk.red('no')}`\n );\n this.logInfo(\n ` Registration IIFE: ${cls.registered ? chalk.green('yes') : chalk.red('no')}`\n );\n\n if (cls.nodeImports.length > 0) {\n this.logInfo(\n chalk.yellow(\n ` Node.js imports in workflow bundle: ${cls.nodeImports.join(', ')}`\n )\n );\n }\n\n for (const issue of cls.issues) {\n this.logInfo(chalk.yellow(` ⚠ ${issue}`));\n }\n }\n\n if (serdeAnalysis.globalNodeImports.length > 0) {\n this.logInfo('');\n this.logInfo(\n chalk.yellow(\n `Node.js built-in imports found in workflow output: ${serdeAnalysis.globalNodeImports.join(', ')}`\n )\n );\n this.logInfo(\n chalk.yellow(\n 'Add \"use step\" to methods that depend on these modules.'\n )\n );\n }\n }\n }\n\n return {};\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@workflow/cli",
|
|
3
|
-
"version": "5.0.0-beta.
|
|
3
|
+
"version": "5.0.0-beta.4",
|
|
4
4
|
"description": "Command-line interface for Workflow SDK",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -55,15 +55,15 @@
|
|
|
55
55
|
"tinyglobby": "0.2.15",
|
|
56
56
|
"xdg-app-paths": "5.1.0",
|
|
57
57
|
"zod": "4.3.6",
|
|
58
|
-
"@workflow/builders": "5.0.0-beta.
|
|
59
|
-
"@workflow/swc-plugin": "5.0.0-beta.
|
|
58
|
+
"@workflow/builders": "5.0.0-beta.4",
|
|
59
|
+
"@workflow/swc-plugin": "5.0.0-beta.3",
|
|
60
60
|
"@workflow/utils": "5.0.0-beta.1",
|
|
61
61
|
"@workflow/errors": "5.0.0-beta.1",
|
|
62
|
-
"@workflow/core": "5.0.0-beta.
|
|
63
|
-
"@workflow/web": "5.0.0-beta.
|
|
62
|
+
"@workflow/core": "5.0.0-beta.4",
|
|
63
|
+
"@workflow/web": "5.0.0-beta.4",
|
|
64
64
|
"@workflow/world": "5.0.0-beta.1",
|
|
65
|
-
"@workflow/world-local": "5.0.0-beta.
|
|
66
|
-
"@workflow/world-vercel": "5.0.0-beta.
|
|
65
|
+
"@workflow/world-local": "5.0.0-beta.3",
|
|
66
|
+
"@workflow/world-vercel": "5.0.0-beta.3"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
69
|
"build": "tsc && chmod +x bin/run.js",
|