@inlang/sdk 0.18.0 → 0.20.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.
- package/README.md +1 -1
- package/dist/adapter/solidAdapter.test.js +16 -15
- package/dist/createMessageLintReportsQuery.d.ts +2 -3
- package/dist/createMessageLintReportsQuery.d.ts.map +1 -1
- package/dist/createMessageLintReportsQuery.js +42 -21
- package/dist/createNodeishFsWithAbsolutePaths.d.ts +2 -2
- package/dist/createNodeishFsWithAbsolutePaths.d.ts.map +1 -1
- package/dist/createNodeishFsWithAbsolutePaths.js +4 -4
- package/dist/createNodeishFsWithAbsolutePaths.test.js +4 -4
- package/dist/createNodeishFsWithWatcher.d.ts +1 -1
- package/dist/createNodeishFsWithWatcher.d.ts.map +1 -1
- package/dist/createNodeishFsWithWatcher.js +6 -4
- package/dist/generateProjectId.d.ts +3 -0
- package/dist/generateProjectId.d.ts.map +1 -0
- package/dist/generateProjectId.js +11 -0
- package/dist/generateProjectId.test.d.ts +2 -0
- package/dist/generateProjectId.test.d.ts.map +1 -0
- package/dist/generateProjectId.test.js +18 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/isAbsolutePath.test.js +1 -1
- package/dist/listProjects.d.ts +5 -0
- package/dist/listProjects.d.ts.map +1 -0
- package/dist/listProjects.js +31 -0
- package/dist/listProjects.test.d.ts +2 -0
- package/dist/listProjects.test.d.ts.map +1 -0
- package/dist/listProjects.test.js +56 -0
- package/dist/loadProject.d.ts +6 -4
- package/dist/loadProject.d.ts.map +1 -1
- package/dist/loadProject.js +58 -22
- package/dist/loadProject.test.js +157 -75
- package/dist/migrations/migrateToDirectory.d.ts +10 -0
- package/dist/migrations/migrateToDirectory.d.ts.map +1 -0
- package/dist/migrations/migrateToDirectory.js +46 -0
- package/dist/migrations/migrateToDirectory.test.d.ts +2 -0
- package/dist/migrations/migrateToDirectory.test.d.ts.map +1 -0
- package/dist/migrations/migrateToDirectory.test.js +48 -0
- package/dist/resolve-modules/validateModuleSettings.test.js +1 -1
- package/package.json +57 -56
- package/src/adapter/solidAdapter.test.ts +16 -15
- package/src/createMessageLintReportsQuery.ts +57 -28
- package/src/createNodeishFsWithAbsolutePaths.test.ts +4 -4
- package/src/createNodeishFsWithAbsolutePaths.ts +5 -5
- package/src/createNodeishFsWithWatcher.ts +6 -4
- package/src/generateProjectId.test.ts +22 -0
- package/src/generateProjectId.ts +14 -0
- package/src/index.ts +1 -0
- package/src/isAbsolutePath.test.ts +1 -1
- package/src/listProjects.test.ts +69 -0
- package/src/listProjects.ts +39 -0
- package/src/loadProject.test.ts +182 -76
- package/src/loadProject.ts +77 -28
- package/src/migrations/migrateToDirectory.test.ts +54 -0
- package/src/migrations/migrateToDirectory.ts +59 -0
- package/src/resolve-modules/validateModuleSettings.test.ts +1 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { NodeishFilesystem } from "@lix-js/fs"
|
|
2
|
+
|
|
3
|
+
export const listProjects = async (
|
|
4
|
+
nodeishFs: NodeishFilesystem,
|
|
5
|
+
from: string
|
|
6
|
+
): Promise<Array<{ projectPath: string }>> => {
|
|
7
|
+
// !TODO: Remove this limit once we introduce caching
|
|
8
|
+
const recursionLimit = 5
|
|
9
|
+
|
|
10
|
+
const projects: Array<{ projectPath: string }> = []
|
|
11
|
+
|
|
12
|
+
async function searchDir(path: string, depth: number) {
|
|
13
|
+
if (depth > recursionLimit) {
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const files = await nodeishFs.readdir(path)
|
|
18
|
+
for (const file of files) {
|
|
19
|
+
const filePath = `${path}/${file}`
|
|
20
|
+
const stats = await nodeishFs.stat(filePath)
|
|
21
|
+
if (stats.isDirectory()) {
|
|
22
|
+
if (file === "node_modules") continue
|
|
23
|
+
if (file.endsWith(".inlang")) {
|
|
24
|
+
projects.push({ projectPath: filePath })
|
|
25
|
+
} else {
|
|
26
|
+
await searchDir(filePath, depth + 1)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
await searchDir(from, 0)
|
|
33
|
+
|
|
34
|
+
// remove double slashes
|
|
35
|
+
for (const project of projects) {
|
|
36
|
+
project.projectPath = project.projectPath.replace(/\/\//g, "/")
|
|
37
|
+
}
|
|
38
|
+
return projects
|
|
39
|
+
}
|
package/src/loadProject.test.ts
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
import { createNodeishMemoryFs, normalizePath } from "@lix-js/fs"
|
|
20
20
|
import { createMessage } from "./test-utilities/createMessage.js"
|
|
21
21
|
import { tryCatch } from "@inlang/result"
|
|
22
|
+
import { mockRepo } from "@lix-js/client"
|
|
22
23
|
|
|
23
24
|
// ------------------------------------------------------------------------------------------------
|
|
24
25
|
|
|
@@ -105,13 +106,52 @@ const _import: ImportFunction = async (name) =>
|
|
|
105
106
|
|
|
106
107
|
// ------------------------------------------------------------------------------------------------
|
|
107
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Dear Developers,
|
|
111
|
+
*
|
|
112
|
+
* Inlang projects (folders) are not like .vscode, .git, or .github folders. Treat em
|
|
113
|
+
* like files: they can be renamed and moved around.
|
|
114
|
+
*/
|
|
115
|
+
it("should throw if a project (path) does not have a name", async () => {
|
|
116
|
+
const fs = createNodeishMemoryFs()
|
|
117
|
+
const project = await tryCatch(() =>
|
|
118
|
+
loadProject({
|
|
119
|
+
projectPath: "/source-code/.inlang",
|
|
120
|
+
nodeishFs: fs,
|
|
121
|
+
_import,
|
|
122
|
+
})
|
|
123
|
+
)
|
|
124
|
+
expect(project.error).toBeInstanceOf(LoadProjectInvalidArgument)
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
it("should throw if a project path does not end with .inlang", async () => {
|
|
128
|
+
const fs = createNodeishMemoryFs()
|
|
129
|
+
|
|
130
|
+
const invalidPaths = [
|
|
131
|
+
"/source-code/frontend.inlang/settings",
|
|
132
|
+
"/source-code/frontend.inlang/settings.json",
|
|
133
|
+
"/source-code/frontend.inlang.md",
|
|
134
|
+
]
|
|
135
|
+
|
|
136
|
+
for (const invalidPath of invalidPaths) {
|
|
137
|
+
const project = await tryCatch(() =>
|
|
138
|
+
loadProject({
|
|
139
|
+
projectPath: invalidPath,
|
|
140
|
+
nodeishFs: fs,
|
|
141
|
+
_import,
|
|
142
|
+
})
|
|
143
|
+
)
|
|
144
|
+
expect(project.error).toBeInstanceOf(LoadProjectInvalidArgument)
|
|
145
|
+
}
|
|
146
|
+
})
|
|
147
|
+
|
|
108
148
|
describe("initialization", () => {
|
|
109
|
-
it("should throw if
|
|
149
|
+
it("should throw if projectPath is not an absolute path", async () => {
|
|
110
150
|
const fs = createNodeishMemoryFs()
|
|
111
151
|
|
|
112
152
|
const result = await tryCatch(() =>
|
|
113
153
|
loadProject({
|
|
114
|
-
|
|
154
|
+
projectPath: "relative/path",
|
|
115
155
|
nodeishFs: fs,
|
|
116
156
|
_import,
|
|
117
157
|
})
|
|
@@ -120,14 +160,79 @@ describe("initialization", () => {
|
|
|
120
160
|
expect(result.data).toBeUndefined()
|
|
121
161
|
})
|
|
122
162
|
|
|
163
|
+
it("should generate projectId on missing projectid", async () => {
|
|
164
|
+
const repo = await mockRepo()
|
|
165
|
+
|
|
166
|
+
const existing = await repo.nodeishFs
|
|
167
|
+
.readFile("/project.inlang/project_id", {
|
|
168
|
+
encoding: "utf-8",
|
|
169
|
+
})
|
|
170
|
+
.catch((error) => {
|
|
171
|
+
return { error }
|
|
172
|
+
})
|
|
173
|
+
|
|
174
|
+
// @ts-ignore
|
|
175
|
+
expect(existing.error.code).toBe("ENOENT")
|
|
176
|
+
|
|
177
|
+
const result = await tryCatch(() =>
|
|
178
|
+
loadProject({
|
|
179
|
+
projectPath: "/project.inlang",
|
|
180
|
+
nodeishFs: repo.nodeishFs,
|
|
181
|
+
repo,
|
|
182
|
+
_import,
|
|
183
|
+
})
|
|
184
|
+
)
|
|
185
|
+
|
|
186
|
+
const newId = await repo.nodeishFs
|
|
187
|
+
.readFile("/project.inlang/project_id", {
|
|
188
|
+
encoding: "utf-8",
|
|
189
|
+
})
|
|
190
|
+
.catch((error) => {
|
|
191
|
+
return { error }
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
expect(newId).toBe("7cd6c2b7cf12febf99496408917123fdfe158b6bc442914f5fb42aa74346bd50")
|
|
195
|
+
|
|
196
|
+
expect(result.error).toBeUndefined()
|
|
197
|
+
expect(result.data).toBeDefined()
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
it("should reuse projectId on existing projectid", async () => {
|
|
201
|
+
const repo = await mockRepo()
|
|
202
|
+
|
|
203
|
+
repo.nodeishFs.writeFile("/project.inlang/project_id", "testId")
|
|
204
|
+
|
|
205
|
+
const result = await tryCatch(() =>
|
|
206
|
+
loadProject({
|
|
207
|
+
projectPath: "/project.inlang",
|
|
208
|
+
nodeishFs: repo.nodeishFs,
|
|
209
|
+
repo,
|
|
210
|
+
_import,
|
|
211
|
+
})
|
|
212
|
+
)
|
|
213
|
+
|
|
214
|
+
const newId = await repo.nodeishFs
|
|
215
|
+
.readFile("/project.inlang/project_id", {
|
|
216
|
+
encoding: "utf-8",
|
|
217
|
+
})
|
|
218
|
+
.catch((error) => {
|
|
219
|
+
return { error }
|
|
220
|
+
})
|
|
221
|
+
|
|
222
|
+
expect(newId).toBe("testId")
|
|
223
|
+
|
|
224
|
+
expect(result.error).toBeUndefined()
|
|
225
|
+
expect(result.data).toBeDefined()
|
|
226
|
+
})
|
|
227
|
+
|
|
123
228
|
it("should resolve from a windows path", async () => {
|
|
124
229
|
const fs = createNodeishMemoryFs()
|
|
125
|
-
fs.mkdir("C:\\Users\\user\\project", { recursive: true })
|
|
126
|
-
fs.writeFile("C:\\Users\\user\\project
|
|
230
|
+
fs.mkdir("C:\\Users\\user\\project.inlang", { recursive: true })
|
|
231
|
+
fs.writeFile("C:\\Users\\user\\project.inlang\\settings.json", JSON.stringify(settings))
|
|
127
232
|
|
|
128
233
|
const result = await tryCatch(() =>
|
|
129
234
|
loadProject({
|
|
130
|
-
|
|
235
|
+
projectPath: "C:\\Users\\user\\project.inlang",
|
|
131
236
|
nodeishFs: fs,
|
|
132
237
|
_import,
|
|
133
238
|
})
|
|
@@ -143,7 +248,7 @@ describe("initialization", () => {
|
|
|
143
248
|
fs.mkdir("/user/project", { recursive: true })
|
|
144
249
|
|
|
145
250
|
const project = await loadProject({
|
|
146
|
-
|
|
251
|
+
projectPath: "/user/non-existend-project.inlang",
|
|
147
252
|
nodeishFs: fs,
|
|
148
253
|
_import,
|
|
149
254
|
})
|
|
@@ -153,11 +258,11 @@ describe("initialization", () => {
|
|
|
153
258
|
|
|
154
259
|
it("should return an error if settings file is not a valid JSON", async () => {
|
|
155
260
|
const fs = await createNodeishMemoryFs()
|
|
156
|
-
await fs.mkdir("/user/project", { recursive: true })
|
|
157
|
-
await fs.writeFile("/user/project
|
|
261
|
+
await fs.mkdir("/user/project.inlang", { recursive: true })
|
|
262
|
+
await fs.writeFile("/user/project.inlang/settings.json", "invalid json")
|
|
158
263
|
|
|
159
264
|
const project = await loadProject({
|
|
160
|
-
|
|
265
|
+
projectPath: "/user/project.inlang",
|
|
161
266
|
nodeishFs: fs,
|
|
162
267
|
_import,
|
|
163
268
|
})
|
|
@@ -167,11 +272,11 @@ describe("initialization", () => {
|
|
|
167
272
|
|
|
168
273
|
it("should return an error if settings file is does not match schema", async () => {
|
|
169
274
|
const fs = await createNodeishMemoryFs()
|
|
170
|
-
await fs.mkdir("/user/project", { recursive: true })
|
|
171
|
-
await fs.writeFile("/user/project
|
|
275
|
+
await fs.mkdir("/user/project.inlang", { recursive: true })
|
|
276
|
+
await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify({}))
|
|
172
277
|
|
|
173
278
|
const project = await loadProject({
|
|
174
|
-
|
|
279
|
+
projectPath: "/user/project.inlang",
|
|
175
280
|
nodeishFs: fs,
|
|
176
281
|
_import,
|
|
177
282
|
})
|
|
@@ -181,10 +286,10 @@ describe("initialization", () => {
|
|
|
181
286
|
|
|
182
287
|
it("should return the parsed settings", async () => {
|
|
183
288
|
const fs = await createNodeishMemoryFs()
|
|
184
|
-
await fs.mkdir("/user/project", { recursive: true })
|
|
185
|
-
await fs.writeFile("/user/project
|
|
289
|
+
await fs.mkdir("/user/project.inlang", { recursive: true })
|
|
290
|
+
await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
|
|
186
291
|
const project = await loadProject({
|
|
187
|
-
|
|
292
|
+
projectPath: "/user/project.inlang",
|
|
188
293
|
nodeishFs: fs,
|
|
189
294
|
_import,
|
|
190
295
|
})
|
|
@@ -195,16 +300,16 @@ describe("initialization", () => {
|
|
|
195
300
|
it("should not re-write the settings to disk when initializing", async () => {
|
|
196
301
|
const fs = await createNodeishMemoryFs()
|
|
197
302
|
const settingsWithDeifferentFormatting = JSON.stringify(settings, undefined, 4)
|
|
198
|
-
await fs.mkdir("/user/project", { recursive: true })
|
|
199
|
-
await fs.writeFile("/user/project
|
|
303
|
+
await fs.mkdir("/user/project.inlang", { recursive: true })
|
|
304
|
+
await fs.writeFile("/user/project.inlang/settings.json", settingsWithDeifferentFormatting)
|
|
200
305
|
|
|
201
306
|
const project = await loadProject({
|
|
202
|
-
|
|
307
|
+
projectPath: "/user/project.inlang",
|
|
203
308
|
nodeishFs: fs,
|
|
204
309
|
_import,
|
|
205
310
|
})
|
|
206
311
|
|
|
207
|
-
const settingsOnDisk = await fs.readFile("/user/project
|
|
312
|
+
const settingsOnDisk = await fs.readFile("/user/project.inlang/settings.json", {
|
|
208
313
|
encoding: "utf-8",
|
|
209
314
|
})
|
|
210
315
|
expect(settingsOnDisk).toBe(settingsWithDeifferentFormatting)
|
|
@@ -213,7 +318,7 @@ describe("initialization", () => {
|
|
|
213
318
|
// TODO: how can we await `setsettings` correctly
|
|
214
319
|
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
215
320
|
|
|
216
|
-
const newsettingsOnDisk = await fs.readFile("/user/project
|
|
321
|
+
const newsettingsOnDisk = await fs.readFile("/user/project.inlang/settings.json", {
|
|
217
322
|
encoding: "utf-8",
|
|
218
323
|
})
|
|
219
324
|
expect(newsettingsOnDisk).not.toBe(settingsWithDeifferentFormatting)
|
|
@@ -228,11 +333,11 @@ describe("initialization", () => {
|
|
|
228
333
|
} satisfies InlangModule)
|
|
229
334
|
|
|
230
335
|
const fs = createNodeishMemoryFs()
|
|
231
|
-
await fs.mkdir("/user/project", { recursive: true })
|
|
232
|
-
await fs.writeFile("/user/project
|
|
336
|
+
await fs.mkdir("/user/project.inlang", { recursive: true })
|
|
337
|
+
await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
|
|
233
338
|
|
|
234
339
|
const project = await loadProject({
|
|
235
|
-
|
|
340
|
+
projectPath: "/user/project.inlang",
|
|
236
341
|
nodeishFs: fs,
|
|
237
342
|
_import: $badImport,
|
|
238
343
|
})
|
|
@@ -261,10 +366,10 @@ describe("functionality", () => {
|
|
|
261
366
|
describe("settings", () => {
|
|
262
367
|
it("should return the settings", async () => {
|
|
263
368
|
const fs = await createNodeishMemoryFs()
|
|
264
|
-
await fs.mkdir("/user/project", { recursive: true })
|
|
265
|
-
await fs.writeFile("/user/project
|
|
369
|
+
await fs.mkdir("/user/project.inlang", { recursive: true })
|
|
370
|
+
await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
|
|
266
371
|
const project = await loadProject({
|
|
267
|
-
|
|
372
|
+
projectPath: "/user/project.inlang",
|
|
268
373
|
nodeishFs: fs,
|
|
269
374
|
_import,
|
|
270
375
|
})
|
|
@@ -274,10 +379,10 @@ describe("functionality", () => {
|
|
|
274
379
|
|
|
275
380
|
it("should set a new settings", async () => {
|
|
276
381
|
const fs = await createNodeishMemoryFs()
|
|
277
|
-
await fs.mkdir("/user/project", { recursive: true })
|
|
278
|
-
await fs.writeFile("/user/project
|
|
382
|
+
await fs.mkdir("/user/project.inlang", { recursive: true })
|
|
383
|
+
await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
|
|
279
384
|
const project = await loadProject({
|
|
280
|
-
|
|
385
|
+
projectPath: "/user/project.inlang",
|
|
281
386
|
nodeishFs: fs,
|
|
282
387
|
_import,
|
|
283
388
|
})
|
|
@@ -298,12 +403,12 @@ describe("functionality", () => {
|
|
|
298
403
|
})
|
|
299
404
|
|
|
300
405
|
describe("setSettings", () => {
|
|
301
|
-
it("should fail if settings
|
|
406
|
+
it("should fail if settings are not valid", async () => {
|
|
302
407
|
const fs = await createNodeishMemoryFs()
|
|
303
|
-
await fs.mkdir("/user/project", { recursive: true })
|
|
304
|
-
await fs.writeFile("/user/project
|
|
408
|
+
await fs.mkdir("/user/project.inlang", { recursive: true })
|
|
409
|
+
await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
|
|
305
410
|
const project = await loadProject({
|
|
306
|
-
|
|
411
|
+
projectPath: "/user/project.inlang",
|
|
307
412
|
nodeishFs: fs,
|
|
308
413
|
_import,
|
|
309
414
|
})
|
|
@@ -315,7 +420,7 @@ describe("functionality", () => {
|
|
|
315
420
|
|
|
316
421
|
it("should throw an error if sourceLanguageTag is not in languageTags", async () => {
|
|
317
422
|
const fs = await createNodeishMemoryFs()
|
|
318
|
-
await fs.mkdir("/user/project", { recursive: true })
|
|
423
|
+
await fs.mkdir("/user/project.inlang", { recursive: true })
|
|
319
424
|
|
|
320
425
|
const settings: ProjectSettings = {
|
|
321
426
|
sourceLanguageTag: "en",
|
|
@@ -323,10 +428,10 @@ describe("functionality", () => {
|
|
|
323
428
|
modules: [],
|
|
324
429
|
}
|
|
325
430
|
|
|
326
|
-
await fs.writeFile("/user/project
|
|
431
|
+
await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
|
|
327
432
|
|
|
328
433
|
const project = await loadProject({
|
|
329
|
-
|
|
434
|
+
projectPath: "/user/project.inlang",
|
|
330
435
|
nodeishFs: fs,
|
|
331
436
|
_import,
|
|
332
437
|
})
|
|
@@ -337,25 +442,25 @@ describe("functionality", () => {
|
|
|
337
442
|
|
|
338
443
|
it("should write settings to disk", async () => {
|
|
339
444
|
const fs = await createNodeishMemoryFs()
|
|
340
|
-
await fs.mkdir("/user/project", { recursive: true })
|
|
341
|
-
await fs.writeFile("/user/project
|
|
445
|
+
await fs.mkdir("/user/project.inlang", { recursive: true })
|
|
446
|
+
await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
|
|
342
447
|
const project = await loadProject({
|
|
343
|
-
|
|
448
|
+
projectPath: "/user/project.inlang",
|
|
344
449
|
nodeishFs: fs,
|
|
345
450
|
_import,
|
|
346
451
|
})
|
|
347
452
|
|
|
348
|
-
const before = await fs.readFile("/user/project
|
|
453
|
+
const before = await fs.readFile("/user/project.inlang/settings.json", { encoding: "utf-8" })
|
|
349
454
|
expect(before).toBeDefined()
|
|
350
455
|
|
|
351
|
-
const result = project.setSettings({ ...settings, languageTags: ["en"] })
|
|
456
|
+
const result = project.setSettings({ ...settings, languageTags: ["en", "nl", "de"] })
|
|
352
457
|
expect(result.data).toBeUndefined()
|
|
353
458
|
expect(result.error).toBeUndefined()
|
|
354
459
|
|
|
355
460
|
// TODO: how to wait for fs.writeFile to finish?
|
|
356
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
461
|
+
await new Promise((resolve) => setTimeout(resolve, 50))
|
|
357
462
|
|
|
358
|
-
const after = await fs.readFile("/user/project
|
|
463
|
+
const after = await fs.readFile("/user/project.inlang/settings.json", { encoding: "utf-8" })
|
|
359
464
|
expect(after).toBeDefined()
|
|
360
465
|
expect(after).not.toBe(before)
|
|
361
466
|
})
|
|
@@ -369,10 +474,10 @@ describe("functionality", () => {
|
|
|
369
474
|
languageTags: ["en"],
|
|
370
475
|
modules: ["plugin.js", "lintRule.js"],
|
|
371
476
|
}
|
|
372
|
-
await fs.mkdir("/user/project", { recursive: true })
|
|
373
|
-
await fs.writeFile("/user/project
|
|
477
|
+
await fs.mkdir("/user/project.inlang", { recursive: true })
|
|
478
|
+
await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
|
|
374
479
|
const project = await loadProject({
|
|
375
|
-
|
|
480
|
+
projectPath: "/user/project.inlang",
|
|
376
481
|
nodeishFs: fs,
|
|
377
482
|
_import,
|
|
378
483
|
})
|
|
@@ -402,11 +507,11 @@ describe("functionality", () => {
|
|
|
402
507
|
modules: ["plugin.js", "lintRule.js"],
|
|
403
508
|
}
|
|
404
509
|
|
|
405
|
-
await fs.mkdir("/user/project", { recursive: true })
|
|
406
|
-
await fs.writeFile("/user/project
|
|
510
|
+
await fs.mkdir("/user/project.inlang", { recursive: true })
|
|
511
|
+
await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
|
|
407
512
|
|
|
408
513
|
const project = await loadProject({
|
|
409
|
-
|
|
514
|
+
projectPath: "/user/project.inlang",
|
|
410
515
|
nodeishFs: fs,
|
|
411
516
|
_import,
|
|
412
517
|
})
|
|
@@ -437,9 +542,9 @@ describe("functionality", () => {
|
|
|
437
542
|
saveMessages: () => undefined,
|
|
438
543
|
}
|
|
439
544
|
const fs = await createNodeishMemoryFs()
|
|
440
|
-
await fs.mkdir("/user/project", { recursive: true })
|
|
545
|
+
await fs.mkdir("/user/project.inlang", { recursive: true })
|
|
441
546
|
await fs.writeFile(
|
|
442
|
-
"/user/project
|
|
547
|
+
"/user/project.inlang/settings.json",
|
|
443
548
|
JSON.stringify({
|
|
444
549
|
sourceLanguageTag: "en",
|
|
445
550
|
languageTags: ["en"],
|
|
@@ -453,7 +558,7 @@ describe("functionality", () => {
|
|
|
453
558
|
} satisfies InlangModule
|
|
454
559
|
}
|
|
455
560
|
const project = await loadProject({
|
|
456
|
-
|
|
561
|
+
projectPath: "/user/project.inlang",
|
|
457
562
|
nodeishFs: fs,
|
|
458
563
|
_import,
|
|
459
564
|
})
|
|
@@ -488,9 +593,9 @@ describe("functionality", () => {
|
|
|
488
593
|
saveMessages: () => undefined,
|
|
489
594
|
}
|
|
490
595
|
const fs = await createNodeishMemoryFs()
|
|
491
|
-
await fs.mkdir("/user/project", { recursive: true })
|
|
596
|
+
await fs.mkdir("/user/project.inlang", { recursive: true })
|
|
492
597
|
await fs.writeFile(
|
|
493
|
-
"/user/project
|
|
598
|
+
"/user/project.inlang/settings.json",
|
|
494
599
|
JSON.stringify({
|
|
495
600
|
sourceLanguageTag: "en",
|
|
496
601
|
languageTags: ["en"],
|
|
@@ -504,7 +609,7 @@ describe("functionality", () => {
|
|
|
504
609
|
}
|
|
505
610
|
|
|
506
611
|
const project = await loadProject({
|
|
507
|
-
|
|
612
|
+
projectPath: "/user/project.inlang",
|
|
508
613
|
nodeishFs: fs,
|
|
509
614
|
_import,
|
|
510
615
|
})
|
|
@@ -520,10 +625,10 @@ describe("functionality", () => {
|
|
|
520
625
|
describe("errors", () => {
|
|
521
626
|
it("should return the errors", async () => {
|
|
522
627
|
const fs = await createNodeishMemoryFs()
|
|
523
|
-
await fs.mkdir("/user/project", { recursive: true })
|
|
524
|
-
await fs.writeFile("/user/project
|
|
628
|
+
await fs.mkdir("/user/project.inlang", { recursive: true })
|
|
629
|
+
await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
|
|
525
630
|
const project = await loadProject({
|
|
526
|
-
|
|
631
|
+
projectPath: "/user/project.inlang",
|
|
527
632
|
nodeishFs: fs,
|
|
528
633
|
_import,
|
|
529
634
|
})
|
|
@@ -536,10 +641,10 @@ describe("functionality", () => {
|
|
|
536
641
|
describe("customApi", () => {
|
|
537
642
|
it("should return the app specific api", async () => {
|
|
538
643
|
const fs = await createNodeishMemoryFs()
|
|
539
|
-
await fs.mkdir("/user/project", { recursive: true })
|
|
540
|
-
await fs.writeFile("/user/project
|
|
644
|
+
await fs.mkdir("/user/project.inlang", { recursive: true })
|
|
645
|
+
await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
|
|
541
646
|
const project = await loadProject({
|
|
542
|
-
|
|
647
|
+
projectPath: "/user/project.inlang",
|
|
543
648
|
nodeishFs: fs,
|
|
544
649
|
_import,
|
|
545
650
|
})
|
|
@@ -553,10 +658,10 @@ describe("functionality", () => {
|
|
|
553
658
|
describe("messages", () => {
|
|
554
659
|
it("should return the messages", async () => {
|
|
555
660
|
const fs = await createNodeishMemoryFs()
|
|
556
|
-
await fs.mkdir("/user/project", { recursive: true })
|
|
557
|
-
await fs.writeFile("/user/project
|
|
661
|
+
await fs.mkdir("/user/project.inlang", { recursive: true })
|
|
662
|
+
await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
|
|
558
663
|
const project = await loadProject({
|
|
559
|
-
|
|
664
|
+
projectPath: "/user/project.inlang",
|
|
560
665
|
nodeishFs: fs,
|
|
561
666
|
_import,
|
|
562
667
|
})
|
|
@@ -578,8 +683,8 @@ describe("functionality", () => {
|
|
|
578
683
|
},
|
|
579
684
|
}
|
|
580
685
|
|
|
581
|
-
await fs.mkdir("/user/project", { recursive: true })
|
|
582
|
-
await fs.writeFile("/user/project
|
|
686
|
+
await fs.mkdir("/user/project.inlang", { recursive: true })
|
|
687
|
+
await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
|
|
583
688
|
|
|
584
689
|
await fs.mkdir("./resources")
|
|
585
690
|
|
|
@@ -601,7 +706,7 @@ describe("functionality", () => {
|
|
|
601
706
|
}
|
|
602
707
|
|
|
603
708
|
const project = await loadProject({
|
|
604
|
-
|
|
709
|
+
projectPath: "/user/project.inlang",
|
|
605
710
|
nodeishFs: fs,
|
|
606
711
|
_import,
|
|
607
712
|
})
|
|
@@ -652,7 +757,6 @@ describe("functionality", () => {
|
|
|
652
757
|
},
|
|
653
758
|
],
|
|
654
759
|
},
|
|
655
|
-
|
|
656
760
|
{
|
|
657
761
|
languageTag: "de",
|
|
658
762
|
match: [],
|
|
@@ -756,7 +860,8 @@ describe("functionality", () => {
|
|
|
756
860
|
},
|
|
757
861
|
}
|
|
758
862
|
|
|
759
|
-
await fs.
|
|
863
|
+
await fs.mkdir("./project.inlang", { recursive: true })
|
|
864
|
+
await fs.writeFile("./project.inlang/settings.json", JSON.stringify(settings))
|
|
760
865
|
|
|
761
866
|
const mockSaveFn = vi.fn()
|
|
762
867
|
|
|
@@ -780,7 +885,7 @@ describe("functionality", () => {
|
|
|
780
885
|
}
|
|
781
886
|
|
|
782
887
|
const project = await loadProject({
|
|
783
|
-
|
|
888
|
+
projectPath: "/project.inlang",
|
|
784
889
|
nodeishFs: fs,
|
|
785
890
|
_import,
|
|
786
891
|
})
|
|
@@ -800,7 +905,7 @@ describe("functionality", () => {
|
|
|
800
905
|
await fs.mkdir("/user/project", { recursive: true })
|
|
801
906
|
await fs.writeFile("/user/project/project.inlang.json", JSON.stringify(settings))
|
|
802
907
|
const project = await loadProject({
|
|
803
|
-
|
|
908
|
+
projectPath: "/user/project/project.inlang.json",
|
|
804
909
|
nodeishFs: fs,
|
|
805
910
|
_import,
|
|
806
911
|
})
|
|
@@ -819,10 +924,10 @@ describe("functionality", () => {
|
|
|
819
924
|
modules: ["lintRule.js"],
|
|
820
925
|
}
|
|
821
926
|
const fs = createNodeishMemoryFs()
|
|
822
|
-
await fs.mkdir("/user/project", { recursive: true })
|
|
823
|
-
await fs.writeFile("/user/project
|
|
927
|
+
await fs.mkdir("/user/project.inlang", { recursive: true })
|
|
928
|
+
await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
|
|
824
929
|
const project = await loadProject({
|
|
825
|
-
|
|
930
|
+
projectPath: "/user/project.inlang",
|
|
826
931
|
nodeishFs: fs,
|
|
827
932
|
_import: async () => ({
|
|
828
933
|
default: mockMessageLintRule,
|
|
@@ -884,11 +989,12 @@ describe("functionality", () => {
|
|
|
884
989
|
},
|
|
885
990
|
}
|
|
886
991
|
|
|
887
|
-
await fs.
|
|
992
|
+
await fs.mkdir("./project.inlang", { recursive: true })
|
|
993
|
+
await fs.writeFile("./project.inlang/settings.json", JSON.stringify(settings))
|
|
888
994
|
|
|
889
995
|
// establish watcher
|
|
890
996
|
const project = await loadProject({
|
|
891
|
-
|
|
997
|
+
projectPath: normalizePath("/project.inlang"),
|
|
892
998
|
nodeishFs: fs,
|
|
893
999
|
_import: async () => ({
|
|
894
1000
|
default: mockMessageFormatPlugin,
|