An open source design system that's fully customizable and agent ready
TypeScript
fix(packages): exclude tests and benchmarks from tarballs (#9153)
Cindy Zhangabf156aec87f
diff --git a/.changeset/slim-published-package-artifacts.md b/.changeset/slim-published-package-artifacts.mdnew file mode 100644index 0000000000..f1c93548dc--- /dev/null+++ b/.changeset/slim-published-package-artifacts.md@@ -0,0 +1,17 @@+---+'@astryxdesign/build': patch+'@astryxdesign/cli': patch+'@astryxdesign/core': patch+'@astryxdesign/richtext': patch+'@astryxdesign/theme-butter': patch+'@astryxdesign/theme-chocolate': patch+'@astryxdesign/theme-gothic': patch+'@astryxdesign/theme-matcha': patch+'@astryxdesign/theme-neutral': patch+'@astryxdesign/theme-stone': patch+'@astryxdesign/theme-y2k': patch+---++[fix] Published packages no longer include repository test and benchmark files, reducing install size without changing exports.++@parinith-webdiff --git a/packages/build/package.json b/packages/build/package.jsonindex 500df42ff4..74c8bf42d6 100644--- a/packages/build/package.json+++ b/packages/build/package.json@@ -1,7 +1,7 @@{"name": "@astryxdesign/build","version": "0.7.6",- "description": "Build plugins for Astryx source builds — babel, PostCSS, and Vite integrations",+ "description": "Build plugins for Astryx source builds \u2014 babel, PostCSS, and Vite integrations","author": "Meta Open Source","license": "MIT","homepage": "https://github.com/meta/astryx#readme",@@ -33,7 +33,20 @@},"files": ["src",- "dist"+ "dist",+ "!**/*.test.*",+ "!**/*.spec.js",+ "!**/*.spec.jsx",+ "!**/*.spec.mjs",+ "!**/*.spec.cjs",+ "!**/*.spec.ts",+ "!**/*.spec.tsx",+ "!**/*.spec.mts",+ "!**/*.spec.cts",+ "!**/*.spec.d.ts",+ "!**/__tests__/**",+ "!**/__mocks__/**",+ "!**/*.bench.*"],"scripts": {"build": "node build.mjs",diff --git a/packages/build/src/index.js b/packages/build/src/index.jsindex be57b0f83e..fc8f9c2cf2 100644--- a/packages/build/src/index.js+++ b/packages/build/src/index.js@@ -42,12 +42,12 @@ const LIBRARY_PATTERNS = [const STYLEX_IMPORT_SOURCE = '@stylexjs/stylex';/**- * Globs for the source each installed Astryx package publishes: each `files`- * entry, a directory (the files below it) or a file, or the whole package when- * it has none; an entry with glob characters or a leading `!` is refused, not- * approximated. A package's own `node_modules` is never scanned: in a- * workspace its links can lead back to the package (here, core's dev- * dependency `@astryxdesign/cli` links core again).+ * Globs for the source each installed Astryx package publishes: each positive+ * `files` entry is a directory (the files below it) or a file, while negated+ * entries become discovery exclusions. Positive entries with glob characters+ * are refused rather than approximated. A package's own `node_modules` is never+ * scanned: in a workspace its links can lead back to the package (here, core's+ * dev dependency `@astryxdesign/cli` links core again).*/function libraryGlobs(cwd) {const include = [];@@ -69,10 +69,14 @@ function libraryGlobs(cwd) {continue;}for (const entry of files) {- // isGlob also flags a leading `!`.+ if (entry.startsWith('!')) {+ const excluded = entry.slice(1).replace(/^\.?\/|\/$/g, '');+ if (excluded) ignore.push(`${base}/${excluded}`);+ continue;+ }if (isGlob(entry)) {throw new Error(- `@astryxdesign/build reads plain files entries only; @astryxdesign/${name} lists "${entry}"`,+ `@astryxdesign/build reads plain positive files entries only; @astryxdesign/${name} lists "${entry}"`,);}const plain = entry.replace(/^\.?\/|\/$/g, '');diff --git a/packages/build/src/postcss.workspace-links.test.mjs b/packages/build/src/postcss.workspace-links.test.mjsindex f96eb92f19..8eb4212793 100644--- a/packages/build/src/postcss.workspace-links.test.mjs+++ b/packages/build/src/postcss.workspace-links.test.mjs@@ -5,8 +5,8 @@* @input The PostCSS plugin, run from apps whose Astryx packages are linked* from a workspace where package links form cycles* @output Proves the plugin compiles what each installed package publishes,- * once, never walks a package's own `node_modules`, and refuses `files`- * entries it cannot read faithfully+ * once, never walks a package's own `node_modules`, honors negated `files`+ * entries, and refuses positive globs it cannot read faithfully* @position Regression test for @astryxdesign/build's PostCSS library scan*/@@ -31,7 +31,9 @@ const stylexModule = color =>/*** A pnpm-style workspace. Core publishes `src` and also carries a test fixture;* its dev dependency, the CLI, links back to it. The theme declares no `files`,- * and its own dependency links to core. Two more list a glob and a `!` entry.+ * and its own dependency links to core. One more lists a positive glob that+ * cannot be represented faithfully; another uses Astryx's test and benchmark+ * negations.*/beforeAll(() => {root = fs.realpathSync(@@ -57,9 +59,18 @@ beforeAll(() => {'packages/globbed/src/index.ts': stylexModule('orange'),'packages/negated/package.json': manifest('@astryxdesign/negated', ['src',- '!src/internal',+ '!**/*.test.*',+ '!**/*.spec.ts',+ '!**/__tests__/**',+ '!**/__mocks__/**',+ '!**/*.bench.*',]),'packages/negated/src/index.ts': stylexModule('teal'),+ 'packages/negated/src/index.test.ts': stylexModule('red'),+ 'packages/negated/src/private.spec.ts': stylexModule('blue'),+ 'packages/negated/src/perf.bench.ts': stylexModule('yellow'),+ 'packages/negated/src/__tests__/helper.ts': stylexModule('orange'),+ 'packages/negated/src/__mocks__/helper.ts': stylexModule('purple'),'apps/site/src/page.tsx': '','apps/themed/src/page.tsx': '','apps/globbed/src/page.tsx': '',@@ -149,15 +160,18 @@ describe('the PostCSS plugin and workspace links', () => {]);});- it.each([- ['globbed', 'src/*'],- ['negated', '!src/internal'],- ])(- 'refuses a `files` entry it cannot read faithfully: %s',- async (name, entry) => {- await expect(compileApp(path.join(root, `apps/${name}`))).rejects.toThrow(- `@astryxdesign/build reads plain files entries only; @astryxdesign/${name} lists "${entry}"`,- );- },- );+ it('honors negated test and benchmark entries in package files', async () => {+ const {css, compiled} = await compileApp(path.join(root, 'apps/negated'));++ expect(compiled).toEqual([+ path.join('node_modules/@astryxdesign/negated/src/index.ts'),+ ]);+ expect(css).toMatch(/@layer astryx-base \{[^]*color:\s*teal/);+ });++ it('refuses a positive `files` glob it cannot read faithfully', async () => {+ await expect(compileApp(path.join(root, 'apps/globbed'))).rejects.toThrow(+ '@astryxdesign/build reads plain positive files entries only; @astryxdesign/globbed lists "src/*"',+ );+ });});diff --git a/packages/cli/foundation/doc-compiler/inputs.test.mjs b/packages/cli/foundation/doc-compiler/inputs.test.mjsindex f690a79b2f..5673a5fa42 100644--- a/packages/cli/foundation/doc-compiler/inputs.test.mjs+++ b/packages/cli/foundation/doc-compiler/inputs.test.mjs@@ -65,6 +65,7 @@ describe('collectDocInputs over what this repo ships', () => {fs.readFileSync(path.join(CLI_ROOT, 'package.json'), 'utf-8'),);for (const entry of files) {+ if (entry.startsWith('!')) continue;const full = path.join(CLI_ROOT, entry);if (fs.statSync(full).isDirectory()) docFiles(full, shipped);}diff --git a/packages/cli/package.json b/packages/cli/package.jsonindex 5ca1214507..e5d551fe94 100644--- a/packages/cli/package.json+++ b/packages/cli/package.json@@ -91,7 +91,20 @@"foundation","host","scripts/postinstall.mjs",- "CHANGELOG.md"+ "CHANGELOG.md",+ "!**/*.test.*",+ "!**/*.spec.js",+ "!**/*.spec.jsx",+ "!**/*.spec.mjs",+ "!**/*.spec.cjs",+ "!**/*.spec.ts",+ "!**/*.spec.tsx",+ "!**/*.spec.mts",+ "!**/*.spec.cts",+ "!**/*.spec.d.ts",+ "!**/__tests__/**",+ "!**/__mocks__/**",+ "!**/*.bench.*"],"scripts": {"astryx": "node clients/cli/bin/astryx.mjs",diff --git a/packages/core/package.json b/packages/core/package.jsonindex 534ade244e..19b0a84439 100644--- a/packages/core/package.json+++ b/packages/core/package.json@@ -839,7 +839,20 @@"docs.mjs","groups.doc.mjs","README.md",- "CHANGELOG.md"+ "CHANGELOG.md",+ "!**/*.test.*",+ "!**/*.spec.js",+ "!**/*.spec.jsx",+ "!**/*.spec.mjs",+ "!**/*.spec.cjs",+ "!**/*.spec.ts",+ "!**/*.spec.tsx",+ "!**/*.spec.mts",+ "!**/*.spec.cts",+ "!**/*.spec.d.ts",+ "!**/__tests__/**",+ "!**/__mocks__/**",+ "!**/*.bench.*"],"scripts": {"prepack": "pnpm build",diff --git a/packages/core/tsconfig.build.json b/packages/core/tsconfig.build.jsonindex 53ea66fbfe..8d4fbbf903 100644--- a/packages/core/tsconfig.build.json+++ b/packages/core/tsconfig.build.json@@ -9,15 +9,14 @@"emitDeclarationOnly": true,"sourceMap": false},- "include": [- "src"- ],+ "include": ["src"],"exclude": ["src/**/*.test.ts","src/**/*.test.tsx","src/**/*.doc.mjs","src/**/__tests__/**","src/**/*.perf.test.ts",- "src/**/*.perf.test.tsx"+ "src/**/*.perf.test.tsx",+ "src/**/*.bench.*"]}diff --git a/packages/richtext/package.json b/packages/richtext/package.jsonindex c743476312..50f16e55b8 100644--- a/packages/richtext/package.json+++ b/packages/richtext/package.json@@ -2,7 +2,7 @@"name": "@astryxdesign/richtext","displayName": "Rich Text","version": "0.7.6",- "description": "Astryx rich text — a Lexical-based rich text editor and viewer, styled with Astryx design tokens.",+ "description": "Astryx rich text \u2014 a Lexical-based rich text editor and viewer, styled with Astryx design tokens.","author": "Meta Open Source","license": "MIT","homepage": "https://github.com/meta/astryx#readme",@@ -34,7 +34,20 @@"dist","src","README.md",- "CHANGELOG.md"+ "CHANGELOG.md",+ "!**/*.test.*",+ "!**/*.spec.js",+ "!**/*.spec.jsx",+ "!**/*.spec.mjs",+ "!**/*.spec.cjs",+ "!**/*.spec.ts",+ "!**/*.spec.tsx",+ "!**/*.spec.mts",+ "!**/*.spec.cts",+ "!**/*.spec.d.ts",+ "!**/__tests__/**",+ "!**/__mocks__/**",+ "!**/*.bench.*"],"exports": {".": {diff --git a/packages/themes/butter/package.json b/packages/themes/butter/package.jsonindex 5e123cdd4b..992cae6600 100644--- a/packages/themes/butter/package.json+++ b/packages/themes/butter/package.json@@ -52,7 +52,20 @@"src","palette.config.json","fonts.css",- "fonts.css.d.ts"+ "fonts.css.d.ts",+ "!**/*.test.*",+ "!**/*.spec.js",+ "!**/*.spec.jsx",+ "!**/*.spec.mjs",+ "!**/*.spec.cjs",+ "!**/*.spec.ts",+ "!**/*.spec.tsx",+ "!**/*.spec.mts",+ "!**/*.spec.cts",+ "!**/*.spec.d.ts",+ "!**/__tests__/**",+ "!**/__mocks__/**",+ "!**/*.bench.*"],"scripts": {"build": "node ../../../scripts/clean-dist.mjs && node ../../../scripts/generate-butter-palette-refs.mjs --check && astryx theme build src/butterTheme.ts -o dist/theme.css --icons-specifier ./icons.mjs && tsup && tsc --project tsconfig.build.json && node ../../../scripts/check-fully-specified.mjs"diff --git a/packages/themes/chocolate/package.json b/packages/themes/chocolate/package.jsonindex e3816aecfe..f42948599e 100644--- a/packages/themes/chocolate/package.json+++ b/packages/themes/chocolate/package.json@@ -3,7 +3,7 @@"version": "0.7.6","displayName": "Chocolate Theme","private": false,- "description": "Warm chocolate theme for Astryx — rich brown palette with Fraunces headings, Albert Sans body, and Lucide icons",+ "description": "Warm chocolate theme for Astryx \u2014 rich brown palette with Fraunces headings, Albert Sans body, and Lucide icons","author": "Meta Open Source","license": "MIT","homepage": "https://github.com/meta/astryx#readme",@@ -51,7 +51,20 @@"dist","src","fonts.css",- "fonts.css.d.ts"+ "fonts.css.d.ts",+ "!**/*.test.*",+ "!**/*.spec.js",+ "!**/*.spec.jsx",+ "!**/*.spec.mjs",+ "!**/*.spec.cjs",+ "!**/*.spec.ts",+ "!**/*.spec.tsx",+ "!**/*.spec.mts",+ "!**/*.spec.cts",+ "!**/*.spec.d.ts",+ "!**/__tests__/**",+ "!**/__mocks__/**",+ "!**/*.bench.*"],"scripts": {"build": "node ../../../scripts/clean-dist.mjs && astryx theme build src/chocolateTheme.ts -o dist/theme.css --icons-specifier ./icons.mjs && tsup && tsc --project tsconfig.build.json && node ../../../scripts/check-fully-specified.mjs"diff --git a/packages/themes/gothic/package.json b/packages/themes/gothic/package.jsonindex 49a129fd3a..4f3956fc6b 100644--- a/packages/themes/gothic/package.json+++ b/packages/themes/gothic/package.json@@ -52,7 +52,20 @@"src","fonts.css","fonts.css.d.ts",- "palette.config.json"+ "palette.config.json",+ "!**/*.test.*",+ "!**/*.spec.js",+ "!**/*.spec.jsx",+ "!**/*.spec.mjs",+ "!**/*.spec.cjs",+ "!**/*.spec.ts",+ "!**/*.spec.tsx",+ "!**/*.spec.mts",+ "!**/*.spec.cts",+ "!**/*.spec.d.ts",+ "!**/__tests__/**",+ "!**/__mocks__/**",+ "!**/*.bench.*"],"scripts": {"build": "node ../../../scripts/clean-dist.mjs && node ../../../scripts/generate-gothic-palette-refs.mjs --check && astryx theme build src/gothicTheme.ts -o dist/theme.css --icons-specifier ./icons.mjs && tsup && tsc --project tsconfig.build.json && node ../../../scripts/check-fully-specified.mjs"diff --git a/packages/themes/matcha/package.json b/packages/themes/matcha/package.jsonindex 2fbfd726bb..609bbeb5ec 100644--- a/packages/themes/matcha/package.json+++ b/packages/themes/matcha/package.json@@ -51,7 +51,20 @@"src","fonts.css","fonts.css.d.ts",- "palette.config.json"+ "palette.config.json",+ "!**/*.test.*",+ "!**/*.spec.js",+ "!**/*.spec.jsx",+ "!**/*.spec.mjs",+ "!**/*.spec.cjs",+ "!**/*.spec.ts",+ "!**/*.spec.tsx",+ "!**/*.spec.mts",+ "!**/*.spec.cts",+ "!**/*.spec.d.ts",+ "!**/__tests__/**",+ "!**/__mocks__/**",+ "!**/*.bench.*"],"scripts": {"build": "node ../../../scripts/clean-dist.mjs && node ../../../scripts/generate-matcha-palette-refs.mjs --check && astryx theme build src/matchaTheme.ts -o dist/theme.css --icons-specifier ./icons.mjs && tsup && tsc --project tsconfig.build.json && node ../../../scripts/check-fully-specified.mjs"diff --git a/packages/themes/neutral/package.json b/packages/themes/neutral/package.jsonindex 8183a43977..e90ac4dbb0 100644--- a/packages/themes/neutral/package.json+++ b/packages/themes/neutral/package.json@@ -52,7 +52,20 @@"src","fonts.css","fonts.css.d.ts",- "palette.config.json"+ "palette.config.json",+ "!**/*.test.*",+ "!**/*.spec.js",+ "!**/*.spec.jsx",+ "!**/*.spec.mjs",+ "!**/*.spec.cjs",+ "!**/*.spec.ts",+ "!**/*.spec.tsx",+ "!**/*.spec.mts",+ "!**/*.spec.cts",+ "!**/*.spec.d.ts",+ "!**/__tests__/**",+ "!**/__mocks__/**",+ "!**/*.bench.*"],"scripts": {"build": "node ../../../scripts/clean-dist.mjs && node ../../../scripts/generate-neutral-palette-refs.mjs --check && astryx theme build src/neutralTheme.ts -o dist/theme.css --icons-specifier ./icons.mjs && tsup && tsc --project tsconfig.build.json && node ../../../scripts/check-fully-specified.mjs"diff --git a/packages/themes/stone/package.json b/packages/themes/stone/package.jsonindex 54f5b84c97..9cf03e621b 100644--- a/packages/themes/stone/package.json+++ b/packages/themes/stone/package.json@@ -52,7 +52,20 @@"src","fonts.css","fonts.css.d.ts",- "palette.config.json"+ "palette.config.json",+ "!**/*.test.*",+ "!**/*.spec.js",+ "!**/*.spec.jsx",+ "!**/*.spec.mjs",+ "!**/*.spec.cjs",+ "!**/*.spec.ts",+ "!**/*.spec.tsx",+ "!**/*.spec.mts",+ "!**/*.spec.cts",+ "!**/*.spec.d.ts",+ "!**/__tests__/**",+ "!**/__mocks__/**",+ "!**/*.bench.*"],"scripts": {"build": "node ../../../scripts/clean-dist.mjs && node ../../../scripts/generate-stone-palette-refs.mjs --check && astryx theme build src/stoneTheme.ts -o dist/theme.css --icons-specifier ./icons.mjs && tsup && tsc --project tsconfig.build.json && node ../../../scripts/check-fully-specified.mjs"diff --git a/packages/themes/y2k/package.json b/packages/themes/y2k/package.jsonindex e7f5b84a5a..3290e3b518 100644--- a/packages/themes/y2k/package.json+++ b/packages/themes/y2k/package.json@@ -52,7 +52,20 @@"src","palette.config.json","fonts.css",- "fonts.css.d.ts"+ "fonts.css.d.ts",+ "!**/*.test.*",+ "!**/*.spec.js",+ "!**/*.spec.jsx",+ "!**/*.spec.mjs",+ "!**/*.spec.cjs",+ "!**/*.spec.ts",+ "!**/*.spec.tsx",+ "!**/*.spec.mts",+ "!**/*.spec.cts",+ "!**/*.spec.d.ts",+ "!**/__tests__/**",+ "!**/__mocks__/**",+ "!**/*.bench.*"],"scripts": {"build": "node ../../../scripts/clean-dist.mjs && node ../../../scripts/generate-y2k-palette-refs.mjs --check && astryx theme build src/y2kTheme.ts -o dist/theme.css --icons-specifier ./icons.mjs && tsup && tsc --project tsconfig.build.json && node ../../../scripts/check-fully-specified.mjs"