Skip to content

Commit 60d69b0

Browse files
Copiloticlanton
andauthored
address review feedback: cleanup, alphabetical deps, drop unused IRepoStateJson, package entrypoint imports
Agent-Logs-Url: https://github.com/microsoft/rushstack/sessions/83bb9e28-6062-4265-851a-ce82c95398ec Co-authored-by: iclanton <5010588+iclanton@users.noreply.github.com>
1 parent 0183306 commit 60d69b0

16 files changed

Lines changed: 42 additions & 74 deletions

File tree

common/config/rush/browser-approved-packages.json

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,10 @@
3838
"name": "@reduxjs/toolkit",
3939
"allowedCategories": [ "libraries", "vscode-extensions" ]
4040
},
41-
{
42-
"name": "@rushstack/heft-zod-schema-plugin",
43-
"allowedCategories": [ "libraries" ]
44-
},
4541
{
4642
"name": "@rushstack/problem-matcher",
4743
"allowedCategories": [ "libraries" ]
4844
},
49-
{
50-
"name": "@rushstack/rush-schemas",
51-
"allowedCategories": [ "libraries" ]
52-
},
5345
{
5446
"name": "@rushstack/rush-themed-ui",
5547
"allowedCategories": [ "libraries" ]

common/config/rush/nonbrowser-approved-packages.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,10 @@
290290
"name": "@rushstack/heft-webpack5-plugin",
291291
"allowedCategories": [ "libraries", "tests", "vscode-extensions" ]
292292
},
293+
{
294+
"name": "@rushstack/heft-zod-schema-plugin",
295+
"allowedCategories": [ "libraries" ]
296+
},
293297
{
294298
"name": "@rushstack/localization-utilities",
295299
"allowedCategories": [ "libraries" ]
@@ -378,6 +382,10 @@
378382
"name": "@rushstack/rush-resolver-cache-plugin",
379383
"allowedCategories": [ "libraries" ]
380384
},
385+
{
386+
"name": "@rushstack/rush-schemas",
387+
"allowedCategories": [ "libraries" ]
388+
},
381389
{
382390
"name": "@rushstack/rush-sdk",
383391
"allowedCategories": [ "libraries", "tests", "vscode-extensions" ]

common/config/subspaces/build-tests-subspace/repo-state.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
{
33
"pnpmShrinkwrapHash": "0d3fa0f98a02504bf1f36a2cea15fadf76e1f0b9",
44
"preferredVersionsHash": "550b4cee0bef4e97db6c6aad726df5149d20e7d9",
5-
"packageJsonInjectedDependenciesHash": "c4fba4181349178d4b8b8aa1fee6cfe76e3639c0"
5+
"packageJsonInjectedDependenciesHash": "cf6202674eee7a6015522eac2f64eaee1666ce39"
66
}

common/reviews/api/rush-lib.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { CredentialCache } from '@rushstack/credential-cache';
1717
import { HookMap } from 'tapable';
1818
import { ICredentialCacheEntry } from '@rushstack/credential-cache';
1919
import { ICredentialCacheOptions } from '@rushstack/credential-cache';
20-
import type { IExperimentsJson } from '@rushstack/rush-schemas/lib/experiments.zod';
20+
import type { IExperimentsJson } from '@rushstack/rush-schemas';
2121
import { IFileDiffStatus } from '@rushstack/package-deps-hash';
2222
import { IPackageJson } from '@rushstack/node-core-library';
2323
import { IPrefixMatch } from '@rushstack/lookup-by-path';

heft-plugins/heft-zod-schema-plugin/CHANGELOG.json

Lines changed: 0 additions & 4 deletions
This file was deleted.

heft-plugins/heft-zod-schema-plugin/CHANGELOG.md

Lines changed: 0 additions & 3 deletions
This file was deleted.

heft-plugins/heft-zod-schema-plugin/src/ZodSchemaGenerator.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import * as path from 'node:path';
55

6-
import { FileSystem, NewlineKind } from '@rushstack/node-core-library';
6+
import { FileSystem, NewlineKind, Path } from '@rushstack/node-core-library';
77
import type { ITerminal } from '@rushstack/terminal';
88

99
import {
@@ -20,20 +20,20 @@ import {
2020
*/
2121
export interface IZodSchemaGeneratorOptions {
2222
/**
23-
* The project root folder. All `inputGlobs` and `outputFolder` paths are resolved
24-
* relative to this folder.
23+
* The project root folder. Relative `inputGlobs` and `outputFolder` paths are resolved
24+
* relative to this folder; absolute paths are accepted as-is.
2525
*/
2626
buildFolderPath: string;
2727

2828
/**
29-
* Globs (relative to `buildFolderPath`) identifying the compiled JavaScript modules
30-
* that export zod schemas.
29+
* Globs identifying the compiled JavaScript modules that export zod schemas.
30+
* May be relative to `buildFolderPath` or absolute.
3131
*/
3232
inputGlobs: string[];
3333

3434
/**
35-
* Folder (relative to `buildFolderPath`) where the generated `*.schema.json` files
36-
* will be written.
35+
* Folder where the generated `*.schema.json` files will be written. May be
36+
* relative to `buildFolderPath` or absolute.
3737
*/
3838
outputFolder: string;
3939

@@ -108,7 +108,12 @@ export class ZodSchemaGenerator {
108108
// Defer requiring fast-glob until use to keep startup cheap when the plugin
109109
// is loaded but no work is needed.
110110
const glob: typeof import('fast-glob') = require('fast-glob');
111-
const matches: string[] = await glob(this._options.inputGlobs, {
111+
// fast-glob requires forward-slash patterns; convert any platform-specific
112+
// separators (Windows backslashes from `__dirname`-rooted patterns, etc.).
113+
const normalizedGlobs: string[] = this._options.inputGlobs.map((pattern) =>
114+
Path.convertToSlashes(pattern)
115+
);
116+
const matches: string[] = await glob(normalizedGlobs, {
112117
cwd: this._options.buildFolderPath,
113118
absolute: true,
114119
onlyFiles: true
@@ -170,7 +175,7 @@ export class ZodSchemaGenerator {
170175
exportName === 'default'
171176
? `${baseName}${SCHEMA_FILE_EXTENSION}`
172177
: `${baseName}.${exportName}${SCHEMA_FILE_EXTENSION}`;
173-
const outputFilePath: string = path.join(
178+
const outputFilePath: string = path.resolve(
174179
this._options.buildFolderPath,
175180
this._options.outputFolder,
176181
outputFileName

heft-plugins/heft-zod-schema-plugin/src/test/ZodSchemaGenerator.test.ts

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
22
// See LICENSE in the project root for license information.
33

4-
import * as path from 'node:path';
5-
64
import { FileSystem, PackageJsonLookup } from '@rushstack/node-core-library';
75

86
import { ZodSchemaGenerator, type IGeneratedSchema } from '../ZodSchemaGenerator';
97

108
const projectFolder: string = PackageJsonLookup.instance.tryGetPackageFolderFor(__dirname)!;
11-
const compiledFixturesFolder: string = path.join(__dirname, 'fixtures');
12-
const outputFolder: string = path.join(projectFolder, 'temp/test-zod-schema-output');
9+
const compiledFixturesFolder: string = `${__dirname}/fixtures`;
10+
const outputFolder: string = `${projectFolder}/temp/test-zod-schema-output`;
1311

1412
async function readJsonAsync(absolutePath: string): Promise<unknown> {
1513
const text: string = await FileSystem.readFileAsync(absolutePath);
@@ -24,8 +22,8 @@ describe(ZodSchemaGenerator.name, () => {
2422
it('emits a JSON schema for a basic zod default export', async () => {
2523
const generator: ZodSchemaGenerator = new ZodSchemaGenerator({
2624
buildFolderPath: projectFolder,
27-
inputGlobs: [path.relative(projectFolder, path.join(compiledFixturesFolder, 'basic.zod.js'))],
28-
outputFolder: path.relative(projectFolder, outputFolder),
25+
inputGlobs: [`${compiledFixturesFolder}/basic.zod.js`],
26+
outputFolder,
2927
exportName: 'default',
3028
indent: 2
3129
});
@@ -41,10 +39,8 @@ describe(ZodSchemaGenerator.name, () => {
4139
it('applies withSchemaMeta() metadata, including the TSDoc release tag', async () => {
4240
const generator: ZodSchemaGenerator = new ZodSchemaGenerator({
4341
buildFolderPath: projectFolder,
44-
inputGlobs: [
45-
path.relative(projectFolder, path.join(compiledFixturesFolder, 'with-tsdoc-tag.zod.js'))
46-
],
47-
outputFolder: path.relative(projectFolder, outputFolder),
42+
inputGlobs: [`${compiledFixturesFolder}/with-tsdoc-tag.zod.js`],
43+
outputFolder,
4844
exportName: 'default',
4945
indent: 2
5046
});
@@ -64,25 +60,23 @@ describe(ZodSchemaGenerator.name, () => {
6460
it('emits one schema file per named ZodType export when exportName is "*"', async () => {
6561
const generator: ZodSchemaGenerator = new ZodSchemaGenerator({
6662
buildFolderPath: projectFolder,
67-
inputGlobs: [
68-
path.relative(projectFolder, path.join(compiledFixturesFolder, 'named-exports.zod.js'))
69-
],
70-
outputFolder: path.relative(projectFolder, outputFolder),
63+
inputGlobs: [`${compiledFixturesFolder}/named-exports.zod.js`],
64+
outputFolder,
7165
exportName: '*',
7266
indent: 2
7367
});
7468

7569
const results: IGeneratedSchema[] = await generator.generateAsync();
7670
expect(results).toHaveLength(2);
77-
const fileNames: string[] = results.map((r) => path.basename(r.outputFilePath)).sort();
71+
const fileNames: string[] = results.map((r) => r.outputFilePath.split(/[\\/]/).pop()!).sort();
7872
expect(fileNames).toEqual(['named-exports.alphaSchema.schema.json', 'named-exports.betaSchema.schema.json']);
7973
});
8074

8175
it('produces deterministic output and skips writes when contents are unchanged', async () => {
8276
const generator: ZodSchemaGenerator = new ZodSchemaGenerator({
8377
buildFolderPath: projectFolder,
84-
inputGlobs: [path.relative(projectFolder, path.join(compiledFixturesFolder, 'basic.zod.js'))],
85-
outputFolder: path.relative(projectFolder, outputFolder),
78+
inputGlobs: [`${compiledFixturesFolder}/basic.zod.js`],
79+
outputFolder,
8680
exportName: 'default',
8781
indent: 2
8882
});
@@ -98,8 +92,8 @@ describe(ZodSchemaGenerator.name, () => {
9892
it('throws a clear error when the requested export is not a zod schema', async () => {
9993
const generator: ZodSchemaGenerator = new ZodSchemaGenerator({
10094
buildFolderPath: projectFolder,
101-
inputGlobs: [path.relative(projectFolder, path.join(compiledFixturesFolder, 'basic.zod.js'))],
102-
outputFolder: path.relative(projectFolder, outputFolder),
95+
inputGlobs: [`${compiledFixturesFolder}/basic.zod.js`],
96+
outputFolder,
10397
exportName: 'doesNotExist',
10498
indent: 2
10599
});

libraries/rush-lib/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"@rushstack/rush-pnpm-kit-v10": "workspace:*",
5454
"@rushstack/rush-pnpm-kit-v8": "workspace:*",
5555
"@rushstack/rush-pnpm-kit-v9": "workspace:*",
56+
"@rushstack/rush-schemas": "workspace:*",
5657
"@rushstack/stream-collator": "workspace:*",
5758
"@rushstack/terminal": "workspace:*",
5859
"@rushstack/ts-command-line": "workspace:*",
@@ -74,7 +75,6 @@
7475
"pnpm-sync-lib": "0.3.3",
7576
"read-package-tree": "~5.1.5",
7677
"rxjs": "~6.6.7",
77-
"@rushstack/rush-schemas": "workspace:*",
7878
"semver": "~7.7.4",
7979
"ssri": "~8.0.0",
8080
"strict-uri-encode": "~2.0.0",

libraries/rush-lib/src/api/ExperimentsConfiguration.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// See LICENSE in the project root for license information.
33

44
import { JsonFile, JsonSchema, FileSystem } from '@rushstack/node-core-library';
5-
import type { IExperimentsJson } from '@rushstack/rush-schemas/lib/experiments.zod';
5+
import type { IExperimentsJson } from '@rushstack/rush-schemas';
66
import { Colorize } from '@rushstack/terminal';
77

88
import schemaJson from '../schemas/experiments.schema.json';

0 commit comments

Comments
 (0)