motia 0.17.9-beta.192-396370 → 0.17.9-beta.192-239007

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.
@@ -31,8 +31,8 @@ const installRequiredDependencies = async (packageManager, rootDir, context) =>
31
31
  `@motiadev/workbench@${version}`
32
32
  ].join(" ");
33
33
  try {
34
- await executeCommand(`REDISMS_DISABLE_POSTINSTALL=1 ${installCommand} ${dependencies}`, rootDir);
35
- await executeCommand(`REDISMS_DISABLE_POSTINSTALL=1 ${installCommand} -D ${devDependencies}`, rootDir);
34
+ await executeCommand(`${installCommand} ${dependencies}`, rootDir);
35
+ await executeCommand(`${installCommand} -D ${devDependencies}`, rootDir);
36
36
  context.log("dependencies-installed", (message) => message.tag("success").append("Dependencies installed"));
37
37
  } catch (error) {
38
38
  console.error("❌ Failed to install dependencies:", error);
@@ -167,7 +167,7 @@ const create = async ({ projectName, template, cursorEnabled, context, skipRedis
167
167
  yarn: "yarn"
168
168
  }[packageManager];
169
169
  try {
170
- await executeCommand(`REDISMS_DISABLE_POSTINSTALL=1 ${installCommand}`, rootDir);
170
+ await executeCommand(`${installCommand}`, rootDir);
171
171
  context.log("plugin-dependencies-installed", (message) => message.tag("success").append("Plugin dependencies installed"));
172
172
  } catch (error) {
173
173
  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 { getInstallCommands, getInstallSaveCommands } from '../utils/build-npm-command'\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 = getInstallSaveCommands(rootDir)[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 installCommands: Record<string, string> = {\n ...getInstallCommands(rootDir),\n yarn: 'yarn', // yarn uses plain 'yarn' for install\n }\n const installCommand = installCommands[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":";;;;;;;;;;;;;;;;AAgBA,MAAM,YAAY,KAAK,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AAE9D,MAAM,8BAA8B,OAAO,gBAAwB,SAAiB,YAAw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K,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 { getInstallCommands, getInstallSaveCommands } from '../utils/build-npm-command'\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 = getInstallSaveCommands(rootDir)[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 installCommands: Record<string, string> = {\n ...getInstallCommands(rootDir),\n yarn: 'yarn', // yarn uses plain 'yarn' for install\n }\n const installCommand = installCommands[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":";;;;;;;;;;;;;;;;AAgBA,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,uBAAuB,QAAQ,CAAC;CAEvD,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,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,SAAqB,mBAAmB,UAAU;CACtG,MAAM,eAAe,mBAAmB,QAAQ,KAAK,GAAG;CACxD,MAAM,oBAAoB,0BAA0B;CACpD,MAAM,iBAAiB,kBAAkB,aAAa;AAKtD,KAFE,CAAC,qBAAqB,mBAAmB,SAAS,CAAC,kBAAkB,cAAc,oBAAoB,CAGvG,SAAQ,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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,6 +1,5 @@
1
1
  import { internalLogger } from "../utils/internal-logger.mjs";
2
2
  import { ensureBuildTools } from "../utils/check-build-tools.mjs";
3
- import { ProgressInterceptor } from "./progress-interceptor.mjs";
4
3
  import { mkdirSync } from "fs";
5
4
  import { RedisMemoryServer } from "redis-memory-server";
6
5
 
@@ -10,7 +9,6 @@ var RedisMemoryManager = class {
10
9
  this.server = null;
11
10
  this.client = null;
12
11
  this.running = false;
13
- this.progressInterceptor = new ProgressInterceptor();
14
12
  }
15
13
  registerCleanupHandlers() {
16
14
  process.on("exit", async () => {
@@ -52,12 +50,8 @@ var RedisMemoryManager = class {
52
50
  throw error;
53
51
  }
54
52
  try {
55
- const { host, port } = await this.progressInterceptor.wrap(async () => {
56
- return {
57
- host: await this.server.getHost(),
58
- port: await this.server.getPort()
59
- };
60
- });
53
+ const host = await this.server.getHost();
54
+ const port = await this.server.getPort();
61
55
  this.running = true;
62
56
  internalLogger.info("Redis Memory Server started", `${host}:${port}`);
63
57
  return {
@@ -65,7 +59,6 @@ var RedisMemoryManager = class {
65
59
  port
66
60
  };
67
61
  } catch (error) {
68
- this.progressInterceptor.stop();
69
62
  internalLogger.error("Failed to start Redis Memory Server");
70
63
  if (error instanceof Error) {
71
64
  console.error(error.message);
@@ -1 +1 @@
1
- {"version":3,"file":"memory-manager.mjs","names":["instance: RedisMemoryInstancePropT","error: unknown"],"sources":["../../src/redis/memory-manager.ts"],"sourcesContent":["import { mkdirSync } from 'fs'\nimport type { RedisClientType } from 'redis'\nimport { RedisMemoryServer } from 'redis-memory-server'\nimport type { RedisMemoryInstancePropT } from 'redis-memory-server/lib/types'\nimport { ensureBuildTools } from '../utils/check-build-tools'\nimport { internalLogger } from '../utils/internal-logger'\nimport { ProgressInterceptor } from './progress-interceptor'\nimport type { RedisConnectionInfo } from './types'\n\nexport class RedisMemoryManager {\n private server: RedisMemoryServer | null = null\n private client: RedisClientType | null = null\n private running = false\n private progressInterceptor = new ProgressInterceptor()\n\n private registerCleanupHandlers(): void {\n process.on('exit', async () => {\n await this.stop()\n })\n process.on('SIGTERM', async () => {\n await this.stop()\n })\n\n process.on('SIGINT', async () => {\n await this.stop()\n })\n }\n\n async startServer(baseDir: string): Promise<RedisConnectionInfo> {\n if (!this.server) {\n try {\n // Check for required build tools before attempting to start\n await ensureBuildTools()\n\n mkdirSync(baseDir, { recursive: true })\n\n const instance: RedisMemoryInstancePropT = {\n args: ['--appendonly', 'yes', '--appendfsync', 'everysec', '--save', '\"\"', '--dir', baseDir],\n }\n\n if (process.env.MOTIA_REDIS_PORT) {\n instance.port = parseInt(process.env.MOTIA_REDIS_PORT || '6379')\n }\n\n this.server = new RedisMemoryServer({ instance })\n this.registerCleanupHandlers()\n } catch (error) {\n internalLogger.error('Failed to initialize Redis Memory Server')\n if (error instanceof Error) {\n console.error(error.message)\n if (process.env.LOG_LEVEL === 'debug' && error.stack) {\n console.error('\\nStack trace:')\n console.error(error.stack)\n }\n }\n throw error\n }\n }\n\n try {\n // Wrap the server startup with progress interception\n // The download happens during getHost/getPort calls\n const { host, port } = await this.progressInterceptor.wrap(async () => {\n const host = await this.server!.getHost()\n const port = await this.server!.getPort()\n return { host, port }\n })\n\n this.running = true\n internalLogger.info('Redis Memory Server started', `${host}:${port}`)\n\n return { host, port }\n } catch (error) {\n this.progressInterceptor.stop() // Ensure interceptor is stopped on error\n internalLogger.error('Failed to start Redis Memory Server')\n\n if (error instanceof Error) {\n console.error(error.message)\n\n // Provide helpful suggestions based on common error patterns\n if (error.message.includes('make') || error.message.includes('compile')) {\n console.error('\\nThis error typically occurs when build tools are missing.')\n console.error('Please ensure you have \"make\" and a C compiler installed.')\n }\n\n if (process.env.LOG_LEVEL === 'debug' && error.stack) {\n console.error('\\nStack trace:')\n console.error(error.stack)\n }\n }\n\n console.error('\\nAlternative: Use an external Redis server')\n console.error(' Set MOTIA_DISABLE_MEMORY_SERVER=true')\n console.error(' Set MOTIA_REDIS_HOST=<your-redis-host>')\n console.error(' Set MOTIA_REDIS_PORT=<your-redis-port> (default: 6379)')\n\n throw error\n }\n }\n\n async stop(): Promise<void> {\n if (this.server && this.running) {\n try {\n await this.server.stop()\n } catch (error: unknown) {\n internalLogger.error('Error stopping Redis Memory Server', (error as Error)?.message)\n } finally {\n this.running = false\n this.server = null\n }\n }\n }\n\n isRunning(): boolean {\n return this.running\n }\n\n getClient(): RedisClientType | null {\n return this.client\n }\n}\n"],"mappings":";;;;;;;AASA,IAAa,qBAAb,MAAgC;;gBACa;gBACF;iBACvB;6BACY,IAAI,qBAAqB;;CAEvD,AAAQ,0BAAgC;AACtC,UAAQ,GAAG,QAAQ,YAAY;AAC7B,SAAM,KAAK,MAAM;IACjB;AACF,UAAQ,GAAG,WAAW,YAAY;AAChC,SAAM,KAAK,MAAM;IACjB;AAEF,UAAQ,GAAG,UAAU,YAAY;AAC/B,SAAM,KAAK,MAAM;IACjB;;CAGJ,MAAM,YAAY,SAA+C;AAC/D,MAAI,CAAC,KAAK,OACR,KAAI;AAEF,SAAM,kBAAkB;AAExB,aAAU,SAAS,EAAE,WAAW,MAAM,CAAC;GAEvC,MAAMA,WAAqC,E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AAM,OAAsB;AAC1B,MAAI,KAAK,UAAU,KAAK,QACtB,KAAI;AACF,SAAM,KAAK,OAAO,MAAM;WACjBC,OAAgB;AACvB,kBAAe,MAAM,sCAAuC,OAAiB,QAAQ;YAC7E;AACR,QAAK,UAAU;AACf,QAAK,SAAS;;;CAKpB,YAAqB;AACnB,SAAO,KAAK;;CAGd,YAAoC;AAClC,SAAO,KAAK"}
1
+ {"version":3,"file":"memory-manager.mjs","names":["instance: RedisMemoryInstancePropT","error: unknown"],"sources":["../../src/redis/memory-manager.ts"],"sourcesContent":["import { mkdirSync } from 'fs'\nimport type { RedisClientType } from 'redis'\nimport { RedisMemoryServer } from 'redis-memory-server'\nimport type { RedisMemoryInstancePropT } from 'redis-memory-server/lib/types'\nimport { ensureBuildTools } from '../utils/check-build-tools'\nimport { internalLogger } from '../utils/internal-logger'\nimport type { RedisConnectionInfo } from './types'\n\nexport class RedisMemoryManager {\n private server: RedisMemoryServer | null = null\n private client: RedisClientType | null = null\n private running = false\n\n private registerCleanupHandlers(): void {\n process.on('exit', async () => {\n await this.stop()\n })\n process.on('SIGTERM', async () => {\n await this.stop()\n })\n\n process.on('SIGINT', async () => {\n await this.stop()\n })\n }\n\n async startServer(baseDir: string): Promise<RedisConnectionInfo> {\n if (!this.server) {\n try {\n // Check for required build tools before attempting to start\n await ensureBuildTools()\n\n mkdirSync(baseDir, { recursive: true })\n\n const instance: RedisMemoryInstancePropT = {\n args: ['--appendonly', 'yes', '--appendfsync', 'everysec', '--save', '\"\"', '--dir', baseDir],\n }\n\n if (process.env.MOTIA_REDIS_PORT) {\n instance.port = parseInt(process.env.MOTIA_REDIS_PORT || '6379')\n }\n\n this.server = new RedisMemoryServer({ instance })\n this.registerCleanupHandlers()\n } catch (error) {\n internalLogger.error('Failed to initialize Redis Memory Server')\n if (error instanceof Error) {\n console.error(error.message)\n if (process.env.LOG_LEVEL === 'debug' && error.stack) {\n console.error('\\nStack trace:')\n console.error(error.stack)\n }\n }\n throw error\n }\n }\n\n try {\n const host = await this.server.getHost()\n const port = await this.server.getPort()\n\n this.running = true\n internalLogger.info('Redis Memory Server started', `${host}:${port}`)\n\n return { host, port }\n } catch (error) {\n internalLogger.error('Failed to start Redis Memory Server')\n\n if (error instanceof Error) {\n console.error(error.message)\n\n // Provide helpful suggestions based on common error patterns\n if (error.message.includes('make') || error.message.includes('compile')) {\n console.error('\\nThis error typically occurs when build tools are missing.')\n console.error('Please ensure you have \"make\" and a C compiler installed.')\n }\n\n if (process.env.LOG_LEVEL === 'debug' && error.stack) {\n console.error('\\nStack trace:')\n console.error(error.stack)\n }\n }\n\n console.error('\\nAlternative: Use an external Redis server')\n console.error(' Set MOTIA_DISABLE_MEMORY_SERVER=true')\n console.error(' Set MOTIA_REDIS_HOST=<your-redis-host>')\n console.error(' Set MOTIA_REDIS_PORT=<your-redis-port> (default: 6379)')\n\n throw error\n }\n }\n\n async stop(): Promise<void> {\n if (this.server && this.running) {\n try {\n await this.server.stop()\n } catch (error: unknown) {\n internalLogger.error('Error stopping Redis Memory Server', (error as Error)?.message)\n } finally {\n this.running = false\n this.server = null\n }\n }\n }\n\n isRunning(): boolean {\n return this.running\n }\n\n getClient(): RedisClientType | null {\n return this.client\n }\n}\n"],"mappings":";;;;;;AAQA,IAAa,qBAAb,MAAgC;;gBACa;gBACF;iBACvB;;CAElB,AAAQ,0BAAgC;AACtC,UAAQ,GAAG,QAAQ,YAAY;AAC7B,SAAM,KAAK,MAAM;IACjB;AACF,UAAQ,GAAG,WAAW,YAAY;AAChC,SAAM,KAAK,MAAM;IACjB;AAEF,UAAQ,GAAG,UAAU,YAAY;AAC/B,SAAM,KAAK,MAAM;IACjB;;CAGJ,MAAM,YAAY,SAA+C;AAC/D,MAAI,CAAC,KAAK,OACR,KAAI;AAEF,SAAM,kBAAkB;AAExB,aAAU,SAAS,EAAE,WAAW,MAAM,CAAC;GAEvC,MAAMA,WAAqC,EACzC,MAAM;IAAC;IAAgB;IAAO;IAAiB;IAAY;IAAU;IAAM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AU;AACf,QAAK,SAAS;;;CAKpB,YAAqB;AACnB,SAAO,KAAK;;CAGd,YAAoC;AAClC,SAAO,KAAK"}
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-396370",
4
+ "version": "0.17.9-beta.192-239007",
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-redis-cron": "0.17.9-beta.192-396370",
50
- "@motiadev/adapter-redis-state": "0.17.9-beta.192-396370",
51
- "@motiadev/adapter-redis-streams": "0.17.9-beta.192-396370",
52
- "@motiadev/adapter-bullmq-events": "0.17.9-beta.192-396370",
53
- "@motiadev/workbench": "0.17.9-beta.192-396370",
54
- "@motiadev/core": "0.17.9-beta.192-396370",
55
- "@motiadev/stream-client-node": "0.17.9-beta.192-396370"
49
+ "@motiadev/adapter-bullmq-events": "0.17.9-beta.192-239007",
50
+ "@motiadev/adapter-redis-cron": "0.17.9-beta.192-239007",
51
+ "@motiadev/adapter-redis-state": "0.17.9-beta.192-239007",
52
+ "@motiadev/adapter-redis-streams": "0.17.9-beta.192-239007",
53
+ "@motiadev/core": "0.17.9-beta.192-239007",
54
+ "@motiadev/workbench": "0.17.9-beta.192-239007",
55
+ "@motiadev/stream-client-node": "0.17.9-beta.192-239007"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@amplitude/analytics-types": "^2.9.2",
@@ -1,65 +0,0 @@
1
- import { internalLogger } from "../utils/internal-logger.mjs";
2
-
3
- //#region src/redis/progress-interceptor.ts
4
- /**
5
- * Intercepts stdout during Redis download to reformat progress messages
6
- * The redis-memory-server library uses carriage returns (\r) for in-place updates,
7
- * which don't render properly in all terminals (especially WSL).
8
- * This interceptor converts those updates to line-by-line progress.
9
- */
10
- var ProgressInterceptor = class {
11
- constructor() {
12
- this.lastReportedPercent = -1;
13
- this.isActive = false;
14
- this.progressPattern = /Downloading Redis[^:]*:\s*([\d.]+)\s*%/;
15
- this.originalStdoutWrite = process.stdout.write.bind(process.stdout);
16
- }
17
- /**
18
- * Start intercepting stdout to reformat progress messages
19
- */
20
- start() {
21
- if (this.isActive) return;
22
- this.isActive = true;
23
- this.lastReportedPercent = -1;
24
- internalLogger.info("Downloading Redis binary (this may take a few minutes)...");
25
- process.stdout.write = ((chunk, encodingOrCallback, callback) => {
26
- const match = (typeof chunk === "string" ? chunk : chunk.toString()).match(this.progressPattern);
27
- if (match) {
28
- const percent = Math.floor(parseFloat(match[1]));
29
- const milestone = Math.floor(percent / 25) * 25;
30
- if (milestone > this.lastReportedPercent) {
31
- this.lastReportedPercent = milestone;
32
- console.log(` Progress: ${milestone}%`);
33
- }
34
- return true;
35
- }
36
- if (typeof encodingOrCallback === "function") return this.originalStdoutWrite(chunk, encodingOrCallback);
37
- return this.originalStdoutWrite(chunk, encodingOrCallback, callback);
38
- });
39
- }
40
- /**
41
- * Stop intercepting and restore original stdout
42
- */
43
- stop() {
44
- if (!this.isActive) return;
45
- this.isActive = false;
46
- process.stdout.write = this.originalStdoutWrite;
47
- if (this.lastReportedPercent >= 0 && this.lastReportedPercent < 100) console.log(" Progress: 100%");
48
- internalLogger.info("Redis binary download complete");
49
- }
50
- /**
51
- * Execute an async function with progress interception
52
- */
53
- async wrap(fn) {
54
- this.start();
55
- try {
56
- return await fn();
57
- } finally {
58
- this.stop();
59
- }
60
- }
61
- };
62
-
63
- //#endregion
64
- export { ProgressInterceptor };
65
- //# sourceMappingURL=progress-interceptor.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"progress-interceptor.mjs","names":[],"sources":["../../src/redis/progress-interceptor.ts"],"sourcesContent":["import { internalLogger } from '../utils/internal-logger'\n\n/**\n * Intercepts stdout during Redis download to reformat progress messages\n * The redis-memory-server library uses carriage returns (\\r) for in-place updates,\n * which don't render properly in all terminals (especially WSL).\n * This interceptor converts those updates to line-by-line progress.\n */\nexport class ProgressInterceptor {\n private originalStdoutWrite: typeof process.stdout.write\n private lastReportedPercent = -1\n private isActive = false\n private progressPattern = /Downloading Redis[^:]*:\\s*([\\d.]+)\\s*%/\n\n constructor() {\n this.originalStdoutWrite = process.stdout.write.bind(process.stdout)\n }\n\n /**\n * Start intercepting stdout to reformat progress messages\n */\n start(): void {\n if (this.isActive) return\n this.isActive = true\n this.lastReportedPercent = -1\n\n internalLogger.info('Downloading Redis binary (this may take a few minutes)...')\n\n // Override stdout.write to intercept progress messages\n process.stdout.write = ((\n chunk: string | Uint8Array,\n encodingOrCallback?: BufferEncoding | ((err?: Error) => void),\n callback?: (err?: Error) => void\n ): boolean => {\n const text = typeof chunk === 'string' ? chunk : chunk.toString()\n\n // Check if this is a Redis download progress message\n const match = text.match(this.progressPattern)\n if (match) {\n const percent = Math.floor(parseFloat(match[1]))\n\n // Report at 0%, 25%, 50%, 75%, and 100%\n const milestone = Math.floor(percent / 25) * 25\n if (milestone > this.lastReportedPercent) {\n this.lastReportedPercent = milestone\n // Use console.log for clean line-by-line output\n console.log(` Progress: ${milestone}%`)\n }\n\n // Suppress the original output (which has \\r issues)\n return true\n }\n\n // Pass through all other output\n if (typeof encodingOrCallback === 'function') {\n return this.originalStdoutWrite(chunk, encodingOrCallback)\n }\n return this.originalStdoutWrite(chunk, encodingOrCallback, callback)\n }) as typeof process.stdout.write\n }\n\n /**\n * Stop intercepting and restore original stdout\n */\n stop(): void {\n if (!this.isActive) return\n this.isActive = false\n process.stdout.write = this.originalStdoutWrite\n\n if (this.lastReportedPercent >= 0 && this.lastReportedPercent < 100) {\n console.log(' Progress: 100%')\n }\n internalLogger.info('Redis binary download complete')\n }\n\n /**\n * Execute an async function with progress interception\n */\n async wrap<T>(fn: () => Promise<T>): Promise<T> {\n this.start()\n try {\n return await fn()\n } finally {\n this.stop()\n }\n }\n}\n\n"],"mappings":";;;;;;;;;AAQA,IAAa,sBAAb,MAAiC;CAM/B,cAAc;6BAJgB;kBACX;yBACO;AAGxB,OAAK,sBAAsB,QAAQ,OAAO,MAAM,KAAK,QAAQ,OAAO;;;;;CAMtE,QAAc;AACZ,MAAI,KAAK,SAAU;AACnB,OAAK,WAAW;AAChB,OAAK,sBAAsB;AAE3B,iBAAe,KAAK,4DAA4D;AAGhF,UAAQ,OAAO,UACb,OACA,oBACA,aACY;GAIZ,MAAM,SAHO,OAAO,UAAU,WAAW,QAAQ,MAAM,UAAU,EAG9C,MAAM,KAAK,gBAAgB;AAC9C,OAAI,OAAO;IACT,MAAM,UAAU,KAAK,MAAM,WAAW,MAAM,GAAG,CAAC;IAGhD,MAAM,YAAY,KAAK,MAAM,UAAU,GAAG,GAAG;AAC7C,QAAI,YAAY,KAAK,qBAAqB;AACxC,UAAK,sBAAsB;AAE3B,aAAQ,IAAI,eAAe,UAAU,GAAG;;AAI1C,WAAO;;AAIT,OAAI,OAAO,uBAAuB,WAChC,QAAO,KAAK,oBAAoB,OAAO,mBAAmB;AAE5D,UAAO,KAAK,oBAAoB,OAAO,oBAAoB,SAAS;;;;;;CAOxE,OAAa;AACX,MAAI,CAAC,KAAK,SAAU;AACpB,OAAK,WAAW;AAChB,UAAQ,OAAO,QAAQ,KAAK;AAE5B,MAAI,KAAK,uBAAuB,KAAK,KAAK,sBAAsB,IAC9D,SAAQ,IAAI,mBAAmB;AAEjC,iBAAe,KAAK,iCAAiC;;;;;CAMvD,MAAM,KAAQ,IAAkC;AAC9C,OAAK,OAAO;AACZ,MAAI;AACF,UAAO,MAAM,IAAI;YACT;AACR,QAAK,MAAM"}