@platformos/platformos-common 0.0.7 → 0.0.9
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/CHANGELOG.md +12 -0
- package/dist/AbstractFileSystem.d.ts +1 -1
- package/dist/documents-locator/DocumentsLocator.js +7 -37
- package/dist/documents-locator/DocumentsLocator.js.map +1 -1
- package/dist/path-utils.d.ts +85 -22
- package/dist/path-utils.js +169 -26
- package/dist/path-utils.js.map +1 -1
- package/dist/translation-provider/TranslationProvider.d.ts +24 -0
- package/dist/translation-provider/TranslationProvider.js +76 -0
- package/dist/translation-provider/TranslationProvider.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -2
- package/src/AbstractFileSystem.ts +1 -1
- package/src/documents-locator/DocumentsLocator.ts +7 -37
- package/src/path-utils.spec.ts +350 -0
- package/src/path-utils.ts +172 -26
- package/src/translation-provider/TranslationProvider.ts +83 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The AbstractFileSystem interface is used to abstract file system operations.
|
|
3
3
|
*
|
|
4
|
-
* This way, the
|
|
4
|
+
* This way, the App Check library can be used in different environments,
|
|
5
5
|
* such as the browser, node.js or VS Code (which works with local files, remote
|
|
6
6
|
* files and on the web)
|
|
7
7
|
*/
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DocumentsLocator = void 0;
|
|
4
4
|
const AbstractFileSystem_1 = require("../AbstractFileSystem");
|
|
5
|
+
const path_utils_1 = require("../path-utils");
|
|
5
6
|
const vscode_uri_1 = require("vscode-uri");
|
|
6
7
|
class DocumentsLocator {
|
|
7
8
|
constructor(fs) {
|
|
@@ -24,43 +25,12 @@ class DocumentsLocator {
|
|
|
24
25
|
return moduleName ? { isModule: true, moduleName, key } : { isModule: false, key: fileName };
|
|
25
26
|
}
|
|
26
27
|
getSearchPaths(type, moduleName) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
case 'asset':
|
|
34
|
-
return ['app/assets'];
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
switch (type) {
|
|
38
|
-
case 'partial':
|
|
39
|
-
return [
|
|
40
|
-
`app/modules/${moduleName}/public/views/partials`,
|
|
41
|
-
`app/modules/${moduleName}/private/views/partials`,
|
|
42
|
-
`app/modules/${moduleName}/public/lib`,
|
|
43
|
-
`app/modules/${moduleName}/private/lib`,
|
|
44
|
-
`modules/${moduleName}/public/views/partials`,
|
|
45
|
-
`modules/${moduleName}/private/views/partials`,
|
|
46
|
-
`modules/${moduleName}/public/lib`,
|
|
47
|
-
`modules/${moduleName}/private/lib`,
|
|
48
|
-
];
|
|
49
|
-
case 'graphql':
|
|
50
|
-
return [
|
|
51
|
-
`app/modules/${moduleName}/public/graphql`,
|
|
52
|
-
`app/modules/${moduleName}/private/graphql`,
|
|
53
|
-
`modules/${moduleName}/public/graphql`,
|
|
54
|
-
`modules/${moduleName}/private/graphql`,
|
|
55
|
-
];
|
|
56
|
-
case 'asset':
|
|
57
|
-
return [
|
|
58
|
-
`app/modules/${moduleName}/public/assets`,
|
|
59
|
-
`app/modules/${moduleName}/private/assets`,
|
|
60
|
-
`modules/${moduleName}/public/assets`,
|
|
61
|
-
`modules/${moduleName}/private/assets`,
|
|
62
|
-
];
|
|
63
|
-
}
|
|
28
|
+
const fileType = {
|
|
29
|
+
partial: path_utils_1.PlatformOSFileType.Partial,
|
|
30
|
+
graphql: path_utils_1.PlatformOSFileType.GraphQL,
|
|
31
|
+
asset: path_utils_1.PlatformOSFileType.Asset,
|
|
32
|
+
}[type];
|
|
33
|
+
return moduleName ? (0, path_utils_1.getModulePaths)(fileType, moduleName) : (0, path_utils_1.getAppPaths)(fileType);
|
|
64
34
|
}
|
|
65
35
|
async locateFile(rootUri, fileName, type) {
|
|
66
36
|
const parsed = this.parseModulePath(fileName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentsLocator.js","sourceRoot":"","sources":["../../src/documents-locator/DocumentsLocator.ts"],"names":[],"mappings":";;;AAAA,8DAAqE;AACrE,2CAAwC;AAQxC,MAAa,gBAAgB;IAC3B,YAA6B,EAAsB;QAAtB,OAAE,GAAF,EAAE,CAAoB;IAAG,CAAC;IAE/C,KAAK,CAAC,MAAM,CAAC,IAAY;QAC/B,IAAI,CAAC;YACH,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,6BAAQ,CAAC,IAAI,CAAC;QAC3D,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAEO,eAAe,CAAC,QAAgB;QACtC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;YACrC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;QAC5C,CAAC;QAED,MAAM,CAAC,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACpD,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAE3B,OAAO,UAAU,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;IAC/F,CAAC;IAEO,cAAc,CAAC,IAAqC,EAAE,UAAmB;QAC/E,
|
|
1
|
+
{"version":3,"file":"DocumentsLocator.js","sourceRoot":"","sources":["../../src/documents-locator/DocumentsLocator.ts"],"names":[],"mappings":";;;AAAA,8DAAqE;AACrE,8CAAgF;AAChF,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EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YAErD;gBACE,OAAO,SAAS,CAAC;QACrB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,OAAY,EAAE,QAA4B,EAAE,UAAkB;QACvE,QAAQ,QAAQ,EAAE,CAAC;YACjB,KAAK,UAAU,CAAC;YAChB,KAAK,QAAQ,CAAC;YACd,KAAK,SAAS;gBACZ,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;YAExD,KAAK,SAAS;gBACZ,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;YAExD,KAAK,OAAO;gBACV,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;YAEtD;gBACE,OAAO,EAAE,CAAC;QACd,CAAC;IACH,CAAC;CACF;AA9JD,4CA8JC"}
|
package/dist/path-utils.d.ts
CHANGED
|
@@ -1,34 +1,97 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Utility functions for identifying platformOS file types based on their paths
|
|
2
|
+
* Utility functions for identifying platformOS file types based on their paths.
|
|
3
|
+
*
|
|
4
|
+
* Architecture:
|
|
5
|
+
* - FILE_TYPE_DIRS is the single source of truth for all platformOS directory names
|
|
6
|
+
* - getAppPaths() and getModulePaths() generate concrete search paths from FILE_TYPE_DIRS
|
|
7
|
+
* - TYPE_MATCHERS pre-compiles regexes for fast URI classification
|
|
8
|
+
* - getFileType() classifies any URI to a PlatformOSFileType
|
|
9
|
+
* - isPage(), isLayout(), isPartial() etc. are convenience wrappers around getFileType()
|
|
10
|
+
*
|
|
11
|
+
* Pattern precision: each type uses exact path segment patterns (/app/{dir}/ or
|
|
12
|
+
* /(public|private)/{dir}/) so that nested paths don't produce false positives.
|
|
13
|
+
* For example, app/lib/smses/file.liquid is correctly identified as Partial
|
|
14
|
+
* (matches /app/lib/), not Sms (does not match /app/smses/).
|
|
3
15
|
*/
|
|
4
16
|
import { UriString } from './AbstractFileSystem';
|
|
5
17
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* - app/lib
|
|
9
|
-
* - app/views/partials
|
|
10
|
-
* - app/modules/{moduleName}/public/lib
|
|
11
|
-
* - app/modules/{moduleName}/private/lib
|
|
12
|
-
* - app/modules/{moduleName}/public/views/partials
|
|
13
|
-
* - app/modules/{moduleName}/private/views/partials
|
|
14
|
-
* - modules/{moduleName}/public/lib
|
|
15
|
-
* - modules/{moduleName}/private/lib
|
|
16
|
-
* - modules/{moduleName}/public/views/partials
|
|
17
|
-
* - modules/{moduleName}/private/views/partials
|
|
18
|
+
* File types that exist in a platformOS app, each mapping to one or more
|
|
19
|
+
* canonical directory names relative to the app root or module access level.
|
|
18
20
|
*/
|
|
19
|
-
export declare
|
|
21
|
+
export declare enum PlatformOSFileType {
|
|
22
|
+
Page = "Page",
|
|
23
|
+
Layout = "Layout",
|
|
24
|
+
Partial = "Partial",
|
|
25
|
+
Authorization = "Authorization",
|
|
26
|
+
Email = "Email",
|
|
27
|
+
ApiCall = "ApiCall",
|
|
28
|
+
Sms = "Sms",
|
|
29
|
+
Migration = "Migration",
|
|
30
|
+
GraphQL = "GraphQL",
|
|
31
|
+
Asset = "Asset"
|
|
32
|
+
}
|
|
20
33
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
34
|
+
* The single source of truth for the platformOS directory structure.
|
|
35
|
+
*
|
|
36
|
+
* Maps each file type to its canonical directory name(s) relative to:
|
|
37
|
+
* - the app root: app/{dir}/
|
|
38
|
+
* - a module access level: modules/{name}/(public|private)/{dir}/
|
|
39
|
+
* - a nested module access level: app/modules/{name}/(public|private)/{dir}/
|
|
40
|
+
*
|
|
41
|
+
* Types with multiple dirs (e.g. Partial) will match any of their dirs.
|
|
42
|
+
* The first matching type wins, so order of evaluation matters for overlapping
|
|
43
|
+
* paths — but exact segment matching means dirs don't overlap in practice.
|
|
23
44
|
*/
|
|
24
|
-
export declare
|
|
45
|
+
export declare const FILE_TYPE_DIRS: Readonly<Record<PlatformOSFileType, readonly string[]>>;
|
|
25
46
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
47
|
+
* Returns the PlatformOSFileType for the given URI, or undefined if the URI
|
|
48
|
+
* does not belong to any recognized platformOS directory.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* getFileType('file:///root/app/lib/smses/notify.liquid') // → PlatformOSFileType.Partial
|
|
52
|
+
* getFileType('file:///root/app/smses/notify.liquid') // → PlatformOSFileType.Sms
|
|
53
|
+
* getFileType('file:///root/modules/core/generators/templates/lib/create.liquid') // → undefined
|
|
28
54
|
*/
|
|
29
|
-
export declare function
|
|
55
|
+
export declare function getFileType(uri: UriString): PlatformOSFileType | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Returns app-level search paths for a file type (relative to project root).
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* getAppPaths(PlatformOSFileType.Partial) // → ['app/views/partials', 'app/lib']
|
|
61
|
+
* getAppPaths(PlatformOSFileType.GraphQL) // → ['app/graphql']
|
|
62
|
+
*/
|
|
63
|
+
export declare function getAppPaths(type: PlatformOSFileType): string[];
|
|
30
64
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
65
|
+
* Returns all module search paths for a file type and module name, covering
|
|
66
|
+
* both app/modules/{name}/... and modules/{name}/... roots, and both
|
|
67
|
+
* public and private access levels (relative to project root).
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* getModulePaths(PlatformOSFileType.Partial, 'core') // → [
|
|
71
|
+
* 'app/modules/core/public/views/partials',
|
|
72
|
+
* 'app/modules/core/private/views/partials',
|
|
73
|
+
* 'modules/core/public/views/partials',
|
|
74
|
+
* 'modules/core/private/views/partials',
|
|
75
|
+
* 'app/modules/core/public/lib',
|
|
76
|
+
* 'app/modules/core/private/lib',
|
|
77
|
+
* 'modules/core/public/lib',
|
|
78
|
+
* 'modules/core/private/lib',
|
|
79
|
+
* ]
|
|
33
80
|
*/
|
|
81
|
+
export declare function getModulePaths(type: PlatformOSFileType, moduleName: string): string[];
|
|
82
|
+
/**
|
|
83
|
+
* Returns true if the URI belongs to a recognized platformOS Liquid directory
|
|
84
|
+
* and should be linted. Files outside known directories (e.g. generator
|
|
85
|
+
* templates, build artifacts) return false and are excluded from linting.
|
|
86
|
+
*/
|
|
87
|
+
export declare function isKnownLiquidFile(uri: UriString): boolean;
|
|
88
|
+
export declare function isPartial(uri: UriString): boolean;
|
|
89
|
+
export declare function isPage(uri: UriString): boolean;
|
|
90
|
+
export declare function isLayout(uri: UriString): boolean;
|
|
91
|
+
export declare function isAuthorization(uri: UriString): boolean;
|
|
92
|
+
export declare function isEmail(uri: UriString): boolean;
|
|
93
|
+
export declare function isApiCall(uri: UriString): boolean;
|
|
94
|
+
export declare function isSms(uri: UriString): boolean;
|
|
95
|
+
export declare function isMigration(uri: UriString): boolean;
|
|
96
|
+
/** @deprecated Use isPartial instead */
|
|
34
97
|
export declare const isSnippet: typeof isPartial;
|
package/dist/path-utils.js
CHANGED
|
@@ -1,46 +1,189 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Utility functions for identifying platformOS file types based on their paths
|
|
3
|
+
* Utility functions for identifying platformOS file types based on their paths.
|
|
4
|
+
*
|
|
5
|
+
* Architecture:
|
|
6
|
+
* - FILE_TYPE_DIRS is the single source of truth for all platformOS directory names
|
|
7
|
+
* - getAppPaths() and getModulePaths() generate concrete search paths from FILE_TYPE_DIRS
|
|
8
|
+
* - TYPE_MATCHERS pre-compiles regexes for fast URI classification
|
|
9
|
+
* - getFileType() classifies any URI to a PlatformOSFileType
|
|
10
|
+
* - isPage(), isLayout(), isPartial() etc. are convenience wrappers around getFileType()
|
|
11
|
+
*
|
|
12
|
+
* Pattern precision: each type uses exact path segment patterns (/app/{dir}/ or
|
|
13
|
+
* /(public|private)/{dir}/) so that nested paths don't produce false positives.
|
|
14
|
+
* For example, app/lib/smses/file.liquid is correctly identified as Partial
|
|
15
|
+
* (matches /app/lib/), not Sms (does not match /app/smses/).
|
|
4
16
|
*/
|
|
5
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.isSnippet = void 0;
|
|
18
|
+
exports.isSnippet = exports.FILE_TYPE_DIRS = exports.PlatformOSFileType = void 0;
|
|
19
|
+
exports.getFileType = getFileType;
|
|
20
|
+
exports.getAppPaths = getAppPaths;
|
|
21
|
+
exports.getModulePaths = getModulePaths;
|
|
22
|
+
exports.isKnownLiquidFile = isKnownLiquidFile;
|
|
7
23
|
exports.isPartial = isPartial;
|
|
8
24
|
exports.isPage = isPage;
|
|
9
25
|
exports.isLayout = isLayout;
|
|
26
|
+
exports.isAuthorization = isAuthorization;
|
|
27
|
+
exports.isEmail = isEmail;
|
|
28
|
+
exports.isApiCall = isApiCall;
|
|
29
|
+
exports.isSms = isSms;
|
|
30
|
+
exports.isMigration = isMigration;
|
|
10
31
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* - app/lib
|
|
14
|
-
* - app/views/partials
|
|
15
|
-
* - app/modules/{moduleName}/public/lib
|
|
16
|
-
* - app/modules/{moduleName}/private/lib
|
|
17
|
-
* - app/modules/{moduleName}/public/views/partials
|
|
18
|
-
* - app/modules/{moduleName}/private/views/partials
|
|
19
|
-
* - modules/{moduleName}/public/lib
|
|
20
|
-
* - modules/{moduleName}/private/lib
|
|
21
|
-
* - modules/{moduleName}/public/views/partials
|
|
22
|
-
* - modules/{moduleName}/private/views/partials
|
|
32
|
+
* File types that exist in a platformOS app, each mapping to one or more
|
|
33
|
+
* canonical directory names relative to the app root or module access level.
|
|
23
34
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
35
|
+
var PlatformOSFileType;
|
|
36
|
+
(function (PlatformOSFileType) {
|
|
37
|
+
PlatformOSFileType["Page"] = "Page";
|
|
38
|
+
PlatformOSFileType["Layout"] = "Layout";
|
|
39
|
+
PlatformOSFileType["Partial"] = "Partial";
|
|
40
|
+
PlatformOSFileType["Authorization"] = "Authorization";
|
|
41
|
+
PlatformOSFileType["Email"] = "Email";
|
|
42
|
+
PlatformOSFileType["ApiCall"] = "ApiCall";
|
|
43
|
+
PlatformOSFileType["Sms"] = "Sms";
|
|
44
|
+
PlatformOSFileType["Migration"] = "Migration";
|
|
45
|
+
PlatformOSFileType["GraphQL"] = "GraphQL";
|
|
46
|
+
PlatformOSFileType["Asset"] = "Asset";
|
|
47
|
+
})(PlatformOSFileType || (exports.PlatformOSFileType = PlatformOSFileType = {}));
|
|
48
|
+
/**
|
|
49
|
+
* The single source of truth for the platformOS directory structure.
|
|
50
|
+
*
|
|
51
|
+
* Maps each file type to its canonical directory name(s) relative to:
|
|
52
|
+
* - the app root: app/{dir}/
|
|
53
|
+
* - a module access level: modules/{name}/(public|private)/{dir}/
|
|
54
|
+
* - a nested module access level: app/modules/{name}/(public|private)/{dir}/
|
|
55
|
+
*
|
|
56
|
+
* Types with multiple dirs (e.g. Partial) will match any of their dirs.
|
|
57
|
+
* The first matching type wins, so order of evaluation matters for overlapping
|
|
58
|
+
* paths — but exact segment matching means dirs don't overlap in practice.
|
|
59
|
+
*/
|
|
60
|
+
exports.FILE_TYPE_DIRS = {
|
|
61
|
+
[PlatformOSFileType.Page]: ['views/pages'],
|
|
62
|
+
[PlatformOSFileType.Layout]: ['views/layouts'],
|
|
63
|
+
[PlatformOSFileType.Partial]: ['views/partials', 'lib'],
|
|
64
|
+
[PlatformOSFileType.Authorization]: ['authorization_policies'],
|
|
65
|
+
[PlatformOSFileType.Email]: ['emails'],
|
|
66
|
+
[PlatformOSFileType.ApiCall]: ['api_calls'],
|
|
67
|
+
[PlatformOSFileType.Sms]: ['smses'],
|
|
68
|
+
[PlatformOSFileType.Migration]: ['migrations'],
|
|
69
|
+
[PlatformOSFileType.GraphQL]: ['graphql'],
|
|
70
|
+
[PlatformOSFileType.Asset]: ['assets'],
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Liquid-containing file types. GraphQL and Asset are excluded because they
|
|
74
|
+
* don't contain Liquid code and should not be passed to the Liquid linter.
|
|
75
|
+
*/
|
|
76
|
+
const LIQUID_FILE_TYPES = new Set([
|
|
77
|
+
PlatformOSFileType.Page,
|
|
78
|
+
PlatformOSFileType.Layout,
|
|
79
|
+
PlatformOSFileType.Partial,
|
|
80
|
+
PlatformOSFileType.Authorization,
|
|
81
|
+
PlatformOSFileType.Email,
|
|
82
|
+
PlatformOSFileType.ApiCall,
|
|
83
|
+
PlatformOSFileType.Sms,
|
|
84
|
+
PlatformOSFileType.Migration,
|
|
85
|
+
]);
|
|
86
|
+
/**
|
|
87
|
+
* Pre-compiled regex per file type, derived entirely from FILE_TYPE_DIRS.
|
|
88
|
+
*
|
|
89
|
+
* For each canonical dir, two pattern alternatives are generated:
|
|
90
|
+
* /app/{dir}/ — direct app-level path (e.g. /app/lib/)
|
|
91
|
+
* /(public|private)/{dir}/ — module path, covers both:
|
|
92
|
+
* modules/{name}/(public|private)/{dir}/
|
|
93
|
+
* app/modules/{name}/(public|private)/{dir}/
|
|
94
|
+
*
|
|
95
|
+
* Exact path segment matching prevents false positives:
|
|
96
|
+
* /app/lib/smses/file.liquid → matches /app/lib/ → Partial (NOT Sms)
|
|
97
|
+
* /app/smses/file.liquid → matches /app/smses/ → Sms (NOT Partial)
|
|
98
|
+
*/
|
|
99
|
+
const TYPE_MATCHERS = new Map(Object.entries(exports.FILE_TYPE_DIRS).map(([type, dirs]) => {
|
|
100
|
+
const alternatives = dirs.flatMap((dir) => [`/app/${dir}/`, `/(public|private)/${dir}/`]);
|
|
101
|
+
return [type, new RegExp(alternatives.join('|'))];
|
|
102
|
+
}));
|
|
103
|
+
/**
|
|
104
|
+
* Returns the PlatformOSFileType for the given URI, or undefined if the URI
|
|
105
|
+
* does not belong to any recognized platformOS directory.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* getFileType('file:///root/app/lib/smses/notify.liquid') // → PlatformOSFileType.Partial
|
|
109
|
+
* getFileType('file:///root/app/smses/notify.liquid') // → PlatformOSFileType.Sms
|
|
110
|
+
* getFileType('file:///root/modules/core/generators/templates/lib/create.liquid') // → undefined
|
|
111
|
+
*/
|
|
112
|
+
function getFileType(uri) {
|
|
113
|
+
for (const [type, re] of TYPE_MATCHERS) {
|
|
114
|
+
if (re.test(uri))
|
|
115
|
+
return type;
|
|
116
|
+
}
|
|
117
|
+
return undefined;
|
|
26
118
|
}
|
|
27
119
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
120
|
+
* Returns app-level search paths for a file type (relative to project root).
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* getAppPaths(PlatformOSFileType.Partial) // → ['app/views/partials', 'app/lib']
|
|
124
|
+
* getAppPaths(PlatformOSFileType.GraphQL) // → ['app/graphql']
|
|
30
125
|
*/
|
|
31
|
-
function
|
|
32
|
-
return
|
|
126
|
+
function getAppPaths(type) {
|
|
127
|
+
return exports.FILE_TYPE_DIRS[type].map((dir) => `app/${dir}`);
|
|
33
128
|
}
|
|
34
129
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
130
|
+
* Returns all module search paths for a file type and module name, covering
|
|
131
|
+
* both app/modules/{name}/... and modules/{name}/... roots, and both
|
|
132
|
+
* public and private access levels (relative to project root).
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* getModulePaths(PlatformOSFileType.Partial, 'core') // → [
|
|
136
|
+
* 'app/modules/core/public/views/partials',
|
|
137
|
+
* 'app/modules/core/private/views/partials',
|
|
138
|
+
* 'modules/core/public/views/partials',
|
|
139
|
+
* 'modules/core/private/views/partials',
|
|
140
|
+
* 'app/modules/core/public/lib',
|
|
141
|
+
* 'app/modules/core/private/lib',
|
|
142
|
+
* 'modules/core/public/lib',
|
|
143
|
+
* 'modules/core/private/lib',
|
|
144
|
+
* ]
|
|
37
145
|
*/
|
|
38
|
-
function
|
|
39
|
-
return
|
|
146
|
+
function getModulePaths(type, moduleName) {
|
|
147
|
+
return exports.FILE_TYPE_DIRS[type].flatMap((dir) => [
|
|
148
|
+
`app/modules/${moduleName}/public/${dir}`,
|
|
149
|
+
`app/modules/${moduleName}/private/${dir}`,
|
|
150
|
+
`modules/${moduleName}/public/${dir}`,
|
|
151
|
+
`modules/${moduleName}/private/${dir}`,
|
|
152
|
+
]);
|
|
40
153
|
}
|
|
41
154
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
155
|
+
* Returns true if the URI belongs to a recognized platformOS Liquid directory
|
|
156
|
+
* and should be linted. Files outside known directories (e.g. generator
|
|
157
|
+
* templates, build artifacts) return false and are excluded from linting.
|
|
44
158
|
*/
|
|
159
|
+
function isKnownLiquidFile(uri) {
|
|
160
|
+
const type = getFileType(uri);
|
|
161
|
+
return type !== undefined && LIQUID_FILE_TYPES.has(type);
|
|
162
|
+
}
|
|
163
|
+
function isPartial(uri) {
|
|
164
|
+
return getFileType(uri) === PlatformOSFileType.Partial;
|
|
165
|
+
}
|
|
166
|
+
function isPage(uri) {
|
|
167
|
+
return getFileType(uri) === PlatformOSFileType.Page;
|
|
168
|
+
}
|
|
169
|
+
function isLayout(uri) {
|
|
170
|
+
return getFileType(uri) === PlatformOSFileType.Layout;
|
|
171
|
+
}
|
|
172
|
+
function isAuthorization(uri) {
|
|
173
|
+
return getFileType(uri) === PlatformOSFileType.Authorization;
|
|
174
|
+
}
|
|
175
|
+
function isEmail(uri) {
|
|
176
|
+
return getFileType(uri) === PlatformOSFileType.Email;
|
|
177
|
+
}
|
|
178
|
+
function isApiCall(uri) {
|
|
179
|
+
return getFileType(uri) === PlatformOSFileType.ApiCall;
|
|
180
|
+
}
|
|
181
|
+
function isSms(uri) {
|
|
182
|
+
return getFileType(uri) === PlatformOSFileType.Sms;
|
|
183
|
+
}
|
|
184
|
+
function isMigration(uri) {
|
|
185
|
+
return getFileType(uri) === PlatformOSFileType.Migration;
|
|
186
|
+
}
|
|
187
|
+
/** @deprecated Use isPartial instead */
|
|
45
188
|
exports.isSnippet = isPartial;
|
|
46
189
|
//# sourceMappingURL=path-utils.js.map
|
package/dist/path-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../src/path-utils.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"path-utils.js","sourceRoot":"","sources":["../src/path-utils.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AA4FH,kCAKC;AASD,kCAEC;AAmBD,wCAOC;AAOD,8CAGC;AAED,8BAEC;AAED,wBAEC;AAED,4BAEC;AAED,0CAEC;AAED,0BAEC;AAED,8BAEC;AAED,sBAEC;AAED,kCAEC;AA5KD;;;GAGG;AACH,IAAY,kBAWX;AAXD,WAAY,kBAAkB;IAC5B,mCAAa,CAAA;IACb,uCAAiB,CAAA;IACjB,yCAAmB,CAAA;IACnB,qDAA+B,CAAA;IAC/B,qCAAe,CAAA;IACf,yCAAmB,CAAA;IACnB,iCAAW,CAAA;IACX,6CAAuB,CAAA;IACvB,yCAAmB,CAAA;IACnB,qCAAe,CAAA;AACjB,CAAC,EAXW,kBAAkB,kCAAlB,kBAAkB,QAW7B;AAED;;;;;;;;;;;GAWG;AACU,QAAA,cAAc,GAA4D;IACrF,CAAC,kBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC;IAC1C,CAAC,kBAAkB,CAAC,MAAM,CAAC,EAAE,CAAC,eAAe,CAAC;IAC9C,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC,gBAAgB,EAAE,KAAK,CAAC;IACvD,CAAC,kBAAkB,CAAC,aAAa,CAAC,EAAE,CAAC,wBAAwB,CAAC;IAC9D,CAAC,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC;IACtC,CAAC,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC,WAAW,CAAC;IAC3C,CA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AAK,kBAAkB,CAAC,KAAK,CAAC;AACvD,CAAC;AAED,SAAgB,SAAS,CAAC,GAAc;IACtC,OAAO,WAAW,CAAC,GAAG,CAAC,KAAK,kBAAkB,CAAC,OAAO,CAAC;AACzD,CAAC;AAED,SAAgB,KAAK,CAAC,GAAc;IAClC,OAAO,WAAW,CAAC,GAAG,CAAC,KAAK,kBAAkB,CAAC,GAAG,CAAC;AACrD,CAAC;AAED,SAAgB,WAAW,CAAC,GAAc;IACxC,OAAO,WAAW,CAAC,GAAG,CAAC,KAAK,kBAAkB,CAAC,SAAS,CAAC;AAC3D,CAAC;AAED,wCAAwC;AAC3B,QAAA,SAAS,GAAG,SAAS,CAAC"}
|
|
@@ -10,5 +10,29 @@ export declare class TranslationProvider {
|
|
|
10
10
|
private parseModuleKey;
|
|
11
11
|
private getSearchPaths;
|
|
12
12
|
findTranslationFile(rootUri: URI, translationKey: string, defaultLocale: string): Promise<[string | undefined, string | undefined]>;
|
|
13
|
+
/**
|
|
14
|
+
* Aggregates ALL translation files for `locale` within `translationBaseUri`.
|
|
15
|
+
*
|
|
16
|
+
* Covers two layouts:
|
|
17
|
+
* - Single file: `{base}/{locale}.yml`
|
|
18
|
+
* - Split files: `{base}/{locale}/*.yml`
|
|
19
|
+
*
|
|
20
|
+
* Only files whose first YAML key matches `locale` are included, so a file
|
|
21
|
+
* placed in the wrong directory (or accidentally containing a different
|
|
22
|
+
* locale) is silently ignored.
|
|
23
|
+
*
|
|
24
|
+
* @param contentOverride Optional function called before the filesystem is
|
|
25
|
+
* consulted. Return the file's source string to use it instead of the
|
|
26
|
+
* on-disk content, or `undefined` to fall through to the filesystem.
|
|
27
|
+
* Used by editor integrations to honour unsaved buffer changes.
|
|
28
|
+
*/
|
|
29
|
+
loadAllTranslationsForBase(translationBaseUri: URI, locale: string, contentOverride?: (uri: string) => string | undefined): Promise<Record<string, any>>;
|
|
30
|
+
/**
|
|
31
|
+
* Parses a YAML translation file and returns its contents under the locale
|
|
32
|
+
* key. Returns `undefined` if the file cannot be parsed or if its first
|
|
33
|
+
* key does not match `expectedLocale` (guards against mis-placed files).
|
|
34
|
+
*/
|
|
35
|
+
private parseTranslationFile;
|
|
36
|
+
private deepMerge;
|
|
13
37
|
translate(rootUri: URI, translationKey: string, defaultLocale?: string): Promise<string | undefined>;
|
|
14
38
|
}
|
|
@@ -92,6 +92,82 @@ class TranslationProvider {
|
|
|
92
92
|
}
|
|
93
93
|
return [undefined, undefined];
|
|
94
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Aggregates ALL translation files for `locale` within `translationBaseUri`.
|
|
97
|
+
*
|
|
98
|
+
* Covers two layouts:
|
|
99
|
+
* - Single file: `{base}/{locale}.yml`
|
|
100
|
+
* - Split files: `{base}/{locale}/*.yml`
|
|
101
|
+
*
|
|
102
|
+
* Only files whose first YAML key matches `locale` are included, so a file
|
|
103
|
+
* placed in the wrong directory (or accidentally containing a different
|
|
104
|
+
* locale) is silently ignored.
|
|
105
|
+
*
|
|
106
|
+
* @param contentOverride Optional function called before the filesystem is
|
|
107
|
+
* consulted. Return the file's source string to use it instead of the
|
|
108
|
+
* on-disk content, or `undefined` to fall through to the filesystem.
|
|
109
|
+
* Used by editor integrations to honour unsaved buffer changes.
|
|
110
|
+
*/
|
|
111
|
+
async loadAllTranslationsForBase(translationBaseUri, locale, contentOverride) {
|
|
112
|
+
const merged = {};
|
|
113
|
+
const read = async (uri) => {
|
|
114
|
+
if (contentOverride) {
|
|
115
|
+
const buffered = contentOverride(uri);
|
|
116
|
+
if (buffered !== undefined)
|
|
117
|
+
return buffered;
|
|
118
|
+
}
|
|
119
|
+
return this.readFileIfExists(uri);
|
|
120
|
+
};
|
|
121
|
+
// Strategy A: single locale file ({base}/{locale}.yml)
|
|
122
|
+
const singleFileUri = vscode_uri_1.Utils.joinPath(translationBaseUri, `${locale}.yml`).toString();
|
|
123
|
+
const singleContent = await read(singleFileUri);
|
|
124
|
+
if (singleContent) {
|
|
125
|
+
const parsed = this.parseTranslationFile(singleContent, locale);
|
|
126
|
+
if (parsed)
|
|
127
|
+
this.deepMerge(merged, parsed);
|
|
128
|
+
}
|
|
129
|
+
// Strategy B: locale directory ({base}/{locale}/*.yml)
|
|
130
|
+
const localeDirUri = vscode_uri_1.Utils.joinPath(translationBaseUri, locale).toString();
|
|
131
|
+
const ymlFiles = await this.listYmlFiles(localeDirUri);
|
|
132
|
+
for (const fileUri of ymlFiles) {
|
|
133
|
+
const content = await read(fileUri);
|
|
134
|
+
if (content) {
|
|
135
|
+
const parsed = this.parseTranslationFile(content, locale);
|
|
136
|
+
if (parsed)
|
|
137
|
+
this.deepMerge(merged, parsed);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
return merged;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Parses a YAML translation file and returns its contents under the locale
|
|
144
|
+
* key. Returns `undefined` if the file cannot be parsed or if its first
|
|
145
|
+
* key does not match `expectedLocale` (guards against mis-placed files).
|
|
146
|
+
*/
|
|
147
|
+
parseTranslationFile(content, expectedLocale) {
|
|
148
|
+
try {
|
|
149
|
+
const data = js_yaml_1.default.load(content);
|
|
150
|
+
if (!data || typeof data !== 'object')
|
|
151
|
+
return undefined;
|
|
152
|
+
const firstKey = Object.keys(data)[0];
|
|
153
|
+
if (firstKey !== expectedLocale)
|
|
154
|
+
return undefined;
|
|
155
|
+
return data[firstKey] ?? undefined;
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
return undefined;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
deepMerge(target, source) {
|
|
162
|
+
for (const [key, value] of Object.entries(source)) {
|
|
163
|
+
if (typeof value === 'object' && value !== null && typeof target[key] === 'object') {
|
|
164
|
+
this.deepMerge(target[key], value);
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
target[key] = value;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
95
171
|
async translate(rootUri, translationKey, defaultLocale = 'en') {
|
|
96
172
|
const [file, key] = await this.findTranslationFile(rootUri, translationKey, defaultLocale);
|
|
97
173
|
if (!file || !key) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TranslationProvider.js","sourceRoot":"","sources":["../../src/translation-provider/TranslationProvider.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAqE;AACrE,2CAAwC;AACxC,sDAA2B;AAM3B,MAAa,mBAAmB;IAC9B,YAA6B,EAAsB;QAAtB,OAAE,GAAF,EAAE,CAAoB;IAAG,CAAC;IAE/C,KAAK,CAAC,MAAM,CAAC,IAAY;QAC/B,IAAI,CAAC;YACH,OAAO,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,6BAAQ,CAAC,IAAI,CAAC;QAC3D,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,gBAAgB,CAAC,IAAY;QACzC,OAAO,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACxE,CAAC;IAEO,KAAK,CAAC,YAAY,CAAC,MAAc;QACvC,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;YACpD,OAAO,OAAO;iBACX,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,KAAK,6BAAQ,CAAC,IAAI,CAAC;iBAC5C,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC;iBACrB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7C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AI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;oBACjC,IAAI,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,aAAa,EAAE,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC;wBACxD,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;oBAC/B,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;QAED,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;IAChC,CAAC;IAED,KAAK,CAAC,SAAS,CACb,OAAY,EACZ,cAAsB,EACtB,gBAAwB,IAAI;QAE5B,MAAM,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,EAAE,cAAc,EAAE,aAAa,CAAC,CAAC;QAE3F,IAAI,CAAC,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YAClB,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACnD,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,IAAI,IAAI,GAAQ,iBAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEpC,KAAK,MAAM,IAAI,IAAI,CAAC,aAAa,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;YACtD,IAAI,GAAG,IAAI,EAAE,CAAC,IAAI,CAAC,CAAC;YACpB,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;gBACvB,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF;
|
|
1
|
+
{"version":3,"file":"TranslationProvider.js","sourceRoot":"","sources":["../../src/translation-provider/TranslationProvider.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAqE;AACrE,2CAAwC;AACxC,s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