jsii 5.8.23-dev.8 → 5.8.25-dev.10

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.
@@ -204,6 +204,10 @@ export declare class Assembler implements Emitter {
204
204
  * not output position
205
205
  */
206
206
  private validateTypesAgainstPositions;
207
+ /**
208
+ * Make sure that no 2 submodules are emitting into the same target namespaces
209
+ */
210
+ private validateSubmoduleConfigs;
207
211
  }
208
212
  export interface AssemblerOptions {
209
213
  /**
package/lib/assembler.js CHANGED
@@ -18,6 +18,7 @@ const helpers_1 = require("./helpers");
18
18
  const jsii_diagnostic_1 = require("./jsii-diagnostic");
19
19
  const literate = require("./literate");
20
20
  const bindings = require("./node-bindings");
21
+ const project_info_1 = require("./project-info");
21
22
  const reserved_words_1 = require("./reserved-words");
22
23
  const sets_1 = require("./sets");
23
24
  const deprecated_remover_1 = require("./transforms/deprecated-remover");
@@ -140,6 +141,7 @@ class Assembler {
140
141
  }
141
142
  this.callDeferredsInOrder();
142
143
  this.validateTypesAgainstPositions();
144
+ this.validateSubmoduleConfigs();
143
145
  // Skip emitting if any diagnostic message is an error
144
146
  if (this._diagnostics.find((diag) => diag.category === ts.DiagnosticCategory.Error) != null) {
145
147
  LOG.debug('Skipping emit due to errors.');
@@ -555,12 +557,20 @@ class Assembler {
555
557
  };
556
558
  }
557
559
  function loadSubmoduleTargetConfig(submoduleMain) {
558
- const jsiirc = path.resolve(submoduleMain, '..', '.jsiirc.json');
559
- if (!fs.existsSync(jsiirc)) {
560
+ const dirname = path.dirname(submoduleMain);
561
+ const basenameWithoutExtension = path.basename(submoduleMain).replace(/\.ts$/, '');
562
+ let jsiirc;
563
+ if (basenameWithoutExtension === 'index') {
564
+ jsiirc = path.resolve(submoduleMain, '..', '.jsiirc.json');
565
+ }
566
+ else {
567
+ jsiirc = path.resolve(dirname, `.${basenameWithoutExtension}.jsiirc.json`);
568
+ }
569
+ if (!jsiirc || !fs.existsSync(jsiirc)) {
560
570
  return undefined;
561
571
  }
562
572
  const data = JSON.parse(fs.readFileSync(jsiirc, 'utf-8'));
563
- return data.targets;
573
+ return (0, project_info_1.validateTargets)(data.targets);
564
574
  }
565
575
  /**
566
576
  * Load the README for the given submodule
@@ -2029,6 +2039,48 @@ class Assembler {
2029
2039
  });
2030
2040
  }
2031
2041
  }
2042
+ /**
2043
+ * Make sure that no 2 submodules are emitting into the same target namespaces
2044
+ */
2045
+ validateSubmoduleConfigs() {
2046
+ const self = this;
2047
+ const dotNetnamespaces = {};
2048
+ const javaPackages = {};
2049
+ const pythonModules = {};
2050
+ const goPackages = {};
2051
+ for (const submodule of this._submodules.values()) {
2052
+ const targets = submodule.targets;
2053
+ if (targets?.dotnet?.namespace) {
2054
+ accumList(dotNetnamespaces, targets.dotnet.namespace, submodule.fqn);
2055
+ }
2056
+ if (targets?.java?.package) {
2057
+ accumList(javaPackages, targets.java.package, submodule.fqn);
2058
+ }
2059
+ if (targets?.python?.module) {
2060
+ accumList(pythonModules, targets.python.module, submodule.fqn);
2061
+ }
2062
+ if (targets?.go?.packageName) {
2063
+ accumList(goPackages, targets.go.packageName, submodule.fqn);
2064
+ }
2065
+ }
2066
+ maybeError('dotnet', dotNetnamespaces);
2067
+ maybeError('java', javaPackages);
2068
+ maybeError('python', pythonModules);
2069
+ maybeError('go', goPackages);
2070
+ function accumList(set, key, value) {
2071
+ if (!set[key]) {
2072
+ set[key] = [];
2073
+ }
2074
+ set[key].push(value);
2075
+ }
2076
+ function maybeError(language, set) {
2077
+ for (const [namespace, modules] of Object.entries(set)) {
2078
+ if (modules.length > 1) {
2079
+ self._diagnostics.push(jsii_diagnostic_1.JsiiDiagnostic.JSII_4010_SUBMODULE_NAMESPACE_CONFLICT.create(undefined, language, namespace, modules));
2080
+ }
2081
+ }
2082
+ }
2083
+ }
2032
2084
  }
2033
2085
  exports.Assembler = Assembler;
2034
2086
  function _fingerprint(assembly) {