@inlang/paraglide-js 2.24.0 → 2.25.0

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 (85) hide show
  1. package/dist/bundler-plugins/esbuild.d.ts +1 -1
  2. package/dist/bundler-plugins/per-locale-build/index.d.ts +3 -3
  3. package/dist/bundler-plugins/per-locale-build/index.js +59 -15
  4. package/dist/bundler-plugins/per-locale-build/index.js.map +1 -1
  5. package/dist/bundler-plugins/rolldown.d.ts +1 -1
  6. package/dist/bundler-plugins/rollup.d.ts +1 -1
  7. package/dist/bundler-plugins/rspack.d.ts +1 -1
  8. package/dist/bundler-plugins/unplugin.d.ts +35 -1
  9. package/dist/bundler-plugins/unplugin.js +404 -123
  10. package/dist/bundler-plugins/unplugin.js.map +1 -1
  11. package/dist/bundler-plugins/unplugin.test.js +357 -202
  12. package/dist/bundler-plugins/unplugin.test.js.map +1 -1
  13. package/dist/bundler-plugins/vite.d.ts +2 -2
  14. package/dist/bundler-plugins/vite.js.map +1 -1
  15. package/dist/bundler-plugins/vite.test.js +2 -1
  16. package/dist/bundler-plugins/vite.test.js.map +1 -1
  17. package/dist/bundler-plugins/webpack.d.ts +1 -1
  18. package/dist/cli/commands/compile/command.js +156 -36
  19. package/dist/cli/commands/compile/command.js.map +1 -1
  20. package/dist/cli/commands/compile/command.test.js +311 -7
  21. package/dist/cli/commands/compile/command.test.js.map +1 -1
  22. package/dist/cli/defaults.d.ts +0 -2
  23. package/dist/cli/defaults.js +0 -2
  24. package/dist/cli/defaults.js.map +1 -1
  25. package/dist/cli/steps/initialize-inlang-project.js +2 -1
  26. package/dist/cli/steps/initialize-inlang-project.js.map +1 -1
  27. package/dist/cli/steps/prompt-for-outdir.js +1 -1
  28. package/dist/cli/steps/prompt-for-outdir.js.map +1 -1
  29. package/dist/compiler/compile-annotation.d.ts +2 -2
  30. package/dist/compiler/compile-annotation.js +9 -9
  31. package/dist/compiler/compile-annotation.js.map +1 -1
  32. package/dist/compiler/compile-local-variable.d.ts +2 -1
  33. package/dist/compiler/compile-local-variable.js +4 -4
  34. package/dist/compiler/compile-local-variable.js.map +1 -1
  35. package/dist/compiler/compile-local-variable.test.js +82 -0
  36. package/dist/compiler/compile-local-variable.test.js.map +1 -1
  37. package/dist/compiler/compile-message.js +10 -2
  38. package/dist/compiler/compile-message.js.map +1 -1
  39. package/dist/compiler/compile-message.test.js +132 -2
  40. package/dist/compiler/compile-message.test.js.map +1 -1
  41. package/dist/compiler/compile-pattern.js +4 -2
  42. package/dist/compiler/compile-pattern.js.map +1 -1
  43. package/dist/compiler/compile-pattern.test.js +31 -0
  44. package/dist/compiler/compile-pattern.test.js.map +1 -1
  45. package/dist/compiler/compiler-options.d.ts +1 -1
  46. package/dist/compiler/compiler-options.js.map +1 -1
  47. package/dist/compiler/server/create-server-file.js +18 -4
  48. package/dist/compiler/server/create-server-file.js.map +1 -1
  49. package/dist/compiler/server/create-server-file.test.js +76 -0
  50. package/dist/compiler/server/create-server-file.test.js.map +1 -1
  51. package/dist/compiler/variable-access.d.ts +2 -0
  52. package/dist/compiler/variable-access.js +6 -0
  53. package/dist/compiler/variable-access.js.map +1 -1
  54. package/dist/index.d.ts +1 -0
  55. package/dist/index.js +1 -0
  56. package/dist/index.js.map +1 -1
  57. package/dist/services/config/config-schema.d.ts +69 -0
  58. package/dist/services/config/config-schema.js +78 -0
  59. package/dist/services/config/config-schema.js.map +1 -0
  60. package/dist/services/config/defaults.d.ts +11 -0
  61. package/dist/services/config/defaults.js +12 -0
  62. package/dist/services/config/defaults.js.map +1 -0
  63. package/dist/services/config/discover-config-file.d.ts +19 -0
  64. package/dist/services/config/discover-config-file.js +39 -0
  65. package/dist/services/config/discover-config-file.js.map +1 -0
  66. package/dist/services/config/index.d.ts +24 -0
  67. package/dist/services/config/index.js +25 -0
  68. package/dist/services/config/index.js.map +1 -0
  69. package/dist/services/config/load-paraglide-config.d.ts +44 -0
  70. package/dist/services/config/load-paraglide-config.js +109 -0
  71. package/dist/services/config/load-paraglide-config.js.map +1 -0
  72. package/dist/services/config/load-paraglide-config.test.d.ts +1 -0
  73. package/dist/services/config/load-paraglide-config.test.js +201 -0
  74. package/dist/services/config/load-paraglide-config.test.js.map +1 -0
  75. package/dist/services/config/resolve-compiler-options.d.ts +24 -0
  76. package/dist/services/config/resolve-compiler-options.js +51 -0
  77. package/dist/services/config/resolve-compiler-options.js.map +1 -0
  78. package/dist/services/config/resolve-compiler-options.test.d.ts +1 -0
  79. package/dist/services/config/resolve-compiler-options.test.js +60 -0
  80. package/dist/services/config/resolve-compiler-options.test.js.map +1 -0
  81. package/dist/services/env-variables/index.js +1 -1
  82. package/dist/services/env-variables/index.js.map +1 -1
  83. package/dist/services/logger/index.js +2 -0
  84. package/dist/services/logger/index.js.map +1 -1
  85. package/package.json +5 -3
