@abaplint/transpiler-cli 2.12.5 → 2.12.7

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/abap_transpile CHANGED
@@ -1,2 +1,2 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env node
2
2
  require("./build/bundle");
package/build/bundle.js CHANGED
@@ -22879,9 +22879,30 @@ class TypeUtils {
22879
22879
  return true;
22880
22880
  }
22881
22881
  else if (source instanceof basic_1.StructureType) {
22882
- if (this.structureContainsString(target) && !this.structureContainsString(source)) {
22882
+ const targetDeep = this.structureContainsString(target);
22883
+ const sourceDeep = this.structureContainsString(source);
22884
+ if (targetDeep && !sourceDeep) {
22883
22885
  return false;
22884
22886
  }
22887
+ const targetComponents = target.getComponents();
22888
+ const sourceComponents = source.getComponents();
22889
+ if (targetComponents.length !== sourceComponents.length) {
22890
+ if (targetDeep === true || sourceDeep === true) {
22891
+ return false;
22892
+ }
22893
+ }
22894
+ for (let i = 0; i < targetComponents.length; i++) {
22895
+ if (sourceComponents[i] === undefined) {
22896
+ continue;
22897
+ }
22898
+ // hmm
22899
+ if (sourceComponents[i].type instanceof basic_1.StringType && !(targetComponents[i].type instanceof basic_1.StringType)) {
22900
+ return false;
22901
+ }
22902
+ else if (!(sourceComponents[i].type instanceof basic_1.StringType) && targetComponents[i].type instanceof basic_1.StringType) {
22903
+ return false;
22904
+ }
22905
+ }
22885
22906
  return true;
22886
22907
  }
22887
22908
  else if (target.containsVoid() === true) {
@@ -24877,7 +24898,7 @@ class FieldAssignment {
24877
24898
  const text = c.concatTokens();
24878
24899
  if (text !== "-" && context instanceof basic_1.StructureType) {
24879
24900
  context = context.getComponentByName(text);
24880
- if (context === undefined && targetType.containsVoid() === false) {
24901
+ if (context === undefined) {
24881
24902
  const message = `field ${text} does not exist in structure`;
24882
24903
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
24883
24904
  return;
@@ -32031,6 +32052,7 @@ const _object_oriented_1 = __webpack_require__(/*! ../_object_oriented */ "./nod
32031
32052
  const _scope_type_1 = __webpack_require__(/*! ../_scope_type */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_scope_type.js");
32032
32053
  const _reference_1 = __webpack_require__(/*! ../_reference */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_reference.js");
32033
32054
  const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_syntax_input.js");
32055
+ const visibility_1 = __webpack_require__(/*! ../../4_file_information/visibility */ "./node_modules/@abaplint/core/build/src/abap/4_file_information/visibility.js");
32034
32056
  class MethodImplementation {
32035
32057
  runSyntax(node, input) {
32036
32058
  const helper = new _object_oriented_1.ObjectOriented(input.scope);
@@ -32044,6 +32066,13 @@ class MethodImplementation {
32044
32066
  return;
32045
32067
  }
32046
32068
  const { method: methodDefinition } = helper.searchMethodName(classDefinition, methodName);
32069
+ if (classDefinition.isForTesting()
32070
+ && (methodDefinition === null || methodDefinition === void 0 ? void 0 : methodDefinition.getVisibility()) !== visibility_1.Visibility.Private
32071
+ && ["SETUP", "TEARDOWN", "CLASS_SETUP", "CLASS_TEARDOWN"].includes(methodName.toUpperCase())) {
32072
+ const message = "Special test method \"" + methodName + "\" must be private";
32073
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
32074
+ return;
32075
+ }
32047
32076
  const start = node.getFirstToken().getStart();
32048
32077
  if ((methodDefinition === null || methodDefinition === void 0 ? void 0 : methodDefinition.isStatic()) === false) {
32049
32078
  input.scope.push(_scope_type_1.ScopeType.MethodInstance, methodName, start, input.filename);
@@ -32884,6 +32913,11 @@ class ReadTable {
32884
32913
  input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
32885
32914
  return;
32886
32915
  }
32916
+ else if (sourceType instanceof basic_1.TableType && sourceType.getAccessType() === basic_1.TableAccessType.hashed) {
32917
+ const message = "INDEX on hashed table not possible";
32918
+ input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
32919
+ return;
32920
+ }
32887
32921
  }
32888
32922
  const fromSource = node.findExpressionAfterToken("FROM");
32889
32923
  if (fromSource) {
@@ -53637,7 +53671,7 @@ class Registry {
53637
53671
  }
53638
53672
  static abaplintVersion() {
53639
53673
  // magic, see build script "version.sh"
53640
- return "2.113.232";
53674
+ return "2.113.233";
53641
53675
  }
53642
53676
  getDDICReferences() {
53643
53677
  return this.ddicReferences;
@@ -80408,6 +80442,15 @@ class MethodSourceTranspiler {
80408
80442
  }
80409
80443
  call += traversal.traverse(child).getCode();
80410
80444
  }
80445
+ else if (child.get() instanceof core_1.Expressions.SourceFieldSymbol) {
80446
+ call += traversal.traverse(child).getCode();
80447
+ }
80448
+ else if (child.get() instanceof core_1.Expressions.ComponentName) {
80449
+ call += `["${child.concatTokens().toLowerCase()}"]`;
80450
+ }
80451
+ else if (child.get() instanceof core_1.Tokens.Dash) {
80452
+ call += '.get()';
80453
+ }
80411
80454
  else {
80412
80455
  ret.appendString("MethodSourceTranspiler-" + child.get().constructor.name + "-todo");
80413
80456
  }
@@ -84600,7 +84643,7 @@ static INTERNAL_TYPE = 'CLAS';
84600
84643
  static INTERNAL_NAME = '${traversal.buildInternalName(token.getStr(), def)}';
84601
84644
  static IMPLEMENTED_INTERFACES = [${this.findImplementedByClass(traversal, def, scope).map(e => `"` + e.toUpperCase() + `"`).join(",")}];
84602
84645
  static ATTRIBUTES = {${Array.from(traversal.buildAttributes(def, scope)).join(",\n")}};
84603
- static METHODS = {${traversal.buildMethods(def, scope).join(",\n")}};`, node, traversal);
84646
+ static METHODS = {${traversal.buildMethods(def).join(",\n")}};`, node, traversal);
84604
84647
  }
84605
84648
  findImplementedInterface(traversal, def, scope) {
84606
84649
  if (def === undefined || scope === undefined) {
@@ -90736,7 +90779,7 @@ class InterfaceTranspiler {
90736
90779
  ret += `static INTERNAL_TYPE = 'INTF';\n`;
90737
90780
  ret += `static INTERNAL_NAME = '${traversal.buildInternalName(token.getStr(), def)}';\n`;
90738
90781
  ret += `static ATTRIBUTES = {${Array.from(traversal.buildAttributes(def, scope)).join(",\n")}};\n`;
90739
- ret += `static METHODS = {${traversal.buildMethods(def, scope).join(",\n")}};\n`;
90782
+ ret += `static METHODS = {${traversal.buildMethods(def).join(",\n")}};\n`;
90740
90783
  // todo, add IMPLEMENTED_INTERFACES ?
90741
90784
  }
90742
90785
  else if (c instanceof abaplint.Nodes.StatementNode && c.get() instanceof abaplint.Statements.EndInterface) {
@@ -91632,7 +91675,7 @@ class Traversal {
91632
91675
  }
91633
91676
  return undefined;
91634
91677
  }
91635
- buildMethods(def, _scope) {
91678
+ buildMethods(def) {
91636
91679
  const methods = [];
91637
91680
  if (def === undefined) {
91638
91681
  return methods;
@@ -103651,32 +103694,36 @@ class Progress {
103651
103694
  }
103652
103695
  async function loadLib(config) {
103653
103696
  const files = [];
103654
- for (const l of config.libs || []) {
103697
+ for (const lib of config.libs || []) {
103655
103698
  let dir = "";
103656
103699
  let cleanupFolder = false;
103657
- if (l.folder !== undefined && l.folder !== "" && fs.existsSync(process.cwd() + l.folder)) {
103658
- console.log("From folder: " + l.folder);
103659
- dir = process.cwd() + l.folder;
103700
+ if (lib.folder !== undefined && lib.folder !== "" && fs.existsSync(process.cwd() + lib.folder)) {
103701
+ console.log("From folder: " + lib.folder);
103702
+ dir = process.cwd() + lib.folder;
103660
103703
  }
103661
103704
  else {
103662
- console.log("Clone: " + l.url);
103705
+ console.log("Clone: " + lib.url);
103663
103706
  dir = fs.mkdtempSync(path.join(os.tmpdir(), "abap_transpile-"));
103664
- childProcess.execSync("git clone --quiet --depth 1 " + l.url + " .", { cwd: dir, stdio: "inherit" });
103707
+ childProcess.execSync("git clone --quiet --depth 1 " + lib.url + " .", { cwd: dir, stdio: "inherit" });
103665
103708
  cleanupFolder = true;
103666
103709
  }
103667
103710
  let patterns = ["/src/**"];
103668
- if (l.files !== undefined && typeof l.files === "string" && l.files !== "") {
103669
- patterns = [l.files];
103711
+ if (lib.files !== undefined && typeof lib.files === "string" && lib.files !== "") {
103712
+ patterns = [lib.files];
103670
103713
  }
103671
- else if (Array.isArray(l.files)) {
103672
- patterns = l.files;
103714
+ else if (Array.isArray(lib.files)) {
103715
+ patterns = lib.files;
103673
103716
  }
103717
+ const excludeFilters = (lib.exclude_filter ?? []).map(pattern => new RegExp(pattern, "i"));
103674
103718
  const filesToRead = [];
103675
103719
  for (const pattern of patterns) {
103676
103720
  for (const filename of glob.sync(dir + pattern, { nosort: true, nodir: true })) {
103677
103721
  if (filename.endsWith(".clas.testclasses.abap")) {
103678
103722
  continue;
103679
103723
  }
103724
+ else if (excludeFilters.length > 0 && excludeFilters.some(a => a.test(filename)) === true) {
103725
+ continue;
103726
+ }
103680
103727
  filesToRead.push(filename);
103681
103728
  }
103682
103729
  }
package/build/types.d.ts CHANGED
@@ -1,15 +1,23 @@
1
1
  import { ITranspilerOptions } from "@abaplint/transpiler";
2
2
  export interface ITranspilerConfig {
3
3
  input_folder: string | string[];
4
- /** list of regex, case insensitive, empty gives all files, positive list */
4
+ /** list of regex, case insensitive, empty gives all files, positive list
5
+ * @uniqueItems true
6
+ */
5
7
  input_filter?: string[];
6
- /** list of regex, case insensitive */
8
+ /** list of regex, case insensitive
9
+ * @uniqueItems true
10
+ */
7
11
  exclude_filter?: string[];
8
12
  output_folder: string;
9
13
  libs?: {
10
14
  url?: string;
11
15
  folder?: string;
12
16
  files?: string | string[];
17
+ /** list of regex, case insensitive
18
+ * @uniqueItems true
19
+ */
20
+ exclude_filter?: string[];
13
21
  }[];
14
22
  write_unit_tests?: boolean;
15
23
  write_source_map?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.12.5",
3
+ "version": "2.12.7",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -27,10 +27,10 @@
27
27
  "author": "abaplint",
28
28
  "license": "MIT",
29
29
  "devDependencies": {
30
- "@abaplint/core": "^2.113.232",
31
- "@abaplint/transpiler": "^2.12.5",
30
+ "@abaplint/core": "^2.113.233",
31
+ "@abaplint/transpiler": "^2.12.7",
32
32
  "@types/glob": "^8.1.0",
33
- "@types/node": "^24.8.1",
33
+ "@types/node": "^24.9.1",
34
34
  "@types/progress": "^2.0.7",
35
35
  "glob": "=7.2.0",
36
36
  "progress": "^2.0.3",
package/schema.json ADDED
@@ -0,0 +1,219 @@
1
+ {
2
+ "$ref": "#/definitions/ITranspilerConfig",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "ITranspilerConfig": {
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "exclude_filter": {
9
+ "description": "list of regex, case insensitive",
10
+ "items": {
11
+ "type": "string"
12
+ },
13
+ "type": "array",
14
+ "uniqueItems": true
15
+ },
16
+ "input_filter": {
17
+ "description": "list of regex, case insensitive, empty gives all files, positive list",
18
+ "items": {
19
+ "type": "string"
20
+ },
21
+ "type": "array",
22
+ "uniqueItems": true
23
+ },
24
+ "input_folder": {
25
+ "anyOf": [
26
+ {
27
+ "type": "string"
28
+ },
29
+ {
30
+ "items": {
31
+ "type": "string"
32
+ },
33
+ "type": "array"
34
+ }
35
+ ]
36
+ },
37
+ "libs": {
38
+ "items": {
39
+ "additionalProperties": false,
40
+ "properties": {
41
+ "exclude_filter": {
42
+ "description": "list of regex, case insensitive",
43
+ "items": {
44
+ "type": "string"
45
+ },
46
+ "type": "array",
47
+ "uniqueItems": true
48
+ },
49
+ "files": {
50
+ "anyOf": [
51
+ {
52
+ "type": "string"
53
+ },
54
+ {
55
+ "items": {
56
+ "type": "string"
57
+ },
58
+ "type": "array"
59
+ }
60
+ ]
61
+ },
62
+ "folder": {
63
+ "type": "string"
64
+ },
65
+ "url": {
66
+ "type": "string"
67
+ }
68
+ },
69
+ "type": "object"
70
+ },
71
+ "type": "array"
72
+ },
73
+ "options": {
74
+ "$ref": "#/definitions/ITranspilerOptions"
75
+ },
76
+ "output_folder": {
77
+ "type": "string"
78
+ },
79
+ "write_source_map": {
80
+ "type": "boolean"
81
+ },
82
+ "write_unit_tests": {
83
+ "type": "boolean"
84
+ }
85
+ },
86
+ "required": [
87
+ "input_folder",
88
+ "output_folder",
89
+ "options"
90
+ ],
91
+ "type": "object"
92
+ },
93
+ "ITranspilerOptions": {
94
+ "additionalProperties": false,
95
+ "properties": {
96
+ "addCommonJS": {
97
+ "description": "adds common js modules",
98
+ "type": "boolean"
99
+ },
100
+ "addFilenames": {
101
+ "description": "adds filenames as comments in the output js",
102
+ "type": "boolean"
103
+ },
104
+ "ignoreSourceMap": {
105
+ "description": "ignore source map",
106
+ "type": "boolean"
107
+ },
108
+ "ignoreSyntaxCheck": {
109
+ "description": "ignore syntax check, used for internal testing",
110
+ "type": "boolean"
111
+ },
112
+ "importProg": {
113
+ "description": "import programs",
114
+ "type": "boolean"
115
+ },
116
+ "keywords": {
117
+ "description": "list of keywords to rename, if not supplied default will be used",
118
+ "items": {
119
+ "type": "string"
120
+ },
121
+ "type": "array"
122
+ },
123
+ "populateTables": {
124
+ "additionalProperties": false,
125
+ "description": "populate tables, all tables are populated if undefined and they exist",
126
+ "properties": {
127
+ "reposrc": {
128
+ "description": "insert into REPOSRC, skips if equals false",
129
+ "type": "boolean"
130
+ },
131
+ "seosubco": {
132
+ "description": "insert into SEOSUBCO, skips if equals false",
133
+ "type": "boolean"
134
+ },
135
+ "seosubcodf": {
136
+ "description": "insert into SEOSUBCODF, skips if equals false",
137
+ "type": "boolean"
138
+ },
139
+ "seosubcotx": {
140
+ "description": "insert into SEOSUBCOTX, skips if equals false",
141
+ "type": "boolean"
142
+ }
143
+ },
144
+ "type": "object"
145
+ },
146
+ "setup": {
147
+ "additionalProperties": false,
148
+ "description": "extra setup script to be executed during initialization",
149
+ "properties": {
150
+ "filename": {
151
+ "type": "string"
152
+ },
153
+ "postFunction": {
154
+ "type": "string"
155
+ },
156
+ "preFunction": {
157
+ "type": "string"
158
+ }
159
+ },
160
+ "required": [
161
+ "filename"
162
+ ],
163
+ "type": "object"
164
+ },
165
+ "skip": {
166
+ "$ref": "#/definitions/TestMethodList",
167
+ "description": "list of unit tests to skip"
168
+ },
169
+ "skipVersionCheck": {
170
+ "description": "skips version check, not recommended",
171
+ "type": "boolean"
172
+ },
173
+ "unknownTypes": {
174
+ "$ref": "#/definitions/UnknownTypesEnum",
175
+ "description": "sets behavior for unknown types, either fail at compile- or run-time"
176
+ }
177
+ },
178
+ "type": "object"
179
+ },
180
+ "TestMethodList": {
181
+ "items": {
182
+ "additionalProperties": false,
183
+ "properties": {
184
+ "class": {
185
+ "pattern": "^[a-zA-Z0-9_\\/]+$",
186
+ "type": "string"
187
+ },
188
+ "method": {
189
+ "pattern": "^[a-zA-Z0-9_\\/]+$",
190
+ "type": "string"
191
+ },
192
+ "note": {
193
+ "type": "string"
194
+ },
195
+ "object": {
196
+ "pattern": "^[a-zA-Z0-9_\\/]+$",
197
+ "type": "string"
198
+ }
199
+ },
200
+ "required": [
201
+ "object",
202
+ "class",
203
+ "method"
204
+ ],
205
+ "type": "object"
206
+ },
207
+ "type": "array",
208
+ "uniqueItems": true
209
+ },
210
+ "UnknownTypesEnum": {
211
+ "enum": [
212
+ "compileError",
213
+ "runtimeError"
214
+ ],
215
+ "type": "string"
216
+ }
217
+ }
218
+ }
219
+