@inlang/sdk 0.36.3 → 2.0.0-beta.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.
- package/README.md +1 -1
- package/dist/database/initDb.d.ts +7 -0
- package/dist/database/initDb.d.ts.map +1 -0
- package/dist/database/initDb.js +36 -0
- package/dist/database/initDb.js.map +1 -0
- package/dist/database/initDbAndSchema.test.d.ts +2 -0
- package/dist/database/initDbAndSchema.test.d.ts.map +1 -0
- package/dist/database/initDbAndSchema.test.js +110 -0
- package/dist/database/initDbAndSchema.test.js.map +1 -0
- package/dist/database/jsonbPlugin.d.ts +20 -0
- package/dist/database/jsonbPlugin.d.ts.map +1 -0
- package/dist/database/jsonbPlugin.js +183 -0
- package/dist/database/jsonbPlugin.js.map +1 -0
- package/dist/database/jsonbPlugin.test.d.ts +2 -0
- package/dist/database/jsonbPlugin.test.d.ts.map +1 -0
- package/dist/database/jsonbPlugin.test.js +119 -0
- package/dist/database/jsonbPlugin.test.js.map +1 -0
- package/dist/database/schema.d.ts +74 -0
- package/dist/database/schema.d.ts.map +1 -0
- package/dist/database/schema.js +45 -0
- package/dist/database/schema.js.map +1 -0
- package/dist/helper.d.ts +71 -0
- package/dist/helper.d.ts.map +1 -0
- package/dist/helper.js +91 -0
- package/dist/helper.js.map +1 -0
- package/dist/human-id/human-id.d.ts +3 -0
- package/dist/human-id/human-id.d.ts.map +1 -0
- package/dist/human-id/human-id.js +12 -0
- package/dist/human-id/human-id.js.map +1 -0
- package/dist/human-id/words.d.ts.map +1 -0
- package/dist/{storage/human-id → human-id}/words.js +4 -0
- package/dist/human-id/words.js.map +1 -0
- package/dist/human-id/words.test.d.ts.map +1 -0
- package/dist/{storage/human-id → human-id}/words.test.js +4 -0
- package/dist/human-id/words.test.js.map +1 -0
- package/dist/import-export/exportFiles.d.ts +11 -0
- package/dist/import-export/exportFiles.d.ts.map +1 -0
- package/dist/import-export/exportFiles.js +26 -0
- package/dist/import-export/exportFiles.js.map +1 -0
- package/dist/import-export/importFiles.d.ts +13 -0
- package/dist/import-export/importFiles.d.ts.map +1 -0
- package/dist/import-export/importFiles.js +124 -0
- package/dist/import-export/importFiles.js.map +1 -0
- package/dist/import-export/importFiles.test.d.ts +2 -0
- package/dist/import-export/importFiles.test.d.ts.map +1 -0
- package/dist/import-export/importFiles.test.js +179 -0
- package/dist/import-export/importFiles.test.js.map +1 -0
- package/dist/import-export/roundtrip.test.d.ts +2 -0
- package/dist/import-export/roundtrip.test.d.ts.map +1 -0
- package/dist/import-export/roundtrip.test.js +273 -0
- package/dist/import-export/roundtrip.test.js.map +1 -0
- package/dist/import-export/upsertBundleNestedMatchByProperties.d.ts +4 -0
- package/dist/import-export/upsertBundleNestedMatchByProperties.d.ts.map +1 -0
- package/dist/import-export/upsertBundleNestedMatchByProperties.js +58 -0
- package/dist/import-export/upsertBundleNestedMatchByProperties.js.map +1 -0
- package/dist/index.d.ts +21 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +20 -17
- package/dist/index.js.map +1 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.d.ts +9 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.js +84 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.js.map +1 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.test.d.ts +2 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.test.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.test.js +85 -0
- package/dist/json-schema/old-v1-message/fromMessageV1.test.js.map +1 -0
- package/dist/json-schema/old-v1-message/schemaV1.d.ts +86 -0
- package/dist/json-schema/old-v1-message/schemaV1.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/schemaV1.js +35 -0
- package/dist/json-schema/old-v1-message/schemaV1.js.map +1 -0
- package/dist/json-schema/old-v1-message/toMessageV1.d.ts +9 -0
- package/dist/json-schema/old-v1-message/toMessageV1.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/toMessageV1.js +67 -0
- package/dist/json-schema/old-v1-message/toMessageV1.js.map +1 -0
- package/dist/json-schema/old-v1-message/toMessageV1.test.d.ts +2 -0
- package/dist/json-schema/old-v1-message/toMessageV1.test.d.ts.map +1 -0
- package/dist/json-schema/old-v1-message/toMessageV1.test.js +85 -0
- package/dist/json-schema/old-v1-message/toMessageV1.test.js.map +1 -0
- package/dist/json-schema/pattern.d.ts +190 -0
- package/dist/json-schema/pattern.d.ts.map +1 -0
- package/dist/json-schema/pattern.js +43 -0
- package/dist/json-schema/pattern.js.map +1 -0
- package/dist/json-schema/settings.d.ts +31 -0
- package/dist/json-schema/settings.d.ts.map +1 -0
- package/dist/json-schema/settings.js +96 -0
- package/dist/json-schema/settings.js.map +1 -0
- package/dist/json-schema/settings.test-d.d.ts +2 -0
- package/dist/json-schema/settings.test-d.d.ts.map +1 -0
- package/dist/json-schema/settings.test-d.js +20 -0
- package/dist/json-schema/settings.test-d.js.map +1 -0
- package/dist/lix-plugin/applyChanges.d.ts +3 -0
- package/dist/lix-plugin/applyChanges.d.ts.map +1 -0
- package/dist/lix-plugin/applyChanges.js +127 -0
- package/dist/lix-plugin/applyChanges.js.map +1 -0
- package/dist/lix-plugin/applyChanges.test.d.ts +2 -0
- package/dist/lix-plugin/applyChanges.test.d.ts.map +1 -0
- package/dist/lix-plugin/applyChanges.test.js +135 -0
- package/dist/lix-plugin/applyChanges.test.js.map +1 -0
- package/dist/lix-plugin/detectConflicts.d.ts +3 -0
- package/dist/lix-plugin/detectConflicts.d.ts.map +1 -0
- package/dist/lix-plugin/detectConflicts.js +47 -0
- package/dist/lix-plugin/detectConflicts.js.map +1 -0
- package/dist/lix-plugin/detectConflicts.test.d.ts +2 -0
- package/dist/lix-plugin/detectConflicts.test.d.ts.map +1 -0
- package/dist/lix-plugin/detectConflicts.test.js +251 -0
- package/dist/lix-plugin/detectConflicts.test.js.map +1 -0
- package/dist/lix-plugin/inlangLixPluginV1.d.ts +8 -0
- package/dist/lix-plugin/inlangLixPluginV1.d.ts.map +1 -0
- package/dist/lix-plugin/inlangLixPluginV1.js +109 -0
- package/dist/lix-plugin/inlangLixPluginV1.js.map +1 -0
- package/dist/lix-plugin/inlangLixPluginV1.test.d.ts +2 -0
- package/dist/lix-plugin/inlangLixPluginV1.test.d.ts.map +1 -0
- package/dist/lix-plugin/inlangLixPluginV1.test.js +418 -0
- package/dist/lix-plugin/inlangLixPluginV1.test.js.map +1 -0
- package/dist/lix-plugin/merge.test.d.ts +2 -0
- package/dist/lix-plugin/merge.test.d.ts.map +1 -0
- package/dist/lix-plugin/merge.test.js +120 -0
- package/dist/lix-plugin/merge.test.js.map +1 -0
- package/dist/lix-plugin/resolveConflictBySelecting.test.d.ts +2 -0
- package/dist/lix-plugin/resolveConflictBySelecting.test.d.ts.map +1 -0
- package/dist/lix-plugin/resolveConflictBySelecting.test.js +176 -0
- package/dist/lix-plugin/resolveConflictBySelecting.test.js.map +1 -0
- package/dist/migrations/v2/createMessageV1.d.ts +28 -0
- package/dist/migrations/v2/createMessageV1.d.ts.map +1 -0
- package/dist/migrations/v2/createMessageV1.js +31 -0
- package/dist/migrations/v2/createMessageV1.js.map +1 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.d.ts +9 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.d.ts.map +1 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.js +31 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.js.map +1 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.d.ts +2 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.d.ts.map +1 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.js +45 -0
- package/dist/migrations/v2/withLanguageTagToLocaleMigration.test.js.map +1 -0
- package/dist/plugin/cache.d.ts +6 -0
- package/dist/plugin/cache.d.ts.map +1 -0
- package/dist/plugin/cache.js +59 -0
- package/dist/plugin/cache.js.map +1 -0
- package/dist/plugin/cache.test.d.ts +2 -0
- package/dist/plugin/cache.test.d.ts.map +1 -0
- package/dist/plugin/cache.test.js +61 -0
- package/dist/plugin/cache.test.js.map +1 -0
- package/dist/plugin/errors.d.ts +41 -0
- package/dist/plugin/errors.d.ts.map +1 -0
- package/dist/plugin/errors.js +48 -0
- package/dist/plugin/errors.js.map +1 -0
- package/dist/plugin/importPlugins.d.ts +19 -0
- package/dist/plugin/importPlugins.d.ts.map +1 -0
- package/dist/plugin/importPlugins.js +43 -0
- package/dist/plugin/importPlugins.js.map +1 -0
- package/dist/plugin/importPlugins.test.d.ts +2 -0
- package/dist/plugin/importPlugins.test.d.ts.map +1 -0
- package/dist/plugin/importPlugins.test.js +95 -0
- package/dist/plugin/importPlugins.test.js.map +1 -0
- package/dist/plugin/meta/ideExtension.d.ts +54 -0
- package/dist/plugin/meta/ideExtension.d.ts.map +1 -0
- package/dist/plugin/meta/ideExtension.js +5 -0
- package/dist/plugin/meta/ideExtension.js.map +1 -0
- package/dist/plugin/schema.d.ts +152 -0
- package/dist/plugin/schema.d.ts.map +1 -0
- package/dist/plugin/schema.js +5 -0
- package/dist/plugin/schema.js.map +1 -0
- package/dist/project/api.d.ts +74 -0
- package/dist/project/api.d.ts.map +1 -0
- package/dist/project/api.js +5 -0
- package/dist/project/api.js.map +1 -0
- package/dist/project/initHandleSaveToLixOnChange.d.ts +14 -0
- package/dist/project/initHandleSaveToLixOnChange.d.ts.map +1 -0
- package/dist/project/initHandleSaveToLixOnChange.js +87 -0
- package/dist/project/initHandleSaveToLixOnChange.js.map +1 -0
- package/dist/project/loadProject.d.ts +53 -0
- package/dist/project/loadProject.d.ts.map +1 -0
- package/dist/project/loadProject.js +167 -0
- package/dist/project/loadProject.js.map +1 -0
- package/dist/project/loadProject.test.d.ts.map +1 -0
- package/dist/project/loadProject.test.js +146 -0
- package/dist/project/loadProject.test.js.map +1 -0
- package/dist/project/loadProjectFromDirectory.d.ts +77 -0
- package/dist/project/loadProjectFromDirectory.d.ts.map +1 -0
- package/dist/project/loadProjectFromDirectory.js +584 -0
- package/dist/project/loadProjectFromDirectory.js.map +1 -0
- package/dist/project/loadProjectFromDirectory.test.d.ts +2 -0
- package/dist/project/loadProjectFromDirectory.test.d.ts.map +1 -0
- package/dist/project/loadProjectFromDirectory.test.js +663 -0
- package/dist/project/loadProjectFromDirectory.test.js.map +1 -0
- package/dist/project/loadProjectInMemory.d.ts +8 -0
- package/dist/project/loadProjectInMemory.d.ts.map +1 -0
- package/dist/project/loadProjectInMemory.js +32 -0
- package/dist/project/loadProjectInMemory.js.map +1 -0
- package/dist/project/loadProjectInMemory.test.d.ts +2 -0
- package/dist/project/loadProjectInMemory.test.d.ts.map +1 -0
- package/dist/project/loadProjectInMemory.test.js +27 -0
- package/dist/project/loadProjectInMemory.test.js.map +1 -0
- package/dist/project/maybeCaptureTelemetry.d.ts +13 -0
- package/dist/project/maybeCaptureTelemetry.d.ts.map +1 -0
- package/dist/project/maybeCaptureTelemetry.js +53 -0
- package/dist/project/maybeCaptureTelemetry.js.map +1 -0
- package/dist/project/maybeCaptureTelemetry.test.d.ts +2 -0
- package/dist/project/maybeCaptureTelemetry.test.d.ts.map +1 -0
- package/dist/project/maybeCaptureTelemetry.test.js +65 -0
- package/dist/project/maybeCaptureTelemetry.test.js.map +1 -0
- package/dist/project/newProject.d.ts +17 -0
- package/dist/project/newProject.d.ts.map +1 -0
- package/dist/project/newProject.js +71 -0
- package/dist/project/newProject.js.map +1 -0
- package/dist/project/newProject.test.d.ts +2 -0
- package/dist/project/newProject.test.d.ts.map +1 -0
- package/dist/project/newProject.test.js +37 -0
- package/dist/project/newProject.test.js.map +1 -0
- package/dist/project/saveProjectToDirectory.d.ts +8 -0
- package/dist/project/saveProjectToDirectory.d.ts.map +1 -0
- package/dist/project/saveProjectToDirectory.js +86 -0
- package/dist/project/saveProjectToDirectory.js.map +1 -0
- package/dist/project/saveProjectToDirectory.test.d.ts +2 -0
- package/dist/project/saveProjectToDirectory.test.d.ts.map +1 -0
- package/dist/project/saveProjectToDirectory.test.js +245 -0
- package/dist/project/saveProjectToDirectory.test.js.map +1 -0
- package/dist/project/state/id$.d.ts +6 -0
- package/dist/project/state/id$.d.ts.map +1 -0
- package/dist/project/state/id$.js +19 -0
- package/dist/project/state/id$.js.map +1 -0
- package/dist/project/state/id$.test.d.ts +2 -0
- package/dist/project/state/id$.test.d.ts.map +1 -0
- package/dist/project/state/id$.test.js +36 -0
- package/dist/project/state/id$.test.js.map +1 -0
- package/dist/project/state/setSettings.d.ts +7 -0
- package/dist/project/state/setSettings.d.ts.map +1 -0
- package/dist/project/state/setSettings.js +16 -0
- package/dist/project/state/setSettings.js.map +1 -0
- package/dist/project/state/setSettings.test.d.ts +2 -0
- package/dist/project/state/setSettings.test.d.ts.map +1 -0
- package/dist/project/state/setSettings.test.js +58 -0
- package/dist/project/state/setSettings.test.js.map +1 -0
- package/dist/project/state/settings$.d.ts +7 -0
- package/dist/project/state/settings$.d.ts.map +1 -0
- package/dist/project/state/settings$.js +21 -0
- package/dist/project/state/settings$.js.map +1 -0
- package/dist/project/state/settings$.test.d.ts +2 -0
- package/dist/project/state/settings$.test.d.ts.map +1 -0
- package/dist/project/state/settings$.test.js +51 -0
- package/dist/project/state/settings$.test.js.map +1 -0
- package/dist/project/state/state.d.ts +58 -0
- package/dist/project/state/state.d.ts.map +1 -0
- package/dist/project/state/state.js +67 -0
- package/dist/project/state/state.js.map +1 -0
- package/dist/project/state/state.test.d.ts +2 -0
- package/dist/project/state/state.test.d.ts.map +1 -0
- package/dist/project/state/state.test.js +103 -0
- package/dist/project/state/state.test.js.map +1 -0
- package/dist/query-utilities/index.d.ts +5 -0
- package/dist/query-utilities/index.d.ts.map +1 -0
- package/dist/query-utilities/index.js +8 -0
- package/dist/query-utilities/index.js.map +1 -0
- package/dist/query-utilities/insertBundleNested.d.ts +4 -0
- package/dist/query-utilities/insertBundleNested.d.ts.map +1 -0
- package/dist/query-utilities/insertBundleNested.js +39 -0
- package/dist/query-utilities/insertBundleNested.js.map +1 -0
- package/dist/query-utilities/pollQuery.d.ts +14 -0
- package/dist/query-utilities/pollQuery.d.ts.map +1 -0
- package/dist/query-utilities/pollQuery.js +22 -0
- package/dist/query-utilities/pollQuery.js.map +1 -0
- package/dist/query-utilities/pollQuery.test.d.ts +2 -0
- package/dist/query-utilities/pollQuery.test.d.ts.map +1 -0
- package/dist/query-utilities/pollQuery.test.js +67 -0
- package/dist/query-utilities/pollQuery.test.js.map +1 -0
- package/dist/query-utilities/selectBundleNested.d.ts +107 -0
- package/dist/query-utilities/selectBundleNested.d.ts.map +1 -0
- package/dist/query-utilities/selectBundleNested.js +43 -0
- package/dist/query-utilities/selectBundleNested.js.map +1 -0
- package/dist/query-utilities/updateBundleNested.d.ts +12 -0
- package/dist/query-utilities/updateBundleNested.d.ts.map +1 -0
- package/dist/query-utilities/updateBundleNested.js +25 -0
- package/dist/query-utilities/updateBundleNested.js.map +1 -0
- package/dist/query-utilities/upsertBundleNested.d.ts +4 -0
- package/dist/query-utilities/upsertBundleNested.d.ts.map +1 -0
- package/dist/query-utilities/upsertBundleNested.js +50 -0
- package/dist/query-utilities/upsertBundleNested.js.map +1 -0
- package/dist/services/env-variables/index.d.ts +6 -0
- package/dist/services/env-variables/index.d.ts.map +1 -0
- package/dist/services/env-variables/index.js +9 -0
- package/dist/services/env-variables/index.js.map +1 -0
- package/dist/services/error-reporting/index.d.ts +15 -0
- package/dist/services/error-reporting/index.d.ts.map +1 -0
- package/dist/services/error-reporting/index.js +30 -0
- package/dist/services/error-reporting/index.js.map +1 -0
- package/dist/{telemetry → services/telemetry}/capture.d.ts +4 -2
- package/dist/services/telemetry/capture.d.ts.map +1 -0
- package/dist/services/telemetry/capture.js +77 -0
- package/dist/services/telemetry/capture.js.map +1 -0
- package/dist/services/telemetry/capture.test.d.ts +2 -0
- package/dist/services/telemetry/capture.test.d.ts.map +1 -0
- package/dist/services/telemetry/capture.test.js +44 -0
- package/dist/services/telemetry/capture.test.js.map +1 -0
- package/dist/utilities/detectJsonFormatting.d.ts +11 -0
- package/dist/utilities/detectJsonFormatting.d.ts.map +1 -0
- package/dist/utilities/detectJsonFormatting.js +83 -0
- package/dist/utilities/detectJsonFormatting.js.map +1 -0
- package/dist/utilities/detectJsonFormatting.test.d.ts +2 -0
- package/dist/utilities/detectJsonFormatting.test.d.ts.map +1 -0
- package/dist/utilities/detectJsonFormatting.test.js +33 -0
- package/dist/utilities/detectJsonFormatting.test.js.map +1 -0
- package/package.json +32 -40
- package/src/database/initDb.ts +34 -0
- package/src/database/initDbAndSchema.test.ts +125 -0
- package/src/database/jsonbPlugin.test.ts +154 -0
- package/src/database/jsonbPlugin.ts +215 -0
- package/src/database/schema.ts +127 -0
- package/src/helper.ts +113 -0
- package/src/human-id/human-id.ts +14 -0
- package/src/{storage/human-id → human-id}/words.test.ts +14 -14
- package/src/{storage/human-id → human-id}/words.ts +4 -4
- package/src/import-export/exportFiles.ts +36 -0
- package/src/import-export/importFiles.test.ts +211 -0
- package/src/import-export/importFiles.ts +142 -0
- package/src/import-export/roundtrip.test.ts +313 -0
- package/src/import-export/upsertBundleNestedMatchByProperties.ts +74 -0
- package/src/index.ts +29 -37
- package/src/json-schema/old-v1-message/README.md +1 -0
- package/src/json-schema/old-v1-message/fromMessageV1.test.ts +87 -0
- package/src/json-schema/old-v1-message/fromMessageV1.ts +99 -0
- package/src/json-schema/old-v1-message/schemaV1.ts +66 -0
- package/src/json-schema/old-v1-message/toMessageV1.test.ts +87 -0
- package/src/json-schema/old-v1-message/toMessageV1.ts +79 -0
- package/src/json-schema/pattern.ts +59 -0
- package/src/json-schema/settings.test-d.ts +21 -0
- package/src/json-schema/settings.ts +138 -0
- package/src/lix-plugin/applyChanges.test.ts +150 -0
- package/src/lix-plugin/applyChanges.ts +171 -0
- package/src/lix-plugin/detectConflicts.test.ts +286 -0
- package/src/lix-plugin/detectConflicts.ts +62 -0
- package/src/lix-plugin/inlangLixPluginV1.test.ts +439 -0
- package/src/lix-plugin/inlangLixPluginV1.ts +132 -0
- package/src/lix-plugin/merge.test.ts +133 -0
- package/src/lix-plugin/resolveConflictBySelecting.test.ts +188 -0
- package/src/migrations/v2/createMessageV1.ts +37 -0
- package/src/migrations/v2/withLanguageTagToLocaleMigration.test.ts +51 -0
- package/src/migrations/v2/withLanguageTagToLocaleMigration.ts +31 -0
- package/src/plugin/cache.test.ts +83 -0
- package/src/plugin/cache.ts +79 -0
- package/src/plugin/errors.ts +67 -0
- package/src/plugin/importPlugins.test.ts +107 -0
- package/src/plugin/importPlugins.ts +60 -0
- package/src/plugin/meta/ideExtension.ts +56 -0
- package/src/plugin/schema.ts +165 -0
- package/src/project/api.ts +77 -0
- package/src/project/initHandleSaveToLixOnChange.ts +93 -0
- package/src/project/loadProject.test.ts +177 -0
- package/src/project/loadProject.ts +245 -0
- package/src/project/loadProjectFromDirectory.test.ts +854 -0
- package/src/project/loadProjectFromDirectory.ts +752 -0
- package/src/project/loadProjectInMemory.test.ts +29 -0
- package/src/project/loadProjectInMemory.ts +36 -0
- package/src/project/maybeCaptureTelemetry.test.ts +72 -0
- package/src/project/maybeCaptureTelemetry.ts +61 -0
- package/src/project/newProject.test.ts +36 -0
- package/src/project/newProject.ts +78 -0
- package/src/project/saveProjectToDirectory.test.ts +310 -0
- package/src/project/saveProjectToDirectory.ts +100 -0
- package/src/query-utilities/index.ts +4 -0
- package/src/query-utilities/insertBundleNested.ts +46 -0
- package/src/query-utilities/selectBundleNested.ts +46 -0
- package/src/query-utilities/updateBundleNested.ts +35 -0
- package/src/query-utilities/upsertBundleNested.ts +61 -0
- package/src/services/env-variables/createIndexFile.js +40 -0
- package/src/{env-variables → services/env-variables}/index.d.ts +8 -5
- package/src/services/error-reporting/index.ts +28 -0
- package/src/services/telemetry/capture.test.ts +48 -0
- package/src/services/telemetry/capture.ts +98 -0
- package/src/utilities/detectJsonFormatting.test.ts +38 -0
- package/src/utilities/detectJsonFormatting.ts +109 -0
- package/dist/adapter/solidAdapter.d.ts +0 -33
- package/dist/adapter/solidAdapter.d.ts.map +0 -1
- package/dist/adapter/solidAdapter.js +0 -40
- package/dist/adapter/solidAdapter.test.d.ts +0 -2
- package/dist/adapter/solidAdapter.test.d.ts.map +0 -1
- package/dist/adapter/solidAdapter.test.js +0 -356
- package/dist/api.d.ts +0 -113
- package/dist/api.d.ts.map +0 -1
- package/dist/api.js +0 -1
- package/dist/api.test-d.d.ts +0 -2
- package/dist/api.test-d.d.ts.map +0 -1
- package/dist/api.test-d.js +0 -4
- package/dist/createMessageLintReportsQuery.d.ts +0 -12
- package/dist/createMessageLintReportsQuery.d.ts.map +0 -1
- package/dist/createMessageLintReportsQuery.js +0 -176
- package/dist/createMessagesQuery.d.ts +0 -19
- package/dist/createMessagesQuery.d.ts.map +0 -1
- package/dist/createMessagesQuery.js +0 -451
- package/dist/createMessagesQuery.test.d.ts +0 -2
- package/dist/createMessagesQuery.test.d.ts.map +0 -1
- package/dist/createMessagesQuery.test.js +0 -402
- package/dist/createNewProject.d.ts +0 -12
- package/dist/createNewProject.d.ts.map +0 -1
- package/dist/createNewProject.js +0 -38
- package/dist/createNewProject.test.d.ts +0 -2
- package/dist/createNewProject.test.d.ts.map +0 -1
- package/dist/createNewProject.test.js +0 -91
- package/dist/createNodeishFsWithAbsolutePaths.d.ts +0 -12
- package/dist/createNodeishFsWithAbsolutePaths.d.ts.map +0 -1
- package/dist/createNodeishFsWithAbsolutePaths.js +0 -38
- package/dist/createNodeishFsWithAbsolutePaths.test.d.ts +0 -2
- package/dist/createNodeishFsWithAbsolutePaths.test.d.ts.map +0 -1
- package/dist/createNodeishFsWithAbsolutePaths.test.js +0 -44
- package/dist/createNodeishFsWithWatcher.d.ts +0 -14
- package/dist/createNodeishFsWithWatcher.d.ts.map +0 -1
- package/dist/createNodeishFsWithWatcher.js +0 -75
- package/dist/createNodeishFsWithWatcher.test.d.ts +0 -2
- package/dist/createNodeishFsWithWatcher.test.d.ts.map +0 -1
- package/dist/createNodeishFsWithWatcher.test.js +0 -38
- package/dist/defaultProjectSettings.d.ts +0 -14
- package/dist/defaultProjectSettings.d.ts.map +0 -1
- package/dist/defaultProjectSettings.js +0 -22
- package/dist/env-variables/index.d.ts +0 -4
- package/dist/env-variables/index.d.ts.map +0 -1
- package/dist/env-variables/index.js +0 -3
- package/dist/errors.d.ts +0 -48
- package/dist/errors.d.ts.map +0 -1
- package/dist/errors.js +0 -62
- package/dist/lint/index.d.ts +0 -3
- package/dist/lint/index.d.ts.map +0 -1
- package/dist/lint/index.js +0 -2
- package/dist/lint/message/errors.d.ts +0 -7
- package/dist/lint/message/errors.d.ts.map +0 -1
- package/dist/lint/message/errors.js +0 -9
- package/dist/lint/message/lintMessages.d.ts +0 -13
- package/dist/lint/message/lintMessages.d.ts.map +0 -1
- package/dist/lint/message/lintMessages.js +0 -12
- package/dist/lint/message/lintMessages.test.d.ts +0 -2
- package/dist/lint/message/lintMessages.test.d.ts.map +0 -1
- package/dist/lint/message/lintMessages.test.js +0 -107
- package/dist/lint/message/lintSingleMessage.d.ts +0 -19
- package/dist/lint/message/lintSingleMessage.d.ts.map +0 -1
- package/dist/lint/message/lintSingleMessage.js +0 -38
- package/dist/lint/message/lintSingleMessage.test.d.ts +0 -2
- package/dist/lint/message/lintSingleMessage.test.d.ts.map +0 -1
- package/dist/lint/message/lintSingleMessage.test.js +0 -161
- package/dist/listProjects.d.ts +0 -5
- package/dist/listProjects.d.ts.map +0 -1
- package/dist/listProjects.js +0 -38
- package/dist/listProjects.test.d.ts +0 -2
- package/dist/listProjects.test.d.ts.map +0 -1
- package/dist/listProjects.test.js +0 -72
- package/dist/loadProject.d.ts +0 -19
- package/dist/loadProject.d.ts.map +0 -1
- package/dist/loadProject.js +0 -343
- package/dist/loadProject.test.d.ts.map +0 -1
- package/dist/loadProject.test.js +0 -975
- package/dist/messages/errors.d.ts +0 -13
- package/dist/messages/errors.d.ts.map +0 -1
- package/dist/messages/errors.js +0 -18
- package/dist/messages/index.d.ts +0 -3
- package/dist/messages/index.d.ts.map +0 -1
- package/dist/messages/index.js +0 -2
- package/dist/messages/variant.d.ts +0 -46
- package/dist/messages/variant.d.ts.map +0 -1
- package/dist/messages/variant.js +0 -176
- package/dist/messages/variant.test.d.ts +0 -2
- package/dist/messages/variant.test.d.ts.map +0 -1
- package/dist/messages/variant.test.js +0 -439
- package/dist/migrations/maybeAddModuleCache.d.ts +0 -6
- package/dist/migrations/maybeAddModuleCache.d.ts.map +0 -1
- package/dist/migrations/maybeAddModuleCache.js +0 -62
- package/dist/migrations/maybeCreateFirstProjectId.d.ts +0 -16
- package/dist/migrations/maybeCreateFirstProjectId.d.ts.map +0 -1
- package/dist/migrations/maybeCreateFirstProjectId.js +0 -46
- package/dist/migrations/maybeCreateFirstProjectId.test.d.ts +0 -2
- package/dist/migrations/maybeCreateFirstProjectId.test.d.ts.map +0 -1
- package/dist/migrations/maybeCreateFirstProjectId.test.js +0 -24
- package/dist/migrations/migrateToDirectory.d.ts +0 -10
- package/dist/migrations/migrateToDirectory.d.ts.map +0 -1
- package/dist/migrations/migrateToDirectory.js +0 -48
- package/dist/migrations/migrateToDirectory.test.d.ts +0 -2
- package/dist/migrations/migrateToDirectory.test.d.ts.map +0 -1
- package/dist/migrations/migrateToDirectory.test.js +0 -48
- package/dist/parseConfig.d.ts +0 -8
- package/dist/parseConfig.d.ts.map +0 -1
- package/dist/parseConfig.js +0 -26
- package/dist/persistence/batchedIO.d.ts +0 -11
- package/dist/persistence/batchedIO.d.ts.map +0 -1
- package/dist/persistence/batchedIO.js +0 -49
- package/dist/persistence/batchedIO.test.d.ts +0 -2
- package/dist/persistence/batchedIO.test.d.ts.map +0 -1
- package/dist/persistence/batchedIO.test.js +0 -56
- package/dist/persistence/filelock/acquireFileLock.d.ts +0 -3
- package/dist/persistence/filelock/acquireFileLock.d.ts.map +0 -1
- package/dist/persistence/filelock/acquireFileLock.js +0 -111
- package/dist/persistence/filelock/releaseLock.d.ts +0 -3
- package/dist/persistence/filelock/releaseLock.d.ts.map +0 -1
- package/dist/persistence/filelock/releaseLock.js +0 -24
- package/dist/persistence/store.d.ts +0 -107
- package/dist/persistence/store.d.ts.map +0 -1
- package/dist/persistence/store.js +0 -99
- package/dist/persistence/store.test.d.ts +0 -2
- package/dist/persistence/store.test.d.ts.map +0 -1
- package/dist/persistence/store.test.js +0 -79
- package/dist/persistence/storeApi.d.ts +0 -22
- package/dist/persistence/storeApi.d.ts.map +0 -1
- package/dist/persistence/storeApi.js +0 -1
- package/dist/reactivity/map.d.ts +0 -67
- package/dist/reactivity/map.d.ts.map +0 -1
- package/dist/reactivity/map.js +0 -143
- package/dist/reactivity/solid.d.ts +0 -14
- package/dist/reactivity/solid.d.ts.map +0 -1
- package/dist/reactivity/solid.js +0 -15
- package/dist/reactivity/solid.test.d.ts +0 -2
- package/dist/reactivity/solid.test.d.ts.map +0 -1
- package/dist/reactivity/solid.test.js +0 -189
- package/dist/reactivity/trigger.d.ts +0 -11
- package/dist/reactivity/trigger.d.ts.map +0 -1
- package/dist/reactivity/trigger.js +0 -46
- package/dist/resolve-modules/cache.d.ts +0 -6
- package/dist/resolve-modules/cache.d.ts.map +0 -1
- package/dist/resolve-modules/cache.js +0 -58
- package/dist/resolve-modules/errors.d.ts +0 -41
- package/dist/resolve-modules/errors.d.ts.map +0 -1
- package/dist/resolve-modules/errors.js +0 -45
- package/dist/resolve-modules/import.d.ts +0 -19
- package/dist/resolve-modules/import.d.ts.map +0 -1
- package/dist/resolve-modules/import.js +0 -102
- package/dist/resolve-modules/import.test.d.ts +0 -2
- package/dist/resolve-modules/import.test.d.ts.map +0 -1
- package/dist/resolve-modules/import.test.js +0 -47
- package/dist/resolve-modules/index.d.ts +0 -3
- package/dist/resolve-modules/index.d.ts.map +0 -1
- package/dist/resolve-modules/index.js +0 -2
- package/dist/resolve-modules/message-lint-rules/errors.d.ts +0 -9
- package/dist/resolve-modules/message-lint-rules/errors.d.ts.map +0 -1
- package/dist/resolve-modules/message-lint-rules/errors.js +0 -6
- package/dist/resolve-modules/message-lint-rules/resolveMessageLintRules.d.ts +0 -9
- package/dist/resolve-modules/message-lint-rules/resolveMessageLintRules.d.ts.map +0 -1
- package/dist/resolve-modules/message-lint-rules/resolveMessageLintRules.js +0 -24
- package/dist/resolve-modules/plugins/errors.d.ts +0 -33
- package/dist/resolve-modules/plugins/errors.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/errors.js +0 -38
- package/dist/resolve-modules/plugins/resolvePlugins.d.ts +0 -3
- package/dist/resolve-modules/plugins/resolvePlugins.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/resolvePlugins.js +0 -92
- package/dist/resolve-modules/plugins/resolvePlugins.test.d.ts +0 -2
- package/dist/resolve-modules/plugins/resolvePlugins.test.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/resolvePlugins.test.js +0 -252
- package/dist/resolve-modules/plugins/types.d.ts +0 -57
- package/dist/resolve-modules/plugins/types.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/types.js +0 -1
- package/dist/resolve-modules/plugins/types.test.d.ts +0 -2
- package/dist/resolve-modules/plugins/types.test.d.ts.map +0 -1
- package/dist/resolve-modules/plugins/types.test.js +0 -45
- package/dist/resolve-modules/resolveModules.d.ts +0 -3
- package/dist/resolve-modules/resolveModules.d.ts.map +0 -1
- package/dist/resolve-modules/resolveModules.js +0 -80
- package/dist/resolve-modules/resolveModules.test.d.ts +0 -2
- package/dist/resolve-modules/resolveModules.test.d.ts.map +0 -1
- package/dist/resolve-modules/resolveModules.test.js +0 -185
- package/dist/resolve-modules/types.d.ts +0 -63
- package/dist/resolve-modules/types.d.ts.map +0 -1
- package/dist/resolve-modules/types.js +0 -1
- package/dist/resolve-modules/validateModuleSettings.test.d.ts +0 -2
- package/dist/resolve-modules/validateModuleSettings.test.d.ts.map +0 -1
- package/dist/resolve-modules/validateModuleSettings.test.js +0 -71
- package/dist/resolve-modules/validatedModuleSettings.d.ts +0 -7
- package/dist/resolve-modules/validatedModuleSettings.d.ts.map +0 -1
- package/dist/resolve-modules/validatedModuleSettings.js +0 -11
- package/dist/storage/helper.d.ts +0 -11
- package/dist/storage/helper.d.ts.map +0 -1
- package/dist/storage/helper.js +0 -63
- package/dist/storage/helpers.test.d.ts +0 -2
- package/dist/storage/helpers.test.d.ts.map +0 -1
- package/dist/storage/helpers.test.js +0 -84
- package/dist/storage/human-id/human-readable-id.d.ts +0 -3
- package/dist/storage/human-id/human-readable-id.d.ts.map +0 -1
- package/dist/storage/human-id/human-readable-id.js +0 -20
- package/dist/storage/human-id/words.d.ts.map +0 -1
- package/dist/storage/human-id/words.test.d.ts.map +0 -1
- package/dist/telemetry/capture.d.ts.map +0 -1
- package/dist/telemetry/capture.js +0 -39
- package/dist/telemetry/groupIdentify.d.ts +0 -13
- package/dist/telemetry/groupIdentify.d.ts.map +0 -1
- package/dist/telemetry/groupIdentify.js +0 -35
- package/dist/test-utilities/createMessage.d.ts +0 -18
- package/dist/test-utilities/createMessage.d.ts.map +0 -1
- package/dist/test-utilities/createMessage.js +0 -17
- package/dist/test-utilities/createMessage.test.d.ts +0 -2
- package/dist/test-utilities/createMessage.test.d.ts.map +0 -1
- package/dist/test-utilities/createMessage.test.js +0 -106
- package/dist/test-utilities/index.d.ts +0 -3
- package/dist/test-utilities/index.d.ts.map +0 -1
- package/dist/test-utilities/index.js +0 -2
- package/dist/test-utilities/sleep.d.ts +0 -4
- package/dist/test-utilities/sleep.d.ts.map +0 -1
- package/dist/test-utilities/sleep.js +0 -9
- package/dist/v2/helper.d.ts +0 -43
- package/dist/v2/helper.d.ts.map +0 -1
- package/dist/v2/helper.js +0 -75
- package/dist/v2/helper.test.d.ts +0 -2
- package/dist/v2/helper.test.d.ts.map +0 -1
- package/dist/v2/helper.test.js +0 -92
- package/dist/v2/index.d.ts +0 -4
- package/dist/v2/index.d.ts.map +0 -1
- package/dist/v2/index.js +0 -2
- package/dist/v2/mocks/index.d.ts +0 -3
- package/dist/v2/mocks/index.d.ts.map +0 -1
- package/dist/v2/mocks/index.js +0 -2
- package/dist/v2/mocks/multipleMatcher/bundle.d.ts +0 -3
- package/dist/v2/mocks/multipleMatcher/bundle.d.ts.map +0 -1
- package/dist/v2/mocks/multipleMatcher/bundle.js +0 -194
- package/dist/v2/mocks/multipleMatcher/bundle.test.d.ts +0 -2
- package/dist/v2/mocks/multipleMatcher/bundle.test.d.ts.map +0 -1
- package/dist/v2/mocks/multipleMatcher/bundle.test.js +0 -10
- package/dist/v2/mocks/plural/bundle.d.ts +0 -3
- package/dist/v2/mocks/plural/bundle.d.ts.map +0 -1
- package/dist/v2/mocks/plural/bundle.js +0 -162
- package/dist/v2/mocks/plural/bundle.test.d.ts +0 -2
- package/dist/v2/mocks/plural/bundle.test.d.ts.map +0 -1
- package/dist/v2/mocks/plural/bundle.test.js +0 -15
- package/dist/v2/shim.d.ts +0 -12
- package/dist/v2/shim.d.ts.map +0 -1
- package/dist/v2/shim.js +0 -151
- package/dist/v2/shim.test.d.ts +0 -2
- package/dist/v2/shim.test.d.ts.map +0 -1
- package/dist/v2/shim.test.js +0 -49
- package/dist/v2/stubQueryApi.d.ts +0 -9
- package/dist/v2/stubQueryApi.d.ts.map +0 -1
- package/dist/v2/stubQueryApi.js +0 -38
- package/dist/v2/types.d.ts +0 -521
- package/dist/v2/types.d.ts.map +0 -1
- package/dist/v2/types.js +0 -78
- package/dist/validateProjectPath.d.ts +0 -17
- package/dist/validateProjectPath.d.ts.map +0 -1
- package/dist/validateProjectPath.js +0 -31
- package/dist/validateProjectPath.test.d.ts +0 -2
- package/dist/validateProjectPath.test.d.ts.map +0 -1
- package/dist/validateProjectPath.test.js +0 -40
- package/dist/versionedInterfaces.d.ts +0 -8
- package/dist/versionedInterfaces.d.ts.map +0 -1
- package/dist/versionedInterfaces.js +0 -8
- package/src/adapter/solidAdapter.test.ts +0 -472
- package/src/adapter/solidAdapter.ts +0 -79
- package/src/api.test-d.ts +0 -8
- package/src/api.ts +0 -116
- package/src/createMessageLintReportsQuery.ts +0 -225
- package/src/createMessagesQuery.test.ts +0 -538
- package/src/createMessagesQuery.ts +0 -635
- package/src/createNewProject.test.ts +0 -105
- package/src/createNewProject.ts +0 -46
- package/src/createNodeishFsWithAbsolutePaths.test.ts +0 -55
- package/src/createNodeishFsWithAbsolutePaths.ts +0 -52
- package/src/createNodeishFsWithWatcher.test.ts +0 -50
- package/src/createNodeishFsWithWatcher.ts +0 -85
- package/src/defaultProjectSettings.ts +0 -26
- package/src/env-variables/.prettierignore +0 -1
- package/src/env-variables/createIndexFile.js +0 -28
- package/src/errors.ts +0 -84
- package/src/lint/index.ts +0 -2
- package/src/lint/message/errors.ts +0 -9
- package/src/lint/message/lintMessages.test.ts +0 -126
- package/src/lint/message/lintMessages.ts +0 -25
- package/src/lint/message/lintSingleMessage.test.ts +0 -191
- package/src/lint/message/lintSingleMessage.ts +0 -57
- package/src/listProjects.test.ts +0 -91
- package/src/listProjects.ts +0 -48
- package/src/loadProject.test.ts +0 -1173
- package/src/loadProject.ts +0 -460
- package/src/messages/errors.ts +0 -25
- package/src/messages/index.ts +0 -2
- package/src/messages/variant.test.ts +0 -511
- package/src/messages/variant.ts +0 -247
- package/src/migrations/maybeAddModuleCache.ts +0 -68
- package/src/migrations/maybeCreateFirstProjectId.test.ts +0 -31
- package/src/migrations/maybeCreateFirstProjectId.ts +0 -51
- package/src/migrations/migrateToDirectory.test.ts +0 -54
- package/src/migrations/migrateToDirectory.ts +0 -62
- package/src/parseConfig.ts +0 -35
- package/src/persistence/batchedIO.test.ts +0 -63
- package/src/persistence/batchedIO.ts +0 -64
- package/src/persistence/filelock/acquireFileLock.ts +0 -129
- package/src/persistence/filelock/releaseLock.ts +0 -29
- package/src/persistence/store.test.ts +0 -102
- package/src/persistence/store.ts +0 -119
- package/src/persistence/storeApi.ts +0 -19
- package/src/reactivity/map.ts +0 -135
- package/src/reactivity/solid.test.ts +0 -222
- package/src/reactivity/solid.ts +0 -42
- package/src/reactivity/trigger.ts +0 -46
- package/src/resolve-modules/cache.ts +0 -89
- package/src/resolve-modules/errors.ts +0 -69
- package/src/resolve-modules/import.test.ts +0 -62
- package/src/resolve-modules/import.ts +0 -133
- package/src/resolve-modules/index.ts +0 -2
- package/src/resolve-modules/message-lint-rules/errors.ts +0 -9
- package/src/resolve-modules/message-lint-rules/resolveMessageLintRules.ts +0 -27
- package/src/resolve-modules/plugins/errors.ts +0 -56
- package/src/resolve-modules/plugins/resolvePlugins.test.ts +0 -301
- package/src/resolve-modules/plugins/resolvePlugins.ts +0 -129
- package/src/resolve-modules/plugins/types.test.ts +0 -53
- package/src/resolve-modules/plugins/types.ts +0 -76
- package/src/resolve-modules/resolveModules.test.ts +0 -224
- package/src/resolve-modules/resolveModules.ts +0 -113
- package/src/resolve-modules/types.ts +0 -72
- package/src/resolve-modules/validateModuleSettings.test.ts +0 -85
- package/src/resolve-modules/validatedModuleSettings.ts +0 -19
- package/src/storage/helper.ts +0 -74
- package/src/storage/helpers.test.ts +0 -95
- package/src/storage/human-id/human-readable-id.ts +0 -27
- package/src/telemetry/capture.ts +0 -49
- package/src/telemetry/groupIdentify.ts +0 -41
- package/src/test-utilities/createMessage.test.ts +0 -118
- package/src/test-utilities/createMessage.ts +0 -21
- package/src/test-utilities/index.ts +0 -2
- package/src/test-utilities/sleep.ts +0 -11
- package/src/v2/helper.test.ts +0 -95
- package/src/v2/helper.ts +0 -98
- package/src/v2/index.ts +0 -3
- package/src/v2/mocks/index.ts +0 -2
- package/src/v2/mocks/multipleMatcher/bundle.test.ts +0 -11
- package/src/v2/mocks/multipleMatcher/bundle.ts +0 -196
- package/src/v2/mocks/plural/bundle.test.ts +0 -18
- package/src/v2/mocks/plural/bundle.ts +0 -164
- package/src/v2/shim.test.ts +0 -56
- package/src/v2/shim.ts +0 -173
- package/src/v2/stubQueryApi.ts +0 -43
- package/src/v2/types.ts +0 -159
- package/src/validateProjectPath.test.ts +0 -50
- package/src/validateProjectPath.ts +0 -38
- package/src/versionedInterfaces.ts +0 -9
- /package/dist/{storage/human-id → human-id}/words.d.ts +0 -0
- /package/dist/{storage/human-id → human-id}/words.test.d.ts +0 -0
- /package/dist/{loadProject.test.d.ts → project/loadProject.test.d.ts} +0 -0
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from "vitest"
|
|
2
|
-
import { createNewProject } from "./createNewProject.js"
|
|
3
|
-
import { mockRepo } from "@lix-js/client"
|
|
4
|
-
import { defaultProjectSettings } from "./defaultProjectSettings.js"
|
|
5
|
-
import { loadProject } from "./loadProject.js"
|
|
6
|
-
import { createMessage } from "./test-utilities/createMessage.js"
|
|
7
|
-
import { sleep } from "./test-utilities/sleep.js"
|
|
8
|
-
|
|
9
|
-
describe("createNewProject", () => {
|
|
10
|
-
it("should throw if a path does not end with .inlang", async () => {
|
|
11
|
-
const repo = await mockRepo()
|
|
12
|
-
const projectPath = "/test/project.inl"
|
|
13
|
-
try {
|
|
14
|
-
await createNewProject({ projectPath, repo, projectSettings: defaultProjectSettings })
|
|
15
|
-
// should not reach this point
|
|
16
|
-
throw new Error("Expected an error")
|
|
17
|
-
} catch (e) {
|
|
18
|
-
expect((e as Error).message).toMatch(
|
|
19
|
-
'Expected a path ending in "{name}.inlang" but received "/test/project.inl"'
|
|
20
|
-
)
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
it("should throw if projectPath is not an absolute path", async () => {
|
|
25
|
-
const repo = await mockRepo()
|
|
26
|
-
const projectPath = "test/project.inlang"
|
|
27
|
-
try {
|
|
28
|
-
await createNewProject({ projectPath, repo, projectSettings: defaultProjectSettings })
|
|
29
|
-
// should not reach this point
|
|
30
|
-
throw new Error("Expected an error")
|
|
31
|
-
} catch (e) {
|
|
32
|
-
expect((e as Error).message).toMatch(
|
|
33
|
-
'Expected an absolute path but received "test/project.inlang"'
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
it("should throw if the path already exists", async () => {
|
|
39
|
-
const repo = await mockRepo()
|
|
40
|
-
const projectPath = "/test/project.inlang"
|
|
41
|
-
await repo.nodeishFs.mkdir(projectPath, { recursive: true })
|
|
42
|
-
try {
|
|
43
|
-
await createNewProject({ projectPath, repo, projectSettings: defaultProjectSettings })
|
|
44
|
-
// should not reach this point
|
|
45
|
-
throw new Error("Expected an error")
|
|
46
|
-
} catch (e) {
|
|
47
|
-
expect((e as Error).message).toMatch(
|
|
48
|
-
'projectPath already exists, received "/test/project.inlang"'
|
|
49
|
-
)
|
|
50
|
-
}
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
it("should create default defaultProjectSettings in projectPath", async () => {
|
|
54
|
-
const repo = await mockRepo()
|
|
55
|
-
const projectPath = "/test/project.inlang"
|
|
56
|
-
await createNewProject({ projectPath, repo, projectSettings: defaultProjectSettings })
|
|
57
|
-
const json = await repo.nodeishFs.readFile(`${projectPath}/settings.json`, {
|
|
58
|
-
encoding: "utf-8",
|
|
59
|
-
})
|
|
60
|
-
const settings = JSON.parse(json)
|
|
61
|
-
expect(settings).toEqual(defaultProjectSettings)
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
it("should create different projectSettings in projectPath", async () => {
|
|
65
|
-
const repo = await mockRepo()
|
|
66
|
-
const projectPath = "/test/project.inlang"
|
|
67
|
-
const projectSettings = { ...defaultProjectSettings, languageTags: ["en", "de", "fr"] }
|
|
68
|
-
await createNewProject({ projectPath, repo, projectSettings })
|
|
69
|
-
const json = await repo.nodeishFs.readFile(`${projectPath}/settings.json`, {
|
|
70
|
-
encoding: "utf-8",
|
|
71
|
-
})
|
|
72
|
-
const settings = JSON.parse(json)
|
|
73
|
-
expect(settings).toEqual(projectSettings)
|
|
74
|
-
expect(settings).not.toEqual(defaultProjectSettings)
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
it("should load the project after creating it", async () => {
|
|
78
|
-
const repo = await mockRepo()
|
|
79
|
-
const projectPath = "/test/project.inlang"
|
|
80
|
-
await createNewProject({ projectPath, repo, projectSettings: defaultProjectSettings })
|
|
81
|
-
|
|
82
|
-
const project = await loadProject({ projectPath, repo })
|
|
83
|
-
expect(project.errors()).toEqual([])
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
it("should create messages inside the project directory", async () => {
|
|
87
|
-
const repo = await mockRepo()
|
|
88
|
-
const projectPath = "/test/project.inlang"
|
|
89
|
-
await createNewProject({ projectPath, repo, projectSettings: defaultProjectSettings })
|
|
90
|
-
const project = await loadProject({ projectPath, repo })
|
|
91
|
-
expect(project.errors()).toEqual([])
|
|
92
|
-
|
|
93
|
-
const testMessage = createMessage("test", { en: "test message" })
|
|
94
|
-
project.query.messages.create({ data: testMessage })
|
|
95
|
-
const messages = project.query.messages.getAll()
|
|
96
|
-
expect(messages.length).toBe(1)
|
|
97
|
-
expect(messages[0]).toEqual(testMessage)
|
|
98
|
-
|
|
99
|
-
await sleep(20)
|
|
100
|
-
|
|
101
|
-
const json = await repo.nodeishFs.readFile("/test/messages/en.json", { encoding: "utf-8" })
|
|
102
|
-
const jsonMessages = JSON.parse(json)
|
|
103
|
-
expect(jsonMessages["test"]).toEqual("test message")
|
|
104
|
-
})
|
|
105
|
-
})
|
package/src/createNewProject.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import type { Repository } from "@lix-js/client"
|
|
2
|
-
import type { NodeishFilesystem } from "@lix-js/fs"
|
|
3
|
-
import { ProjectSettings } from "@inlang/project-settings"
|
|
4
|
-
import { assertValidProjectPath } from "./validateProjectPath.js"
|
|
5
|
-
import { defaultProjectSettings } from "./defaultProjectSettings.js"
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Creates a new project in the given directory.
|
|
9
|
-
* The directory must be an absolute path, must not exist, and must end with {name}.inlang
|
|
10
|
-
*/
|
|
11
|
-
export async function createNewProject(args: {
|
|
12
|
-
projectPath: string
|
|
13
|
-
repo: Repository
|
|
14
|
-
projectSettings: ProjectSettings
|
|
15
|
-
}): Promise<void> {
|
|
16
|
-
assertValidProjectPath(args.projectPath)
|
|
17
|
-
|
|
18
|
-
const nodeishFs = args.repo.nodeishFs
|
|
19
|
-
if (await directoryExists(args.projectPath, nodeishFs)) {
|
|
20
|
-
throw new Error(`projectPath already exists, received "${args.projectPath}"`)
|
|
21
|
-
}
|
|
22
|
-
const settingsText = JSON.stringify(args.projectSettings ?? defaultProjectSettings, undefined, 2)
|
|
23
|
-
|
|
24
|
-
await nodeishFs.mkdir(args.projectPath, { recursive: true })
|
|
25
|
-
await Promise.all([
|
|
26
|
-
nodeishFs.writeFile(`${args.projectPath}/settings.json`, settingsText),
|
|
27
|
-
nodeishFs.writeFile(`${args.projectPath}/.gitignore`, "cache"),
|
|
28
|
-
nodeishFs.mkdir(`${args.projectPath}/cache/modules`, { recursive: true }),
|
|
29
|
-
])
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Returns true if the path exists (file or directory), false otherwise.
|
|
34
|
-
*/
|
|
35
|
-
async function directoryExists(filePath: string, nodeishFs: NodeishFilesystem) {
|
|
36
|
-
try {
|
|
37
|
-
const stat = await nodeishFs.stat(filePath)
|
|
38
|
-
return stat.isDirectory()
|
|
39
|
-
} catch (error: any) {
|
|
40
|
-
if (error && "code" in error && error.code === "ENOENT") {
|
|
41
|
-
return false
|
|
42
|
-
} else {
|
|
43
|
-
throw new Error(`Failed to check if path exists: ${error}`, { cause: error })
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { it, expect, vi } from "vitest"
|
|
2
|
-
import { createNodeishFsWithAbsolutePaths } from "./createNodeishFsWithAbsolutePaths.js"
|
|
3
|
-
// import type { NodeishFilesystemSubset } from "./versionedInterfaces.js"
|
|
4
|
-
import type { NodeishFilesystem } from "@lix-js/fs"
|
|
5
|
-
|
|
6
|
-
it("throws an error if projectPath is not an absolute path", () => {
|
|
7
|
-
const relativePath = "relative/path"
|
|
8
|
-
|
|
9
|
-
expect(() =>
|
|
10
|
-
createNodeishFsWithAbsolutePaths({ projectPath: relativePath, nodeishFs: {} as any })
|
|
11
|
-
).toThrow()
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
it("intercepts paths correctly for readFile", async () => {
|
|
15
|
-
const projectPath = `/Users/samuel/Documents/paraglide/example/project.inlang`
|
|
16
|
-
|
|
17
|
-
const filePaths = [
|
|
18
|
-
["file.txt", `/Users/samuel/Documents/paraglide/example/file.txt`],
|
|
19
|
-
["./file.txt", `/Users/samuel/Documents/paraglide/example/file.txt`],
|
|
20
|
-
["./folder/file.txt", `/Users/samuel/Documents/paraglide/example/folder/file.txt`],
|
|
21
|
-
["../file.txt", `/Users/samuel/Documents/paraglide/file.txt`],
|
|
22
|
-
["../folder/file.txt", `/Users/samuel/Documents/paraglide/folder/file.txt`],
|
|
23
|
-
["../../file.txt", `/Users/samuel/Documents/file.txt`],
|
|
24
|
-
["../../../file.txt", `/Users/samuel/file.txt`],
|
|
25
|
-
]
|
|
26
|
-
|
|
27
|
-
const mockNodeishFs = {
|
|
28
|
-
readFile: vi.fn(),
|
|
29
|
-
readdir: vi.fn(),
|
|
30
|
-
mkdir: vi.fn(),
|
|
31
|
-
rmdir: vi.fn(),
|
|
32
|
-
writeFile: vi.fn(),
|
|
33
|
-
watch: vi.fn(),
|
|
34
|
-
rm: vi.fn(),
|
|
35
|
-
stat: vi.fn(),
|
|
36
|
-
lstat: vi.fn(),
|
|
37
|
-
symlink: vi.fn(),
|
|
38
|
-
unlink: vi.fn(),
|
|
39
|
-
readlink: vi.fn(),
|
|
40
|
-
} satisfies Record<keyof NodeishFilesystem, any>
|
|
41
|
-
|
|
42
|
-
const interceptedFs = createNodeishFsWithAbsolutePaths({
|
|
43
|
-
projectPath,
|
|
44
|
-
nodeishFs: mockNodeishFs,
|
|
45
|
-
})
|
|
46
|
-
|
|
47
|
-
for (const [path, expectedPath] of filePaths) {
|
|
48
|
-
for (const fn of Object.keys(mockNodeishFs)) {
|
|
49
|
-
await interceptedFs[fn](path)
|
|
50
|
-
// @ts-expect-error
|
|
51
|
-
// expect the first argument to be the expectedPath
|
|
52
|
-
expect(mockNodeishFs[fn].mock.lastCall[0]).toBe(expectedPath)
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
})
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { normalizePath, type NodeishFilesystem } from "@lix-js/fs"
|
|
2
|
-
import { isAbsolutePath } from "./validateProjectPath.js"
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Wraps the nodeish filesystem subset with a function that intercepts paths
|
|
6
|
-
* and prepends the base path.
|
|
7
|
-
*
|
|
8
|
-
* The paths are resolved from the `projectPath` argument.
|
|
9
|
-
*/
|
|
10
|
-
export const createNodeishFsWithAbsolutePaths = (args: {
|
|
11
|
-
projectPath: string
|
|
12
|
-
nodeishFs: NodeishFilesystem
|
|
13
|
-
}): NodeishFilesystem => {
|
|
14
|
-
if (!isAbsolutePath(args.projectPath)) {
|
|
15
|
-
throw new Error(`Expected an absolute path but received "${args.projectPath}".`)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// get the base path of the settings file by
|
|
19
|
-
// removing the file name from the path
|
|
20
|
-
const basePath = normalizePath(args.projectPath).split("/").slice(0, -1).join("/")
|
|
21
|
-
|
|
22
|
-
const makeAbsolute = (path: string) => {
|
|
23
|
-
if (isAbsolutePath(path)) {
|
|
24
|
-
return normalizePath(path)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return normalizePath(basePath + "/" + path)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return {
|
|
31
|
-
// @ts-expect-error
|
|
32
|
-
readFile: (path: string, options: { encoding: "utf-8" | "binary" }) =>
|
|
33
|
-
args.nodeishFs.readFile(makeAbsolute(path), options),
|
|
34
|
-
readdir: (path: string) => args.nodeishFs.readdir(makeAbsolute(path)),
|
|
35
|
-
mkdir: (path: string, options: { recursive: boolean }) =>
|
|
36
|
-
args.nodeishFs.mkdir(makeAbsolute(path), options),
|
|
37
|
-
writeFile: (path: string, data: string) => args.nodeishFs.writeFile(makeAbsolute(path), data),
|
|
38
|
-
stat: (path: string) => args.nodeishFs.stat(makeAbsolute(path)),
|
|
39
|
-
rm: (path: string) => args.nodeishFs.rm(makeAbsolute(path)),
|
|
40
|
-
rmdir: (path: string) => (args.nodeishFs as any).rmdir(makeAbsolute(path)),
|
|
41
|
-
watch: (
|
|
42
|
-
path: string,
|
|
43
|
-
options: { signal: AbortSignal | undefined; recursive: boolean | undefined }
|
|
44
|
-
) => args.nodeishFs.watch(makeAbsolute(path), options),
|
|
45
|
-
// This might be surprising when symlinks were intended to be relative
|
|
46
|
-
symlink: (target: string, path: string) =>
|
|
47
|
-
args.nodeishFs.symlink(makeAbsolute(target), makeAbsolute(path)),
|
|
48
|
-
unlink: (path: string) => args.nodeishFs.unlink(makeAbsolute(path)),
|
|
49
|
-
readlink: (path: string) => args.nodeishFs.readlink(makeAbsolute(path)),
|
|
50
|
-
lstat: (path: string) => args.nodeishFs.lstat(makeAbsolute(path)),
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { createNodeishMemoryFs } from "@lix-js/fs"
|
|
2
|
-
import { describe, it, expect } from "vitest"
|
|
3
|
-
import { createNodeishFsWithWatcher } from "./createNodeishFsWithWatcher.js"
|
|
4
|
-
|
|
5
|
-
describe("watcher", () => {
|
|
6
|
-
it("should trigger the update function when file changes", async () => {
|
|
7
|
-
let counter = 0
|
|
8
|
-
|
|
9
|
-
const fs = createNodeishFsWithWatcher({
|
|
10
|
-
nodeishFs: createNodeishMemoryFs(),
|
|
11
|
-
onChange: () => {
|
|
12
|
-
counter++
|
|
13
|
-
},
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
// establish watcher
|
|
17
|
-
await fs.writeFile("file.txt", "a")
|
|
18
|
-
await fs.readFile("file.txt", { encoding: "utf-8" })
|
|
19
|
-
expect(counter).toBe(0)
|
|
20
|
-
|
|
21
|
-
// initial file change
|
|
22
|
-
await fs.writeFile("file.txt", "b")
|
|
23
|
-
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
24
|
-
|
|
25
|
-
expect(counter).toBe(1)
|
|
26
|
-
|
|
27
|
-
// change file
|
|
28
|
-
await fs.writeFile("file.txt", "a")
|
|
29
|
-
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
30
|
-
|
|
31
|
-
//check if update function was called
|
|
32
|
-
expect(counter).toBe(2)
|
|
33
|
-
|
|
34
|
-
// change file
|
|
35
|
-
await fs.readFile("file.txt")
|
|
36
|
-
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
37
|
-
|
|
38
|
-
//check if update function was called
|
|
39
|
-
expect(counter).toBe(2)
|
|
40
|
-
|
|
41
|
-
fs.stopWatching()
|
|
42
|
-
|
|
43
|
-
// change file
|
|
44
|
-
await fs.writeFile("file.txt", "b")
|
|
45
|
-
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
46
|
-
|
|
47
|
-
//check if update function was called - should not since signalled
|
|
48
|
-
expect(counter).toBe(2)
|
|
49
|
-
})
|
|
50
|
-
})
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import type { NodeishFilesystem } from "@lix-js/fs"
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Wraps the nodeish filesystem subset with a function that intercepts paths
|
|
5
|
-
* and prepends the base path.
|
|
6
|
-
*
|
|
7
|
-
* The paths are resolved from the `projectPath` argument.
|
|
8
|
-
*/
|
|
9
|
-
export const createNodeishFsWithWatcher = (args: {
|
|
10
|
-
nodeishFs: NodeishFilesystem
|
|
11
|
-
onChange: () => void
|
|
12
|
-
}): NodeishFilesystem & {
|
|
13
|
-
stopWatching: () => void
|
|
14
|
-
} => {
|
|
15
|
-
const pathList = new Set<string>()
|
|
16
|
-
const abortControllers = new Set<AbortController>()
|
|
17
|
-
|
|
18
|
-
const stopWatching = () => {
|
|
19
|
-
for (const ac of abortControllers) {
|
|
20
|
-
ac.abort()
|
|
21
|
-
abortControllers.delete(ac) // release reference
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const makeWatcher = async (path: string) => {
|
|
26
|
-
try {
|
|
27
|
-
const ac = new AbortController()
|
|
28
|
-
abortControllers.add(ac)
|
|
29
|
-
const watcher = args.nodeishFs.watch(path, {
|
|
30
|
-
signal: ac.signal,
|
|
31
|
-
recursive: true,
|
|
32
|
-
persistent: false,
|
|
33
|
-
})
|
|
34
|
-
if (watcher) {
|
|
35
|
-
//eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
36
|
-
for await (const event of watcher) {
|
|
37
|
-
// whenever the watcher changes we need to update the messages
|
|
38
|
-
args.onChange()
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
} catch (err: any) {
|
|
42
|
-
if (err.name === "AbortError") return
|
|
43
|
-
// https://github.com/opral/monorepo/issues/1647
|
|
44
|
-
// the file does not exist (yet)
|
|
45
|
-
// this is not testable beacause the fs.watch api differs
|
|
46
|
-
// from node and lix. lenghty
|
|
47
|
-
else if (err.code === "ENOENT") return
|
|
48
|
-
throw err
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Creates watchers on-the-fly for any file or directory that is not yet watched.
|
|
54
|
-
*
|
|
55
|
-
* We do this instead of recursively watching the entire project because fs.watch does not support
|
|
56
|
-
* recursive watching on linux in node 18. Once node 18 support is dropped this can be drastically simplified.
|
|
57
|
-
*/
|
|
58
|
-
const watched = <T extends any[], R>(
|
|
59
|
-
fn: (path: string, ...rest: T) => R
|
|
60
|
-
): ((path: string, ...rest: T) => R) => {
|
|
61
|
-
return (path: string, ...rest: T): R => {
|
|
62
|
-
if (!pathList.has(path)) {
|
|
63
|
-
makeWatcher(path)
|
|
64
|
-
pathList.add(path)
|
|
65
|
-
}
|
|
66
|
-
return fn(path, ...rest)
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return {
|
|
71
|
-
...args.nodeishFs,
|
|
72
|
-
/**
|
|
73
|
-
* Reads the file and automatically adds it to the list of watched files.
|
|
74
|
-
* Any changes to the file will trigger a message update.
|
|
75
|
-
*/
|
|
76
|
-
// @ts-expect-error
|
|
77
|
-
readFile: watched(args.nodeishFs.readFile),
|
|
78
|
-
/**
|
|
79
|
-
* Reads the directory and automatically adds it to the list of watched files.
|
|
80
|
-
* Any changes to the directory will trigger a message update.
|
|
81
|
-
*/
|
|
82
|
-
readdir: watched(args.nodeishFs.readdir),
|
|
83
|
-
stopWatching,
|
|
84
|
-
}
|
|
85
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { ProjectSettings } from "@inlang/project-settings"
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Default project settings for createNewProject
|
|
5
|
-
* from paraglide-js/src/cli/commands/init/defaults.ts
|
|
6
|
-
*/
|
|
7
|
-
export const defaultProjectSettings = {
|
|
8
|
-
$schema: "https://inlang.com/schema/project-settings",
|
|
9
|
-
sourceLanguageTag: "en",
|
|
10
|
-
languageTags: ["en"],
|
|
11
|
-
modules: [
|
|
12
|
-
// for instant gratification, we're adding common rules
|
|
13
|
-
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-empty-pattern@latest/dist/index.js",
|
|
14
|
-
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-missing-translation@latest/dist/index.js",
|
|
15
|
-
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-without-source@latest/dist/index.js",
|
|
16
|
-
|
|
17
|
-
// default to the message format plugin because it supports all features
|
|
18
|
-
"https://cdn.jsdelivr.net/npm/@inlang/plugin-message-format@latest/dist/index.js",
|
|
19
|
-
|
|
20
|
-
// the m function matcher should be installed by default in case Sherlock (VS Code extension) is adopted
|
|
21
|
-
"https://cdn.jsdelivr.net/npm/@inlang/plugin-m-function-matcher@latest/dist/index.js",
|
|
22
|
-
],
|
|
23
|
-
"plugin.inlang.messageFormat": {
|
|
24
|
-
pathPattern: "./messages/{languageTag}.json",
|
|
25
|
-
},
|
|
26
|
-
} satisfies ProjectSettings
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
index.js
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-restricted-imports */
|
|
2
|
-
/* eslint-disable no-undef */
|
|
3
|
-
/**
|
|
4
|
-
* This script writes public environment variables
|
|
5
|
-
* to an importable env file.
|
|
6
|
-
*
|
|
7
|
-
* - The SDK must bundle this file with the rest of the SDK
|
|
8
|
-
* - This scripts avoids the need for a bundler
|
|
9
|
-
* - Must be ran before building the SDK
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
import fs from "node:fs/promises"
|
|
13
|
-
import url from "node:url"
|
|
14
|
-
import path from "node:path"
|
|
15
|
-
|
|
16
|
-
const dirname = path.dirname(url.fileURLToPath(import.meta.url))
|
|
17
|
-
|
|
18
|
-
await fs.writeFile(
|
|
19
|
-
dirname + "/index.ts",
|
|
20
|
-
`
|
|
21
|
-
export const ENV_VARIABLES = {
|
|
22
|
-
PUBLIC_POSTHOG_TOKEN: "${process.env.PUBLIC_POSTHOG_TOKEN}",
|
|
23
|
-
}
|
|
24
|
-
`
|
|
25
|
-
)
|
|
26
|
-
|
|
27
|
-
// eslint-disable-next-line no-console
|
|
28
|
-
console.log("✅ Created env variable index file.")
|
package/src/errors.ts
DELETED
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import type { SchemaOptions } from "@sinclair/typebox"
|
|
2
|
-
import type { ValueError } from "@sinclair/typebox/errors"
|
|
3
|
-
|
|
4
|
-
export class LoadProjectInvalidArgument extends Error {
|
|
5
|
-
constructor(message: string, options: { argument: string }) {
|
|
6
|
-
super(`The argument "${options.argument}" of loadProject() is invalid: ${message}`)
|
|
7
|
-
this.name = "LoadProjectInvalidArgument"
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export class ProjectSettingsInvalidError extends Error {
|
|
12
|
-
constructor(options: { errors: ValueError[] }) {
|
|
13
|
-
// TODO: beatufiy ValueErrors
|
|
14
|
-
super(
|
|
15
|
-
`The project settings are invalid:
|
|
16
|
-
${options.errors
|
|
17
|
-
.filter((error) => error.path)
|
|
18
|
-
.map(FormatProjectSettingsError)
|
|
19
|
-
.join("\n")}`
|
|
20
|
-
)
|
|
21
|
-
this.name = "ProjectSettingsInvalidError"
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function FormatProjectSettingsError(error: ValueError) {
|
|
26
|
-
let msg = `${error.message} at ${error.path}`
|
|
27
|
-
if (error.path.startsWith("/modules/")) {
|
|
28
|
-
msg += `
|
|
29
|
-
value = "${error.value}"
|
|
30
|
-
- ${error.schema.allOf.map((o: SchemaOptions) => `${o.description ?? ""}`).join("\n- ")}`
|
|
31
|
-
}
|
|
32
|
-
return msg
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export class ProjectSettingsFileJSONSyntaxError extends Error {
|
|
36
|
-
constructor(options: { cause: ErrorOptions["cause"]; path: string }) {
|
|
37
|
-
super(
|
|
38
|
-
`The settings file at "${options.path}" is not a valid JSON file:\n\n${options.cause}`,
|
|
39
|
-
options
|
|
40
|
-
)
|
|
41
|
-
this.name = "ProjectSettingsFileJSONSyntaxError"
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export class ProjectSettingsFileNotFoundError extends Error {
|
|
46
|
-
constructor(options: { cause?: ErrorOptions["cause"]; path: string }) {
|
|
47
|
-
super(`The file at "${options.path}" could not be read. Does the file exists?`, options)
|
|
48
|
-
this.name = "ProjectSettingsFileNotFoundError"
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export class PluginSaveMessagesError extends Error {
|
|
53
|
-
constructor(options: { cause: ErrorOptions["cause"] }) {
|
|
54
|
-
super(`An error occured in saveMessages() caused by ${options.cause}.`, options)
|
|
55
|
-
this.name = "PluginSaveMessagesError"
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export class PluginLoadMessagesError extends Error {
|
|
60
|
-
constructor(options: { cause: ErrorOptions["cause"] }) {
|
|
61
|
-
super(`An error occured in loadMessages() caused by ${options.cause}.`, options)
|
|
62
|
-
this.name = "PluginLoadMessagesError"
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export class LoadMessageError extends Error {
|
|
67
|
-
constructor(options: { path: string; messageId: string; cause: ErrorOptions["cause"] }) {
|
|
68
|
-
super(
|
|
69
|
-
`An error occured when loading message ${options.messageId} from path ${options.path} caused by ${options.cause}.`,
|
|
70
|
-
options
|
|
71
|
-
)
|
|
72
|
-
this.name = "LoadMessageError"
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export class SaveMessageError extends Error {
|
|
77
|
-
constructor(options: { path: string; messageId: string; cause: ErrorOptions["cause"] }) {
|
|
78
|
-
super(
|
|
79
|
-
`An error occured when loading message ${options.messageId} from path ${options.path} caused by ${options.cause}.`,
|
|
80
|
-
options
|
|
81
|
-
)
|
|
82
|
-
this.name = "SaveMessageError"
|
|
83
|
-
}
|
|
84
|
-
}
|
package/src/lint/index.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error when a lint rule throws during the linting process.
|
|
3
|
-
*/
|
|
4
|
-
export class MessagedLintRuleThrowedError extends Error {
|
|
5
|
-
constructor(message: string, options?: ErrorOptions) {
|
|
6
|
-
super(message, options)
|
|
7
|
-
this.name = "MessagedLintRuleThrowedError"
|
|
8
|
-
}
|
|
9
|
-
}
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, test, vi } from "vitest"
|
|
2
|
-
import { lintMessages } from "./lintMessages.js"
|
|
3
|
-
import type { MessageLintReport, MessageLintRule } from "@inlang/message-lint-rule"
|
|
4
|
-
import type { Message } from "@inlang/message"
|
|
5
|
-
|
|
6
|
-
const lintRule1 = {
|
|
7
|
-
id: "messageLintRule.x.1",
|
|
8
|
-
displayName: { en: "" },
|
|
9
|
-
description: { en: "" },
|
|
10
|
-
|
|
11
|
-
run: vi.fn(),
|
|
12
|
-
} satisfies MessageLintRule
|
|
13
|
-
|
|
14
|
-
const lintRule2 = {
|
|
15
|
-
id: "messageLintRule.x.2",
|
|
16
|
-
displayName: { en: "" },
|
|
17
|
-
description: { en: "" },
|
|
18
|
-
|
|
19
|
-
run: vi.fn(),
|
|
20
|
-
} satisfies MessageLintRule
|
|
21
|
-
|
|
22
|
-
const message1 = { id: "m1" } as Message
|
|
23
|
-
const message2 = { id: "m2" } as Message
|
|
24
|
-
const message3 = { id: "m3" } as Message
|
|
25
|
-
|
|
26
|
-
const messages = [message1, message2, message3]
|
|
27
|
-
|
|
28
|
-
describe("lintMessages", async () => {
|
|
29
|
-
beforeEach(() => {
|
|
30
|
-
vi.resetAllMocks()
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
test("it should await all messages", async () => {
|
|
34
|
-
let called = 0
|
|
35
|
-
lintRule2.run.mockImplementation(async () => {
|
|
36
|
-
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
37
|
-
called++
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
await lintMessages({
|
|
41
|
-
settings: {
|
|
42
|
-
sourceLanguageTag: "en",
|
|
43
|
-
languageTags: [],
|
|
44
|
-
modules: [],
|
|
45
|
-
messageLintRuleLevels: {
|
|
46
|
-
[lintRule1.id]: "warning",
|
|
47
|
-
[lintRule2.id]: "warning",
|
|
48
|
-
},
|
|
49
|
-
},
|
|
50
|
-
messages,
|
|
51
|
-
rules: [lintRule1, lintRule2],
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
expect(lintRule1.run).toHaveBeenCalledTimes(3)
|
|
55
|
-
expect(called).toBe(3)
|
|
56
|
-
})
|
|
57
|
-
|
|
58
|
-
test("it should process all messages and rules in parallel", async () => {
|
|
59
|
-
const fn = vi.fn()
|
|
60
|
-
|
|
61
|
-
lintRule1.run.mockImplementation(async ({ message }) => {
|
|
62
|
-
fn("r1", "before", message.id)
|
|
63
|
-
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
64
|
-
fn("r1", "after", message.id)
|
|
65
|
-
})
|
|
66
|
-
lintRule2.run.mockImplementation(async ({ message }) => {
|
|
67
|
-
fn("r2", "before", message.id)
|
|
68
|
-
await new Promise((resolve) => setTimeout(resolve, 0))
|
|
69
|
-
fn("r2", "after", message.id)
|
|
70
|
-
})
|
|
71
|
-
|
|
72
|
-
await lintMessages({
|
|
73
|
-
settings: {
|
|
74
|
-
sourceLanguageTag: "en",
|
|
75
|
-
languageTags: [],
|
|
76
|
-
modules: [],
|
|
77
|
-
messageLintRuleLevels: {
|
|
78
|
-
[lintRule1.id]: "warning",
|
|
79
|
-
[lintRule2.id]: "warning",
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
rules: [lintRule1, lintRule2],
|
|
83
|
-
messages,
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
expect(fn).toHaveBeenCalledTimes(12)
|
|
87
|
-
expect(fn).toHaveBeenNthCalledWith(1, "r1", "before", "m1")
|
|
88
|
-
expect(fn).toHaveBeenNthCalledWith(2, "r2", "before", "m1")
|
|
89
|
-
expect(fn).toHaveBeenNthCalledWith(3, "r1", "before", "m2")
|
|
90
|
-
expect(fn).toHaveBeenNthCalledWith(4, "r2", "before", "m2")
|
|
91
|
-
expect(fn).toHaveBeenNthCalledWith(5, "r1", "before", "m3")
|
|
92
|
-
expect(fn).toHaveBeenNthCalledWith(6, "r2", "before", "m3")
|
|
93
|
-
expect(fn).toHaveBeenNthCalledWith(7, "r1", "after", "m1")
|
|
94
|
-
expect(fn).toHaveBeenNthCalledWith(8, "r2", "after", "m1")
|
|
95
|
-
expect(fn).toHaveBeenNthCalledWith(9, "r1", "after", "m2")
|
|
96
|
-
expect(fn).toHaveBeenNthCalledWith(10, "r2", "after", "m2")
|
|
97
|
-
expect(fn).toHaveBeenNthCalledWith(11, "r1", "after", "m3")
|
|
98
|
-
expect(fn).toHaveBeenNthCalledWith(12, "r2", "after", "m3")
|
|
99
|
-
})
|
|
100
|
-
|
|
101
|
-
test("it should not abort the linting process when errors occur", async () => {
|
|
102
|
-
lintRule1.run.mockImplementation(({ report }) => {
|
|
103
|
-
report({} as MessageLintReport)
|
|
104
|
-
})
|
|
105
|
-
lintRule2.run.mockImplementation(() => {
|
|
106
|
-
throw new Error("error")
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
const { data, errors } = await lintMessages({
|
|
110
|
-
settings: {
|
|
111
|
-
sourceLanguageTag: "en",
|
|
112
|
-
languageTags: [],
|
|
113
|
-
modules: [],
|
|
114
|
-
messageLintRuleLevels: {
|
|
115
|
-
[lintRule1.id]: "warning",
|
|
116
|
-
[lintRule2.id]: "warning",
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
messages,
|
|
120
|
-
rules: [lintRule1, lintRule2],
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
expect(data).toHaveLength(3)
|
|
124
|
-
expect(errors).toHaveLength(3)
|
|
125
|
-
})
|
|
126
|
-
})
|