Skip to content

Commit

Permalink
Moving to fixtures, much easier to add test cases, although less dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugos68 committed Jan 15, 2025
1 parent 86969ce commit f91af07
Show file tree
Hide file tree
Showing 30 changed files with 321 additions and 467 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { transformApp } from './transformers/transform-app.js';
import { readFile, writeFile } from 'node:fs/promises';
import { installDependencies } from '../../../../utility/install-dependencies.js';
import { FALLBACK_THEME } from './utility/constants';
import getLatestVersion from 'latest-version';

export default async function (options: MigrateOptions) {
const cwd = options.cwd ?? process.cwd();
Expand Down Expand Up @@ -57,7 +58,9 @@ export default async function (options: MigrateOptions) {
packageSpinner.start(`Migrating ${pkg.matcher}...`);
try {
const pkgCode = await readFile(pkg.paths[0], 'utf-8');
const transformedPkg = await transformPackage(pkgCode);
const skeletonVersion = await getLatestVersion('@skeletonlabs/skeleton', { version: '>=3.0.0-0 <4.0.0' });
const skeletonSvelteVersion = await getLatestVersion('@skeletonlabs/skeleton-svelte', { version: '>=1.0.0-0 <2.0.0' });
const transformedPkg = transformPackage(pkgCode, skeletonVersion, skeletonSvelteVersion);
await writeFile(pkg.paths[0], transformedPkg.code);
packageSpinner.stop(`Successfully migrated ${pkg.matcher}`);
} catch (e) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import type { PackageJson } from 'type-fest';
import getLatestVersion from 'latest-version';
import { coerce, lt } from 'semver';
import { sortPropertiesAlphabetically } from '../../../../../utility/sort-properties-alphabetically';
import detectIndent from 'detect-indent';

async function transformPackage(code: string) {
function transformPackage(code: string, skeletonVersion: string, skeletonSvelteVersion: string) {
const pkg = JSON.parse(code) as PackageJson;
const skeletonVersion = await getLatestVersion('@skeletonlabs/skeleton', { version: '>=3.0.0-0 <4.0.0' });
const skeletonSvelteVersion = await getLatestVersion('@skeletonlabs/skeleton-svelte', { version: '>=1.0.0-0 <2.0.0' });
for (const field of ['dependencies', 'devDependencies'] as const) {
if (!pkg[field]) {
continue;
Expand Down
Loading

0 comments on commit f91af07

Please sign in to comment.