motia 0.14.0-beta.165-277118 → 0.14.0-beta.165-198270

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.
Files changed (30) hide show
  1. package/dist/create/index.mjs +1 -1
  2. package/dist/create/index.mjs.map +1 -1
  3. package/dist/create/interactive.mjs +5 -6
  4. package/dist/create/interactive.mjs.map +1 -1
  5. package/dist/create/templates/generate.mjs +1 -2
  6. package/dist/create/templates/generate.mjs.map +1 -1
  7. package/dist/create/templates/generate.ts +0 -1
  8. package/dist/create/templates/hello/README.md.txt +2 -1
  9. package/dist/create/templates/hello_js/README.md.txt +2 -1
  10. package/dist/create/templates/hello_js/steps/hello/hello-api.step.js.txt +5 -3
  11. package/dist/create/templates/hello_js/steps/hello/process-greeting.step.js.txt +5 -3
  12. package/dist/create/templates/hello_python/README.md.txt +2 -1
  13. package/dist/create/templates/hello_python/steps/hello/hello_api_step.py.txt +2 -2
  14. package/dist/create/templates/hello_python/steps/hello/process_greeting_step.py.txt +2 -2
  15. package/dist/create/templates/index.mjs +1 -2
  16. package/dist/create/templates/index.mjs.map +1 -1
  17. package/dist/create/templates/index.ts +0 -1
  18. package/dist/create/templates/nodejs/README.md.txt +2 -1
  19. package/dist/create/templates/plugin/src/plugin.ts.txt +1 -1
  20. package/dist/create/templates/plugin/tsdown.config.ts.txt +1 -1
  21. package/dist/create/templates/python/README.md.txt +2 -1
  22. package/dist/create/templates/python/steps/petstore/process_food_order_step.py.txt +2 -2
  23. package/package.json +8 -8
  24. package/dist/create/templates/hello_multilang/README.md.txt +0 -106
  25. package/dist/create/templates/hello_multilang/motia-workbench.json +0 -21
  26. package/dist/create/templates/hello_multilang/motia.config.ts.txt +0 -10
  27. package/dist/create/templates/hello_multilang/requirements.txt +0 -2
  28. package/dist/create/templates/hello_multilang/steps/hello/hello-api.step.ts.txt +0 -46
  29. package/dist/create/templates/hello_multilang/steps/hello/log-greeting.step.js.txt +0 -34
  30. package/dist/create/templates/hello_multilang/steps/hello/process_greeting_step.py.txt +0 -75
