diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000..d2304073e --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,18 @@ +## 0.0.0-e2e (2024-06-24) + +### 🚀 Features + +- **sveltekit:** upgrade versions and allow CLI overrides ([f867fb34](https://github.com/nxext/nx-extensions/commit/f867fb34)) + +### 🩹 Fixes + +- **stencil:** allow ArrayLiteralExpression in addCodeIntoArray ([f24475d5](https://github.com/nxext/nx-extensions/commit/f24475d5)) +- **stencil:** resolve `validateConfig` error from @stencil/core@14.17.0 onward ([f5b87252](https://github.com/nxext/nx-extensions/commit/f5b87252)) +- **stencil:** remove gitignore addage ([b6e8e8be](https://github.com/nxext/nx-extensions/commit/b6e8e8be)) + +### ❤️ Thank You + +- Dominik Pieper @DominikPieper +- kristianmandrup @kristianmandrup +- Maarten Van Hoof @mrtnvh +- Sharief Orie diff --git a/docs/docs/svelte/generators.md b/docs/docs/svelte/generators.md index 3853e3e3a..7a99e48b9 100644 --- a/docs/docs/svelte/generators.md +++ b/docs/docs/svelte/generators.md @@ -238,7 +238,7 @@ Default: `vitest` Type: `string` -Possible values: `jest`, `vitest`, `none` +Possible values: `vitest`, `none` Test runner to use for unit tests. diff --git a/e2e/solid-e2e/tests/solid.test.ts b/e2e/solid-e2e/tests/solid.test.ts index f47d09a32..9ad080b19 100644 --- a/e2e/solid-e2e/tests/solid.test.ts +++ b/e2e/solid-e2e/tests/solid.test.ts @@ -12,10 +12,10 @@ describe('solid e2e', () => { afterAll(() => { // Cleanup the test project - rmSync(projectDirectory, { + /*rmSync(projectDirectory, { recursive: true, force: true, - }); + });*/ }); describe('solid app', () => { diff --git a/e2e/svelte-e2e/tests/application.test.ts b/e2e/svelte-e2e/tests/application.test.ts index 510a4b341..6a7e70289 100644 --- a/e2e/svelte-e2e/tests/application.test.ts +++ b/e2e/svelte-e2e/tests/application.test.ts @@ -8,7 +8,7 @@ import { import { createTestProject, installPlugin } from '@nxext/e2e-utils'; import { rmSync } from 'fs'; -describe('svelte e2e', () => { +xdescribe('svelte e2e', () => { let projectDirectory: string; beforeAll(() => { @@ -82,21 +82,6 @@ describe('svelte e2e', () => { }); describe('should be able to run tests', () => { - it('with jest', async () => { - const plugin = uniq('svelteapptests'); - await runNxCommandAsync( - `generate @nxext/svelte:app ${plugin} --directory=apps --unitTestRunner='jest' --e2eTestRunner='none'` - ); - await runNxCommandAsync( - `generate @nxext/svelte:component test --project=${plugin}` - ); - - const result = await runNxCommandAsync(`test ${plugin}`); - expect(`${result.stdout}${result.stderr}`).toContain( - 'Ran all test suites' - ); - }); - it('with vitest', async () => { const plugin = uniq('svelteapptests'); await runNxCommandAsync( diff --git a/e2e/svelte-e2e/tests/library.test.ts b/e2e/svelte-e2e/tests/library.test.ts index a04daf6a6..c447996f5 100644 --- a/e2e/svelte-e2e/tests/library.test.ts +++ b/e2e/svelte-e2e/tests/library.test.ts @@ -13,10 +13,10 @@ describe('svelte e2e', () => { afterAll(() => { // Cleanup the test project - rmSync(projectDirectory, { + /*rmSync(projectDirectory, { recursive: true, force: true, - }); + });*/ }); describe('Svelte lib', () => { @@ -55,21 +55,6 @@ describe('svelte e2e', () => { }); describe('should be able to run tests', () => { - it('with jest', async () => { - const plugin = uniq('jest'); - await runNxCommandAsync( - `generate @nxext/svelte:lib ${plugin} --directory=libs --unitTestRunner=jest --e2eTestRunner='none'` - ); - await runNxCommandAsync( - `generate @nxext/svelte:component test --project=${plugin}` - ); - - const result = await runNxCommandAsync(`test ${plugin}`); - expect(`${result.stdout}${result.stderr}`).toContain( - 'Ran all test suites' - ); - }); - it('with vitest', async () => { const plugin = uniq('vitest'); await runNxCommandAsync( diff --git a/nx.json b/nx.json index 217a923a4..5af5f1c8a 100644 --- a/nx.json +++ b/nx.json @@ -69,6 +69,11 @@ } }, "targetDefaults": { + "nx-release-publish": { + "options": { + "packageRoot": "dist/packages/{projectName}" + } + }, "build": { "dependsOn": ["^build"], "inputs": ["production", "^production"], @@ -122,6 +127,16 @@ "parallel": 1, "defaultBase": "main", "release": { - "projects": ["*", "!docs", "!stencil", "!*-e2e", "!e2e-*"] + "projects": ["*", "!docs", "!stencil", "!common", "!*-e2e", "!e2e-*"], + "releaseTagPattern": "release/{version}", + "git": { + "commitMessage": "chore(release): {version}" + }, + "version": { + "generatorOptions": { + "packageRoot": "dist/packages/{projectName}", + "currentVersionResolver": "git-tag" + } + } } } diff --git a/package.json b/package.json index 5c67601cf..9b0097e23 100644 --- a/package.json +++ b/package.json @@ -111,8 +111,8 @@ "prettier": "2.7.1", "pretty-quick": "^3.1.3", "semver": "^7.6.2", - "svelte": "^4.2.12", - "svelte-preprocess": "^5.1.3", + "svelte": "^4.2.18", + "svelte-preprocess": "^6.0.1", "tcp-port-used": "^1.0.2", "ts-jest": "29.1.2", "ts-node": "10.9.2", diff --git a/packages/common/project.json b/packages/common/project.json index 673008fdf..4834b0796 100644 --- a/packages/common/project.json +++ b/packages/common/project.json @@ -27,5 +27,18 @@ } } }, - "tags": [] + "tags": [], + "release": { + "version": { + "generatorOptions": { + "packageRoot": "dist/{projectRoot}", + "currentVersionResolver": "git-tag" + } + } + }, + "nx-release-publish": { + "options": { + "packageRoot": "dist/{projectRoot}" + } + } } diff --git a/packages/solid/src/generators/library/lib/add-vite.ts b/packages/solid/src/generators/library/lib/add-vite.ts index 124cdcc85..48feb3c6a 100644 --- a/packages/solid/src/generators/library/lib/add-vite.ts +++ b/packages/solid/src/generators/library/lib/add-vite.ts @@ -1,16 +1,46 @@ -import { ensurePackage, NX_VERSION, Tree } from '@nx/devkit'; +import { + ensurePackage, + GeneratorCallback, + NX_VERSION, + runTasksInSerial, + Tree, +} from '@nx/devkit'; import { NormalizedSchema } from '../schema'; +import { createOrEditViteConfig } from '@nx/vite'; export async function addVite(host: Tree, options: NormalizedSchema) { - const { viteConfigurationGenerator } = ensurePackage< - typeof import('@nx/vite') - >('@nx/vite', NX_VERSION); + const tasks: GeneratorCallback[] = []; - return await viteConfigurationGenerator(host, { - uiFramework: 'none', - project: options.name, - newProject: true, - includeVitest: options.unitTestRunner === 'vitest', - inSourceTests: false, - }); + if (options.buildable || options.publishable) { + const { viteConfigurationGenerator } = ensurePackage< + typeof import('@nx/vite') + >('@nx/vite', NX_VERSION); + + const viteTask = await viteConfigurationGenerator(host, { + uiFramework: 'none', + project: options.name, + newProject: true, + includeLib: true, + includeVitest: options.unitTestRunner === 'vitest', + inSourceTests: false, + skipFormat: true, + }); + tasks.push(viteTask); + + createOrEditViteConfig( + host, + { + project: options.name, + includeLib: true, + includeVitest: options.unitTestRunner === 'vitest', + inSourceTests: false, + rollupOptionsExternal: [], + imports: [`import solidPlugin from 'vite-plugin-solid'`], + plugins: [`solidPlugin()`], + }, + false + ); + } + + return runTasksInSerial(...tasks); } diff --git a/packages/solid/src/generators/library/library.ts b/packages/solid/src/generators/library/library.ts index aa321317c..e7bfc7c16 100644 --- a/packages/solid/src/generators/library/library.ts +++ b/packages/solid/src/generators/library/library.ts @@ -93,20 +93,6 @@ export async function libraryGeneratorInternal( const lintTask = await addLinting(host, options); const jestTask = await addJest(host, options); const viteTask = await addVite(host, options); - createOrEditViteConfig( - host, - { - project: options.name, - includeLib: false, - includeVitest: options.unitTestRunner === 'vitest', - inSourceTests: false, - rollupOptionsExternal: [], - imports: [`import solidPlugin from 'vite-plugin-solid'`], - plugins: [`solidPlugin()`], - }, - false - ); - const vitestTask = await addVitest(host, options); updateTsConfig(host, options); diff --git a/packages/svelte/src/generators/library/lib/add-jest.ts b/packages/svelte/src/generators/library/lib/add-jest.ts deleted file mode 100644 index d39129b58..000000000 --- a/packages/svelte/src/generators/library/lib/add-jest.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { ensurePackage, NX_VERSION, Tree } from '@nx/devkit'; -import { NormalizedSchema } from '../schema'; - -export async function addJest(host: Tree, options: NormalizedSchema) { - if (options.unitTestRunner !== 'jest') { - return () => {}; // eslint-disable-line @typescript-eslint/no-empty-function - } - - const { jestProjectGenerator } = ensurePackage( - '@nx/jest', - NX_VERSION - ); - - return await jestProjectGenerator(host, { - project: options.name, - supportTsx: false, - skipSerializers: true, - setupFile: 'none', - babelJest: false, - }); -} diff --git a/packages/svelte/src/generators/library/lib/add-vite.ts b/packages/svelte/src/generators/library/lib/add-vite.ts index e4b2c4bfc..db867e06e 100644 --- a/packages/svelte/src/generators/library/lib/add-vite.ts +++ b/packages/svelte/src/generators/library/lib/add-vite.ts @@ -1,22 +1,46 @@ -import { Tree, ensurePackage, NX_VERSION } from '@nx/devkit'; +import { + Tree, + ensurePackage, + NX_VERSION, + GeneratorCallback, + runTasksInSerial, +} from '@nx/devkit'; import { NormalizedSchema } from '../schema'; +import { createOrEditViteConfig } from '@nx/vite'; export async function addVite(host: Tree, options: NormalizedSchema) { + const tasks: GeneratorCallback[] = []; + if (options.buildable || options.publishable) { const { viteConfigurationGenerator } = ensurePackage< typeof import('@nx/vite') >('@nx/vite', NX_VERSION); - return await viteConfigurationGenerator(host, { + const viteTask = await viteConfigurationGenerator(host, { uiFramework: 'none', project: options.name, newProject: true, + includeLib: true, includeVitest: options.unitTestRunner === 'vitest', inSourceTests: false, skipFormat: true, }); + tasks.push(viteTask); + + createOrEditViteConfig( + host, + { + project: options.name, + includeLib: false, + includeVitest: options.unitTestRunner === 'vitest', + inSourceTests: false, + rollupOptionsExternal: [], + imports: [`import { svelte } from '@sveltejs/vite-plugin-svelte'`], + plugins: [`svelte()`], + }, + false + ); } - // eslint-disable-next-line @typescript-eslint/no-empty-function - return () => {}; + return runTasksInSerial(...tasks); } diff --git a/packages/svelte/src/generators/library/lib/update-jest-config.ts b/packages/svelte/src/generators/library/lib/update-jest-config.ts deleted file mode 100644 index 4bd8e38f0..000000000 --- a/packages/svelte/src/generators/library/lib/update-jest-config.ts +++ /dev/null @@ -1,23 +0,0 @@ -import { NormalizedSchema } from '../schema'; -import { Tree } from '@nx/devkit'; - -export function updateJestConfig(host: Tree, options: NormalizedSchema) { - if (options.unitTestRunner !== 'jest') { - return; - } - - const configPath = `${options.projectRoot}/jest.config.ts`; - const svelteConfigPath = `${options.projectRoot}/svelte.config.cjs`; - const originalContent = host.read(configPath)?.toString(); - const content = updateJestConfigContent(originalContent, svelteConfigPath); - host.write(configPath, content); -} - -function updateJestConfigContent(content: string, svelteConfigPath: string) { - return content - .replace('moduleFileExtensions: [', "moduleFileExtensions: ['svelte', ") - .replace( - 'transform: {', - `transform: {\n '^(.+\\\\.svelte$)': ['svelte-jester', {\n 'preprocess': '${svelteConfigPath}'\n }\n ],` - ); -} diff --git a/packages/svelte/src/generators/library/library.ts b/packages/svelte/src/generators/library/library.ts index e90a32da1..8e83e2c10 100644 --- a/packages/svelte/src/generators/library/library.ts +++ b/packages/svelte/src/generators/library/library.ts @@ -4,13 +4,10 @@ import { addProject } from './lib/add-project'; import { updateTsConfig } from './lib/update-tsconfig'; import { formatFiles, Tree, updateJson, runTasksInSerial } from '@nx/devkit'; import { addLinting } from './lib/add-linting'; -import { addJest } from './lib/add-jest'; -import { updateJestConfig } from './lib/update-jest-config'; import { addVite } from './lib/add-vite'; import { createProjectFiles } from './lib/create-project-files'; import { addVitest } from './lib/add-vitest'; import { normalizeOptions } from './lib/normalize-options'; -import { createOrEditViteConfig } from '@nx/vite'; function updateLibPackageNpmScope(host: Tree, options: NormalizedSchema) { return updateJson(host, `${options.projectRoot}/package.json`, (json) => { @@ -36,26 +33,10 @@ export async function libraryGenerator( await createProjectFiles(host, options); const lintTask = await addLinting(host, options); - const jestTask = await addJest(host, options); const viteTask = await addVite(host, options); - createOrEditViteConfig( - host, - { - project: options.name, - includeLib: false, - includeVitest: options.unitTestRunner === 'vitest', - inSourceTests: false, - rollupOptionsExternal: [], - imports: [`import { svelte } from '@sveltejs/vite-plugin-svelte'`], - plugins: [`svelte()`], - }, - false - ); const vitestTask = await addVitest(host, options); - updateTsConfig(host, options); - updateJestConfig(host, options); if (options.publishable || options.buildable) { updateLibPackageNpmScope(host, options); @@ -65,6 +46,6 @@ export async function libraryGenerator( await formatFiles(host); } - return runTasksInSerial(initTask, lintTask, viteTask, jestTask, vitestTask); + return runTasksInSerial(initTask, lintTask, viteTask, vitestTask); } export default libraryGenerator; diff --git a/packages/svelte/src/generators/library/schema.d.ts b/packages/svelte/src/generators/library/schema.d.ts index 9f35c0e27..78365a606 100644 --- a/packages/svelte/src/generators/library/schema.d.ts +++ b/packages/svelte/src/generators/library/schema.d.ts @@ -6,7 +6,7 @@ export interface SvelteLibrarySchema { tags?: string; projectNameAndRootFormat?: ProjectNameAndRootFormat; linter: Linter; - unitTestRunner: 'jest' | 'vitest' | 'none'; + unitTestRunner: 'vitest' | 'none'; e2eTestRunner: 'cypress' | 'none'; buildable?: boolean; directory?: string; diff --git a/packages/svelte/src/generators/library/schema.json b/packages/svelte/src/generators/library/schema.json index b59dcd747..db976ade0 100644 --- a/packages/svelte/src/generators/library/schema.json +++ b/packages/svelte/src/generators/library/schema.json @@ -26,7 +26,7 @@ }, "unitTestRunner": { "type": "string", - "enum": ["jest", "vitest", "none"], + "enum": ["vitest", "none"], "description": "Test runner to use for unit tests.", "default": "vitest" }, diff --git a/packages/svelte/src/generators/utils/versions.ts b/packages/svelte/src/generators/utils/versions.ts index 30b75f3bb..274d1f318 100644 --- a/packages/svelte/src/generators/utils/versions.ts +++ b/packages/svelte/src/generators/utils/versions.ts @@ -1,8 +1,8 @@ -export const svelteVersion = '^4.2.12'; +export const svelteVersion = '^4.2.18'; export const svelteJesterVersion = '^2.3.2'; export const svelteCheckVersion = '^2.10.2'; export const svelteLoaderVersion = '^3.1.9'; -export const sveltePreprocessVersion = '^5.1.3'; +export const sveltePreprocessVersion = '^6.0.1'; export const eslintPluginSvelteVersion = '^4.0.0'; export const tsconfigSvelteVersion = '^4.0.1'; export const testingLibrarySvelteVersion = '^3.2.2';