@platforma-sdk/tengo-builder 2.1.3 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +10 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +111 -107
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/commands/build.ts +24 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platforma-sdk/tengo-builder",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.4",
|
|
4
4
|
"description": "Pl Tengo Template Builder",
|
|
5
5
|
"bin": {
|
|
6
6
|
"pl-tengo": "./bin/run.js"
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"@oclif/core": "^4.0.37",
|
|
20
20
|
"canonicalize": "~2.1.0",
|
|
21
21
|
"winston": "^3.17.0",
|
|
22
|
-
"@milaboratories/
|
|
22
|
+
"@milaboratories/ts-helpers": "1.2.0",
|
|
23
23
|
"@milaboratories/pl-model-backend": "^1.1.0",
|
|
24
|
-
"@milaboratories/
|
|
24
|
+
"@milaboratories/resolve-helper": "1.1.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"typescript": "~5.5.4",
|
package/src/commands/build.ts
CHANGED
|
@@ -104,7 +104,10 @@ function checkAndGenerateCtags(
|
|
|
104
104
|
const additionalArgs = flags['tags-additional-args'];
|
|
105
105
|
|
|
106
106
|
// all tengo files in dirs and subdirs
|
|
107
|
-
|
|
107
|
+
// If we don't limit the depth, it could become unbearably slow
|
|
108
|
+
// and even OOM killed node js.
|
|
109
|
+
// Increase the depth if you need to.
|
|
110
|
+
const tengoFiles = toRelativePath(rootDir, getTengoFiles(rootDir, 9));
|
|
108
111
|
|
|
109
112
|
logger.info(
|
|
110
113
|
`Generating tags for tengo autocompletion from "${rootDir}" \
|
|
@@ -112,7 +115,7 @@ in "${fileName}", additional arguments: "${additionalArgs.join('" "')}".
|
|
|
112
115
|
Found ${tengoFiles.length} tengo files...`,
|
|
113
116
|
);
|
|
114
117
|
|
|
115
|
-
// see https://docs.ctags.io/en/
|
|
118
|
+
// see https://docs.ctags.io/en/latest/man/ctags-optlib.7.html#perl-pod
|
|
116
119
|
const result = spawnSync(
|
|
117
120
|
'ctags',
|
|
118
121
|
[
|
|
@@ -153,21 +156,34 @@ https://marketplace.visualstudio.com/items?itemName=jaydenlin.ctags-support`);
|
|
|
153
156
|
logger.info('Generation of tags is done.');
|
|
154
157
|
}
|
|
155
158
|
|
|
156
|
-
function getTengoFiles(dir: string): string[] {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
+
function getTengoFiles(dir: string, depth: number): string[] {
|
|
160
|
+
if (depth === 0) {
|
|
161
|
+
return [];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const files = fs.readdirSync(dir, { withFileTypes: true });
|
|
159
165
|
|
|
166
|
+
let tengoFiles: string[] = [];
|
|
160
167
|
files.forEach((file) => {
|
|
168
|
+
const absPath = path.join(dir, file.name);
|
|
169
|
+
|
|
170
|
+
if (file.isDirectory()) {
|
|
171
|
+
tengoFiles = tengoFiles.concat(getTengoFiles(absPath, depth - 1));
|
|
172
|
+
}
|
|
173
|
+
|
|
161
174
|
if (!file.isDirectory() && file.name.endsWith('.tengo')) {
|
|
162
|
-
|
|
163
|
-
const relativePath = path.join(file.parentPath, file.name).replace(dir, '.');
|
|
164
|
-
tengoFiles.push(relativePath);
|
|
175
|
+
tengoFiles.push(absPath);
|
|
165
176
|
}
|
|
166
177
|
});
|
|
167
178
|
|
|
168
179
|
return tengoFiles;
|
|
169
180
|
}
|
|
170
181
|
|
|
182
|
+
function toRelativePath(dir: string, files: string[]): string[] {
|
|
183
|
+
// Note that VS Code extension likes only relatives paths to the root of the opened dir.
|
|
184
|
+
return files.map((file) => file.replace(dir, '.'));
|
|
185
|
+
}
|
|
186
|
+
|
|
171
187
|
function checkRunError(result: SpawnSyncReturns<Buffer>, message?: string) {
|
|
172
188
|
if (result.error) {
|
|
173
189
|
console.log(result.error);
|