@@ -150,7 +150,7 @@ const create = async ({ projectName, template, cursorEnabled, context }) => {
150
150
  let packageManager;
151
151
  if (!isPluginTemplate) {
152
152
  packageManager = await installNodeDependencies(rootDir, context);
153
- if (template.includes("python") || template.includes("multilang")) await pythonInstall({ baseDir: rootDir });
153
+ if (template.includes("python")) await pythonInstall({ baseDir: rootDir });
154
154
  await generateTypes(rootDir);
155
155
  } else packageManager = await preparePackageManager(rootDir, context);
156
156
  const projectDirName = path.basename(rootDir);
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["packageManager: string"],"sources":["../../src/create/index.ts"],"sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport pc from 'picocolors'\nimport type { CliContext, Message } from '../cloud/config-utils'\nimport { generateTypes } from '../generate-types'\nimport { pythonInstall } from '../install'\nimport { pluginDependencies } from '../plugins/plugin-dependencies'\nimport { executeCommand } from '../utils/execute-command'\nimport { getPackageManager } from '../utils/get-package-manager'\nimport { version } from '../version'\nimport { pullRules } from './pull-rules'\nimport { setupTemplate } from './setup-template'\nimport { checkIfDirectoryExists, checkIfFileExists } from './utils'\n\nconst installRequiredDependencies = async (packageManager: string, rootDir: string, context: CliContext) => {\n context.log('installing-dependencies', (message: Message) => message.tag('info').append('Installing dependencies...'))\n\n const installCommand = {\n npm: 'npm install --save',\n yarn: 'yarn add',\n pnpm: 'pnpm add',\n }[packageManager]\n\n const dependencies = [\n `motia@${version}`,\n 'zod@4.1.12',\n `@motiadev/adapter-bullmq-events@${version}`,\n ...pluginDependencies.map((dep: string) => `${dep}@${version}`),\n ].join(' ')\n\n const devDependencies = ['ts-node@10.9.2', 'typescript@5.7.3', '@types/react@19.1.1'].join(' ')\n\n try {\n await executeCommand(`${installCommand} ${dependencies}`, rootDir)\n await executeCommand(`${installCommand} -D ${devDependencies}`, rootDir)\n\n context.log('dependencies-installed', (message: Message) => message.tag('success').append('Dependencies installed'))\n } catch (error) {\n console.error('❌ Failed to install dependencies:', error)\n }\n}\n\nconst preparePackageManager = async (rootDir: string, context: CliContext) => {\n let packageManager = 'npm'\n const detectedPackageManager = getPackageManager(rootDir)\n\n if (detectedPackageManager !== 'unknown') {\n context.log('package-manager-detected', (message: Message) =>\n message.tag('info').append('Detected package manager').append(detectedPackageManager, 'gray'),\n )\n packageManager = detectedPackageManager\n } else {\n context.log('package-manager-using-default', (message: Message) =>\n message.tag('info').append('Using default package manager').append(packageManager, 'gray'),\n )\n }\n\n return packageManager\n}\n\nconst installNodeDependencies = async (rootDir: string, context: CliContext) => {\n const packageManager = await preparePackageManager(rootDir, context)\n\n await installRequiredDependencies(packageManager, rootDir, context).catch((error: unknown) => {\n context.log('failed-to-install-dependencies', (message: Message) =>\n message.tag('failed').append('Failed to install dependencies'),\n )\n console.error(error)\n })\n\n return packageManager\n}\n\ntype Args = {\n projectName: string\n template: string\n cursorEnabled: boolean\n context: CliContext\n skipTutorialTemplates?: boolean\n}\n\nexport const create = async ({ projectName, template, cursorEnabled, context }: Args): Promise<void> => {\n console.log(\n '\\n\\n' +\n `\n _____ ______ ______ ______\n /'\\\\_/\\`\\\\/\\\\ __\\`\\\\/\\\\__ _\\\\/\\\\__ _\\\\ /\\\\ _ \\\\\n /\\\\ \\\\ \\\\ \\\\/\\\\ \\\\/_/\\\\ \\\\/\\\\/_/\\\\ \\\\/ \\\\ \\\\ \\\\L\\\\ \\\\\n \\\\ \\\\ \\\\__\\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ __ \\\\\n \\\\ \\\\ \\\\_/\\\\ \\\\ \\\\ \\\\_\\\\ \\\\ \\\\ \\\\ \\\\ \\\\_\\\\ \\\\__\\\\ \\\\ \\\\/\\\\ \\\\\n \\\\ \\\\_\\\\\\\\ \\\\_\\\\ \\\\_____\\\\ \\\\ \\\\_\\\\ /\\\\_____\\\\\\\\ \\\\_\\\\ \\\\_\\\\\n \\\\/_/ \\\\/_/\\\\/_____/ \\\\/_/ \\\\/_____/ \\\\/_/\\\\/_/\n ` +\n '\\n\\n',\n )\n\n const isCurrentDir = projectName === '.' || projectName === './' || projectName === '.\\\\'\n const rootDir = isCurrentDir ? process.cwd() : path.join(process.cwd(), projectName)\n const isPluginTemplate = template === 'plugin'\n\n if (!isCurrentDir && !checkIfDirectoryExists(rootDir)) {\n fs.mkdirSync(path.join(rootDir))\n context.log('directory-created', (message: Message) =>\n message.tag('success').append('Directory created ').append(projectName, 'gray'),\n )\n } else {\n context.log('directory-using', (message: Message) => message.tag('info').append('Using current directory'))\n }\n\n // Plugin template handles package.json differently (via template)\n if (!isPluginTemplate && !checkIfFileExists(rootDir, 'package.json')) {\n const finalProjectName =\n !projectName || projectName === '.' || projectName === './' || projectName === '.\\\\'\n ? path.basename(process.cwd())\n : projectName.trim()\n\n const packageJsonContent = {\n name: finalProjectName,\n description: '',\n type: 'module',\n scripts: {\n postinstall: 'motia install',\n dev: 'motia dev',\n start: 'motia start',\n 'generate-types': 'motia generate-types',\n build: 'motia build',\n clean: 'rm -rf dist node_modules python_modules .motia .mermaid',\n //'generate:config': 'motia get-config --output ./', TODO: doesnt work at the moment\n },\n keywords: ['motia'],\n }\n\n fs.writeFileSync(path.join(rootDir, 'package.json'), JSON.stringify(packageJsonContent, null, 2))\n\n context.log('package-json-created', (message: Message) =>\n message.tag('success').append('File').append('package.json', 'cyan').append('has been created.'),\n )\n } else if (!isPluginTemplate) {\n const packageJsonPath = path.join(rootDir, 'package.json')\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))\n\n if (!packageJson.scripts) {\n packageJson.scripts = {}\n }\n\n if (!packageJson.scripts.dev) {\n packageJson.scripts.dev = 'motia dev'\n } else {\n packageJson.scripts.olddev = packageJson.scripts.dev\n packageJson.scripts.dev = 'motia dev'\n context.log('dev-command-already-exists', (message: Message) =>\n message.tag('warning').append('dev command already exists in package.json'),\n )\n }\n\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))\n context.log('dev-command-updated', (message: Message) =>\n message\n .tag('success')\n .append('Updated')\n .append('dev', 'gray')\n .append('command to')\n .append('package.json', 'gray'),\n )\n }\n\n // Plugin template handles tsconfig.json via template\n if (!isPluginTemplate && !checkIfFileExists(rootDir, 'tsconfig.json')) {\n const tsconfigContent = {\n compilerOptions: {\n target: 'ES2020',\n module: 'ESNext',\n moduleResolution: 'bundler',\n allowImportingTsExtensions: true,\n noEmit: true,\n esModuleInterop: true,\n strict: true,\n skipLibCheck: true,\n forceConsistentCasingInFileNames: true,\n resolveJsonModule: true,\n allowJs: true,\n outDir: 'dist',\n rootDir: '.',\n baseUrl: '.',\n jsx: 'react-jsx',\n },\n include: ['**/*.ts', 'motia.config.ts', '**/*.tsx', 'types.d.ts', '**/*.jsx'],\n exclude: ['node_modules', 'dist', 'tests'],\n }\n\n fs.writeFileSync(path.join(rootDir, 'tsconfig.json'), JSON.stringify(tsconfigContent, null, 2))\n context.log('tsconfig-json-created', (message: Message) =>\n message.tag('success').append('File').append('tsconfig.json', 'cyan').append('has been created.'),\n )\n }\n\n // Plugin template handles .gitignore via template\n if (!isPluginTemplate && !checkIfFileExists(rootDir, '.gitignore')) {\n const gitignoreContent = [\n 'node_modules',\n 'python_modules',\n '.venv',\n 'venv',\n '.motia',\n '.mermaid',\n 'dist',\n '*.pyc',\n ].join('\\n')\n\n fs.writeFileSync(path.join(rootDir, '.gitignore'), gitignoreContent)\n context.log('gitignore-created', (message: Message) =>\n message.tag('success').append('File').append('.gitignore', 'cyan').append('has been created.'),\n )\n }\n\n // Skip cursor rules for plugin template\n if (!isPluginTemplate && cursorEnabled) {\n await pullRules({ force: true, rootDir }, context)\n }\n\n if (template) {\n await setupTemplate(template, rootDir, context)\n }\n\n let packageManager: string\n if (!isPluginTemplate) {\n packageManager = await installNodeDependencies(rootDir, context)\n\n if (template.includes('python') || template.includes('multilang')) {\n await pythonInstall({ baseDir: rootDir })\n }\n\n await generateTypes(rootDir)\n } else {\n // For plugin template, just detect the package manager\n packageManager = await preparePackageManager(rootDir, context)\n }\n\n const projectDirName = path.basename(rootDir)\n const devCommand = `${packageManager} run dev`\n const port = 3000\n const cdCommand = isCurrentDir ? '' : `${pc.cyan(`cd ${projectDirName}`)}\\n `\n\n context.log('success-blank', (message) => message.text(''))\n context.log('success-header', (message) =>\n message.text(`${pc.green('✨')} ${pc.bold('All set! Your project is ready to go.')}`),\n )\n context.log('success-blank-2', (message) => message.text(''))\n context.log('success-get-started', (message) => message.text('Get started:'))\n context.log('success-blank-3', (message) => message.text(''))\n context.log('success-commands', (message) => message.text(` ${cdCommand}${pc.cyan(devCommand)}`))\n context.log('success-blank-4', (message) => message.text(''))\n context.log('success-open', (message) => message.text(`Then open ${pc.cyan(`http://localhost:${port}`)}`))\n context.log('success-blank-5', (message: Message) => message.text(''))\n context.log('success-docs', (message) => message.text(`Docs: ${pc.cyan('https://www.motia.dev/docs')}`))\n context.log('success-blank-6', (message) => message.text(''))\n context.log('success-signoff', (message) => message.text('Happy coding! 🚀'))\n context.log('success-blank-7', (message) => message.text(''))\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,8BAA8B,OAAO,gBAAwB,SAAiB,YAAwB;AAC1G,SAAQ,IAAI,4BAA4B,YAAqB,QAAQ,IAAI,OAAO,CAAC,OAAO,6BAA6B,CAAC;CAEtH,MAAM,iBAAiB;EACrB,KAAK;EACL,MAAM;EACN,MAAM;EACP,CAAC;CAEF,MAAM,eAAe;EACnB,SAAS;EACT;EACA,mCAAmC;EACnC,GAAG,mBAAmB,KAAK,QAAgB,GAAG,IAAI,GAAG,UAAU;EAChE,CAAC,KAAK,IAAI;CAEX,MAAM,kBAAkB;EAAC;EAAkB;EAAoB;EAAsB,CAAC,KAAK,IAAI;AAE/F,KAAI;AACF,QAAM,eAAe,GAAG,eAAe,GAAG,gBAAgB,QAAQ;AAClE,QAAM,eAAe,GAAG,eAAe,MAAM,mBAAmB,QAAQ;AAExE,UAAQ,IAAI,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BAAsB,SAAS,QAAQ;CAGhE,MAAM,iBAAiB,KAAK,SAAS,QAAQ;CAC7C,MAAM,aAAa,GAAG,eAAe;CACrC,MAAM,OAAO;CACb,MAAM,YAAY,eAAe,KAAK,GAAG,GAAG,KAAK,MAAM,iBAAiB,CAAC;AAEzE,SAAQ,IAAI,kBAAkB,YAAY,QAAQ,KAAK,GAAG,CAAC;AAC3D,SAAQ,IAAI,mBAAmB,YAC7B,QAAQ,KAAK,GAAG,GAAG,MAAM,IAAI,CAAC,GAAG,GAAG,KAAK,wCAAwC,GAAG,CACrF;AACD,SAAQ,IAAI,oBAAoB,YAAY,QAAQ,KAAK,GAAG,CAAC;AAC7D,SAAQ,IAAI,wBAAwB,YAAY,QAAQ,KAAK,eAAe,CAAC;AAC7E,SAAQ,IAAI,oBAAoB,YAAY,QAAQ,KAAK,GAAG,CAAC;AAC7D,SAAQ,IAAI,qBAAqB,YAAY,QAAQ,KAAK,KAAK,YAAY,GAAG,KAAK,WAAW,GAAG,CAAC;AAClG,SAAQ,IAAI,oBAAoB,YAAY,QAAQ,KAAK,GAAG,CAAC;AAC7D,SAAQ,IAAI,iBAAiB,YAAY,QAAQ,KAAK,aAAa,GAAG,KAAK,oBAAoB,OAAO,GAAG,CAAC;AAC1G,SAAQ,IAAI,oBAAoB,YAAqB,QAAQ,KAAK,GAAG,CAAC;AACtE,SAAQ,IAAI,iBAAiB,YAAY,QAAQ,KAAK,SAAS,GAAG,KAAK,6BAA6B,GAAG,CAAC;AACxG,SAAQ,IAAI,oBAAoB,YAAY,QAAQ,KAAK,GAAG,CAAC;AAC7D,SAAQ,IAAI,oBAAoB,YAAY,QAAQ,KAAK,mBAAmB,CAAC;AAC7E,SAAQ,IAAI,oBAAoB,YAAY,QAAQ,KAAK,GAAG,CAAC"}
1
+ {"version":3,"file":"index.mjs","names":["packageManager: string"],"sources":["../../src/create/index.ts"],"sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport pc from 'picocolors'\nimport type { CliContext, Message } from '../cloud/config-utils'\nimport { generateTypes } from '../generate-types'\nimport { pythonInstall } from '../install'\nimport { pluginDependencies } from '../plugins/plugin-dependencies'\nimport { executeCommand } from '../utils/execute-command'\nimport { getPackageManager } from '../utils/get-package-manager'\nimport { version } from '../version'\nimport { pullRules } from './pull-rules'\nimport { setupTemplate } from './setup-template'\nimport { checkIfDirectoryExists, checkIfFileExists } from './utils'\n\nconst installRequiredDependencies = async (packageManager: string, rootDir: string, context: CliContext) => {\n context.log('installing-dependencies', (message: Message) => message.tag('info').append('Installing dependencies...'))\n\n const installCommand = {\n npm: 'npm install --save',\n yarn: 'yarn add',\n pnpm: 'pnpm add',\n }[packageManager]\n\n const dependencies = [\n `motia@${version}`,\n 'zod@4.1.12',\n `@motiadev/adapter-bullmq-events@${version}`,\n ...pluginDependencies.map((dep: string) => `${dep}@${version}`),\n ].join(' ')\n\n const devDependencies = ['ts-node@10.9.2', 'typescript@5.7.3', '@types/react@19.1.1'].join(' ')\n\n try {\n await executeCommand(`${installCommand} ${dependencies}`, rootDir)\n await executeCommand(`${installCommand} -D ${devDependencies}`, rootDir)\n\n context.log('dependencies-installed', (message: Message) => message.tag('success').append('Dependencies installed'))\n } catch (error) {\n console.error('❌ Failed to install dependencies:', error)\n }\n}\n\nconst preparePackageManager = async (rootDir: string, context: CliContext) => {\n let packageManager = 'npm'\n const detectedPackageManager = getPackageManager(rootDir)\n\n if (detectedPackageManager !== 'unknown') {\n context.log('package-manager-detected', (message: Message) =>\n message.tag('info').append('Detected package manager').append(detectedPackageManager, 'gray'),\n )\n packageManager = detectedPackageManager\n } else {\n context.log('package-manager-using-default', (message: Message) =>\n message.tag('info').append('Using default package manager').append(packageManager, 'gray'),\n )\n }\n\n return packageManager\n}\n\nconst installNodeDependencies = async (rootDir: string, context: CliContext) => {\n const packageManager = await preparePackageManager(rootDir, context)\n\n await installRequiredDependencies(packageManager, rootDir, context).catch((error: unknown) => {\n context.log('failed-to-install-dependencies', (message: Message) =>\n message.tag('failed').append('Failed to install dependencies'),\n )\n console.error(error)\n })\n\n return packageManager\n}\n\ntype Args = {\n projectName: string\n template: string\n cursorEnabled: boolean\n context: CliContext\n skipTutorialTemplates?: boolean\n}\n\nexport const create = async ({ projectName, template, cursorEnabled, context }: Args): Promise<void> => {\n console.log(\n '\\n\\n' +\n `\n _____ ______ ______ ______\n /'\\\\_/\\`\\\\/\\\\ __\\`\\\\/\\\\__ _\\\\/\\\\__ _\\\\ /\\\\ _ \\\\\n /\\\\ \\\\ \\\\ \\\\/\\\\ \\\\/_/\\\\ \\\\/\\\\/_/\\\\ \\\\/ \\\\ \\\\ \\\\L\\\\ \\\\\n \\\\ \\\\ \\\\__\\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ \\\\ __ \\\\\n \\\\ \\\\ \\\\_/\\\\ \\\\ \\\\ \\\\_\\\\ \\\\ \\\\ \\\\ \\\\ \\\\_\\\\ \\\\__\\\\ \\\\ \\\\/\\\\ \\\\\n \\\\ \\\\_\\\\\\\\ \\\\_\\\\ \\\\_____\\\\ \\\\ \\\\_\\\\ /\\\\_____\\\\\\\\ \\\\_\\\\ \\\\_\\\\\n \\\\/_/ \\\\/_/\\\\/_____/ \\\\/_/ \\\\/_____/ \\\\/_/\\\\/_/\n ` +\n '\\n\\n',\n )\n\n const isCurrentDir = projectName === '.' || projectName === './' || projectName === '.\\\\'\n const rootDir = isCurrentDir ? process.cwd() : path.join(process.cwd(), projectName)\n const isPluginTemplate = template === 'plugin'\n\n if (!isCurrentDir && !checkIfDirectoryExists(rootDir)) {\n fs.mkdirSync(path.join(rootDir))\n context.log('directory-created', (message: Message) =>\n message.tag('success').append('Directory created ').append(projectName, 'gray'),\n )\n } else {\n context.log('directory-using', (message: Message) => message.tag('info').append('Using current directory'))\n }\n\n // Plugin template handles package.json differently (via template)\n if (!isPluginTemplate && !checkIfFileExists(rootDir, 'package.json')) {\n const finalProjectName =\n !projectName || projectName === '.' || projectName === './' || projectName === '.\\\\'\n ? path.basename(process.cwd())\n : projectName.trim()\n\n const packageJsonContent = {\n name: finalProjectName,\n description: '',\n type: 'module',\n scripts: {\n postinstall: 'motia install',\n dev: 'motia dev',\n start: 'motia start',\n 'generate-types': 'motia generate-types',\n build: 'motia build',\n clean: 'rm -rf dist node_modules python_modules .motia .mermaid',\n //'generate:config': 'motia get-config --output ./', TODO: doesnt work at the moment\n },\n keywords: ['motia'],\n }\n\n fs.writeFileSync(path.join(rootDir, 'package.json'), JSON.stringify(packageJsonContent, null, 2))\n\n context.log('package-json-created', (message: Message) =>\n message.tag('success').append('File').append('package.json', 'cyan').append('has been created.'),\n )\n } else if (!isPluginTemplate) {\n const packageJsonPath = path.join(rootDir, 'package.json')\n const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'))\n\n if (!packageJson.scripts) {\n packageJson.scripts = {}\n }\n\n if (!packageJson.scripts.dev) {\n packageJson.scripts.dev = 'motia dev'\n } else {\n packageJson.scripts.olddev = packageJson.scripts.dev\n packageJson.scripts.dev = 'motia dev'\n context.log('dev-command-already-exists', (message: Message) =>\n message.tag('warning').append('dev command already exists in package.json'),\n )\n }\n\n fs.writeFileSync(packageJsonPath, JSON.stringify(packageJson, null, 2))\n context.log('dev-command-updated', (message: Message) =>\n message\n .tag('success')\n .append('Updated')\n .append('dev', 'gray')\n .append('command to')\n .append('package.json', 'gray'),\n )\n }\n\n // Plugin template handles tsconfig.json via template\n if (!isPluginTemplate && !checkIfFileExists(rootDir, 'tsconfig.json')) {\n const tsconfigContent = {\n compilerOptions: {\n target: 'ES2020',\n module: 'ESNext',\n moduleResolution: 'bundler',\n allowImportingTsExtensions: true,\n noEmit: true,\n esModuleInterop: true,\n strict: true,\n skipLibCheck: true,\n forceConsistentCasingInFileNames: true,\n resolveJsonModule: true,\n allowJs: true,\n outDir: 'dist',\n rootDir: '.',\n baseUrl: '.',\n jsx: 'react-jsx',\n },\n include: ['**/*.ts', 'motia.config.ts', '**/*.tsx', 'types.d.ts', '**/*.jsx'],\n exclude: ['node_modules', 'dist', 'tests'],\n }\n\n fs.writeFileSync(path.join(rootDir, 'tsconfig.json'), JSON.stringify(tsconfigContent, null, 2))\n context.log('tsconfig-json-created', (message: Message) =>\n message.tag('success').append('File').append('tsconfig.json', 'cyan').append('has been created.'),\n )\n }\n\n // Plugin template handles .gitignore via template\n if (!isPluginTemplate && !checkIfFileExists(rootDir, '.gitignore')) {\n const gitignoreContent = [\n 'node_modules',\n 'python_modules',\n '.venv',\n 'venv',\n '.motia',\n '.mermaid',\n 'dist',\n '*.pyc',\n ].join('\\n')\n\n fs.writeFileSync(path.join(rootDir, '.gitignore'), gitignoreContent)\n context.log('gitignore-created', (message: Message) =>\n message.tag('success').append('File').append('.gitignore', 'cyan').append('has been created.'),\n )\n }\n\n // Skip cursor rules for plugin template\n if (!isPluginTemplate && cursorEnabled) {\n await pullRules({ force: true, rootDir }, context)\n }\n\n if (template) {\n await setupTemplate(template, rootDir, context)\n }\n\n let packageManager: string\n if (!isPluginTemplate) {\n packageManager = await installNodeDependencies(rootDir, context)\n\n if (template.includes('python')) {\n await pythonInstall({ baseDir: rootDir })\n }\n\n await generateTypes(rootDir)\n } else {\n // For plugin template, just detect the package manager\n packageManager = await preparePackageManager(rootDir, context)\n }\n\n const projectDirName = path.basename(rootDir)\n const devCommand = `${packageManager} run dev`\n const port = 3000\n const cdCommand = isCurrentDir ? '' : `${pc.cyan(`cd ${projectDirName}`)}\\n `\n\n context.log('success-blank', (message) => message.text(''))\n context.log('success-header', (message) =>\n message.text(`${pc.green('✨')} ${pc.bold('All set! Your project is ready to go.')}`),\n )\n context.log('success-blank-2', (message) => message.text(''))\n context.log('success-get-started', (message) => message.text('Get started:'))\n context.log('success-blank-3', (message) => message.text(''))\n context.log('success-commands', (message) => message.text(` ${cdCommand}${pc.cyan(devCommand)}`))\n context.log('success-blank-4', (message) => message.text(''))\n context.log('success-open', (message) => message.text(`Then open ${pc.cyan(`http://localhost:${port}`)}`))\n context.log('success-blank-5', (message: Message) => message.text(''))\n context.log('success-docs', (message) => message.text(`Docs: ${pc.cyan('https://www.motia.dev/docs')}`))\n context.log('success-blank-6', (message) => message.text(''))\n context.log('success-signoff', (message) => message.text('Happy coding! 🚀'))\n context.log('success-blank-7', (message) => message.text(''))\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,MAAM,8BAA8B,OAAO,gBAAwB,SAAiB,YAAwB;AAC1G,SAAQ,IAAI,4BAA4B,YAAqB,QAAQ,IAAI,OAAO,CAAC,OAAO,6BAA6B,CAAC;CAEtH,MAAM,iBAAiB;EACrB,KAAK;EACL,MAAM;EACN,MAAM;EACP,CAAC;CAEF,MAAM,eAAe;EACnB,SAAS;EACT;EACA,mCAAmC;EACnC,GAAG,mBAAmB,KAAK,QAAgB,GAAG,IAAI,GAAG,UAAU;EAChE,CAAC,KAAK,IAAI;CAEX,MAAM,kBAAkB;EAAC;EAAkB;EAAoB;EAAsB,CAAC,KAAK,IAAI;AAE/F,KAAI;AACF,QAAM,eAAe,GAAG,eAAe,GAAG,gBAAgB,QAAQ;AAClE,QAAM,eAAe,GAAG,eAAe,MAAM,mBAAmB,QAAQ;AAExE,UAAQ,IAAI,2BAA2B,YAAqB,QAAQ,IAAI,UAAU,CAAC,OAAO,yBAAyB,CAAC;UAC7G,OAAO;AACd,UAAQ,MAAM,qCAAqC,MAAM;;;AAI7D,MAAM,wBAAwB,OAAO,SAAiB,YAAwB;CAC5E,IAAI,iBAAiB;CACrB,MAAM,yBAAyB,kBAAkB,QAAQ;AAEzD,KAAI,2BAA2B,WAAW;AACxC,UAAQ,IAAI,6BAA6B,YACvC,QAAQ,IAAI,OAAO,CAAC,OAAO,2BAA2B,CAAC,OAAO,wBAAwB,OAAO,CAC9F;AACD,mBAAiB;OAEjB,SAAQ,IAAI,kCAAkC,YAC5C,QAAQ,IAAI,OAAO,CAAC,OAAO,gCAAgC,CAAC,OAAO,gBAAgB,OAAO,CAC3F;AAGH,QAAO;;AAGT,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AAQ,KAAK,GAAG,CAAC;AAC7D,SAAQ,IAAI,qBAAqB,YAAY,QAAQ,KAAK,KAAK,YAAY,GAAG,KAAK,WAAW,GAAG,CAAC;AAClG,SAAQ,IAAI,oBAAoB,YAAY,QAAQ,KAAK,GAAG,CAAC;AAC7D,SAAQ,IAAI,iBAAiB,YAAY,QAAQ,KAAK,aAAa,GAAG,KAAK,oBAAoB,OAAO,GAAG,CAAC;AAC1G,SAAQ,IAAI,oBAAoB,YAAqB,QAAQ,KAAK,GAAG,CAAC;AACtE,SAAQ,IAAI,iBAAiB,YAAY,QAAQ,KAAK,SAAS,GAAG,KAAK,6BAA6B,GAAG,CAAC;AACxG,SAAQ,IAAI,oBAAoB,YAAY,QAAQ,KAAK,GAAG,CAAC;AAC7D,SAAQ,IAAI,oBAAoB,YAAY,QAAQ,KAAK,mBAAmB,CAAC;AAC7E,SAAQ,IAAI,oBAAoB,YAAY,QAAQ,KAAK,GAAG,CAAC"}
@@ -4,12 +4,11 @@ import inquirer from "inquirer";
4
4
 
