@inlang/sdk 0.23.0 → 0.24.1

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.
@@ -4,6 +4,7 @@ import { createEffect, from, createRoot } from "../reactivity/solid.js";
4
4
  import { solidAdapter } from "./solidAdapter.js";
5
5
  import { loadProject } from "../loadProject.js";
6
6
  import { createNodeishMemoryFs } from "@lix-js/fs";
7
+ import { openRepository } from "@lix-js/client";
7
8
  // ------------------------------------------------------------------------------------------------
8
9
  const config = {
9
10
  sourceLanguageTag: "en",
@@ -74,9 +75,10 @@ describe("config", () => {
74
75
  const fs = createNodeishMemoryFs();
75
76
  await fs.mkdir("/user/project.inlang", { recursive: true });
76
77
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(config));
78
+ const repo = await openRepository("file://", { nodeishFs: fs });
77
79
  const project = solidAdapter(await loadProject({
78
80
  projectPath: "/user/project.inlang",
79
- nodeishFs: fs,
81
+ repo,
80
82
  _import: $import,
81
83
  }), { from });
82
84
  let counter = 0;
@@ -98,9 +100,10 @@ describe("installed", () => {
98
100
  const fs = createNodeishMemoryFs();
99
101
  await fs.mkdir("/user/project.inlang", { recursive: true });
100
102
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(config));
103
+ const repo = await openRepository("file://", { nodeishFs: fs });
101
104
  const project = solidAdapter(await loadProject({
102
105
  projectPath: "/user/project.inlang",
103
- nodeishFs: fs,
106
+ repo,
104
107
  _import: $import,
105
108
  }), { from });
106
109
  let counterPlugins = 0;
@@ -151,9 +154,10 @@ describe("messages", () => {
151
154
  const mockImport = async () => ({ default: mockPlugin });
152
155
  await fs.mkdir("/user/project.inlang.inlang", { recursive: true });
153
156
  await fs.writeFile("/user/project.inlang.inlang/settings.json", JSON.stringify(mockConfig));
157
+ const repo = await openRepository("file://", { nodeishFs: fs });
154
158
  const project = solidAdapter(await loadProject({
155
159
  projectPath: "/user/project.inlang.inlang",
156
- nodeishFs: fs,
160
+ repo,
157
161
  _import: mockImport,
158
162
  }), { from });
159
163
  let counter = 0;
@@ -172,9 +176,10 @@ describe("messages", () => {
172
176
  const fs = createNodeishMemoryFs();
173
177
  await fs.mkdir("/user/project.inlang.inlang", { recursive: true });
174
178
  await fs.writeFile("/user/project.inlang.inlang/settings.json", JSON.stringify(config));
179
+ const repo = await openRepository("file://", { nodeishFs: fs });
175
180
  const project = solidAdapter(await loadProject({
176
181
  projectPath: "/user/project.inlang.inlang",
177
- nodeishFs: fs,
182
+ repo,
178
183
  _import: $import,
179
184
  }), { from });
180
185
  let counter = 0;
@@ -218,9 +223,10 @@ describe("lint", () => {
218
223
  const fs = createNodeishMemoryFs();
219
224
  await fs.mkdir("./project.inlang", { recursive: true });
220
225
  await fs.writeFile("./project.inlang/settings.json", JSON.stringify(config));
226
+ const repo = await openRepository("file://", { nodeishFs: fs });
221
227
  const project = solidAdapter(await loadProject({
222
228
  projectPath: "./project.inlang",
223
- nodeishFs: fs,
229
+ repo,
224
230
  _import: $import,
225
231
  }), { from });
226
232
  let counter = 0;
@@ -245,9 +251,10 @@ describe("lint", () => {
245
251
  await createRoot(async () => {
246
252
  const fs = createNodeishMemoryFs();
247
253
  await fs.writeFile("./project.config.json", JSON.stringify(config));
254
+ const repo = await openRepository("file://", { nodeishFs: fs });
248
255
  const project = solidAdapter(await loadProject({
249
256
  projectPath: "./project.config.json",
250
- nodeishFs: fs,
257
+ repo,
251
258
  _import: $import,
252
259
  }), { from });
253
260
  let counter = 0;
@@ -5,10 +5,12 @@ import { LoadProjectInvalidArgument, ProjectSettingsFileJSONSyntaxError, Project
5
5
  import { createNodeishMemoryFs, normalizePath } from "@lix-js/fs";
6
6
  import { createMessage } from "./test-utilities/createMessage.js";
7
7
  import { tryCatch } from "@inlang/result";
8
- import { mockRepo } from "@lix-js/client";
8
+ import { mockRepo, openRepository } from "@lix-js/client";
9
9
  import {} from "@lix-js/fs";
10
10
  // eslint-disable-next-line no-restricted-imports -- test
11
11
  import { readFileSync } from "node:fs";
12
+ // eslint-disable-next-line no-restricted-imports -- test
13
+ import { resolve } from "node:path";
12
14
  // ------------------------------------------------------------------------------------------------
13
15
  const getValue = (subscribable) => {
14
16
  let value;
@@ -83,6 +85,13 @@ const mockMessageLintRule = {
83
85
  const _import = async (name) => ({
84
86
  default: name === "plugin.js" ? mockPlugin : mockMessageLintRule,
85
87
  });
88
+ async function openCiTestRepo() {
89
+ return await mockRepo({
90
+ fromSnapshot: JSON.parse(readFileSync(resolve(__dirname, "../mocks/ci-test-repo-no-shallow.json"), {
91
+ encoding: "utf-8",
92
+ })),
93
+ });
94
+ }
86
95
  // ------------------------------------------------------------------------------------------------
87
96
  /**
88
97
  * Dear Developers,
@@ -92,15 +101,17 @@ const _import = async (name) => ({
92
101
  */
93
102
  it("should throw if a project (path) does not have a name", async () => {
94
103
  const fs = createNodeishMemoryFs();
104
+ const repo = await openRepository("file://", { nodeishFs: fs });
95
105
  const project = await tryCatch(() => loadProject({
96
106
  projectPath: "/source-code/.inlang",
97
- nodeishFs: fs,
107
+ repo,
98
108
  _import,
99
109
  }));
100
110
  expect(project.error).toBeInstanceOf(LoadProjectInvalidArgument);
101
111
  });
102
112
  it("should throw if a project path does not end with .inlang", async () => {
103
113
  const fs = createNodeishMemoryFs();
114
+ const repo = await openRepository("file://", { nodeishFs: fs });
104
115
  const invalidPaths = [
105
116
  "/source-code/frontend.inlang/settings",
106
117
  "/source-code/frontend.inlang/settings.json",
@@ -109,7 +120,7 @@ it("should throw if a project path does not end with .inlang", async () => {
109
120
  for (const invalidPath of invalidPaths) {
110
121
  const project = await tryCatch(() => loadProject({
111
122
  projectPath: invalidPath,
112
- nodeishFs: fs,
123
+ repo,
113
124
  _import,
114
125
  }));
115
126
  expect(project.error).toBeInstanceOf(LoadProjectInvalidArgument);
@@ -118,17 +129,17 @@ it("should throw if a project path does not end with .inlang", async () => {
118
129
  describe("initialization", () => {
119
130
  it("should throw if projectPath is not an absolute path", async () => {
120
131
  const fs = createNodeishMemoryFs();
132
+ const repo = await openRepository("file://", { nodeishFs: fs });
121
133
  const result = await tryCatch(() => loadProject({
122
134
  projectPath: "relative/path",
123
- nodeishFs: fs,
135
+ repo,
124
136
  _import,
125
137
  }));
126
138
  expect(result.error).toBeInstanceOf(LoadProjectInvalidArgument);
127
139
  expect(result.data).toBeUndefined();
128
140
  });
129
141
  it("should generate projectId on missing projectid", async () => {
130
- const ciTestRepo = JSON.parse(readFileSync("./mocks/ci-test-repo-no-shallow.json", { encoding: "utf-8" }));
131
- const repo = await mockRepo({ fromSnapshot: ciTestRepo });
142
+ const repo = await openCiTestRepo();
132
143
  const existing = await repo.nodeishFs
133
144
  .readFile("/project.inlang/project_id", {
134
145
  encoding: "utf-8",
@@ -150,13 +161,12 @@ describe("initialization", () => {
150
161
  .catch((error) => {
151
162
  return { error };
152
163
  });
153
- expect(newId).toBe("e8c61726bc2f437ec6a260abb632b3c59195059b60031e648b5afbafa7f3d79a");
164
+ expect(newId).toBe("aef225403be8b526dfb492a4617fd59d8181e8fef2c7f4aff56ab299046e36ed");
154
165
  expect(result.error).toBeUndefined();
155
166
  expect(result.data).toBeDefined();
156
167
  });
157
168
  it("should reuse projectId on existing projectid", async () => {
158
- const ciTestRepo = JSON.parse(readFileSync("./mocks/ci-test-repo-no-shallow.json", { encoding: "utf-8" }));
159
- const repo = await mockRepo({ fromSnapshot: ciTestRepo });
169
+ const repo = await openCiTestRepo();
160
170
  repo.nodeishFs.writeFile("/project.inlang/project_id", "testId");
161
171
  const result = await tryCatch(() => loadProject({
162
172
  projectPath: "/project.inlang",
@@ -178,9 +188,10 @@ describe("initialization", () => {
178
188
  const fs = createNodeishMemoryFs();
179
189
  fs.mkdir("C:\\Users\\user\\project.inlang", { recursive: true });
180
190
  fs.writeFile("C:\\Users\\user\\project.inlang\\settings.json", JSON.stringify(settings));
191
+ const repo = await openRepository("file://", { nodeishFs: fs });
181
192
  const result = await tryCatch(() => loadProject({
182
193
  projectPath: "C:\\Users\\user\\project.inlang",
183
- nodeishFs: fs,
194
+ repo,
184
195
  _import,
185
196
  }));
186
197
  expect(result.error).toBeUndefined();
@@ -190,9 +201,10 @@ describe("initialization", () => {
190
201
  it("should return an error if settings file is not found", async () => {
191
202
  const fs = createNodeishMemoryFs();
192
203
  fs.mkdir("/user/project", { recursive: true });
204
+ const repo = await openRepository("file://", { nodeishFs: fs });
193
205
  const project = await loadProject({
194
206
  projectPath: "/user/non-existend-project.inlang",
195
- nodeishFs: fs,
207
+ repo,
196
208
  _import,
197
209
  });
198
210
  expect(project.errors()[0]).toBeInstanceOf(ProjectSettingsFileNotFoundError);
@@ -201,9 +213,10 @@ describe("initialization", () => {
201
213
  const fs = await createNodeishMemoryFs();
202
214
  await fs.mkdir("/user/project.inlang", { recursive: true });
203
215
  await fs.writeFile("/user/project.inlang/settings.json", "invalid json");
216
+ const repo = await openRepository("file://", { nodeishFs: fs });
204
217
  const project = await loadProject({
205
218
  projectPath: "/user/project.inlang",
206
- nodeishFs: fs,
219
+ repo,
207
220
  _import,
208
221
  });
209
222
  expect(project.errors()[0]).toBeInstanceOf(ProjectSettingsFileJSONSyntaxError);
@@ -212,9 +225,10 @@ describe("initialization", () => {
212
225
  const fs = await createNodeishMemoryFs();
213
226
  await fs.mkdir("/user/project.inlang", { recursive: true });
214
227
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify({}));
228
+ const repo = await openRepository("file://", { nodeishFs: fs });
215
229
  const project = await loadProject({
216
230
  projectPath: "/user/project.inlang",
217
- nodeishFs: fs,
231
+ repo,
218
232
  _import,
219
233
  });
220
234
  expect(project.errors()[0]).toBeInstanceOf(ProjectSettingsInvalidError);
@@ -223,9 +237,10 @@ describe("initialization", () => {
223
237
  const fs = await createNodeishMemoryFs();
224
238
  await fs.mkdir("/user/project.inlang", { recursive: true });
225
239
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings));
240
+ const repo = await openRepository("file://", { nodeishFs: fs });
226
241
  const project = await loadProject({
227
242
  projectPath: "/user/project.inlang",
228
- nodeishFs: fs,
243
+ repo,
229
244
  _import,
230
245
  });
231
246
  expect(project.settings()).toStrictEqual(settings);
@@ -235,9 +250,10 @@ describe("initialization", () => {
235
250
  const settingsWithDeifferentFormatting = JSON.stringify(settings, undefined, 4);
236
251
  await fs.mkdir("/user/project.inlang", { recursive: true });
237
252
  await fs.writeFile("/user/project.inlang/settings.json", settingsWithDeifferentFormatting);
253
+ const repo = await openRepository("file://", { nodeishFs: fs });
238
254
  const project = await loadProject({
239
255
  projectPath: "/user/project.inlang",
240
- nodeishFs: fs,
256
+ repo,
241
257
  _import,
242
258
  });
243
259
  const settingsOnDisk = await fs.readFile("/user/project.inlang/settings.json", {
@@ -261,9 +277,10 @@ describe("initialization", () => {
261
277
  const fs = createNodeishMemoryFs();
262
278
  await fs.mkdir("/user/project.inlang", { recursive: true });
263
279
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings));
280
+ const repo = await openRepository("file://", { nodeishFs: fs });
264
281
  const project = await loadProject({
265
282
  projectPath: "/user/project.inlang",
266
- nodeishFs: fs,
283
+ repo,
267
284
  _import: $badImport,
268
285
  });
269
286
  expect(project.errors()).not.toHaveLength(0);
@@ -289,9 +306,10 @@ describe("functionality", () => {
289
306
  const fs = await createNodeishMemoryFs();
290
307
  await fs.mkdir("/user/project.inlang", { recursive: true });
291
308
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings));
309
+ const repo = await openRepository("file://", { nodeishFs: fs });
292
310
  const project = await loadProject({
293
311
  projectPath: "/user/project.inlang",
294
- nodeishFs: fs,
312
+ repo,
295
313
  _import,
296
314
  });
297
315
  expect(getValue(project.settings)).toStrictEqual(settings);
@@ -300,9 +318,10 @@ describe("functionality", () => {
300
318
  const fs = await createNodeishMemoryFs();
301
319
  await fs.mkdir("/user/project.inlang", { recursive: true });
302
320
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings));
321
+ const repo = await openRepository("file://", { nodeishFs: fs });
303
322
  const project = await loadProject({
304
323
  projectPath: "/user/project.inlang",
305
- nodeishFs: fs,
324
+ repo,
306
325
  _import,
307
326
  });
308
327
  expect(project.settings()).toStrictEqual(settings);
@@ -322,9 +341,10 @@ describe("functionality", () => {
322
341
  const fs = await createNodeishMemoryFs();
323
342
  await fs.mkdir("/user/project.inlang", { recursive: true });
324
343
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings));
344
+ const repo = await openRepository("file://", { nodeishFs: fs });
325
345
  const project = await loadProject({
326
346
  projectPath: "/user/project.inlang",
327
- nodeishFs: fs,
347
+ repo,
328
348
  _import,
329
349
  });
330
350
  const result = project.setSettings({});
@@ -340,9 +360,10 @@ describe("functionality", () => {
340
360
  modules: [],
341
361
  };
342
362
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings));
363
+ const repo = await openRepository("file://", { nodeishFs: fs });
343
364
  const project = await loadProject({
344
365
  projectPath: "/user/project.inlang",
345
- nodeishFs: fs,
366
+ repo,
346
367
  _import,
347
368
  });
348
369
  expect(project.errors()).toHaveLength(1);
@@ -352,9 +373,10 @@ describe("functionality", () => {
352
373
  const fs = await createNodeishMemoryFs();
353
374
  await fs.mkdir("/user/project.inlang", { recursive: true });
354
375
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings));
376
+ const repo = await openRepository("file://", { nodeishFs: fs });
355
377
  const project = await loadProject({
356
378
  projectPath: "/user/project.inlang",
357
- nodeishFs: fs,
379
+ repo,
358
380
  _import,
359
381
  });
360
382
  const before = await fs.readFile("/user/project.inlang/settings.json", { encoding: "utf-8" });
@@ -379,9 +401,10 @@ describe("functionality", () => {
379
401
  };
380
402
  await fs.mkdir("/user/project.inlang", { recursive: true });
381
403
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings));
404
+ const repo = await openRepository("file://", { nodeishFs: fs });
382
405
  const project = await loadProject({
383
406
  projectPath: "/user/project.inlang",
384
- nodeishFs: fs,
407
+ repo,
385
408
  _import,
386
409
  });
387
410
  expect(project.installed.plugins()[0]).toStrictEqual({
@@ -407,9 +430,10 @@ describe("functionality", () => {
407
430
  };
408
431
  await fs.mkdir("/user/project.inlang", { recursive: true });
409
432
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings));
433
+ const repo = await openRepository("file://", { nodeishFs: fs });
410
434
  const project = await loadProject({
411
435
  projectPath: "/user/project.inlang",
412
- nodeishFs: fs,
436
+ repo,
413
437
  _import,
414
438
  });
415
439
  expect(project.installed.messageLintRules()[0]?.level).toBe("warning");
@@ -442,6 +466,7 @@ describe("functionality", () => {
442
466
  languageTags: ["en"],
443
467
  modules: ["plugin.js", "lintRule.js"],
444
468
  }));
469
+ const repo = await openRepository("file://", { nodeishFs: fs });
445
470
  const _import = async (name) => {
446
471
  return {
447
472
  default: name === "plugin.js" ? _mockPlugin : _mockLintRule,
@@ -449,7 +474,7 @@ describe("functionality", () => {
449
474
  };
450
475
  const project = await loadProject({
451
476
  projectPath: "/user/project.inlang",
452
- nodeishFs: fs,
477
+ repo,
453
478
  _import,
454
479
  });
455
480
  await new Promise((resolve) => setTimeout(resolve, 510));
@@ -484,6 +509,7 @@ describe("functionality", () => {
484
509
  languageTags: ["en"],
485
510
  modules: ["plugin.js", "lintRule.js"],
486
511
  }));
512
+ const repo = await openRepository("file://", { nodeishFs: fs });
487
513
  const _import = async (name) => {
488
514
  return {
489
515
  default: name === "plugin.js" ? _mockPlugin : _mockLintRule,
@@ -491,7 +517,7 @@ describe("functionality", () => {
491
517
  };
492
518
  const project = await loadProject({
493
519
  projectPath: "/user/project.inlang",
494
- nodeishFs: fs,
520
+ repo,
495
521
  _import,
496
522
  });
497
523
  await new Promise((resolve) => setTimeout(resolve, 510));
@@ -503,9 +529,10 @@ describe("functionality", () => {
503
529
  const fs = await createNodeishMemoryFs();
504
530
  await fs.mkdir("/user/project.inlang", { recursive: true });
505
531
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings));
532
+ const repo = await openRepository("file://", { nodeishFs: fs });
506
533
  const project = await loadProject({
507
534
  projectPath: "/user/project.inlang",
508
- nodeishFs: fs,
535
+ repo,
509
536
  _import,
510
537
  });
511
538
  project.errors.subscribe((errors) => {
@@ -518,9 +545,10 @@ describe("functionality", () => {
518
545
  const fs = await createNodeishMemoryFs();
519
546
  await fs.mkdir("/user/project.inlang", { recursive: true });
520
547
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings));
548
+ const repo = await openRepository("file://", { nodeishFs: fs });
521
549
  const project = await loadProject({
522
550
  projectPath: "/user/project.inlang",
523
- nodeishFs: fs,
551
+ repo,
524
552
  _import,
525
553
  });
526
554
  project.customApi.subscribe((api) => {
@@ -533,9 +561,10 @@ describe("functionality", () => {
533
561
  const fs = await createNodeishMemoryFs();
534
562
  await fs.mkdir("/user/project.inlang", { recursive: true });
535
563
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings));
564
+ const repo = await openRepository("file://", { nodeishFs: fs });
536
565
  const project = await loadProject({
537
566
  projectPath: "/user/project.inlang",
538
- nodeishFs: fs,
567
+ repo,
539
568
  _import,
540
569
  });
541
570
  expect(Object.values(project.query.messages.getAll())).toEqual(exampleMessages);
@@ -555,6 +584,7 @@ describe("functionality", () => {
555
584
  await fs.mkdir("/user/project.inlang", { recursive: true });
556
585
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings));
557
586
  await fs.mkdir("./resources");
587
+ const repo = await openRepository("file://", { nodeishFs: fs });
558
588
  const mockSaveFn = vi.fn();
559
589
  const _mockPlugin = {
560
590
  id: "plugin.project.json",
@@ -570,7 +600,7 @@ describe("functionality", () => {
570
600
  };
571
601
  const project = await loadProject({
572
602
  projectPath: "/user/project.inlang",
573
- nodeishFs: fs,
603
+ repo,
574
604
  _import,
575
605
  });
576
606
  await project.query.messages.upsert({
@@ -716,6 +746,7 @@ describe("functionality", () => {
716
746
  };
717
747
  await fs.mkdir("./project.inlang", { recursive: true });
718
748
  await fs.writeFile("./project.inlang/settings.json", JSON.stringify(settings));
749
+ const repo = await openRepository("file://", { nodeishFs: fs });
719
750
  const mockSaveFn = vi.fn();
720
751
  const _mockPlugin = {
721
752
  id: "plugin.placeholder.name",
@@ -735,7 +766,7 @@ describe("functionality", () => {
735
766
  };
736
767
  const project = await loadProject({
737
768
  projectPath: "/project.inlang",
738
- nodeishFs: fs,
769
+ repo,
739
770
  _import,
740
771
  });
741
772
  project.query.messages.create({ data: createMessage("fourth", { en: "fourth message" }) });
@@ -749,9 +780,10 @@ describe("functionality", () => {
749
780
  const fs = await createNodeishMemoryFs();
750
781
  await fs.mkdir("/user/project", { recursive: true });
751
782
  await fs.writeFile("/user/project/project.inlang.json", JSON.stringify(settings));
783
+ const repo = await openRepository("file://", { nodeishFs: fs });
752
784
  const project = await loadProject({
753
785
  projectPath: "/user/project/project.inlang.json",
754
- nodeishFs: fs,
786
+ repo,
755
787
  _import,
756
788
  });
757
789
  // TODO: test with real lint rules
@@ -772,9 +804,10 @@ describe("functionality", () => {
772
804
  const fs = createNodeishMemoryFs();
773
805
  await fs.mkdir("/user/project.inlang", { recursive: true });
774
806
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings));
807
+ const repo = await openRepository("file://", { nodeishFs: fs });
775
808
  const project = await loadProject({
776
809
  projectPath: "/user/project.inlang",
777
- nodeishFs: fs,
810
+ repo,
778
811
  _import: async () => ({
779
812
  default: mockMessageLintRule,
780
813
  }),
@@ -829,10 +862,11 @@ describe("functionality", () => {
829
862
  };
830
863
  await fs.mkdir("./project.inlang", { recursive: true });
831
864
  await fs.writeFile("./project.inlang/settings.json", JSON.stringify(settings));
865
+ const repo = await openRepository("file://", { nodeishFs: fs });
832
866
  // establish watcher
833
867
  const project = await loadProject({
834
868
  projectPath: normalizePath("/project.inlang"),
835
- nodeishFs: fs,
869
+ repo,
836
870
  _import: async () => ({
837
871
  default: mockMessageFormatPlugin,
838
872
  }),
@@ -1 +1 @@
1
- {"version":3,"file":"maybeCreateFirstProjectId.d.ts","sourceRoot":"","sources":["../../src/migrations/maybeCreateFirstProjectId.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAGhD;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAAC,IAAI,EAAE;IACrD,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,UAAU,CAAA;CACjB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBhB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAAE,IAAI,CAAC,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,+BAWvF"}
1
+ {"version":3,"file":"maybeCreateFirstProjectId.d.ts","sourceRoot":"","sources":["../../src/migrations/maybeCreateFirstProjectId.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAGhD;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAAC,IAAI,EAAE;IACrD,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,CAAC,EAAE,UAAU,CAAA;CACjB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBhB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAAE,IAAI,CAAC,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,+BAUvF"}
@@ -30,9 +30,8 @@ export async function generateProjectId(args) {
30
30
  return undefined;
31
31
  }
32
32
  const firstCommitHash = await args.repo.getFirstCommitHash();
33
- const originHash = await args.repo.getOrigin({ safeHashOnly: true });
34
33
  if (firstCommitHash) {
35
- return hash(`${firstCommitHash + args.projectPath + originHash}`);
34
+ return hash(`${firstCommitHash + args.projectPath}`);
36
35
  }
37
36
  return undefined;
38
37
  }
@@ -13,7 +13,7 @@ it("should return if repo is undefined", async () => {
13
13
  });
14
14
  it("should generate a project id", async () => {
15
15
  const projectId = await generateProjectId({ repo, projectPath: "mocked_project_path" });
16
- expect(projectId).toBe("959bcf0a30e678c9b90a3c76d1a281d085eab55f289c5439b6b10849baa1920c");
16
+ expect(projectId).toBe("432d7ef29c510e99d95e2d14ef57a0797a1603859b5a851b7dff7e77161b8c08");
17
17
  });
18
18
  it("should return undefined if repoMeta contains error", async () => {
19
19
  const repoWithError = await openRepository("https://github.com/inlang/no-exist", {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@inlang/sdk",
3
3
  "type": "module",
4
- "version": "0.23.0",
4
+ "version": "0.24.1",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {
7
7
  "access": "public"
@@ -27,15 +27,15 @@
27
27
  "throttle-debounce": "^5.0.0",
28
28
  "@inlang/json-types": "1.1.0",
29
29
  "@inlang/language-tag": "1.4.0",
30
- "@inlang/message": "2.0.1",
31
30
  "@inlang/message-lint-rule": "1.4.1",
32
- "@inlang/module": "1.2.2",
33
- "@inlang/plugin": "2.4.2",
31
+ "@inlang/module": "1.2.3",
32
+ "@inlang/plugin": "2.4.3",
33
+ "@inlang/result": "1.1.0",
34
34
  "@inlang/project-settings": "2.2.1",
35
- "@inlang/translatable": "1.2.1",
36
- "@lix-js/fs": "0.5.0",
37
- "@lix-js/client": "0.5.0",
38
- "@inlang/result": "1.1.0"
35
+ "@inlang/message": "2.0.1",
36
+ "@lix-js/fs": "0.6.0",
37
+ "@lix-js/client": "0.7.0",
38
+ "@inlang/translatable": "1.2.1"
39
39
  },
40
40
  "devDependencies": {
41
41
  "@types/throttle-debounce": "5.0.0",
@@ -5,6 +5,7 @@ import { createEffect, from, createRoot } from "../reactivity/solid.js"
5
5
  import { solidAdapter } from "./solidAdapter.js"
6
6
  import { loadProject } from "../loadProject.js"
7
7
  import { createNodeishMemoryFs } from "@lix-js/fs"
8
+ import { openRepository } from "@lix-js/client"
8
9
  import type {
9
10
  Message,
10
11
  ProjectSettings,
@@ -92,10 +93,11 @@ describe("config", () => {
92
93
  const fs = createNodeishMemoryFs()
93
94
  await fs.mkdir("/user/project.inlang", { recursive: true })
94
95
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(config))
96
+ const repo = await openRepository("file://", { nodeishFs: fs })
95
97
  const project = solidAdapter(
96
98
  await loadProject({
97
99
  projectPath: "/user/project.inlang",
98
- nodeishFs: fs,
100
+ repo,
99
101
  _import: $import,
100
102
  }),
101
103
  { from }
@@ -125,10 +127,11 @@ describe("installed", () => {
125
127
  const fs = createNodeishMemoryFs()
126
128
  await fs.mkdir("/user/project.inlang", { recursive: true })
127
129
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(config))
130
+ const repo = await openRepository("file://", { nodeishFs: fs })
128
131
  const project = solidAdapter(
129
132
  await loadProject({
130
133
  projectPath: "/user/project.inlang",
131
- nodeishFs: fs,
134
+ repo,
132
135
  _import: $import,
133
136
  }),
134
137
  { from }
@@ -190,10 +193,11 @@ describe("messages", () => {
190
193
 
191
194
  await fs.mkdir("/user/project.inlang.inlang", { recursive: true })
192
195
  await fs.writeFile("/user/project.inlang.inlang/settings.json", JSON.stringify(mockConfig))
196
+ const repo = await openRepository("file://", { nodeishFs: fs })
193
197
  const project = solidAdapter(
194
198
  await loadProject({
195
199
  projectPath: "/user/project.inlang.inlang",
196
- nodeishFs: fs,
200
+ repo,
197
201
  _import: mockImport,
198
202
  }),
199
203
  { from }
@@ -220,10 +224,11 @@ describe("messages", () => {
220
224
  const fs = createNodeishMemoryFs()
221
225
  await fs.mkdir("/user/project.inlang.inlang", { recursive: true })
222
226
  await fs.writeFile("/user/project.inlang.inlang/settings.json", JSON.stringify(config))
227
+ const repo = await openRepository("file://", { nodeishFs: fs })
223
228
  const project = solidAdapter(
224
229
  await loadProject({
225
230
  projectPath: "/user/project.inlang.inlang",
226
- nodeishFs: fs,
231
+ repo,
227
232
  _import: $import,
228
233
  }),
229
234
  { from }
@@ -282,10 +287,11 @@ describe("lint", () => {
282
287
  const fs = createNodeishMemoryFs()
283
288
  await fs.mkdir("./project.inlang", { recursive: true })
284
289
  await fs.writeFile("./project.inlang/settings.json", JSON.stringify(config))
290
+ const repo = await openRepository("file://", { nodeishFs: fs })
285
291
  const project = solidAdapter(
286
292
  await loadProject({
287
293
  projectPath: "./project.inlang",
288
- nodeishFs: fs,
294
+ repo,
289
295
  _import: $import,
290
296
  }),
291
297
  { from }
@@ -320,10 +326,11 @@ describe("lint", () => {
320
326
  await createRoot(async () => {
321
327
  const fs = createNodeishMemoryFs()
322
328
  await fs.writeFile("./project.config.json", JSON.stringify(config))
329
+ const repo = await openRepository("file://", { nodeishFs: fs })
323
330
  const project = solidAdapter(
324
331
  await loadProject({
325
332
  projectPath: "./project.config.json",
326
- nodeishFs: fs,
333
+ repo,
327
334
  _import: $import,
328
335
  }),
329
336
  { from }
@@ -19,10 +19,12 @@ 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
+ import { mockRepo, openRepository } from "@lix-js/client"
23
23
  import { type Snapshot } from "@lix-js/fs"
24
24
  // eslint-disable-next-line no-restricted-imports -- test
25
25
  import { readFileSync } from "node:fs"
26
+ // eslint-disable-next-line no-restricted-imports -- test
27
+ import { resolve } from "node:path"
26
28
 
27
29
  // ------------------------------------------------------------------------------------------------
28
30
 
@@ -107,6 +109,16 @@ const _import: ImportFunction = async (name) =>
107
109
  default: name === "plugin.js" ? mockPlugin : mockMessageLintRule,
108
110
  } satisfies InlangModule)
109
111
 
112
+ async function openCiTestRepo() {
113
+ return await mockRepo({
114
+ fromSnapshot: JSON.parse(
115
+ readFileSync(resolve(__dirname, "../mocks/ci-test-repo-no-shallow.json"), {
116
+ encoding: "utf-8",
117
+ })
118
+ ) as Snapshot,
119
+ })
120
+ }
121
+
110
122
  // ------------------------------------------------------------------------------------------------
111
123
 
112
124
  /**
@@ -117,10 +129,11 @@ const _import: ImportFunction = async (name) =>
117
129
  */
118
130
  it("should throw if a project (path) does not have a name", async () => {
119
131
  const fs = createNodeishMemoryFs()
132
+ const repo = await openRepository("file://", { nodeishFs: fs })
120
133
  const project = await tryCatch(() =>
121
134
  loadProject({
122
135
  projectPath: "/source-code/.inlang",
123
- nodeishFs: fs,
136
+ repo,
124
137
  _import,
125
138
  })
126
139
  )
@@ -129,6 +142,7 @@ it("should throw if a project (path) does not have a name", async () => {
129
142
 
130
143
  it("should throw if a project path does not end with .inlang", async () => {
131
144
  const fs = createNodeishMemoryFs()
145
+ const repo = await openRepository("file://", { nodeishFs: fs })
132
146
 
133
147
  const invalidPaths = [
134
148
  "/source-code/frontend.inlang/settings",
@@ -140,7 +154,7 @@ it("should throw if a project path does not end with .inlang", async () => {
140
154
  const project = await tryCatch(() =>
141
155
  loadProject({
142
156
  projectPath: invalidPath,
143
- nodeishFs: fs,
157
+ repo,
144
158
  _import,
145
159
  })
146
160
  )
@@ -151,11 +165,12 @@ it("should throw if a project path does not end with .inlang", async () => {
151
165
  describe("initialization", () => {
152
166
  it("should throw if projectPath is not an absolute path", async () => {
153
167
  const fs = createNodeishMemoryFs()
168
+ const repo = await openRepository("file://", { nodeishFs: fs })
154
169
 
155
170
  const result = await tryCatch(() =>
156
171
  loadProject({
157
172
  projectPath: "relative/path",
158
- nodeishFs: fs,
173
+ repo,
159
174
  _import,
160
175
  })
161
176
  )
@@ -164,10 +179,7 @@ describe("initialization", () => {
164
179
  })
165
180
 
166
181
  it("should generate projectId on missing projectid", async () => {
167
- const ciTestRepo: Snapshot = JSON.parse(
168
- readFileSync("./mocks/ci-test-repo-no-shallow.json", { encoding: "utf-8" })
169
- )
170
- const repo = await mockRepo({ fromSnapshot: ciTestRepo })
182
+ const repo = await openCiTestRepo()
171
183
 
172
184
  const existing = await repo.nodeishFs
173
185
  .readFile("/project.inlang/project_id", {
@@ -196,17 +208,14 @@ describe("initialization", () => {
196
208
  return { error }
197
209
  })
198
210
 
199
- expect(newId).toBe("e8c61726bc2f437ec6a260abb632b3c59195059b60031e648b5afbafa7f3d79a")
211
+ expect(newId).toBe("aef225403be8b526dfb492a4617fd59d8181e8fef2c7f4aff56ab299046e36ed")
200
212
 
201
213
  expect(result.error).toBeUndefined()
202
214
  expect(result.data).toBeDefined()
203
215
  })
204
216
 
205
217
  it("should reuse projectId on existing projectid", async () => {
206
- const ciTestRepo: Snapshot = JSON.parse(
207
- readFileSync("./mocks/ci-test-repo-no-shallow.json", { encoding: "utf-8" })
208
- )
209
- const repo = await mockRepo({ fromSnapshot: ciTestRepo })
218
+ const repo = await openCiTestRepo()
210
219
 
211
220
  repo.nodeishFs.writeFile("/project.inlang/project_id", "testId")
212
221
 
@@ -236,11 +245,12 @@ describe("initialization", () => {
236
245
  const fs = createNodeishMemoryFs()
237
246
  fs.mkdir("C:\\Users\\user\\project.inlang", { recursive: true })
238
247
  fs.writeFile("C:\\Users\\user\\project.inlang\\settings.json", JSON.stringify(settings))
248
+ const repo = await openRepository("file://", { nodeishFs: fs })
239
249
 
240
250
  const result = await tryCatch(() =>
241
251
  loadProject({
242
252
  projectPath: "C:\\Users\\user\\project.inlang",
243
- nodeishFs: fs,
253
+ repo,
244
254
  _import,
245
255
  })
246
256
  )
@@ -253,10 +263,11 @@ describe("initialization", () => {
253
263
  it("should return an error if settings file is not found", async () => {
254
264
  const fs = createNodeishMemoryFs()
255
265
  fs.mkdir("/user/project", { recursive: true })
266
+ const repo = await openRepository("file://", { nodeishFs: fs })
256
267
 
257
268
  const project = await loadProject({
258
269
  projectPath: "/user/non-existend-project.inlang",
259
- nodeishFs: fs,
270
+ repo,
260
271
  _import,
261
272
  })
262
273
 
@@ -267,10 +278,11 @@ describe("initialization", () => {
267
278
  const fs = await createNodeishMemoryFs()
268
279
  await fs.mkdir("/user/project.inlang", { recursive: true })
269
280
  await fs.writeFile("/user/project.inlang/settings.json", "invalid json")
281
+ const repo = await openRepository("file://", { nodeishFs: fs })
270
282
 
271
283
  const project = await loadProject({
272
284
  projectPath: "/user/project.inlang",
273
- nodeishFs: fs,
285
+ repo,
274
286
  _import,
275
287
  })
276
288
 
@@ -281,10 +293,11 @@ describe("initialization", () => {
281
293
  const fs = await createNodeishMemoryFs()
282
294
  await fs.mkdir("/user/project.inlang", { recursive: true })
283
295
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify({}))
296
+ const repo = await openRepository("file://", { nodeishFs: fs })
284
297
 
285
298
  const project = await loadProject({
286
299
  projectPath: "/user/project.inlang",
287
- nodeishFs: fs,
300
+ repo,
288
301
  _import,
289
302
  })
290
303
 
@@ -295,9 +308,10 @@ describe("initialization", () => {
295
308
  const fs = await createNodeishMemoryFs()
296
309
  await fs.mkdir("/user/project.inlang", { recursive: true })
297
310
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
311
+ const repo = await openRepository("file://", { nodeishFs: fs })
298
312
  const project = await loadProject({
299
313
  projectPath: "/user/project.inlang",
300
- nodeishFs: fs,
314
+ repo,
301
315
  _import,
302
316
  })
303
317
 
@@ -309,10 +323,11 @@ describe("initialization", () => {
309
323
  const settingsWithDeifferentFormatting = JSON.stringify(settings, undefined, 4)
310
324
  await fs.mkdir("/user/project.inlang", { recursive: true })
311
325
  await fs.writeFile("/user/project.inlang/settings.json", settingsWithDeifferentFormatting)
326
+ const repo = await openRepository("file://", { nodeishFs: fs })
312
327
 
313
328
  const project = await loadProject({
314
329
  projectPath: "/user/project.inlang",
315
- nodeishFs: fs,
330
+ repo,
316
331
  _import,
317
332
  })
318
333
 
@@ -342,10 +357,11 @@ describe("initialization", () => {
342
357
  const fs = createNodeishMemoryFs()
343
358
  await fs.mkdir("/user/project.inlang", { recursive: true })
344
359
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
360
+ const repo = await openRepository("file://", { nodeishFs: fs })
345
361
 
346
362
  const project = await loadProject({
347
363
  projectPath: "/user/project.inlang",
348
- nodeishFs: fs,
364
+ repo,
349
365
  _import: $badImport,
350
366
  })
351
367
 
@@ -375,9 +391,10 @@ describe("functionality", () => {
375
391
  const fs = await createNodeishMemoryFs()
376
392
  await fs.mkdir("/user/project.inlang", { recursive: true })
377
393
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
394
+ const repo = await openRepository("file://", { nodeishFs: fs })
378
395
  const project = await loadProject({
379
396
  projectPath: "/user/project.inlang",
380
- nodeishFs: fs,
397
+ repo,
381
398
  _import,
382
399
  })
383
400
 
@@ -388,9 +405,10 @@ describe("functionality", () => {
388
405
  const fs = await createNodeishMemoryFs()
389
406
  await fs.mkdir("/user/project.inlang", { recursive: true })
390
407
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
408
+ const repo = await openRepository("file://", { nodeishFs: fs })
391
409
  const project = await loadProject({
392
410
  projectPath: "/user/project.inlang",
393
- nodeishFs: fs,
411
+ repo,
394
412
  _import,
395
413
  })
396
414
 
@@ -414,9 +432,10 @@ describe("functionality", () => {
414
432
  const fs = await createNodeishMemoryFs()
415
433
  await fs.mkdir("/user/project.inlang", { recursive: true })
416
434
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
435
+ const repo = await openRepository("file://", { nodeishFs: fs })
417
436
  const project = await loadProject({
418
437
  projectPath: "/user/project.inlang",
419
- nodeishFs: fs,
438
+ repo,
420
439
  _import,
421
440
  })
422
441
 
@@ -436,10 +455,11 @@ describe("functionality", () => {
436
455
  }
437
456
 
438
457
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
458
+ const repo = await openRepository("file://", { nodeishFs: fs })
439
459
 
440
460
  const project = await loadProject({
441
461
  projectPath: "/user/project.inlang",
442
- nodeishFs: fs,
462
+ repo,
443
463
  _import,
444
464
  })
445
465
 
@@ -451,9 +471,10 @@ describe("functionality", () => {
451
471
  const fs = await createNodeishMemoryFs()
452
472
  await fs.mkdir("/user/project.inlang", { recursive: true })
453
473
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
474
+ const repo = await openRepository("file://", { nodeishFs: fs })
454
475
  const project = await loadProject({
455
476
  projectPath: "/user/project.inlang",
456
- nodeishFs: fs,
477
+ repo,
457
478
  _import,
458
479
  })
459
480
 
@@ -483,9 +504,10 @@ describe("functionality", () => {
483
504
  }
484
505
  await fs.mkdir("/user/project.inlang", { recursive: true })
485
506
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
507
+ const repo = await openRepository("file://", { nodeishFs: fs })
486
508
  const project = await loadProject({
487
509
  projectPath: "/user/project.inlang",
488
- nodeishFs: fs,
510
+ repo,
489
511
  _import,
490
512
  })
491
513
 
@@ -516,10 +538,11 @@ describe("functionality", () => {
516
538
 
517
539
  await fs.mkdir("/user/project.inlang", { recursive: true })
518
540
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
541
+ const repo = await openRepository("file://", { nodeishFs: fs })
519
542
 
520
543
  const project = await loadProject({
521
544
  projectPath: "/user/project.inlang",
522
- nodeishFs: fs,
545
+ repo,
523
546
  _import,
524
547
  })
525
548
 
@@ -558,6 +581,7 @@ describe("functionality", () => {
558
581
  modules: ["plugin.js", "lintRule.js"],
559
582
  } satisfies ProjectSettings)
560
583
  )
584
+ const repo = await openRepository("file://", { nodeishFs: fs })
561
585
 
562
586
  const _import: ImportFunction = async (name) => {
563
587
  return {
@@ -566,7 +590,7 @@ describe("functionality", () => {
566
590
  }
567
591
  const project = await loadProject({
568
592
  projectPath: "/user/project.inlang",
569
- nodeishFs: fs,
593
+ repo,
570
594
  _import,
571
595
  })
572
596
 
@@ -609,6 +633,7 @@ describe("functionality", () => {
609
633
  modules: ["plugin.js", "lintRule.js"],
610
634
  } satisfies ProjectSettings)
611
635
  )
636
+ const repo = await openRepository("file://", { nodeishFs: fs })
612
637
  const _import: ImportFunction = async (name) => {
613
638
  return {
614
639
  default: name === "plugin.js" ? _mockPlugin : _mockLintRule,
@@ -617,7 +642,7 @@ describe("functionality", () => {
617
642
 
618
643
  const project = await loadProject({
619
644
  projectPath: "/user/project.inlang",
620
- nodeishFs: fs,
645
+ repo,
621
646
  _import,
622
647
  })
623
648
 
@@ -634,9 +659,10 @@ describe("functionality", () => {
634
659
  const fs = await createNodeishMemoryFs()
635
660
  await fs.mkdir("/user/project.inlang", { recursive: true })
636
661
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
662
+ const repo = await openRepository("file://", { nodeishFs: fs })
637
663
  const project = await loadProject({
638
664
  projectPath: "/user/project.inlang",
639
- nodeishFs: fs,
665
+ repo,
640
666
  _import,
641
667
  })
642
668
  project.errors.subscribe((errors) => {
@@ -650,9 +676,10 @@ describe("functionality", () => {
650
676
  const fs = await createNodeishMemoryFs()
651
677
  await fs.mkdir("/user/project.inlang", { recursive: true })
652
678
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
679
+ const repo = await openRepository("file://", { nodeishFs: fs })
653
680
  const project = await loadProject({
654
681
  projectPath: "/user/project.inlang",
655
- nodeishFs: fs,
682
+ repo,
656
683
  _import,
657
684
  })
658
685
 
@@ -667,9 +694,10 @@ describe("functionality", () => {
667
694
  const fs = await createNodeishMemoryFs()
668
695
  await fs.mkdir("/user/project.inlang", { recursive: true })
669
696
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
697
+ const repo = await openRepository("file://", { nodeishFs: fs })
670
698
  const project = await loadProject({
671
699
  projectPath: "/user/project.inlang",
672
- nodeishFs: fs,
700
+ repo,
673
701
  _import,
674
702
  })
675
703
 
@@ -694,6 +722,7 @@ describe("functionality", () => {
694
722
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
695
723
 
696
724
  await fs.mkdir("./resources")
725
+ const repo = await openRepository("file://", { nodeishFs: fs })
697
726
 
698
727
  const mockSaveFn = vi.fn()
699
728
 
@@ -714,7 +743,7 @@ describe("functionality", () => {
714
743
 
715
744
  const project = await loadProject({
716
745
  projectPath: "/user/project.inlang",
717
- nodeishFs: fs,
746
+ repo,
718
747
  _import,
719
748
  })
720
749
 
@@ -869,6 +898,7 @@ describe("functionality", () => {
869
898
 
870
899
  await fs.mkdir("./project.inlang", { recursive: true })
871
900
  await fs.writeFile("./project.inlang/settings.json", JSON.stringify(settings))
901
+ const repo = await openRepository("file://", { nodeishFs: fs })
872
902
 
873
903
  const mockSaveFn = vi.fn()
874
904
 
@@ -893,7 +923,7 @@ describe("functionality", () => {
893
923
 
894
924
  const project = await loadProject({
895
925
  projectPath: "/project.inlang",
896
- nodeishFs: fs,
926
+ repo,
897
927
  _import,
898
928
  })
899
929
 
@@ -911,9 +941,10 @@ describe("functionality", () => {
911
941
  const fs = await createNodeishMemoryFs()
912
942
  await fs.mkdir("/user/project", { recursive: true })
913
943
  await fs.writeFile("/user/project/project.inlang.json", JSON.stringify(settings))
944
+ const repo = await openRepository("file://", { nodeishFs: fs })
914
945
  const project = await loadProject({
915
946
  projectPath: "/user/project/project.inlang.json",
916
- nodeishFs: fs,
947
+ repo,
917
948
  _import,
918
949
  })
919
950
  // TODO: test with real lint rules
@@ -933,9 +964,10 @@ describe("functionality", () => {
933
964
  const fs = createNodeishMemoryFs()
934
965
  await fs.mkdir("/user/project.inlang", { recursive: true })
935
966
  await fs.writeFile("/user/project.inlang/settings.json", JSON.stringify(settings))
967
+ const repo = await openRepository("file://", { nodeishFs: fs })
936
968
  const project = await loadProject({
937
969
  projectPath: "/user/project.inlang",
938
- nodeishFs: fs,
970
+ repo,
939
971
  _import: async () => ({
940
972
  default: mockMessageLintRule,
941
973
  }),
@@ -998,11 +1030,12 @@ describe("functionality", () => {
998
1030
 
999
1031
  await fs.mkdir("./project.inlang", { recursive: true })
1000
1032
  await fs.writeFile("./project.inlang/settings.json", JSON.stringify(settings))
1033
+ const repo = await openRepository("file://", { nodeishFs: fs })
1001
1034
 
1002
1035
  // establish watcher
1003
1036
  const project = await loadProject({
1004
1037
  projectPath: normalizePath("/project.inlang"),
1005
- nodeishFs: fs,
1038
+ repo,
1006
1039
  _import: async () => ({
1007
1040
  default: mockMessageFormatPlugin,
1008
1041
  }),
@@ -18,7 +18,7 @@ it("should return if repo is undefined", async () => {
18
18
 
19
19
  it("should generate a project id", async () => {
20
20
  const projectId = await generateProjectId({ repo, projectPath: "mocked_project_path" })
21
- expect(projectId).toBe("959bcf0a30e678c9b90a3c76d1a281d085eab55f289c5439b6b10849baa1920c")
21
+ expect(projectId).toBe("432d7ef29c510e99d95e2d14ef57a0797a1603859b5a851b7dff7e77161b8c08")
22
22
  })
23
23
 
24
24
  it("should return undefined if repoMeta contains error", async () => {
@@ -35,10 +35,9 @@ export async function generateProjectId(args: { repo?: Repository; projectPath:
35
35
  return undefined
36
36
  }
37
37
  const firstCommitHash = await args.repo.getFirstCommitHash()
38
- const originHash = await args.repo.getOrigin({ safeHashOnly: true })
39
38
 
40
39
  if (firstCommitHash) {
41
- return hash(`${firstCommitHash + args.projectPath + originHash}`)
40
+ return hash(`${firstCommitHash + args.projectPath}`)
42
41
  }
43
42
  return undefined
44
43
  }