@inlang/paraglide-js 2.26.0 → 2.28.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 (225) hide show
  1. package/README.md +11 -1
  2. package/dist/bundler-plugins/per-locale-build/index.js +14 -7
  3. package/dist/bundler-plugins/per-locale-build/index.js.map +1 -1
  4. package/dist/bundler-plugins/per-locale-build/vite-environments.test.js +237 -4
  5. package/dist/bundler-plugins/per-locale-build/vite-environments.test.js.map +1 -1
  6. package/dist/bundler-plugins/unplugin.d.ts +1 -1
  7. package/dist/bundler-plugins/unplugin.js +79 -10
  8. package/dist/bundler-plugins/unplugin.js.map +1 -1
  9. package/dist/bundler-plugins/unplugin.test.js +334 -1
  10. package/dist/bundler-plugins/unplugin.test.js.map +1 -1
  11. package/dist/bundler-plugins/vite.js +2 -1
  12. package/dist/bundler-plugins/vite.js.map +1 -1
  13. package/dist/bundler-plugins/vite.test.js +1 -1
  14. package/dist/bundler-plugins/vite.test.js.map +1 -1
  15. package/dist/cli/commands/compile/command.js +13 -0
  16. package/dist/cli/commands/compile/command.js.map +1 -1
  17. package/dist/cli/commands/compile/command.test.js +87 -3
  18. package/dist/cli/commands/compile/command.test.js.map +1 -1
  19. package/dist/cli/commands/init/command.d.ts +5 -0
  20. package/dist/cli/commands/init/command.js +216 -44
  21. package/dist/cli/commands/init/command.js.map +1 -1
  22. package/dist/cli/commands/init/command.test.d.ts +1 -0
  23. package/dist/cli/commands/init/command.test.js +123 -0
  24. package/dist/cli/commands/init/command.test.js.map +1 -0
  25. package/dist/cli/defaults.js +2 -2
  26. package/dist/cli/defaults.js.map +1 -1
  27. package/dist/cli/init-options.d.ts +11 -0
  28. package/dist/cli/init-options.js +2 -0
  29. package/dist/cli/init-options.js.map +1 -0
  30. package/dist/cli/steps/add-inlang-check.d.ts +19 -0
  31. package/dist/cli/steps/add-inlang-check.js +60 -0
  32. package/dist/cli/steps/add-inlang-check.js.map +1 -0
  33. package/dist/cli/steps/add-inlang-check.test.d.ts +1 -0
  34. package/dist/cli/steps/add-inlang-check.test.js +88 -0
  35. package/dist/cli/steps/add-inlang-check.test.js.map +1 -0
  36. package/dist/cli/steps/add-message-lint.d.ts +34 -0
  37. package/dist/cli/steps/add-message-lint.js +105 -0
  38. package/dist/cli/steps/add-message-lint.js.map +1 -0
  39. package/dist/cli/steps/add-message-lint.test.d.ts +1 -0
  40. package/dist/cli/steps/add-message-lint.test.js +74 -0
  41. package/dist/cli/steps/add-message-lint.test.js.map +1 -0
  42. package/dist/cli/steps/add-vite-plugin.d.ts +18 -0
  43. package/dist/cli/steps/add-vite-plugin.js +34 -6
  44. package/dist/cli/steps/add-vite-plugin.js.map +1 -1
  45. package/dist/cli/steps/add-vite-plugin.test.js +25 -9
  46. package/dist/cli/steps/add-vite-plugin.test.js.map +1 -1
  47. package/dist/cli/steps/agents-md-suggestion.d.ts +11 -0
  48. package/dist/cli/steps/agents-md-suggestion.js +19 -0
  49. package/dist/cli/steps/agents-md-suggestion.js.map +1 -0
  50. package/dist/cli/steps/agents-md-suggestion.test.d.ts +1 -0
  51. package/dist/cli/steps/agents-md-suggestion.test.js +36 -0
  52. package/dist/cli/steps/agents-md-suggestion.test.js.map +1 -0
  53. package/dist/cli/steps/check-for-uncomitted-changes.d.ts +3 -0
  54. package/dist/cli/steps/check-for-uncomitted-changes.js +15 -3
  55. package/dist/cli/steps/check-for-uncomitted-changes.js.map +1 -1
  56. package/dist/cli/steps/detect-bundler.d.ts +1 -0
  57. package/dist/cli/steps/detect-bundler.js +7 -1
  58. package/dist/cli/steps/detect-bundler.js.map +1 -1
  59. package/dist/cli/steps/initialize-inlang-project.d.ts +4 -3
  60. package/dist/cli/steps/initialize-inlang-project.js +60 -157
  61. package/dist/cli/steps/initialize-inlang-project.js.map +1 -1
  62. package/dist/cli/steps/maybe-add-machine-translation.d.ts +4 -0
  63. package/dist/cli/steps/maybe-add-machine-translation.js +14 -8
  64. package/dist/cli/steps/maybe-add-machine-translation.js.map +1 -1
  65. package/dist/cli/steps/maybe-add-sherlock.d.ts +2 -0
  66. package/dist/cli/steps/maybe-add-sherlock.js +13 -7
  67. package/dist/cli/steps/maybe-add-sherlock.js.map +1 -1
  68. package/dist/cli/steps/maybe-add-sherlock.test.d.ts +1 -0
  69. package/dist/cli/steps/maybe-add-sherlock.test.js +44 -0
  70. package/dist/cli/steps/maybe-add-sherlock.test.js.map +1 -0
  71. package/dist/cli/steps/prompt-for-outdir.d.ts +2 -0
  72. package/dist/cli/steps/prompt-for-outdir.js +4 -0
  73. package/dist/cli/steps/prompt-for-outdir.js.map +1 -1
  74. package/dist/cli/steps/update-package-json.js +8 -13
  75. package/dist/cli/steps/update-package-json.js.map +1 -1
  76. package/dist/cli/steps/update-ts-config.d.ts +6 -0
  77. package/dist/cli/steps/update-ts-config.js +27 -4
  78. package/dist/cli/steps/update-ts-config.js.map +1 -1
  79. package/dist/cli/utils.d.ts +11 -0
  80. package/dist/cli/utils.js +21 -0
  81. package/dist/cli/utils.js.map +1 -1
  82. package/dist/cli/utils.test.d.ts +1 -0
  83. package/dist/cli/utils.test.js +16 -0
  84. package/dist/cli/utils.test.js.map +1 -0
  85. package/dist/compiler/compile-annotation.d.ts +48 -1
  86. package/dist/compiler/compile-annotation.js +243 -10
  87. package/dist/compiler/compile-annotation.js.map +1 -1
  88. package/dist/compiler/compile-bundle.d.ts +7 -2
  89. package/dist/compiler/compile-bundle.js +97 -3
  90. package/dist/compiler/compile-bundle.js.map +1 -1
  91. package/dist/compiler/compile-bundle.test.js +232 -19
  92. package/dist/compiler/compile-bundle.test.js.map +1 -1
  93. package/dist/compiler/compile-lifecycle.test.d.ts +1 -0
  94. package/dist/compiler/compile-lifecycle.test.js +69 -0
  95. package/dist/compiler/compile-lifecycle.test.js.map +1 -0
  96. package/dist/compiler/compile-local-variable.d.ts +3 -0
  97. package/dist/compiler/compile-local-variable.js +5 -2
  98. package/dist/compiler/compile-local-variable.js.map +1 -1
  99. package/dist/compiler/compile-local-variable.test.js +55 -15
  100. package/dist/compiler/compile-local-variable.test.js.map +1 -1
  101. package/dist/compiler/compile-message.d.ts +29 -1
  102. package/dist/compiler/compile-message.exact-number.test.d.ts +1 -0
  103. package/dist/compiler/compile-message.exact-number.test.js +786 -0
  104. package/dist/compiler/compile-message.exact-number.test.js.map +1 -0
  105. package/dist/compiler/compile-message.js +162 -66
  106. package/dist/compiler/compile-message.js.map +1 -1
  107. package/dist/compiler/compile-message.locals.test.d.ts +1 -0
  108. package/dist/compiler/compile-message.locals.test.js +498 -0
  109. package/dist/compiler/compile-message.locals.test.js.map +1 -0
  110. package/dist/compiler/compile-message.test.js +113 -22
  111. package/dist/compiler/compile-message.test.js.map +1 -1
  112. package/dist/compiler/compile-pattern.d.ts +5 -0
  113. package/dist/compiler/compile-pattern.js +6 -18
  114. package/dist/compiler/compile-pattern.js.map +1 -1
  115. package/dist/compiler/compile-pattern.test.js +169 -5
  116. package/dist/compiler/compile-pattern.test.js.map +1 -1
  117. package/dist/compiler/compile-project.js +5 -1
  118. package/dist/compiler/compile-project.js.map +1 -1
  119. package/dist/compiler/compile-project.test.js +1260 -185
  120. package/dist/compiler/compile-project.test.js.map +1 -1
  121. package/dist/compiler/compile.js +36 -17
  122. package/dist/compiler/compile.js.map +1 -1
  123. package/dist/compiler/compile.test.js +71 -1
  124. package/dist/compiler/compile.test.js.map +1 -1
  125. package/dist/compiler/compiler-options.d.ts +41 -0
  126. package/dist/compiler/compiler-options.js.map +1 -1
  127. package/dist/compiler/create-readme.d.ts +4 -1
  128. package/dist/compiler/create-readme.js +33 -125
  129. package/dist/compiler/create-readme.js.map +1 -1
  130. package/dist/compiler/emit-ts-declarations.interop.test.js +2 -2
  131. package/dist/compiler/emit-ts-declarations.interop.test.js.map +1 -1
  132. package/dist/compiler/emit-ts-declarations.test.js +4 -4
  133. package/dist/compiler/emit-ts-declarations.test.js.map +1 -1
  134. package/dist/compiler/index.d.ts +1 -1
  135. package/dist/compiler/index.js +1 -1
  136. package/dist/compiler/index.js.map +1 -1
  137. package/dist/compiler/input-alias.d.ts +21 -0
  138. package/dist/compiler/input-alias.js +42 -0
  139. package/dist/compiler/input-alias.js.map +1 -0
  140. package/dist/compiler/input-alias.test.d.ts +1 -0
  141. package/dist/compiler/input-alias.test.js +58 -0
  142. package/dist/compiler/input-alias.test.js.map +1 -0
  143. package/dist/compiler/message-locals.d.ts +46 -0
  144. package/dist/compiler/message-locals.js +129 -0
  145. package/dist/compiler/message-locals.js.map +1 -0
  146. package/dist/compiler/output-structure/locale-modules.js +7 -1
  147. package/dist/compiler/output-structure/locale-modules.js.map +1 -1
  148. package/dist/compiler/output-structure/locale-modules.test.js +35 -0
  149. package/dist/compiler/output-structure/locale-modules.test.js.map +1 -1
  150. package/dist/compiler/output-structure/message-modules.js +6 -4
  151. package/dist/compiler/output-structure/message-modules.js.map +1 -1
  152. package/dist/compiler/output-structure/message-modules.test.js +35 -0
  153. package/dist/compiler/output-structure/message-modules.test.js.map +1 -1
  154. package/dist/compiler/registry.d.ts +12 -0
  155. package/dist/compiler/registry.js +158 -31
  156. package/dist/compiler/registry.js.map +1 -1
  157. package/dist/compiler/registry.test.d.ts +1 -0
  158. package/dist/compiler/registry.test.js +291 -0
  159. package/dist/compiler/registry.test.js.map +1 -0
  160. package/dist/compiler/runtime/create-runtime.d.ts +2 -0
  161. package/dist/compiler/runtime/create-runtime.js +9 -0
  162. package/dist/compiler/runtime/create-runtime.js.map +1 -1
  163. package/dist/compiler/runtime/extract-locale-from-cookie.js +8 -1
  164. package/dist/compiler/runtime/extract-locale-from-cookie.js.map +1 -1
  165. package/dist/compiler/runtime/extract-locale-from-cookie.test.js +26 -0
  166. package/dist/compiler/runtime/extract-locale-from-cookie.test.js.map +1 -1
  167. package/dist/compiler/runtime/extract-locale-from-header.js +47 -5
  168. package/dist/compiler/runtime/extract-locale-from-header.js.map +1 -1
  169. package/dist/compiler/runtime/extract-locale-from-header.test.js +58 -0
  170. package/dist/compiler/runtime/extract-locale-from-header.test.js.map +1 -1
  171. package/dist/compiler/runtime/get-locale.js +7 -1
  172. package/dist/compiler/runtime/get-locale.js.map +1 -1
  173. package/dist/compiler/runtime/get-locale.test.js +95 -0
  174. package/dist/compiler/runtime/get-locale.test.js.map +1 -1
  175. package/dist/compiler/runtime/localize-href.d.ts +8 -0
  176. package/dist/compiler/runtime/localize-href.js +60 -0
  177. package/dist/compiler/runtime/localize-href.js.map +1 -1
  178. package/dist/compiler/runtime/localize-href.test.js +227 -1
  179. package/dist/compiler/runtime/localize-href.test.js.map +1 -1
  180. package/dist/compiler/runtime/set-locale.js +24 -6
  181. package/dist/compiler/runtime/set-locale.js.map +1 -1
  182. package/dist/compiler/runtime/set-locale.test.js +182 -0
  183. package/dist/compiler/runtime/set-locale.test.js.map +1 -1
  184. package/dist/compiler/runtime/type.d.ts +2 -0
  185. package/dist/compiler/runtime/type.js.map +1 -1
  186. package/dist/compiler/runtime/type.test.js +34 -0
  187. package/dist/compiler/runtime/type.test.js.map +1 -1
  188. package/dist/compiler/runtime/variables.d.ts +2 -0
  189. package/dist/compiler/runtime/variables.js +7 -0
  190. package/dist/compiler/runtime/variables.js.map +1 -1
  191. package/dist/compiler/server/create-server-file.js +24 -0
  192. package/dist/compiler/server/create-server-file.js.map +1 -1
  193. package/dist/compiler/server/create-server-file.test.js +8 -2
  194. package/dist/compiler/server/create-server-file.test.js.map +1 -1
  195. package/dist/compiler/server/middleware.d.ts +8 -2
  196. package/dist/compiler/server/middleware.js +204 -11
  197. package/dist/compiler/server/middleware.js.map +1 -1
  198. package/dist/compiler/server/middleware.test.js +750 -3
  199. package/dist/compiler/server/middleware.test.js.map +1 -1
  200. package/dist/eslint/index.d.ts +4 -0
  201. package/dist/eslint/index.js +8 -0
  202. package/dist/eslint/index.js.map +1 -0
  203. package/dist/eslint/no-dynamic-message-access.d.ts +3 -0
  204. package/dist/eslint/no-dynamic-message-access.js +150 -0
  205. package/dist/eslint/no-dynamic-message-access.js.map +1 -0
  206. package/dist/eslint/no-dynamic-message-access.test.d.ts +1 -0
  207. package/dist/eslint/no-dynamic-message-access.test.js +126 -0
  208. package/dist/eslint/no-dynamic-message-access.test.js.map +1 -0
  209. package/dist/eslint/oxlint.test.d.ts +1 -0
  210. package/dist/eslint/oxlint.test.js +64 -0
  211. package/dist/eslint/oxlint.test.js.map +1 -0
  212. package/dist/services/config/config-schema.d.ts +2 -0
  213. package/dist/services/config/config-schema.js +2 -0
  214. package/dist/services/config/config-schema.js.map +1 -1
  215. package/dist/services/config/load-paraglide-config.test.js +12 -0
  216. package/dist/services/config/load-paraglide-config.test.js.map +1 -1
  217. package/dist/services/env-variables/index.js +1 -1
  218. package/dist/services/env-variables/index.js.map +1 -1
  219. package/dist/services/file-handling/write-output.bench.js +51 -11
  220. package/dist/services/file-handling/write-output.bench.js.map +1 -1
  221. package/dist/services/file-handling/write-output.js +60 -20
  222. package/dist/services/file-handling/write-output.js.map +1 -1
  223. package/dist/services/file-handling/write-output.test.js +175 -0
  224. package/dist/services/file-handling/write-output.test.js.map +1 -1
  225. package/package.json +15 -5
