@inlang/sdk 0.29.0 → 0.31.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/dist/loadProject.d.ts.map +1 -1
- package/dist/loadProject.js +4 -5
- package/dist/migrations/maybeCreateFirstProjectId.d.ts.map +1 -1
- package/dist/migrations/maybeCreateFirstProjectId.js +6 -1
- package/package.json +5 -5
- package/src/loadProject.ts +4 -6
- package/src/migrations/maybeCreateFirstProjectId.ts +5 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loadProject.d.ts","sourceRoot":"","sources":["../src/loadProject.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,aAAa,EAGb,YAAY,EACZ,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,4BAA4B,CAAA;AAyBhF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAgChD;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACvC,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,UAAU,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,cAAc,CAAA;CACxB,GAAG,OAAO,CAAC,aAAa,CAAC,
|
|
1
|
+
{"version":3,"file":"loadProject.d.ts","sourceRoot":"","sources":["../src/loadProject.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACX,aAAa,EAGb,YAAY,EACZ,MAAM,UAAU,CAAA;AACjB,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,4BAA4B,CAAA;AAyBhF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAgChD;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACvC,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,UAAU,CAAA;IAChB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,OAAO,CAAC,EAAE,cAAc,CAAA;CACxB,GAAG,OAAO,CAAC,aAAa,CAAC,CAqYzB;AAsHD,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC,CAQtE"}
|
package/dist/loadProject.js
CHANGED
|
@@ -49,20 +49,19 @@ export async function loadProject(args) {
|
|
|
49
49
|
else if (/[^\\/]+\.inlang$/.test(projectPath) === false) {
|
|
50
50
|
throw new LoadProjectInvalidArgument(`Expected a path ending in "{name}.inlang" but received "${projectPath}".\n\nValid examples: \n- "/path/to/micky-mouse.inlang"\n- "/path/to/green-elephant.inlang\n`, { argument: "projectPath" });
|
|
51
51
|
}
|
|
52
|
-
const fs = args.repo.nodeishFs;
|
|
53
52
|
const nodeishFs = createNodeishFsWithAbsolutePaths({
|
|
54
53
|
projectPath,
|
|
55
|
-
nodeishFs:
|
|
54
|
+
nodeishFs: args.repo.nodeishFs,
|
|
56
55
|
});
|
|
57
56
|
// -- migratations ------------------------------------------------
|
|
58
|
-
await maybeMigrateToDirectory({ nodeishFs
|
|
57
|
+
await maybeMigrateToDirectory({ nodeishFs, projectPath });
|
|
59
58
|
await maybeCreateFirstProjectId({ projectPath, repo: args.repo });
|
|
60
59
|
// -- load project ------------------------------------------------------
|
|
61
60
|
return await createRoot(async () => {
|
|
62
61
|
// TODO remove tryCatch after https://github.com/opral/monorepo/issues/2013
|
|
63
62
|
// - a repo will always be present
|
|
64
63
|
// - if a repo is present, the project id will always be present
|
|
65
|
-
const { data: projectId } = await tryCatch(() =>
|
|
64
|
+
const { data: projectId } = await tryCatch(() => nodeishFs.readFile(args.projectPath + "/project_id", { encoding: "utf-8" }));
|
|
66
65
|
const [initialized, markInitAsComplete, markInitAsFailed] = createAwaitable();
|
|
67
66
|
// -- settings ------------------------------------------------------------
|
|
68
67
|
const [settings, _setSettings] = createSignal();
|
|
@@ -219,7 +218,7 @@ export async function loadProject(args) {
|
|
|
219
218
|
// don't trigger saves or set dirty flags during initial setup
|
|
220
219
|
if (!initialSetup) {
|
|
221
220
|
messageStates.messageDirtyFlags[message.id] = true;
|
|
222
|
-
saveMessagesViaPlugin(
|
|
221
|
+
saveMessagesViaPlugin(nodeishFs, messageLockDirPath, messageStates, messagesQuery, settings(), saveMessagesPlugin, loadMessagesPlugin)
|
|
223
222
|
.catch((e) => setSaveMessagesViaPluginError(new PluginSaveMessagesError({ cause: e })))
|
|
224
223
|
.then(() => {
|
|
225
224
|
if (saveMessagesViaPluginError() !== undefined) {
|
|
@@ -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,CAsBhB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAAE,IAAI,CAAC,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,+
|
|
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,CAsBhB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE;IAAE,IAAI,CAAC,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,+BAcvF"}
|
|
@@ -35,7 +35,12 @@ export async function generateProjectId(args) {
|
|
|
35
35
|
}
|
|
36
36
|
const firstCommitHash = await args.repo.getFirstCommitHash();
|
|
37
37
|
if (firstCommitHash) {
|
|
38
|
-
|
|
38
|
+
try {
|
|
39
|
+
return await hash(`${firstCommitHash + args.projectPath}`);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
console.error("Failed to generate project_id", error);
|
|
43
|
+
}
|
|
39
44
|
}
|
|
40
45
|
return undefined;
|
|
41
46
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inlang/sdk",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.31.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
"@inlang/json-types": "1.1.0",
|
|
36
36
|
"@inlang/language-tag": "1.5.1",
|
|
37
37
|
"@inlang/message": "2.1.0",
|
|
38
|
-
"@inlang/message-lint-rule": "1.4.5",
|
|
39
38
|
"@inlang/module": "1.2.9",
|
|
40
39
|
"@inlang/project-settings": "2.4.0",
|
|
41
|
-
"@inlang/plugin": "2.4.9",
|
|
42
40
|
"@inlang/result": "1.1.0",
|
|
43
|
-
"@
|
|
41
|
+
"@inlang/plugin": "2.4.9",
|
|
42
|
+
"@inlang/message-lint-rule": "1.4.5",
|
|
44
43
|
"@lix-js/client": "1.2.0",
|
|
45
|
-
"@inlang/translatable": "1.3.1"
|
|
44
|
+
"@inlang/translatable": "1.3.1",
|
|
45
|
+
"@lix-js/fs": "1.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@types/debug": "^4.1.12",
|
package/src/loadProject.ts
CHANGED
|
@@ -105,16 +105,14 @@ export async function loadProject(args: {
|
|
|
105
105
|
)
|
|
106
106
|
}
|
|
107
107
|
|
|
108
|
-
const fs = args.repo.nodeishFs
|
|
109
|
-
|
|
110
108
|
const nodeishFs = createNodeishFsWithAbsolutePaths({
|
|
111
109
|
projectPath,
|
|
112
|
-
nodeishFs:
|
|
110
|
+
nodeishFs: args.repo.nodeishFs,
|
|
113
111
|
})
|
|
114
112
|
|
|
115
113
|
// -- migratations ------------------------------------------------
|
|
116
114
|
|
|
117
|
-
await maybeMigrateToDirectory({ nodeishFs
|
|
115
|
+
await maybeMigrateToDirectory({ nodeishFs, projectPath })
|
|
118
116
|
await maybeCreateFirstProjectId({ projectPath, repo: args.repo })
|
|
119
117
|
|
|
120
118
|
// -- load project ------------------------------------------------------
|
|
@@ -124,7 +122,7 @@ export async function loadProject(args: {
|
|
|
124
122
|
// - a repo will always be present
|
|
125
123
|
// - if a repo is present, the project id will always be present
|
|
126
124
|
const { data: projectId } = await tryCatch(() =>
|
|
127
|
-
|
|
125
|
+
nodeishFs.readFile(args.projectPath + "/project_id", { encoding: "utf-8" })
|
|
128
126
|
)
|
|
129
127
|
|
|
130
128
|
const [initialized, markInitAsComplete, markInitAsFailed] = createAwaitable()
|
|
@@ -348,7 +346,7 @@ export async function loadProject(args: {
|
|
|
348
346
|
if (!initialSetup) {
|
|
349
347
|
messageStates.messageDirtyFlags[message.id] = true
|
|
350
348
|
saveMessagesViaPlugin(
|
|
351
|
-
|
|
349
|
+
nodeishFs,
|
|
352
350
|
messageLockDirPath,
|
|
353
351
|
messageStates,
|
|
354
352
|
messagesQuery,
|
|
@@ -41,7 +41,11 @@ export async function generateProjectId(args: { repo?: Repository; projectPath:
|
|
|
41
41
|
const firstCommitHash = await args.repo.getFirstCommitHash()
|
|
42
42
|
|
|
43
43
|
if (firstCommitHash) {
|
|
44
|
-
|
|
44
|
+
try {
|
|
45
|
+
return await hash(`${firstCommitHash + args.projectPath}`)
|
|
46
|
+
} catch (error) {
|
|
47
|
+
console.error("Failed to generate project_id", error)
|
|
48
|
+
}
|
|
45
49
|
}
|
|
46
50
|
return undefined
|
|
47
51
|
}
|