-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[fei5815.2.workaround] Add step to tidy up files (#1024)
## Summary: It seems that `changesets publish` isn't honoring our root `.npmignore` even though `npm pack` would. This works around that by borrowing some code from Wonder Blocks where we tidy up any ignored files that aren't source-controlled, reducing what we package. We also explicitly include things in each package.json. This combination means we can easily exclude files and folders in the `dist` location, without having really explicit `files` definitions that might be hard to maintain. Issue: FEI-5815 ## Test plan: `yarn build:types` and see the files being removed. Author: somewhatabstract Reviewers: jeresig Required Reviewers: Approved By: jeresig Checks: ✅ Test (macos-latest, 20.x), ✅ codecov/project, ✅ CodeQL, ✅ Lint, typecheck, and coverage check (ubuntu-latest, 20.x), ✅ Prime node_modules cache for primary configuration (ubuntu-latest, 20.x), ✅ Analyze (javascript), ✅ gerald, ⏭️ dependabot Pull Request URL: #1024
- Loading branch information
1 parent
fd1083e
commit a026cee
Showing
18 changed files
with
368 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
"@khanacademy/wonder-stuff-ci": patch | ||
"@khanacademy/wonder-stuff-core": patch | ||
"@khanacademy/wonder-stuff-i18n": patch | ||
"@khanacademy/wonder-stuff-render-environment-jsdom": patch | ||
"@khanacademy/wonder-stuff-render-server": patch | ||
"@khanacademy/wonder-stuff-sentry": patch | ||
"@khanacademy/wonder-stuff-server": patch | ||
"@khanacademy/wonder-stuff-testing": patch | ||
--- | ||
|
||
Stop packaging some files that we don't need to package |
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 |
---|---|---|
|
@@ -7,3 +7,4 @@ docs | |
.DS_Store | ||
yarn-error.log | ||
*.tsbuildinfo | ||
utils/**/*.d.ts |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env -S node -r @swc-node/register | ||
/* eslint-disable no-console */ | ||
/** | ||
* Check type definition files for anything that doesn't look right. | ||
* | ||
* If our packages don't export all the types that other packages reference, | ||
* even indirectly, then their type definitions will import them from the source | ||
* files instead. Since we don't want to ship source code in every package, | ||
* we want to guard against this. | ||
* | ||
* This script should be run after `yarn build:types`. It will scan the type | ||
* definitions of each package for any types that are being incorrectly | ||
* imported from other the source code of other packages, and flag them, | ||
* exiting with a non-zero status code if any are found. | ||
*/ | ||
import * as fs from "fs"; | ||
import * as path from "path"; | ||
import * as fglob from "fast-glob"; | ||
|
||
const rootDir = path.join(__dirname, ".."); | ||
const packagesDir = path.join(rootDir, "packages"); | ||
|
||
// Find all the type definition files in the packages dist directories. | ||
const typeDefinitionFiles = fglob.sync("**/*.d.ts", { | ||
cwd: packagesDir, | ||
onlyFiles: true, | ||
}); | ||
|
||
let foundErrors = false; | ||
// Scan each one for any imports of types from source. | ||
for (const typeDefinitionFile of typeDefinitionFiles) { | ||
const regexpImportSrc = | ||
/import\(".+\/(wonder-stuff-.+)\/src\/.+"\)\.([a-zA-Z]+)/g; | ||
const content = fs.readFileSync( | ||
path.join(packagesDir, typeDefinitionFile), | ||
"utf-8", | ||
); | ||
const lines = content.split("\n"); | ||
let match; | ||
for (let line = 0; line < lines.length; line++) { | ||
while ((match = regexpImportSrc.exec(lines[line]))) { | ||
foundErrors = true; | ||
const position = match.index; | ||
const lineNo = line + 1; | ||
const refPath = path.join("packages", typeDefinitionFile); | ||
console.error(`${refPath}:${lineNo}:${position}`); | ||
console.error( | ||
` Incorrectly imported type ${match[2]} from ${match[1]} source`, | ||
); | ||
console.error( | ||
` Update the package ${match[1]} to export the type ${match[2]}\n`, | ||
); | ||
} | ||
} | ||
} | ||
|
||
if (foundErrors) { | ||
process.exit(1); | ||
} |
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,13 @@ | ||
*.tsbuildinfo | ||
tsconfig-build.json | ||
dist/**/__tests__ | ||
dist/**/*.test.d.ts | ||
src | ||
README.md | ||
demo | ||
docs | ||
node_modules | ||
babel.config.js | ||
.eslintrc.js | ||
.mocharc.js | ||
test |
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,13 @@ | ||
*.tsbuildinfo | ||
tsconfig-build.json | ||
dist/**/__tests__ | ||
dist/**/*.test.d.ts | ||
src | ||
README.md | ||
demo | ||
docs | ||
node_modules | ||
babel.config.js | ||
.eslintrc.js | ||
.mocharc.js | ||
test |
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 |
---|---|---|
|
@@ -10,9 +10,6 @@ | |
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"files": [ | ||
"/dist" | ||
], | ||
"main": "dist/index.js", | ||
"module": "dist/es/index.js", | ||
"author": "Kevin Barabash <[email protected]>", | ||
|
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,13 @@ | ||
*.tsbuildinfo | ||
tsconfig-build.json | ||
dist/**/__tests__ | ||
dist/**/*.test.d.ts | ||
src | ||
README.md | ||
demo | ||
docs | ||
node_modules | ||
babel.config.js | ||
.eslintrc.js | ||
.mocharc.js | ||
test |
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,13 @@ | ||
*.tsbuildinfo | ||
tsconfig-build.json | ||
dist/**/__tests__ | ||
dist/**/*.test.d.ts | ||
src | ||
README.md | ||
demo | ||
docs | ||
node_modules | ||
babel.config.js | ||
.eslintrc.js | ||
.mocharc.js | ||
test |
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,13 @@ | ||
*.tsbuildinfo | ||
tsconfig-build.json | ||
dist/**/__tests__ | ||
dist/**/*.test.d.ts | ||
src | ||
README.md | ||
demo | ||
docs | ||
node_modules | ||
babel.config.js | ||
.eslintrc.js | ||
.mocharc.js | ||
test |
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,13 @@ | ||
*.tsbuildinfo | ||
tsconfig-build.json | ||
dist/**/__tests__ | ||
dist/**/*.test.d.ts | ||
src | ||
README.md | ||
demo | ||
docs | ||
node_modules | ||
babel.config.js | ||
.eslintrc.js | ||
.mocharc.js | ||
test |
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,13 @@ | ||
*.tsbuildinfo | ||
tsconfig-build.json | ||
dist/**/__tests__ | ||
dist/**/*.test.d.ts | ||
src | ||
README.md | ||
demo | ||
docs | ||
node_modules | ||
babel.config.js | ||
.eslintrc.js | ||
.mocharc.js | ||
test |
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,13 @@ | ||
*.tsbuildinfo | ||
tsconfig-build.json | ||
dist/**/__tests__ | ||
dist/**/*.test.d.ts | ||
src | ||
README.md | ||
demo | ||
docs | ||
node_modules | ||
babel.config.js | ||
.eslintrc.js | ||
.mocharc.js | ||
test |
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,13 @@ | ||
*.tsbuildinfo | ||
tsconfig-build.json | ||
dist/**/__tests__ | ||
dist/**/*.test.d.ts | ||
src | ||
README.md | ||
demo | ||
docs | ||
node_modules | ||
babel.config.js | ||
.eslintrc.js | ||
.mocharc.js | ||
test |
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,13 @@ | ||
*.tsbuildinfo | ||
tsconfig-build.json | ||
dist/**/__tests__ | ||
dist/**/*.test.d.ts | ||
src | ||
README.md | ||
demo | ||
docs | ||
node_modules | ||
babel.config.js | ||
.eslintrc.js | ||
.mocharc.js | ||
test |
Oops, something went wrong.