@@ -1,72 +1,244 @@
1
- import { Command } from "commander";
1
+ import { Command, Option } from "commander";
2
2
  import * as nodePath from "node:path";
3
3
  import { Logger } from "../../../services/logger/index.js";
4
4
  import { findPackageJson } from "../../../services/environment/package.js";
5
5
  import { checkForUncommittedChanges } from "../../steps/check-for-uncomitted-changes.js";
6
6
  import { initializeInlangProject } from "../../steps/initialize-inlang-project.js";
7
7
  import { maybeAddSherlock } from "../../steps/maybe-add-sherlock.js";
8
- import { maybeUpdateTsConfig } from "../../steps/update-ts-config.js";
8
+ import { maybeUpdateTsConfig, enableAllowJs, } from "../../steps/update-ts-config.js";
9
9
  import { promptForOutdir } from "../../steps/prompt-for-outdir.js";
10
10
  import { updatePackageJson } from "../../steps/update-package-json.js";
11
+ import { shellArgument } from "../../utils.js";
11
12
  import nodeFs from "node:fs";
12
13
  import { ENV_VARIABLES } from "../../../services/env-variables/index.js";
13
14
  import { detectBundler } from "../../steps/detect-bundler.js";
14
15
  import { addVitePlugin } from "../../steps/add-vite-plugin.js";
15
16
  import { compile } from "../../../compiler/compile.js";
16
17
  import { maybeAddMachineTranslation } from "../../steps/maybe-add-machine-translation.js";