@@ -1 +1 @@
1
- {"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../src/cli/commands/compile/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,OAAO,EAA0B,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,iCAAiC,EAAE,MAAM,gDAAgD,CAAC;AACnG,OAAO,EACN,sBAAsB,GAEtB,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EACN,eAAe,EACf,eAAe,GACf,MAAM,+CAA+C,CAAC;AAEvD,MAAM,oBAAoB,GAAG,CAC5B,KAAa,EACqC,EAAE;IACpD,IAAI,KAAK,KAAK,iBAAiB,IAAI,KAAK,KAAK,gBAAgB,EAAE,CAAC;QAC/D,OAAO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,KAAK,MAAM,OAAO,IAAI,YAAY,CAAC,MAAM,EAAE,EAAE,CAAC;YAC7C,OAAO,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;QACD,KAAK,MAAM,OAAO,IAAI,iBAAiB,CAAC,MAAM,EAAE,EAAE,CAAC;YAClD,OAAO,CAAC,KAAK,EAAE,CAAC;QACjB,CAAC;QACD,YAAY,CAAC,KAAK,EAAE,CAAC;QACrB,iBAAiB,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC,CAAC;IAEF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACzB,aAAa,EAAE,CAAC;QAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,MAAM,UAAU,EAAE,CAAC;IACnB,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;AACxC,CAAC,CACD,CAAC","sourcesContent":["import { Command, InvalidArgumentError } from \"commander\";\nimport fs from \"node:fs\";\nimport { resolve, relative } from \"node:path\";\nimport { Logger } from \"../../../services/logger/index.js\";\nimport { DEFAULT_OUTDIR, DEFAULT_PROJECT_PATH } from \"../../defaults.js\";\nimport { compile, type CompilationResult } from \"../../../compiler/compile.js\";\nimport { seedPreviousCompilationFromOutdir } from \"../../../compiler/seed-previous-compilation.js\";\nimport {\n\tdefaultCompilerOptions,\n\ttype CompilerOptions,\n} from \"../../../compiler/compiler-options.js\";\nimport {\n\tcreateTrackedFs,\n\tgetWatchTargets,\n} from \"../../../services/file-watching/tracked-fs.js\";\n\nconst parseOutputStructure = (\n\tvalue: string\n): NonNullable<CompilerOptions[\"outputStructure\"]> => {\n\tif (value === \"message-modules\" || value === \"locale-modules\") {\n\t\treturn value;\n\t}\n\tthrow new InvalidArgumentError(\n\t\t`Invalid output structure \"${value}\". Expected \"message-modules\" or \"locale-modules\".`\n\t);\n};\n\nexport const compileCommand = new Command()\n\t.name(\"compile\")\n\t.summary(\"Compiles inlang Paraglide-JS\")\n\t.requiredOption(\n\t\t\"--project <path>\",\n\t\t'The path to the inlang project. Example: \"./project.inlang\"',\n\t\tDEFAULT_PROJECT_PATH\n\t)\n\t.requiredOption(\n\t\t\"--outdir <path>\",\n\t\t'The path to the output directory. Example: \"./src/paraglide\"',\n\t\tDEFAULT_OUTDIR\n\t)\n\t.option(\n\t\t\"--strategy <items...>\",\n\t\t[\n\t\t\t\"The strategy to be used.\",\n\t\t\t\"\",\n\t\t\t\"Example: --strategy cookie globalVariable baseLocale\",\n\t\t\t\"Read more on https://paraglidejs.com/strategy\",\n\t\t].join(\"\\n\")\n\t)\n\t.requiredOption(\"--silent\", \"Only log errors to the console\", false)\n\t.option(\n\t\t\"--emit-ts-declarations\",\n\t\t\"Emit .d.ts files for the generated output (requires the typescript package)\",\n\t\tdefaultCompilerOptions.emitTsDeclarations\n\t)\n\t.option(\n\t\t\"--no-emit-ts-declarations\",\n\t\t\"Do not emit .d.ts files for the generated output\"\n\t)\n\t.option(\n\t\t\"--emit-git-ignore\",\n\t\t\"Emit a .gitignore in the output directory\",\n\t\tdefaultCompilerOptions.emitGitIgnore\n\t)\n\t.option(\n\t\t\"--no-emit-git-ignore\",\n\t\t\"Do not emit a .gitignore in the output directory\"\n\t)\n\t.option(\n\t\t\"--emit-prettier-ignore\",\n\t\t\"Emit a .prettierignore in the output directory\",\n\t\tdefaultCompilerOptions.emitPrettierIgnore\n\t)\n\t.option(\n\t\t\"--no-emit-prettier-ignore\",\n\t\t\"Do not emit a .prettierignore in the output directory\"\n\t)\n\t.option(\n\t\t\"--emit-readme\",\n\t\t\"Emit a README.md in the output directory (helps LLMs understand the generated code)\",\n\t\tdefaultCompilerOptions.emitReadme\n\t)\n\t.option(\n\t\t\"--no-emit-readme\",\n\t\t\"Do not emit README.md in the output directory\"\n\t)\n\t.option(\n\t\t\"--is-server <expression>\",\n\t\t[\n\t\t\t\"JavaScript expression for runtime `isServer` (enables server/client tree-shaking).\",\n\t\t\t'Quote if the expression contains spaces, e.g. --is-server \\'typeof window === \"undefined\"\\'.',\n\t\t\t\"Vite SSR example: --is-server 'import.meta.env.SSR'\",\n\t\t].join(\" \")\n\t)\n\t.option(\n\t\t\"--output-structure <structure>\",\n\t\t[\n\t\t\t'The output structure for compiled messages. Either \"message-modules\" or \"locale-modules\".',\n\t\t\t\"\",\n\t\t\t'\"message-modules\" gives each message its own module (better tree-shaking).',\n\t\t\t'\"locale-modules\" bundles messages per locale (fewer files, better for large projects in dev).',\n\t\t].join(\"\\n\"),\n\t\tparseOutputStructure,\n\t\tdefaultCompilerOptions.outputStructure\n\t)\n\t.option(\"--watch\", \"Watch project files and recompile on change\", false)\n\t.action(\n\t\tasync (options: {\n\t\t\tsilent: boolean;\n\t\t\tproject: string;\n\t\t\toutdir: string;\n\t\t\tstrategy?: CompilerOptions[\"strategy\"];\n\t\t\temitTsDeclarations?: CompilerOptions[\"emitTsDeclarations\"];\n\t\t\temitGitIgnore?: CompilerOptions[\"emitGitIgnore\"];\n\t\t\temitPrettierIgnore?: CompilerOptions[\"emitPrettierIgnore\"];\n\t\t\temitReadme?: CompilerOptions[\"emitReadme\"];\n\t\t\tisServer?: CompilerOptions[\"isServer\"];\n\t\t\toutputStructure?: CompilerOptions[\"outputStructure\"];\n\t\t\twatch?: boolean;\n\t\t}) => {\n\t\t\tconst logger = new Logger({ silent: options.silent, prefix: true });\n\t\t\tconst path = resolve(process.cwd(), options.project);\n\n\t\t\tconst compileOptions = {\n\t\t\t\tproject: path,\n\t\t\t\toutdir: options.outdir,\n\t\t\t\tstrategy: options.strategy ?? defaultCompilerOptions.strategy,\n\t\t\t\temitTsDeclarations:\n\t\t\t\t\toptions.emitTsDeclarations ??\n\t\t\t\t\tdefaultCompilerOptions.emitTsDeclarations,\n\t\t\t\temitGitIgnore:\n\t\t\t\t\toptions.emitGitIgnore ?? defaultCompilerOptions.emitGitIgnore,\n\t\t\t\temitPrettierIgnore:\n\t\t\t\t\toptions.emitPrettierIgnore ??\n\t\t\t\t\tdefaultCompilerOptions.emitPrettierIgnore,\n\t\t\t\temitReadme: options.emitReadme ?? defaultCompilerOptions.emitReadme,\n\t\t\t\tisServer: options.isServer ?? defaultCompilerOptions.isServer,\n\t\t\t\toutputStructure:\n\t\t\t\t\toptions.outputStructure ??\n\t\t\t\t\tdefaultCompilerOptions.outputStructure,\n\t\t\t};\n\n\t\t\tif (!options.watch) {\n\t\t\t\tlogger.info(`Compiling inlang project ...`);\n\n\t\t\t\ttry {\n\t\t\t\t\tconst previousCompilation = await seedPreviousCompilationFromOutdir({\n\t\t\t\t\t\toutdir: compileOptions.outdir,\n\t\t\t\t\t});\n\n\t\t\t\t\tawait compile({\n\t\t\t\t\t\t...compileOptions,\n\t\t\t\t\t\tpreviousCompilation,\n\t\t\t\t\t\tcleanOutdir: false,\n\t\t\t\t\t});\n\t\t\t\t} catch (e) {\n\t\t\t\t\tlogger.error(\"Error while compiling inlang project.\");\n\t\t\t\t\tlogger.error(e);\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tlogger.success(`Successfully compiled inlang project.`);\n\n\t\t\t\tprocess.exit(0);\n\t\t\t}\n\n\t\t\tconst { fs: trackedFs, readFiles, clearReadFiles } = createTrackedFs();\n\t\t\tconst fileWatchers = new Map<string, fs.FSWatcher>();\n\t\t\tconst directoryWatchers = new Map<string, fs.FSWatcher>();\n\t\t\tlet previousCompilation: CompilationResult | undefined;\n\t\t\tlet compileTimer: NodeJS.Timeout | undefined;\n\t\t\tlet compileInProgress = false;\n\t\t\tlet compileRequested = false;\n\n\t\t\tconst updateWatchers = (files: Set<string>) => {\n\t\t\t\tconst {\n\t\t\t\t\tfiles: nextFiles,\n\t\t\t\t\tdirectories: nextDirectories,\n\t\t\t\t\tisIgnoredPath,\n\t\t\t\t} = getWatchTargets(files, { outdir: options.outdir });\n\n\t\t\t\tfor (const [filePath, watcher] of fileWatchers) {\n\t\t\t\t\tif (!nextFiles.has(filePath)) {\n\t\t\t\t\t\twatcher.close();\n\t\t\t\t\t\tfileWatchers.delete(filePath);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const [directoryPath, watcher] of directoryWatchers) {\n\t\t\t\t\tif (!nextDirectories.has(directoryPath)) {\n\t\t\t\t\t\twatcher.close();\n\t\t\t\t\t\tdirectoryWatchers.delete(directoryPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst attachWatcherErrorHandler = (\n\t\t\t\t\twatcher: fs.FSWatcher,\n\t\t\t\t\ttargetPath: string,\n\t\t\t\t\ttargetType: \"file\" | \"directory\"\n\t\t\t\t) => {\n\t\t\t\t\twatcher.on(\"error\", (error) => {\n\t\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t\t`Watch ${targetType} error for ${targetPath}: ${(error as Error).message}`\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\tfor (const filePath of nextFiles) {\n\t\t\t\t\tif (fileWatchers.has(filePath)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst watcher = fs.watch(filePath, () => {\n\t\t\t\t\t\t\tscheduleCompile(filePath);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tattachWatcherErrorHandler(watcher, filePath, \"file\");\n\t\t\t\t\t\tfileWatchers.set(filePath, watcher);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tlogger.warn(`Failed to watch file: ${filePath}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const directoryPath of nextDirectories) {\n\t\t\t\t\tif (directoryWatchers.has(directoryPath)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst watcher = fs.watch(directoryPath, (eventType, filename) => {\n\t\t\t\t\t\t\tif (!filename) {\n\t\t\t\t\t\t\t\tscheduleCompile(directoryPath);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst changedPath = resolve(directoryPath, filename.toString());\n\t\t\t\t\t\t\tif (isIgnoredPath(changedPath)) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tscheduleCompile(changedPath);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tattachWatcherErrorHandler(watcher, directoryPath, \"directory\");\n\t\t\t\t\t\tdirectoryWatchers.set(directoryPath, watcher);\n\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\tlogger.warn(`Failed to watch directory: ${directoryPath}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst runCompile = async (changedPath?: string) => {\n\t\t\t\tif (compileInProgress) {\n\t\t\t\t\tcompileRequested = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tcompileInProgress = true;\n\t\t\t\tconst previouslyReadFiles = new Set(readFiles);\n\t\t\t\tclearReadFiles();\n\n\t\t\t\tif (changedPath) {\n\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t`Re-compiling inlang project... File \"${relative(process.cwd(), changedPath)}\" has changed.`\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.info(\"Compiling inlang project ...\");\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst seededPrevious =\n\t\t\t\t\t\tpreviousCompilation ??\n\t\t\t\t\t\t(await seedPreviousCompilationFromOutdir({\n\t\t\t\t\t\t\toutdir: compileOptions.outdir,\n\t\t\t\t\t\t}));\n\n\t\t\t\t\tpreviousCompilation = await compile({\n\t\t\t\t\t\t...compileOptions,\n\t\t\t\t\t\tfs: trackedFs,\n\t\t\t\t\t\tpreviousCompilation: seededPrevious,\n\t\t\t\t\t\tcleanOutdir: false,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (changedPath) {\n\t\t\t\t\t\tlogger.success(\"Re-compilation complete.\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogger.success(\"Successfully compiled inlang project.\");\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (previouslyReadFiles.size > 0) {\n\t\t\t\t\t\tclearReadFiles();\n\t\t\t\t\t\tfor (const filePath of previouslyReadFiles) {\n\t\t\t\t\t\t\treadFiles.add(filePath);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tpreviousCompilation = undefined;\n\t\t\t\t\tlogger.error(\"Error while compiling inlang project.\");\n\t\t\t\t\tlogger.error(e);\n\t\t\t\t} finally {\n\t\t\t\t\tupdateWatchers(readFiles);\n\t\t\t\t\tcompileInProgress = false;\n\t\t\t\t\tif (compileRequested) {\n\t\t\t\t\t\tcompileRequested = false;\n\t\t\t\t\t\trunCompile();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst scheduleCompile = (changedPath?: string) => {\n\t\t\t\tif (compileTimer) {\n\t\t\t\t\tclearTimeout(compileTimer);\n\t\t\t\t}\n\t\t\t\tcompileTimer = setTimeout(() => {\n\t\t\t\t\trunCompile(changedPath);\n\t\t\t\t}, 100);\n\t\t\t};\n\n\t\t\tconst closeWatchers = () => {\n\t\t\t\tfor (const watcher of fileWatchers.values()) {\n\t\t\t\t\twatcher.close();\n\t\t\t\t}\n\t\t\t\tfor (const watcher of directoryWatchers.values()) {\n\t\t\t\t\twatcher.close();\n\t\t\t\t}\n\t\t\t\tfileWatchers.clear();\n\t\t\t\tdirectoryWatchers.clear();\n\t\t\t};\n\n\t\t\tprocess.on(\"SIGINT\", () => {\n\t\t\t\tcloseWatchers();\n\t\t\t\tprocess.exit(0);\n\t\t\t});\n\n\t\t\tawait runCompile();\n\t\t\tlogger.info(\"Watching for changes...\");\n\t\t}\n\t);\n"]}
1
+ {"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../src/cli/commands/compile/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAC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B,CAAC;QACD,YAAY,CAAC,KAAK,EAAE,CAAC;QACrB,iBAAiB,CAAC,KAAK,EAAE,CAAC;IAC3B,CAAC,CAAC;IAEF,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE;QACzB,aAAa,EAAE,CAAC;QAChB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,MAAM,UAAU,EAAE,CAAC;IACnB,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;AACxC,CAAC,CACD,CAAC","sourcesContent":["import { Command, InvalidArgumentError } from \"commander\";\nimport fs from \"node:fs\";\nimport { resolve, relative } from \"node:path\";\nimport { Logger } from \"../../../services/logger/index.js\";\nimport {\n\tDEFAULT_OUTDIR,\n\tDEFAULT_PROJECT_PATH,\n} from \"../../../services/config/defaults.js\";\nimport { compile, type CompilationResult } from \"../../../compiler/compile.js\";\nimport { defaultCompilerOptions } from \"../../../compiler/compiler-options.js\";\nimport { seedPreviousCompilationFromOutdir } from \"../../../compiler/seed-previous-compilation.js\";\nimport {\n\tcreateTrackedFs,\n\tgetWatchTargets,\n} from \"../../../services/file-watching/tracked-fs.js\";\nimport * as v from \"valibot\";\nimport {\n\tclearParaglideConfigCache,\n\tisConfigFileName,\n\tloadParaglideConfig,\n\tresolveCompilerOptions,\n\tresolveConfigCandidate,\n\tstrategyNameSchema,\n\ttype LoadedParaglideConfig,\n\ttype ParaglideConfig,\n} from \"../../../services/config/index.js\";\nimport { nodeNormalizePath } from \"../../../utilities/node-normalize-path.js\";\nimport type { CompilerOptions } from \"../../../compiler/compiler-options.js\";\n\ntype OutputStructure = NonNullable<CompilerOptions[\"outputStructure\"]>;\n\nconst errorMessage = (error: unknown): string =>\n\terror instanceof Error ? error.message : String(error);\n\nconst parseOutputStructure = (value: string): OutputStructure => {\n\tif (value === \"message-modules\" || value === \"locale-modules\") {\n\t\treturn value;\n\t}\n\tthrow new InvalidArgumentError(\n\t\t`Invalid output structure \"${value}\". Expected \"message-modules\" or \"locale-modules\".`\n\t);\n};\n\nexport const compileCommand = new Command()\n\t.name(\"compile\")\n\t.summary(\"Compiles inlang Paraglide-JS\")\n\t.option(\n\t\t\"--project <path>\",\n\t\t`The path to the inlang project. Example: \"./project.inlang\". Defaults to \"${DEFAULT_PROJECT_PATH}\".`\n\t)\n\t.option(\n\t\t\"--outdir <path>\",\n\t\t`The path to the output directory. Example: \"./src/paraglide\". Defaults to \"${DEFAULT_OUTDIR}\".`\n\t)\n\t.option(\n\t\t\"--strategy <items...>\",\n\t\t[\n\t\t\t\"The strategy to be used.\",\n\t\t\t\"\",\n\t\t\t\"Example: --strategy cookie globalVariable baseLocale\",\n\t\t\t\"Read more on https://paraglidejs.com/strategy\",\n\t\t].join(\"\\n\")\n\t)\n\t.requiredOption(\"--silent\", \"Only log errors to the console\", false)\n\t.option(\n\t\t\"--emit-ts-declarations\",\n\t\t`Emit .d.ts files for the generated output (requires the typescript package) (default: ${defaultCompilerOptions.emitTsDeclarations})`\n\t)\n\t.option(\n\t\t\"--no-emit-ts-declarations\",\n\t\t\"Do not emit .d.ts files for the generated output\"\n\t)\n\t.option(\n\t\t\"--emit-git-ignore\",\n\t\t`Emit a .gitignore in the output directory (default: ${defaultCompilerOptions.emitGitIgnore})`\n\t)\n\t.option(\n\t\t\"--no-emit-git-ignore\",\n\t\t\"Do not emit a .gitignore in the output directory\"\n\t)\n\t.option(\n\t\t\"--emit-prettier-ignore\",\n\t\t`Emit a .prettierignore in the output directory (default: ${defaultCompilerOptions.emitPrettierIgnore})`\n\t)\n\t.option(\n\t\t\"--no-emit-prettier-ignore\",\n\t\t\"Do not emit a .prettierignore in the output directory\"\n\t)\n\t.option(\n\t\t\"--emit-readme\",\n\t\t`Emit a README.md in the output directory (helps LLMs understand the generated code) (default: ${defaultCompilerOptions.emitReadme})`\n\t)\n\t.option(\"--no-emit-readme\", \"Do not emit README.md in the output directory\")\n\t.option(\n\t\t\"--is-server <expression>\",\n\t\t[\n\t\t\t\"JavaScript expression for runtime `isServer` (enables server/client tree-shaking).\",\n\t\t\t\"Quote if the expression contains spaces, e.g. --is-server 'typeof window === \\\"undefined\\\"'.\",\n\t\t\t\"Vite SSR example: --is-server 'import.meta.env.SSR'\",\n\t\t].join(\" \")\n\t)\n\t.option(\n\t\t\"--clean-outdir\",\n\t\t\"Remove files in the output directory that are not generated by this compile\",\n\t\tdefaultCompilerOptions.cleanOutdir\n\t)\n\t.option(\n\t\t\"--no-clean-outdir\",\n\t\t\"Preserve files in the output directory that are not generated by this compile\"\n\t)\n\t.option(\n\t\t\"--experimental-static-locale <expression>\",\n\t\t[\n\t\t\t\"JavaScript expression for a compile-time locale constant (experimental).\",\n\t\t\t\"For a literal locale, include the JavaScript quotes, e.g. --experimental-static-locale '\\\"de\\\"'.\",\n\t\t].join(\" \")\n\t)\n\t.option(\n\t\t\"--disable-async-local-storage\",\n\t\t\"Use the synchronous request-locale fallback instead of AsyncLocalStorage\",\n\t\tdefaultCompilerOptions.disableAsyncLocalStorage\n\t)\n\t.option(\n\t\t\"--output-structure <structure>\",\n\t\t[\n\t\t\t`The output structure for compiled messages. Either \"message-modules\" or \"locale-modules\" (default: \"${defaultCompilerOptions.outputStructure}\").`,\n\t\t\t\"\",\n\t\t\t'\"message-modules\" gives each message its own module (better tree-shaking).',\n\t\t\t'\"locale-modules\" bundles messages per locale (fewer files, better for large projects in dev).',\n\t\t].join(\"\\n\"),\n\t\tparseOutputStructure\n\t)\n\t.option(\"--watch\", \"Watch project files and recompile on change\", false)\n\t.action(\n\t\tasync (options: {\n\t\t\tsilent: boolean;\n\t\t\tproject?: string;\n\t\t\toutdir?: string;\n\t\t\tstrategy?: string[];\n\t\t\temitTsDeclarations?: boolean;\n\t\t\temitGitIgnore?: boolean;\n\t\t\temitPrettierIgnore?: boolean;\n\t\t\temitReadme?: boolean;\n\t\t\tisServer?: string;\n\t\t\tcleanOutdir?: CompilerOptions[\"cleanOutdir\"];\n\t\t\texperimentalStaticLocale?: CompilerOptions[\"experimentalStaticLocale\"];\n\t\t\tdisableAsyncLocalStorage?: CompilerOptions[\"disableAsyncLocalStorage\"];\n\t\t\toutputStructure?: OutputStructure;\n\t\t\twatch?: boolean;\n\t\t}) => {\n\t\t\tconst logger = new Logger({ silent: options.silent, prefix: true });\n\n\t\t\tconst projectDir = nodeNormalizePath(\n\t\t\t\tresolve(process.cwd(), options.project ?? DEFAULT_PROJECT_PATH)\n\t\t\t);\n\n\t\t\tconst loadConfig = () => loadParaglideConfig({ projectDir, logger });\n\n\t\t\tlet projectOverride = options.project;\n\t\t\tif (projectOverride === undefined) {\n\t\t\t\tprojectOverride = DEFAULT_PROJECT_PATH;\n\t\t\t\tlogger.info(\n\t\t\t\t\t`--project was not provided, using \"${DEFAULT_PROJECT_PATH}\".`\n\t\t\t\t);\n\t\t\t}\n\n\n\t\t\tconst buildCompileOptions = () => {\n\t\t\t\tlet validatedStrategy: ParaglideConfig[\"strategy\"] | undefined;\n\t\t\t\tif (options.strategy !== undefined) {\n\t\t\t\t\tconst parsed = v.safeParse(\n\t\t\t\t\t\tv.array(strategyNameSchema),\n\t\t\t\t\t\toptions.strategy\n\t\t\t\t\t);\n\t\t\t\t\tif (!parsed.success) {\n\t\t\t\t\t\tconst details = parsed.issues\n\t\t\t\t\t\t\t.map((i) => `\"${v.getDotPath(i) ?? \"(root)\"}\": ${i.message}`)\n\t\t\t\t\t\t\t.join(\", \");\n\t\t\t\t\t\tthrow new Error(`Invalid --strategy: ${details}`);\n\t\t\t\t\t}\n\t\t\t\t\tvalidatedStrategy = parsed.output;\n\t\t\t\t}\n\t\t\t\tlet outdirOverride: string | undefined = options.outdir;\n\t\t\t\tif (\n\t\t\t\t\toutdirOverride === undefined &&\n\t\t\t\t\tloadedConfig?.config.outdir === undefined\n\t\t\t\t) {\n\t\t\t\t\toutdirOverride = DEFAULT_OUTDIR;\n\t\t\t\t}\n\t\t\t\treturn resolveCompilerOptions({\n\t\t\t\t\tconfig: loadedConfig?.config,\n\t\t\t\t\toverrides: {\n\t\t\t\t\t\tproject: projectOverride,\n\t\t\t\t\t\toutdir: outdirOverride,\n\t\t\t\t\t\tstrategy: validatedStrategy,\n\t\t\t\t\t\temitTsDeclarations: options.emitTsDeclarations,\n\t\t\t\t\t\temitGitIgnore: options.emitGitIgnore,\n\t\t\t\t\t\temitPrettierIgnore: options.emitPrettierIgnore,\n\t\t\t\t\t\temitReadme: options.emitReadme,\n\t\t\t\t\t\tisServer: options.isServer,\n\t\t\t\t\t\tcleanOutdir: options.cleanOutdir,\n\t\t\t\t\t\texperimentalStaticLocale: options.experimentalStaticLocale,\n\t\t\t\t\t\tdisableAsyncLocalStorage: options.disableAsyncLocalStorage,\n\t\t\t\t\t\t// The CLI always uses message-modules unless told otherwise\n\t\t\t\t\t\t// (plugins apply their own development default).\n\t\t\t\t\t\toutputStructure:\n\t\t\t\t\t\t\toptions.outputStructure ?? defaultCompilerOptions.outputStructure,\n\t\t\t\t\t},\n\t\t\t\t\troot: process.cwd(),\n\t\t\t\t});\n\t\t\t};\n\n\t\t\tlet loadedConfig: LoadedParaglideConfig | undefined;\n\t\t\tlet compileOptions: CompilerOptions;\n\n\t\t\ttry {\n\t\t\t\tloadedConfig = await loadConfig();\n\t\t\t\tcompileOptions = buildCompileOptions();\n\t\t\t} catch (error) {\n\t\t\t\tlogger.error(errorMessage(error));\n\t\t\t\tprocess.exit(1);\n\t\t\t}\n\n\t\t\tif (!options.watch) {\n\t\t\t\tlogger.info(`Compiling inlang project ...`);\n\n\t\t\t\ttry {\n\t\t\t\t\tconst previousCompilation = compileOptions.cleanOutdir\n\t\t\t\t\t\t? await seedPreviousCompilationFromOutdir({\n\t\t\t\t\t\t\t\toutdir: compileOptions.outdir,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t\t: undefined;\n\n\t\t\t\t\tawait compile({\n\t\t\t\t\t\t...compileOptions,\n\t\t\t\t\t\tpreviousCompilation,\n\t\t\t\t\t\tcleanOutdir: false,\n\t\t\t\t\t});\n\t\t\t\t} catch (e) {\n\t\t\t\t\tlogger.error(\"Error while compiling inlang project.\");\n\t\t\t\t\tlogger.error(e);\n\t\t\t\t\tprocess.exit(1);\n\t\t\t\t}\n\n\t\t\t\tlogger.success(`Successfully compiled inlang project.`);\n\n\t\t\t\tprocess.exit(0);\n\t\t\t}\n\n\t\t\tconst { fs: trackedFs, readFiles, clearReadFiles } = createTrackedFs();\n\t\t\tconst fileWatchers = new Map<string, fs.FSWatcher>();\n\t\t\tconst directoryWatchers = new Map<string, fs.FSWatcher>();\n\t\t\tlet previousCompilation: CompilationResult | undefined;\n\t\t\tlet compileTimer: NodeJS.Timeout | undefined;\n\t\t\tlet compileInProgress = false;\n\t\t\tlet compileRequested = false;\n\t\t\t// Set by the project-directory watcher when a config-named file\n\t\t\t// changes — survives debounced coalescing with unrelated events.\n\t\t\tlet configChangedSinceLastBuild = false;\n\n\t\t\t/**\n\t\t\t * Reacts to a config-named event in the project directory:\n\t\t\t * rescans the candidate winner and reloads. A missing config\n\t\t\t * falls back to the built-in defaults; an invalid one fails the\n\t\t\t * reload (caller skips the compilation).\n\t\t\t */\n\t\t\tconst refreshConfig = async (): Promise<boolean> => {\n\t\t\t\tconst winner = await resolveConfigCandidate(projectDir);\n\t\t\t\tif (winner === undefined) {\n\t\t\t\t\tif (loadedConfig !== undefined) {\n\t\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t\t\"Paraglide config file was removed, compiling with default options.\"\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tloadedConfig = undefined;\n\t\t\t\t\tcompileOptions = buildCompileOptions();\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t\ttry {\n\t\t\t\t\tclearParaglideConfigCache({ projectDir });\n\t\t\t\t\tconst nextLoadedConfig = await loadConfig();\n\t\t\t\t\tif (nextLoadedConfig === undefined) return true; // raced deletion\n\t\t\t\t\tloadedConfig = nextLoadedConfig;\n\t\t\t\t\tcompileOptions = buildCompileOptions();\n\t\t\t\t\treturn true;\n\t\t\t\t} catch (error) {\n\t\t\t\t\tlogger.error(errorMessage(error));\n\t\t\t\t\tlogger.error(\n\t\t\t\t\t\t\"Skipping compilation because of the invalid paraglide config.\"\n\t\t\t\t\t);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst updateWatchers = (files: Set<string>) => {\n\t\t\t\tconst {\n\t\t\t\t\tfiles: nextFiles,\n\t\t\t\t\tdirectories: nextDirectories,\n\t\t\t\t\tisIgnoredPath,\n\t\t\t\t} = getWatchTargets(files, { outdir: compileOptions.outdir });\n\n\t\t\t\tfor (const [filePath, watcher] of fileWatchers) {\n\t\t\t\t\tif (!nextFiles.has(filePath)) {\n\t\t\t\t\t\twatcher.close();\n\t\t\t\t\t\tfileWatchers.delete(filePath);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// The project directory is always watched: it hosts the config\n\t\t\t\t// file, and its other contents (settings.json, messages/) are\n\t\t\t\t// compile inputs anyway.\n\t\t\t\tnextDirectories.add(projectDir);\n\n\t\t\t\tfor (const [directoryPath, watcher] of directoryWatchers) {\n\t\t\t\t\tif (!nextDirectories.has(directoryPath)) {\n\t\t\t\t\t\twatcher.close();\n\t\t\t\t\t\tdirectoryWatchers.delete(directoryPath);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst attachWatcherErrorHandler = (\n\t\t\t\t\twatcher: fs.FSWatcher,\n\t\t\t\t\ttargetPath: string,\n\t\t\t\t\ttargetType: \"file\" | \"directory\"\n\t\t\t\t) => {\n\t\t\t\t\twatcher.on(\"error\", (error) => {\n\t\t\t\t\t\tlogger.warn(\n\t\t\t\t\t\t\t`Watch ${targetType} error for ${targetPath}: ${errorMessage(error)}`\n\t\t\t\t\t\t);\n\t\t\t\t\t});\n\t\t\t\t};\n\n\t\t\t\tfor (const filePath of nextFiles) {\n\t\t\t\t\tif (fileWatchers.has(filePath)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst watcher = fs.watch(filePath, () => {\n\t\t\t\t\t\t\tscheduleCompile(filePath);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tattachWatcherErrorHandler(watcher, filePath, \"file\");\n\t\t\t\t\t\tfileWatchers.set(filePath, watcher);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tlogger.warn(`Failed to watch file: ${filePath}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tfor (const directoryPath of nextDirectories) {\n\t\t\t\t\tif (directoryWatchers.has(directoryPath)) {\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\n\t\t\t\t\ttry {\n\t\t\t\t\t\tconst watcher = fs.watch(directoryPath, (eventType, filename) => {\n\t\t\t\t\t\t\tconst isProjectDir = directoryPath === projectDir;\n\n\t\t\t\t\t\t\tif (!filename) {\n\t\t\t\t\t\t\t\tif (isProjectDir) {\n\t\t\t\t\t\t\t\t\tconfigChangedSinceLastBuild = true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tscheduleCompile(directoryPath);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tconst changedPath = resolve(directoryPath, filename.toString());\n\t\t\t\t\t\t\tif (isIgnoredPath(changedPath)) {\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t// Config-named events must not be lost to debounce\n\t\t\t\t\t\t\t// coalescing with unrelated files. Ordinary files are\n\t\t\t\t\t\t\t// still scheduled: new inputs can appear directly in\n\t\t\t\t\t\t\t// the project directory (e.g. a locale file matching\n\t\t\t\t\t\t\t// ./messages/{locale}.json patterns rooted there).\n\t\t\t\t\t\t\tif (isProjectDir && isConfigFileName(changedPath)) {\n\t\t\t\t\t\t\t\tconfigChangedSinceLastBuild = true;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tscheduleCompile(changedPath);\n\t\t\t\t\t\t});\n\t\t\t\t\t\tattachWatcherErrorHandler(watcher, directoryPath, \"directory\");\n\t\t\t\t\t\tdirectoryWatchers.set(directoryPath, watcher);\n\t\t\t\t\t} catch {\n\t\t\t\t\t\tlogger.warn(`Failed to watch directory: ${directoryPath}`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst runCompile = async (changedPath?: string) => {\n\t\t\t\tif (compileInProgress) {\n\t\t\t\t\tcompileRequested = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tcompileInProgress = true;\n\t\t\t\tconst previouslyReadFiles = new Set(readFiles);\n\t\t\t\tclearReadFiles();\n\n\t\t\t\tif (configChangedSinceLastBuild) {\n\t\t\t\t\tconfigChangedSinceLastBuild = false;\n\t\t\t\t\tconst succeeded = await refreshConfig();\n\t\t\t\t\tif (!succeeded) {\n\t\t\t\t\t\t// Invalid config: skip this compilation entirely — the\n\t\t\t\t\t\t// previously compiled output stays on disk untouched.\n\t\t\t\t\t\tcompileInProgress = false;\n\t\t\t\t\t\tupdateWatchers(new Set(readFiles));\n\t\t\t\t\t\tif (compileRequested) {\n\t\t\t\t\t\t\tcompileRequested = false;\n\t\t\t\t\t\t\trunCompile();\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif (changedPath) {\n\t\t\t\t\tlogger.info(\n\t\t\t\t\t\t`Re-compiling inlang project... File \"${relative(process.cwd(), changedPath)}\" has changed.`\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\tlogger.info(\"Compiling inlang project ...\");\n\t\t\t\t}\n\n\t\t\t\ttry {\n\t\t\t\t\tconst seededPrevious =\n\t\t\t\t\t\tpreviousCompilation ??\n\t\t\t\t\t\t(compileOptions.cleanOutdir\n\t\t\t\t\t\t\t? await seedPreviousCompilationFromOutdir({\n\t\t\t\t\t\t\t\t\toutdir: compileOptions.outdir,\n\t\t\t\t\t\t\t\t})\n\t\t\t\t\t\t\t: undefined);\n\n\t\t\t\t\tpreviousCompilation = await compile({\n\t\t\t\t\t\t...compileOptions,\n\t\t\t\t\t\tfs: trackedFs,\n\t\t\t\t\t\tpreviousCompilation: seededPrevious,\n\t\t\t\t\t\tcleanOutdir: false,\n\t\t\t\t\t});\n\n\t\t\t\t\tif (changedPath) {\n\t\t\t\t\t\tlogger.success(\"Re-compilation complete.\");\n\t\t\t\t\t} else {\n\t\t\t\t\t\tlogger.success(\"Successfully compiled inlang project.\");\n\t\t\t\t\t}\n\t\t\t\t} catch (e) {\n\t\t\t\t\tif (previouslyReadFiles.size > 0) {\n\t\t\t\t\t\tclearReadFiles();\n\t\t\t\t\t\tfor (const filePath of previouslyReadFiles) {\n\t\t\t\t\t\t\treadFiles.add(filePath);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tpreviousCompilation = undefined;\n\t\t\t\t\tlogger.error(\"Error while compiling inlang project.\");\n\t\t\t\t\tlogger.error(e);\n\t\t\t\t} finally {\n\t\t\t\t\tupdateWatchers(new Set(readFiles));\n\t\t\t\t\tcompileInProgress = false;\n\t\t\t\t\tif (compileRequested) {\n\t\t\t\t\t\tcompileRequested = false;\n\t\t\t\t\t\trunCompile();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconst scheduleCompile = (changedPath?: string) => {\n\t\t\t\tif (compileTimer) {\n\t\t\t\t\tclearTimeout(compileTimer);\n\t\t\t\t}\n\t\t\t\tcompileTimer = setTimeout(() => {\n\t\t\t\t\trunCompile(changedPath);\n\t\t\t\t}, 100);\n\t\t\t};\n\n\t\t\tconst closeWatchers = () => {\n\t\t\t\tfor (const watcher of fileWatchers.values()) {\n\t\t\t\t\twatcher.close();\n\t\t\t\t}\n\t\t\t\tfor (const watcher of directoryWatchers.values()) {\n\t\t\t\t\twatcher.close();\n\t\t\t\t}\n\t\t\t\tfileWatchers.clear();\n\t\t\t\tdirectoryWatchers.clear();\n\t\t\t};\n\n\t\t\tprocess.on(\"SIGINT\", () => {\n\t\t\t\tcloseWatchers();\n\t\t\t\tprocess.exit(0);\n\t\t\t});\n\n\t\t\tawait runCompile();\n\t\t\tlogger.info(\"Watching for changes...\");\n\t\t}\n\t);\n"]}
@@ -1,8 +1,9 @@
1
- import { mkdtemp, rm } from "node:fs/promises";
1
+ import { mkdtemp, rm, writeFile, mkdir } from "node:fs/promises";
2
2
  import * as nodeFs from "node:fs/promises";
