diff --git a/packages/skeleton-cli/src/commands/migrate/migrations/skeleton-3/index.ts b/packages/skeleton-cli/src/commands/migrate/migrations/skeleton-3/index.ts index 09a2de8bf..04a4ee9ea 100644 --- a/packages/skeleton-cli/src/commands/migrate/migrations/skeleton-3/index.ts +++ b/packages/skeleton-cli/src/commands/migrate/migrations/skeleton-3/index.ts @@ -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(); @@ -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) { diff --git a/packages/skeleton-cli/src/commands/migrate/migrations/skeleton-3/transformers/transform-package.test.ts b/packages/skeleton-cli/src/commands/migrate/migrations/skeleton-3/transformers/transform-package.test.ts deleted file mode 100644 index 8ae995511..000000000 --- a/packages/skeleton-cli/src/commands/migrate/migrations/skeleton-3/transformers/transform-package.test.ts +++ /dev/null @@ -1,127 +0,0 @@ -import { transformPackage } from './transform-package.js'; -import getLatestVersion from 'latest-version'; -import { describe, it, expect, vi } from 'vitest'; - -vi.mock('latest-version', () => { - return { - default: vi.fn() - }; -}); - -describe('transformPackage', () => { - it('updates the "@skeletonlabs/tw-plugin" dependency', async () => { - vi.mocked(getLatestVersion).mockReturnValue(Promise.resolve('3.0.0')); - expect( - ( - await transformPackage(` -{ - "dependencies": { - "@skeletonlabs/tw-plugin": "^1.0.0" - } -} - `) - ).code - .trim() - .replace(/\r\n|\r|\n/g, '\n') - ).toBe( - ` -{ - "dependencies": { - "@skeletonlabs/skeleton": "^3.0.0" - } -} - ` - .trim() - .replace(/\r\n|\r|\n/g, '\n') - ); - }); - it('updates the "@skeletonlabs/skeleton" dependency', async () => { - vi.mocked(getLatestVersion).mockReturnValue(Promise.resolve('3.0.0')); - - expect( - ( - await transformPackage(` -{ - "dependencies": { - "@skeletonlabs/skeleton": "^2.0.0" - } -} - `) - ).code - .trim() - .replace(/\r\n|\r|\n/g, '\n') - ).toBe( - ` -{ - "dependencies": { - "@skeletonlabs/skeleton-svelte": "^3.0.0" - } -} - ` - .trim() - .replace(/\r\n|\r|\n/g, '\n') - ); - }); - it('updates both "@skeletonlabs/tw-plugin" and "@skeletonlabs/skeleton" dependencies', async () => { - vi.mocked(getLatestVersion).mockImplementation((pkg) => { - switch (pkg) { - case '@skeletonlabs/skeleton-svelte': - return Promise.resolve('1.0.0'); - case '@skeletonlabs/skeleton': - return Promise.resolve('3.0.0'); - } - return Promise.resolve('0.0.0'); - }); - expect( - ( - await transformPackage(` -{ - "dependencies": { - "@skeletonlabs/tw-plugin": "^1.0.0", - "@skeletonlabs/skeleton": "^2.0.0" - } -} - `) - ).code - .trim() - .replace(/\r\n|\r|\n/g, '\n') - ).toBe( - ` -{ - "dependencies": { - "@skeletonlabs/skeleton": "^3.0.0", - "@skeletonlabs/skeleton-svelte": "^1.0.0" - } -} - ` - .trim() - .replace(/\r\n|\r|\n/g, '\n') - ); - }); - it('does not update "@skeletonlabs/skeleton" if version is >=3.0.0', async () => { - vi.mocked(getLatestVersion).mockReturnValue(Promise.resolve('3.0.0')); - expect( - ( - await transformPackage(` -{ - "dependencies": { - "@skeletonlabs/skeleton": "^3.0.0" - } -} - `) - ).code - .trim() - .replace(/\r\n|\r|\n/g, '\n') - ).toBe( - ` -{ - "dependencies": { - "@skeletonlabs/skeleton": "^3.0.0" - } -} - ` - .trim() - .replace(/\r\n|\r|\n/g, '\n') - ); - }); -}); diff --git a/packages/skeleton-cli/src/commands/migrate/migrations/skeleton-3/transformers/transform-package.ts b/packages/skeleton-cli/src/commands/migrate/migrations/skeleton-3/transformers/transform-package.ts index adf749e6d..646333567 100644 --- a/packages/skeleton-cli/src/commands/migrate/migrations/skeleton-3/transformers/transform-package.ts +++ b/packages/skeleton-cli/src/commands/migrate/migrations/skeleton-3/transformers/transform-package.ts @@ -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; diff --git a/packages/skeleton-cli/src/commands/migrate/migrations/skeleton-3/transformers/transform-tailwind-config.test.ts b/packages/skeleton-cli/src/commands/migrate/migrations/skeleton-3/transformers/transform-tailwind-config.test.ts deleted file mode 100644 index dddc96759..000000000 --- a/packages/skeleton-cli/src/commands/migrate/migrations/skeleton-3/transformers/transform-tailwind-config.test.ts +++ /dev/null @@ -1,334 +0,0 @@ -import { describe, expect, it } from 'vitest'; -import { transformTailwindConfig } from './transform-tailwind-config.js'; -import { THEME_MAPPINGS } from '../utility/theme-mappings.js'; - -describe('transformTailwindConfig', () => { - it('transforms content path', () => { - expect( - transformTailwindConfig(` -import { join } from "path"; - -export default { - content: [ - "./src/**/*.{html,js,svelte,ts}", - join(require.resolve("@skeletonlabs/skeleton"), "../**/*.{html,js,svelte,ts}") - ] -} - `) - .code.trim() - .replace(/\r\n|\r|\n/g, '\n') - ).toBe( - ` -import { contentPath } from "@skeletonlabs/skeleton/plugin"; - -export default { - content: [ - "./src/**/*.{html,js,svelte,ts}", - contentPath(import.meta.url, "svelte") - ] -} - ` - .trim() - .replace(/\r\n|\r|\n/g, '\n') - ); - }); - it('transforms content path with at different index', () => { - expect( - transformTailwindConfig(` -import { join } from "path"; - -export default { - content: [ - join(require.resolve("@skeletonlabs/skeleton"), "../**/*.{html,js,svelte,ts}"), - "./src/**/*.{html,js,svelte,ts}" - ] -} - `) - .code.trim() - .replace(/\r\n|\r|\n/g, '\n') - ).toBe( - ` -import { contentPath } from "@skeletonlabs/skeleton/plugin"; - -export default { - content: [ - contentPath(import.meta.url, "svelte"), - "./src/**/*.{html,js,svelte,ts}" - ] -} - ` - .trim() - .replace(/\r\n|\r|\n/g, '\n') - ); - }); - for (const [oldTheme, newTheme] of Object.entries(THEME_MAPPINGS)) { - it(`transforms a config with ${oldTheme} theme`, () => { - expect( - transformTailwindConfig(` -import { skeleton } from "@skeletonlabs/tw-plugin"; - -export default { - plugins: [ - skeleton({ - themes: { - preset: ["${oldTheme}"] - } - }) - ], -} - `) - .code.trim() - .replace(/\r\n|\r|\n/g, '\n') - ).toBe( - ` -import { skeleton } from "@skeletonlabs/skeleton/plugin"; -import * as themes from "@skeletonlabs/skeleton/themes"; - -export default { - plugins: [ - skeleton({ - themes: [themes.${newTheme}] - }) - ], -} - ` - .trim() - .replace(/\r\n|\r|\n/g, '\n') - ); - }); - it(`transforms a config with ${oldTheme} theme using the object theme format`, () => { - expect( - transformTailwindConfig(` -import { join } from "path"; -import { skeleton } from "@skeletonlabs/tw-plugin"; - -export default { - plugins: [ - skeleton({ - themes: { - preset: [ - { - name: "${oldTheme}", - enhancements: true - } - ] - } - }) - ], -} - `) - .code.trim() - .replace(/\r\n|\r|\n/g, '\n') - ).toBe( - ` -import { skeleton } from "@skeletonlabs/skeleton/plugin"; -import * as themes from "@skeletonlabs/skeleton/themes"; - -export default { - plugins: [ - skeleton({ - themes: [themes.${newTheme}] - }) - ], -} - ` - .trim() - .replace(/\r\n|\r|\n/g, '\n') - ); - }); - } - it(`transforms a config with multiple preset themes`, () => { - expect( - transformTailwindConfig(` -import { skeleton } from "@skeletonlabs/tw-plugin"; - -export default { - plugins: [ - skeleton({ - themes: { - preset: ["skeleton", "gold-nouveau"] - } - }) - ], -} - `) - .code.trim() - .replace(/\r\n|\r|\n/g, '\n') - ).toBe( - ` -import { skeleton } from "@skeletonlabs/skeleton/plugin"; -import * as themes from "@skeletonlabs/skeleton/themes"; - -export default { - plugins: [ - skeleton({ - themes: [themes.legacy, themes.nouveau] - }) - ], -} - ` - .trim() - .replace(/\r\n|\r|\n/g, '\n') - ); - }); - it('transforms a config with custom themes', () => { - expect( - transformTailwindConfig(` -import { skeleton } from "@skeletonlabs/tw-plugin"; -import myCustomTheme from "./my-custom-theme.js"; - -export default { - plugins: [ - skeleton({ - themes: { - custom: [myCustomTheme] - } - }) - ], -} - `) - .code.trim() - .replace(/\r\n|\r|\n/g, '\n') - ).toBe( - ` -/** - * SKELETON MIGRATION NOTICE - * - * The following custom themes were detected and commented out due to them not being compatible with the V3 theme format: - * - * - myCustomTheme - * - * See https://github.com/skeletonlabs/skeleton/discussions/2921 for info on how to migrate these yourself. - */ - -import { skeleton } from "@skeletonlabs/skeleton/plugin"; -import * as themes from "@skeletonlabs/skeleton/themes"; - -export default { - plugins: [ - skeleton({ - themes: [themes.cerberus /* myCustomTheme */] - }) - ], -} - ` - .trim() - .replace(/\r\n|\r|\n/g, '\n') - ); - }); - it('transforms a config with multiple custom themes', () => { - expect( - transformTailwindConfig(` -import { skeleton } from "@skeletonlabs/tw-plugin"; -import myCustomTheme from "./my-custom-theme.js"; -import myCustomThemeTwo from "./my-custom-theme-two.js"; - -export default { - plugins: [ - skeleton({ - themes: { - custom: [myCustomTheme, myCustomThemeTwo] - } - }) - ], -} - `) - .code.trim() - .replace(/\r\n|\r|\n/g, '\n') - ).toBe( - ` -/** - * SKELETON MIGRATION NOTICE - * - * The following custom themes were detected and commented out due to them not being compatible with the V3 theme format: - * - * - myCustomTheme - * - myCustomThemeTwo - * - * See https://github.com/skeletonlabs/skeleton/discussions/2921 for info on how to migrate these yourself. - */ - -import { skeleton } from "@skeletonlabs/skeleton/plugin"; -import * as themes from "@skeletonlabs/skeleton/themes"; - -export default { - plugins: [ - skeleton({ - themes: [themes.cerberus /* myCustomTheme, myCustomThemeTwo */] - }) - ], -} - ` - .trim() - .replace(/\r\n|\r|\n/g, '\n') - ); - }); - it('does not add a themes import when no themes are set', () => { - expect( - transformTailwindConfig(` -import { join } from "path"; -import { skeleton } from "@skeletonlabs/tw-plugin"; - -export default { - plugins: [ - skeleton({ - themes: {} - }) - ], -} - `) - .code.trim() - .replace(/\r\n|\r|\n/g, '\n') - ).toBe( - ` -import { skeleton } from "@skeletonlabs/skeleton/plugin"; - -export default { - plugins: [ - skeleton({ - themes: [] - }) - ], -} - ` - .trim() - .replace(/\r\n|\r|\n/g, '\n') - ); - }); - it('keeps other skeleton configuration options', () => { - expect( - transformTailwindConfig(` -import { join } from "path"; -import { skeleton } from "@skeletonlabs/tw-plugin"; - -export default { - plugins: [ - skeleton({ - base: true, - themes: {}, - prefix: "sk-" - }) - ], -} - `) - .code.trim() - .replace(/\r\n|\r|\n/g, '\n') - ).toBe( - ` -import { skeleton } from "@skeletonlabs/skeleton/plugin"; - -export default { - plugins: [ - skeleton({ - base: true, - themes: [], - prefix: "sk-" - }) - ], -} - ` - .trim() - .replace(/\r\n|\r|\n/g, '\n') - ); - }); -}); diff --git a/packages/skeleton-cli/src/commands/migrate/migrations/skeleton-3/transformers/transform-classes.test.ts b/packages/skeleton-cli/test/migrate/skeleton-3/classes.test.ts similarity index 98% rename from packages/skeleton-cli/src/commands/migrate/migrations/skeleton-3/transformers/transform-classes.test.ts rename to packages/skeleton-cli/test/migrate/skeleton-3/classes.test.ts index 89c178b76..cacfda259 100644 --- a/packages/skeleton-cli/src/commands/migrate/migrations/skeleton-3/transformers/transform-classes.test.ts +++ b/packages/skeleton-cli/test/migrate/skeleton-3/classes.test.ts @@ -1,5 +1,5 @@ import { describe, expect, it } from 'vitest'; -import { transformClasses } from './transform-classes.js'; +import { transformClasses } from '../../../src/commands/migrate/migrations/skeleton-3/transformers/transform-classes.js'; describe('transformClasses', () => { const COLORS = ['primary', 'secondary', 'tertiary', 'success', 'warning', 'error', 'surface']; diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/fixtures.test.ts b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures.test.ts new file mode 100644 index 000000000..3f8942423 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures.test.ts @@ -0,0 +1,64 @@ +import { fileURLToPath, resolve } from 'node:url'; +import { describe, expect, test } from 'vitest'; +import { readFile } from 'node:fs/promises'; +import { transformSvelte } from '../../../src/commands/migrate/migrations/skeleton-3/transformers/transform-svelte.js'; +import { transformModule } from '../../../src/commands/migrate/migrations/skeleton-3/transformers/transform-module.js'; +import { transformTailwindConfig } from '../../../src/commands/migrate/migrations/skeleton-3/transformers/transform-tailwind-config.js'; +import { transformApp } from '../../../src/commands/migrate/migrations/skeleton-3/transformers/transform-app.js'; +import { transformPackage } from '../../../src/commands/migrate/migrations/skeleton-3/transformers/transform-package.js'; + +const TRANSFORMER_MAP = { + svelte: transformSvelte, + module: transformModule, + 'tailwind-config': transformTailwindConfig, + app: transformApp, + package: transformPackage +}; + +const fixturesTest = import.meta.glob('./fixtures/**/*', { + query: '?raw' +}); + +function getResult(code: string, transformer: keyof typeof TRANSFORMER_MAP) { + switch (transformer) { + case 'svelte': + case 'module': + case 'tailwind-config': + return TRANSFORMER_MAP[transformer](code).code; + case 'app': + return TRANSFORMER_MAP[transformer](code, 'cerberus').code; + case 'package': + return TRANSFORMER_MAP[transformer](code, '3.0.0', '1.0.0').code; + } +} + +const testCases: Record = {}; + +for (const path of Object.keys(fixturesTest)) { + const name = path.split('/').at(-1); + const transformerName = path.split('/').at(-2) as keyof typeof TRANSFORMER_MAP | undefined; + if (!name || !transformerName || !(transformerName in TRANSFORMER_MAP)) { + continue; + } + if (!testCases[transformerName]) { + testCases[transformerName] = []; + } + testCases[transformerName].push({ name, path }); +} + +describe('fixtures', () => { + for (const [transformerName, cases] of Object.entries(testCases)) { + describe(transformerName, () => { + for (const { name, path } of cases) { + test(name, async () => { + const result = getResult( + await readFile(resolve(fileURLToPath(import.meta.url), path), 'utf-8'), + transformerName as keyof typeof TRANSFORMER_MAP + ); + const expected = await readFile(resolve(fileURLToPath(import.meta.url), path.replace('fixtures', 'results')), 'utf-8'); + expect(result.trim()).toEqual(expected.trim()); + }); + } + }); + } +}); diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/package/update-skeleton b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/package/update-skeleton new file mode 100644 index 000000000..9dd58e016 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/package/update-skeleton @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@skeletonlabs/skeleton": "^2.0.0" + } +} diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/package/update-skeleton-and-tw-plugin b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/package/update-skeleton-and-tw-plugin new file mode 100644 index 000000000..8cb401573 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/package/update-skeleton-and-tw-plugin @@ -0,0 +1,6 @@ +{ + "dependencies": { + "@skeletonlabs/tw-plugin": "^1.0.0", + "@skeletonlabs/skeleton": "^2.0.0" + } +} diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/package/update-tw-plugin b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/package/update-tw-plugin new file mode 100644 index 000000000..85abfea77 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/package/update-tw-plugin @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@skeletonlabs/tw-plugin": "^1.0.0" + } +} diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/svelte/remove-component-import b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/svelte/remove-component-import new file mode 100644 index 000000000..2da568e03 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/svelte/remove-component-import @@ -0,0 +1,7 @@ + + + diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/svelte/rename-component-import b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/svelte/rename-component-import new file mode 100644 index 000000000..a3cbc8fb7 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/svelte/rename-component-import @@ -0,0 +1,7 @@ + + + diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/content-path b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/content-path new file mode 100644 index 000000000..1a25bb17f --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/content-path @@ -0,0 +1,8 @@ +import { join } from "path"; + +export default { + content: [ + "./src/**/*.{html,js,svelte,ts}", + join(require.resolve("@skeletonlabs/skeleton"), "../**/*.{html,js,svelte,ts}") + ] +} diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/content-path-different-index b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/content-path-different-index new file mode 100644 index 000000000..957d5f276 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/content-path-different-index @@ -0,0 +1,8 @@ +import { join } from "path"; + +export default { + content: [ + join(require.resolve("@skeletonlabs/skeleton"), "../**/*.{html,js,svelte,ts}"), + "./src/**/*.{html,js,svelte,ts}" + ] +} diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/custom-theme b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/custom-theme new file mode 100644 index 000000000..829c9270f --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/custom-theme @@ -0,0 +1,13 @@ +import { skeleton } from "@skeletonlabs/tw-plugin"; +import myCustomTheme from "./my-custom-theme.js"; +import myCustomThemeTwo from "./my-custom-theme-two.js"; + +export default { + plugins: [ + skeleton({ + themes: { + custom: [myCustomTheme, myCustomThemeTwo] + } + }) + ], +} diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/no-themes b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/no-themes new file mode 100644 index 000000000..837693c39 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/no-themes @@ -0,0 +1,10 @@ +import { join } from "path"; +import { skeleton } from "@skeletonlabs/tw-plugin"; + +export default { + plugins: [ + skeleton({ + themes: {} + }) + ], +} \ No newline at end of file diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/perserve-config b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/perserve-config new file mode 100644 index 000000000..6390e7f70 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/perserve-config @@ -0,0 +1,12 @@ +import { join } from "path"; +import { skeleton } from "@skeletonlabs/tw-plugin"; + +export default { + plugins: [ + skeleton({ + base: true, + themes: {}, + prefix: "sk-" + }) + ], +} diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/preset-theme-object-notation b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/preset-theme-object-notation new file mode 100644 index 000000000..d5bfdea86 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/preset-theme-object-notation @@ -0,0 +1,53 @@ +import { join } from "path"; +import { skeleton } from "@skeletonlabs/tw-plugin"; + +export default { + plugins: [ + skeleton({ + themes: { + preset: [ + { + name: "skeleton", + enhancements: true + }, + { + name: "gold-nouveau", + enhancements: true + }, + { + name: "wintry", + enhancements: true + }, + { + name: "modern", + enhancements: true + }, + { + name: "rocket", + enhancements: true + }, + { + name: "seafoam", + enhancements: true + }, + { + name: "vintage", + enhancements: true + }, + { + name: "sahara", + enhancements: true + }, + { + name: "hamlindigo", + enhancements: true + }, + { + name: "crimson", + enhancements: true + } + ] + } + }) + ], +} diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/preset-theme-string-notation b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/preset-theme-string-notation new file mode 100644 index 000000000..5b2ba8748 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/fixtures/tailwind-config/preset-theme-string-notation @@ -0,0 +1,11 @@ +import { skeleton } from "@skeletonlabs/tw-plugin"; + +export default { + plugins: [ + skeleton({ + themes: { + preset: ["skeleton", "gold-nouveau", "wintry", "modern", "rocket", "seafoam", "vintage", "sahara", "hamlindigo", "crimson"] + } + }) + ], +} diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/results/package/update-skeleton b/packages/skeleton-cli/test/migrate/skeleton-3/results/package/update-skeleton new file mode 100644 index 000000000..c972ea9ba --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/results/package/update-skeleton @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@skeletonlabs/skeleton-svelte": "^1.0.0" + } +} diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/results/package/update-skeleton-and-tw-plugin b/packages/skeleton-cli/test/migrate/skeleton-3/results/package/update-skeleton-and-tw-plugin new file mode 100644 index 000000000..e8246862a --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/results/package/update-skeleton-and-tw-plugin @@ -0,0 +1,6 @@ +{ + "dependencies": { + "@skeletonlabs/skeleton": "^3.0.0", + "@skeletonlabs/skeleton-svelte": "^1.0.0" + } +} diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/results/package/update-tw-plugin b/packages/skeleton-cli/test/migrate/skeleton-3/results/package/update-tw-plugin new file mode 100644 index 000000000..c971fb3f8 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/results/package/update-tw-plugin @@ -0,0 +1,5 @@ +{ + "dependencies": { + "@skeletonlabs/skeleton": "^3.0.0" + } +} diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/results/svelte/remove-component-import b/packages/skeleton-cli/test/migrate/skeleton-3/results/svelte/remove-component-import new file mode 100644 index 000000000..4b15a7337 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/results/svelte/remove-component-import @@ -0,0 +1,7 @@ + + + diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/results/svelte/rename-component-import b/packages/skeleton-cli/test/migrate/skeleton-3/results/svelte/rename-component-import new file mode 100644 index 000000000..e571c88e1 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/results/svelte/rename-component-import @@ -0,0 +1,7 @@ + + + diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/content-path b/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/content-path new file mode 100644 index 000000000..136216ed8 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/content-path @@ -0,0 +1,8 @@ +import { contentPath } from "@skeletonlabs/skeleton/plugin"; + +export default { + content: [ + "./src/**/*.{html,js,svelte,ts}", + contentPath(import.meta.url, "svelte") + ] +} diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/content-path-different-index b/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/content-path-different-index new file mode 100644 index 000000000..d951766f8 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/content-path-different-index @@ -0,0 +1,8 @@ +import { contentPath } from "@skeletonlabs/skeleton/plugin"; + +export default { + content: [ + contentPath(import.meta.url, "svelte"), + "./src/**/*.{html,js,svelte,ts}" + ] +} diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/custom-theme b/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/custom-theme new file mode 100644 index 000000000..fbb1cfad5 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/custom-theme @@ -0,0 +1,20 @@ +/** + * SKELETON MIGRATION NOTICE + * + * The following custom themes were detected and commented out due to them not being compatible with the V3 theme format: + * + * - myCustomTheme + * - myCustomThemeTwo + * + * See https://github.com/skeletonlabs/skeleton/discussions/2921 for info on how to migrate these yourself. + */ +import { skeleton } from "@skeletonlabs/skeleton/plugin"; +import * as themes from "@skeletonlabs/skeleton/themes"; + +export default { + plugins: [ + skeleton({ + themes: [themes.cerberus /* myCustomTheme, myCustomThemeTwo */] + }) + ], +} diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/no-themes b/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/no-themes new file mode 100644 index 000000000..a4473cff1 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/no-themes @@ -0,0 +1,9 @@ +import { skeleton } from "@skeletonlabs/skeleton/plugin"; + +export default { + plugins: [ + skeleton({ + themes: [] + }) + ], +} \ No newline at end of file diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/perserve-config b/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/perserve-config new file mode 100644 index 000000000..021ea3d4a --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/perserve-config @@ -0,0 +1,11 @@ +import { skeleton } from "@skeletonlabs/skeleton/plugin"; + +export default { + plugins: [ + skeleton({ + base: true, + themes: [], + prefix: "sk-" + }) + ], +} diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/preset-theme-object-notation b/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/preset-theme-object-notation new file mode 100644 index 000000000..59c3b6b60 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/preset-theme-object-notation @@ -0,0 +1,10 @@ +import { skeleton } from "@skeletonlabs/skeleton/plugin"; +import * as themes from "@skeletonlabs/skeleton/themes"; + +export default { + plugins: [ + skeleton({ + themes: [themes.legacy, themes.nouveau, themes.wintry, themes.modern, themes.rocket, themes.seafoam, themes.vintage, themes.sahara, themes.hamlindigo, themes.crimson] + }) + ], +} diff --git a/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/preset-theme-string-notation b/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/preset-theme-string-notation new file mode 100644 index 000000000..59c3b6b60 --- /dev/null +++ b/packages/skeleton-cli/test/migrate/skeleton-3/results/tailwind-config/preset-theme-string-notation @@ -0,0 +1,10 @@ +import { skeleton } from "@skeletonlabs/skeleton/plugin"; +import * as themes from "@skeletonlabs/skeleton/themes"; + +export default { + plugins: [ + skeleton({ + themes: [themes.legacy, themes.nouveau, themes.wintry, themes.modern, themes.rocket, themes.seafoam, themes.vintage, themes.sahara, themes.hamlindigo, themes.crimson] + }) + ], +}