5
5
  //#region src/create/interactive.ts
6
6
  const choices = {
7
- "motia-tutorial-typescript": "Tutorial (TypeScript only)",
8
- "motia-tutorial-python": "Tutorial (Python only)",
9
- "starter-multilang": "Starter (All languages; TS/JS + Python)",
10
- "starter-typescript": "Starter (TypeScript only)",
11
- "starter-javascript": "Starter (JavaScript only)",
12
- "starter-python": "Starter (Python only)"
7
+ "motia-tutorial-typescript": "Tutorial (TypeScript)",
8
+ "motia-tutorial-python": "Tutorial (Python)",
9
+ "starter-typescript": "Starter (TypeScript)",
10
+ "starter-javascript": "Starter (JavaScript)",
11
+ "starter-python": "Starter (Python)"
13
12
  };
14
13
  const createInteractive = async (args, context) => {
15
14
  context.log("welcome", (message) => message.append(`\n🚀 ${pc.bold(args.plugin ? "Welcome to Motia Plugin Creator!" : "Welcome to Motia Project Creator!")}`));
@@ -1 +1 @@
1
- {"version":3,"file":"interactive.mjs","names":["choices: Record<string, string>","questions: QuestionCollection<never>[]","answers: InteractiveAnswers"],"sources":["../../src/create/interactive.ts"],"sourcesContent":["import inquirer, { type QuestionCollection } from 'inquirer'\nimport pc from 'picocolors'\nimport type { CliContext, Message } from '../cloud/config-utils'\nimport { create } from './index'\n\ninterface InteractiveAnswers {\n template: string\n projectName: string\n}\n\nconst choices: Record<string, string> = {\n 'motia-tutorial-typescript': 'Tutorial (TypeScript only)',\n 'motia-tutorial-python': 'Tutorial (Python only)',\n 'starter-multilang': 'Starter (All languages; TS/JS + Python)',\n 'starter-typescript': 'Starter (TypeScript only)',\n 'starter-javascript': 'Starter (JavaScript only)',\n 'starter-python': 'Starter (Python only)',\n}\n\ninterface CreateInteractiveArgs {\n name?: string\n template?: string\n plugin?: boolean\n}\n\nexport const createInteractive = async (args: CreateInteractiveArgs, context: CliContext): Promise<void> => {\n context.log('welcome', (message: Message) =>\n message.append(\n `\\n🚀 ${pc.bold(args.plugin ? 'Welcome to Motia Plugin Creator!' : 'Welcome to Motia Project Creator!')}`,\n ),\n )\n\n const questions: QuestionCollection<never>[] = []\n\n let name = args.name\n let template = args.template\n\n if (args.plugin) {\n if (!args.name) {\n context.log('failed', (message: Message) =>\n message.tag('failed').append(`Project name is required: ${pc.bold('motia create --plugin [project-name]')}\\n`),\n )\n return\n }\n\n return create({\n projectName: args.name,\n template: 'plugin',\n cursorEnabled: false,\n context,\n })\n } else if (!args.template) {\n questions.push({\n type: 'list',\n name: 'template',\n message: 'What template do you want to use? (Use arrow keys)',\n choices: Object.keys(choices).map((key) => ({\n name: choices[key],\n value: key,\n })),\n })\n }\n\n if (!args.name) {\n questions.push({\n type: 'input',\n name: 'projectName',\n message: 'Project name (leave blank to use current folder):',\n validate: (input: string) => {\n if (input && input.trim().length > 0) {\n if (!/^[a-zA-Z0-9][a-zA-Z0-9-_]*$/.test(input.trim())) {\n return 'Project name must start with a letter or number and contain only letters, numbers, hyphens, and underscores'\n }\n }\n return true\n },\n filter: (input: string) => input.trim(),\n })\n }\n\n if (questions.length > 0) {\n const answers: InteractiveAnswers = await inquirer.prompt(questions)\n name = args.name || answers.projectName\n template = args.template || answers.template\n }\n\n context.log('creating', (message: Message) => message.append('\\n🔨 Creating your Motia project...\\n'))\n\n await create({\n projectName: name || '.',\n template: template || 'motia-tutorial-typescript',\n cursorEnabled: true, // Default to true for cursor rules\n context,\n })\n\n process.exit(0)\n}\n"],"mappings":";;;;;AAUA,MAAMA,UAAkC;CACtC,6BAA6B;CAC7B,yBAAyB;CACzB,qBAAqB;CACrB,sBAAsB;CACtB,sBAAsB;CACtB,kBAAkB;CACnB;AAQD,MAAa,oBAAoB,OAAO,MAA6B,YAAuC;AAC1G,SAAQ,IAAI,YAAY,YACtB,QAAQ,OACN,QAAQ,GAAG,KAAK,KAAK,SAAS,qCAAqC,oCAAoC,GACxG,CACF;CAED,MAAMC,YAAyC,EAAE;CAEjD,IAAI,OAAO,KAAK;CAChB,IAAI,WAAW,KAAK;AAEpB,KAAI,KAAK,QAAQ;AACf,MAAI,CAAC,KAAK,MAAM;AACd,WAAQ,IAAI,WAAW,YACrB,QAAQ,IAAI,SAAS,CAAC,OAAO,6BAA6B,GAAG,KAAK,uCAAuC,CAAC,IAAI,CAC/G;AACD;;AAGF,SAAO,OAAO;GACZ,aAAa,KAAK;GAClB,UAAU;GACV,eAAe;GACf;GACD,CAAC;YACO,CAAC,KAAK,SACf,WAAU,KAAK;EACb,MAAM;EACN,MAAM;EACN,SAAS;EACT,SAAS,OAAO,KAAK,QAAQ,CAAC,KAAK,SAAS;GAC1C,MAAM,QAAQ;GACd,OAAO;GACR,EAAE;EACJ,CAAC;AAGJ,KAAI,CAAC,KAAK,KACR,WAAU,KAAK;EACb,MAAM;EACN,MAAM;EACN,SAAS;EACT,WAAW,UAAkB;AAC3B,OAAI,SAAS,MAAM,MAAM,CAAC,SAAS,GACjC;QAAI,CAAC,8BAA8B,KAAK,MAAM,MAAM,CAAC,CACnD,QAAO;;AAGX,UAAO;;EAET,SAAS,UAAkB,MAAM,MAAM;EACxC,CAAC;AAGJ,KAAI,UAAU,SAAS,GAAG;EACxB,MAAMC,UAA8B,MAAM,SAAS,OAAO,UAAU;AACpE,SAAO,KAAK,QAAQ,QAAQ;AAC5B,aAAW,KAAK,YAAY,QAAQ;;AAGtC,SAAQ,IAAI,aAAa,YAAqB,QAAQ,OAAO,wCAAwC,CAAC;AAEtG,OAAM,OAAO;EACX,aAAa,QAAQ;EACrB,UAAU,YAAY;EACtB,eAAe;EACf;EACD,CAAC;AAEF,SAAQ,KAAK,EAAE"}
1
+ {"version":3,"file":"interactive.mjs","names":["choices: Record<string, string>","questions: QuestionCollection<never>[]","answers: InteractiveAnswers"],"sources":["../../src/create/interactive.ts"],"sourcesContent":["import inquirer, { type QuestionCollection } from 'inquirer'\nimport pc from 'picocolors'\nimport type { CliContext, Message } from '../cloud/config-utils'\nimport { create } from './index'\n\ninterface InteractiveAnswers {\n template: string\n projectName: string\n}\n\nconst choices: Record<string, string> = {\n 'motia-tutorial-typescript': 'Tutorial (TypeScript)',\n 'motia-tutorial-python': 'Tutorial (Python)',\n 'starter-typescript': 'Starter (TypeScript)',\n 'starter-javascript': 'Starter (JavaScript)',\n 'starter-python': 'Starter (Python)',\n}\n\ninterface CreateInteractiveArgs {\n name?: string\n template?: string\n plugin?: boolean\n}\n\nexport const createInteractive = async (args: CreateInteractiveArgs, context: CliContext): Promise<void> => {\n context.log('welcome', (message: Message) =>\n message.append(\n `\\n🚀 ${pc.bold(args.plugin ? 'Welcome to Motia Plugin Creator!' : 'Welcome to Motia Project Creator!')}`,\n ),\n )\n\n const questions: QuestionCollection<never>[] = []\n\n let name = args.name\n let template = args.template\n\n if (args.plugin) {\n if (!args.name) {\n context.log('failed', (message: Message) =>\n message.tag('failed').append(`Project name is required: ${pc.bold('motia create --plugin [project-name]')}\\n`),\n )\n return\n }\n\n return create({\n projectName: args.name,\n template: 'plugin',\n cursorEnabled: false,\n context,\n })\n } else if (!args.template) {\n questions.push({\n type: 'list',\n name: 'template',\n message: 'What template do you want to use? (Use arrow keys)',\n choices: Object.keys(choices).map((key) => ({\n name: choices[key],\n value: key,\n })),\n })\n }\n\n if (!args.name) {\n questions.push({\n type: 'input',\n name: 'projectName',\n message: 'Project name (leave blank to use current folder):',\n validate: (input: string) => {\n if (input && input.trim().length > 0) {\n if (!/^[a-zA-Z0-9][a-zA-Z0-9-_]*$/.test(input.trim())) {\n return 'Project name must start with a letter or number and contain only letters, numbers, hyphens, and underscores'\n }\n }\n return true\n },\n filter: (input: string) => input.trim(),\n })\n }\n\n if (questions.length > 0) {\n const answers: InteractiveAnswers = await inquirer.prompt(questions)\n name = args.name || answers.projectName\n template = args.template || answers.template\n }\n\n context.log('creating', (message: Message) => message.append('\\n🔨 Creating your Motia project...\\n'))\n\n await create({\n projectName: name || '.',\n template: template || 'motia-tutorial-typescript',\n cursorEnabled: true, // Default to true for cursor rules\n context,\n })\n\n process.exit(0)\n}\n"],"mappings":";;;;;AAUA,MAAMA,UAAkC;CACtC,6BAA6B;CAC7B,yBAAyB;CACzB,sBAAsB;CACtB,sBAAsB;CACtB,kBAAkB;CACnB;AAQD,MAAa,oBAAoB,OAAO,MAA6B,YAAuC;AAC1G,SAAQ,IAAI,YAAY,YACtB,QAAQ,OACN,QAAQ,GAAG,KAAK,KAAK,SAAS,qCAAqC,oCAAoC,GACxG,CACF;CAED,MAAMC,YAAyC,EAAE;CAEjD,IAAI,OAAO,KAAK;CAChB,IAAI,WAAW,KAAK;AAEpB,KAAI,KAAK,QAAQ;AACf,MAAI,CAAC,KAAK,MAAM;AACd,WAAQ,IAAI,WAAW,YACrB,QAAQ,IAAI,SAAS,CAAC,OAAO,6BAA6B,GAAG,KAAK,uCAAuC,CAAC,IAAI,CAC/G;AACD;;AAGF,SAAO,OAAO;GACZ,aAAa,KAAK;GAClB,UAAU;GACV,eAAe;GACf;GACD,CAAC;YACO,CAAC,KAAK,SACf,WAAU,KAAK;EACb,MAAM;EACN,MAAM;EACN,SAAS;EACT,SAAS,OAAO,KAAK,QAAQ,CAAC,KAAK,SAAS;GAC1C,MAAM,QAAQ;GACd,OAAO;GACR,EAAE;EACJ,CAAC;AAGJ,KAAI,CAAC,KAAK,KACR,WAAU,KAAK;EACb,MAAM;EACN,MAAM;EACN,SAAS;EACT,WAAW,UAAkB;AAC3B,OAAI,SAAS,MAAM,MAAM,CAAC,SAAS,GACjC;QAAI,CAAC,8BAA8B,KAAK,MAAM,MAAM,CAAC,CACnD,QAAO;;AAGX,UAAO;;EAET,SAAS,UAAkB,MAAM,MAAM;EACxC,CAAC;AAGJ,KAAI,UAAU,SAAS,GAAG;EACxB,MAAMC,UAA8B,MAAM,SAAS,OAAO,UAAU;AACpE,SAAO,KAAK,QAAQ,QAAQ;AAC5B,aAAW,KAAK,YAAY,QAAQ;;AAGtC,SAAQ,IAAI,aAAa,YAAqB,QAAQ,OAAO,wCAAwC,CAAC;AAEtG,OAAM,OAAO;EACX,aAAa,QAAQ;EACrB,UAAU,YAAY;EACtB,eAAe;EACf;EACD,CAAC;AAEF,SAAQ,KAAK,EAAE"}
@@ -7,8 +7,7 @@ import { fileURLToPath } from "url";
7
7
  const replaceTemplateVariables = (content, projectName) => {
8
8
  const replacements = {
9
9
  "{{PROJECT_NAME}}": projectName,
10
- "{{PLUGIN_NAME}}": toPascalCase(projectName),
11
- "{{CSS_FILE_NAME}}": projectName.replace(/^@[^/]+\//, "")
10
+ "{{PLUGIN_NAME}}": toPascalCase(projectName)
12
11
  };
13
12
  return Object.entries(replacements).reduce((result, [key, value]) => {
14
13
  return result.replace(new RegExp(key, "g"), value);
@@ -1 +1 @@
1
- {"version":3,"file":"generate.mjs","names":["replacements: Record<string, string>","path","fs","fd: fs.FileHandle | null","fd"],"sources":["../../../src/create/templates/generate.ts"],"sourcesContent":["import { constants, promises as fs, mkdirSync, statSync } from 'fs'\nimport { globSync } from 'glob'\nimport * as path from 'path'\nimport { fileURLToPath } from 'url'\nimport type { CliContext } from '../../cloud/config-utils'\n\nexport type Generator = (rootDir: string, context: CliContext) => Promise<void>\n\nconst replaceTemplateVariables = (content: string, projectName: string): string => {\n const replacements: Record<string, string> = {\n '{{PROJECT_NAME}}': projectName,\n '{{PLUGIN_NAME}}': toPascalCase(projectName),\n '{{CSS_FILE_NAME}}': projectName.replace(/^@[^/]+\\//, ''),\n }\n\n return Object.entries(replacements).reduce((result, [key, value]) => {\n return result.replace(new RegExp(key, 'g'), value)\n }, content)\n}\n\nconst toPascalCase = (str: string): string => {\n // Remove @ and scope if present\n const name = str.replace(/^@[^/]+\\//, '')\n return name\n .split(/[-_]/)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join('')\n}\nconst __dirname = path.dirname(fileURLToPath(import.meta.url))\n\nexport const generateTemplateSteps = (templateFolder: string): Generator => {\n return async (rootDir: string, context: CliContext): Promise<void> => {\n const templatePath = path.join(__dirname, templateFolder)\n const files = globSync('**/*', { absolute: false, cwd: templatePath, dot: true })\n const projectName = path.basename(rootDir)\n\n try {\n for (const fileName of files) {\n const filePath = path.join(templatePath, fileName)\n const targetFilePath = path.join(rootDir, fileName)\n const targetDir = path.dirname(targetFilePath)\n\n mkdirSync(targetDir, { recursive: true })\n\n if (statSync(filePath).isDirectory()) {\n const folderPath = filePath.replace(templatePath, '')\n mkdirSync(path.join(rootDir, folderPath), { recursive: true })\n continue\n }\n\n const sanitizedFileName = fileName === 'requirements.txt' ? fileName : fileName.replace('.txt', '')\n const isWorkbenchConfig = fileName.match('motia-workbench.json')\n const generateFilePath = path.join(rootDir, sanitizedFileName)\n let content = await fs.readFile(filePath, 'utf8')\n\n if (isWorkbenchConfig) {\n try {\n // Use file descriptor to avoid TOCTOU vulnerability\n let fd: fs.FileHandle | null = null\n try {\n // Try to open existing file for reading\n fd = await fs.open(generateFilePath, constants.O_RDONLY)\n const existingWorkbenchConfig = await fd.readFile('utf8')\n const workbenchContent = JSON.parse(content)\n\n content = JSON.stringify([...JSON.parse(existingWorkbenchConfig), ...workbenchContent], null, 2)\n\n context.log('workbench-config-updated', (message) =>\n message.tag('success').append('Workbench config').append('has been updated.'),\n )\n } finally {\n if (fd) await fd.close()\n }\n } catch {\n void 0\n }\n } else {\n content = replaceTemplateVariables(content, projectName)\n }\n\n // Use file descriptor for atomic write operation\n let fd: fs.FileHandle | null = null\n try {\n fd = await fs.open(generateFilePath, constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC, 0o644)\n await fd.writeFile(content, 'utf8')\n } finally {\n if (fd) await fd.close()\n }\n context.log(sanitizedFileName, (message) => {\n message.tag('success').append('File').append(sanitizedFileName, 'cyan').append('has been created.')\n })\n }\n } catch (error) {\n console.error('Error generating template files:', error)\n }\n }\n}\n\nexport const generatePluginTemplate = (templateFolder: string): Generator => {\n return async (rootDir: string, context: CliContext): Promise<void> => {\n const templatePath = path.join(__dirname, templateFolder)\n const files = globSync('**/*', { absolute: false, cwd: templatePath, dot: true })\n const projectName = path.basename(rootDir)\n\n try {\n for (const fileName of files) {\n const filePath = path.join(templatePath, fileName)\n const targetFilePath = path.join(rootDir, fileName)\n const targetDir = path.dirname(targetFilePath)\n\n mkdirSync(targetDir, { recursive: true })\n\n if (statSync(filePath).isDirectory()) {\n const folderPath = filePath.replace(templatePath, '')\n mkdirSync(path.join(rootDir, folderPath), { recursive: true })\n continue\n }\n\n const sanitizedFileName = fileName.replace('.txt', '')\n const generateFilePath = path.join(rootDir, sanitizedFileName)\n let content = await fs.readFile(filePath, 'utf8')\n\n content = replaceTemplateVariables(content, projectName)\n\n // Use file descriptor for atomic write operation\n let fd: fs.FileHandle | null = null\n try {\n fd = await fs.open(generateFilePath, constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC, 0o644)\n await fd.writeFile(content, 'utf8')\n } finally {\n if (fd) await fd.close()\n }\n context.log(sanitizedFileName, (message) => {\n message.tag('success').append('File').append(sanitizedFileName, 'cyan').append('has been created.')\n })\n }\n } catch (error) {\n console.error('Error generating template files:', error)\n }\n }\n}\n"],"mappings":";;;;;;AAQA,MAAM,4BAA4B,SAAiB,gBAAgC;CACjF,M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iBAAiBA,OAAK,KAAK,SAAS,SAAS;AAGnD,cAFkBA,OAAK,QAAQ,eAAe,EAEzB,EAAE,WAAW,MAAM,CAAC;AAEzC,QAAI,SAAS,SAAS,CAAC,aAAa,EAAE;KACpC,MAAM,aAAa,SAAS,QAAQ,cAAc,GAAG;AACrD,eAAUA,OAAK,KAAK,SAAS,WAAW,EAAE,EAAE,WAAW,MAAM,CAAC;AAC9D;;IAGF,MAAM,oBAAoB,SAAS,QAAQ,QAAQ,GAAG;IACtD,MAAM,mBAAmBA,OAAK,KAAK,SAAS,kBAAkB;IAC9D,IAAI,UAAU,MAAMC,SAAG,SAAS,UAAU,OAAO;AAEjD,cAAU,yBAAyB,SAAS,YAAY;IAGxD,IAAIC,KAA2B;AAC/B,QAAI;AACF,UAAK,MAAMD,SAAG,KAAK,kBAAkB,UAAU,UAAU,UAAU,WAAW,UAAU,SAAS,IAAM;AACvG,WAAM,GAAG,UAAU,SAAS,OAAO;cAC3B;AACR,SAAI,GAAI,OAAM,GAAG,OAAO;;AAE1B,YAAQ,IAAI,oBAAoB,YAAY;AAC1C,aAAQ,IAAI,UAAU,CAAC,OAAO,OAAO,CAAC,OAAO,mBAAmB,OAAO,CAAC,OAAO,oBAAoB;MACnG;;WAEG,OAAO;AACd,WAAQ,MAAM,oCAAoC,MAAM"}
1
+ {"version":3,"file":"generate.mjs","names":["replacements: Record<string, string>","path","fs","fd: fs.FileHandle | null","fd"],"sources":["../../../src/create/templates/generate.ts"],"sourcesContent":["import { constants, promises as fs, mkdirSync, statSync } from 'fs'\nimport { globSync } from 'glob'\nimport * as path from 'path'\nimport { fileURLToPath } from 'url'\nimport type { CliContext } from '../../cloud/config-utils'\n\nexport type Generator = (rootDir: string, context: CliContext) => Promise<void>\n\nconst replaceTemplateVariables = (content: string, projectName: string): string => {\n const replacements: Record<string, string> = {\n '{{PROJECT_NAME}}': projectName,\n '{{PLUGIN_NAME}}': toPascalCase(projectName),\n }\n\n return Object.entries(replacements).reduce((result, [key, value]) => {\n return result.replace(new RegExp(key, 'g'), value)\n }, content)\n}\n\nconst toPascalCase = (str: string): string => {\n // Remove @ and scope if present\n const name = str.replace(/^@[^/]+\\//, '')\n return name\n .split(/[-_]/)\n .map((word) => word.charAt(0).toUpperCase() + word.slice(1))\n .join('')\n}\nconst __dirname = path.dirname(fileURLToPath(import.meta.url))\n\nexport const generateTemplateSteps = (templateFolder: string): Generator => {\n return async (rootDir: string, context: CliContext): Promise<void> => {\n const templatePath = path.join(__dirname, templateFolder)\n const files = globSync('**/*', { absolute: false, cwd: templatePath, dot: true })\n const projectName = path.basename(rootDir)\n\n try {\n for (const fileName of files) {\n const filePath = path.join(templatePath, fileName)\n const targetFilePath = path.join(rootDir, fileName)\n const targetDir = path.dirname(targetFilePath)\n\n mkdirSync(targetDir, { recursive: true })\n\n if (statSync(filePath).isDirectory()) {\n const folderPath = filePath.replace(templatePath, '')\n mkdirSync(path.join(rootDir, folderPath), { recursive: true })\n continue\n }\n\n const sanitizedFileName = fileName === 'requirements.txt' ? fileName : fileName.replace('.txt', '')\n const isWorkbenchConfig = fileName.match('motia-workbench.json')\n const generateFilePath = path.join(rootDir, sanitizedFileName)\n let content = await fs.readFile(filePath, 'utf8')\n\n if (isWorkbenchConfig) {\n try {\n // Use file descriptor to avoid TOCTOU vulnerability\n let fd: fs.FileHandle | null = null\n try {\n // Try to open existing file for reading\n fd = await fs.open(generateFilePath, constants.O_RDONLY)\n const existingWorkbenchConfig = await fd.readFile('utf8')\n const workbenchContent = JSON.parse(content)\n\n content = JSON.stringify([...JSON.parse(existingWorkbenchConfig), ...workbenchContent], null, 2)\n\n context.log('workbench-config-updated', (message) =>\n message.tag('success').append('Workbench config').append('has been updated.'),\n )\n } finally {\n if (fd) await fd.close()\n }\n } catch {\n void 0\n }\n } else {\n content = replaceTemplateVariables(content, projectName)\n }\n\n // Use file descriptor for atomic write operation\n let fd: fs.FileHandle | null = null\n try {\n fd = await fs.open(generateFilePath, constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC, 0o644)\n await fd.writeFile(content, 'utf8')\n } finally {\n if (fd) await fd.close()\n }\n context.log(sanitizedFileName, (message) => {\n message.tag('success').append('File').append(sanitizedFileName, 'cyan').append('has been created.')\n })\n }\n } catch (error) {\n console.error('Error generating template files:', error)\n }\n }\n}\n\nexport const generatePluginTemplate = (templateFolder: string): Generator => {\n return async (rootDir: string, context: CliContext): Promise<void> => {\n const templatePath = path.join(__dirname, templateFolder)\n const files = globSync('**/*', { absolute: false, cwd: templatePath, dot: true })\n const projectName = path.basename(rootDir)\n\n try {\n for (const fileName of files) {\n const filePath = path.join(templatePath, fileName)\n const targetFilePath = path.join(rootDir, fileName)\n const targetDir = path.dirname(targetFilePath)\n\n mkdirSync(targetDir, { recursive: true })\n\n if (statSync(filePath).isDirectory()) {\n const folderPath = filePath.replace(templatePath, '')\n mkdirSync(path.join(rootDir, folderPath), { recursive: true })\n continue\n }\n\n const sanitizedFileName = fileName.replace('.txt', '')\n const generateFilePath = path.join(rootDir, sanitizedFileName)\n let content = await fs.readFile(filePath, 'utf8')\n\n content = replaceTemplateVariables(content, projectName)\n\n // Use file descriptor for atomic write operation\n let fd: fs.FileHandle | null = null\n try {\n fd = await fs.open(generateFilePath, constants.O_CREAT | constants.O_WRONLY | constants.O_TRUNC, 0o644)\n await fd.writeFile(content, 'utf8')\n } finally {\n if (fd) await fd.close()\n }\n context.log(sanitizedFileName, (message) => {\n message.tag('success').append('File').append(sanitizedFileName, 'cyan').append('has been created.')\n })\n }\n } catch (error) {\n console.error('Error generating template files:', error)\n }\n }\n}\n"],"mappings":";;;;;;AAQA,MAAM,4BAA4B,SAAiB,gBAAgC;CACjF,MAAMA,eAAuC;EAC3C,oBAAoB;EACpB,mBAAmB,aAAa,YAAY;EAC7C;AAED,QAAO,OAAO,QAAQ,aAAa,CAAC,QAAQ,QAAQ,CAAC,KAAK,WAAW;AACnE,SAAO,OAAO,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,MAAM;IACjD,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W,MAAM,CAAC;AAC9D;;IAGF,MAAM,oBAAoB,SAAS,QAAQ,QAAQ,GAAG;IACtD,MAAM,mBAAmBA,OAAK,KAAK,SAAS,kBAAkB;IAC9D,IAAI,UAAU,MAAMC,SAAG,SAAS,UAAU,OAAO;AAEjD,cAAU,yBAAyB,SAAS,YAAY;IAGxD,IAAIC,KAA2B;AAC/B,QAAI;AACF,UAAK,MAAMD,SAAG,KAAK,kBAAkB,UAAU,UAAU,UAAU,WAAW,UAAU,SAAS,IAAM;AACvG,WAAM,GAAG,UAAU,SAAS,OAAO;cAC3B;AACR,SAAI,GAAI,OAAM,GAAG,OAAO;;AAE1B,YAAQ,IAAI,oBAAoB,YAAY;AAC1C,aAAQ,IAAI,UAAU,CAAC,OAAO,OAAO,CAAC,OAAO,mBAAmB,OAAO,CAAC,OAAO,oBAAoB;MACnG;;WAEG,OAAO;AACd,WAAQ,MAAM,oCAAoC,MAAM"}
@@ -10,7 +10,6 @@ const replaceTemplateVariables = (content: string, projectName: string): string
10
10
  const replacements: Record<string, string> = {
11
11
  '{{PROJECT_NAME}}': projectName,
12
12
  '{{PLUGIN_NAME}}': toPascalCase(projectName),
13
- '{{CSS_FILE_NAME}}': projectName.replace(/^@[^/]+\//, ''),
14
13
  }
15
14
 
16
15
  return Object.entries(replacements).reduce((result, [key, value]) => {
@@ -80,4 +80,5 @@ Steps are auto-discovered from your `steps/` or `src/` directories - no manual r
80
80
  - [Documentation](https://motia.dev/docs) - Complete guides and API reference
81
81
  - [Quick Start Guide](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
82
82
  - [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
83
- - [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
83
+ - [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
84
+
@@ -80,4 +80,5 @@ Steps are auto-discovered from your `steps/` or `src/` directories - no manual r
80
80
  - [Documentation](https://motia.dev/docs) - Complete guides and API reference
81
81
  - [Quick Start Guide](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
82
82
  - [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
83
- - [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
83
+ - [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
84
+
@@ -1,6 +1,6 @@
1
- import { z } from 'zod';
1
+ const { z } = require('zod');
2
2
 
3
- export const config = {
3
+ const config = {
4
4
  name: 'HelloAPI',
5
5
  type: 'api',
6
6
  path: '/hello',
@@ -17,7 +17,7 @@ export const config = {
17
17
  }
18
18
  };
19
19
 
20
- export const handler = async (_, { emit, logger }) => {
20
+ const handler = async (_, { emit, logger }) => {
21
21
  const appName = process.env.APP_NAME || 'Motia App';
22
22
  const timestamp = new Date().toISOString();
23
23
 
@@ -43,3 +43,5 @@ export const handler = async (_, { emit, logger }) => {
43
43
  }
44
44
  };
45
45
  };
46
+
47
+ module.exports = { config, handler };
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ const { z } = require('zod');
2
2
 
3
3
  const inputSchema = z.object({
4
4
  timestamp: z.string(),
@@ -7,7 +7,7 @@ const inputSchema = z.object({
7
7
  requestId: z.string()
8
8
  });
9
9
 
10
- export const config = {
10
+ const config = {
11
11
  name: 'ProcessGreeting',
12
12
  type: 'event',
13
13
  description: 'Processes greeting in the background',
@@ -17,7 +17,7 @@ export const config = {
17
17
  input: inputSchema
18
18
  };
19
19
 
20
- export const handler = async (input, { logger, state }) => {
20
+ const handler = async (input, { logger, state }) => {
21
21
  const { timestamp, appName, greetingPrefix, requestId } = input;
22
22
 
23
23
  logger.info('Processing greeting', { requestId, appName });
@@ -38,3 +38,5 @@ export const handler = async (input, { logger, state }) => {
38
38
  storedInState: true
39
39
  });
40
40
  };
41
+
42
+ module.exports = { config, handler };
@@ -81,4 +81,5 @@ Steps are auto-discovered from your `steps/` or `src/` directories - no manual r
81
81
  - [Documentation](https://motia.dev/docs) - Complete guides and API reference
82
82
  - [Quick Start Guide](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
83
83
  - [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
84
- - [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
84
+ - [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
85
+
@@ -1,7 +1,7 @@
1
1
  import os
2
2
  import random
3
3
  import string
4
- from datetime import datetime, timezone
4
+ from datetime import datetime
5
5
 
6
6
  # Optional: Using Pydantic for validation (remove if not using Pydantic)
7
7
  try:
@@ -43,7 +43,7 @@ config = {
43
43
 
44
44
  async def handler(req, context):
45
45
  app_name = os.environ.get("APP_NAME", "Motia App")
46
- timestamp = datetime.now(timezone.utc).isoformat()
46
+ timestamp = datetime.utcnow().isoformat()
47
47
 
48
48
  context.logger.info("Hello API endpoint called", {
49
49
  "app_name": app_name,
@@ -1,5 +1,5 @@
1
1
  import asyncio
2
- from datetime import datetime, timezone
2
+ from datetime import datetime
3
3
 
4
4
  # Optional: Using Pydantic for validation (remove if not using Pydantic)
5
5
  try:
@@ -54,7 +54,7 @@ async def handler(input_data, context):
54
54
  # Note: The state.set method takes (groupId, key, value)
55
55
  await context.state.set("greetings", request_id, {
56
56
  "greeting": greeting,
57
- "processedAt": datetime.now(timezone.utc).isoformat(),
57
+ "processedAt": datetime.utcnow().isoformat(),
58
58
  "originalTimestamp": timestamp
59
59
  })
60
60
 
@@ -7,8 +7,7 @@ const templates = {
7
7
  plugin: generatePluginTemplate("plugin"),
8
8
  "starter-typescript": generateTemplateSteps("hello"),
9
9
  "starter-javascript": generateTemplateSteps("hello_js"),
10
- "starter-python": generateTemplateSteps("hello_python"),
11
- "starter-multilang": generateTemplateSteps("hello_multilang")
10
+ "starter-python": generateTemplateSteps("hello_python")
12
11
  };
13
12
 
14
13
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["templates: Record<string, Generator>"],"sources":["../../../src/create/templates/index.ts"],"sourcesContent":["import { type Generator, generatePluginTemplate, generateTemplateSteps } from './generate'\n\nexport const templates: Record<string, Generator> = {\n 'motia-tutorial-typescript': generateTemplateSteps('nodejs'),\n 'motia-tutorial-python': generateTemplateSteps('python'),\n plugin: generatePluginTemplate('plugin'),\n 'starter-typescript': generateTemplateSteps('hello'),\n 'starter-javascript': generateTemplateSteps('hello_js'),\n 'starter-python': generateTemplateSteps('hello_python'),\n 'starter-multilang': generateTemplateSteps('hello_multilang'),\n}\n"],"mappings":";;;AAEA,MAAaA,YAAuC;CAClD,6BAA6B,sBAAsB,SAAS;CAC5D,yBAAyB,sBAAsB,SAAS;CACxD,QAAQ,uBAAuB,SAAS;CACxC,sBAAsB,sBAAsB,QAAQ;CACpD,sBAAsB,sBAAsB,WAAW;CACvD,kBAAkB,sBAAsB,eAAe;CACvD,qBAAqB,sBAAsB,kBAAkB;CAC9D"}
1
+ {"version":3,"file":"index.mjs","names":["templates: Record<string, Generator>"],"sources":["../../../src/create/templates/index.ts"],"sourcesContent":["import { type Generator, generatePluginTemplate, generateTemplateSteps } from './generate'\n\nexport const templates: Record<string, Generator> = {\n 'motia-tutorial-typescript': generateTemplateSteps('nodejs'),\n 'motia-tutorial-python': generateTemplateSteps('python'),\n plugin: generatePluginTemplate('plugin'),\n 'starter-typescript': generateTemplateSteps('hello'),\n 'starter-javascript': generateTemplateSteps('hello_js'),\n 'starter-python': generateTemplateSteps('hello_python'),\n}\n"],"mappings":";;;AAEA,MAAaA,YAAuC;CAClD,6BAA6B,sBAAsB,SAAS;CAC5D,yBAAyB,sBAAsB,SAAS;CACxD,QAAQ,uBAAuB,SAAS;CACxC,sBAAsB,sBAAsB,QAAQ;CACpD,sBAAsB,sBAAsB,WAAW;CACvD,kBAAkB,sBAAsB,eAAe;CACxD"}
@@ -7,5 +7,4 @@ export const templates: Record<string, Generator> = {
7
7
  'starter-typescript': generateTemplateSteps('hello'),
8
8
  'starter-javascript': generateTemplateSteps('hello_js'),
9
9
  'starter-python': generateTemplateSteps('hello_python'),
10
- 'starter-multilang': generateTemplateSteps('hello_multilang'),
11
10
  }
@@ -89,4 +89,5 @@ This project includes an interactive tutorial that will guide you through:
89
89
  - [Documentation](https://motia.dev/docs) - Complete guides and API reference
90
90
  - [Quick Start Guide](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
91
91
  - [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
92
- - [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
92
+ - [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
93
+
@@ -5,7 +5,7 @@ export default function plugin(_motia: MotiaPluginContext): MotiaPlugin {
5
5
  workbench: [
6
6
  {
7
7
  packageName: '{{PROJECT_NAME}}',
8
- cssImports: ['{{PROJECT_NAME}}/dist/{{CSS_FILE_NAME}}.css'],
8
+ cssImports: ['{{PROJECT_NAME}}/dist/styles.css'],
9
9
  label: 'Example',
10
10
  position: 'bottom',
11
11
  componentName: 'ExamplePage',
@@ -37,7 +37,7 @@ export default defineConfig([
37
37
  // Separate CSS build
38
38
  {
39
39
  entry: {
40
- index: './src/styles.css',
40
+ styles: './src/styles.css',
41
41
  },
42
42
  format: 'esm',
43
43
  platform: 'browser',
@@ -90,4 +90,5 @@ This project includes an interactive tutorial that will guide you through:
90
90
  - [Documentation](https://motia.dev/docs) - Complete guides and API reference
91
91
  - [Quick Start Guide](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
92
92
  - [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
93
- - [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
93
+ - [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
94
+
@@ -1,5 +1,5 @@
1
1
  from pydantic import BaseModel
2
- from datetime import datetime, timezone
2
+ from datetime import datetime
3
3
  from src.services.pet_store import pet_store_service
4
4
 
5
5
  class InputSchema(BaseModel):
@@ -24,7 +24,7 @@ async def handler(input_data, context):
24
24
  "quantity": input_data.get("quantity"),
25
25
  "pet_id": input_data.get("pet_id"),
26
26
  "email": input_data.get("email"),
27
- "ship_date": datetime.now(timezone.utc).isoformat(),
27
+ "ship_date": datetime.now().isoformat(),
28
28
  "status": "placed",
29
29
  })
30
30
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "motia",
3
3
  "description": "Build production-grade backends with a single primitive. APIs, background jobs, Queues, Workflows, and AI agents - unified in one system with built-in State management, Streaming, and Observability.",
4
- "version": "0.14.0-beta.165-277118",
4
+ "version": "0.14.0-beta.165-198270",
5
5
  "license": "Elastic-2.0",
6
6
  "type": "module",
7
7
  "repository": {
@@ -46,13 +46,13 @@
46
46
  "table": "^6.9.0",
47
47
  "ts-node": "^10.9.2",
48
48
  "zod": "^4.1.12",
49
- "@motiadev/adapter-redis-cron": "0.14.0-beta.165-277118",
50
- "@motiadev/adapter-bullmq-events": "0.14.0-beta.165-277118",
51
- "@motiadev/adapter-redis-state": "0.14.0-beta.165-277118",
52
- "@motiadev/core": "0.14.0-beta.165-277118",
53
- "@motiadev/workbench": "0.14.0-beta.165-277118",
54
- "@motiadev/adapter-redis-streams": "0.14.0-beta.165-277118",
55
- "@motiadev/stream-client-node": "0.14.0-beta.165-277118"
49
+ "@motiadev/adapter-redis-cron": "0.14.0-beta.165-198270",
50
+ "@motiadev/adapter-redis-state": "0.14.0-beta.165-198270",
51
+ "@motiadev/adapter-redis-streams": "0.14.0-beta.165-198270",
52
+ "@motiadev/adapter-bullmq-events": "0.14.0-beta.165-198270",
53
+ "@motiadev/core": "0.14.0-beta.165-198270",
54
+ "@motiadev/stream-client-node": "0.14.0-beta.165-198270",
55
+ "@motiadev/workbench": "0.14.0-beta.165-198270"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@amplitude/analytics-types": "^2.9.2",
@@ -1,106 +0,0 @@
1
- # {{PROJECT_NAME}}
2
-
3
- A Motia project created with the **multi-language** starter template (TypeScript + Python).
4
-
5
- ## What is Motia?
6
-
7
- Motia is an open-source, unified backend framework that eliminates runtime fragmentation by bringing **APIs, background jobs, queueing, streaming, state, workflows, AI agents, observability, scaling, and deployment** into one unified system using a single core primitive, the **Step**.
8
-
9
- ## Polyglot Architecture
10
-
11
- This template demonstrates Motia's polyglot capabilities by combining:
12
-
13
- - **TypeScript**: API endpoint (`hello-api.step.ts`) - handles HTTP requests
14
- - **Python**: Event processor (`process_greeting_step.py`) - handles background processing
15
- - **JavaScript**: Logger (`log-greeting.step.js`) - handles workflow completion
16
-
17
- This shows how you can use the best language for each task while keeping everything in a single unified system.
18
-
19
- ## Quick Start
20
-
21
- ```bash
22
- # Start the development server
23
- npm run dev
24
- # or
25
- yarn dev
26
- # or
27
- pnpm dev
28
- ```
29
-
30
- This starts the Motia runtime and the **Workbench** - a powerful UI for developing and debugging your workflows. By default, it's available at [`http://localhost:3000`](http://localhost:3000).
31
-
32
- ```bash
33
- # Test your first endpoint
34
- curl http://localhost:3000/hello
35
- ```
36
-
37
- ## How It Works
38
-
39
- 1. **TypeScript API Step** receives the HTTP request at `/hello`
40
- 2. It emits a `process-greeting` event with the request data
41
- 3. **Python Event Step** picks up the event, processes it, and stores the result in state
42
- 4. Python emits a `greeting-processed` event
43
- 5. **JavaScript Event Step** logs the completed workflow
44
-
45
- ## Step Types
46
-
47
- Every Step has a `type` that defines how it triggers:
48
-
49
- | Type | When it runs | Use case |
50
- |------|--------------|----------|
51
- | **`api`** | HTTP request | REST APIs, webhooks |
52
- | **`event`** | Event emitted | Background jobs, workflows |
53
- | **`cron`** | Schedule | Cleanup, reports, reminders |
54
-
55
- ## Development Commands
56
-
57
- ```bash
58
- # Start Workbench and development server
59
- npm run dev
60
- # or
61
- yarn dev
62
- # or
63
- pnpm dev
64
-
65
- # Start production server (without hot reload)
66
- npm run start
67
- # or
68
- yarn start
69
- # or
70
- pnpm start
71
-
72
- # Generate TypeScript types from Step configs
73
- npm run generate-types
74
- # or
75
- yarn generate-types
76
- # or
77
- pnpm generate-types
78
-
79
- # Build project for deployment
80
- npm run build
81
- # or
82
- yarn build
83
- # or
84
- pnpm build
85
- ```
86
-
87
- ## Project Structure
88
-
89
- ```
90
- steps/ # Your Step definitions
91
- ├── hello/
92
- │ ├── hello-api.step.ts # TypeScript API endpoint
93
- │ ├── process_greeting_step.py # Python event processor
94
- │ └── log-greeting.step.js # JavaScript logger
95
- motia.config.ts # Motia configuration
96
- requirements.txt # Python dependencies
97
- ```
98
-
99
- Steps are auto-discovered from your `steps/` or `src/` directories - no manual registration required.
100
-
101
- ## Learn More
102
-
103
- - [Documentation](https://motia.dev/docs) - Complete guides and API reference
104
- - [Quick Start Guide](https://motia.dev/docs/getting-started/quick-start) - Detailed getting started tutorial
105
- - [Core Concepts](https://motia.dev/docs/concepts/overview) - Learn about Steps and Motia architecture
106
- - [Discord Community](https://discord.gg/motia) - Get help and connect with other developers
@@ -1,21 +0,0 @@
1
- [
2
- {
3
- "id": "hello-world-flow",
4
- "config": {
5
- "steps/hello/log-greeting.step.js": {
6
- "x": 409,
7
- "y": 44
8
- },
9
- "steps/hello/hello-api.step.ts": {
10
- "x": -409,
11
- "y": 0,
12
- "sourceHandlePosition": "right"
13
- },
14
- "steps/hello/process_greeting_step.py": {
15
- "x": 0,
16
- "y": 34,
17
- "sourceHandlePosition": "right"
18
- }
19
- }
20
- }
21
- ]
@@ -1,10 +0,0 @@
1
- import { config } from '@motiadev/core'
2
- import endpointPlugin from '@motiadev/plugin-endpoint/plugin'
3
- import logsPlugin from '@motiadev/plugin-logs/plugin'
4
- import observabilityPlugin from '@motiadev/plugin-observability/plugin'
5
- import statesPlugin from '@motiadev/plugin-states/plugin'
6
- import bullmqPlugin from '@motiadev/plugin-bullmq/plugin'
7
-
8
- export default config({
9
- plugins: [observabilityPlugin, statesPlugin, endpointPlugin, logsPlugin, bullmqPlugin],
10
- })
@@ -1,2 +0,0 @@
1
- # Optional: Uncomment if you want to use Pydantic for validation
2
- # pydantic>=2.0.0
@@ -1,46 +0,0 @@
1
- import type { ApiRouteConfig, Handlers } from 'motia';
2
- import { z } from 'zod';
3
-
4
- export const config: ApiRouteConfig = {
5
- name: 'HelloAPI',
6
- type: 'api',
7
- path: '/hello',
8
- method: 'GET',
9
- description: 'Receives hello request and emits event for Python processing',
10
- emits: ['process-greeting'],
11
- flows: ['hello-world-flow'],
12
- responseSchema: {
13
- 200: z.object({
14
- message: z.string(),
15
- status: z.string(),
16
- appName: z.string()
17
- })
18
- }
19
- };
20
-
21
- export const handler: Handlers['HelloAPI'] = async (_, { emit, logger }) => {
22
- const appName = process.env.APP_NAME || 'Motia App';
23
- const timestamp = new Date().toISOString();
24
-
25
- logger.info('Hello API endpoint called (TypeScript)', { appName, timestamp });
26
-
27
- // Emit event for background processing in Python
28
- await emit({
29
- topic: 'process-greeting',
30
- data: {
31
- timestamp,
32
- appName,
33
- greetingPrefix: process.env.GREETING_PREFIX || 'Hello',
34
- requestId: Math.random().toString(36).substring(7)
35
- }
36
- });
37
-
38
- return {
39
- status: 200,
40
- body: {
41
- message: 'Hello request received! Processing in Python...',
42
- status: 'processing',
43
- appName
44
- }
45
- };
46
- };
@@ -1,34 +0,0 @@
1
- import { z } from 'zod';
2
-
3
- const inputSchema = z.object({
4
- requestId: z.string(),
5
- greeting: z.string(),
6
- processedBy: z.string()
7
- });
8
-
9
- export const config = {
10
- name: 'LogGreeting',
11
- type: 'event',
12
- description: 'Logs the processed greeting (JavaScript)',
13
- subscribes: ['greeting-processed'],
14
- emits: [],
15
- flows: ['hello-world-flow'],
16
- input: inputSchema
17
- };
18
-
19
- export const handler = async (input, { logger, state }) => {
20
- const { requestId, greeting, processedBy } = input;
21
-
22
- logger.info('Logging greeting (JavaScript)', { requestId, processedBy });
23
-
24
- // Retrieve the stored greeting from state
25
- const storedData = await state.get('greetings', requestId);
26
-
27
- logger.info('Greeting workflow complete (JavaScript)', {
28
- requestId,
29
- greeting,
30
- processedBy,
31
- storedAt: storedData?.processedAt,
32
- workflowComplete: true
33
- });
34
- };
@@ -1,75 +0,0 @@
1
- from datetime import datetime, timezone
2
-
3
- # Optional: Using Pydantic for validation (remove if not using Pydantic)
4
- try:
5
- from pydantic import BaseModel
6
-
7
- class GreetingInput(BaseModel):
8
- timestamp: str
9
- appName: str
10
- greetingPrefix: str
11
- requestId: str
12
-
13
- # If using Pydantic, we can generate the JSON schema
14
- input_schema = GreetingInput.model_json_schema()
15
- except ImportError:
16
- # Without Pydantic, define JSON schema manually
17
- input_schema = {
18
- "type": "object",
19
- "properties": {
20
- "timestamp": {"type": "string"},
21
- "appName": {"type": "string"},
22
- "greetingPrefix": {"type": "string"},
23
- "requestId": {"type": "string"}
24
- },
25
- "required": ["timestamp", "appName", "greetingPrefix", "requestId"]
26
- }
27
-
28
- config = {
29
- "name": "ProcessGreeting",
30
- "type": "event",
31
- "description": "Processes greeting in the background (Python)",
32
- "subscribes": ["process-greeting"],
33
- "emits": ["greeting-processed"],
34
- "flows": ["hello-world-flow"],
35
- "input": input_schema
36
- }
37
-
38
- async def handler(input_data, context):
39
- # Extract data from input
40
- timestamp = input_data.get("timestamp")
41
- app_name = input_data.get("appName")
42
- greeting_prefix = input_data.get("greetingPrefix")
43
- request_id = input_data.get("requestId")
44
-
45
- context.logger.info("Processing greeting (Python)", {
46
- "request_id": request_id,
47
- "app_name": app_name
48
- })
49
-
50
- greeting = f"{greeting_prefix} {app_name}!"
51
-
52
- # Store result in state (demonstrates state usage)
53
- # Note: The state.set method takes (groupId, key, value)
54
- await context.state.set("greetings", request_id, {
55
- "greeting": greeting,
56
- "processedAt": datetime.now(timezone.utc).isoformat(),
57
- "originalTimestamp": timestamp,
58
- "processedBy": "python"
59
- })
60
-
61
- context.logger.info("Greeting processed successfully (Python)", {
62
- "request_id": request_id,
63
- "greeting": greeting,
64
- "stored_in_state": True
65
- })
66
-
67
- # Emit event for JavaScript notification step
68
- await context.emit({
69
- "topic": "greeting-processed",
70
- "data": {
71
- "requestId": request_id,
72
- "greeting": greeting,
73
- "processedBy": "python"
74
- }
75
- })