Merge remote-tracking branch 'upstream/main' into josh/desktop-wsl-parallel-backends
Resolve scripts/build-desktop-artifact.ts: keep both our WSL node-pty prebuild staging (decodeNodePtyManifest) and upstream's fff native binary staging (encodeStageWorkspaceConfig / DESKTOP_ASAR_UNPACK), and collapse the duplicated asarUnpack key the merge left behind into a single entry that unpacks the fff native binaries, the server bundle, and the full node_modules tree.
This commit is contained in:
commit
42e863ab74
261 files changed
+13650
-11179
No files matched your search
@@ -6,8 +6,11 @@ import * as Layer from "effect/Layer";
|
||||
import * as Option from "effect/Option";
|
||||
|
||||
import {
|
||||
createStageWorkspaceConfig,
|
||||
createStagePnpmConfig,
|
||||
DESKTOP_ASAR_UNPACK,
|
||||
resolveDesktopRuntimeDependencies,
|
||||
resolveFffNativeDependencies,
|
||||
resolveBuildOptions,
|
||||
resolveDesktopBuildIconAssets,
|
||||
resolveDesktopProductName,
|
||||
@@ -15,6 +18,7 @@ import {
|
||||
resolveGitHubPublishConfig,
|
||||
resolveMockUpdateServerPort,
|
||||
resolveMockUpdateServerUrl,
|
||||
STAGE_INSTALL_ARGS,
|
||||
} from "./build-desktop-artifact.ts";
|
||||
import { BRAND_ASSET_PATHS } from "./lib/brand-assets.ts";
|
||||
import { HostProcessArchitecture, HostProcessPlatform } from "@t3tools/shared/hostProcess";
|
||||
@@ -114,17 +118,20 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
|
||||
createStagePnpmConfig(
|
||||
{
|
||||
"@expo/[email protected]": "patches/@expo%[email protected]",
|
||||
"@ff-labs/[email protected]": "patches/@[email protected]",
|
||||
"@pierre/[email protected]": "patches/@pierre%[email protected]",
|
||||
"[email protected]": "patches/[email protected]",
|
||||
"[email protected]": "patches/[email protected]",
|
||||
},
|
||||
{
|
||||
"@ff-labs/fff-node": "0.9.4",
|
||||
"@pierre/diffs": "1.1.20",
|
||||
effect: "4.0.0-beta.73",
|
||||
},
|
||||
),
|
||||
{
|
||||
patchedDependencies: {
|
||||
"@ff-labs/[email protected]": "patches/@[email protected]",
|
||||
"@pierre/[email protected]": "patches/@pierre%[email protected]",
|
||||
"[email protected]": "patches/[email protected]",
|
||||
},
|
||||
@@ -142,6 +149,49 @@ it.layer(NodeServices.layer)("build-desktop-artifact", (it) => {
|
||||
);
|
||||
});
|
||||
|
||||
it("installs optional native dependencies for the target desktop architecture", () => {
|
||||
assert.deepStrictEqual(STAGE_INSTALL_ARGS, ["install", "--prod"]);
|
||||
assert.deepStrictEqual(createStageWorkspaceConfig("mac", "x64"), {
|
||||
supportedArchitectures: {
|
||||
os: ["darwin"],
|
||||
cpu: ["x64"],
|
||||
},
|
||||
});
|
||||
assert.deepStrictEqual(createStageWorkspaceConfig("win", "arm64"), {
|
||||
supportedArchitectures: {
|
||||
os: ["win32"],
|
||||
cpu: ["arm64"],
|
||||
},
|
||||
});
|
||||
assert.deepStrictEqual(createStageWorkspaceConfig("mac", "universal"), {
|
||||
supportedArchitectures: {
|
||||
os: ["darwin"],
|
||||
cpu: ["arm64", "x64"],
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("unpacks the fff shared library for filesystem and FFI access", () => {
|
||||
assert.deepStrictEqual(DESKTOP_ASAR_UNPACK, ["node_modules/@ff-labs/fff-bin-*/**/*"]);
|
||||
});
|
||||
|
||||
it("promotes target fff binaries to direct staged dependencies", () => {
|
||||
assert.deepStrictEqual(resolveFffNativeDependencies("mac", "arm64", "0.9.4"), {
|
||||
"@ff-labs/fff-bin-darwin-arm64": "0.9.4",
|
||||
});
|
||||
assert.deepStrictEqual(resolveFffNativeDependencies("mac", "universal", "0.9.4"), {
|
||||
"@ff-labs/fff-bin-darwin-arm64": "0.9.4",
|
||||
"@ff-labs/fff-bin-darwin-x64": "0.9.4",
|
||||
});
|
||||
assert.deepStrictEqual(resolveFffNativeDependencies("win", "x64", "0.9.4"), {
|
||||
"@ff-labs/fff-bin-win32-x64": "0.9.4",
|
||||
});
|
||||
assert.deepStrictEqual(resolveFffNativeDependencies("linux", "arm64", "0.9.4"), {
|
||||
"@ff-labs/fff-bin-linux-arm64-gnu": "0.9.4",
|
||||
"@ff-labs/fff-bin-linux-arm64-musl": "0.9.4",
|
||||
});
|
||||
});
|
||||
|
||||
it("falls back to the default mock update port when the configured port is blank", () => {
|
||||
assert.equal(resolveMockUpdateServerUrl(undefined), "http://localhost:3000");
|
||||
assert.equal(resolveMockUpdateServerUrl(4123), "http://localhost:4123");
|
||||
|
||||
@@ -38,6 +38,13 @@ const WorkspaceConfig = Schema.Struct({
|
||||
});
|
||||
type WorkspaceConfig = typeof WorkspaceConfig.Type;
|
||||
|
||||
const StageWorkspaceConfig = Schema.Struct({
|
||||
supportedArchitectures: Schema.Struct({
|
||||
os: Schema.Array(Schema.String),
|
||||
cpu: Schema.Array(Schema.String),
|
||||
}),
|
||||
});
|
||||
|
||||
const RepoRoot = Effect.service(Path.Path).pipe(
|
||||
Effect.flatMap((path) => path.fromFileUrl(new URL("..", import.meta.url))),
|
||||
);
|
||||
@@ -46,6 +53,7 @@ const decodeWorkspaceConfig = Schema.decodeEffect(fromYaml(WorkspaceConfig));
|
||||
const decodeNodePtyManifest = Schema.decodeUnknownEffect(
|
||||
Schema.fromJsonString(Schema.Struct({ version: Schema.String })),
|
||||
);
|
||||
const encodeStageWorkspaceConfig = Schema.encodeEffect(fromYaml(StageWorkspaceConfig));
|
||||
|
||||
const readWorkspaceConfig = Effect.fn("readWorkspaceConfig")(function* () {
|
||||
const fs = yield* FileSystem.FileSystem;
|
||||
@@ -287,6 +295,47 @@ interface StagePackageJson {
|
||||
};
|
||||
}
|
||||
|
||||
export const STAGE_INSTALL_ARGS = ["install", "--prod"] as const;
|
||||
export const DESKTOP_ASAR_UNPACK = ["node_modules/@ff-labs/fff-bin-*/**/*"] as const;
|
||||
|
||||
export function resolveFffNativeDependencies(
|
||||
platform: typeof BuildPlatform.Type,
|
||||
arch: typeof BuildArch.Type,
|
||||
version: string,
|
||||
): Record<string, string> {
|
||||
const architectures = arch === "universal" ? (["arm64", "x64"] as const) : [arch];
|
||||
|
||||
if (platform === "mac") {
|
||||
return Object.fromEntries(
|
||||
architectures.map((architecture) => [`@ff-labs/fff-bin-darwin-${architecture}`, version]),
|
||||
);
|
||||
}
|
||||
|
||||
if (platform === "win") {
|
||||
return Object.fromEntries(
|
||||
architectures.map((architecture) => [`@ff-labs/fff-bin-win32-${architecture}`, version]),
|
||||
);
|
||||
}
|
||||
|
||||
return Object.fromEntries(
|
||||
architectures.flatMap((architecture) =>
|
||||
["gnu", "musl"].map((libc) => [`@ff-labs/fff-bin-linux-${architecture}-${libc}`, version]),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
export function createStageWorkspaceConfig(
|
||||
platform: typeof BuildPlatform.Type,
|
||||
arch: typeof BuildArch.Type,
|
||||
): typeof StageWorkspaceConfig.Type {
|
||||
return {
|
||||
supportedArchitectures: {
|
||||
os: [platform === "mac" ? "darwin" : platform === "win" ? "win32" : "linux"],
|
||||
cpu: arch === "universal" ? ["arm64", "x64"] : [arch],
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
export function createStagePnpmConfig(
|
||||
patchedDependencies: Record<string, string>,
|
||||
dependencies: Record<string, unknown>,
|
||||
@@ -728,10 +777,11 @@ const createBuildConfig = Effect.fn("createBuildConfig")(function* (
|
||||
// them, so unpacking just the bundle + node-pty isn't enough — the Linux Node
|
||||
// fails with ERR_MODULE_NOT_FOUND (e.g. "Cannot find package 'effect'") before
|
||||
// it even reaches node-pty. Unpack the server bundle AND the whole
|
||||
// node_modules tree so every import resolves. The Windows primary keeps
|
||||
// reading the same files through the asar (transparently redirected to the
|
||||
// unpacked copy), so there's no duplication.
|
||||
asarUnpack: ["apps/server/dist/**", "**/node_modules/**"],
|
||||
// node_modules tree so every import resolves (this also covers the fff native
|
||||
// binaries in DESKTOP_ASAR_UNPACK). The Windows primary keeps reading the same
|
||||
// files through the asar (transparently redirected to the unpacked copy), so
|
||||
// there's no duplication.
|
||||
asarUnpack: [...DESKTOP_ASAR_UNPACK, "apps/server/dist/**", "**/node_modules/**"],
|
||||
};
|
||||
const updateChannel = resolveDesktopUpdateChannel(version);
|
||||
const publishConfig = yield* resolveGitHubPublishConfig(updateChannel);
|
||||
@@ -1005,6 +1055,11 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
|
||||
const stageDependencies = {
|
||||
...resolvedServerDependencies,
|
||||
...resolvedDesktopRuntimeDependencies,
|
||||
...resolveFffNativeDependencies(
|
||||
options.platform,
|
||||
options.arch,
|
||||
serverPackageJson.dependencies["@ff-labs/fff-node"],
|
||||
),
|
||||
};
|
||||
const stagePnpmConfig = createStagePnpmConfig(workspacePatchedDependencies, stageDependencies);
|
||||
const stagePackageJson: StagePackageJson = {
|
||||
@@ -1035,19 +1090,25 @@ const buildDesktopArtifact = Effect.fn("buildDesktopArtifact")(function* (
|
||||
|
||||
const stagePackageJsonString = yield* encodeJsonString(stagePackageJson);
|
||||
yield* fs.writeFileString(path.join(stageAppDir, "package.json"), `${stagePackageJsonString}\n`);
|
||||
const stageWorkspaceConfig = createStageWorkspaceConfig(options.platform, options.arch);
|
||||
const stageWorkspaceConfigString = yield* encodeStageWorkspaceConfig(stageWorkspaceConfig);
|
||||
yield* fs.writeFileString(
|
||||
path.join(stageAppDir, "pnpm-workspace.yaml"),
|
||||
stageWorkspaceConfigString,
|
||||
);
|
||||
|
||||
if (Object.keys(workspacePatchedDependencies).length > 0) {
|
||||
yield* fs.copy(path.join(repoRoot, "patches"), path.join(stageAppDir, "patches"));
|
||||
}
|
||||
|
||||
yield* Effect.log("[desktop-artifact] Installing staged production dependencies...");
|
||||
const installCommand = yield* resolveSpawnCommand("vp", ["install", "--prod", "--no-optional"]);
|
||||
const installCommand = yield* resolveSpawnCommand("vp", [...STAGE_INSTALL_ARGS]);
|
||||
yield* runCommand(
|
||||
ChildProcess.make(installCommand.command, installCommand.args, {
|
||||
cwd: stageAppDir,
|
||||
shell: installCommand.shell,
|
||||
}),
|
||||
{ label: "vp install --prod --no-optional", verbose: options.verbose },
|
||||
{ label: "vp install --prod", verbose: options.verbose },
|
||||
);
|
||||
|
||||
// WSL is Windows-only, so only the Windows artifact carries the Linux backend
|
||||
|
||||
@@ -33,6 +33,12 @@ describe("loadRepoEnv", () => {
|
||||
expect(env.EXPO_PUBLIC_OTLP_TRACES_URL).toBeUndefined();
|
||||
expect(env.EXPO_PUBLIC_OTLP_TRACES_DATASET).toBeUndefined();
|
||||
expect(env.EXPO_PUBLIC_OTLP_TRACES_TOKEN).toBeUndefined();
|
||||
expect(env.T3CODE_RELAY_CLIENT_OTLP_TRACES_URL).toBeUndefined();
|
||||
expect(env.T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET).toBeUndefined();
|
||||
expect(env.T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN).toBeUndefined();
|
||||
expect(env.VITE_RELAY_OTLP_TRACES_URL).toBeUndefined();
|
||||
expect(env.VITE_RELAY_OTLP_TRACES_DATASET).toBeUndefined();
|
||||
expect(env.VITE_RELAY_OTLP_TRACES_TOKEN).toBeUndefined();
|
||||
});
|
||||
|
||||
it("applies process, root local, and root precedence in that order", () => {
|
||||
@@ -91,6 +97,29 @@ describe("loadRepoEnv", () => {
|
||||
mobileOtlpTracesUrl: "https://api.axiom.co/v1/traces",
|
||||
mobileOtlpTracesDataset: "mobile-traces",
|
||||
mobileOtlpTracesToken: "mobile-token",
|
||||
relayClientOtlpTracesUrl: undefined,
|
||||
relayClientOtlpTracesDataset: undefined,
|
||||
relayClientOtlpTracesToken: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it("projects canonical relay client tracing values to web build aliases", () => {
|
||||
expect(
|
||||
loadRepoEnv({
|
||||
baseEnv: {
|
||||
T3CODE_RELAY_CLIENT_OTLP_TRACES_URL: "https://api.axiom.co/v1/traces",
|
||||
T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET: "relay-client-traces",
|
||||
T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN: "relay-client-token",
|
||||
},
|
||||
repoRoot: makeTemporaryDirectory(),
|
||||
}),
|
||||
).toEqual({
|
||||
T3CODE_RELAY_CLIENT_OTLP_TRACES_URL: "https://api.axiom.co/v1/traces",
|
||||
T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET: "relay-client-traces",
|
||||
T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN: "relay-client-token",
|
||||
VITE_RELAY_OTLP_TRACES_URL: "https://api.axiom.co/v1/traces",
|
||||
VITE_RELAY_OTLP_TRACES_DATASET: "relay-client-traces",
|
||||
VITE_RELAY_OTLP_TRACES_TOKEN: "relay-client-token",
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -12,6 +12,9 @@ export interface T3CodePublicConfig {
|
||||
readonly mobileOtlpTracesUrl: string | undefined;
|
||||
readonly mobileOtlpTracesDataset: string | undefined;
|
||||
readonly mobileOtlpTracesToken: string | undefined;
|
||||
readonly relayClientOtlpTracesUrl: string | undefined;
|
||||
readonly relayClientOtlpTracesDataset: string | undefined;
|
||||
readonly relayClientOtlpTracesToken: string | undefined;
|
||||
}
|
||||
|
||||
type Environment = Readonly<Record<string, string | undefined>>;
|
||||
@@ -78,6 +81,24 @@ export function loadRepoEnv({
|
||||
EXPO_PUBLIC_OTLP_TRACES_TOKEN: config.mobileOtlpTracesToken,
|
||||
}
|
||||
: {}),
|
||||
...(config.relayClientOtlpTracesUrl
|
||||
? {
|
||||
T3CODE_RELAY_CLIENT_OTLP_TRACES_URL: config.relayClientOtlpTracesUrl,
|
||||
VITE_RELAY_OTLP_TRACES_URL: config.relayClientOtlpTracesUrl,
|
||||
}
|
||||
: {}),
|
||||
...(config.relayClientOtlpTracesDataset
|
||||
? {
|
||||
T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET: config.relayClientOtlpTracesDataset,
|
||||
VITE_RELAY_OTLP_TRACES_DATASET: config.relayClientOtlpTracesDataset,
|
||||
}
|
||||
: {}),
|
||||
...(config.relayClientOtlpTracesToken
|
||||
? {
|
||||
T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN: config.relayClientOtlpTracesToken,
|
||||
VITE_RELAY_OTLP_TRACES_TOKEN: config.relayClientOtlpTracesToken,
|
||||
}
|
||||
: {}),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -112,6 +133,21 @@ export function resolvePublicConfig(...sources: readonly Environment[]): T3CodeP
|
||||
"T3CODE_MOBILE_OTLP_TRACES_TOKEN",
|
||||
"EXPO_PUBLIC_OTLP_TRACES_TOKEN",
|
||||
),
|
||||
relayClientOtlpTracesUrl: firstNonEmpty(
|
||||
sources,
|
||||
"T3CODE_RELAY_CLIENT_OTLP_TRACES_URL",
|
||||
"VITE_RELAY_OTLP_TRACES_URL",
|
||||
),
|
||||
relayClientOtlpTracesDataset: firstNonEmpty(
|
||||
sources,
|
||||
"T3CODE_RELAY_CLIENT_OTLP_TRACES_DATASET",
|
||||
"VITE_RELAY_OTLP_TRACES_DATASET",
|
||||
),
|
||||
relayClientOtlpTracesToken: firstNonEmpty(
|
||||
sources,
|
||||
"T3CODE_RELAY_CLIENT_OTLP_TRACES_TOKEN",
|
||||
"VITE_RELAY_OTLP_TRACES_TOKEN",
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ const workspaceFiles = [
|
||||
"apps/web/package.json",
|
||||
"apps/mobile/package.json",
|
||||
"apps/mobile/deps/react-native-nitro-markdown-0.5.0.tgz",
|
||||
"apps/mobile/modules/t3-markdown-text/package.json",
|
||||
"apps/mobile/modules/t3-review-diff/package.json",
|
||||
"apps/mobile/modules/t3-terminal/package.json",
|
||||
"apps/marketing/package.json",
|
||||
|
||||
@@ -1,153 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import vm from "node:vm";
|
||||
import { execFile } from "node:child_process";
|
||||
import { promisify } from "node:util";
|
||||
|
||||
const execFileAsync = promisify(execFile);
|
||||
|
||||
const VERSION = process.argv[2] ?? "12.17.0";
|
||||
const VERSION_TAG = `v${VERSION}`;
|
||||
const VSIX_URL = `https://open-vsx.org/api/vscode-icons-team/vscode-icons/${VERSION}/file/vscode-icons-team.vscode-icons-${VERSION}.vsix`;
|
||||
const LANGUAGES_URL = `https://raw.githubusercontent.com/vscode-icons/vscode-icons/${VERSION_TAG}/src/iconsManifest/languages.ts`;
|
||||
|
||||
const REPO_ROOT = process.cwd();
|
||||
const MANIFEST_PATH = path.join(REPO_ROOT, "apps/web/src/vscode-icons-manifest.json");
|
||||
const ASSOCIATIONS_PATH = path.join(
|
||||
REPO_ROOT,
|
||||
"apps/web/src/vscode-icons-language-associations.json",
|
||||
);
|
||||
|
||||
function normalizeExtension(value) {
|
||||
return value.trim().toLowerCase().replace(/^\./, "");
|
||||
}
|
||||
|
||||
function normalizeFileName(value) {
|
||||
return value.trim().toLowerCase();
|
||||
}
|
||||
|
||||
function putIfAbsent(target, key, value) {
|
||||
if (!(key in target)) {
|
||||
target[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
async function downloadVsix(tmpDir) {
|
||||
const vsixPath = path.join(tmpDir, `vscode-icons-${VERSION}.vsix`);
|
||||
const response = await fetch(VSIX_URL);
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to download VSIX: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
const bytes = Buffer.from(await response.arrayBuffer());
|
||||
await fs.writeFile(vsixPath, bytes);
|
||||
return vsixPath;
|
||||
}
|
||||
|
||||
async function extractManifestFromVsix(vsixPath) {
|
||||
const { stdout } = await execFileAsync("unzip", [
|
||||
"-p",
|
||||
vsixPath,
|
||||
"extension/dist/src/vsicons-icon-theme.json",
|
||||
]);
|
||||
if (!stdout || stdout.trim().length === 0) {
|
||||
throw new Error("Could not extract vsicons-icon-theme.json from VSIX");
|
||||
}
|
||||
return JSON.parse(stdout);
|
||||
}
|
||||
|
||||
async function loadLanguagesCollection() {
|
||||
const response = await fetch(LANGUAGES_URL);
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch languages.ts: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
const rawSource = await response.text();
|
||||
const source = rawSource
|
||||
.replace(/^import[^;]+;\s*/gm, "")
|
||||
.replace(/export const languages(?:\s*:\s*[^=]+)?\s*=/, "const languages =")
|
||||
.replace(/\}\s*satisfies\s*Record<[^;]+>;/, "};");
|
||||
|
||||
const context = {};
|
||||
vm.createContext(context);
|
||||
vm.runInContext(`${source}\n;globalThis.__languages = languages;`, context);
|
||||
const languages = context.__languages;
|
||||
if (!languages || typeof languages !== "object") {
|
||||
throw new Error("Failed to parse languages.ts into a collection");
|
||||
}
|
||||
return languages;
|
||||
}
|
||||
|
||||
function buildLanguageAssociations(manifest, languages) {
|
||||
const availableLanguageIds = new Set(Object.keys(manifest.languageIds ?? {}));
|
||||
const extensionToLanguageId = {};
|
||||
const fileNameToLanguageId = {};
|
||||
|
||||
for (const entry of Object.values(languages)) {
|
||||
if (!entry || typeof entry !== "object") continue;
|
||||
const idsRaw = entry.ids;
|
||||
const ids = Array.isArray(idsRaw) ? idsRaw : [idsRaw];
|
||||
const knownExtensions = Array.isArray(entry.knownExtensions) ? entry.knownExtensions : [];
|
||||
const knownFilenames = Array.isArray(entry.knownFilenames) ? entry.knownFilenames : [];
|
||||
|
||||
for (const idValue of ids) {
|
||||
if (typeof idValue !== "string") continue;
|
||||
const languageId = idValue.trim();
|
||||
if (languageId.length === 0) continue;
|
||||
if (!availableLanguageIds.has(languageId)) continue;
|
||||
|
||||
for (const extensionValue of knownExtensions) {
|
||||
if (typeof extensionValue !== "string") continue;
|
||||
const extension = normalizeExtension(extensionValue);
|
||||
if (extension.length === 0) continue;
|
||||
putIfAbsent(extensionToLanguageId, extension, languageId);
|
||||
}
|
||||
|
||||
for (const fileNameValue of knownFilenames) {
|
||||
if (typeof fileNameValue !== "string") continue;
|
||||
const fileName = normalizeFileName(fileNameValue);
|
||||
if (fileName.length === 0) continue;
|
||||
putIfAbsent(fileNameToLanguageId, fileName, languageId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
version: VERSION,
|
||||
source: LANGUAGES_URL,
|
||||
generatedAt: new Date().toISOString(),
|
||||
extensionToLanguageId,
|
||||
fileNameToLanguageId,
|
||||
};
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "t3-vscode-icons-sync-"));
|
||||
try {
|
||||
const vsixPath = await downloadVsix(tmpDir);
|
||||
const manifest = await extractManifestFromVsix(vsixPath);
|
||||
const languages = await loadLanguagesCollection();
|
||||
const associations = buildLanguageAssociations(manifest, languages);
|
||||
|
||||
await fs.writeFile(MANIFEST_PATH, `${JSON.stringify(manifest)}\n`, "utf8");
|
||||
await fs.writeFile(ASSOCIATIONS_PATH, `${JSON.stringify(associations)}\n`, "utf8");
|
||||
|
||||
process.stdout.write(
|
||||
[
|
||||
`Synced vscode-icons ${VERSION}`,
|
||||
`manifest: ${MANIFEST_PATH}`,
|
||||
`language associations: ${ASSOCIATIONS_PATH}`,
|
||||
`extension mappings: ${Object.keys(associations.extensionToLanguageId).length}`,
|
||||
`filename mappings: ${Object.keys(associations.fileNameToLanguageId).length}`,
|
||||
].join("\n") + "\n",
|
||||
);
|
||||
} finally {
|
||||
await fs.rm(tmpDir, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
process.stderr.write(`${error instanceof Error ? error.message : String(error)}\n`);
|
||||
process.exit(1);
|
||||
});
|
||||
Reference in new issue
Block a user