Skip to content

Commit

Permalink
fix: Assembly not found on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgrain committed Apr 28, 2024
1 parent f215392 commit 742dfc4
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 5 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/build.yml

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

5 changes: 5 additions & 0 deletions .projenrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ const project = new CdklabsTypeScriptProject({
jestOptions: {
jestConfig: {
setupFilesAfterEnv: ['<rootDir>/test/setup-jest.ts'],
testMatch: [
// On Windows the standard tests paths are not matched
// Use this simplified version instead that works good enough in this repo
'<rootDir>/test/**/*.test.ts',
],
},
},
tsconfig: {
Expand Down
1 change: 1 addition & 0 deletions package.json

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

17 changes: 15 additions & 2 deletions projenrc/rosetta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@ export class RosettaPeerDependency extends Component {
super(project);

const constraint = this.calculateVersionConstraint(options.supportedVersions);
const minVersions = this.calculateMinimalVersions(options.supportedVersions);
const latestVersion = this.calculateLatestVersion(options.supportedVersions);

project.addDevDeps(constraint);
project.addPeerDeps(constraint);

project.github?.tryFindWorkflow('build')?.addJob('rosetta-compat', {
runsOn: ['ubuntu-latest'],
runsOn: ['${{ matrix.os }}'],
permissions: {},
env: {
CI: 'true',
Expand All @@ -38,8 +41,13 @@ export class RosettaPeerDependency extends Component {
strategy: {
matrix: {
domain: {
rosetta: this.calculateMinimalVersions(options.supportedVersions),
rosetta: minVersions,
os: ['ubuntu-latest'],
},
include: [{
rosetta: latestVersion,
os: 'windows-latest',
}],
},
},
steps: [{
Expand Down Expand Up @@ -95,4 +103,9 @@ export class RosettaPeerDependency extends Component {

return discoveredVersions;
}

private calculateLatestVersion(versions: RosettaPeerDependencyOptions['supportedVersions']): string {
const discoveredVersions = this.calculateMinimalVersions(versions);
return discoveredVersions.sort().pop() ?? 'latest';
}
}
2 changes: 1 addition & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function main() {
.option('readme', { alias: 'r', type: 'boolean', required: false, desc: 'Include the user defined README.md in the documentation.' })
.option('submodule', { alias: 's', type: 'string', required: false, desc: 'Generate docs for a specific submodule (or "root")' })
.option('split-by-submodule', { type: 'boolean', required: false, desc: 'Generate a separate file for each submodule' })
.example('$0', 'Generate documentation for the current module as a single file (auto-resolves node depedencies)')
.example('$0', 'Generate documentation for the current module as a single file (auto-resolves node dependencies)')
.argv;

const submodule = args.submodule === 'root' ? undefined : args.submodule;
Expand Down
11 changes: 10 additions & 1 deletion src/docgen/view/documentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ export class Documentation {
});

const ts = new reflect.TypeSystem();
for (let dotJsii of await glob.promise(`${this.assembliesDir}/**/${SPEC_FILE_NAME}`)) {
const searchPattern = normalizePathForGlob(this.assembliesDir) + `/**/${SPEC_FILE_NAME}`;
for (let dotJsii of await glob.promise(searchPattern)) {
// we only transliterate the top level assembly and not the entire type-system.
// note that the only reason to translate dependant assemblies is to show code examples
// for expanded python arguments - which we don't to right now anyway.
Expand Down Expand Up @@ -556,3 +557,11 @@ function maybeCorruptedAssemblyError(error: Error): CorruptedAssemblyError | und
}
return;
}

/**
* glob needs the pattern to only use forward slashes.
* So we split the path based on the current platforms separator and re-join using /.
*/
function normalizePathForGlob(pattern: string): string {
return path.normalize(pattern).split(path.sep).join(path.posix.sep);
}

0 comments on commit 742dfc4

Please sign in to comment.