From 418291b2f6b5e9a05f68c05288377c1ab254e146 Mon Sep 17 00:00:00 2001 From: Elizabeth Mitchell Date: Tue, 23 Jun 2026 16:56:01 -0700 Subject: [PATCH] chore: update and move generate-manifest script PiperOrigin-RevId: 936972062 --- package.json | 2 +- scripts/{ => analyzer}/generate-manifest.ts | 40 +++------------------ 2 files changed, 6 insertions(+), 36 deletions(-) rename scripts/{ => analyzer}/generate-manifest.ts (57%) diff --git a/package.json b/package.json index c7d5bb73dc..99ac3e0ee9 100644 --- a/package.json +++ b/package.json @@ -192,7 +192,7 @@ ] }, "build:manifest": { - "command": "node scripts/generate-manifest.js", + "command": "node scripts/analyzer/generate-manifest.js", "files": [ "**/*.ts" ], diff --git a/scripts/generate-manifest.ts b/scripts/analyzer/generate-manifest.ts similarity index 57% rename from scripts/generate-manifest.ts rename to scripts/analyzer/generate-manifest.ts index 5fb84b7cb6..66d4d92d2c 100644 --- a/scripts/generate-manifest.ts +++ b/scripts/analyzer/generate-manifest.ts @@ -4,12 +4,14 @@ * SPDX-License-Identifier: Apache-2.0 */ -import {Analyzer, type AbsolutePath} from '@lit-labs/analyzer'; +import { + createPackageAnalyzer, + type AbsolutePath, +} from '@lit-labs/analyzer/package-analyzer.js'; import {generateManifest} from '@lit-labs/gen-manifest'; import {writeFileTree} from '@lit-labs/gen-utils/lib/file-utils.js'; import type {Package as Manifest} from 'custom-elements-manifest'; import * as path from 'path'; -import ts from 'typescript'; const ROOT = process.cwd() as AbsolutePath; @@ -39,39 +41,7 @@ await writeFileTree(ROOT, { console.log('Generated custom-elements.json'); async function generateManifestFromTsconfig(basePath: AbsolutePath) { - // Create TS program - const formatHost: ts.FormatDiagnosticsHost = { - getCanonicalFileName: (fileName) => fileName, - getCurrentDirectory: () => ts.sys.getCurrentDirectory(), - getNewLine: () => ts.sys.newLine, - }; - const tsconfigPath = ts.findConfigFile(basePath, ts.sys.fileExists); - const configFile = ts.readConfigFile(tsconfigPath, ts.sys.readFile); - if (configFile.error) { - throw new Error(ts.formatDiagnostic(configFile.error, formatHost)); - } - const parsedConfig = ts.parseJsonConfigFileContent( - configFile.config, - ts.sys, - basePath, - ); - if (parsedConfig.errors.length) { - throw new Error(ts.formatDiagnostics(parsedConfig.errors, formatHost)); - } - const program = ts.createProgram({ - rootNames: parsedConfig.fileNames, - options: parsedConfig.options, - host: ts.createCompilerHost(parsedConfig.options, true), - }); - - // Run Lit analyzer - const analyzer = new Analyzer({ - typescript: ts, - getProgram: () => program, - fs: ts.sys, - path, - basePath, - }); + const analyzer = createPackageAnalyzer(basePath); const pkg = analyzer.getPackage(); const files = await generateManifest(pkg); const manifestContent = files['custom-elements.json'];