node-opcua-convert-nodeset-to-javascript 2.169.0 → 2.172.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,6 +11,26 @@ const node_opcua_constants_1 = require("node-opcua-constants");
11
11
  const walk_through_1 = require("./walk_through");
12
12
  const convert_to_typescript_1 = require("./convert_to_typescript");
13
13
  const cache_1 = require("./private/cache");
14
+ // Robust write: on Windows, transient locks from antivirus, OneDrive, or the
15
+ // TS language server (when files are open in an IDE) surface as ERROR_SHARING_VIOLATION
16
+ // (errno -4094 / code UNKNOWN/EBUSY/EPERM). Retry with backoff.
17
+ function writeFileSyncRetry(filePath, content, attempts = 6) {
18
+ for (let i = 0; i < attempts; i++) {
19
+ try {
20
+ fs_1.default.writeFileSync(filePath, content);
21
+ return;
22
+ }
23
+ catch (err) {
24
+ const code = err.code;
25
+ const transient = code === "UNKNOWN" || code === "EBUSY" || code === "EPERM";
26
+ if (!transient || i === attempts - 1)
27
+ throw err;
28
+ // Synchronous backoff (tight loop is fine for ~ms-scale retries).
29
+ const until = Date.now() + 50 * (i + 1);
30
+ while (Date.now() < until) { /* spin */ }
31
+ }
32
+ }
33
+ }
14
34
  function getPackageFolder(dependency, options) {
15
35
  const l = [...(options.lookupFolders || [])];
16
36
  l.push(path_1.default.join(__dirname, "../../"));
@@ -77,7 +97,7 @@ async function convertNamespaceTypeToTypescript(session, namespaceIndex, options
77
97
  if (!fs_1.default.existsSync(sourceFolder)) {
78
98
  fs_1.default.mkdirSync(sourceFolder);
79
99
  }
80
- fs_1.default.writeFileSync(path_1.default.join(sourceFolder, filename + ".ts"), content);
100
+ writeFileSyncRetry(path_1.default.join(sourceFolder, filename + ".ts"), content);
81
101
  infos[module] = infos[module] || { folder, dependencies: [], module, files: [] };
82
102
  infos[module].files.push(filename + ".ts");
83
103
  infos[module].dependencies = [...new Set([...infos[module].dependencies, ...dependencies])];
@@ -222,10 +242,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
222
242
  // content3.push(fs.readFileSync(path.join(__dirname, "../source/licences/agpl_v3.md"), "utf8"));
223
243
  fs_1.default.writeFileSync(licenseFile, content3.join("\n"));
224
244
  }
225
- const remove_unused_1 = require("./remove_unused");
226
- function _tidyUpImports(folder) {
227
- (0, remove_unused_1.cleanUpTypescriptModule)(folder);
228
- }
229
245
  async function outputFiles(infos, options) {
230
246
  const values = Object.values(infos);
231
247
  if (values.length < 1) {
@@ -233,12 +249,13 @@ async function outputFiles(infos, options) {
233
249
  }
234
250
  console.log("generating files for ", options.nsName);
235
251
  for (const info of values) {
236
- // create indexes
237
252
  await _output_index_ts_file(info);
238
253
  await _output_package_json(info, options);
239
254
  await _output_tsconfig_json(info, options);
240
255
  await _output_licence(info, options);
241
- await _tidyUpImports(info.folder);
242
256
  }
257
+ // Import cleanup is deferred to a second, parallel phase in main.ts —
258
+ // each namespace's cleanup uses an isolated ts-morph Project, so the
259
+ // expensive AST work can run across many cores without contention.
243
260
  }
244
261
  //# sourceMappingURL=convert_namespace_to_typescript.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"convert_namespace_to_typescript.js","sourceRoot":"","sources":["../source/convert_namespace_to_typescript.ts"],"names":[],"mappings":";;;;;AAoDA,4EA4DC;AAhHD,mCAAmC;AACnC,gDAAwB;AACxB,4CAAoB;AAGpB,+DAAmD;AACnD,iDAAgI;AAChI,mEAAkE;AAClE,2CAAiD;AAGjD,SAAS,gBAAgB,CAAC,UAAkB,EAAE,OAAgB;IAC1D,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,CAAC;IAC7C,CAAC,CAAC,IAAI,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC;IACvC,KAAK,MAAM,MAAM,IAAI,CAAC,EAAE,CAAC;QACrB,MAAM,CAAC,GAAG,cAAI,CAAC,IAAI,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AO,CAAC,CAAC;QAE3C,MAAM,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAGrC,MAAM,cAAc,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;AACL,CAAC"}
1
+ {"version":3,"file":"convert_namespace_to_typescript.js","sourceRoot":"","sources":["../source/convert_namespace_to_typescript.ts"],"names":[],"mappings":";;;;;AAuEA,4EA4DC;AAnID,mCAAmC;AACnC,gDAAwB;AACxB,4CAAoB;AAGpB,+DAAmD;AACnD,iDAAgI;AAChI,mEAAkE;AAClE,2CAAiD;AAGjD,6EAA6E;AAC7E,wFAAwF;AACxF,gEAAgE;AAChE,SAAS,kBAAkB,CAAC,QAAgB,EAAE,OAAe,EAAE,QAAQ,GAAG,CAAC;IACvE,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,IAAI,CAAC;YACD,YAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACpC,OAAO;QACX,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACX,MAAM,IAAI,GAAI,GAA6B,CAAC,IAAI,CAAC;YACjD,MAAM,SAAS,GAAG,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,OAAO,IAAI,IAAI,KAAK,OAAO,CAAC;YAC7E,IAAI,CAAC,SAAS,IAAI,CAAC,KAAK,QAAQ,GAAG,CAAC;gBAAE,MAAM,GAAG,CAAC;YAChD,kEAAkE;YAClE,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;YACxC,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC;QAC7C,CAAC;IACL,CAAC;AACL,CAAC;AAED,SAAS,gBAAgB,CAAC,UAAkB,EAAE,OAAgB;IAC1D,MAAM,CAA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,qBAAqB,CAAC,IAAI,CAAC,CAAC;QAClC,MAAM,oBAAoB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC1C,MAAM,qBAAqB,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAC3C,MAAM,eAAe,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACzC,CAAC;IACD,sEAAsE;IACtE,qEAAqE;IACrE,mEAAmE;AACvE,CAAC"}
package/dist/main.js CHANGED
@@ -3,33 +3,64 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const path_1 = __importDefault(require("path"));
6
+ const node_fs_1 = __importDefault(require("node:fs"));
7
+ const node_os_1 = __importDefault(require("node:os"));
8
+ const node_path_1 = __importDefault(require("node:path"));
7
9
  const node_opcua_address_space_1 = require("node-opcua-address-space");
8
10
  const nodeJS_1 = require("node-opcua-address-space/nodeJS");
9
11
  const node_opcua_nodesets_1 = require("node-opcua-nodesets");
10
12
  const convert_namespace_to_typescript_1 = require("./convert_namespace_to_typescript");
13
+ const remove_unused_1 = require("./remove_unused");
11
14
  const update_parent_tsconfig_1 = require("./update_parent_tsconfig");
15
+ async function runWithConcurrency(items, limit, fn) {
16
+ let cursor = 0;
17
+ const workers = Array.from({ length: limit }, async () => {
18
+ while (true) {
19
+ const idx = cursor++;
20
+ if (idx >= items.length)
21
+ return;
22
+ await fn(items[idx]);
23
+ }
24
+ });
25
+ await Promise.all(workers);
26
+ }
12
27
  async function main() {
13
28
  const addressSpace = node_opcua_address_space_1.AddressSpace.create();
14
29
  const xmlFiles = node_opcua_nodesets_1.nodesetCatalog.map((set) => (0, node_opcua_nodesets_1.constructNodesetFilename)(set.xmlFile));
15
30
  await (0, nodeJS_1.generateAddressSpace)(addressSpace, xmlFiles);
16
31
  const session = new node_opcua_address_space_1.PseudoSession(addressSpace);
17
32
  const options = {
18
- baseFolder: path_1.default.join(__dirname, "../../"),
33
+ baseFolder: node_path_1.default.join(__dirname, "../../"),
19
34
  prefix: "node-opcua-nodeset-",
20
35
  };
21
36
  // const nodesetCatalog2 = nodesetCatalog.filter((meta) => meta.name == "scales");
22
- await Promise.all(node_opcua_nodesets_1.nodesetCatalog.map((meta) => {
37
+ // Phase 1: convert each namespace sequentially.
38
+ // The convert step writes type files into whichever package the type
39
+ // *originates* in, not the namespace being processed. Two namespaces
40
+ // running in parallel will both try to write e.g. node-opcua-nodeset-ua
41
+ // files concurrently, causing Windows ERROR_SHARING_VIOLATION.
42
+ for (const meta of node_opcua_nodesets_1.nodesetCatalog) {
23
43
  const index = addressSpace.getNamespaceIndex(meta.uri);
24
44
  if (index === -1) {
25
45
  console.log("namespace not found", meta.uri);
26
- return;
46
+ continue;
27
47
  }
28
- return (0, convert_namespace_to_typescript_1.convertNamespaceTypeToTypescript)(session, index, {
48
+ await (0, convert_namespace_to_typescript_1.convertNamespaceTypeToTypescript)(session, index, {
29
49
  ...options,
30
50
  nsName: meta.name,
31
51
  });
32
- }));
52
+ }
53
+ // Phase 2: clean up imports in every nodeset package that actually has a
54
+ // source/ folder on disk. This covers cases where a catalog entry name
55
+ // doesn't line up with its package folder (e.g. catalog "standard" writes
56
+ // into node-opcua-nodeset-ua).
57
+ const folders = node_fs_1.default.readdirSync(options.baseFolder)
58
+ .filter((name) => name.startsWith(options.prefix))
59
+ .map((name) => node_path_1.default.join(options.baseFolder, name))
60
+ .filter((p) => node_fs_1.default.existsSync(node_path_1.default.join(p, "source")));
61
+ const concurrency = Math.max(2, Math.min(node_os_1.default.cpus().length, 12));
62
+ console.log(`tidying imports across ${folders.length} packages with concurrency=${concurrency}`);
63
+ await runWithConcurrency(folders, concurrency, remove_unused_1.cleanUpTypescriptModule);
33
64
  await (0, update_parent_tsconfig_1.updateParentTSConfig)();
34
65
  }
35
66
  void main();
package/dist/main.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"main.js","sourceRoot":"","sources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E,CAAC"}
@@ -4,49 +4,199 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.cleanUpTypescriptModule = cleanUpTypescriptModule;
7
+ const node_fs_1 = __importDefault(require("node:fs"));
8
+ const node_path_1 = __importDefault(require("node:path"));
7
9
  const ts_morph_1 = require("ts-morph");
8
- const fs_1 = __importDefault(require("fs"));
9
- const path_1 = __importDefault(require("path"));
10
10
  const dryRun = false;
11
- function fixFile(file) {
12
- // Remove unused imports
11
+ const NODE_BUILTINS = new Set([
12
+ "assert", "async_hooks", "buffer", "child_process", "cluster", "console",
13
+ "crypto", "dgram", "dns", "events", "fs", "http", "http2", "https", "net",
14
+ "os", "path", "perf_hooks", "process", "querystring", "readline", "stream",
15
+ "string_decoder", "tls", "tty", "url", "util", "v8", "vm", "worker_threads",
16
+ "zlib",
17
+ ]);
18
+ function importGroup(spec) {
19
+ if (spec.startsWith("node:") || NODE_BUILTINS.has(spec))
20
+ return 0;
21
+ if (spec.startsWith("."))
22
+ return 3;
23
+ if (spec.startsWith("node-opcua"))
24
+ return 2;
25
+ return 1;
26
+ }
27
+ function applyTypeOnlyImports(file) {
28
+ // Pass 1: collect identifier names used in value (runtime) positions.
29
+ // Anything whose name appears only in TypeNode positions is type-only.
30
+ const valueNames = new Set();
31
+ file.forEachDescendant((node) => {
32
+ if (node.getKind() !== ts_morph_1.SyntaxKind.Identifier)
33
+ return;
34
+ const parent = node.getParent();
35
+ if (!parent)
36
+ return;
37
+ // Declaration sites are not usages.
38
+ if (ts_morph_1.Node.isImportSpecifier(parent))
39
+ return;
40
+ if (ts_morph_1.Node.isImportClause(parent))
41
+ return;
42
+ if (ts_morph_1.Node.isNamespaceImport(parent))
43
+ return;
44
+ // Walk past QualifiedName chains: in dotted type references like
45
+ // `UAProperty<UInt32, DataType.UInt32>` both `DataType` and the inner
46
+ // `UInt32` have a QualifiedName as their immediate parent, but the
47
+ // surrounding context is a TypeReference (a TypeNode).
48
+ let ctx = parent;
49
+ while (ts_morph_1.Node.isQualifiedName(ctx)) {
50
+ const p = ctx.getParent();
51
+ if (!p)
52
+ break;
53
+ ctx = p;
54
+ }
55
+ if (ts_morph_1.Node.isTypeNode(ctx))
56
+ return;
57
+ // `interface X extends Foo` — Foo's parent is ExpressionWithTypeArguments
58
+ // inside a HeritageClause inside an InterfaceDeclaration. Still type-only.
59
+ if (ts_morph_1.Node.isExpressionWithTypeArguments(ctx)) {
60
+ const heritage = ctx.getParent();
61
+ if (heritage && ts_morph_1.Node.isHeritageClause(heritage)) {
62
+ const decl = heritage.getParent();
63
+ if (decl && ts_morph_1.Node.isInterfaceDeclaration(decl))
64
+ return;
65
+ }
66
+ }
67
+ valueNames.add(node.getText());
68
+ });
69
+ // Pass 2: flip type-only on import specifiers, hoist when all qualify.
13
70
  file.getImportDeclarations().forEach((importDecl) => {
71
+ if (importDecl.isTypeOnly())
72
+ return;
14
73
  const namedImports = importDecl.getNamedImports();
15
- const usedNamedImports = namedImports.filter((namedImport) => {
16
- const name = namedImport.getNameNode().getText();
17
- return file.getDescendantsOfKind(ts_morph_1.SyntaxKind.Identifier)
18
- .some(id => id.getText() === name && id !== namedImport.getNameNode());
74
+ if (namedImports.length === 0)
75
+ return;
76
+ const hasDefault = !!importDecl.getDefaultImport();
77
+ const hasNamespace = !!importDecl.getNamespaceImport();
78
+ const isTypeOnly = namedImports.map((spec) => {
79
+ if (spec.isTypeOnly())
80
+ return true;
81
+ const localName = spec.getAliasNode()?.getText() ?? spec.getNameNode().getText();
82
+ return !valueNames.has(localName);
19
83
  });
20
- // If none are used, remove whole import
21
- if (usedNamedImports.length === 0) {
22
- console.log("removing wholee import", importDecl.getText());
23
- importDecl.remove();
84
+ const allTypeOnly = isTypeOnly.every(Boolean);
85
+ if (allTypeOnly && !hasDefault && !hasNamespace) {
86
+ // Hoist to `import type { ... }`; clear redundant per-specifier `type` keywords.
87
+ importDecl.setIsTypeOnly(true);
88
+ namedImports.forEach((spec) => {
89
+ if (spec.isTypeOnly())
90
+ spec.setIsTypeOnly(false);
91
+ });
24
92
  }
25
- else if (usedNamedImports.length < namedImports.length) {
26
- // Remove only unused named imports
27
- namedImports.forEach(named => {
28
- if (!usedNamedImports.includes(named)) {
29
- console.log("removing name in import ", named.getText());
30
- named.remove();
93
+ else {
94
+ namedImports.forEach((spec, i) => {
95
+ if (isTypeOnly[i] && !spec.isTypeOnly()) {
96
+ spec.setIsTypeOnly(true);
31
97
  }
32
98
  });
33
99
  }
34
100
  });
35
- // Remove unused local variables (function-scope or top-level)
36
- file.getVariableStatements().forEach(variableStatement => {
37
- variableStatement.getDeclarations().forEach(declaration => {
101
+ }
102
+ function regroupImports(file) {
103
+ const imports = file.getImportDeclarations();
104
+ if (imports.length === 0)
105
+ return;
106
+ const structures = imports.map((d) => d.getStructure());
107
+ for (const d of [...imports].reverse())
108
+ d.remove();
109
+ structures.sort((a, b) => {
110
+ const ga = importGroup(a.moduleSpecifier);
111
+ const gb = importGroup(b.moduleSpecifier);
112
+ if (ga !== gb)
113
+ return ga - gb;
114
+ return a.moduleSpecifier.localeCompare(b.moduleSpecifier);
115
+ });
116
+ file.insertImportDeclarations(0, structures);
117
+ const reinserted = file.getImportDeclarations();
118
+ for (let i = 1; i < reinserted.length; i++) {
119
+ const prevG = importGroup(reinserted[i - 1].getModuleSpecifierValue());
120
+ const currG = importGroup(reinserted[i].getModuleSpecifierValue());
121
+ if (prevG !== currG) {
122
+ reinserted[i].prependWhitespace("\n");
123
+ }
124
+ }
125
+ }
126
+ const BIOME_IGNORE_EMPTY_INTERFACE = "// biome-ignore lint/suspicious/noEmptyInterface: forward-compatible placeholder for OPC-UA generated types";
127
+ function tidyEmptyInterfaces(file) {
128
+ // Two complaints to resolve:
129
+ // 1. Formatter wants `interface X {}` on a single line, not `{\n}`.
130
+ // 2. suspicious/noEmptyInterface fires for `interface X {}` WITHOUT extends.
131
+ // For `interface X extends Y {}` the rule doesn't fire, so a directive
132
+ // there is reported as "unused".
133
+ //
134
+ // First pass (in reverse, since text only shrinks): collapse bodies.
135
+ // Then a snapshot+descending pass for the biome-ignore directives, which
136
+ // only target interfaces with no extends clause.
137
+ const ifaces = file.getInterfaces();
138
+ for (let i = ifaces.length - 1; i >= 0; i--) {
139
+ const iface = ifaces[i];
140
+ if (iface.getMembers().length !== 0)
141
+ continue;
142
+ const text = iface.getText();
143
+ const collapsed = text.replace(/\{\s*\}\s*$/, "{}");
144
+ if (collapsed !== text) {
145
+ iface.replaceWithText(collapsed);
146
+ }
147
+ }
148
+ // Re-fetch (previous replaceWithText calls may have invalidated nodes),
149
+ // then snapshot positions before inserting comment lines.
150
+ const positions = [];
151
+ for (const iface of file.getInterfaces()) {
152
+ if (iface.getMembers().length !== 0)
153
+ continue;
154
+ // Rule only fires when there's no extends clause.
155
+ if (iface.getExtends().length !== 0)
156
+ continue;
157
+ const leading = iface.getLeadingCommentRanges().map((c) => c.getText()).join("\n");
158
+ if (leading.includes("biome-ignore lint/suspicious/noEmptyInterface"))
159
+ continue;
160
+ positions.push(iface.getStart());
161
+ }
162
+ positions.sort((a, b) => b - a);
163
+ for (const pos of positions) {
164
+ file.insertText(pos, `${BIOME_IGNORE_EMPTY_INTERFACE}\n`);
165
+ }
166
+ }
167
+ function fixFile(file) {
168
+ // Sort alphabetically, dedupe, drop unused imports.
169
+ file.organizeImports();
170
+ // Mark type-only specifiers; hoist when the whole import qualifies.
171
+ applyTypeOnlyImports(file);
172
+ // Group: builtins → external → node-opcua-* → relative.
173
+ regroupImports(file);
174
+ // Collapse empty interface bodies to single-line `{}` and add a
175
+ // suppression directive for the ones the lint rule actually fires on.
176
+ tidyEmptyInterfaces(file);
177
+ // Remove unused local variables (function-scope or top-level).
178
+ // Use a single-pass identifier-name frequency map instead of ts-morph's
179
+ // findReferences(), which calls TS's reference finder per declaration —
180
+ // unreliable without dep resolution and 10–100× slower. For generated
181
+ // code (no fancy scoping), name count > 1 is a sufficient proxy for "used".
182
+ const identifierCounts = new Map();
183
+ file.forEachDescendant((node) => {
184
+ if (node.getKind() === ts_morph_1.SyntaxKind.Identifier) {
185
+ const txt = node.getText();
186
+ identifierCounts.set(txt, (identifierCounts.get(txt) || 0) + 1);
187
+ }
188
+ });
189
+ file.getVariableStatements().forEach((variableStatement) => {
190
+ variableStatement.getDeclarations().forEach((declaration) => {
38
191
  const name = declaration.getName();
39
- const references = declaration.findReferences();
40
- const isUsed = references.some(ref => {
41
- return ref.getReferences().some(r => !r.isDefinition());
42
- });
43
- if (!isUsed) {
192
+ const count = identifierCounts.get(name) ?? 0;
193
+ // Count includes the declaration's own name node; >1 means referenced elsewhere.
194
+ if (count <= 1) {
44
195
  console.log("removing unused variable=", name);
45
196
  declaration.remove();
46
197
  }
47
198
  });
48
199
  try {
49
- // If no declarations left in this statement, remove the whole statement
50
200
  if (variableStatement.getDeclarations().length === 0) {
51
201
  console.log("removing variable statement:", variableStatement.getText());
52
202
  variableStatement.remove();
@@ -56,20 +206,35 @@ function fixFile(file) {
56
206
  console.log(err.message);
57
207
  }
58
208
  });
59
- // Save changes
60
209
  if (!dryRun) {
61
210
  file.saveSync();
62
211
  }
63
212
  }
64
213
  async function cleanUpTypescriptModule(moduleFolder) {
214
+ const sourceFolder = node_path_1.default.join(moduleFolder, "source");
215
+ // Some namespaces in the catalog don't have a dedicated module folder
216
+ // (their types are written into a shared package like node-opcua-nodeset-ua).
217
+ // Nothing to tidy here — silently skip.
218
+ if (!node_fs_1.default.existsSync(sourceFolder)) {
219
+ return;
220
+ }
221
+ // Isolated project: only this module's own files, no tsconfig dependency
222
+ // resolution. The cleanup analysis is purely syntactic (organizeImports +
223
+ // type-position check via AST), so we don't need the full type checker —
224
+ // and skipping dep resolution lets us run many namespaces in parallel
225
+ // without ts-morph touching files outside this folder.
65
226
  const project = new ts_morph_1.Project({
66
- tsConfigFilePath: path_1.default.join(moduleFolder, "tsconfig.json"), // Optional but recommended
227
+ skipAddingFilesFromTsConfig: true,
228
+ skipFileDependencyResolution: true,
229
+ skipLoadingLibFiles: true,
67
230
  });
68
- const sourceFolder = path_1.default.join(moduleFolder, "source");
69
- const dirFiles = await fs_1.default.promises.readdir(sourceFolder);
70
- for (let f of dirFiles) {
71
- console.log("processing file: ", f);
72
- const fullPath = path_1.default.join(sourceFolder, f);
231
+ const dirFiles = await node_fs_1.default.promises.readdir(sourceFolder);
232
+ for (const f of dirFiles) {
233
+ const fullPath = node_path_1.default.join(sourceFolder, f);
234
+ project.addSourceFileAtPath(fullPath);
235
+ }
236
+ for (const f of dirFiles) {
237
+ const fullPath = node_path_1.default.join(sourceFolder, f);
73
238
  const sourceFile = project.getSourceFileOrThrow(fullPath);
74
239
  fixFile(sourceFile);
75
240
  }
@@ -1 +1 @@
1
- {"version":3,"file":"remove_unused.js","sourceRoot":"","sources":["../source/remove_unused.ts"],"names":[],"mappings":";;;;;AA8DA,0DAiBC;AA/ED,uCAA2D;AAC3D,4CAAoB;AACpB,gDAAwB;AAExB,MAAM,MAAM,GAAG,KAAK,CAAC;AACrB,SAAS,OAAO,CAAC,IAAgB;IAC7B,wBAAwB;IACxB,IAAI,CAAC,qBAAqB,EAAE,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;QAChD,MAAM,YAAY,GAAG,UAAU,CAAC,eAAe,EAAE,CAAC;QAClD,MAAM,gBAAgB,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,EAAE;YACzD,MAAM,IAAI,GAAG,WAAW,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,CAAC;YACjD,OAAO,IAAI,CAAC,oBAAoB,CAAC,qBAAU,CAAC,UAAU,CAAC;iBAClD,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,KAAK,IAAI,IAAI,EAAE,KAAK,WAAW,CAAC,WAAW,EAAE,CAAC,CAAC;QAC/E,CAAC,CAAC,CAAC;QAEH,wCAAwC;QACxC,IAAI,gBAAgB,CAAC,MAAM,KAAK,CAAC,EA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AC;IAEH,MAAM,QAAQ,GAAG,MAAM,iBAAE,CAAC,QAAQ,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;IAEzD,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACvB,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;QAC5C,OAAO,CAAC,mBAAmB,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;IAED,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;QACvB,MAAM,QAAQ,GAAG,mBAAI,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;QAC5C,MAAM,UAAU,GAAG,OAAO,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC;QAC1D,OAAO,CAAC,UAAU,CAAC,CAAC;IACxB,CAAC;AACL,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-opcua-convert-nodeset-to-javascript",
3
- "version": "2.169.0",
3
+ "version": "2.172.0",
4
4
  "description": "pure nodejs OPCUA SDK - module convert-nodeset-to-javascript",
5
5
  "types": "dist/index.d.ts",
6
6
  "main": "dist/index.js",
@@ -16,26 +16,26 @@
16
16
  "dependencies": {
17
17
  "case-anything": "1.1.5",
18
18
  "chalk": "4.1.2",
19
- "node-opcua-address-space": "2.169.0",
20
- "node-opcua-address-space-base": "2.169.0",
19
+ "node-opcua-address-space": "2.172.0",
20
+ "node-opcua-address-space-base": "2.172.0",
21
21
  "node-opcua-assert": "2.164.0",
22
22
  "node-opcua-constants": "2.157.0",
23
- "node-opcua-data-model": "2.169.0",
24
- "node-opcua-debug": "2.168.0",
25
- "node-opcua-nodeid": "2.169.0",
23
+ "node-opcua-data-model": "2.172.0",
24
+ "node-opcua-debug": "2.172.0",
25
+ "node-opcua-nodeid": "2.172.0",
26
26
  "node-opcua-nodesets": "2.163.1",
27
- "node-opcua-pseudo-session": "2.169.0",
28
- "node-opcua-types": "2.169.0",
29
- "node-opcua-utils": "2.169.0",
30
- "node-opcua-variant": "2.169.0",
27
+ "node-opcua-pseudo-session": "2.172.0",
28
+ "node-opcua-types": "2.172.0",
29
+ "node-opcua-utils": "2.172.0",
30
+ "node-opcua-variant": "2.172.0",
31
31
  "ts-morph": "28.0.0",
32
32
  "typescript": "5.9.3",
33
33
  "wordwrap": "^1.0.0"
34
34
  },
35
35
  "devDependencies": {
36
- "node-opcua-leak-detector": "2.169.0",
37
- "node-opcua-packet-analyzer": "2.169.0",
38
- "node-opcua-service-translate-browse-path": "2.169.0"
36
+ "node-opcua-leak-detector": "2.172.0",
37
+ "node-opcua-packet-analyzer": "2.172.0",
38
+ "node-opcua-service-translate-browse-path": "2.172.0"
39
39
  },
40
40
  "author": "Etienne Rossignon",
41
41
  "license": "MIT",
@@ -52,7 +52,7 @@
52
52
  "internet of things"
53
53
  ],
54
54
  "homepage": "http://node-opcua.github.io/",
55
- "gitHead": "82d570d3e95bea689cbbe30096279885c5282245",
55
+ "gitHead": "dfe9993a93b5c3897825e898b5f07b25952c7f45",
56
56
  "files": [
57
57
  "dist",
58
58
  "source"
@@ -9,6 +9,25 @@ import { convertTypeToTypescript } from "./convert_to_typescript";
9
9
  import { constructCache } from "./private/cache";
10
10
  import { Options } from "./options";
11
11
 
12
+ // Robust write: on Windows, transient locks from antivirus, OneDrive, or the
13
+ // TS language server (when files are open in an IDE) surface as ERROR_SHARING_VIOLATION
14
+ // (errno -4094 / code UNKNOWN/EBUSY/EPERM). Retry with backoff.
15
+ function writeFileSyncRetry(filePath: string, content: string, attempts = 6): void {
16
+ for (let i = 0; i < attempts; i++) {
17
+ try {
18
+ fs.writeFileSync(filePath, content);
19
+ return;
20
+ } catch (err) {
21
+ const code = (err as NodeJS.ErrnoException).code;
22
+ const transient = code === "UNKNOWN" || code === "EBUSY" || code === "EPERM";
23
+ if (!transient || i === attempts - 1) throw err;
24
+ // Synchronous backoff (tight loop is fine for ~ms-scale retries).
25
+ const until = Date.now() + 50 * (i + 1);
26
+ while (Date.now() < until) { /* spin */ }
27
+ }
28
+ }
29
+ }
30
+
12
31
  function getPackageFolder(dependency: string, options: Options) {
13
32
  const l = [...(options.lookupFolders || [])];
14
33
  l.push(path.join(__dirname, "../../"));
@@ -98,7 +117,7 @@ export async function convertNamespaceTypeToTypescript(
98
117
  if (!fs.existsSync(sourceFolder)) {
99
118
  fs.mkdirSync(sourceFolder);
100
119
  }
101
- fs.writeFileSync(path.join(sourceFolder, filename + ".ts"), content);
120
+ writeFileSyncRetry(path.join(sourceFolder, filename + ".ts"), content);
102
121
  infos[module] = infos[module] || { folder, dependencies: [], module, files: [] };
103
122
  infos[module].files.push(filename + ".ts");
104
123
  infos[module].dependencies = [...new Set([...infos[module].dependencies, ...dependencies])];
@@ -261,10 +280,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
261
280
 
262
281
 
263
282
 
264
- }
265
- import { cleanUpTypescriptModule } from "./remove_unused";
266
- function _tidyUpImports(folder: string) {
267
- cleanUpTypescriptModule(folder);
268
283
  }
269
284
  async function outputFiles(infos: { [key: string]: Info }, options: Options) {
270
285
  const values = Object.values(infos) as Info[];
@@ -273,16 +288,12 @@ async function outputFiles(infos: { [key: string]: Info }, options: Options) {
273
288
  }
274
289
  console.log("generating files for ", options.nsName);
275
290
  for (const info of values) {
276
- // create indexes
277
291
  await _output_index_ts_file(info);
278
-
279
292
  await _output_package_json(info, options);
280
-
281
293
  await _output_tsconfig_json(info, options);
282
-
283
294
  await _output_licence(info, options);
284
-
285
-
286
- await _tidyUpImports(info.folder);
287
295
  }
296
+ // Import cleanup is deferred to a second, parallel phase in main.ts —
297
+ // each namespace's cleanup uses an isolated ts-morph Project, so the
298
+ // expensive AST work can run across many cores without contention.
288
299
  }
package/source/main.ts CHANGED
@@ -1,9 +1,26 @@
1
- import path from "path";
1
+ import fs from "node:fs";
2
+ import os from "node:os";
3
+ import path from "node:path";
4
+
2
5
  import { AddressSpace, PseudoSession } from "node-opcua-address-space";
3
6
  import { generateAddressSpace } from "node-opcua-address-space/nodeJS";
4
7
  import { constructNodesetFilename, nodesetCatalog } from "node-opcua-nodesets";
8
+
5
9
  import { convertNamespaceTypeToTypescript } from "./convert_namespace_to_typescript";
6
- import { updateParentTSConfig } from './update_parent_tsconfig';
10
+ import { cleanUpTypescriptModule } from "./remove_unused";
11
+ import { updateParentTSConfig } from "./update_parent_tsconfig";
12
+
13
+ async function runWithConcurrency<T>(items: T[], limit: number, fn: (item: T) => Promise<void>): Promise<void> {
14
+ let cursor = 0;
15
+ const workers = Array.from({ length: limit }, async () => {
16
+ while (true) {
17
+ const idx = cursor++;
18
+ if (idx >= items.length) return;
19
+ await fn(items[idx]);
20
+ }
21
+ });
22
+ await Promise.all(workers);
23
+ }
7
24
 
8
25
  async function main() {
9
26
  const addressSpace = AddressSpace.create();
@@ -18,18 +35,35 @@ async function main() {
18
35
  };
19
36
  // const nodesetCatalog2 = nodesetCatalog.filter((meta) => meta.name == "scales");
20
37
 
21
- await Promise.all(nodesetCatalog.map((meta) => {
38
+ // Phase 1: convert each namespace sequentially.
39
+ // The convert step writes type files into whichever package the type
40
+ // *originates* in, not the namespace being processed. Two namespaces
41
+ // running in parallel will both try to write e.g. node-opcua-nodeset-ua
42
+ // files concurrently, causing Windows ERROR_SHARING_VIOLATION.
43
+ for (const meta of nodesetCatalog) {
22
44
  const index = addressSpace.getNamespaceIndex(meta.uri);
23
45
  if (index === -1) {
24
46
  console.log("namespace not found", meta.uri);
25
- return;
47
+ continue;
26
48
  }
27
- return convertNamespaceTypeToTypescript(session, index, {
49
+ await convertNamespaceTypeToTypescript(session, index, {
28
50
  ...options,
29
51
  nsName: meta.name,
30
- })
52
+ });
31
53
  }
32
- ));
54
+
55
+ // Phase 2: clean up imports in every nodeset package that actually has a
56
+ // source/ folder on disk. This covers cases where a catalog entry name
57
+ // doesn't line up with its package folder (e.g. catalog "standard" writes
58
+ // into node-opcua-nodeset-ua).
59
+ const folders = fs.readdirSync(options.baseFolder)
60
+ .filter((name) => name.startsWith(options.prefix))
61
+ .map((name) => path.join(options.baseFolder, name))
62
+ .filter((p) => fs.existsSync(path.join(p, "source")));
63
+
64
+ const concurrency = Math.max(2, Math.min(os.cpus().length, 12));
65
+ console.log(`tidying imports across ${folders.length} packages with concurrency=${concurrency}`);
66
+ await runWithConcurrency(folders, concurrency, cleanUpTypescriptModule);
33
67
  await updateParentTSConfig();
34
68
  }
35
69
  void main();
@@ -1,80 +1,248 @@
1
- import { Project, SourceFile, SyntaxKind } from "ts-morph";
2
- import fs from "fs";
3
- import path from "path";
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+
4
+ import type { ImportDeclarationStructure, OptionalKind, SourceFile } from "ts-morph";
5
+ import { Node, Project, SyntaxKind } from "ts-morph";
4
6
 
5
7
  const dryRun = false;
6
- function fixFile(file: SourceFile) {
7
- // Remove unused imports
8
+
9
+ const NODE_BUILTINS = new Set([
10
+ "assert", "async_hooks", "buffer", "child_process", "cluster", "console",
11
+ "crypto", "dgram", "dns", "events", "fs", "http", "http2", "https", "net",
12
+ "os", "path", "perf_hooks", "process", "querystring", "readline", "stream",
13
+ "string_decoder", "tls", "tty", "url", "util", "v8", "vm", "worker_threads",
14
+ "zlib",
15
+ ]);
16
+
17
+ function importGroup(spec: string): number {
18
+ if (spec.startsWith("node:") || NODE_BUILTINS.has(spec)) return 0;
19
+ if (spec.startsWith(".")) return 3;
20
+ if (spec.startsWith("node-opcua")) return 2;
21
+ return 1;
22
+ }
23
+
24
+ function applyTypeOnlyImports(file: SourceFile) {
25
+ // Pass 1: collect identifier names used in value (runtime) positions.
26
+ // Anything whose name appears only in TypeNode positions is type-only.
27
+ const valueNames = new Set<string>();
28
+ file.forEachDescendant((node) => {
29
+ if (node.getKind() !== SyntaxKind.Identifier) return;
30
+ const parent = node.getParent();
31
+ if (!parent) return;
32
+ // Declaration sites are not usages.
33
+ if (Node.isImportSpecifier(parent)) return;
34
+ if (Node.isImportClause(parent)) return;
35
+ if (Node.isNamespaceImport(parent)) return;
36
+
37
+ // Walk past QualifiedName chains: in dotted type references like
38
+ // `UAProperty<UInt32, DataType.UInt32>` both `DataType` and the inner
39
+ // `UInt32` have a QualifiedName as their immediate parent, but the
40
+ // surrounding context is a TypeReference (a TypeNode).
41
+ let ctx = parent;
42
+ while (Node.isQualifiedName(ctx)) {
43
+ const p = ctx.getParent();
44
+ if (!p) break;
45
+ ctx = p;
46
+ }
47
+
48
+ if (Node.isTypeNode(ctx)) return;
49
+
50
+ // `interface X extends Foo` — Foo's parent is ExpressionWithTypeArguments
51
+ // inside a HeritageClause inside an InterfaceDeclaration. Still type-only.
52
+ if (Node.isExpressionWithTypeArguments(ctx)) {
53
+ const heritage = ctx.getParent();
54
+ if (heritage && Node.isHeritageClause(heritage)) {
55
+ const decl = heritage.getParent();
56
+ if (decl && Node.isInterfaceDeclaration(decl)) return;
57
+ }
58
+ }
59
+
60
+ valueNames.add(node.getText());
61
+ });
62
+
63
+ // Pass 2: flip type-only on import specifiers, hoist when all qualify.
8
64
  file.getImportDeclarations().forEach((importDecl) => {
65
+ if (importDecl.isTypeOnly()) return;
9
66
  const namedImports = importDecl.getNamedImports();
10
- const usedNamedImports = namedImports.filter((namedImport) => {
11
- const name = namedImport.getNameNode().getText();
12
- return file.getDescendantsOfKind(SyntaxKind.Identifier)
13
- .some(id => id.getText() === name && id !== namedImport.getNameNode());
67
+ if (namedImports.length === 0) return;
68
+
69
+ const hasDefault = !!importDecl.getDefaultImport();
70
+ const hasNamespace = !!importDecl.getNamespaceImport();
71
+
72
+ const isTypeOnly = namedImports.map((spec) => {
73
+ if (spec.isTypeOnly()) return true;
74
+ const localName = spec.getAliasNode()?.getText() ?? spec.getNameNode().getText();
75
+ return !valueNames.has(localName);
14
76
  });
15
77
 
16
- // If none are used, remove whole import
17
- if (usedNamedImports.length === 0) {
18
- console.log("removing wholee import", importDecl.getText());
19
- importDecl.remove();
20
- } else if (usedNamedImports.length < namedImports.length) {
21
- // Remove only unused named imports
22
- namedImports.forEach(named => {
23
- if (!usedNamedImports.includes(named)) {
24
- console.log("removing name in import ", named.getText());
25
- named.remove();
78
+ const allTypeOnly = isTypeOnly.every(Boolean);
79
+
80
+ if (allTypeOnly && !hasDefault && !hasNamespace) {
81
+ // Hoist to `import type { ... }`; clear redundant per-specifier `type` keywords.
82
+ importDecl.setIsTypeOnly(true);
83
+ namedImports.forEach((spec) => {
84
+ if (spec.isTypeOnly()) spec.setIsTypeOnly(false);
85
+ });
86
+ } else {
87
+ namedImports.forEach((spec, i) => {
88
+ if (isTypeOnly[i] && !spec.isTypeOnly()) {
89
+ spec.setIsTypeOnly(true);
26
90
  }
27
91
  });
28
92
  }
29
93
  });
94
+ }
30
95
 
31
- // Remove unused local variables (function-scope or top-level)
32
- file.getVariableStatements().forEach(variableStatement => {
33
- variableStatement.getDeclarations().forEach(declaration => {
34
- const name = declaration.getName();
35
- const references = declaration.findReferences();
36
- const isUsed = references.some(ref => {
37
- return ref.getReferences().some(r => !r.isDefinition());
38
- });
96
+ function regroupImports(file: SourceFile) {
97
+ const imports = file.getImportDeclarations();
98
+ if (imports.length === 0) return;
99
+
100
+ const structures: OptionalKind<ImportDeclarationStructure>[] = imports.map((d) => d.getStructure());
101
+
102
+ for (const d of [...imports].reverse()) d.remove();
103
+
104
+ structures.sort((a, b) => {
105
+ const ga = importGroup(a.moduleSpecifier);
106
+ const gb = importGroup(b.moduleSpecifier);
107
+ if (ga !== gb) return ga - gb;
108
+ return a.moduleSpecifier.localeCompare(b.moduleSpecifier);
109
+ });
110
+
111
+ file.insertImportDeclarations(0, structures);
112
+
113
+ const reinserted = file.getImportDeclarations();
114
+ for (let i = 1; i < reinserted.length; i++) {
115
+ const prevG = importGroup(reinserted[i - 1].getModuleSpecifierValue());
116
+ const currG = importGroup(reinserted[i].getModuleSpecifierValue());
117
+ if (prevG !== currG) {
118
+ reinserted[i].prependWhitespace("\n");
119
+ }
120
+ }
121
+ }
39
122
 
40
- if (!isUsed) {
41
- console.log("removing unused variable=", name );
123
+ const BIOME_IGNORE_EMPTY_INTERFACE = "// biome-ignore lint/suspicious/noEmptyInterface: forward-compatible placeholder for OPC-UA generated types";
124
+
125
+ function tidyEmptyInterfaces(file: SourceFile) {
126
+ // Two complaints to resolve:
127
+ // 1. Formatter wants `interface X {}` on a single line, not `{\n}`.
128
+ // 2. suspicious/noEmptyInterface fires for `interface X {}` WITHOUT extends.
129
+ // For `interface X extends Y {}` the rule doesn't fire, so a directive
130
+ // there is reported as "unused".
131
+ //
132
+ // First pass (in reverse, since text only shrinks): collapse bodies.
133
+ // Then a snapshot+descending pass for the biome-ignore directives, which
134
+ // only target interfaces with no extends clause.
135
+ const ifaces = file.getInterfaces();
136
+ for (let i = ifaces.length - 1; i >= 0; i--) {
137
+ const iface = ifaces[i];
138
+ if (iface.getMembers().length !== 0) continue;
139
+ const text = iface.getText();
140
+ const collapsed = text.replace(/\{\s*\}\s*$/, "{}");
141
+ if (collapsed !== text) {
142
+ iface.replaceWithText(collapsed);
143
+ }
144
+ }
145
+
146
+ // Re-fetch (previous replaceWithText calls may have invalidated nodes),
147
+ // then snapshot positions before inserting comment lines.
148
+ const positions: number[] = [];
149
+ for (const iface of file.getInterfaces()) {
150
+ if (iface.getMembers().length !== 0) continue;
151
+ // Rule only fires when there's no extends clause.
152
+ if (iface.getExtends().length !== 0) continue;
153
+ const leading = iface.getLeadingCommentRanges().map((c) => c.getText()).join("\n");
154
+ if (leading.includes("biome-ignore lint/suspicious/noEmptyInterface")) continue;
155
+ positions.push(iface.getStart());
156
+ }
157
+ positions.sort((a, b) => b - a);
158
+ for (const pos of positions) {
159
+ file.insertText(pos, `${BIOME_IGNORE_EMPTY_INTERFACE}\n`);
160
+ }
161
+ }
162
+
163
+ function fixFile(file: SourceFile) {
164
+ // Sort alphabetically, dedupe, drop unused imports.
165
+ file.organizeImports();
166
+
167
+ // Mark type-only specifiers; hoist when the whole import qualifies.
168
+ applyTypeOnlyImports(file);
169
+
170
+ // Group: builtins → external → node-opcua-* → relative.
171
+ regroupImports(file);
172
+
173
+ // Collapse empty interface bodies to single-line `{}` and add a
174
+ // suppression directive for the ones the lint rule actually fires on.
175
+ tidyEmptyInterfaces(file);
176
+
177
+ // Remove unused local variables (function-scope or top-level).
178
+ // Use a single-pass identifier-name frequency map instead of ts-morph's
179
+ // findReferences(), which calls TS's reference finder per declaration —
180
+ // unreliable without dep resolution and 10–100× slower. For generated
181
+ // code (no fancy scoping), name count > 1 is a sufficient proxy for "used".
182
+ const identifierCounts = new Map<string, number>();
183
+ file.forEachDescendant((node) => {
184
+ if (node.getKind() === SyntaxKind.Identifier) {
185
+ const txt = node.getText();
186
+ identifierCounts.set(txt, (identifierCounts.get(txt) || 0) + 1);
187
+ }
188
+ });
189
+
190
+ file.getVariableStatements().forEach((variableStatement) => {
191
+ variableStatement.getDeclarations().forEach((declaration) => {
192
+ const name = declaration.getName();
193
+ const count = identifierCounts.get(name) ?? 0;
194
+ // Count includes the declaration's own name node; >1 means referenced elsewhere.
195
+ if (count <= 1) {
196
+ console.log("removing unused variable=", name);
42
197
  declaration.remove();
43
198
  }
44
199
  });
45
200
 
46
201
  try {
47
- // If no declarations left in this statement, remove the whole statement
48
202
  if (variableStatement.getDeclarations().length === 0) {
49
203
  console.log("removing variable statement:", variableStatement.getText());
50
204
  variableStatement.remove();
51
205
  }
52
206
  } catch (err) {
53
207
  console.log((err as Error).message);
54
-
55
208
  }
56
209
  });
57
210
 
58
- // Save changes
59
211
  if (!dryRun) {
60
212
  file.saveSync();
61
213
  }
62
214
  }
63
- export async function cleanUpTypescriptModule(moduleFolder: string) {
64
215
 
216
+ export async function cleanUpTypescriptModule(moduleFolder: string) {
217
+ const sourceFolder = path.join(moduleFolder, "source");
218
+ // Some namespaces in the catalog don't have a dedicated module folder
219
+ // (their types are written into a shared package like node-opcua-nodeset-ua).
220
+ // Nothing to tidy here — silently skip.
221
+ if (!fs.existsSync(sourceFolder)) {
222
+ return;
223
+ }
65
224
 
225
+ // Isolated project: only this module's own files, no tsconfig dependency
226
+ // resolution. The cleanup analysis is purely syntactic (organizeImports +
227
+ // type-position check via AST), so we don't need the full type checker —
228
+ // and skipping dep resolution lets us run many namespaces in parallel
229
+ // without ts-morph touching files outside this folder.
66
230
  const project = new Project({
67
- tsConfigFilePath: path.join(moduleFolder, "tsconfig.json"), // Optional but recommended
231
+ skipAddingFilesFromTsConfig: true,
232
+ skipFileDependencyResolution: true,
233
+ skipLoadingLibFiles: true,
68
234
  });
69
235
 
70
- const sourceFolder = path.join(moduleFolder, "source");
71
-
72
236
  const dirFiles = await fs.promises.readdir(sourceFolder);
73
- for (let f of dirFiles) {
74
- console.log("processing file: ", f);
237
+
238
+ for (const f of dirFiles) {
239
+ const fullPath = path.join(sourceFolder, f);
240
+ project.addSourceFileAtPath(fullPath);
241
+ }
242
+
243
+ for (const f of dirFiles) {
75
244
  const fullPath = path.join(sourceFolder, f);
76
245
  const sourceFile = project.getSourceFileOrThrow(fullPath);
77
246
  fixFile(sourceFile);
78
247
  }
79
-
80
- }
248
+ }