Skip to content

Commit

Permalink
fix(go): invalid major version suffix for submodules and jsii init
Browse files Browse the repository at this point in the history
The major version suffix introduced in #2507 was added at the end of the full module name, but for submodules, the suffix is needed only after the root package name.

Additionally, the `_init_` import failed to include the major version suffix as well.

In order to cover these cases in tests, change the version of `jsii-calc` to `3.20.1` so that it will be a MV larger then 2.0.

Fixes #2507
  • Loading branch information
Elad Ben-Israel committed Feb 3, 2021
1 parent 9e639b2 commit 131eaac
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 39 deletions.
2 changes: 1 addition & 1 deletion packages/jsii-calc/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jsii-calc",
"version": "0.0.0",
"version": "3.20.120",
"private": true,
"description": "A simple calcuator built on JSII.",
"stability": "stable",
Expand Down
6 changes: 3 additions & 3 deletions packages/jsii-pacmak/lib/targets/go/package.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ export abstract class Package {
const moduleName = this.root.moduleName;
const prefix = moduleName !== '' ? `${moduleName}/` : '';
const rootPackageName = this.root.packageName;
const suffix = this.filePath !== '' ? `/${this.filePath}` : ``;
const versionSuffix = determineMajorVersionSuffix(this.version);
return `${prefix}${rootPackageName}${suffix}${versionSuffix}`;
const suffix = this.filePath !== '' ? `/${this.filePath}` : ``;
return `${prefix}${rootPackageName}${versionSuffix}${suffix}`;
}

/*
Expand Down Expand Up @@ -150,7 +150,7 @@ export abstract class Package {

if (this.usesInitPackage) {
code.line(
`${JSII_INIT_ALIAS} "${this.root.moduleName}/${this.root.packageName}/${JSII_INIT_PACKAGE}"`,
`${JSII_INIT_ALIAS} "${this.root.goModuleName}/${JSII_INIT_PACKAGE}"`,
);
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion scripts/align-version.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,16 @@ const fs = require('fs');

const marker = require('./get-version-marker');
const repoVersion = require('./get-version');
const exclude = [
'@fixtures/jsii-calc-bundled',
'jsii-calc', // tests major version >2 for go
];

for (const file of process.argv.splice(2)) {
const pkg = JSON.parse(fs.readFileSync(file).toString());

// Ignore fixture packages
if (pkg.name === '@fixtures/jsii-calc-bundled') {
if (exclude.includes(pkg.name)) {
continue;
}

Expand Down

0 comments on commit 131eaac

Please sign in to comment.