17
- export const initCommand = new Command()
18
- .name("init")
19
- .summary("Initializes Paraglide-JS.")
20
- .action(async () => {
18
+ import { addInlangCheck } from "../../steps/add-inlang-check.js";
19
+ import { agentsMdSuggestion } from "../../steps/agents-md-suggestion.js";
20
+ import { getNewProjectTemplate } from "../../defaults.js";
21
+ import { addMessageLint, chooseMessageLint, preflightMessageLint, } from "../../steps/add-message-lint.js";
22
+ import { DEFAULT_PROJECT_PATH, DEFAULT_OUTDIR, } from "../../../services/config/defaults.js";
23
+ import { updateViteConfig } from "../../steps/add-vite-plugin.js";
24
+ export function createInitCommand() {
25
+ return new Command()
26
+ .name("init")
27
+ .summary("Initializes Paraglide-JS.")
28
+ .option("-y, --yes", "Use defaults without prompts; optional editor, translation and lint tools are skipped")
29
+ .option("--non-interactive", "Alias for --yes; never open terminal prompts")
30
+ .option("--allow-dirty", "Continue with uncommitted changes")
31
+ .option("--project <path>", "Inlang project to create or reuse", DEFAULT_PROJECT_PATH)
32
+ .option("--outdir <path>", "Directory for generated messages")
33
+ .addOption(new Option("--lint <tool>", "Optional message lint setup").choices([
34
+ "none",
35
+ "eslint",
36
+ "oxlint",
37
+ ]))
38
+ .option("--no-check", "Skip adding inlang check")
39
+ .option("--sherlock", "Add the editor recommendation")
40
+ .option("--no-sherlock", "Skip the editor recommendation")
41
+ .option("--machine-translation", "Add a machine-translate script")
42
+ .option("--no-machine-translation", "Skip the machine-translate script")
43
+ .option("--no-compile", "Skip the initial compilation; compile after installing dependencies")
44
+ .action(async (options, command) => {
45
+ try {
46
+ await runInit({
47
+ ...options,
48
+ sherlock: command.getOptionValueSource("sherlock") === "cli"
49
+ ? options.sherlock
50
+ : undefined,
51
+ machineTranslation: command.getOptionValueSource("machineTranslation") === "cli"
52
+ ? options.machineTranslation
53
+ : undefined,
54
+ });
55
+ }
56
+ catch (error) {
57
+ new Logger({ silent: false, prefix: false }).error(error instanceof Error ? error.message : String(error));
58
+ process.exitCode = 1;
59
+ }
60
+ });
61
+ }
62
+ export const initCommand = createInitCommand();
63
+ export async function runInit(options) {
64
+ const interactive = !(options.yes || options.nonInteractive);
65
+ if (interactive && (!process.stdin.isTTY || !process.stdout.isTTY))
66
+ throw new Error("init needs a terminal. Use --yes (or --non-interactive) for unattended setup; no files were changed.");
21
67
  const logger = new Logger({ silent: false, prefix: false });
22
- logger.box("Welcome to Paraglide JS 🪂");
68
+ const root = process.cwd();
69
+ const projectPath = nodePath.resolve(root, options.project ?? DEFAULT_PROJECT_PATH);
70
+ const outdir = nodePath.resolve(root, options.outdir ?? DEFAULT_OUTDIR);
71
+ const contains = (parent, child) => {
72
+ const relative = nodePath.relative(parent, child);
73
+ return (relative === "" ||
74
+ (!relative.startsWith(".." + nodePath.sep) &&
75
+ relative !== ".." &&
76
+ !nodePath.isAbsolute(relative)));
77
+ };
78
+ if (!options.project?.trim() && options.project !== undefined)
79
+ throw new Error("--project must not be empty.");
80
+ if (!options.outdir?.trim() && options.outdir !== undefined)
81
+ throw new Error("--outdir must not be empty.");
82
+ if (contains(outdir, root) ||
83
+ contains(projectPath, root) ||
84
+ contains(outdir, projectPath) ||
85
+ contains(projectPath, outdir))
86
+ throw new Error("Project and output directories must be distinct and must not contain the package root or each other.");
23
87
  const ctx = {
24
88
  logger,
25
89
  fs: nodeFs.promises,
26
90
  syncFs: nodeFs,
27
- root: process.cwd(),
91
+ root,
92
+ interactive,
93
+ allowDirty: options.allowDirty,
94
+ projectPath,
95
+ outdir: options.outdir
96
+ ? "./" + nodePath.relative(root, outdir).split(nodePath.sep).join("/")
97
+ : undefined,
98
+ sherlock: options.sherlock,
99
+ machineTranslation: options.machineTranslation,
28
100
  };
29
- const ctx1 = await checkForUncommittedChanges(ctx);
30
- const ctx2 = await enforcePackageJsonExists(ctx1);
31
- const ctx3 = await initializeInlangProject(ctx2);
32
- const ctx4 = await promptForOutdir(ctx3);
33
- const ctx5 = await addParaglideJsToDevDependencies(ctx4);
34
- const ctx6 = await detectBundler(ctx5);
35
- if (ctx6.bundler === "vite") {
36
- await addVitePlugin(ctx6);
101
+ await checkForUncommittedChanges(ctx);
102
+ const ctx2 = await enforcePackageJsonExists(ctx);
103
+ const pkg = JSON.parse(await ctx.fs.readFile(ctx2.packageJsonPath, "utf8"));
104
+ if (!pkg || typeof pkg !== "object" || Array.isArray(pkg))
105
+ throw new Error("package.json must contain a JSON object.");
106
+ for (const field of ["scripts", "dependencies", "devDependencies"])
107
+ if (pkg[field] !== undefined &&
108
+ (!pkg[field] ||
109
+ typeof pkg[field] !== "object" ||
110
+ Array.isArray(pkg[field])))
111
+ throw new Error(`package.json ${field} must be an object.`);
112
+ // Validate collisions before creating projects or changing dependencies.
113
+ const settingsExist = await nodeFs.promises
114
+ .access(nodePath.join(projectPath, "settings.json"))
115
+ .then(() => true, () => false);
116
+ if (!settingsExist) {
117
+ const contents = await nodeFs.promises
118
+ .readdir(projectPath)
119
+ .catch((error) => {
120
+ if (error.code === "ENOENT")
121
+ return [];
122
+ throw error;
123
+ });
124
+ if (contents.length)
125
+ throw new Error("The selected project directory is nonempty and has no settings.json; it will not be overwritten.");
37
126
  }
38
- else {
39
- await addCompileStepToPackageJSON(ctx6);
127
+ if (!interactive) {
128
+ const text = await nodeFs.promises
129
+ .readFile(nodePath.join(root, "tsconfig.json"), "utf8")
130
+ .catch((error) => {
131
+ if (error.code === "ENOENT")
132
+ return undefined;
133
+ throw error;
134
+ });
135
+ if (text !== undefined)
136
+ enableAllowJs(text);
137
+ }
138
+ const ctx4 = await promptForOutdir(ctx2);
139
+ const normalizedOutput = "./" +
140
+ nodePath
141
+ .relative(root, nodePath.resolve(root, ctx4.outdir))
142
+ .split(nodePath.sep)
143
+ .join("/");
144
+ const chosenOutput = nodePath.resolve(root, ctx4.outdir);
145
+ if (contains(chosenOutput, root) ||
146
+ contains(chosenOutput, projectPath) ||
147
+ contains(projectPath, chosenOutput))
148
+ throw new Error("Output must not contain the package root or overlap the inlang project.");
149
+ const lint = await chooseMessageLint({ ...ctx4, lint: options.lint });
150
+ await preflightMessageLint({ ...ctx4, outdir: normalizedOutput, lint });
151
+ const detected = await detectBundler(ctx4);
152
+ if (!interactive && detected.bundler === "vite") {
153
+ const config = await ctx.fs.readFile(detected.configPath, "utf8");
154
+ const result = updateViteConfig({
155
+ config,
156
+ projectPath: "./" +
157
+ nodePath.relative(root, projectPath).split(nodePath.sep).join("/"),
158
+ outdir: normalizedOutput,
159
+ });
160
+ if (!result.ok && result.reason !== "Already present")
161
+ throw new Error("Vite configuration cannot be updated automatically: " +
162
+ result.reason +
163
+ ". Add the plugin manually before rerunning init.");
40
164
  }
41
- const ctx7 = await maybeUpdateTsConfig(ctx6);
42
- const ctx8 = await maybeAddSherlock(ctx7);
43
- const ctx9 = await maybeAddMachineTranslation(ctx8);
165
+ if (interactive)
166
+ logger.box("Welcome to Paraglide JS 🪂");
167
+ const initialized = await initializeInlangProject({
168
+ ...ctx4,
169
+ outdir: normalizedOutput,
170
+ });
171
+ const portable = {
172
+ ...initialized,
173
+ projectPath: "./" +
174
+ nodePath
175
+ .relative(root, initialized.projectPath)
176
+ .split(nodePath.sep)
177
+ .join("/"),
178
+ lint,
179
+ };
44
180
  try {
45
- await compile({
46
- project: ctx9.projectPath,
181
+ const ctx5 = await addParaglideJsToDevDependencies(portable);
182
+ const ctx6 = await detectBundler(ctx5);
183
+ if (ctx6.bundler === "vite")
184
+ await addVitePlugin(ctx6);
185
+ else
186
+ await addCompileStepToPackageJSON(ctx6);
187
+ const ctx7 = await maybeUpdateTsConfig(ctx6);
188
+ const ctx8 = await maybeAddSherlock(ctx7);
189
+ if (options.check !== false)
190
+ await addInlangCheck(ctx8);
191
+ const ctx9 = await maybeAddMachineTranslation(ctx8);
192
+ await addMessageLint({ ...ctx9, lint });
193
+ if (options.compile !== false) {
194
+ try {
195
+ await compile({
196
+ project: ctx9.projectPath,
197
+ outdir: ctx9.outdir,
198
+ cleanOutdir: false,
199
+ });
200
+ logger.success("Ran the paraglide compiler");
201
+ }
202
+ catch (error) {
203
+ if (!interactive)
204
+ throw new Error("Setup files were written, but compilation failed. Install dependencies and rerun init or compile. Cause: " +
205
+ (error instanceof Error ? error.message : String(error)));
206
+ logger.warn("Failed to compile automatically. Install dependencies and run the compiler manually.");
207
+ }
208
+ }
209
+ logger.success("Setup complete! Install dependencies, then run your build" +
210
+ (lint !== "none" ? " and lint:i18n." : "."));
211
+ const settings = await ctx9.project.settings.get();
212
+ const pattern = settings["plugin.inlang.messageFormat"]?.pathPattern;
213
+ process.stdout.write(agentsMdSuggestion({
214
+ root,
215
+ projectPath: ctx9.projectPath,
47
216
  outdir: ctx9.outdir,
48
- });
49
- ctx.logger.success("Ran the paraglide compiler");
217
+ pathPattern: typeof pattern === "string"
218
+ ? nodePath
219
+ .relative(root, nodePath.resolve(nodePath.dirname(nodePath.resolve(root, ctx9.projectPath)), pattern))
220
+ .split(nodePath.sep)
221
+ .join("/")
222
+ : getNewProjectTemplate()["plugin.inlang.messageFormat"]
223
+ .pathPattern,
224
+ }) + "\n");
50
225
  }
51
- catch {
52
- ctx.logger.warn("Failed to compile project automatically. You will need to run the compiler manually");
226
+ finally {
227
+ await initialized.project.close();
53
228
  }
54
- const successMessage = [
55
- "Setup complete! Run `npm install` and then `npm run build`.",
56
- `Docs: https://paraglidejs.com/basics`,
57
- "\n",
58
- "For questions and feedback, visit",
59
- "https://github.com/opral/paraglide-js/issues",
60
- ].join("\n");
61
- ctx.logger.box(successMessage);
62
- process.exit(0);
63
- });
229
+ }
64
230
  const addParaglideJsToDevDependencies = async (ctx) => {
65
231
  const ctx1 = await updatePackageJson({
66
- devDependencies: async (devDeps) => ({
67
- ...devDeps,
68
- "@inlang/paraglide-js": `^${ENV_VARIABLES.PARJS_PACKAGE_VERSION}`,
69
- }),
232
+ devDependencies: async (devDeps) => {
233
+ const pkg = JSON.parse(await ctx.fs.readFile(ctx.packageJsonPath, "utf8"));
234
+ if (pkg.dependencies?.["@inlang/paraglide-js"] ||
235
+ devDeps["@inlang/paraglide-js"])
236
+ return devDeps;
237
+ return {
238
+ ...devDeps,
239
+ "@inlang/paraglide-js": `^${ENV_VARIABLES.PARJS_PACKAGE_VERSION}`,
240
+ };
241
+ },
70
242
  })(ctx);
71
243
  ctx.logger.success("Added @inlang/paraglide-js to the devDependencies in package.json.");
72
244
  return ctx1;
@@ -75,13 +247,13 @@ const enforcePackageJsonExists = async (ctx) => {
75
247
  const packageJsonPath = await findPackageJson(ctx.fs, process.cwd());
76
248
  if (!packageJsonPath) {
77
249
  ctx.logger.warn("No package.json found in the current working directory. Please change the working directory to the directory with a package.json file.");
78
- return process.exit(0);
250
+ throw new Error("No package.json found in the current working directory.");
79
251
  }
80
252
  return { ...ctx, packageJsonPath };
81
253
  };
82
254
  const addCompileStepToPackageJSON = async (ctx) => {
83
- const projectPath = "./" + nodePath.relative(process.cwd(), ctx.projectPath);
84
- const outdir = "./" + nodePath.relative(process.cwd(), ctx.outdir);
255
+ const projectPath = shellArgument("./" + nodePath.relative(process.cwd(), nodePath.resolve(ctx.projectPath)));
256
+ const outdir = shellArgument("./" + nodePath.relative(process.cwd(), nodePath.resolve(ctx.outdir)));
85
257
  ctx = await updatePackageJson({
86
258
  scripts: async (scripts) => {
87
259
  if (scripts.build === undefined) {
@@ -1 +1 @@
1
- {"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../src/cli/commands/init/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EAAE,uBAAuB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rE,OAAO,CAAC,KAAK,GAAG,kCAAkC,WAAW,aAAa,MAAM,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;YACxG,CAAC;iBAAM,CAAC;gBACP,OAAO,OAAO,CAAC;YAChB,CAAC;YAED,GAAG,CAAC,MAAM,CAAC,OAAO,CACjB,8DAA8D,CAC9D,CAAC;YACF,GAAG,CAAC,MAAM,CAAC,IAAI,CACd,wEAAwE,CACxE,CAAC;YACF,OAAO,OAAO,CAAC;QAChB,CAAC;KACD,CAAC,CAAC,GAAG,CAAC,CAAC;IAER,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC","sourcesContent":["import { Command } from \"commander\";\nimport * as nodePath from \"node:path\";\nimport { Logger } from \"../../../services/logger/index.js\";\nimport { findPackageJson } from \"../../../services/environment/package.js\";\nimport { checkForUncommittedChanges } from \"../../steps/check-for-uncomitted-changes.js\";\nimport { initializeInlangProject } from \"../../steps/initialize-inlang-project.js\";\nimport { maybeAddSherlock } from \"../../steps/maybe-add-sherlock.js\";\nimport { maybeUpdateTsConfig } from \"../../steps/update-ts-config.js\";\nimport { promptForOutdir } from \"../../steps/prompt-for-outdir.js\";\nimport { updatePackageJson } from \"../../steps/update-package-json.js\";\nimport type { CliStep } from \"../../utils.js\";\nimport nodeFs from \"node:fs\";\nimport { ENV_VARIABLES } from \"../../../services/env-variables/index.js\";\nimport { detectBundler } from \"../../steps/detect-bundler.js\";\nimport { addVitePlugin } from \"../../steps/add-vite-plugin.js\";\nimport { compile } from \"../../../compiler/compile.js\";\nimport { maybeAddMachineTranslation } from \"../../steps/maybe-add-machine-translation.js\";\n\nexport const initCommand = new Command()\n\t.name(\"init\")\n\t.summary(\"Initializes Paraglide-JS.\")\n\t.action(async () => {\n\t\tconst logger = new Logger({ silent: false, prefix: false });\n\n\t\tlogger.box(\"Welcome to Paraglide JS 🪂\");\n\n\t\tconst ctx = {\n\t\t\tlogger,\n\t\t\tfs: nodeFs.promises,\n\t\t\tsyncFs: nodeFs,\n\t\t\troot: process.cwd(),\n\t\t} as const;\n\n\t\tconst ctx1 = await checkForUncommittedChanges(ctx);\n\t\tconst ctx2 = await enforcePackageJsonExists(ctx1);\n\t\tconst ctx3 = await initializeInlangProject(ctx2);\n\t\tconst ctx4 = await promptForOutdir(ctx3);\n\t\tconst ctx5 = await addParaglideJsToDevDependencies(ctx4);\n\t\tconst ctx6 = await detectBundler(ctx5);\n\n\t\tif (ctx6.bundler === \"vite\") {\n\t\t\tawait addVitePlugin(ctx6);\n\t\t} else {\n\t\t\tawait addCompileStepToPackageJSON(ctx6);\n\t\t}\n\n\t\tconst ctx7 = await maybeUpdateTsConfig(ctx6);\n\t\tconst ctx8 = await maybeAddSherlock(ctx7);\n\t\tconst ctx9 = await maybeAddMachineTranslation(ctx8);\n\n\t\ttry {\n\t\t\tawait compile({\n\t\t\t\tproject: ctx9.projectPath,\n\t\t\t\toutdir: ctx9.outdir,\n\t\t\t});\n\t\t\tctx.logger.success(\"Ran the paraglide compiler\");\n\t\t} catch {\n\t\t\tctx.logger.warn(\n\t\t\t\t\"Failed to compile project automatically. You will need to run the compiler manually\"\n\t\t\t);\n\t\t}\n\n\t\tconst successMessage = [\n\t\t\t\"Setup complete! Run `npm install` and then `npm run build`.\",\n\t\t\t`Docs: https://paraglidejs.com/basics`,\n\t\t\t\"\\n\",\n\t\t\t\"For questions and feedback, visit\",\n\t\t\t\"https://github.com/opral/paraglide-js/issues\",\n\t\t].join(\"\\n\");\n\t\tctx.logger.box(successMessage);\n\t\tprocess.exit(0);\n\t});\n\nconst addParaglideJsToDevDependencies: CliStep<\n\t{\n\t\tfs: typeof import(\"node:fs/promises\");\n\t\tlogger: Logger;\n\t\tpackageJsonPath: string;\n\t},\n\tunknown\n> = async (ctx) => {\n\tconst ctx1 = await updatePackageJson({\n\t\tdevDependencies: async (devDeps) => ({\n\t\t\t...devDeps,\n\t\t\t\"@inlang/paraglide-js\": `^${ENV_VARIABLES.PARJS_PACKAGE_VERSION}`,\n\t\t}),\n\t})(ctx);\n\tctx.logger.success(\n\t\t\"Added @inlang/paraglide-js to the devDependencies in package.json.\"\n\t);\n\treturn ctx1;\n};\n\nconst enforcePackageJsonExists: CliStep<\n\t{ logger: Logger; fs: typeof import(\"node:fs/promises\") },\n\t{ packageJsonPath: string }\n> = async (ctx) => {\n\tconst packageJsonPath = await findPackageJson(ctx.fs, process.cwd());\n\tif (!packageJsonPath) {\n\t\tctx.logger.warn(\n\t\t\t\"No package.json found in the current working directory. Please change the working directory to the directory with a package.json file.\"\n\t\t);\n\t\treturn process.exit(0);\n\t}\n\treturn { ...ctx, packageJsonPath };\n};\n\nconst addCompileStepToPackageJSON: CliStep<\n\t{\n\t\tfs: typeof import(\"node:fs/promises\");\n\t\tlogger: Logger;\n\t\tprojectPath: string;\n\t\toutdir: string;\n\t\tpackageJsonPath: string;\n\t},\n\tunknown\n> = async (ctx) => {\n\tconst projectPath = \"./\" + nodePath.relative(process.cwd(), ctx.projectPath);\n\tconst outdir = \"./\" + nodePath.relative(process.cwd(), ctx.outdir);\n\n\tctx = await updatePackageJson({\n\t\tscripts: async (scripts) => {\n\t\t\tif (scripts.build === undefined) {\n\t\t\t\tscripts.build = `paraglide-js compile --project ${projectPath} --outdir ${outdir}`;\n\t\t\t} else if (scripts.build.includes(\"paraglide-js compile\") === false) {\n\t\t\t\tscripts.build = `paraglide-js compile --project ${projectPath} --outdir ${outdir} && ${scripts.build}`;\n\t\t\t} else {\n\t\t\t\treturn scripts;\n\t\t\t}\n\n\t\t\tctx.logger.success(\n\t\t\t\t\"Added the compile command to the build step in package.json.\"\n\t\t\t);\n\t\t\tctx.logger.info(\n\t\t\t\t`Visit https://paraglidejs.com/compiling-messages for more information.`\n\t\t\t);\n\t\t\treturn scripts;\n\t\t},\n\t})(ctx);\n\n\treturn ctx;\n};\n"]}
1
+ {"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../src/cli/commands/init/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAA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C,WAAW,aAAa,MAAM,OAAO,OAAO,CAAC,KAAK,EAAE,CAAC;YACxG,CAAC;iBAAM,CAAC;gBACP,OAAO,OAAO,CAAC;YAChB,CAAC;YAED,GAAG,CAAC,MAAM,CAAC,OAAO,CACjB,8DAA8D,CAC9D,CAAC;YACF,GAAG,CAAC,MAAM,CAAC,IAAI,CACd,wEAAwE,CACxE,CAAC;YACF,OAAO,OAAO,CAAC;QAChB,CAAC;KACD,CAAC,CAAC,GAAG,CAAC,CAAC;IAER,OAAO,GAAG,CAAC;AACZ,CAAC,CAAC","sourcesContent":["import { Command, Option } from \"commander\";\nimport * as nodePath from \"node:path\";\nimport { Logger } from \"../../../services/logger/index.js\";\nimport { findPackageJson } from \"../../../services/environment/package.js\";\nimport { checkForUncommittedChanges } from \"../../steps/check-for-uncomitted-changes.js\";\nimport { initializeInlangProject } from \"../../steps/initialize-inlang-project.js\";\nimport { maybeAddSherlock } from \"../../steps/maybe-add-sherlock.js\";\nimport {\n\tmaybeUpdateTsConfig,\n\tenableAllowJs,\n} from \"../../steps/update-ts-config.js\";\nimport { promptForOutdir } from \"../../steps/prompt-for-outdir.js\";\nimport { updatePackageJson } from \"../../steps/update-package-json.js\";\nimport { shellArgument, type CliStep } from \"../../utils.js\";\nimport nodeFs from \"node:fs\";\nimport { ENV_VARIABLES } from \"../../../services/env-variables/index.js\";\nimport { detectBundler } from \"../../steps/detect-bundler.js\";\nimport { addVitePlugin } from \"../../steps/add-vite-plugin.js\";\nimport { compile } from \"../../../compiler/compile.js\";\nimport { maybeAddMachineTranslation } from \"../../steps/maybe-add-machine-translation.js\";\nimport { addInlangCheck } from \"../../steps/add-inlang-check.js\";\nimport { agentsMdSuggestion } from \"../../steps/agents-md-suggestion.js\";\nimport { getNewProjectTemplate } from \"../../defaults.js\";\n\nimport type { InitOptions } from \"../../init-options.js\";\nimport {\n\taddMessageLint,\n\tchooseMessageLint,\n\tpreflightMessageLint,\n} from \"../../steps/add-message-lint.js\";\nimport {\n\tDEFAULT_PROJECT_PATH,\n\tDEFAULT_OUTDIR,\n} from \"../../../services/config/defaults.js\";\nimport { updateViteConfig } from \"../../steps/add-vite-plugin.js\";\n\nexport function createInitCommand() {\n\treturn new Command()\n\t\t.name(\"init\")\n\t\t.summary(\"Initializes Paraglide-JS.\")\n\t\t.option(\n\t\t\t\"-y, --yes\",\n\t\t\t\"Use defaults without prompts; optional editor, translation and lint tools are skipped\"\n\t\t)\n\t\t.option(\"--non-interactive\", \"Alias for --yes; never open terminal prompts\")\n\t\t.option(\"--allow-dirty\", \"Continue with uncommitted changes\")\n\t\t.option(\n\t\t\t\"--project <path>\",\n\t\t\t\"Inlang project to create or reuse\",\n\t\t\tDEFAULT_PROJECT_PATH\n\t\t)\n\t\t.option(\"--outdir <path>\", \"Directory for generated messages\")\n\t\t.addOption(\n\t\t\tnew Option(\"--lint <tool>\", \"Optional message lint setup\").choices([\n\t\t\t\t\"none\",\n\t\t\t\t\"eslint\",\n\t\t\t\t\"oxlint\",\n\t\t\t])\n\t\t)\n\t\t.option(\"--no-check\", \"Skip adding inlang check\")\n\t\t.option(\"--sherlock\", \"Add the editor recommendation\")\n\t\t.option(\"--no-sherlock\", \"Skip the editor recommendation\")\n\t\t.option(\"--machine-translation\", \"Add a machine-translate script\")\n\t\t.option(\"--no-machine-translation\", \"Skip the machine-translate script\")\n\t\t.option(\n\t\t\t\"--no-compile\",\n\t\t\t\"Skip the initial compilation; compile after installing dependencies\"\n\t\t)\n\t\t.action(\n\t\t\tasync (options: InitOptions & { compile: boolean }, command: Command) => {\n\t\t\t\ttry {\n\t\t\t\t\tawait runInit({\n\t\t\t\t\t\t...options,\n\t\t\t\t\t\tsherlock:\n\t\t\t\t\t\t\tcommand.getOptionValueSource(\"sherlock\") === \"cli\"\n\t\t\t\t\t\t\t\t? options.sherlock\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t\tmachineTranslation:\n\t\t\t\t\t\t\tcommand.getOptionValueSource(\"machineTranslation\") === \"cli\"\n\t\t\t\t\t\t\t\t? options.machineTranslation\n\t\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\t});\n\t\t\t\t} catch (error) {\n\t\t\t\t\tnew Logger({ silent: false, prefix: false }).error(\n\t\t\t\t\t\terror instanceof Error ? error.message : String(error)\n\t\t\t\t\t);\n\t\t\t\t\tprocess.exitCode = 1;\n\t\t\t\t}\n\t\t\t}\n\t\t);\n}\n\nexport const initCommand = createInitCommand();\n\nexport async function runInit(options: InitOptions & { compile?: boolean }) {\n\tconst interactive = !(options.yes || options.nonInteractive);\n\tif (interactive && (!process.stdin.isTTY || !process.stdout.isTTY))\n\t\tthrow new Error(\n\t\t\t\"init needs a terminal. Use --yes (or --non-interactive) for unattended setup; no files were changed.\"\n\t\t);\n\tconst logger = new Logger({ silent: false, prefix: false });\n\tconst root = process.cwd();\n\tconst projectPath = nodePath.resolve(\n\t\troot,\n\t\toptions.project ?? DEFAULT_PROJECT_PATH\n\t);\n\tconst outdir = nodePath.resolve(root, options.outdir ?? DEFAULT_OUTDIR);\n\tconst contains = (parent: string, child: string) => {\n\t\tconst relative = nodePath.relative(parent, child);\n\t\treturn (\n\t\t\trelative === \"\" ||\n\t\t\t(!relative.startsWith(\"..\" + nodePath.sep) &&\n\t\t\t\trelative !== \"..\" &&\n\t\t\t\t!nodePath.isAbsolute(relative))\n\t\t);\n\t};\n\tif (!options.project?.trim() && options.project !== undefined)\n\t\tthrow new Error(\"--project must not be empty.\");\n\tif (!options.outdir?.trim() && options.outdir !== undefined)\n\t\tthrow new Error(\"--outdir must not be empty.\");\n\tif (\n\t\tcontains(outdir, root) ||\n\t\tcontains(projectPath, root) ||\n\t\tcontains(outdir, projectPath) ||\n\t\tcontains(projectPath, outdir)\n\t)\n\t\tthrow new Error(\n\t\t\t\"Project and output directories must be distinct and must not contain the package root or each other.\"\n\t\t);\n\tconst ctx = {\n\t\tlogger,\n\t\tfs: nodeFs.promises,\n\t\tsyncFs: nodeFs,\n\t\troot,\n\t\tinteractive,\n\t\tallowDirty: options.allowDirty,\n\t\tprojectPath,\n\t\toutdir: options.outdir\n\t\t\t? \"./\" + nodePath.relative(root, outdir).split(nodePath.sep).join(\"/\")\n\t\t\t: undefined,\n\t\tsherlock: options.sherlock,\n\t\tmachineTranslation: options.machineTranslation,\n\t};\n\tawait checkForUncommittedChanges(ctx);\n\tconst ctx2 = await enforcePackageJsonExists(ctx);\n\tconst pkg = JSON.parse(await ctx.fs.readFile(ctx2.packageJsonPath, \"utf8\"));\n\tif (!pkg || typeof pkg !== \"object\" || Array.isArray(pkg))\n\t\tthrow new Error(\"package.json must contain a JSON object.\");\n\tfor (const field of [\"scripts\", \"dependencies\", \"devDependencies\"])\n\t\tif (\n\t\t\tpkg[field] !== undefined &&\n\t\t\t(!pkg[field] ||\n\t\t\t\ttypeof pkg[field] !== \"object\" ||\n\t\t\t\tArray.isArray(pkg[field]))\n\t\t)\n\t\t\tthrow new Error(`package.json ${field} must be an object.`);\n\t// Validate collisions before creating projects or changing dependencies.\n\tconst settingsExist = await nodeFs.promises\n\t\t.access(nodePath.join(projectPath, \"settings.json\"))\n\t\t.then(\n\t\t\t() => true,\n\t\t\t() => false\n\t\t);\n\tif (!settingsExist) {\n\t\tconst contents = await nodeFs.promises\n\t\t\t.readdir(projectPath)\n\t\t\t.catch((error: NodeJS.ErrnoException) => {\n\t\t\t\tif (error.code === \"ENOENT\") return [];\n\t\t\t\tthrow error;\n\t\t\t});\n\t\tif (contents.length)\n\t\t\tthrow new Error(\n\t\t\t\t\"The selected project directory is nonempty and has no settings.json; it will not be overwritten.\"\n\t\t\t);\n\t}\n\tif (!interactive) {\n\t\tconst text = await nodeFs.promises\n\t\t\t.readFile(nodePath.join(root, \"tsconfig.json\"), \"utf8\")\n\t\t\t.catch((error: NodeJS.ErrnoException) => {\n\t\t\t\tif (error.code === \"ENOENT\") return undefined;\n\t\t\t\tthrow error;\n\t\t\t});\n\t\tif (text !== undefined) enableAllowJs(text);\n\t}\n\tconst ctx4 = await promptForOutdir(ctx2);\n\tconst normalizedOutput =\n\t\t\"./\" +\n\t\tnodePath\n\t\t\t.relative(root, nodePath.resolve(root, ctx4.outdir))\n\t\t\t.split(nodePath.sep)\n\t\t\t.join(\"/\");\n\tconst chosenOutput = nodePath.resolve(root, ctx4.outdir);\n\tif (\n\t\tcontains(chosenOutput, root) ||\n\t\tcontains(chosenOutput, projectPath) ||\n\t\tcontains(projectPath, chosenOutput)\n\t)\n\t\tthrow new Error(\n\t\t\t\"Output must not contain the package root or overlap the inlang project.\"\n\t\t);\n\tconst lint = await chooseMessageLint({ ...ctx4, lint: options.lint });\n\tawait preflightMessageLint({ ...ctx4, outdir: normalizedOutput, lint });\n\tconst detected = await detectBundler(ctx4);\n\tif (!interactive && detected.bundler === \"vite\") {\n\t\tconst config = await ctx.fs.readFile(detected.configPath, \"utf8\");\n\t\tconst result = updateViteConfig({\n\t\t\tconfig,\n\t\t\tprojectPath:\n\t\t\t\t\"./\" +\n\t\t\t\tnodePath.relative(root, projectPath).split(nodePath.sep).join(\"/\"),\n\t\t\toutdir: normalizedOutput,\n\t\t});\n\t\tif (!result.ok && result.reason !== \"Already present\")\n\t\t\tthrow new Error(\n\t\t\t\t\"Vite configuration cannot be updated automatically: \" +\n\t\t\t\t\tresult.reason +\n\t\t\t\t\t\". Add the plugin manually before rerunning init.\"\n\t\t\t);\n\t}\n\tif (interactive) logger.box(\"Welcome to Paraglide JS 🪂\");\n\tconst initialized = await initializeInlangProject({\n\t\t...ctx4,\n\t\toutdir: normalizedOutput,\n\t});\n\tconst portable = {\n\t\t...initialized,\n\t\tprojectPath:\n\t\t\t\"./\" +\n\t\t\tnodePath\n\t\t\t\t.relative(root, initialized.projectPath)\n\t\t\t\t.split(nodePath.sep)\n\t\t\t\t.join(\"/\"),\n\t\tlint,\n\t};\n\ttry {\n\t\tconst ctx5 = await addParaglideJsToDevDependencies(portable);\n\t\tconst ctx6 = await detectBundler(ctx5);\n\t\tif (ctx6.bundler === \"vite\") await addVitePlugin(ctx6);\n\t\telse await addCompileStepToPackageJSON(ctx6);\n\t\tconst ctx7 = await maybeUpdateTsConfig(ctx6);\n\t\tconst ctx8 = await maybeAddSherlock(ctx7);\n\t\tif (options.check !== false) await addInlangCheck(ctx8);\n\t\tconst ctx9 = await maybeAddMachineTranslation(ctx8);\n\t\tawait addMessageLint({ ...ctx9, lint });\n\t\tif (options.compile !== false) {\n\t\t\ttry {\n\t\t\t\tawait compile({\n\t\t\t\t\tproject: ctx9.projectPath,\n\t\t\t\t\toutdir: ctx9.outdir,\n\t\t\t\t\tcleanOutdir: false,\n\t\t\t\t});\n\t\t\t\tlogger.success(\"Ran the paraglide compiler\");\n\t\t\t} catch (error) {\n\t\t\t\tif (!interactive)\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t\"Setup files were written, but compilation failed. Install dependencies and rerun init or compile. Cause: \" +\n\t\t\t\t\t\t\t(error instanceof Error ? error.message : String(error))\n\t\t\t\t\t);\n\t\t\t\tlogger.warn(\n\t\t\t\t\t\"Failed to compile automatically. Install dependencies and run the compiler manually.\"\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tlogger.success(\n\t\t\t\"Setup complete! Install dependencies, then run your build\" +\n\t\t\t\t(lint !== \"none\" ? \" and lint:i18n.\" : \".\")\n\t\t);\n\t\tconst settings = await ctx9.project.settings.get();\n\t\tconst pattern = settings[\"plugin.inlang.messageFormat\"]?.pathPattern;\n\t\tprocess.stdout.write(\n\t\t\tagentsMdSuggestion({\n\t\t\t\troot,\n\t\t\t\tprojectPath: ctx9.projectPath,\n\t\t\t\toutdir: ctx9.outdir,\n\t\t\t\tpathPattern:\n\t\t\t\t\ttypeof pattern === \"string\"\n\t\t\t\t\t\t? nodePath\n\t\t\t\t\t\t\t\t.relative(\n\t\t\t\t\t\t\t\t\troot,\n\t\t\t\t\t\t\t\t\tnodePath.resolve(\n\t\t\t\t\t\t\t\t\t\tnodePath.dirname(nodePath.resolve(root, ctx9.projectPath)),\n\t\t\t\t\t\t\t\t\t\tpattern\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.split(nodePath.sep)\n\t\t\t\t\t\t\t\t.join(\"/\")\n\t\t\t\t\t\t: getNewProjectTemplate()[\"plugin.inlang.messageFormat\"]\n\t\t\t\t\t\t\t\t.pathPattern,\n\t\t\t}) + \"\\n\"\n\t\t);\n\t} finally {\n\t\tawait initialized.project.close();\n\t}\n}\n\nconst addParaglideJsToDevDependencies: CliStep<\n\t{\n\t\tfs: typeof import(\"node:fs/promises\");\n\t\tlogger: Logger;\n\t\tpackageJsonPath: string;\n\t},\n\tunknown\n> = async (ctx) => {\n\tconst ctx1 = await updatePackageJson({\n\t\tdevDependencies: async (devDeps) => {\n\t\t\tconst pkg = JSON.parse(\n\t\t\t\tawait ctx.fs.readFile(ctx.packageJsonPath, \"utf8\")\n\t\t\t);\n\t\t\tif (\n\t\t\t\tpkg.dependencies?.[\"@inlang/paraglide-js\"] ||\n\t\t\t\tdevDeps[\"@inlang/paraglide-js\"]\n\t\t\t)\n\t\t\t\treturn devDeps;\n\t\t\treturn {\n\t\t\t\t...devDeps,\n\t\t\t\t\"@inlang/paraglide-js\": `^${ENV_VARIABLES.PARJS_PACKAGE_VERSION}`,\n\t\t\t};\n\t\t},\n\t})(ctx);\n\tctx.logger.success(\n\t\t\"Added @inlang/paraglide-js to the devDependencies in package.json.\"\n\t);\n\treturn ctx1;\n};\n\nconst enforcePackageJsonExists: CliStep<\n\t{ logger: Logger; fs: typeof import(\"node:fs/promises\") },\n\t{ packageJsonPath: string }\n> = async (ctx) => {\n\tconst packageJsonPath = await findPackageJson(ctx.fs, process.cwd());\n\tif (!packageJsonPath) {\n\t\tctx.logger.warn(\n\t\t\t\"No package.json found in the current working directory. Please change the working directory to the directory with a package.json file.\"\n\t\t);\n\t\tthrow new Error(\"No package.json found in the current working directory.\");\n\t}\n\treturn { ...ctx, packageJsonPath };\n};\n\nconst addCompileStepToPackageJSON: CliStep<\n\t{\n\t\tfs: typeof import(\"node:fs/promises\");\n\t\tlogger: Logger;\n\t\tprojectPath: string;\n\t\toutdir: string;\n\t\tpackageJsonPath: string;\n\t},\n\tunknown\n> = async (ctx) => {\n\tconst projectPath = shellArgument(\n\t\t\"./\" + nodePath.relative(process.cwd(), nodePath.resolve(ctx.projectPath))\n\t);\n\tconst outdir = shellArgument(\n\t\t\"./\" + nodePath.relative(process.cwd(), nodePath.resolve(ctx.outdir))\n\t);\n\n\tctx = await updatePackageJson({\n\t\tscripts: async (scripts) => {\n\t\t\tif (scripts.build === undefined) {\n\t\t\t\tscripts.build = `paraglide-js compile --project ${projectPath} --outdir ${outdir}`;\n\t\t\t} else if (scripts.build.includes(\"paraglide-js compile\") === false) {\n\t\t\t\tscripts.build = `paraglide-js compile --project ${projectPath} --outdir ${outdir} && ${scripts.build}`;\n\t\t\t} else {\n\t\t\t\treturn scripts;\n\t\t\t}\n\n\t\t\tctx.logger.success(\n\t\t\t\t\"Added the compile command to the build step in package.json.\"\n\t\t\t);\n\t\t\tctx.logger.info(\n\t\t\t\t`Visit https://paraglidejs.com/compiling-messages for more information.`\n\t\t\t);\n\t\t\treturn scripts;\n\t\t},\n\t})(ctx);\n\n\treturn ctx;\n};\n"]}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,123 @@
1
+ import { test, expect, vi, beforeEach, afterEach } from "vitest";
2
+ import { mkdtemp, writeFile, readFile, readdir, rm } from "node:fs/promises";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import { execFile } from "node:child_process";
6
+ import { promisify } from "node:util";
7
+ import { Logger } from "../../../services/logger/index.js";
8
+ import { checkForUncommittedChanges } from "../../steps/check-for-uncomitted-changes.js";
9
+ import { fileURLToPath } from "node:url";
10
+ import * as defaults from "../../defaults.js";
11
+ import * as utils from "../../utils.js";
12
+ import { createInitCommand, runInit } from "./command.js";
13
+ let root;
14
+ beforeEach(async () => {
15
+ root = await mkdtemp(join(tmpdir(), "paraglide-init-test-"));
16
+ vi.spyOn(process, "cwd").mockReturnValue(root);
17
+ vi.spyOn(utils, "prompt").mockImplementation(async () => {
18
+ throw new Error("Unexpected prompt in headless init");
19
+ });
20
+ vi.spyOn(utils, "promptSelection").mockImplementation(async () => {
21
+ throw new Error("Unexpected select in headless init");
22
+ });
23
+ const original = defaults.getNewProjectTemplate;
24
+ vi.spyOn(defaults, "getNewProjectTemplate").mockImplementation(() => ({
25
+ ...original(),
26
+ modules: [
27
+ fileURLToPath(new URL("../../../../node_modules/@inlang/plugin-message-format/dist/index.js", import.meta.url)),
28
+ ],
29
+ }));
30
+ await writeFile(join(root, "package.json"), JSON.stringify({
31
+ name: "fixture",
32
+ version: "1.0.0",
33
+ scripts: { build: "vite build" },
34
+ }));
35
+ });
36
+ afterEach(async () => {
37
+ vi.restoreAllMocks();
38
+ process.exitCode = 0;
39
+ await rm(root, { recursive: true, force: true });
40
+ });
41
+ test("headless setup and rerun preserve project/messages/comments and skip optional tools", async () => {
42
+ await writeFile(join(root, "tsconfig.json"), '// keep this comment\n{ "compilerOptions": { "strict": true, }, }\n');
43
+ await runInit({ yes: true, compile: false });
44
+ const packageFirst = await readFile(join(root, "package.json"), "utf8");
45
+ const settingsFirst = await readFile(join(root, "project.inlang/settings.json"), "utf8");
46
+ const messagesFirst = await readFile(join(root, "messages/en.json"), "utf8");
47
+ await runInit({ nonInteractive: true, compile: false });
48
+ expect(await readFile(join(root, "package.json"), "utf8")).toBe(packageFirst);
49
+ expect(await readFile(join(root, "project.inlang/settings.json"), "utf8")).toBe(settingsFirst);
50
+ expect(await readFile(join(root, "messages/en.json"), "utf8")).toBe(messagesFirst);
51
+ const tsconfig = await readFile(join(root, "tsconfig.json"), "utf8");
52
+ expect(tsconfig).toContain("keep this comment");
53
+ expect(tsconfig).toContain('"allowJs": true');
54
+ expect(tsconfig).toContain('"strict": true');
55
+ const pkg = JSON.parse(packageFirst);
56
+ expect(pkg.scripts["machine-translate"]).toBeUndefined();
57
+ expect(pkg.scripts["lint:i18n"]).toBeUndefined();
58
+ expect(pkg.devDependencies.eslint).toBeUndefined();
59
+ expect(utils.prompt).not.toHaveBeenCalled();
60
+ expect(utils.promptSelection).not.toHaveBeenCalled();
61
+ });
62
+ test("explicit paths and ESLint setup work without prompts", async () => {
63
+ await writeFile(join(root, "eslint.config.mjs"), "// preserve existing config");
64
+ await runInit({
65
+ yes: true,
66
+ project: "./config/project.inlang",
67
+ outdir: "./src/i18n",
68
+ lint: "eslint",
69
+ check: false,
70
+ compile: false,
71
+ });
72
+ const pkg = JSON.parse(await readFile(join(root, "package.json"), "utf8"));
73
+ expect(pkg.scripts["check:i18n"]).toBeUndefined();
74
+ expect(pkg.scripts["lint:i18n"]).toContain("eslint.paraglide.config.mjs");
75
+ expect(await readFile(join(root, "eslint.config.mjs"), "utf8")).toBe("// preserve existing config");
76
+ const settings = JSON.parse(await readFile(join(root, "config/project.inlang/settings.json"), "utf8"));
77
+ expect(settings["plugin.inlang.messageFormat"].pathPattern).toBe("../messages/{locale}.json");
78
+ expect(pkg.scripts.build).toContain("./config/project.inlang");
79
+ expect(pkg.scripts.build).toContain("./src/i18n");
80
+ });
81
+ test("closed input without an unattended flag fails before writes", async () => {
82
+ await expect(runInit({})).rejects.toThrow("Use --yes");
83
+ expect(await readdir(root)).toEqual(["package.json"]);
84
+ });
85
+ test("unwritable integration and invalid paths fail before scaffolding", async () => {
86
+ await writeFile(join(root, "vite.config.ts"), "export default () => ({plugins:getPlugins()});");
87
+ await expect(runInit({ yes: true })).rejects.toThrow("Vite configuration cannot");
88
+ expect((await readdir(root)).sort()).toEqual([
89
+ "package.json",
90
+ "vite.config.ts",
91
+ ]);
92
+ await expect(runInit({ yes: true, outdir: "." })).rejects.toThrow("distinct");
93
+ });
94
+ test("CLI help exposes unattended mode and optional lint choices", () => {
95
+ const help = createInitCommand().helpInformation();
96
+ for (const flag of [
97
+ "--yes",
98
+ "--non-interactive",
99
+ "--outdir",
100
+ "--project",
101
+ "--lint",
102
+ "--allow-dirty",
103
+ "--no-compile",
104
+ ])
105
+ expect(help).toContain(flag);
106
+ });
107
+ test("dirty git trees require explicit permission without prompting", async () => {
108
+ await promisify(execFile)("git", ["init", root]);
109
+ const ctx = {
110
+ logger: new Logger({ silent: true, prefix: false }),
111
+ root,
112
+ interactive: false,
113
+ };
114
+ await expect(checkForUncommittedChanges(ctx)).rejects.toThrow("--allow-dirty");
115
+ await expect(checkForUncommittedChanges({ ...ctx, allowDirty: true })).resolves.toBeDefined();
116
+ expect(utils.prompt).not.toHaveBeenCalled();
117
+ });
118
+ test("invalid lint choices fail before creating files", async () => {
119
+ const command = createInitCommand().exitOverride();
120
+ await expect(command.parseAsync(["--yes", "--lint", "invalid"], { from: "user" })).rejects.toThrow("Allowed choices");
121
+ expect(await readdir(root)).toEqual(["package.json"]);
122
+ });
123
+ //# sourceMappingURL=command.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"command.test.js","sourceRoot":"","sources":["../../../../src/cli/commands/init/command.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,6CAA6C,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,KAAK,QAAQ,MAAM,mBAAmB,CAAC;A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M,MAAM,CACX,0BAA0B,CAAC,EAAE,GAAG,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CACxD,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;IACzB,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;AAC7C,CAAC,CAAC,CAAC;AAEH,IAAI,CAAC,iDAAiD,EAAE,KAAK,IAAI,EAAE;IAClE,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC,YAAY,EAAE,CAAC;IACnD,MAAM,MAAM,CACX,OAAO,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CACpE,CAAC,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;IACrC,MAAM,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC;AACvD,CAAC,CAAC,CAAC","sourcesContent":["import { test, expect, vi, beforeEach, afterEach } from \"vitest\";\nimport { mkdtemp, writeFile, readFile, readdir, rm } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { execFile } from \"node:child_process\";\nimport { promisify } from \"node:util\";\nimport { Logger } from \"../../../services/logger/index.js\";\nimport { checkForUncommittedChanges } from \"../../steps/check-for-uncomitted-changes.js\";\nimport { fileURLToPath } from \"node:url\";\nimport * as defaults from \"../../defaults.js\";\nimport * as utils from \"../../utils.js\";\nimport { createInitCommand, runInit } from \"./command.js\";\n\nlet root: string;\nbeforeEach(async () => {\n\troot = await mkdtemp(join(tmpdir(), \"paraglide-init-test-\"));\n\tvi.spyOn(process, \"cwd\").mockReturnValue(root);\n\tvi.spyOn(utils, \"prompt\").mockImplementation(async () => {\n\t\tthrow new Error(\"Unexpected prompt in headless init\");\n\t});\n\tvi.spyOn(utils, \"promptSelection\").mockImplementation(async () => {\n\t\tthrow new Error(\"Unexpected select in headless init\");\n\t});\n\tconst original = defaults.getNewProjectTemplate;\n\tvi.spyOn(defaults, \"getNewProjectTemplate\").mockImplementation(() => ({\n\t\t...original(),\n\t\tmodules: [\n\t\t\tfileURLToPath(\n\t\t\t\tnew URL(\n\t\t\t\t\t\"../../../../node_modules/@inlang/plugin-message-format/dist/index.js\",\n\t\t\t\t\timport.meta.url\n\t\t\t\t)\n\t\t\t),\n\t\t],\n\t}));\n\tawait writeFile(\n\t\tjoin(root, \"package.json\"),\n\t\tJSON.stringify({\n\t\t\tname: \"fixture\",\n\t\t\tversion: \"1.0.0\",\n\t\t\tscripts: { build: \"vite build\" },\n\t\t})\n\t);\n});\nafterEach(async () => {\n\tvi.restoreAllMocks();\n\tprocess.exitCode = 0;\n\tawait rm(root, { recursive: true, force: true });\n});\n\ntest(\"headless setup and rerun preserve project/messages/comments and skip optional tools\", async () => {\n\tawait writeFile(\n\t\tjoin(root, \"tsconfig.json\"),\n\t\t'// keep this comment\\n{ \"compilerOptions\": { \"strict\": true, }, }\\n'\n\t);\n\tawait runInit({ yes: true, compile: false });\n\tconst packageFirst = await readFile(join(root, \"package.json\"), \"utf8\");\n\tconst settingsFirst = await readFile(\n\t\tjoin(root, \"project.inlang/settings.json\"),\n\t\t\"utf8\"\n\t);\n\tconst messagesFirst = await readFile(join(root, \"messages/en.json\"), \"utf8\");\n\tawait runInit({ nonInteractive: true, compile: false });\n\texpect(await readFile(join(root, \"package.json\"), \"utf8\")).toBe(packageFirst);\n\texpect(\n\t\tawait readFile(join(root, \"project.inlang/settings.json\"), \"utf8\")\n\t).toBe(settingsFirst);\n\texpect(await readFile(join(root, \"messages/en.json\"), \"utf8\")).toBe(\n\t\tmessagesFirst\n\t);\n\tconst tsconfig = await readFile(join(root, \"tsconfig.json\"), \"utf8\");\n\texpect(tsconfig).toContain(\"keep this comment\");\n\texpect(tsconfig).toContain('\"allowJs\": true');\n\texpect(tsconfig).toContain('\"strict\": true');\n\tconst pkg = JSON.parse(packageFirst);\n\texpect(pkg.scripts[\"machine-translate\"]).toBeUndefined();\n\texpect(pkg.scripts[\"lint:i18n\"]).toBeUndefined();\n\texpect(pkg.devDependencies.eslint).toBeUndefined();\n\texpect(utils.prompt).not.toHaveBeenCalled();\n\texpect(utils.promptSelection).not.toHaveBeenCalled();\n});\n\ntest(\"explicit paths and ESLint setup work without prompts\", async () => {\n\tawait writeFile(\n\t\tjoin(root, \"eslint.config.mjs\"),\n\t\t\"// preserve existing config\"\n\t);\n\tawait runInit({\n\t\tyes: true,\n\t\tproject: \"./config/project.inlang\",\n\t\toutdir: \"./src/i18n\",\n\t\tlint: \"eslint\",\n\t\tcheck: false,\n\t\tcompile: false,\n\t});\n\tconst pkg = JSON.parse(await readFile(join(root, \"package.json\"), \"utf8\"));\n\texpect(pkg.scripts[\"check:i18n\"]).toBeUndefined();\n\texpect(pkg.scripts[\"lint:i18n\"]).toContain(\"eslint.paraglide.config.mjs\");\n\texpect(await readFile(join(root, \"eslint.config.mjs\"), \"utf8\")).toBe(\n\t\t\"// preserve existing config\"\n\t);\n\tconst settings = JSON.parse(\n\t\tawait readFile(join(root, \"config/project.inlang/settings.json\"), \"utf8\")\n\t);\n\texpect(settings[\"plugin.inlang.messageFormat\"].pathPattern).toBe(\n\t\t\"../messages/{locale}.json\"\n\t);\n\texpect(pkg.scripts.build).toContain(\"./config/project.inlang\");\n\texpect(pkg.scripts.build).toContain(\"./src/i18n\");\n});\n\ntest(\"closed input without an unattended flag fails before writes\", async () => {\n\tawait expect(runInit({})).rejects.toThrow(\"Use --yes\");\n\texpect(await readdir(root)).toEqual([\"package.json\"]);\n});\n\ntest(\"unwritable integration and invalid paths fail before scaffolding\", async () => {\n\tawait writeFile(\n\t\tjoin(root, \"vite.config.ts\"),\n\t\t\"export default () => ({plugins:getPlugins()});\"\n\t);\n\tawait expect(runInit({ yes: true })).rejects.toThrow(\n\t\t\"Vite configuration cannot\"\n\t);\n\texpect((await readdir(root)).sort()).toEqual([\n\t\t\"package.json\",\n\t\t\"vite.config.ts\",\n\t]);\n\tawait expect(runInit({ yes: true, outdir: \".\" })).rejects.toThrow(\"distinct\");\n});\n\ntest(\"CLI help exposes unattended mode and optional lint choices\", () => {\n\tconst help = createInitCommand().helpInformation();\n\tfor (const flag of [\n\t\t\"--yes\",\n\t\t\"--non-interactive\",\n\t\t\"--outdir\",\n\t\t\"--project\",\n\t\t\"--lint\",\n\t\t\"--allow-dirty\",\n\t\t\"--no-compile\",\n\t])\n\t\texpect(help).toContain(flag);\n});\n\ntest(\"dirty git trees require explicit permission without prompting\", async () => {\n\tawait promisify(execFile)(\"git\", [\"init\", root]);\n\tconst ctx = {\n\t\tlogger: new Logger({ silent: true, prefix: false }),\n\t\troot,\n\t\tinteractive: false,\n\t};\n\tawait expect(checkForUncommittedChanges(ctx)).rejects.toThrow(\n\t\t\"--allow-dirty\"\n\t);\n\tawait expect(\n\t\tcheckForUncommittedChanges({ ...ctx, allowDirty: true })\n\t).resolves.toBeDefined();\n\texpect(utils.prompt).not.toHaveBeenCalled();\n});\n\ntest(\"invalid lint choices fail before creating files\", async () => {\n\tconst command = createInitCommand().exitOverride();\n\tawait expect(\n\t\tcommand.parseAsync([\"--yes\", \"--lint\", \"invalid\"], { from: \"user\" })\n\t).rejects.toThrow(\"Allowed choices\");\n\texpect(await readdir(root)).toEqual([\"package.json\"]);\n});\n"]}
@@ -7,8 +7,8 @@ const defaultProjectSettings = {
7
7
  baseLocale: "en",
8
8
  locales: ["en", "de"],
9
9
  modules: [
10
- "https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@4.4.0/dist/index.js",
11
- "https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@2.2.6/dist/index.js",
10
+ "https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@4.5.0/dist/index.js",
11
+ "https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@2.3.0/dist/index.js",
12
12
  ],
13
13
  "plugin.inlang.messageFormat": {
14
14
  pathPattern: "./messages/{locale}.json",
@@ -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","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
+ {"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.5.0/dist/index.js\",\n\t\t\"https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@2.3.0/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"]}
@@ -0,0 +1,11 @@
1
+ export type InitOptions = {
2
+ yes?: boolean;
3
+ nonInteractive?: boolean;
4
+ allowDirty?: boolean;
5
+ project?: string;
6
+ outdir?: string;
7
+ lint?: "none" | "eslint" | "oxlint";
8
+ check?: boolean;
9
+ sherlock?: boolean;
10
+ machineTranslation?: boolean;
11
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=init-options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-options.js","sourceRoot":"","sources":["../../src/cli/init-options.ts"],"names":[],"mappings":"","sourcesContent":["export type InitOptions = {\n\tyes?: boolean;\n\tnonInteractive?: boolean;\n\tallowDirty?: boolean;\n\tproject?: string;\n\toutdir?: string;\n\tlint?: \"none\" | \"eslint\" | \"oxlint\";\n\tcheck?: boolean;\n\tsherlock?: boolean;\n\tmachineTranslation?: boolean;\n};\n"]}
@@ -0,0 +1,19 @@
1
+ import type { Logger } from "../../services/logger/index.js";
2
+ import { type CliStep } from "../utils.js";
3
+ /**
4
+ * The `@inlang/cli` range `init` adds. 3.4.0 introduced `inlang check`.
5
+ */
6
+ export declare const INLANG_CLI_VERSION_RANGE = "^3.4.0";
7
+ export declare const CHECK_SCRIPT_NAME = "check:i18n";
8
+ /**
9
+ * Adds `@inlang/cli` to the devDependencies (if not present) and a
10
+ * `check:i18n` script that runs `inlang check` (if no script of that name
11
+ * exists).
12
+ */
13
+ export declare const addInlangCheck: CliStep<{
14
+ fs: typeof import("node:fs/promises");
15
+ logger: Logger;
16
+ projectPath: string;
17
+ root: string;
18
+ packageJsonPath: string;
19
+ }, unknown>;