|
24 | 24 | import * as fs from 'node:fs'; |
25 | 25 | import * as path from 'node:path'; |
26 | 26 | import {spawnSync} from 'node:child_process'; |
27 | | -import {builtinModules} from 'node:module'; |
28 | | -import {parse as parseModule} from '@babel/parser'; |
| 27 | +import {builtinModules, createRequire} from 'node:module'; |
29 | 28 | import {isValidSemver} from '../env/semver.mjs'; |
30 | 29 | import {findProjectCoreDir} from '../fs/paths.mjs'; |
31 | 30 | import {KNOWN_INTEGRATION_KEYS} from '../../authoring/integration/schema.mjs'; |
@@ -64,6 +63,18 @@ import { |
64 | 63 | import {discoverIntegrationDocs} from '../discovery/docs-discovery.mjs'; |
65 | 64 | import {discoverIntegrationThemes} from '../discovery/theme-discovery.mjs'; |
66 | 65 |
|
| 66 | +const requireFromHere = createRequire(import.meta.url); |
| 67 | + |
| 68 | +/** |
| 69 | + * `@babel/parser`'s parse, loaded on first use: most commands that load the |
| 70 | + * project's integrations never validate a contribution's source. |
| 71 | + * @param {string} source |
| 72 | + * @param {import('@babel/parser').ParserOptions} [options] |
| 73 | + */ |
| 74 | +function parseModule(source, options) { |
| 75 | + return requireFromHere('@babel/parser').parse(source, options); |
| 76 | +} |
| 77 | + |
67 | 78 | /** |
68 | 79 | * @typedef {import('./issue').AstryxIntegrationIssue} Issue |
69 | 80 | * @typedef {import('./integrations.mjs').LoadedIntegration} LoadedIntegration |
@@ -1647,15 +1658,17 @@ export async function componentExamplesCheck(integration) { |
1647 | 1658 | : negated != null && !outsideFiles(assetRel, packedFiles) |
1648 | 1659 | ? `${rel(template.filePath)}: loads ${assetRel}, which the \`files\` entry "${negated}" leaves out of the package, so the template breaks once installed. Fix: drop or narrow "${negated}" so it no longer matches ${assetRel}, and confirm with \`npm pack --dry-run\`.` |
1649 | 1660 | : Array.isArray(packedFiles) && |
1650 | | - (outsideFiles(assetRel, packedFiles) || |
1651 | | - !ignoreFilesFor(base, assetRel).some(file => file.includes('/'))) |
1652 | | - ? `${rel(template.filePath)}: loads ${assetRel}, which npm leaves out of the package by its \`files\` field, so the template breaks once installed. Fix: add "${folder}" to \`files\`, drop any \`!\` entry that excludes it, and confirm with \`npm pack --dry-run\`.` |
1653 | | - : ignoreFix( |
1654 | | - base, |
1655 | | - rel(template.filePath), |
1656 | | - assetRel, |
1657 | | - Array.isArray(packedFiles), |
1658 | | - ), |
| 1661 | + (outsideFiles(assetRel, packedFiles) || |
| 1662 | + !ignoreFilesFor(base, assetRel).some(file => |
| 1663 | + file.includes('/'), |
| 1664 | + )) |
| 1665 | + ? `${rel(template.filePath)}: loads ${assetRel}, which npm leaves out of the package by its \`files\` field, so the template breaks once installed. Fix: add "${folder}" to \`files\`, drop any \`!\` entry that excludes it, and confirm with \`npm pack --dry-run\`.` |
| 1666 | + : ignoreFix( |
| 1667 | + base, |
| 1668 | + rel(template.filePath), |
| 1669 | + assetRel, |
| 1670 | + Array.isArray(packedFiles), |
| 1671 | + ), |
1659 | 1672 | }); |
1660 | 1673 | } |
1661 | 1674 | } |
|
0 commit comments