@inlang/sdk 0.18.0 → 0.19.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/adapter/solidAdapter.test.js +16 -15
- 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/isAbsolutePath.test.js +1 -1
- package/dist/loadProject.d.ts +4 -4
- package/dist/loadProject.d.ts.map +1 -1
- package/dist/loadProject.js +23 -17
- package/dist/loadProject.test.js +108 -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 +56 -56
- package/src/adapter/solidAdapter.test.ts +16 -15
- package/src/createNodeishFsWithAbsolutePaths.test.ts +4 -4
- package/src/createNodeishFsWithAbsolutePaths.ts +5 -5
- package/src/createNodeishFsWithWatcher.ts +6 -4
- package/src/isAbsolutePath.test.ts +1 -1
- package/src/loadProject.test.ts +116 -75
- package/src/loadProject.ts +36 -22
- 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,59 @@
|
|
|
1
|
+
import { tryCatch } from "@inlang/result"
|
|
2
|
+
import type { NodeishFilesystem } from "@lix-js/fs"
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Migrates to the new project directory structure
|
|
6
|
+
* https://github.com/inlang/monorepo/issues/1678
|
|
7
|
+
*/
|
|
8
|
+
export const maybeMigrateToDirectory = async (args: {
|
|
9
|
+
nodeishFs: NodeishFilesystem
|
|
10
|
+
projectPath: string
|
|
11
|
+
}) => {
|
|
12
|
+
// the migration assumes that the projectPath ends with project.inlang
|
|
13
|
+
if (args.projectPath.endsWith("project.inlang") === false) {
|
|
14
|
+
return
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// we assume that stat will throw when the directory does not exist
|
|
18
|
+
const projectDirectory = await tryCatch(() => args.nodeishFs.stat(args.projectPath))
|
|
19
|
+
|
|
20
|
+
// the migration has already been conducted.
|
|
21
|
+
if (projectDirectory.data) {
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const settingsFile = await tryCatch(() =>
|
|
26
|
+
args.nodeishFs.readFile(args.projectPath + ".json", { encoding: "utf-8" })
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
// the settings file does not exist or something else is wrong, let loadProject handle it
|
|
30
|
+
if (settingsFile.error) {
|
|
31
|
+
return
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
await args.nodeishFs.mkdir(args.projectPath)
|
|
35
|
+
await args.nodeishFs.writeFile(`${args.projectPath}/settings.json`, settingsFile.data)
|
|
36
|
+
await args.nodeishFs.writeFile(args.projectPath + ".README.md", readme)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const readme = `
|
|
40
|
+
# DELETE THE \`project.inlang.json\` FILE
|
|
41
|
+
|
|
42
|
+
The \`project.inlang.json\` file is now contained in a project directory e.g. \`project.inlang/settings.json\`.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
## What you need to do
|
|
46
|
+
|
|
47
|
+
1. Update the inlang CLI (if you use it) to use the new path \`project.inlang\` instead of \`project.inlang.json\`.
|
|
48
|
+
2. Delete the \`project.inlang.json\` file.
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
## Why is this happening?
|
|
52
|
+
|
|
53
|
+
See this RFC https://docs.google.com/document/d/1OYyA1wYfQRbIJOIBDliYoWjiUlkFBNxH_U2R4WpVRZ4/edit#heading=h.pecv6xb7ial6
|
|
54
|
+
and the following GitHub issue for more information https://github.com/inlang/monorepo/issues/1678.
|
|
55
|
+
|
|
56
|
+
- Monorepo support https://github.com/inlang/monorepo/discussions/258.
|
|
57
|
+
- Required for many other future features like caching, first class offline support, and more.
|
|
58
|
+
- Stablize the inlang project format.
|
|
59
|
+
`
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-non-null-assertion */
|
|
2
2
|
import { expect, test } from "vitest"
|
|
3
|
-
import { Plugin, MessageLintRule } from "
|
|
3
|
+
import { Plugin, MessageLintRule } from "../index.js"
|
|
4
4
|
// import { createNodeishMemoryFs } from "@lix-js/fs"
|
|
5
5
|
import { Type } from "@sinclair/typebox"
|
|
6
6
|
import { validatedModuleSettings } from "./validatedModuleSettings.js"
|