-
Notifications
You must be signed in to change notification settings - Fork 609
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3860 from iclanton/rush-lib-dts-test-project
[rush-lib] Add a test that ensures that all `lib/**/*.d.ts` files have valid imports.
- Loading branch information
Showing
16 changed files
with
163 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// This is a workaround for https://github.com/eslint/eslint/issues/3458 | ||
require('@rushstack/eslint-config/patch/modern-module-resolution'); | ||
|
||
module.exports = { | ||
extends: [ | ||
'@rushstack/eslint-config/profile/node-trusted-tool', | ||
'@rushstack/eslint-config/mixins/friendly-locals' | ||
], | ||
parserOptions: { tsconfigRootDir: __dirname } | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# This is generated by the build | ||
src/ |
32 changes: 32 additions & 0 deletions
32
build-tests/rush-lib-declaration-paths-test/config/heft.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/heft/heft.schema.json", | ||
|
||
"extends": "@rushstack/heft-node-rig/profiles/default/config/heft.json", | ||
|
||
"eventActions": [ | ||
{ | ||
"actionKind": "deleteGlobs", | ||
"actionId": "deleteSrc", | ||
"heftEvent": "clean", | ||
"globsToDelete": ["src/**/*"] | ||
}, | ||
{ | ||
"actionKind": "copyFiles", | ||
"heftEvent": "pre-compile", | ||
"actionId": "createSrc", | ||
"copyOperations": [ | ||
{ | ||
"sourceFolder": "node_modules/@microsoft/rush-lib/src", | ||
"destinationFolders": ["src"], | ||
"includeGlobs": ["npm-check-typings.d.ts"] | ||
} | ||
] | ||
}, | ||
{ | ||
"actionKind": "runScript", | ||
"heftEvent": "pre-compile", | ||
"actionId": "createSrc", | ||
"scriptPath": "./scripts/createSrc.js" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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": "@rushstack/heft-node-rig" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "rush-lib-declaration-paths-test", | ||
"description": "This project ensures all of the paths in rush-lib/lib/... have imports that resolve correctly. If this project builds, all `lib/**/*.d.ts` files in the `@microsoft/rush-lib` package are valid.", | ||
"version": "1.0.0", | ||
"private": true, | ||
"scripts": { | ||
"build": "heft build --clean", | ||
"_phase:build": "heft build --clean" | ||
}, | ||
"dependencies": { | ||
"@microsoft/rush-lib": "workspace:*" | ||
}, | ||
"devDependencies": { | ||
"@rushstack/eslint-config": "workspace:*", | ||
"@rushstack/heft-node-rig": "workspace:*", | ||
"@rushstack/heft": "workspace:*", | ||
"@rushstack/node-core-library": "workspace:*", | ||
"@types/node": "12.20.24" | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
build-tests/rush-lib-declaration-paths-test/scripts/createSrc.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
'ues strict'; | ||
|
||
const { FileSystem, Import } = require('@rushstack/node-core-library'); | ||
|
||
const DTS_EXTENSION = '.d.ts'; | ||
|
||
module.exports = { | ||
runAsync: async ({ heftConfiguration: { buildFolder } }) => { | ||
const rushLibPath = Import.resolvePackage({ | ||
packageName: '@microsoft/rush-lib', | ||
baseFolderPath: __dirname | ||
}); | ||
|
||
async function* collectDtsPaths(absoluteFolderPath, relativeFolderPath) { | ||
const folderItems = FileSystem.readFolderItems(absoluteFolderPath); | ||
for (const folderItem of folderItems) { | ||
const folderItemName = folderItem.name; | ||
if (folderItem.isDirectory()) { | ||
yield* collectDtsPaths( | ||
`${absoluteFolderPath}/${folderItemName}`, | ||
`${relativeFolderPath}/${folderItemName}` | ||
); | ||
} else if (folderItemName.endsWith(DTS_EXTENSION)) { | ||
yield `${relativeFolderPath}/${folderItemName.slice(0, -DTS_EXTENSION.length)}`; | ||
} | ||
} | ||
} | ||
|
||
const indexFileLines = ['/// <reference path="./npm-check-typings.d.ts" />', '']; | ||
for await (const dtsPath of collectDtsPaths(`${rushLibPath}/lib`, '@microsoft/rush-lib/lib')) { | ||
indexFileLines.push(`import '${dtsPath}';`); | ||
} | ||
|
||
const srcFolderPath = `${buildFolder}/src`; | ||
await FileSystem.writeFileAsync(`${srcFolderPath}/index.ts`, indexFileLines.join('\n'), { | ||
ensureFolderExists: true | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "./node_modules/@rushstack/heft-node-rig/profiles/default/tsconfig-base.json", | ||
"compilerOptions": { | ||
"types": ["node"] | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
common/changes/@microsoft/rush/rush-lib-dts-test-project_2022-12-21-06-51.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"changes": [ | ||
{ | ||
"comment": "", | ||
"type": "none", | ||
"packageName": "@microsoft/rush" | ||
} | ||
], | ||
"packageName": "@microsoft/rush", | ||
"email": "[email protected]" | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters