From bed20838aa50d248fb466f3e8c314e5b359cc604 Mon Sep 17 00:00:00 2001 From: jycouet Date: Sat, 4 Apr 2026 12:47:59 +0200 Subject: [PATCH 1/2] refactor: loadFile/saveFile/loadPackageJson; trim workspace addon paths - sv-utils: add loadFile, saveFile, loadPackageJson; deprecate readFile, writeFile, getPackageJson; remove installPackages (logic lives in sv engine). - sv: inline updatePackages in engine; use new helpers; drop deprecated workspace.file paths; addons use string literals; remove stale @deprecated on processors/create exports. - Regenerate api-surface snapshots. Made-with: Cursor --- packages/sv-utils/api-surface.md | 34 ++++---- packages/sv-utils/src/files.ts | 92 ++++++++------------- packages/sv-utils/src/index.ts | 16 ++-- packages/sv/api-surface.md | 3 - packages/sv/src/addons/drizzle.ts | 2 +- packages/sv/src/addons/eslint.ts | 6 +- packages/sv/src/addons/prettier.ts | 8 +- packages/sv/src/addons/sveltekit-adapter.ts | 4 +- packages/sv/src/addons/tailwindcss.ts | 6 +- packages/sv/src/cli/create.ts | 4 +- packages/sv/src/core/engine.ts | 43 ++++++++-- packages/sv/src/core/processors.ts | 2 - packages/sv/src/core/workspace.ts | 27 ++---- packages/sv/src/create/index.ts | 1 - packages/sv/src/index.ts | 2 - 15 files changed, 119 insertions(+), 131 deletions(-) diff --git a/packages/sv-utils/api-surface.md b/packages/sv-utils/api-surface.md index 75a9b392c..dba9a2978 100644 --- a/packages/sv-utils/api-surface.md +++ b/packages/sv-utils/api-surface.md @@ -1257,22 +1257,6 @@ type Package = { keywords?: string[]; workspaces?: string[]; }; -declare function getPackageJson(cwd: string): { - source: string; - data: Package; - generateCode: () => string; -}; -declare function readFile(cwd: string, filePath: string): string; -declare function fileExists(cwd: string, filePath: string): boolean; -declare function writeFile(cwd: string, filePath: string, content: string): void; -/** -* @deprecated Internal to sv — merged into `package.json` by the add-on runner only. Will be removed from the public API in a future version. -*/ -declare function installPackages(dependencies: Array<{ - pkg: string; - version: string; - dev: boolean; -}>, cwd: string): string; declare const commonFilePaths: { readonly packageJson: "package.json"; readonly svelteConfig: "svelte.config.js"; @@ -1282,6 +1266,22 @@ declare const commonFilePaths: { readonly viteConfig: "vite.config.js"; readonly viteConfigTS: "vite.config.ts"; }; +declare function fileExists(cwd: string, filePath: string): boolean; + +declare function loadFile(cwd: string, filePath: string): string; + +declare function saveFile(cwd: string, filePath: string, content: string): void; +declare function loadPackageJson(cwd: string): { + source: string; + data: Package; + generateCode: () => string; +}; +/** @deprecated Use `loadFile` instead. */ +declare const readFile: typeof loadFile; +/** @deprecated Use `saveFile` instead. */ +declare const writeFile: typeof saveFile; +/** @deprecated Use `loadPackageJson` instead. */ +declare const getPackageJson: typeof loadPackageJson; type ColorInput = string | string[]; declare const color: { addon: (str: ColorInput) => string; @@ -1309,5 +1309,5 @@ declare const parse: { toml: typeof parseToml; yaml: typeof parseYaml; }; -export { AGENTS, type AgentName, type estree as AstTypes, COMMANDS, type Comments, type Package, type SvelteAst, type TransformFn, index_d_exports as Walker, color, commonFilePaths, constructCommand, createPrinter, index_d_exports$1 as css, dedent, detect, downloadJson, fileExists, getPackageJson, index_d_exports$2 as html, installPackages, isVersionUnsupportedBelow, index_d_exports$3 as js, json_d_exports as json, parse, readFile, resolveCommand, resolveCommandArray, sanitizeName, splitVersion, index_d_exports$4 as svelte, text_d_exports as text, transforms, writeFile }; +export { AGENTS, type AgentName, type estree as AstTypes, COMMANDS, type Comments, type Package, type SvelteAst, type TransformFn, index_d_exports as Walker, color, commonFilePaths, constructCommand, createPrinter, index_d_exports$1 as css, dedent, detect, downloadJson, fileExists, getPackageJson, index_d_exports$2 as html, isVersionUnsupportedBelow, index_d_exports$3 as js, json_d_exports as json, loadFile, loadPackageJson, parse, readFile, resolveCommand, resolveCommandArray, sanitizeName, saveFile, splitVersion, index_d_exports$4 as svelte, text_d_exports as text, transforms, writeFile }; ``` diff --git a/packages/sv-utils/src/files.ts b/packages/sv-utils/src/files.ts index 8212a637b..540e80602 100644 --- a/packages/sv-utils/src/files.ts +++ b/packages/sv-utils/src/files.ts @@ -13,22 +13,23 @@ export type Package = { workspaces?: string[]; }; -export function getPackageJson(cwd: string): { - source: string; - data: Package; - generateCode: () => string; -} { - const packageText = readFile(cwd, commonFilePaths.packageJson); - if (!packageText) { - const pkgPath = path.join(cwd, commonFilePaths.packageJson); - throw new Error(`Invalid workspace: missing '${pkgPath}'`); - } +export const commonFilePaths = { + packageJson: 'package.json', + svelteConfig: 'svelte.config.js', + svelteConfigTS: 'svelte.config.ts', + jsconfig: 'jsconfig.json', + tsconfig: 'tsconfig.json', + viteConfig: 'vite.config.js', + viteConfigTS: 'vite.config.ts' +} as const; - const { data, generateCode } = parseJson(packageText); - return { source: packageText, data: data as Package, generateCode }; +export function fileExists(cwd: string, filePath: string): boolean { + const fullFilePath = path.resolve(cwd, filePath); + return fs.existsSync(fullFilePath); } -export function readFile(cwd: string, filePath: string): string { +/** Synchronous load of a workspace-relative file as UTF-8 text; missing files yield `''`. */ +export function loadFile(cwd: string, filePath: string): string { const fullFilePath = path.resolve(cwd, filePath); if (!fileExists(cwd, filePath)) { @@ -40,12 +41,8 @@ export function readFile(cwd: string, filePath: string): string { return text; } -export function fileExists(cwd: string, filePath: string): boolean { - const fullFilePath = path.resolve(cwd, filePath); - return fs.existsSync(fullFilePath); -} - -export function writeFile(cwd: string, filePath: string, content: string): void { +/** Synchronous write of a workspace-relative file (creates parent dirs). */ +export function saveFile(cwd: string, filePath: string, content: string): void { const fullFilePath = path.resolve(cwd, filePath); const fullDirectoryPath = path.dirname(fullFilePath); @@ -58,47 +55,26 @@ export function writeFile(cwd: string, filePath: string, content: string): void fs.writeFileSync(fullFilePath, content, 'utf8'); } -/** - * @deprecated Internal to sv — merged into `package.json` by the add-on runner only. Will be removed from the public API in a future version. - */ -export function installPackages( - dependencies: Array<{ pkg: string; version: string; dev: boolean }>, - cwd: string -): string { - const { data, generateCode } = getPackageJson(cwd); - - for (const dependency of dependencies) { - if (dependency.dev) { - data.devDependencies ??= {}; - data.devDependencies[dependency.pkg] = dependency.version; - } else { - data.dependencies ??= {}; - data.dependencies[dependency.pkg] = dependency.version; - } +export function loadPackageJson(cwd: string): { + source: string; + data: Package; + generateCode: () => string; +} { + const packageText = loadFile(cwd, commonFilePaths.packageJson); + if (!packageText) { + const pkgPath = path.join(cwd, commonFilePaths.packageJson); + throw new Error(`Invalid workspace: missing '${pkgPath}'`); } - if (data.dependencies) data.dependencies = alphabetizeProperties(data.dependencies); - if (data.devDependencies) data.devDependencies = alphabetizeProperties(data.devDependencies); - - writeFile(cwd, commonFilePaths.packageJson, generateCode()); - return commonFilePaths.packageJson; + const { data, generateCode } = parseJson(packageText); + return { source: packageText, data: data as Package, generateCode }; } -function alphabetizeProperties(obj: Record) { - const orderedObj: Record = {}; - const sortedEntries = Object.entries(obj).sort(([a], [b]) => a.localeCompare(b)); - for (const [key, value] of sortedEntries) { - orderedObj[key] = value; - } - return orderedObj; -} +/** @deprecated Use {@link loadFile} instead. */ +export const readFile: typeof loadFile = loadFile; -export const commonFilePaths = { - packageJson: 'package.json', - svelteConfig: 'svelte.config.js', - svelteConfigTS: 'svelte.config.ts', - jsconfig: 'jsconfig.json', - tsconfig: 'tsconfig.json', - viteConfig: 'vite.config.js', - viteConfigTS: 'vite.config.ts' -} as const; +/** @deprecated Use {@link saveFile} instead. */ +export const writeFile: typeof saveFile = saveFile; + +/** @deprecated Use {@link loadPackageJson} instead. */ +export const getPackageJson: typeof loadPackageJson = loadPackageJson; diff --git a/packages/sv-utils/src/index.ts b/packages/sv-utils/src/index.ts index 965a974fd..37db2b10b 100644 --- a/packages/sv-utils/src/index.ts +++ b/packages/sv-utils/src/index.ts @@ -77,18 +77,22 @@ export { createPrinter } from './utils.ts'; export { sanitizeName } from './sanitize.ts'; export { downloadJson } from './downloadJson.ts'; -// File system helpers +// File system helpers (sync, workspace-relative paths) export { commonFilePaths, fileExists, - getPackageJson, - readFile, - writeFile, + loadFile, + loadPackageJson, + saveFile, type Package } from './files.ts'; -/** @deprecated Internal to sv — will be removed from the public API in a future version. */ -export { installPackages } from './files.ts'; +/** @deprecated Use {@link loadFile} instead. */ +export { readFile } from './files.ts'; +/** @deprecated Use {@link saveFile} instead. */ +export { writeFile } from './files.ts'; +/** @deprecated Use {@link loadPackageJson} instead. */ +export { getPackageJson } from './files.ts'; // Terminal styling export { color } from './color.ts'; diff --git a/packages/sv/api-surface.md b/packages/sv/api-surface.md index ab42a9bb4..5651f3483 100644 --- a/packages/sv/api-surface.md +++ b/packages/sv/api-surface.md @@ -13,14 +13,11 @@ type Options = { template: TemplateType; types: LanguageType; }; -/** @deprecated Use `create({ cwd, name, template, types })` instead. */ declare function create(cwd: string, options: Omit): void; declare function create(options: Options): void; -/** @deprecated Unused type, will be removed in a future version. */ type FileEditor = Workspace & { content: string; }; -/** @deprecated Unused type, will be removed in a future version. */ type FileType = { name: (options: Workspace) => string; condition?: ConditionDefinition; diff --git a/packages/sv/src/addons/drizzle.ts b/packages/sv/src/addons/drizzle.ts index f807f11cc..c8bd70d79 100644 --- a/packages/sv/src/addons/drizzle.ts +++ b/packages/sv/src/addons/drizzle.ts @@ -206,7 +206,7 @@ export default defineAddon({ const hasPrettier = Boolean(dependencyVersion('prettier')); if (hasPrettier) { sv.file( - file.prettierignore, + '.prettierignore', transforms.text(({ content, text }) => text.upsert(content, '/drizzle/')) ); } diff --git a/packages/sv/src/addons/eslint.ts b/packages/sv/src/addons/eslint.ts index 58b1d00a4..4d6197676 100644 --- a/packages/sv/src/addons/eslint.ts +++ b/packages/sv/src/addons/eslint.ts @@ -31,7 +31,7 @@ export default defineAddon({ ); sv.file( - file.eslintConfig, + 'eslint.config.js', transforms.script(({ ast, comments, js }) => { const eslintConfigs: Array = []; js.imports.addDefault(ast, { from: './svelte.config.js', as: 'svelteConfig' }); @@ -156,14 +156,14 @@ export default defineAddon({ ); sv.file( - file.vscodeExtensions, + '.vscode/extensions.json', transforms.json(({ data, json }) => { json.arrayUpsert(data, 'recommendations', 'dbaeumer.vscode-eslint'); }) ); if (prettierInstalled) { - sv.file(file.eslintConfig, addEslintConfigPrettier); + sv.file('eslint.config.js', addEslintConfigPrettier); } } }); diff --git a/packages/sv/src/addons/prettier.ts b/packages/sv/src/addons/prettier.ts index eea8f1252..69629f2cc 100644 --- a/packages/sv/src/addons/prettier.ts +++ b/packages/sv/src/addons/prettier.ts @@ -16,7 +16,7 @@ export default defineAddon({ sv.devDependency('prettier-plugin-svelte', '^3.4.1'); sv.file( - file.prettierignore, + '.prettierignore', transforms.text(({ content }) => { if (content) return false; return dedent` @@ -34,7 +34,7 @@ export default defineAddon({ ); sv.file( - file.prettierrc, + '.prettierrc', transforms.json( ({ data, json }) => { if (Object.keys(data).length === 0) { @@ -82,7 +82,7 @@ export default defineAddon({ ); sv.file( - file.vscodeExtensions, + '.vscode/extensions.json', transforms.json(({ data, json }) => { json.arrayUpsert(data, 'recommendations', 'esbenp.prettier-vscode'); }) @@ -98,7 +98,7 @@ export default defineAddon({ if (eslintInstalled) { sv.devDependency('eslint-config-prettier', '^10.1.8'); - sv.file(file.eslintConfig, addEslintConfigPrettier); + sv.file('eslint.config.js', addEslintConfigPrettier); } } }); diff --git a/packages/sv/src/addons/sveltekit-adapter.ts b/packages/sv/src/addons/sveltekit-adapter.ts index dd3f9a3a2..739e89896 100644 --- a/packages/sv/src/addons/sveltekit-adapter.ts +++ b/packages/sv/src/addons/sveltekit-adapter.ts @@ -4,7 +4,7 @@ import { text, transforms, fileExists, - getPackageJson, + loadPackageJson, sanitizeName } from '@sveltejs/sv-utils'; import { defineAddon, defineAddonOptions } from '../core/config.ts'; @@ -140,7 +140,7 @@ export default defineAddon({ } if (!data.name) { - const pkg = getPackageJson(cwd); + const pkg = loadPackageJson(cwd); data.name = sanitizeName(pkg.data.name, 'wrangler'); } diff --git a/packages/sv/src/addons/tailwindcss.ts b/packages/sv/src/addons/tailwindcss.ts index 5dd26ce2c..97deeac55 100644 --- a/packages/sv/src/addons/tailwindcss.ts +++ b/packages/sv/src/addons/tailwindcss.ts @@ -106,7 +106,7 @@ export default defineAddon({ } sv.file( - file.vscodeSettings, + '.vscode/settings.json', transforms.json(({ data }) => { data['files.associations'] ??= {}; data['files.associations']['*.css'] = 'tailwindcss'; @@ -114,7 +114,7 @@ export default defineAddon({ ); sv.file( - file.vscodeExtensions, + '.vscode/extensions.json', transforms.json(({ data, json }) => { json.arrayUpsert(data, 'recommendations', 'bradlc.vscode-tailwindcss'); }) @@ -122,7 +122,7 @@ export default defineAddon({ if (prettierInstalled) { sv.file( - file.prettierrc, + '.prettierrc', transforms.json(({ data, json }) => { json.arrayUpsert(data, 'plugins', 'prettier-plugin-tailwindcss'); data.tailwindStylesheet ??= file.getRelative({ to: file.stylesheet }); diff --git a/packages/sv/src/cli/create.ts b/packages/sv/src/cli/create.ts index 8d0722015..c7888c575 100644 --- a/packages/sv/src/cli/create.ts +++ b/packages/sv/src/cli/create.ts @@ -1,5 +1,5 @@ import * as p from '@clack/prompts'; -import { color, resolveCommandArray, commonFilePaths, getPackageJson } from '@sveltejs/sv-utils'; +import { color, resolveCommandArray, commonFilePaths, loadPackageJson } from '@sveltejs/sv-utils'; import { Command, Option } from 'commander'; import fs from 'node:fs'; import path from 'node:path'; @@ -465,7 +465,7 @@ export async function createVirtualWorkspace({ // Let's read the package.json of the template we will use and add the dependencies to the override const templatePackageJsonPath = dist(`templates/${template}`); - const { data: packageJson } = getPackageJson(templatePackageJsonPath); + const { data: packageJson } = loadPackageJson(templatePackageJsonPath); override.dependencies = { ...packageJson.devDependencies, ...packageJson.dependencies, diff --git a/packages/sv/src/core/engine.ts b/packages/sv/src/core/engine.ts index 99a1edba1..9e2028c42 100644 --- a/packages/sv/src/core/engine.ts +++ b/packages/sv/src/core/engine.ts @@ -1,12 +1,13 @@ import * as p from '@clack/prompts'; import { color, + commonFilePaths, resolveCommand, type AgentName, fileExists, - installPackages as updatePackages, - readFile, - writeFile + loadFile, + loadPackageJson, + saveFile } from '@sveltejs/sv-utils'; import { NonZeroExitError, exec } from 'tinyexec'; import { createLoadedAddon } from '../cli/add.ts'; @@ -22,6 +23,38 @@ import { import { TESTING } from './env.ts'; import { createWorkspace, type Workspace } from './workspace.ts'; +function alphabetizePackageJsonDependencies(obj: Record) { + const ordered: Record = {}; + for (const [key, value] of Object.entries(obj).sort(([a], [b]) => a.localeCompare(b))) { + ordered[key] = value; + } + return ordered; +} + +function updatePackages( + dependencies: Array<{ pkg: string; version: string; dev: boolean }>, + cwd: string +): string { + const { data, generateCode } = loadPackageJson(cwd); + + for (const dependency of dependencies) { + if (dependency.dev) { + data.devDependencies ??= {}; + data.devDependencies[dependency.pkg] = dependency.version; + } else { + data.dependencies ??= {}; + data.dependencies[dependency.pkg] = dependency.version; + } + } + + if (data.dependencies) data.dependencies = alphabetizePackageJsonDependencies(data.dependencies); + if (data.devDependencies) + data.devDependencies = alphabetizePackageJsonDependencies(data.devDependencies); + + saveFile(cwd, commonFilePaths.packageJson, generateCode()); + return commonFilePaths.packageJson; +} + export type InstallOptions = { cwd: string; addons: Addons; @@ -180,11 +213,11 @@ async function runAddon({ addon, loaded, multiple, workspace, workspaceOptions } const sv: SvApi = { file: (path, edit) => { try { - const content = fileExists(workspace.cwd, path) ? readFile(workspace.cwd, path) : ''; + const content = fileExists(workspace.cwd, path) ? loadFile(workspace.cwd, path) : ''; const editedContent = edit(content); if (editedContent === '' || editedContent === false) return content; - writeFile(workspace.cwd, path, editedContent); + saveFile(workspace.cwd, path, editedContent); files.add(path); } catch (e) { if (e instanceof Error) { diff --git a/packages/sv/src/core/processors.ts b/packages/sv/src/core/processors.ts index a56240d15..bde28a7c1 100644 --- a/packages/sv/src/core/processors.ts +++ b/packages/sv/src/core/processors.ts @@ -1,10 +1,8 @@ import type { ConditionDefinition } from './config.ts'; import type { Workspace } from './workspace.ts'; -/** @deprecated Unused type, will be removed in a future version. */ export type FileEditor = Workspace & { content: string }; -/** @deprecated Unused type, will be removed in a future version. */ export type FileType = { name: (options: Workspace) => string; condition?: ConditionDefinition; diff --git a/packages/sv/src/core/workspace.ts b/packages/sv/src/core/workspace.ts index 4efb8c136..b04af63f4 100644 --- a/packages/sv/src/core/workspace.ts +++ b/packages/sv/src/core/workspace.ts @@ -4,8 +4,8 @@ import { js, parse, commonFilePaths, - getPackageJson, - readFile + loadFile, + loadPackageJson } from '@sveltejs/sv-utils'; import * as find from 'empathic/find'; import fs from 'node:fs'; @@ -37,18 +37,6 @@ export type Workspace = { package: 'package.json'; gitignore: '.gitignore'; - /** @deprecated Addon-specific path - use the string literal '.prettierignore' directly. Will be removed in a future version. */ - prettierignore: '.prettierignore'; - /** @deprecated Addon-specific path - use the string literal '.prettierrc' directly. Will be removed in a future version. */ - prettierrc: '.prettierrc'; - /** @deprecated Addon-specific path - use the string literal 'eslint.config.js' directly. Will be removed in a future version. */ - eslintConfig: 'eslint.config.js'; - - /** @deprecated Addon-specific path - use the string literal '.vscode/settings.json' directly. Will be removed in a future version. */ - vscodeSettings: '.vscode/settings.json'; - /** @deprecated Addon-specific path - use the string literal '.vscode/extensions.json' directly. Will be removed in a future version. */ - vscodeExtensions: '.vscode/extensions.json'; - /** Get the relative path between two files */ getRelative: ({ from, to }: { from?: string; to: string }) => string; }; @@ -108,7 +96,7 @@ export async function createWorkspace({ directory.length >= workspaceRoot.length ) { if (fs.existsSync(path.join(directory, commonFilePaths.packageJson))) { - const { data: packageJson } = getPackageJson(directory); + const { data: packageJson } = loadPackageJson(directory); dependencies = { ...packageJson.devDependencies, ...packageJson.dependencies, @@ -147,11 +135,6 @@ export async function createWorkspace({ stylesheet, package: 'package.json', gitignore: '.gitignore', - prettierignore: '.prettierignore', - prettierrc: '.prettierrc', - eslintConfig: 'eslint.config.js', - vscodeSettings: '.vscode/settings.json', - vscodeExtensions: '.vscode/extensions.json', getRelative({ from, to }) { from = from ?? ''; let relativePath = path.posix.relative(path.posix.dirname(from), to); @@ -178,7 +161,7 @@ function findWorkspaceRoot(cwd: string): string { return directory; } // in other package managers it's a workspaces key in the package.json - const { data } = getPackageJson(directory); + const { data } = loadPackageJson(directory); if (data.workspaces) { return directory; } @@ -194,7 +177,7 @@ function findWorkspaceRoot(cwd: string): string { } function parseKitOptions(cwd: string, svelteConfigPath: string) { - const configSource = readFile(cwd, svelteConfigPath); + const configSource = loadFile(cwd, svelteConfigPath); const { ast } = parse.script(configSource); const defaultExport = ast.body.find((s) => s.type === 'ExportDefaultDeclaration'); diff --git a/packages/sv/src/create/index.ts b/packages/sv/src/create/index.ts index 5ee524d0c..1c30c199b 100644 --- a/packages/sv/src/create/index.ts +++ b/packages/sv/src/create/index.ts @@ -33,7 +33,6 @@ export type Common = { }>; }; -/** @deprecated Use `create({ cwd, name, template, types })` instead. */ export function create(cwd: string, options: Omit): void; export function create(options: Options): void; export function create( diff --git a/packages/sv/src/index.ts b/packages/sv/src/index.ts index 6b5c64d4a..3c3fe50b0 100644 --- a/packages/sv/src/index.ts +++ b/packages/sv/src/index.ts @@ -37,6 +37,4 @@ export type { // workspace.ts export type { Workspace, WorkspaceOptions } from './core/workspace.ts'; -// processors.ts - deprecated, will be removed -/** @deprecated Unused type, will be removed in a future version. */ export type { FileEditor, FileType } from './core/processors.ts'; From 7e203ce9b79c9930cd7fac0398d922e3b793f133 Mon Sep 17 00:00:00 2001 From: jycouet Date: Sat, 4 Apr 2026 12:48:29 +0200 Subject: [PATCH 2/2] docs(sv-utils): clarify deprecation on readFile/writeFile/getPackageJson aliases Made-with: Cursor --- packages/sv-utils/api-surface.md | 12 +++++++++--- packages/sv-utils/src/files.ts | 12 +++++++++--- packages/sv-utils/src/index.ts | 12 +++++++++--- 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/packages/sv-utils/api-surface.md b/packages/sv-utils/api-surface.md index dba9a2978..0637ba830 100644 --- a/packages/sv-utils/api-surface.md +++ b/packages/sv-utils/api-surface.md @@ -1276,11 +1276,17 @@ declare function loadPackageJson(cwd: string): { data: Package; generateCode: () => string; }; -/** @deprecated Use `loadFile` instead. */ +/** +* @deprecated Use {@link loadFile} instead. This alias will be removed in a future version. +*/ declare const readFile: typeof loadFile; -/** @deprecated Use `saveFile` instead. */ +/** +* @deprecated Use {@link saveFile} instead. This alias will be removed in a future version. +*/ declare const writeFile: typeof saveFile; -/** @deprecated Use `loadPackageJson` instead. */ +/** +* @deprecated Use {@link loadPackageJson} instead. This alias will be removed in a future version. +*/ declare const getPackageJson: typeof loadPackageJson; type ColorInput = string | string[]; declare const color: { diff --git a/packages/sv-utils/src/files.ts b/packages/sv-utils/src/files.ts index 540e80602..8b6dc2488 100644 --- a/packages/sv-utils/src/files.ts +++ b/packages/sv-utils/src/files.ts @@ -70,11 +70,17 @@ export function loadPackageJson(cwd: string): { return { source: packageText, data: data as Package, generateCode }; } -/** @deprecated Use {@link loadFile} instead. */ +/** + * @deprecated Use {@link loadFile} instead. This alias will be removed in a future version. + */ export const readFile: typeof loadFile = loadFile; -/** @deprecated Use {@link saveFile} instead. */ +/** + * @deprecated Use {@link saveFile} instead. This alias will be removed in a future version. + */ export const writeFile: typeof saveFile = saveFile; -/** @deprecated Use {@link loadPackageJson} instead. */ +/** + * @deprecated Use {@link loadPackageJson} instead. This alias will be removed in a future version. + */ export const getPackageJson: typeof loadPackageJson = loadPackageJson; diff --git a/packages/sv-utils/src/index.ts b/packages/sv-utils/src/index.ts index 37db2b10b..d191059fc 100644 --- a/packages/sv-utils/src/index.ts +++ b/packages/sv-utils/src/index.ts @@ -87,11 +87,17 @@ export { type Package } from './files.ts'; -/** @deprecated Use {@link loadFile} instead. */ +/** + * @deprecated Use {@link loadFile} instead. This alias will be removed in a future version. + */ export { readFile } from './files.ts'; -/** @deprecated Use {@link saveFile} instead. */ +/** + * @deprecated Use {@link saveFile} instead. This alias will be removed in a future version. + */ export { writeFile } from './files.ts'; -/** @deprecated Use {@link loadPackageJson} instead. */ +/** + * @deprecated Use {@link loadPackageJson} instead. This alias will be removed in a future version. + */ export { getPackageJson } from './files.ts'; // Terminal styling