3
3
  import { tmpdir } from "node:os";
4
- import path from "node:path";
5
- import { afterEach, beforeEach, expect, test, vi } from "vitest";
4
+ import consola from "consola";
5
+ import path, { resolve } from "node:path";
6
+ import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
6
7
  let testDirectories = [];
7
8
  let initialSigintListeners = [];
8
9
  beforeEach(() => {
@@ -21,10 +22,23 @@ afterEach(async () => {
21
22
  await rm(directory, { recursive: true, force: true });
22
23
  }
23
24
  });
25
+ /**
26
+ * Creates `<dir>/project.inlang/paraglide.config.ts` with the given
27
+ * outdir — the layout of the new config-in-project model.
28
+ */
29
+ async function writeConfig(projectDir, outdir, fileName = "paraglide.config.ts") {
30
+ await mkdir(projectDir, { recursive: true });
31
+ await writeFile(path.join(projectDir, fileName), ["export default {", ` outdir: ${JSON.stringify(outdir)},`, "}"].join("\n"));
32
+ }
33
+ async function createWorkspace() {
34
+ const workspace = await mkdtemp(path.join(tmpdir(), "paraglide-cli-"));
35
+ testDirectories.push(workspace);
36
+ const projectDir = path.join(workspace, "project.inlang");
37
+ return { workspace, projectDir };
38
+ }
24
39
  test("compile seeds existing outdir and disables cleaning (#743)", async () => {
25
- const testDirectory = await mkdtemp(path.join(tmpdir(), "paraglide-cli-"));
26
- testDirectories.push(testDirectory);
27
- const outdir = path.join(testDirectory, "output");
40
+ const { workspace } = await createWorkspace();
41
+ const outdir = path.join(workspace, "output");
28
42
  const { writeOutput } = await import("../../../services/file-handling/write-output.js");
29
43
  await writeOutput({
30
44
  directory: outdir,
@@ -48,7 +62,7 @@ test("compile seeds existing outdir and disables cleaning (#743)", async () => {
48
62
  const { compileCommand } = await import("./command.js");
49
63
  await expect(compileCommand.parseAsync([
50
64
  "--project",
51
- path.join(testDirectory, "project.inlang"),
65
+ path.join(workspace, "project.inlang"),
52
66
  "--outdir",
53
67
  outdir,
54
68
  "--silent",
@@ -65,6 +79,45 @@ test("compile seeds existing outdir and disables cleaning (#743)", async () => {
65
79
  }));
66
80
  expect(exitMock).toHaveBeenCalledWith(0);
67
81
  });
82
+ test("compile exposes and forwards compiler options missing from the CLI (#757)", async () => {
83
+ const testDirectory = await mkdtemp(path.join(tmpdir(), "paraglide-cli-"));
84
+ testDirectories.push(testDirectory);
85
+ const outdir = path.join(testDirectory, "output");
86
+ await nodeFs.mkdir(outdir, { recursive: true });
87
+ await nodeFs.writeFile(path.join(outdir, "custom.txt"), "keep me");
88
+ const compileMock = vi.fn().mockResolvedValue({ outputHashes: {} });
89
+ vi.doMock("../../../compiler/compile.js", () => ({
90
+ compile: compileMock,
91
+ }));
92
+ const exitError = new Error("process.exit");
93
+ vi.spyOn(process, "exit").mockImplementation(() => {
94
+ throw exitError;
95
+ });
96
+ const { compileCommand } = await import("./command.js");
97
+ const help = compileCommand.helpInformation();
98
+ expect(help).toContain("--clean-outdir");
99
+ expect(help).toContain("--no-clean-outdir");
100
+ expect(help).toContain("--experimental-static-locale <expression>");
101
+ expect(help).toContain("--disable-async-local-storage");
102
+ await expect(compileCommand.parseAsync([
103
+ "--project",
104
+ path.join(testDirectory, "project.inlang"),
105
+ "--outdir",
106
+ outdir,
107
+ "--no-clean-outdir",
108
+ "--experimental-static-locale",
109
+ 'import.meta.env.PARAGLIDE_LOCALE ?? "en"',
110
+ "--disable-async-local-storage",
111
+ "--silent",
112
+ ], { from: "user" })).rejects.toBe(exitError);
113
+ expect(compileMock).toHaveBeenCalledTimes(1);
114
+ expect(compileMock).toHaveBeenCalledWith(expect.objectContaining({
115
+ cleanOutdir: false,
116
+ disableAsyncLocalStorage: true,
117
+ experimentalStaticLocale: 'import.meta.env.PARAGLIDE_LOCALE ?? "en"',
118
+ previousCompilation: undefined,
119
+ }));
120
+ });
68
121
  test("compile --watch seeds existing outdir and disables cleaning on first compile (#688)", async () => {
69
122
  const testDirectory = await mkdtemp(path.join(tmpdir(), "paraglide-cli-"));
70
123
  testDirectories.push(testDirectory);
@@ -105,4 +158,255 @@ test("compile --watch seeds existing outdir and disables cleaning on first compi
105
158
  },
106
159
  }));
107
160
  });
161
+ describe("config file integration", () => {
162
+ test("compile reads options from a config file inside --project", async () => {
163
+ const { workspace, projectDir } = await createWorkspace();
164
+ const outdir = path.join(workspace, "from-config");
165
+ await writeConfig(projectDir, outdir);
166
+ const compileMock = vi.fn().mockResolvedValue({});
167
+ vi.doMock("../../../compiler/compile.js", () => ({
168
+ compile: compileMock,
169
+ }));
170
+ const exitError = new Error("process.exit");
171
+ vi.spyOn(process, "exit").mockImplementation(() => {
172
+ throw exitError;
173
+ });
174
+ const { compileCommand } = await import("./command.js");
175
+ await expect(compileCommand.parseAsync(["--project", projectDir, "--silent"], {
176
+ from: "user",
177
+ })).rejects.toBe(exitError);
178
+ expect(compileMock).toHaveBeenCalledWith(expect.objectContaining({
179
+ project: projectDir,
180
+ outdir,
181
+ strategy: ["cookie", "globalVariable", "baseLocale"],
182
+ emitReadme: true,
183
+ }));
184
+ });
185
+ test("discovers the conventional ./project.inlang without flags", async () => {
186
+ const { workspace, projectDir } = await createWorkspace();
187
+ const outdir = path.join(workspace, "from-config");
188
+ await writeConfig(projectDir, outdir);
189
+ const compileMock = vi.fn().mockResolvedValue({});
190
+ vi.doMock("../../../compiler/compile.js", () => ({
191
+ compile: compileMock,
192
+ }));
193
+ const exitError = new Error("process.exit");
194
+ vi.spyOn(process, "exit").mockImplementation(() => {
195
+ throw exitError;
196
+ });
197
+ const cwdMock = vi.spyOn(process, "cwd").mockReturnValue(workspace);
198
+ try {
199
+ const { compileCommand } = await import("./command.js");
200
+ await expect(compileCommand.parseAsync(["--silent"], { from: "user" })).rejects.toBe(exitError);
201
+ expect(compileMock).toHaveBeenCalledWith(expect.objectContaining({
202
+ project: projectDir,
203
+ outdir,
204
+ }));
205
+ }
206
+ finally {
207
+ cwdMock.mockRestore();
208
+ }
209
+ });
210
+ test("announces the conventional project default when --project is omitted", async () => {
211
+ const { workspace, projectDir } = await createWorkspace();
212
+ const outdir = path.join(workspace, "from-config");
213
+ await writeConfig(projectDir, outdir);
214
+ const compileMock = vi.fn().mockResolvedValue({});
215
+ vi.doMock("../../../compiler/compile.js", () => ({
216
+ compile: compileMock,
217
+ }));
218
+ const exitError = new Error("process.exit");
219
+ vi.spyOn(process, "exit").mockImplementation(() => {
220
+ throw exitError;
221
+ });
222
+ const infoSpy = vi.spyOn(consola, "info").mockImplementation(() => { });
223
+ const { compileCommand } = await import("./command.js");
224
+ const cwdMock = vi.spyOn(process, "cwd").mockReturnValue(workspace);
225
+ try {
226
+ await expect(compileCommand.parseAsync(["--outdir", outdir], // no --project, no --silent
227
+ { from: "user" })).rejects.toBe(exitError);
228
+ expect(compileMock).toHaveBeenCalledWith(expect.objectContaining({
229
+ project: projectDir,
230
+ outdir,
231
+ }));
232
+ expect(infoSpy.mock.calls.some((call) => String(call[0]).includes("--project was not provided"))).toBe(true);
233
+ }
234
+ finally {
235
+ cwdMock.mockRestore();
236
+ }
237
+ });
238
+ test("command line flags override config file values", async () => {
239
+ const { workspace, projectDir } = await createWorkspace();
240
+ await writeConfig(projectDir, path.join(workspace, "from-config"));
241
+ const compileMock = vi.fn().mockResolvedValue({});
242
+ vi.doMock("../../../compiler/compile.js", () => ({
243
+ compile: compileMock,
244
+ }));
245
+ const exitError = new Error("process.exit");
246
+ vi.spyOn(process, "exit").mockImplementation(() => {
247
+ throw exitError;
248
+ });
249
+ const { compileCommand } = await import("./command.js");
250
+ await expect(compileCommand.parseAsync([
251
+ "--project",
252
+ projectDir,
253
+ "--outdir",
254
+ "./from-flag",
255
+ "--strategy",
256
+ "cookie",
257
+ "baseLocale",
258
+ "--silent",
259
+ ], { from: "user" })).rejects.toBe(exitError);
260
+ expect(compileMock).toHaveBeenCalledWith(expect.objectContaining({
261
+ project: projectDir,
262
+ outdir: resolve(process.cwd(), "./from-flag"),
263
+ strategy: ["cookie", "baseLocale"],
264
+ }));
265
+ });
266
+ // Deleting the config file mid-watch falls back to the built-in
267
+ // defaults (same as never having a config); recreating it is picked up.
268
+ test("watch falls back to defaults when the config is deleted", async () => {
269
+ const { workspace, projectDir } = await createWorkspace();
270
+ const configPath = path.join(projectDir, "paraglide.config.ts");
271
+ const outdir = path.join(workspace, "from-config");
272
+ await writeConfig(projectDir, outdir);
273
+ const compileMock = vi.fn().mockResolvedValue({});
274
+ vi.doMock("../../../compiler/compile.js", () => ({
275
+ compile: compileMock,
276
+ }));
277
+ const { compileCommand } = await import("./command.js");
278
+ await compileCommand.parseAsync(["--project", projectDir, "--watch", "--silent"], { from: "user" });
279
+ expect(compileMock).toHaveBeenCalledTimes(1);
280
+ expect(compileMock.mock.calls[0][0].outdir).toBe(outdir);
281
+ await rm(configPath);
282
+ const deadline = Date.now() + 10_000;
283
+ while (compileMock.mock.calls.length < 2 && Date.now() < deadline) {
284
+ await new Promise((r) => setTimeout(r, 50));
285
+ }
286
+ expect(compileMock.mock.calls.length).toBeGreaterThanOrEqual(2);
287
+ for (const call of compileMock.mock.calls.slice(1)) {
288
+ // Default outdir, resolved against the working directory.
289
+ expect(String(call[0].outdir).endsWith(path.join("src", "paraglide"))).toBe(true);
290
+ expect(call[0].project).toBe(projectDir);
291
+ }
292
+ // Recreating the config with a different outdir is picked up again.
293
+ await writeConfig(projectDir, path.join(workspace, "recreated"));
294
+ const recreateDeadline = Date.now() + 10_000;
295
+ while (Date.now() < recreateDeadline &&
296
+ !compileMock.mock.calls.some((c) => String(c[0].outdir).endsWith("recreated"))) {
297
+ await new Promise((r) => setTimeout(r, 50));
298
+ }
299
+ expect(compileMock.mock.calls.some((c) => String(c[0].outdir).endsWith("recreated"))).toBe(true);
300
+ });
301
+ // Renaming the config between formats switches to the new winner.
302
+ // A NEW non-config file appearing directly in the project directory (e.g.
303
+ // a locale JSON for a freshly added locale) must schedule a rebuild even
304
+ // though no per-file watcher exists for it yet.
305
+ test("watch recompiles when a new input appears in the project directory", async () => {
306
+ const { workspace, projectDir } = await createWorkspace();
307
+ await writeConfig(projectDir, path.join(workspace, "from-config"));
308
+ const compileMock = vi.fn().mockResolvedValue({});
309
+ vi.doMock("../../../compiler/compile.js", () => ({
310
+ compile: compileMock,
311
+ }));
312
+ const { compileCommand } = await import("./command.js");
313
+ await compileCommand.parseAsync(["--project", projectDir, "--watch", "--silent"], { from: "user" });
314
+ expect(compileMock).toHaveBeenCalledTimes(1);
315
+ await writeFile(path.join(projectDir, "es.json"), "{}");
316
+ const deadline = Date.now() + 10_000;
317
+ while (compileMock.mock.calls.length < 2 && Date.now() < deadline) {
318
+ await new Promise((r) => setTimeout(r, 50));
319
+ }
320
+ expect(compileMock.mock.calls.length).toBeGreaterThanOrEqual(2);
321
+ });
322
+ test("watch follows config renames between formats", async () => {
323
+ const { workspace, projectDir } = await createWorkspace();
324
+ const tsPath = path.join(projectDir, "paraglide.config.ts");
325
+ const jsPath = path.join(projectDir, "paraglide.config.js");
326
+ const outdirA = path.join(workspace, "out-ts");
327
+ const outdirB = path.join(workspace, "out-js");
328
+ await writeConfig(projectDir, outdirA);
329
+ const compileMock = vi.fn().mockResolvedValue({});
330
+ vi.doMock("../../../compiler/compile.js", () => ({
331
+ compile: compileMock,
332
+ }));
333
+ const { compileCommand } = await import("./command.js");
334
+ await compileCommand.parseAsync(["--project", projectDir, "--watch", "--silent"], { from: "user" });
335
+ expect(compileMock.mock.calls[0][0].outdir).toBe(outdirA);
336
+ // Format switch: delete .ts, add .js.
337
+ await rm(tsPath);
338
+ await writeFile(jsPath, ["export default {", ` outdir: ${JSON.stringify(outdirB)},`, "}"].join("\n"));
339
+ const deadline = Date.now() + 10_000;
340
+ while (Date.now() < deadline &&
341
+ !compileMock.mock.calls.some((c) => c[0].outdir === outdirB)) {
342
+ await new Promise((r) => setTimeout(r, 50));
343
+ }
344
+ expect(compileMock.mock.calls.some((c) => c[0].outdir === outdirB)).toBe(true);
345
+ });
346
+ // Non-config changes inside the project directory DO rebuild (new
347
+ // inputs can appear there) but must NOT reload the config.
348
+ test("watch recompiles without reloading config for non-config changes", async () => {
349
+ const { workspace, projectDir } = await createWorkspace();
350
+ await writeConfig(projectDir, path.join(workspace, "from-config"));
351
+ let loadCount = 0;
352
+ vi.doMock("../../../compiler/compile.js", () => ({
353
+ compile: vi.fn().mockResolvedValue({}),
354
+ }));
355
+ vi.doMock("../../../services/config/index.js", async (importActual) => {
356
+ const actual = await importActual();
357
+ return {
358
+ ...actual,
359
+ loadParaglideConfig: (...args) => {
360
+ loadCount++;
361
+ return actual.loadParaglideConfig(...args);
362
+ },
363
+ };
364
+ });
365
+ try {
366
+ const { compileCommand } = await import("./command.js");
367
+ const compileModule = (await import("../../../compiler/compile.js"));
368
+ await compileCommand.parseAsync(["--project", projectDir, "--watch", "--silent"], { from: "user" });
369
+ expect(compileModule.compile).toHaveBeenCalledTimes(1);
370
+ expect(loadCount).toBe(1);
371
+ await writeFile(path.join(projectDir, "README.md"), "hello");
372
+ await new Promise((r) => setTimeout(r, 1_000));
373
+ await writeFile(path.join(projectDir, "notes.txt"), "world");
374
+ await new Promise((r) => setTimeout(r, 1_500));
375
+ expect(compileModule.compile.mock.calls.length).toBeGreaterThanOrEqual(3);
376
+ expect(loadCount).toBe(1);
377
+ }
378
+ finally {
379
+ vi.doUnmock("../../../services/config/index.js");
380
+ }
381
+ });
382
+ });
383
+ test("compile --watch forwards the newly exposed compiler options (#757)", async () => {
384
+ const testDirectory = await mkdtemp(path.join(tmpdir(), "paraglide-cli-"));
385
+ testDirectories.push(testDirectory);
386
+ const outdir = path.join(testDirectory, "output");
387
+ const compileMock = vi.fn().mockResolvedValue({ outputHashes: {} });
388
+ vi.doMock("../../../compiler/compile.js", () => ({
389
+ compile: compileMock,
390
+ }));
391
+ const { compileCommand } = await import("./command.js");
392
+ await compileCommand.parseAsync([
393
+ "--project",
394
+ path.join(testDirectory, "project.inlang"),
395
+ "--outdir",
396
+ outdir,
397
+ "--watch",
398
+ "--no-clean-outdir",
399
+ "--experimental-static-locale",
400
+ '"de"',
401
+ "--disable-async-local-storage",
402
+ "--silent",
403
+ ], { from: "user" });
404
+ expect(compileMock).toHaveBeenCalledTimes(1);
405
+ expect(compileMock).toHaveBeenCalledWith(expect.objectContaining({
406
+ cleanOutdir: false,
407
+ disableAsyncLocalStorage: true,
408
+ experimentalStaticLocale: '"de"',
409
+ previousCompilation: undefined,
410
+ }));
411
+ });
108
412
  //# sourceMappingURL=command.test.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"command.test.js","sourceRoot":"","sources":["../../../../src/cli/commands/compile/command.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAEjE,IAAI,eAAe,GAAa,EAAE,CAAC;AACnC,IAAI,sBAAsB,GAA6B,EAAE,CAAC;AAE1D,UAAU,CAAC,GAAG,EAAE;IACf,EAAE,CAAC,YAAY,EAAE,CAAC;IAClB,eAAe,GAAG,EAAE,CAAC;IACrB,sBAAsB,GAAG,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;AACtD,CAAC,CAAC,CAAC;AAEH,SAAS,CAAC,KAAK,IAAI,EAAE;IACpB,EAAE,CAAC,eAAe,EAAE,CAAC;IACrB,KAAK,MAAM,QAAQ,IAAI,OAAO,CAAC,SAAS,CAAC,QAAQ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B,MAAM,EAAE;YACP,YAAY,EAAE,8BAA8B;SAC5C;QACD,EAAE,EAAE,MAAM;KACV,CAAC,CAAC;IAEH,MAAM,WAAW,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC;QAC7C,YAAY,EAAE;YACb,YAAY,EAAE,WAAW;SACzB;KACD,CAAC,CAAC;IACH,EAAE,CAAC,MAAM,CAAC,8BAA8B,EAAE,GAAG,EAAE,CAAC,CAAC;QAChD,OAAO,EAAE,WAAW;KACpB,CAAC,CAAC,CAAC;IAEJ,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC;IAExD,MAAM,cAAc,CAAC,UAAU,CAC9B;QACC,WAAW;QACX,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,gBAAgB,CAAC;QAC1C,UAAU;QACV,MAAM;QACN,SAAS;QACT,UAAU;KACV,EACD,EAAE,IAAI,EAAE,MAAM,EAAE,CAChB,CAAC;IAEF,MAAM,CAAC,WAAW,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAC7C,MAAM,CAAC,WAAW,CAAC,CAAC,oBAAoB,CACvC,MAAM,CAAC,gBAAgB,CAAC;QACvB,MAAM;QACN,WAAW,EAAE,KAAK;QAClB,mBAAmB,EAAE;YACpB,YAAY,EAAE;gBACb,YAAY,EAAE,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC;aAChC;SACD;KACD,CAAC,CACF,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { mkdtemp, rm } from \"node:fs/promises\";\nimport * as nodeFs from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport path from \"node:path\";\nimport { afterEach, beforeEach, expect, test, vi } from \"vitest\";\n\nlet testDirectories: string[] = [];\nlet initialSigintListeners: NodeJS.SignalsListener[] = [];\n\nbeforeEach(() => {\n\tvi.resetModules();\n\ttestDirectories = [];\n\tinitialSigintListeners = process.listeners(\"SIGINT\");\n});\n\nafterEach(async () => {\n\tvi.restoreAllMocks();\n\tfor (const listener of process.listeners(\"SIGINT\")) {\n\t\tif (!initialSigintListeners.includes(listener)) {\n\t\t\tprocess.removeListener(\"SIGINT\", listener);\n\t\t}\n\t}\n\tfor (const directory of testDirectories) {\n\t\tawait rm(directory, { recursive: true, force: true });\n\t}\n});\n\ntest(\"compile seeds existing outdir and disables cleaning (#743)\", async () => {\n\tconst testDirectory = await mkdtemp(path.join(tmpdir(), \"paraglide-cli-\"));\n\ttestDirectories.push(testDirectory);\n\tconst outdir = path.join(testDirectory, \"output\");\n\tconst { writeOutput } = await import(\n\t\t\"../../../services/file-handling/write-output.js\"\n\t);\n\tawait writeOutput({\n\t\tdirectory: outdir,\n\t\toutput: {\n\t\t\t\"runtime.js\": \"export const runtime = true;\",\n\t\t},\n\t\tfs: nodeFs,\n\t});\n\n\tconst compileMock = vi.fn().mockResolvedValue({\n\t\toutputHashes: {\n\t\t\t\"runtime.js\": \"next-hash\",\n\t\t},\n\t});\n\tvi.doMock(\"../../../compiler/compile.js\", () => ({\n\t\tcompile: compileMock,\n\t}));\n\tconst exitError = new Error(\"process.exit\");\n\tconst exitMock = vi.spyOn(process, \"exit\").mockImplementation(() => {\n\t\tthrow exitError;\n\t});\n\n\tconst { compileCommand } = await import(\"./command.js\");\n\n\tawait expect(\n\t\tcompileCommand.parseAsync(\n\t\t\t[\n\t\t\t\t\"--project\",\n\t\t\t\tpath.join(testDirectory, \"project.inlang\"),\n\t\t\t\t\"--outdir\",\n\t\t\t\toutdir,\n\t\t\t\t\"--silent\",\n\t\t\t],\n\t\t\t{ from: \"user\" }\n\t\t)\n\t).rejects.toBe(exitError);\n\n\texpect(compileMock).toHaveBeenCalledTimes(1);\n\texpect(compileMock).toHaveBeenCalledWith(\n\t\texpect.objectContaining({\n\t\t\toutdir,\n\t\t\tcleanOutdir: false,\n\t\t\tpreviousCompilation: {\n\t\t\t\toutputHashes: {\n\t\t\t\t\t\"runtime.js\": expect.any(String),\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t);\n\texpect(exitMock).toHaveBeenCalledWith(0);\n});\n\ntest(\"compile --watch seeds existing outdir and disables cleaning on first compile (#688)\", async () => {\n\tconst testDirectory = await mkdtemp(path.join(tmpdir(), \"paraglide-cli-\"));\n\ttestDirectories.push(testDirectory);\n\tconst outdir = path.join(testDirectory, \"output\");\n\tconst { writeOutput } = await import(\n\t\t\"../../../services/file-handling/write-output.js\"\n\t);\n\tawait writeOutput({\n\t\tdirectory: outdir,\n\t\toutput: {\n\t\t\t\"runtime.js\": \"export const runtime = true;\",\n\t\t},\n\t\tfs: nodeFs,\n\t});\n\n\tconst compileMock = vi.fn().mockResolvedValue({\n\t\toutputHashes: {\n\t\t\t\"runtime.js\": \"next-hash\",\n\t\t},\n\t});\n\tvi.doMock(\"../../../compiler/compile.js\", () => ({\n\t\tcompile: compileMock,\n\t}));\n\n\tconst { compileCommand } = await import(\"./command.js\");\n\n\tawait compileCommand.parseAsync(\n\t\t[\n\t\t\t\"--project\",\n\t\t\tpath.join(testDirectory, \"project.inlang\"),\n\t\t\t\"--outdir\",\n\t\t\toutdir,\n\t\t\t\"--watch\",\n\t\t\t\"--silent\",\n\t\t],\n\t\t{ from: \"user\" }\n\t);\n\n\texpect(compileMock).toHaveBeenCalledTimes(1);\n\texpect(compileMock).toHaveBeenCalledWith(\n\t\texpect.objectContaining({\n\t\t\toutdir,\n\t\t\tcleanOutdir: false,\n\t\t\tpreviousCompilation: {\n\t\t\t\toutputHashes: {\n\t\t\t\t\t\"runtime.js\": expect.any(String),\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t);\n});\n"]}
1
+ {"version":3,"file":"command.test.js","sourceRoot":"","sources":["../../../../src/cli/commands/compile/command.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACjE,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAC3C,O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E,EAAE,KAAK,IAAI,EAAE;IACrF,MAAM,aAAa,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAC3E,eAAe,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACpC,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;IAElD,MAAM,WAAW,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,iBAAiB,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CAAC;IACpE,EAAE,CAAC,MAAM,CAAC,8BAA8B,EAAE,GAAG,EAAE,CAAC,CAAC;QAChD,OAAO,EAAE,WAAW;KACpB,CAAC,CAAC,CAAC;IAEJ,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,CAAC;IAExD,MAAM,cAAc,CAAC,UAAU,CAC9B;QACC,WAAW;QACX,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,gBAAgB,CAAC;QAC1C,UAAU;QACV,MAAM;QACN,SAAS;QACT,mBAAmB;QACnB,8BAA8B;QAC9B,MAAM;QACN,+BAA+B;QAC/B,UAAU;KACV,EACD,EAAE,IAAI,EAAE,MAAM,EAAE,CAChB,CAAC;IAEF,MAAM,CAAC,WAAW,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;IAC7C,MAAM,CAAC,WAAW,CAAC,CAAC,oBAAoB,CACvC,MAAM,CAAC,gBAAgB,CAAC;QACvB,WAAW,EAAE,KAAK;QAClB,wBAAwB,EAAE,IAAI;QAC9B,wBAAwB,EAAE,MAAM;QAChC,mBAAmB,EAAE,SAAS;KAC9B,CAAC,CACF,CAAC;AACH,CAAC,CAAC,CAAC","sourcesContent":["import { mkdtemp, rm, writeFile, mkdir } from \"node:fs/promises\";\nimport * as nodeFs from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport consola from \"consola\";\nimport path, { resolve } from \"node:path\";\nimport { afterEach, beforeEach, describe, expect, test, vi } from \"vitest\";\n\nlet testDirectories: string[] = [];\nlet initialSigintListeners: NodeJS.SignalsListener[] = [];\n\nbeforeEach(() => {\n\tvi.resetModules();\n\ttestDirectories = [];\n\tinitialSigintListeners = process.listeners(\"SIGINT\");\n});\n\nafterEach(async () => {\n\tvi.restoreAllMocks();\n\tfor (const listener of process.listeners(\"SIGINT\")) {\n\t\tif (!initialSigintListeners.includes(listener)) {\n\t\t\tprocess.removeListener(\"SIGINT\", listener);\n\t\t}\n\t}\n\tfor (const directory of testDirectories) {\n\t\tawait rm(directory, { recursive: true, force: true });\n\t}\n});\n\n/**\n * Creates `<dir>/project.inlang/paraglide.config.ts` with the given\n * outdir — the layout of the new config-in-project model.\n */\nasync function writeConfig(\n\tprojectDir: string,\n\toutdir: string,\n\tfileName = \"paraglide.config.ts\"\n) {\n\tawait mkdir(projectDir, { recursive: true });\n\tawait writeFile(\n\t\tpath.join(projectDir, fileName),\n\t\t[\"export default {\", ` outdir: ${JSON.stringify(outdir)},`, \"}\"].join(\"\\n\")\n\t);\n}\n\nasync function createWorkspace() {\n\tconst workspace = await mkdtemp(path.join(tmpdir(), \"paraglide-cli-\"));\n\ttestDirectories.push(workspace);\n\tconst projectDir = path.join(workspace, \"project.inlang\");\n\treturn { workspace, projectDir };\n}\n\ntest(\"compile seeds existing outdir and disables cleaning (#743)\", async () => {\n\tconst { workspace } = await createWorkspace();\n\tconst outdir = path.join(workspace, \"output\");\n\tconst { writeOutput } =\n\t\tawait import(\"../../../services/file-handling/write-output.js\");\n\tawait writeOutput({\n\t\tdirectory: outdir,\n\t\toutput: {\n\t\t\t\"runtime.js\": \"export const runtime = true;\",\n\t\t},\n\t\tfs: nodeFs,\n\t});\n\n\tconst compileMock = vi.fn().mockResolvedValue({\n\t\toutputHashes: {\n\t\t\t\"runtime.js\": \"next-hash\",\n\t\t},\n\t});\n\tvi.doMock(\"../../../compiler/compile.js\", () => ({\n\t\tcompile: compileMock,\n\t}));\n\tconst exitError = new Error(\"process.exit\");\n\tconst exitMock = vi.spyOn(process, \"exit\").mockImplementation(() => {\n\t\tthrow exitError;\n\t});\n\n\tconst { compileCommand } = await import(\"./command.js\");\n\n\tawait expect(\n\t\tcompileCommand.parseAsync(\n\t\t\t[\n\t\t\t\t\"--project\",\n\t\t\t\tpath.join(workspace, \"project.inlang\"),\n\t\t\t\t\"--outdir\",\n\t\t\t\toutdir,\n\t\t\t\t\"--silent\",\n\t\t\t],\n\t\t\t{ from: \"user\" }\n\t\t)\n\t).rejects.toBe(exitError);\n\n\texpect(compileMock).toHaveBeenCalledTimes(1);\n\texpect(compileMock).toHaveBeenCalledWith(\n\t\texpect.objectContaining({\n\t\t\toutdir,\n\t\t\tcleanOutdir: false,\n\t\t\tpreviousCompilation: {\n\t\t\t\toutputHashes: {\n\t\t\t\t\t\"runtime.js\": expect.any(String),\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t);\n\texpect(exitMock).toHaveBeenCalledWith(0);\n});\n\ntest(\"compile exposes and forwards compiler options missing from the CLI (#757)\", async () => {\n\tconst testDirectory = await mkdtemp(path.join(tmpdir(), \"paraglide-cli-\"));\n\ttestDirectories.push(testDirectory);\n\tconst outdir = path.join(testDirectory, \"output\");\n\tawait nodeFs.mkdir(outdir, { recursive: true });\n\tawait nodeFs.writeFile(path.join(outdir, \"custom.txt\"), \"keep me\");\n\n\tconst compileMock = vi.fn().mockResolvedValue({ outputHashes: {} });\n\tvi.doMock(\"../../../compiler/compile.js\", () => ({\n\t\tcompile: compileMock,\n\t}));\n\tconst exitError = new Error(\"process.exit\");\n\tvi.spyOn(process, \"exit\").mockImplementation(() => {\n\t\tthrow exitError;\n\t});\n\n\tconst { compileCommand } = await import(\"./command.js\");\n\tconst help = compileCommand.helpInformation();\n\n\texpect(help).toContain(\"--clean-outdir\");\n\texpect(help).toContain(\"--no-clean-outdir\");\n\texpect(help).toContain(\"--experimental-static-locale <expression>\");\n\texpect(help).toContain(\"--disable-async-local-storage\");\n\n\tawait expect(\n\t\tcompileCommand.parseAsync(\n\t\t\t[\n\t\t\t\t\"--project\",\n\t\t\t\tpath.join(testDirectory, \"project.inlang\"),\n\t\t\t\t\"--outdir\",\n\t\t\t\toutdir,\n\t\t\t\t\"--no-clean-outdir\",\n\t\t\t\t\"--experimental-static-locale\",\n\t\t\t\t'import.meta.env.PARAGLIDE_LOCALE ?? \"en\"',\n\t\t\t\t\"--disable-async-local-storage\",\n\t\t\t\t\"--silent\",\n\t\t\t],\n\t\t\t{ from: \"user\" }\n\t\t)\n\t).rejects.toBe(exitError);\n\n\texpect(compileMock).toHaveBeenCalledTimes(1);\n\texpect(compileMock).toHaveBeenCalledWith(\n\t\texpect.objectContaining({\n\t\t\tcleanOutdir: false,\n\t\t\tdisableAsyncLocalStorage: true,\n\t\t\texperimentalStaticLocale: 'import.meta.env.PARAGLIDE_LOCALE ?? \"en\"',\n\t\t\tpreviousCompilation: undefined,\n\t\t})\n\t);\n});\n\ntest(\"compile --watch seeds existing outdir and disables cleaning on first compile (#688)\", async () => {\n\tconst testDirectory = await mkdtemp(path.join(tmpdir(), \"paraglide-cli-\"));\n\ttestDirectories.push(testDirectory);\n\tconst outdir = path.join(testDirectory, \"output\");\n\tconst { writeOutput } = await import(\n\t\t\"../../../services/file-handling/write-output.js\"\n\t);\n\tawait writeOutput({\n\t\tdirectory: outdir,\n\t\toutput: {\n\t\t\t\"runtime.js\": \"export const runtime = true;\",\n\t\t},\n\t\tfs: nodeFs,\n\t});\n\n\tconst compileMock = vi.fn().mockResolvedValue({\n\t\toutputHashes: {\n\t\t\t\"runtime.js\": \"next-hash\",\n\t\t},\n\t});\n\tvi.doMock(\"../../../compiler/compile.js\", () => ({\n\t\tcompile: compileMock,\n\t}));\n\n\tconst { compileCommand } = await import(\"./command.js\");\n\n\tawait compileCommand.parseAsync(\n\t\t[\n\t\t\t\"--project\",\n\t\t\tpath.join(testDirectory, \"project.inlang\"),\n\t\t\t\"--outdir\",\n\t\t\toutdir,\n\t\t\t\"--watch\",\n\t\t\t\"--silent\",\n\t\t],\n\t\t{ from: \"user\" }\n\t);\n\n\texpect(compileMock).toHaveBeenCalledTimes(1);\n\texpect(compileMock).toHaveBeenCalledWith(\n\t\texpect.objectContaining({\n\t\t\toutdir,\n\t\t\tcleanOutdir: false,\n\t\t\tpreviousCompilation: {\n\t\t\t\toutputHashes: {\n\t\t\t\t\t\"runtime.js\": expect.any(String),\n\t\t\t\t},\n\t\t\t},\n\t\t})\n\t);\n});\n\ndescribe(\"config file integration\", () => {\n\ttest(\"compile reads options from a config file inside --project\", async () => {\n\t\tconst { workspace, projectDir } = await createWorkspace();\n\t\tconst outdir = path.join(workspace, \"from-config\");\n\t\tawait writeConfig(projectDir, outdir);\n\n\t\tconst compileMock = vi.fn().mockResolvedValue({});\n\t\tvi.doMock(\"../../../compiler/compile.js\", () => ({\n\t\t\tcompile: compileMock,\n\t\t}));\n\t\tconst exitError = new Error(\"process.exit\");\n\t\tvi.spyOn(process, \"exit\").mockImplementation(() => {\n\t\t\tthrow exitError;\n\t\t});\n\n\t\tconst { compileCommand } = await import(\"./command.js\");\n\n\t\tawait expect(\n\t\t\tcompileCommand.parseAsync([\"--project\", projectDir, \"--silent\"], {\n\t\t\t\tfrom: \"user\",\n\t\t\t})\n\t\t).rejects.toBe(exitError);\n\n\t\texpect(compileMock).toHaveBeenCalledWith(\n\t\t\texpect.objectContaining({\n\t\t\t\tproject: projectDir,\n\t\t\t\toutdir,\n\t\t\t\tstrategy: [\"cookie\", \"globalVariable\", \"baseLocale\"],\n\t\t\t\temitReadme: true,\n\t\t\t})\n\t\t);\n\t});\n\n\ttest(\"discovers the conventional ./project.inlang without flags\", async () => {\n\t\tconst { workspace, projectDir } = await createWorkspace();\n\t\tconst outdir = path.join(workspace, \"from-config\");\n\t\tawait writeConfig(projectDir, outdir);\n\n\t\tconst compileMock = vi.fn().mockResolvedValue({});\n\t\tvi.doMock(\"../../../compiler/compile.js\", () => ({\n\t\t\tcompile: compileMock,\n\t\t}));\n\t\tconst exitError = new Error(\"process.exit\");\n\t\tvi.spyOn(process, \"exit\").mockImplementation(() => {\n\t\t\tthrow exitError;\n\t\t});\n\t\tconst cwdMock = vi.spyOn(process, \"cwd\").mockReturnValue(workspace);\n\n\t\ttry {\n\t\t\tconst { compileCommand } = await import(\"./command.js\");\n\n\t\t\tawait expect(\n\t\t\t\tcompileCommand.parseAsync([\"--silent\"], { from: \"user\" })\n\t\t\t).rejects.toBe(exitError);\n\n\t\t\texpect(compileMock).toHaveBeenCalledWith(\n\t\t\t\texpect.objectContaining({\n\t\t\t\t\tproject: projectDir,\n\t\t\t\t\toutdir,\n\t\t\t\t})\n\t\t\t);\n\t\t} finally {\n\t\t\tcwdMock.mockRestore();\n\t\t}\n\t});\n\n\ttest(\"announces the conventional project default when --project is omitted\", async () => {\n\t\tconst { workspace, projectDir } = await createWorkspace();\n\t\tconst outdir = path.join(workspace, \"from-config\");\n\t\tawait writeConfig(projectDir, outdir);\n\n\t\tconst compileMock = vi.fn().mockResolvedValue({});\n\t\tvi.doMock(\"../../../compiler/compile.js\", () => ({\n\t\t\tcompile: compileMock,\n\t\t}));\n\t\tconst exitError = new Error(\"process.exit\");\n\t\tvi.spyOn(process, \"exit\").mockImplementation(() => {\n\t\t\tthrow exitError;\n\t\t});\n\t\tconst infoSpy = vi.spyOn(consola, \"info\").mockImplementation(() => {});\n\n\t\tconst { compileCommand } = await import(\"./command.js\");\n\t\tconst cwdMock = vi.spyOn(process, \"cwd\").mockReturnValue(workspace);\n\n\t\ttry {\n\t\t\tawait expect(\n\t\t\t\tcompileCommand.parseAsync(\n\t\t\t\t\t[\"--outdir\", outdir], // no --project, no --silent\n\t\t\t\t\t{ from: \"user\" }\n\t\t\t\t)\n\t\t\t).rejects.toBe(exitError);\n\n\t\t\texpect(compileMock).toHaveBeenCalledWith(\n\t\t\t\texpect.objectContaining({\n\t\t\t\t\tproject: projectDir,\n\t\t\t\t\toutdir,\n\t\t\t\t})\n\t\t\t);\n\t\t\texpect(\n\t\t\t\tinfoSpy.mock.calls.some((call) =>\n\t\t\t\t\tString(call[0]).includes(\"--project was not provided\")\n\t\t\t\t)\n\t\t\t).toBe(true);\n\t\t} finally {\n\t\t\tcwdMock.mockRestore();\n\t\t}\n\t});\n\n\ttest(\"command line flags override config file values\", async () => {\n\t\tconst { workspace, projectDir } = await createWorkspace();\n\t\tawait writeConfig(projectDir, path.join(workspace, \"from-config\"));\n\n\t\tconst compileMock = vi.fn().mockResolvedValue({});\n\t\tvi.doMock(\"../../../compiler/compile.js\", () => ({\n\t\t\tcompile: compileMock,\n\t\t}));\n\t\tconst exitError = new Error(\"process.exit\");\n\t\tvi.spyOn(process, \"exit\").mockImplementation(() => {\n\t\t\tthrow exitError;\n\t\t});\n\n\t\tconst { compileCommand } = await import(\"./command.js\");\n\n\t\tawait expect(\n\t\t\tcompileCommand.parseAsync(\n\t\t\t\t[\n\t\t\t\t\t\"--project\",\n\t\t\t\t\tprojectDir,\n\t\t\t\t\t\"--outdir\",\n\t\t\t\t\t\"./from-flag\",\n\t\t\t\t\t\"--strategy\",\n\t\t\t\t\t\"cookie\",\n\t\t\t\t\t\"baseLocale\",\n\t\t\t\t\t\"--silent\",\n\t\t\t\t],\n\t\t\t\t{ from: \"user\" }\n\t\t\t)\n\t\t).rejects.toBe(exitError);\n\n\t\texpect(compileMock).toHaveBeenCalledWith(\n\t\t\texpect.objectContaining({\n\t\t\t\tproject: projectDir,\n\t\t\t\toutdir: resolve(process.cwd(), \"./from-flag\"),\n\t\t\t\tstrategy: [\"cookie\", \"baseLocale\"],\n\t\t\t})\n\t\t);\n\t});\n\n\t// Deleting the config file mid-watch falls back to the built-in\n\t// defaults (same as never having a config); recreating it is picked up.\n\ttest(\"watch falls back to defaults when the config is deleted\", async () => {\n\t\tconst { workspace, projectDir } = await createWorkspace();\n\t\tconst configPath = path.join(projectDir, \"paraglide.config.ts\");\n\t\tconst outdir = path.join(workspace, \"from-config\");\n\t\tawait writeConfig(projectDir, outdir);\n\n\t\tconst compileMock = vi.fn().mockResolvedValue({});\n\t\tvi.doMock(\"../../../compiler/compile.js\", () => ({\n\t\t\tcompile: compileMock,\n\t\t}));\n\n\t\tconst { compileCommand } = await import(\"./command.js\");\n\n\t\tawait compileCommand.parseAsync(\n\t\t\t[\"--project\", projectDir, \"--watch\", \"--silent\"],\n\t\t\t{ from: \"user\" }\n\t\t);\n\t\texpect(compileMock).toHaveBeenCalledTimes(1);\n\t\texpect(compileMock.mock.calls[0]![0].outdir).toBe(outdir);\n\n\t\tawait rm(configPath);\n\n\t\tconst deadline = Date.now() + 10_000;\n\t\twhile (compileMock.mock.calls.length < 2 && Date.now() < deadline) {\n\t\t\tawait new Promise((r) => setTimeout(r, 50));\n\t\t}\n\n\t\texpect(compileMock.mock.calls.length).toBeGreaterThanOrEqual(2);\n\t\tfor (const call of compileMock.mock.calls.slice(1)) {\n\t\t\t// Default outdir, resolved against the working directory.\n\t\t\texpect(\n\t\t\t\tString(call[0].outdir).endsWith(path.join(\"src\", \"paraglide\"))\n\t\t\t).toBe(true);\n\t\t\texpect(call[0].project).toBe(projectDir);\n\t\t}\n\n\t\t// Recreating the config with a different outdir is picked up again.\n\t\tawait writeConfig(projectDir, path.join(workspace, \"recreated\"));\n\t\tconst recreateDeadline = Date.now() + 10_000;\n\t\twhile (\n\t\t\tDate.now() < recreateDeadline &&\n\t\t\t!compileMock.mock.calls.some((c) =>\n\t\t\t\tString(c[0].outdir).endsWith(\"recreated\")\n\t\t\t)\n\t\t) {\n\t\t\tawait new Promise((r) => setTimeout(r, 50));\n\t\t}\n\t\texpect(\n\t\t\tcompileMock.mock.calls.some((c) =>\n\t\t\t\tString(c[0].outdir).endsWith(\"recreated\")\n\t\t\t)\n\t\t).toBe(true);\n\t});\n\n\t// Renaming the config between formats switches to the new winner.\n\t// A NEW non-config file appearing directly in the project directory (e.g.\n\t// a locale JSON for a freshly added locale) must schedule a rebuild even\n\t// though no per-file watcher exists for it yet.\n\ttest(\"watch recompiles when a new input appears in the project directory\", async () => {\n\t\tconst { workspace, projectDir } = await createWorkspace();\n\t\tawait writeConfig(projectDir, path.join(workspace, \"from-config\"));\n\n\t\tconst compileMock = vi.fn().mockResolvedValue({});\n\t\tvi.doMock(\"../../../compiler/compile.js\", () => ({\n\t\t\tcompile: compileMock,\n\t\t}));\n\n\t\tconst { compileCommand } = await import(\"./command.js\");\n\n\t\tawait compileCommand.parseAsync(\n\t\t\t[\"--project\", projectDir, \"--watch\", \"--silent\"],\n\t\t\t{ from: \"user\" }\n\t\t);\n\t\texpect(compileMock).toHaveBeenCalledTimes(1);\n\n\t\tawait writeFile(path.join(projectDir, \"es.json\"), \"{}\");\n\n\t\tconst deadline = Date.now() + 10_000;\n\t\twhile (compileMock.mock.calls.length < 2 && Date.now() < deadline) {\n\t\t\tawait new Promise((r) => setTimeout(r, 50));\n\t\t}\n\t\texpect(compileMock.mock.calls.length).toBeGreaterThanOrEqual(2);\n\t});\n\n\ttest(\"watch follows config renames between formats\", async () => {\n\t\tconst { workspace, projectDir } = await createWorkspace();\n\t\tconst tsPath = path.join(projectDir, \"paraglide.config.ts\");\n\t\tconst jsPath = path.join(projectDir, \"paraglide.config.js\");\n\t\tconst outdirA = path.join(workspace, \"out-ts\");\n\t\tconst outdirB = path.join(workspace, \"out-js\");\n\t\tawait writeConfig(projectDir, outdirA);\n\n\t\tconst compileMock = vi.fn().mockResolvedValue({});\n\t\tvi.doMock(\"../../../compiler/compile.js\", () => ({\n\t\t\tcompile: compileMock,\n\t\t}));\n\n\t\tconst { compileCommand } = await import(\"./command.js\");\n\n\t\tawait compileCommand.parseAsync(\n\t\t\t[\"--project\", projectDir, \"--watch\", \"--silent\"],\n\t\t\t{ from: \"user\" }\n\t\t);\n\t\texpect(compileMock.mock.calls[0]![0].outdir).toBe(outdirA);\n\n\t\t// Format switch: delete .ts, add .js.\n\t\tawait rm(tsPath);\n\t\tawait writeFile(\n\t\t\tjsPath,\n\t\t\t[\"export default {\", ` outdir: ${JSON.stringify(outdirB)},`, \"}\"].join(\n\t\t\t\t\"\\n\"\n\t\t\t)\n\t\t);\n\n\t\tconst deadline = Date.now() + 10_000;\n\t\twhile (\n\t\t\tDate.now() < deadline &&\n\t\t\t!compileMock.mock.calls.some((c) => c[0].outdir === outdirB)\n\t\t) {\n\t\t\tawait new Promise((r) => setTimeout(r, 50));\n\t\t}\n\t\texpect(compileMock.mock.calls.some((c) => c[0].outdir === outdirB)).toBe(\n\t\t\ttrue\n\t\t);\n\t});\n\n\t// Non-config changes inside the project directory DO rebuild (new\n\t// inputs can appear there) but must NOT reload the config.\n\ttest(\"watch recompiles without reloading config for non-config changes\", async () => {\n\t\tconst { workspace, projectDir } = await createWorkspace();\n\t\tawait writeConfig(projectDir, path.join(workspace, \"from-config\"));\n\n\t\tlet loadCount = 0;\n\t\tvi.doMock(\"../../../compiler/compile.js\", () => ({\n\t\t\tcompile: vi.fn().mockResolvedValue({}),\n\t\t}));\n\t\tvi.doMock(\"../../../services/config/index.js\", async (importActual) => {\n\t\t\tconst actual =\n\t\t\t\tawait importActual<\n\t\t\t\t\ttypeof import(\"../../../services/config/index.js\")\n\t\t\t\t>();\n\t\t\treturn {\n\t\t\t\t...actual,\n\t\t\t\tloadParaglideConfig: (\n\t\t\t\t\t...args: Parameters<typeof actual.loadParaglideConfig>\n\t\t\t\t) => {\n\t\t\t\t\tloadCount++;\n\t\t\t\t\treturn actual.loadParaglideConfig(...args);\n\t\t\t\t},\n\t\t\t};\n\t\t});\n\n\t\ttry {\n\t\t\tconst { compileCommand } = await import(\"./command.js\");\n\t\t\tconst compileModule = (await import(\"../../../compiler/compile.js\")) as {\n\t\t\t\tcompile: ReturnType<typeof vi.fn>;\n\t\t\t};\n\n\t\t\tawait compileCommand.parseAsync(\n\t\t\t\t[\"--project\", projectDir, \"--watch\", \"--silent\"],\n\t\t\t\t{ from: \"user\" }\n\t\t\t);\n\t\t\texpect(compileModule.compile).toHaveBeenCalledTimes(1);\n\t\t\texpect(loadCount).toBe(1);\n\n\t\t\tawait writeFile(path.join(projectDir, \"README.md\"), \"hello\");\n\t\t\tawait new Promise((r) => setTimeout(r, 1_000));\n\t\t\tawait writeFile(path.join(projectDir, \"notes.txt\"), \"world\");\n\t\t\tawait new Promise((r) => setTimeout(r, 1_500));\n\n\t\t\texpect(compileModule.compile.mock.calls.length).toBeGreaterThanOrEqual(3);\n\t\t\texpect(loadCount).toBe(1);\n\t\t} finally {\n\t\t\tvi.doUnmock(\"../../../services/config/index.js\");\n\t\t}\n\t});\n});\n\ntest(\"compile --watch forwards the newly exposed compiler options (#757)\", async () => {\n\tconst testDirectory = await mkdtemp(path.join(tmpdir(), \"paraglide-cli-\"));\n\ttestDirectories.push(testDirectory);\n\tconst outdir = path.join(testDirectory, \"output\");\n\n\tconst compileMock = vi.fn().mockResolvedValue({ outputHashes: {} });\n\tvi.doMock(\"../../../compiler/compile.js\", () => ({\n\t\tcompile: compileMock,\n\t}));\n\n\tconst { compileCommand } = await import(\"./command.js\");\n\n\tawait compileCommand.parseAsync(\n\t\t[\n\t\t\t\"--project\",\n\t\t\tpath.join(testDirectory, \"project.inlang\"),\n\t\t\t\"--outdir\",\n\t\t\toutdir,\n\t\t\t\"--watch\",\n\t\t\t\"--no-clean-outdir\",\n\t\t\t\"--experimental-static-locale\",\n\t\t\t'\"de\"',\n\t\t\t\"--disable-async-local-storage\",\n\t\t\t\"--silent\",\n\t\t],\n\t\t{ from: \"user\" }\n\t);\n\n\texpect(compileMock).toHaveBeenCalledTimes(1);\n\texpect(compileMock).toHaveBeenCalledWith(\n\t\texpect.objectContaining({\n\t\t\tcleanOutdir: false,\n\t\t\tdisableAsyncLocalStorage: true,\n\t\t\texperimentalStaticLocale: '\"de\"',\n\t\t\tpreviousCompilation: undefined,\n\t\t})\n\t);\n});\n"]}
@@ -10,5 +10,3 @@ export declare function getNewProjectTemplate(): {
10
10
  pathPattern: string;
11
11
  };
12
12
  };
13
- export declare const DEFAULT_PROJECT_PATH = "./project.inlang";
14
- export declare const DEFAULT_OUTDIR = "./src/paraglide";
@@ -20,6 +20,4 @@ const defaultProjectSettings = {
20
20
  export function getNewProjectTemplate() {
21
21
  return structuredClone(defaultProjectSettings);
22
22
  }
23
- export const DEFAULT_PROJECT_PATH = "./project.inlang";
24
- export const DEFAULT_OUTDIR = "./src/paraglide";
25
23
  //# sourceMappingURL=defaults.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/cli/defaults.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,sBAAsB,GAAG;IAC9B,OAAO,EAAE,4CAA4C;IACrD,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;IACrB,OAAO,EAAE;QACR,gFAAgF;QAChF,oFAAoF;KACpF;IACD,6BAA6B,EAAE;QAC9B,WAAW,EAAE,0BAA0B;KACvC;CACyB,CAAC;AAE5B;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACpC,OAAO,eAAe,CAAC,sBAAsB,CAAC,CAAC;AAChD,CAAC;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,kBAAkB,CAAC;AACvD,MAAM,CAAC,MAAM,cAAc,GAAG,iBAAiB,CAAC","sourcesContent":["import type { ProjectSettings } from \"@inlang/sdk\";\n\n/**\n * Default project settings for createNewProject\n * from paraglide-js/src/cli/commands/init/defaults.ts\n */\nconst defaultProjectSettings = {\n\t$schema: \"https://inlang.com/schema/project-settings\",\n\tbaseLocale: \"en\",\n\tlocales: [\"en\", \"de\"],\n\tmodules: [\n\t\t\"https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@4.4.0/dist/index.js\",\n\t\t\"https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@2.2.6/dist/index.js\",\n\t],\n\t\"plugin.inlang.messageFormat\": {\n\t\tpathPattern: \"./messages/{locale}.json\",\n\t},\n} satisfies ProjectSettings;\n\n/**\n * @returns A new copy of the default project template that is safe to mutate.\n */\nexport function getNewProjectTemplate() {\n\treturn structuredClone(defaultProjectSettings);\n}\n\nexport const DEFAULT_PROJECT_PATH = \"./project.inlang\";\nexport const DEFAULT_OUTDIR = \"./src/paraglide\";\n"]}
1
+ {"version":3,"file":"defaults.js","sourceRoot":"","sources":["../../src/cli/defaults.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,sBAAsB,GAAG;IAC9B,OAAO,EAAE,4CAA4C;IACrD,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC;IACrB,OAAO,EAAE;QACR,gFAAgF;QAChF,oFAAoF;KACpF;IACD,6BAA6B,EAAE;QAC9B,WAAW,EAAE,0BAA0B;KACvC;CACyB,CAAC;AAE5B;;GAEG;AACH,MAAM,UAAU,qBAAqB;IACpC,OAAO,eAAe,CAAC,sBAAsB,CAAC,CAAC;AAChD,CAAC","sourcesContent":["import type { ProjectSettings } from \"@inlang/sdk\";\n\n/**\n * Default project settings for createNewProject\n * from paraglide-js/src/cli/commands/init/defaults.ts\n */\nconst defaultProjectSettings = {\n\t$schema: \"https://inlang.com/schema/project-settings\",\n\tbaseLocale: \"en\",\n\tlocales: [\"en\", \"de\"],\n\tmodules: [\n\t\t\"https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@4.4.0/dist/index.js\",\n\t\t\"https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@2.2.6/dist/index.js\",\n\t],\n\t\"plugin.inlang.messageFormat\": {\n\t\tpathPattern: \"./messages/{locale}.json\",\n\t},\n} satisfies ProjectSettings;\n\n/**\n * @returns A new copy of the default project template that is safe to mutate.\n */\nexport function getNewProjectTemplate() {\n\treturn structuredClone(defaultProjectSettings);\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  import { loadProjectFromDirectory, loadProjectInMemory, newProject, saveProjectToDirectory, } from "@inlang/sdk";
2
- import { DEFAULT_PROJECT_PATH, getNewProjectTemplate } from "../defaults.js";
2
+ import { getNewProjectTemplate } from "../defaults.js";
3
+ import { DEFAULT_PROJECT_PATH } from "../../services/config/defaults.js";
3
4
  import nodePath from "node:path";
4
5
  import fs from "node:fs";
5
6
  export const initializeInlangProject = async (ctx) => {