Skip to content

Commit

Permalink
chore(release): 1.49.0
Browse files Browse the repository at this point in the history
  • Loading branch information
rix0rrr authored Dec 14, 2021
2 parents 05dd13a + 546501c commit e322d87
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 11 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,19 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

## [1.49.0](https://github.com/aws/jsii/compare/v1.48.0...v1.49.0) (2021-12-14)


### Bug Fixes

* improve compatibility with restricted-export modules ([#3205](https://github.com/aws/jsii/issues/3205)) ([31a7172](https://github.com/aws/jsii/commit/31a71721bfaff28876ce0554230e63803591e112))
* **jsii:** correctly identify types regardless of import method ([#3233](https://github.com/aws/jsii/issues/3233)) ([aa37d62](https://github.com/aws/jsii/commit/aa37d623f866d2b2a3802a90578e8e85227b37b1)), closes [aws/aws-cdk#17860](https://github.com/aws/aws-cdk/issues/17860)
* **jsii:** handle imports from libraries compiled with old jsii ([#3245](https://github.com/aws/jsii/issues/3245)) ([133d1cf](https://github.com/aws/jsii/commit/133d1cf371367b1516b175aa9ed904eb701fac0f)), closes [#3233](https://github.com/aws/jsii/issues/3233) [#3233](https://github.com/aws/jsii/issues/3233)
* **jsii:** symbolid for single-valued enums is incorrect ([#3234](https://github.com/aws/jsii/issues/3234)) ([83d3fc8](https://github.com/aws/jsii/commit/83d3fc805874a72b7a76d08f62e8b10121b4777b))
* **rosetta:** `rosetta extract` fails if run after `rosetta infuse` ([#3248](https://github.com/aws/jsii/issues/3248)) ([e3ec929](https://github.com/aws/jsii/commit/e3ec92921c10bf397e740d45ad7c5a39a21dc800))
* **rosetta:** classes are not correctly identified if package uses an outDir ([#3225](https://github.com/aws/jsii/issues/3225)) ([05631a7](https://github.com/aws/jsii/commit/05631a723b8c08d8d82e9ec50c6adaee1e2d693e))
* **rosetta:** infuse drops first assembly ([#3243](https://github.com/aws/jsii/issues/3243)) ([29a6a84](https://github.com/aws/jsii/commit/29a6a848e2cada2a695d0d1a852c6c53c24d35ac))

## [1.48.0](https://github.com/aws/jsii/compare/v1.45.0...v1.48.0) (2021-12-13)


Expand All @@ -28,6 +41,7 @@ All notable changes to this project will be documented in this file. See [standa
* **rosetta:** infuse drops first assembly ([#3243](https://github.com/aws/jsii/issues/3243)) ([29a6a84](https://github.com/aws/jsii/commit/29a6a848e2cada2a695d0d1a852c6c53c24d35ac))
* **rosetta:** use `--compile` flag by default ([#3218](https://github.com/aws/jsii/issues/3218)) ([9df7950](https://github.com/aws/jsii/commit/9df7950f263aae045877accb45007e0f9a5b03bd))


## [1.47.0](https://github.com/aws/jsii/compare/v1.45.0...v1.47.0) (2021-12-06)


Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"rejectCycles": true
}
},
"version": "1.48.0"
"version": "1.49.0"
}
15 changes: 9 additions & 6 deletions packages/jsii-rosetta/lib/commands/infuse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { renderMetadataline, TypeScriptSnippet } from '../snippet';
import { SnippetSelector, mean, meanLength, shortest, longest } from '../snippet-selectors';
import { snippetKey } from '../tablets/key';
import { LanguageTablet, TranslatedSnippet, DEFAULT_TABLET_NAME } from '../tablets/tablets';
import { isDefined, mkDict, fmap, indexBy } from '../util';
import { isDefined, mkDict, indexBy } from '../util';

export interface InfuseResult {
readonly coverageResults: Record<string, InfuseTypes>;
Expand Down Expand Up @@ -207,17 +207,20 @@ function insertExample(
type: spec.Type,
tablets: LanguageTablet[],
): void {
const exampleMetadata = fmap(original?.parameters, renderMetadataline);
const parameters = {
...original?.parameters,
infused: '',
};
// exampleMetadata should always be nonempty since we always have a parameter.
const exampleMetadata = renderMetadataline(parameters) ?? '';

if (type.docs) {
type.docs.example = example.originalSource.source;
if (exampleMetadata) {
type.docs.custom = { ...type.docs.custom, exampleMetadata };
}
type.docs.custom = { ...type.docs.custom, exampleMetadata };
} else {
type.docs = {
example: example.originalSource.source,
custom: fmap(exampleMetadata, (exampleMetadata) => ({ exampleMetadata })),
custom: { exampleMetadata },
};
}

Expand Down
8 changes: 6 additions & 2 deletions packages/jsii-rosetta/lib/jsii/assemblies.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,16 @@ export function allTypeScriptSnippets(assemblies: readonly LoadedAssembly[], loo
for (const source of allSnippetSources(assembly)) {
switch (source.type) {
case 'example':
// If an example is an infused example, we do not care about compiler errors.
// We are relying on the tablet cache to have this example stored already.
const [strictForExample, looseForExample] =
source.metadata?.infused !== undefined ? [false, true] : [strict, loose];
const location = { api: source.location, field: { field: 'example' } } as const;
const snippet = updateParameters(typeScriptSnippetFromSource(source.source, location, strict), {
const snippet = updateParameters(typeScriptSnippetFromSource(source.source, location, strictForExample), {
[SnippetParameters.$PROJECT_DIRECTORY]: directory,
...source.metadata,
});
ret.push(fixturize(snippet, loose));
ret.push(fixturize(snippet, looseForExample));
break;
case 'markdown':
for (const snippet of extractTypescriptSnippetsFromMarkdown(source.markdown, source.location, strict)) {
Expand Down
52 changes: 52 additions & 0 deletions packages/jsii-rosetta/test/commands/extract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,58 @@ test('extract and infuse in one command', async () => {
expect(types!['my_assembly.ClassA'].docs?.example).toBeDefined();
});

test('infused examples skip loose mode', async () => {
const otherAssembly = await TestJsiiModule.fromSource(
{
'index.ts': `
/**
* ClassA
*
* @exampleMetadata lit=integ.test.ts
* @example x
*/
export class ClassA {
public someMethod() {
}
}
`,
},
{
name: 'my_assembly',
jsii: DUMMY_JSII_CONFIG,
},
);
try {
const cacheToFile = path.join(otherAssembly.moduleDirectory, 'test.tabl.json');

// Without exampleMetadata infused=true, expect an error
await expect(
extract.extractSnippets([otherAssembly.moduleDirectory], {
cacheToFile,
...defaultExtractOptions,
}),
).rejects.toThrowError(/Sample uses literate source/);

// Add infused=true to metadata and update assembly
otherAssembly.assembly.types!['my_assembly.ClassA'].docs!.custom!.exampleMetadata =
'lit=integ.test.ts infused=true';
await otherAssembly.updateAssembly();

// Expect same function call to succeed now
await extract.extractSnippets([otherAssembly.moduleDirectory], {
cacheToFile,
...defaultExtractOptions,
});

const tablet = await LanguageTablet.fromFile(cacheToFile);
expect(tablet.count).toEqual(1);
const tr = tablet.tryGetSnippet(tablet.snippetKeys[0]);
expect(tr?.originalSource.source).toEqual('x');
} finally {
await otherAssembly.cleanup();
}
});

class MockTranslator extends RosettaTranslator {
public constructor(opts: RosettaTranslatorOptions, translatorFn: jest.Mock) {
super(opts);
Expand Down
2 changes: 1 addition & 1 deletion packages/jsii-rosetta/test/commands/infuse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ test('infuse copies example metadata', async () => {
const updatedAssembly = (await fs.readJson(path.join(assembly.moduleDirectory, '.jsii'))) as spec.Assembly;

const typeDocs = updatedAssembly.types?.['my_assembly.ClassA']?.docs;
expect(typeDocs?.custom?.exampleMetadata).toEqual('some=metadata');
expect(typeDocs?.custom?.exampleMetadata).toEqual('some=metadata infused');
});

test('examples are added to the tablet under new keys', async () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/jsii/test/deprecation-warnings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ function testpkg_Baz(p) {
// Recompiling without deprecation warning to leave the packages in a clean state
await compile(calcBaseRoot, false);
await compile(calcLibRoot, false);
}, 30000);
}, 50000);
});

describe('Call injections', () => {
Expand Down

0 comments on commit e322d87

Please sign in to comment.