motia 0.17.9-beta.192-502786 → 0.17.9-beta.192-311932
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/create/index.mjs
CHANGED
|
@@ -35,8 +35,8 @@ const installRequiredDependencies = async (packageManager, rootDir, context) =>
|
|
|
35
35
|
`@motiadev/workbench@${version}`
|
|
36
36
|
].join(" ");
|
|
37
37
|
try {
|
|
38
|
-
await executeCommand(
|
|
39
|
-
await executeCommand(
|
|
38
|
+
await executeCommand(`REDISMS_DISABLE_POSTINSTALL=1 ${installCommand} ${dependencies}`, rootDir);
|
|
39
|
+
await executeCommand(`REDISMS_DISABLE_POSTINSTALL=1 ${installCommand} -D ${devDependencies}`, rootDir);
|
|
40
40
|
context.log("dependencies-installed", (message) => message.tag("success").append("Dependencies installed"));
|
|
41
41
|
} catch (error) {
|
|
42
42
|
console.error("❌ Failed to install dependencies:", error);
|
|
@@ -173,7 +173,7 @@ const create = async ({ projectName, template, cursorEnabled, context, skipRedis
|
|
|
173
173
|
bun: "bun install"
|
|
174
174
|
}[packageManager];
|
|
175
175
|
try {
|
|
176
|
-
await executeCommand(installCommand
|
|
176
|
+
await executeCommand(`REDISMS_DISABLE_POSTINSTALL=1 ${installCommand}`, rootDir);
|
|
177
177
|
context.log("plugin-dependencies-installed", (message) => message.tag("success").append("Plugin dependencies installed"));
|
|
178
178
|
} catch (error) {
|
|
179
179
|
context.log("failed-to-install-plugin-dependencies", (message) => message.tag("failed").append("Failed to install plugin dependencies"));
|
|
@@ -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 { fileURLToPath } from 'url'\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, getPackageManagerFromEnv } 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 __dirname = path.dirname(fileURLToPath(import.meta.url))\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 bun: 'bun 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 = [\n 'ts-node@10.9.2',\n 'typescript@5.7.3',\n '@types/react@19.1.1',\n `@motiadev/workbench@${version}`,\n ].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, detectFromParent = false) => {\n const detectionDir = detectFromParent ? process.cwd() : rootDir\n const envPackageManager = getPackageManagerFromEnv()\n const packageManager = getPackageManager(detectionDir)\n\n const isFallback =\n !envPackageManager && packageManager === 'npm' && !checkIfFileExists(detectionDir, 'package-lock.json')\n\n if (isFallback) {\n context.log('package-manager-using-default', (message: Message) =>\n message.tag('info').append('Using default package manager').append(packageManager, 'gray'),\n )\n } else {\n context.log('package-manager-detected', (message: Message) =>\n message.tag('info').append('Detected 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 skipRedis?: boolean\n}\n\nexport const create = async ({\n projectName,\n template,\n cursorEnabled,\n context,\n skipRedis = false,\n}: 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 process.env.REDISMS_DISABLE_POSTINSTALL = '1'\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 if (!isPluginTemplate && skipRedis) {\n const motiaConfigPath = path.join(rootDir, 'motia.config.ts')\n\n const templatePath = path.join(__dirname, 'templates/motia.config.external-redis.ts.txt')\n const templateContent = fs.readFileSync(templatePath, 'utf-8')\n fs.writeFileSync(motiaConfigPath, templateContent)\n context.log('motia-config-created', (message: Message) =>\n message.tag('success').append('File').append('motia.config.ts', 'cyan').append('has been created.'),\n )\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 packageManager = await preparePackageManager(rootDir, context, true)\n\n context.log('installing-plugin-dependencies', (message: Message) =>\n message.tag('info').append('Installing plugin dependencies...'),\n )\n\n const installCommand = {\n npm: 'npm install',\n yarn: 'yarn',\n pnpm: 'pnpm install',\n bun: 'bun install',\n }[packageManager]\n\n try {\n await executeCommand(installCommand!, rootDir)\n context.log('plugin-dependencies-installed', (message: Message) =>\n message.tag('success').append('Plugin dependencies installed'),\n )\n } catch (error) {\n context.log('failed-to-install-plugin-dependencies', (message: Message) =>\n message.tag('failed').append('Failed to install plugin dependencies'),\n )\n console.error(error)\n }\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 if (skipRedis) {\n context.log('redis-skip-warning', (message: Message) =>\n message\n .tag('warning')\n .append(\n '⚠️ You skipped Redis binary installation. Make sure to provide a Redis connection before running Motia.',\n ),\n )\n context.log('success-blank-7', (message) => message.text(''))\n }\n context.log('success-signoff', (message) => message.text('Happy coding! 🚀'))\n context.log('success-blank-8', (message) => message.text(''))\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,YAAY,KAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAE9D,MAAM,8BAA8B,OAAO,gBAAwB,SAAiB,YAAwB;AAC1G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AAQ,KAAK,GAAG,CAAC;;AAE/D,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 { fileURLToPath } from 'url'\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, getPackageManagerFromEnv } 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 __dirname = path.dirname(fileURLToPath(import.meta.url))\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 bun: 'bun 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 = [\n 'ts-node@10.9.2',\n 'typescript@5.7.3',\n '@types/react@19.1.1',\n `@motiadev/workbench@${version}`,\n ].join(' ')\n\n try {\n await executeCommand(`REDISMS_DISABLE_POSTINSTALL=1 ${installCommand} ${dependencies}`, rootDir)\n await executeCommand(`REDISMS_DISABLE_POSTINSTALL=1 ${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, detectFromParent = false) => {\n const detectionDir = detectFromParent ? process.cwd() : rootDir\n const envPackageManager = getPackageManagerFromEnv()\n const packageManager = getPackageManager(detectionDir)\n\n const isFallback =\n !envPackageManager && packageManager === 'npm' && !checkIfFileExists(detectionDir, 'package-lock.json')\n\n if (isFallback) {\n context.log('package-manager-using-default', (message: Message) =>\n message.tag('info').append('Using default package manager').append(packageManager, 'gray'),\n )\n } else {\n context.log('package-manager-detected', (message: Message) =>\n message.tag('info').append('Detected 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 skipRedis?: boolean\n}\n\nexport const create = async ({\n projectName,\n template,\n cursorEnabled,\n context,\n skipRedis = false,\n}: 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 process.env.REDISMS_DISABLE_POSTINSTALL = '1'\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 if (!isPluginTemplate && skipRedis) {\n const motiaConfigPath = path.join(rootDir, 'motia.config.ts')\n\n const templatePath = path.join(__dirname, 'templates/motia.config.external-redis.ts.txt')\n const templateContent = fs.readFileSync(templatePath, 'utf-8')\n fs.writeFileSync(motiaConfigPath, templateContent)\n context.log('motia-config-created', (message: Message) =>\n message.tag('success').append('File').append('motia.config.ts', 'cyan').append('has been created.'),\n )\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 packageManager = await preparePackageManager(rootDir, context, true)\n\n context.log('installing-plugin-dependencies', (message: Message) =>\n message.tag('info').append('Installing plugin dependencies...'),\n )\n\n const installCommand = {\n npm: 'npm install',\n yarn: 'yarn',\n pnpm: 'pnpm install',\n bun: 'bun install',\n }[packageManager]\n\n try {\n await executeCommand(`REDISMS_DISABLE_POSTINSTALL=1 ${installCommand!}`, rootDir)\n context.log('plugin-dependencies-installed', (message: Message) =>\n message.tag('success').append('Plugin dependencies installed'),\n )\n } catch (error) {\n context.log('failed-to-install-plugin-dependencies', (message: Message) =>\n message.tag('failed').append('Failed to install plugin dependencies'),\n )\n console.error(error)\n }\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 if (skipRedis) {\n context.log('redis-skip-warning', (message: Message) =>\n message\n .tag('warning')\n .append(\n '⚠️ You skipped Redis binary installation. Make sure to provide a Redis connection before running Motia.',\n ),\n )\n context.log('success-blank-7', (message) => message.text(''))\n }\n context.log('success-signoff', (message) => message.text('Happy coding! 🚀'))\n context.log('success-blank-8', (message) => message.text(''))\n}\n"],"mappings":";;;;;;;;;;;;;;;AAeA,MAAM,YAAY,KAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAE9D,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;EACN,KAAK;EACN,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;EACtB;EACA;EACA;EACA,uBAAuB;EACxB,CAAC,KAAK,IAAI;AAEX,KAAI;AACF,QAAM,eAAe,iCAAiC,eAAe,GAAG,gBAAgB,QAAQ;AAChG,QAAM,eAAe,iCAAiC,eAAe,MAAM,mBAAmB,QAAQ;AAEtG,UAAQ,IAAI,2BAA2B,YAAqB,QAAQ,IAAI,UAAU,CAAC,OAAO,yBAAyB,CAAC;UAC7G,OAAO;AACd,UAAQ,MAAM,qCAAqC,MAAM;;;AAI7D,MAAM,wBAAwB,OAAO,SAAiB,SAAqB,mBAAmB,UAAU;CACtG,MAAM,eAAe,mBAAmB,QAAQ,KAAK,GAAG;CACxD,MAAM,oBAAoB,0BAA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,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,KAAI,WAAW;AACb,UAAQ,IAAI,uBAAuB,YACjC,QACG,IAAI,UAAU,CACd,OACC,2GACD,CACJ;AACD,UAAQ,IAAI,oBAAoB,YAAY,QAAQ,KAAK,GAAG,CAAC;;AAE/D,SAAQ,IAAI,oBAAoB,YAAY,QAAQ,KAAK,mBAAmB,CAAC;AAC7E,SAAQ,IAAI,oBAAoB,YAAY,QAAQ,KAAK,GAAG,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { copyWithWSLCompat } from "./utils.mjs";
|
|
1
2
|
import fs from "fs";
|
|
2
3
|
import path from "path";
|
|
3
4
|
import { fileURLToPath } from "url";
|
|
@@ -11,13 +12,14 @@ const pullRules = async (args, context) => {
|
|
|
11
12
|
const targetFile = path.join(args.rootDir, file);
|
|
12
13
|
const isFolder = fs.statSync(path.join(cursorTemplateDir, file)).isDirectory();
|
|
13
14
|
const type = isFolder ? "Folder" : "File";
|
|
14
|
-
if (args.force || !fs.existsSync(targetFile)) {
|
|
15
|
-
|
|
16
|
-
recursive: isFolder,
|
|
17
|
-
force: true
|
|
18
|
-
});
|
|
15
|
+
if (args.force || !fs.existsSync(targetFile)) try {
|
|
16
|
+
copyWithWSLCompat(path.join(cursorTemplateDir, file), targetFile, isFolder);
|
|
19
17
|
context.log(`${file}-created`, (message) => message.tag("success").append(type).append(file, "cyan").append("has been created."));
|
|
20
|
-
}
|
|
18
|
+
} catch (error) {
|
|
19
|
+
context.log(`${file}-error`, (message) => message.tag("error").append("Failed to create").append(type, "yellow").append(file, "cyan").append(`: ${error.message}`));
|
|
20
|
+
throw error;
|
|
21
|
+
}
|
|
22
|
+
else context.log(`${file}-skipped`, (message) => message.tag("warning").append(type).append(file, "cyan").append("already exists, skipping..."));
|
|
21
23
|
}
|
|
22
24
|
};
|
|
23
25
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pull-rules.mjs","names":[],"sources":["../../src/create/pull-rules.ts"],"sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport { fileURLToPath } from 'url'\nimport type { CliContext, Message } from '../cloud/config-utils'\n\ntype PullRulesArgs = {\n rootDir: string\n force?: boolean\n}\n\nexport const pullRules = async (args: PullRulesArgs, context: CliContext) => {\n const __dirname = path.dirname(fileURLToPath(import.meta.url))\n const cursorTemplateDir = path.join(__dirname, '..', 'cursor-rules', 'dot-files')\n const files = fs.readdirSync(cursorTemplateDir)\n\n for (const file of files) {\n const targetFile = path.join(args.rootDir, file)\n const isFolder = fs.statSync(path.join(cursorTemplateDir, file)).isDirectory()\n const type = isFolder ? 'Folder' : 'File'\n\n if (args.force || !fs.existsSync(targetFile)) {\n
|
|
1
|
+
{"version":3,"file":"pull-rules.mjs","names":["error: any"],"sources":["../../src/create/pull-rules.ts"],"sourcesContent":["import fs from 'fs'\nimport path from 'path'\nimport { fileURLToPath } from 'url'\nimport type { CliContext, Message } from '../cloud/config-utils'\nimport { copyWithWSLCompat } from './utils'\n\ntype PullRulesArgs = {\n rootDir: string\n force?: boolean\n}\n\nexport const pullRules = async (args: PullRulesArgs, context: CliContext) => {\n const __dirname = path.dirname(fileURLToPath(import.meta.url))\n const cursorTemplateDir = path.join(__dirname, '..', 'cursor-rules', 'dot-files')\n const files = fs.readdirSync(cursorTemplateDir)\n\n for (const file of files) {\n const targetFile = path.join(args.rootDir, file)\n const isFolder = fs.statSync(path.join(cursorTemplateDir, file)).isDirectory()\n const type = isFolder ? 'Folder' : 'File'\n\n if (args.force || !fs.existsSync(targetFile)) {\n try {\n copyWithWSLCompat(path.join(cursorTemplateDir, file), targetFile, isFolder)\n context.log(`${file}-created`, (message: Message) =>\n message.tag('success').append(type).append(file, 'cyan').append('has been created.'),\n )\n } catch (error: any) {\n context.log(`${file}-error`, (message: Message) =>\n message\n .tag('error')\n .append('Failed to create')\n .append(type, 'yellow')\n .append(file, 'cyan')\n .append(`: ${error.message}`),\n )\n throw error\n }\n } else {\n context.log(`${file}-skipped`, (message: Message) =>\n message.tag('warning').append(type).append(file, 'cyan').append('already exists, skipping...'),\n )\n }\n }\n}\n"],"mappings":";;;;;;AAWA,MAAa,YAAY,OAAO,MAAqB,YAAwB;CAC3E,MAAM,YAAY,KAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;CAC9D,MAAM,oBAAoB,KAAK,KAAK,WAAW,MAAM,gBAAgB,YAAY;CACjF,MAAM,QAAQ,GAAG,YAAY,kBAAkB;AAE/C,MAAK,MAAM,QAAQ,OAAO;EACxB,MAAM,aAAa,KAAK,KAAK,KAAK,SAAS,KAAK;EAChD,MAAM,WAAW,GAAG,SAAS,KAAK,KAAK,mBAAmB,KAAK,CAAC,CAAC,aAAa;EAC9E,MAAM,OAAO,WAAW,WAAW;AAEnC,MAAI,KAAK,SAAS,CAAC,GAAG,WAAW,WAAW,CAC1C,KAAI;AACF,qBAAkB,KAAK,KAAK,mBAAmB,KAAK,EAAE,YAAY,SAAS;AAC3E,WAAQ,IAAI,GAAG,KAAK,YAAY,YAC9B,QAAQ,IAAI,UAAU,CAAC,OAAO,KAAK,CAAC,OAAO,MAAM,OAAO,CAAC,OAAO,oBAAoB,CACrF;WACMA,OAAY;AACnB,WAAQ,IAAI,GAAG,KAAK,UAAU,YAC5B,QACG,IAAI,QAAQ,CACZ,OAAO,mBAAmB,CAC1B,OAAO,MAAM,SAAS,CACtB,OAAO,MAAM,OAAO,CACpB,OAAO,KAAK,MAAM,UAAU,CAChC;AACD,SAAM;;MAGR,SAAQ,IAAI,GAAG,KAAK,YAAY,YAC9B,QAAQ,IAAI,UAAU,CAAC,OAAO,KAAK,CAAC,OAAO,MAAM,OAAO,CAAC,OAAO,8BAA8B,CAC/F"}
|
package/dist/create/utils.mjs
CHANGED
|
@@ -12,7 +12,51 @@ const checkIfDirectoryExists = (dir) => {
|
|
|
12
12
|
return false;
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Recursively copies a directory using read/write operations.
|
|
17
|
+
* This is a fallback method for WSL/Windows compatibility.
|
|
18
|
+
*/
|
|
19
|
+
function copyDirectoryRecursive(src, dest) {
|
|
20
|
+
fs.mkdirSync(dest, { recursive: true });
|
|
21
|
+
const entries = fs.readdirSync(src, { withFileTypes: true });
|
|
22
|
+
for (const entry of entries) {
|
|
23
|
+
const srcPath = path.join(src, entry.name);
|
|
24
|
+
const destPath = path.join(dest, entry.name);
|
|
25
|
+
if (entry.isDirectory()) copyDirectoryRecursive(srcPath, destPath);
|
|
26
|
+
else {
|
|
27
|
+
const content = fs.readFileSync(srcPath);
|
|
28
|
+
fs.writeFileSync(destPath, content);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Copies a file or directory with WSL/Windows compatibility.
|
|
34
|
+
* Attempts to use fs.cpSync first for better performance, but falls back
|
|
35
|
+
* to manual read/write operations if permission errors occur (common in WSL).
|
|
36
|
+
*
|
|
37
|
+
* @param src - Source file or directory path
|
|
38
|
+
* @param dest - Destination file or directory path
|
|
39
|
+
* @param isDirectory - Whether the source is a directory
|
|
40
|
+
* @throws Error if copy fails after all fallback attempts
|
|
41
|
+
*/
|
|
42
|
+
function copyWithWSLCompat(src, dest, isDirectory) {
|
|
43
|
+
const destDir = isDirectory ? dest : path.dirname(dest);
|
|
44
|
+
fs.mkdirSync(destDir, { recursive: true });
|
|
45
|
+
try {
|
|
46
|
+
fs.cpSync(src, dest, {
|
|
47
|
+
recursive: isDirectory,
|
|
48
|
+
force: true
|
|
49
|
+
});
|
|
50
|
+
} catch (error) {
|
|
51
|
+
if (error.code === "EPERM" || error.code === "EACCES") if (isDirectory) copyDirectoryRecursive(src, dest);
|
|
52
|
+
else {
|
|
53
|
+
const content = fs.readFileSync(src);
|
|
54
|
+
fs.writeFileSync(dest, content);
|
|
55
|
+
}
|
|
56
|
+
else throw error;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
15
59
|
|
|
16
60
|
//#endregion
|
|
17
|
-
export { checkIfDirectoryExists, checkIfFileExists };
|
|
61
|
+
export { checkIfDirectoryExists, checkIfFileExists, copyWithWSLCompat };
|
|
18
62
|
//# sourceMappingURL=utils.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/create/utils.ts"],"sourcesContent":["import fs from 'fs'\nimport path from 'path'\n\nexport const checkIfFileExists = (dir: string, fileName: string): boolean => {\n return fs.existsSync(path.join(dir, fileName))\n}\n\nexport const checkIfDirectoryExists = (dir: string): boolean => {\n try {\n return fs.statSync(dir).isDirectory()\n } catch {\n return false\n }\n}\n"],"mappings":";;;;AAGA,MAAa,qBAAqB,KAAa,aAA8B;AAC3E,QAAO,GAAG,WAAW,KAAK,KAAK,KAAK,SAAS,CAAC;;AAGhD,MAAa,0BAA0B,QAAyB;AAC9D,KAAI;AACF,SAAO,GAAG,SAAS,IAAI,CAAC,aAAa;SAC/B;AACN,SAAO"}
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":["error: any"],"sources":["../../src/create/utils.ts"],"sourcesContent":["import fs from 'fs'\nimport path from 'path'\n\nexport const checkIfFileExists = (dir: string, fileName: string): boolean => {\n return fs.existsSync(path.join(dir, fileName))\n}\n\nexport const checkIfDirectoryExists = (dir: string): boolean => {\n try {\n return fs.statSync(dir).isDirectory()\n } catch {\n return false\n }\n}\n\n/**\n * Recursively copies a directory using read/write operations.\n * This is a fallback method for WSL/Windows compatibility.\n */\nfunction copyDirectoryRecursive(src: string, dest: string): void {\n fs.mkdirSync(dest, { recursive: true })\n const entries = fs.readdirSync(src, { withFileTypes: true })\n\n for (const entry of entries) {\n const srcPath = path.join(src, entry.name)\n const destPath = path.join(dest, entry.name)\n\n if (entry.isDirectory()) {\n copyDirectoryRecursive(srcPath, destPath)\n } else {\n // For files, read and write manually\n const content = fs.readFileSync(srcPath)\n fs.writeFileSync(destPath, content)\n }\n }\n}\n\n/**\n * Copies a file or directory with WSL/Windows compatibility.\n * Attempts to use fs.cpSync first for better performance, but falls back\n * to manual read/write operations if permission errors occur (common in WSL).\n *\n * @param src - Source file or directory path\n * @param dest - Destination file or directory path\n * @param isDirectory - Whether the source is a directory\n * @throws Error if copy fails after all fallback attempts\n */\nexport function copyWithWSLCompat(src: string, dest: string, isDirectory: boolean): void {\n // Ensure destination directory exists\n const destDir = isDirectory ? dest : path.dirname(dest)\n fs.mkdirSync(destDir, { recursive: true })\n\n try {\n // Try the standard cpSync first (faster and works in most cases)\n fs.cpSync(src, dest, {\n recursive: isDirectory,\n force: true,\n })\n } catch (error: any) {\n // If we get permission errors (common in WSL when writing to Windows paths),\n // fall back to manual copy using read/write operations\n if (error.code === 'EPERM' || error.code === 'EACCES') {\n if (isDirectory) {\n copyDirectoryRecursive(src, dest)\n } else {\n // For files, read and write manually\n const content = fs.readFileSync(src)\n fs.writeFileSync(dest, content)\n }\n } else {\n // Re-throw other errors\n throw error\n }\n }\n}"],"mappings":";;;;AAGA,MAAa,qBAAqB,KAAa,aAA8B;AAC3E,QAAO,GAAG,WAAW,KAAK,KAAK,KAAK,SAAS,CAAC;;AAGhD,MAAa,0BAA0B,QAAyB;AAC9D,KAAI;AACF,SAAO,GAAG,SAAS,IAAI,CAAC,aAAa;SAC/B;AACN,SAAO;;;;;;;AAQX,SAAS,uBAAuB,KAAa,MAAoB;AAC/D,IAAG,UAAU,MAAM,EAAE,WAAW,MAAM,CAAC;CACvC,MAAM,UAAU,GAAG,YAAY,KAAK,EAAE,eAAe,MAAM,CAAC;AAE5D,MAAK,MAAM,SAAS,SAAS;EAC3B,MAAM,UAAU,KAAK,KAAK,KAAK,MAAM,KAAK;EAC1C,MAAM,WAAW,KAAK,KAAK,MAAM,MAAM,KAAK;AAE5C,MAAI,MAAM,aAAa,CACrB,wBAAuB,SAAS,SAAS;OACpC;GAEL,MAAM,UAAU,GAAG,aAAa,QAAQ;AACxC,MAAG,cAAc,UAAU,QAAQ;;;;;;;;;;;;;;AAezC,SAAgB,kBAAkB,KAAa,MAAc,aAA4B;CAEvF,MAAM,UAAU,cAAc,OAAO,KAAK,QAAQ,KAAK;AACvD,IAAG,UAAU,SAAS,EAAE,WAAW,MAAM,CAAC;AAE1C,KAAI;AAEF,KAAG,OAAO,KAAK,MAAM;GACnB,WAAW;GACX,OAAO;GACR,CAAC;UACKA,OAAY;AAGnB,MAAI,MAAM,SAAS,WAAW,MAAM,SAAS,SAC3C,KAAI,YACF,wBAAuB,KAAK,KAAK;OAC5B;GAEL,MAAM,UAAU,GAAG,aAAa,IAAI;AACpC,MAAG,cAAc,MAAM,QAAQ;;MAIjC,OAAM"}
|
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.17.9-beta.192-
|
|
4
|
+
"version": "0.17.9-beta.192-311932",
|
|
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.13",
|
|
49
|
-
"@motiadev/adapter-bullmq-events": "0.17.9-beta.192-
|
|
50
|
-
"@motiadev/adapter-redis-cron": "0.17.9-beta.192-
|
|
51
|
-
"@motiadev/adapter-redis-state": "0.17.9-beta.192-
|
|
52
|
-
"@motiadev/
|
|
53
|
-
"@motiadev/core": "0.17.9-beta.192-
|
|
54
|
-
"@motiadev/
|
|
55
|
-
"@motiadev/
|
|
49
|
+
"@motiadev/adapter-bullmq-events": "0.17.9-beta.192-311932",
|
|
50
|
+
"@motiadev/adapter-redis-cron": "0.17.9-beta.192-311932",
|
|
51
|
+
"@motiadev/adapter-redis-state": "0.17.9-beta.192-311932",
|
|
52
|
+
"@motiadev/stream-client-node": "0.17.9-beta.192-311932",
|
|
53
|
+
"@motiadev/core": "0.17.9-beta.192-311932",
|
|
54
|
+
"@motiadev/workbench": "0.17.9-beta.192-311932",
|
|
55
|
+
"@motiadev/adapter-redis-streams": "0.17.9-beta.192-311932"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
58
58
|
"@amplitude/analytics-types": "^2.9.2",
|