Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
bc48f7e
Clean temp/sass-ts.
iclanton Jul 7, 2025
1dec3d0
Add an option to the typings generator to override the write function.
iclanton Jul 7, 2025
9a35045
Normalize the test schema filenames in node-core-library.
iclanton Jul 7, 2025
b5c585e
fixup! Normalize the test schema filenames in node-core-library.
iclanton Jul 7, 2025
f2cd0b6
fixup! Normalize the test schema filenames in node-core-library.
iclanton Jul 7, 2025
056e92f
Initial implementation of the json-schema-typings-plugin.
iclanton Jul 7, 2025
68d0d83
fixup! Initial implementation of the json-schema-typings-plugin.
iclanton Jul 7, 2025
5de5b40
Ensure path paramters don't contain backslashes.
iclanton Jul 7, 2025
62af941
fixup! Initial implementation of the json-schema-typings-plugin.
iclanton Jul 7, 2025
cbac99f
Rush update.
iclanton Jul 7, 2025
0a5fc4d
fixup! Initial implementation of the json-schema-typings-plugin.
iclanton Jul 8, 2025
521cc08
fixup! Rush update.
iclanton Jul 8, 2025
ff2a599
fixup! Initial implementation of the json-schema-typings-plugin.
iclanton Jul 8, 2025
c498ca7
fixup! Rush update.
iclanton Jul 8, 2025
5d14f5c
fixup! Initial implementation of the json-schema-typings-plugin.
iclanton Jul 8, 2025
967f96b
fixup! Rush update.
iclanton Jul 8, 2025
bc28620
fixup! Initial implementation of the json-schema-typings-plugin.
iclanton Jul 8, 2025
19aba59
fixup! Initial implementation of the json-schema-typings-plugin.
iclanton Jul 8, 2025
bf9d43f
Update repo readme.
iclanton Jul 8, 2025
f8fcf48
fixup! Initial implementation of the json-schema-typings-plugin.
iclanton Jul 8, 2025
0a7e95e
Revert "Ensure path paramters don't contain backslashes."
iclanton Jul 8, 2025
13597d5
Simplify the schema testing.
iclanton Jul 8, 2025
1ea0ae3
Don't include the eslint-disable header.
iclanton Jul 8, 2025
62aea76
Revert "Add an option to the typings generator to override the write …
iclanton Jul 8, 2025
ce5aa23
fixup! Revert "Add an option to the typings generator to override the…
iclanton Jul 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ These GitHub repositories provide supplementary resources for Rush Stack:
| [/heft-plugins/heft-dev-cert-plugin](./heft-plugins/heft-dev-cert-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fheft-dev-cert-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Fheft-dev-cert-plugin) | [changelog](./heft-plugins/heft-dev-cert-plugin/CHANGELOG.md) | [@rushstack/heft-dev-cert-plugin](https://www.npmjs.com/package/@rushstack/heft-dev-cert-plugin) |
| [/heft-plugins/heft-isolated-typescript-transpile-plugin](./heft-plugins/heft-isolated-typescript-transpile-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fheft-isolated-typescript-transpile-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Fheft-isolated-typescript-transpile-plugin) | [changelog](./heft-plugins/heft-isolated-typescript-transpile-plugin/CHANGELOG.md) | [@rushstack/heft-isolated-typescript-transpile-plugin](https://www.npmjs.com/package/@rushstack/heft-isolated-typescript-transpile-plugin) |
| [/heft-plugins/heft-jest-plugin](./heft-plugins/heft-jest-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fheft-jest-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Fheft-jest-plugin) | [changelog](./heft-plugins/heft-jest-plugin/CHANGELOG.md) | [@rushstack/heft-jest-plugin](https://www.npmjs.com/package/@rushstack/heft-jest-plugin) |
| [/heft-plugins/heft-json-schema-typings-plugin](./heft-plugins/heft-json-schema-typings-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fheft-json-schema-typings-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Fheft-json-schema-typings-plugin) | [changelog](./heft-plugins/heft-json-schema-typings-plugin/CHANGELOG.md) | [@rushstack/heft-json-schema-typings-plugin](https://www.npmjs.com/package/@rushstack/heft-json-schema-typings-plugin) |
| [/heft-plugins/heft-lint-plugin](./heft-plugins/heft-lint-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fheft-lint-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Fheft-lint-plugin) | [changelog](./heft-plugins/heft-lint-plugin/CHANGELOG.md) | [@rushstack/heft-lint-plugin](https://www.npmjs.com/package/@rushstack/heft-lint-plugin) |
| [/heft-plugins/heft-localization-typings-plugin](./heft-plugins/heft-localization-typings-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fheft-localization-typings-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Fheft-localization-typings-plugin) | [changelog](./heft-plugins/heft-localization-typings-plugin/CHANGELOG.md) | [@rushstack/heft-localization-typings-plugin](https://www.npmjs.com/package/@rushstack/heft-localization-typings-plugin) |
| [/heft-plugins/heft-sass-load-themed-styles-plugin](./heft-plugins/heft-sass-load-themed-styles-plugin/) | [![npm version](https://badge.fury.io/js/%40rushstack%2Fheft-sass-load-themed-styles-plugin.svg)](https://badge.fury.io/js/%40rushstack%2Fheft-sass-load-themed-styles-plugin) | [changelog](./heft-plugins/heft-sass-load-themed-styles-plugin/CHANGELOG.md) | [@rushstack/heft-sass-load-themed-styles-plugin](https://www.npmjs.com/package/@rushstack/heft-sass-load-themed-styles-plugin) |
Expand Down Expand Up @@ -175,6 +176,7 @@ These GitHub repositories provide supplementary resources for Rush Stack:
| [/build-tests/heft-fastify-test](./build-tests/heft-fastify-test/) | This project tests Heft support for the Fastify framework for Node.js services |
| [/build-tests/heft-jest-preset-test](./build-tests/heft-jest-preset-test/) | This project illustrates configuring a Jest preset in a minimal Heft project |
| [/build-tests/heft-jest-reporters-test](./build-tests/heft-jest-reporters-test/) | This project illustrates configuring Jest reporters in a minimal Heft project |
| [/build-tests/heft-json-schema-typings-plugin-test](./build-tests/heft-json-schema-typings-plugin-test/) | This project illustrates configuring Jest reporters in a minimal Heft project |
| [/build-tests/heft-minimal-rig-test](./build-tests/heft-minimal-rig-test/) | This is a minimal rig package that is imported by the 'heft-minimal-rig-usage-test' project |
| [/build-tests/heft-minimal-rig-usage-test](./build-tests/heft-minimal-rig-usage-test/) | A test project for Heft that resolves its compiler from the 'heft-minimal-rig-test' package |
| [/build-tests/heft-node-everything-esm-module-test](./build-tests/heft-node-everything-esm-module-test/) | Building this project tests every task and config file for Heft when targeting the Node.js runtime when configured to use ESM module support |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/heft/v0/heft.schema.json",

"extends": "local-node-rig/profiles/default/config/heft.json",

"phasesByName": {
"build": {
"cleanFiles": [{ "includeGlobs": ["temp/schema-dts"] }],

"tasksByName": {
"json-schema-typings": {
"taskPlugin": {
"pluginPackage": "@rushstack/heft-json-schema-typings-plugin",
"pluginName": "json-schema-typings-plugin",
"options": {
"srcFolder": "node_modules/@rushstack/node-core-library/src/test/test-data/test-schemas",
"generatedTsFolders": ["temp/schema-dts"]
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "local-node-rig/profiles/default/config/jest.config.json"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
// The "rig.json" file directs tools to look for their config files in an external package.
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",

"rigPackageName": "local-node-rig"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

const nodeTrustedToolProfile = require('local-node-rig/profiles/default/includes/eslint/flat/profile/node-trusted-tool');
const friendlyLocalsMixin = require('local-node-rig/profiles/default/includes/eslint/flat/mixins/friendly-locals');

module.exports = [
...nodeTrustedToolProfile,
...friendlyLocalsMixin,
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parserOptions: {
tsconfigRootDir: __dirname
}
}
}
];
19 changes: 19 additions & 0 deletions build-tests/heft-json-schema-typings-plugin-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "heft-json-schema-typings-plugin-test",
"description": "This project illustrates configuring Jest reporters in a minimal Heft project",
"version": "1.0.0",
"private": true,
"scripts": {
"build": "heft build --clean",
"start": "heft build-watch",
"_phase:build": "heft run --only build -- --clean",
"_phase:test": "heft run --only test -- --clean"
},
"devDependencies": {
"@rushstack/heft-json-schema-typings-plugin": "workspace:*",
"@rushstack/heft": "workspace:*",
"@rushstack/node-core-library": "workspace:*",
"eslint": "~9.25.1",
"local-node-rig": "workspace:*"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.

import { FileSystem, type FolderItem, PackageJsonLookup } from '@rushstack/node-core-library';

async function getFolderItemsAsync(
absolutePath: string,
relativePath: string
): Promise<Record<string, string>> {
const folderQueue: [string, string][] = [[absolutePath, relativePath]];
const results: [string, string][] = [];
for (const [folderAbsolutePath, folderRelativePath] of folderQueue) {
const folderItems: FolderItem[] = await FileSystem.readFolderItemsAsync(folderAbsolutePath);
for (const item of folderItems) {
const itemName: string = item.name;
const itemAbsolutePath: string = `${folderAbsolutePath}/${itemName}`;
const itemRelativePath: string = `${folderRelativePath}/${itemName}`;
if (item.isDirectory()) {
folderQueue.push([itemAbsolutePath, itemRelativePath]);
} else {
const itemContents: string = await FileSystem.readFileAsync(itemAbsolutePath);
results.push([itemRelativePath, itemContents]);
}
}
}

results.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0));
return Object.fromEntries(results);
}

describe('json-schema-typings-plugin', () => {
it('should generate typings for JSON Schemas', async () => {
const rootFolder: string | undefined = PackageJsonLookup.instance.tryGetPackageFolderFor(__dirname);
if (!rootFolder) {
throw new Error('Could not find root folder for the test');
}

const folderItems: Record<string, string> = await getFolderItemsAsync(
`${rootFolder}/temp/schema-dts`,
'.'
);
expect(folderItems).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`json-schema-typings-plugin should generate typings for JSON Schemas 1`] = `
Object {
"./test-invalid-additional.schema.json.d.ts": "// This file was generated by a tool. Modifying it will produce unexpected behavior

export interface TestInvalidAdditional {
[k: string]: unknown;
}
",
"./test-invalid-format.schema.json.d.ts": "// This file was generated by a tool. Modifying it will produce unexpected behavior

export interface TestInvalidFormat {
[k: string]: unknown;
}
",
"./test-schema-draft-04.schema.json.d.ts": "// This file was generated by a tool. Modifying it will produce unexpected behavior

export interface TestSchemaFile {
exampleString: string;
exampleLink?: string;
exampleArray: string[];
/**
* Description for exampleOneOf - this is a very long description to show in an error message
*/
exampleOneOf?: Type1 | Type2;
exampleUniqueObjectArray?: {
field2?: string;
field3?: string;
}[];
}
/**
* Description for type1
*/
export interface Type1 {
/**
* Description for field1
*/
field1: string;
}
/**
* Description for type2
*/
export interface Type2 {
/**
* Description for field2
*/
field2: string;
/**
* Description for field3
*/
field3: string;
}
",
"./test-schema-draft-07.schema.json.d.ts": "// This file was generated by a tool. Modifying it will produce unexpected behavior

export interface TestSchemaFile {
exampleString: string;
exampleLink?: string;
exampleArray: string[];
/**
* Description for exampleOneOf - this is a very long description to show in an error message
*/
exampleOneOf?: Type1 | Type2;
exampleUniqueObjectArray?: {
field2?: string;
field3?: string;
}[];
}
/**
* Description for type1
*/
export interface Type1 {
/**
* Description for field1
*/
field1: string;
}
/**
* Description for type2
*/
export interface Type2 {
/**
* Description for field2
*/
field2: string;
/**
* Description for field3
*/
field3: string;
}
",
"./test-schema-invalid.schema.json.d.ts": "// This file was generated by a tool. Modifying it will produce unexpected behavior

export interface HttpExampleComSchemasTestSchemaNestedChildSchemaJson {
[k: string]: unknown;
}
",
"./test-schema-nested-child.schema.json.d.ts": "// This file was generated by a tool. Modifying it will produce unexpected behavior

export interface HttpExampleComSchemasTestSchemaNestedChildSchemaJson {
[k: string]: unknown;
}
",
"./test-schema-nested.schema.json.d.ts": "// This file was generated by a tool. Modifying it will produce unexpected behavior

export interface TestSchemaFile {
exampleString: string;
exampleLink?: string;
exampleArray: string[];
/**
* Description for exampleOneOf - this is a very long description to show in an error message
*/
exampleOneOf?: Type1 | Type2;
exampleUniqueObjectArray?: Type2[];
}
/**
* Description for type1
*/
export interface Type1 {
/**
* Description for field1
*/
field1: string;
}
/**
* Description for type2
*/
export interface Type2 {
/**
* Description for field2
*/
field2: string;
/**
* Description for field3
*/
field3: string;
}
",
"./test-schema.schema.json.d.ts": "// This file was generated by a tool. Modifying it will produce unexpected behavior

export interface TestSchemaFile {
exampleString: string;
exampleLink?: string;
exampleArray: string[];
/**
* Description for exampleOneOf - this is a very long description to show in an error message
*/
exampleOneOf?: Type1 | Type2;
exampleUniqueObjectArray?: {
field2?: string;
field3?: string;
}[];
}
/**
* Description for type1
*/
export interface Type1 {
/**
* Description for field1
*/
field1: string;
}
/**
* Description for type2
*/
export interface Type2 {
/**
* Description for field2
*/
field2: string;
/**
* Description for field3
*/
field3: string;
}
",
"./test-valid.schema.json.d.ts": "// This file was generated by a tool. Modifying it will produce unexpected behavior

export interface TestValid {
[k: string]: unknown;
}
",
}
`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "./node_modules/local-node-rig/profiles/default/tsconfig-base.json"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/heft-json-schema-typings-plugin",
"comment": "Initial release.",
"type": "minor"
}
],
"packageName": "@rushstack/heft-json-schema-typings-plugin"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/heft-web-rig",
"comment": "Clean the temp/sass-ts folder.",
"type": "minor"
}
],
"packageName": "@rushstack/heft-web-rig"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@rushstack/node-core-library",
"comment": "",
"type": "none"
}
],
"packageName": "@rushstack/node-core-library"
}
8 changes: 0 additions & 8 deletions common/config/rush/browser-approved-packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,6 @@
"name": "dependency-path",
"allowedCategories": [ "libraries" ]
},
{
"name": "heft-example-lifecycle-plugin",
"allowedCategories": [ "tests" ]
},
{
"name": "local-web-rig",
"allowedCategories": [ "libraries", "vscode-extensions" ]
},
{
"name": "office-ui-fabric-core",
"allowedCategories": [ "libraries" ]
Expand Down
Loading
Loading