diff --git a/e2e/browser-mode/fixtures/basic/tests/async.test.ts b/e2e/browser-mode/fixtures/basic/tests/async.test.ts index 3d1cf0c17..0052c5896 100644 --- a/e2e/browser-mode/fixtures/basic/tests/async.test.ts +++ b/e2e/browser-mode/fixtures/basic/tests/async.test.ts @@ -65,7 +65,7 @@ describe('Async operations', () => { count++; }, 20); - await sleep(70); + await sleep(300); globalThis.clearInterval(intervalId); expect(count).toBeGreaterThanOrEqual(2); diff --git a/e2e/cli/initBrowser.test.ts b/e2e/cli/initBrowser.test.ts new file mode 100644 index 000000000..2210a47c1 --- /dev/null +++ b/e2e/cli/initBrowser.test.ts @@ -0,0 +1,57 @@ +import fs from 'node:fs'; +import path, { dirname } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { afterEach, beforeEach, describe, expect, it } from '@rstest/core'; +import { runRstestCli } from '../scripts'; + +const __filename = fileURLToPath(import.meta.url); +const __dirname = dirname(__filename); + +function readJson(filePath: string): Record { + return JSON.parse(fs.readFileSync(filePath, 'utf-8')) as Record; +} + +describe('cli init browser', () => { + const projectDir = path.join(__dirname, 'fixtures', 'test-temp-init-browser'); + + beforeEach(() => { + fs.mkdirSync(projectDir, { recursive: true }); + fs.writeFileSync( + path.join(projectDir, 'package.json'), + `${JSON.stringify({ name: 'fixture', private: true }, null, 2)}\n`, + 'utf-8', + ); + }); + + afterEach(() => { + fs.rmSync(projectDir, { recursive: true, force: true }); + }); + + it('should generate files and update package.json in --yes mode', async () => { + const { expectExecSuccess } = await runRstestCli({ + command: 'rstest', + args: ['init', 'browser', '--yes'], + options: { + nodeOptions: { + cwd: projectDir, + }, + }, + }); + + await expectExecSuccess(); + + expect( + fs.existsSync(path.join(projectDir, 'rstest.browser.config.ts')), + ).toBe(true); + + expect( + fs.existsSync(path.join(projectDir, 'tests', 'Counter.test.ts')) || + fs.existsSync(path.join(projectDir, 'tests', 'Counter.test.js')), + ).toBe(true); + + const pkg = readJson(path.join(projectDir, 'package.json')); + expect(pkg.scripts?.['test:browser']).toBe( + 'rstest --config=rstest.browser.config.ts', + ); + }); +}); diff --git a/package.json b/package.json index 066d19cc6..3041b57fe 100644 --- a/package.json +++ b/package.json @@ -47,6 +47,7 @@ "nano-staged": "^0.9.0", "nx": "^21.6.10", "path-serializer": "0.5.1", + "playwright": "^1.49.1", "prettier": "^3.7.4", "prettier-plugin-packagejson": "^2.5.20", "simple-git-hooks": "^2.13.1", diff --git a/packages/core/LICENSE.md b/packages/core/LICENSE.md index 2e27591f6..6693ccb23 100644 --- a/packages/core/LICENSE.md +++ b/packages/core/LICENSE.md @@ -336,6 +336,34 @@ Licensed under MIT license in the repository at https://github.com/babel/babel.g > OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION > WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +### @clack/core + +Licensed under MIT license in the repository at git+https://github.com/bombshell-dev/clack.git. + +> MIT License +> +> Copyright (c) Nate Moore +> +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +### @clack/prompts + +Licensed under MIT license in the repository at git+https://github.com/bombshell-dev/clack.git. + +> MIT License +> +> Copyright (c) Nate Moore +> +> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + ### @jest/diff-sequences Licensed under MIT license in the repository at https://github.com/jestjs/jest.git. @@ -508,6 +536,206 @@ Licensed under BSD-3-Clause license in the repository at git+https://github.com/ > > THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +### @vercel/detect-agent + +Licensed under Apache-2.0 license in the repository at https://github.com/vercel/vercel.git. + +> Apache License +> Version 2.0, January 2004 +> http://www.apache.org/licenses/ +> +> TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION +> +> 1. Definitions. +> +> "License" shall mean the terms and conditions for use, reproduction, +> and distribution as defined by Sections 1 through 9 of this document. +> +> "Licensor" shall mean the copyright owner or entity authorized by +> the copyright owner that is granting the License. +> +> "Legal Entity" shall mean the union of the acting entity and all +> other entities that control, are controlled by, or are under common +> control with that entity. For the purposes of this definition, +> "control" means (i) the power, direct or indirect, to cause the +> direction or management of such entity, whether by contract or +> otherwise, or (ii) ownership of fifty percent (50%) or more of the +> outstanding shares, or (iii) beneficial ownership of such entity. +> +> "You" (or "Your") shall mean an individual or Legal Entity +> exercising permissions granted by this License. +> +> "Source" form shall mean the preferred form for making modifications, +> including but not limited to software source code, documentation +> source, and configuration files. +> +> "Object" form shall mean any form resulting from mechanical +> transformation or translation of a Source form, including but +> not limited to compiled object code, generated documentation, +> and conversions to other media types. +> +> "Work" shall mean the work of authorship, whether in Source or +> Object form, made available under the License, as indicated by a +> copyright notice that is included in or attached to the work +> (an example is provided in the Appendix below). +> +> "Derivative Works" shall mean any work, whether in Source or Object +> form, that is based on (or derived from) the Work and for which the +> editorial revisions, annotations, elaborations, or other modifications +> represent, as a whole, an original work of authorship. For the purposes +> of this License, Derivative Works shall not include works that remain +> separable from, or merely link (or bind by name) to the interfaces of, +> the Work and Derivative Works thereof. +> +> "Contribution" shall mean any work of authorship, including +> the original version of the Work and any modifications or additions +> to that Work or Derivative Works thereof, that is intentionally +> submitted to Licensor for inclusion in the Work by the copyright owner +> or by an individual or Legal Entity authorized to submit on behalf of +> the copyright owner. For the purposes of this definition, "submitted" +> means any form of electronic, verbal, or written communication sent +> to the Licensor or its representatives, including but not limited to +> communication on electronic mailing lists, source code control systems, +> and issue tracking systems that are managed by, or on behalf of, the +> Licensor for the purpose of discussing and improving the Work, but +> excluding communication that is conspicuously marked or otherwise +> designated in writing by the copyright owner as "Not a Contribution." +> +> "Contributor" shall mean Licensor and any individual or Legal Entity +> on behalf of whom a Contribution has been received by Licensor and +> subsequently incorporated within the Work. +> +> 2. Grant of Copyright License. Subject to the terms and conditions of +> this License, each Contributor hereby grants to You a perpetual, +> worldwide, non-exclusive, no-charge, royalty-free, irrevocable +> copyright license to reproduce, prepare Derivative Works of, +> publicly display, publicly perform, sublicense, and distribute the +> Work and such Derivative Works in Source or Object form. +> 3. Grant of Patent License. Subject to the terms and conditions of +> this License, each Contributor hereby grants to You a perpetual, +> worldwide, non-exclusive, no-charge, royalty-free, irrevocable +> (except as stated in this section) patent license to make, have made, +> use, offer to sell, sell, import, and otherwise transfer the Work, +> where such license applies only to those patent claims licensable +> by such Contributor that are necessarily infringed by their +> Contribution(s) alone or by combination of their Contribution(s) +> with the Work to which such Contribution(s) was submitted. If You +> institute patent litigation against any entity (including a +> cross-claim or counterclaim in a lawsuit) alleging that the Work +> or a Contribution incorporated within the Work constitutes direct +> or contributory patent infringement, then any patent licenses +> granted to You under this License for that Work shall terminate +> as of the date such litigation is filed. +> 4. Redistribution. You may reproduce and distribute copies of the +> Work or Derivative Works thereof in any medium, with or without +> modifications, and in Source or Object form, provided that You +> meet the following conditions: +> +> (a) You must give any other recipients of the Work or +> Derivative Works a copy of this License; and +> +> (b) You must cause any modified files to carry prominent notices +> stating that You changed the files; and +> +> (c) You must retain, in the Source form of any Derivative Works +> that You distribute, all copyright, patent, trademark, and +> attribution notices from the Source form of the Work, +> excluding those notices that do not pertain to any part of +> the Derivative Works; and +> +> (d) If the Work includes a "NOTICE" text file as part of its +> distribution, then any Derivative Works that You distribute must +> include a readable copy of the attribution notices contained +> within such NOTICE file, excluding those notices that do not +> pertain to any part of the Derivative Works, in at least one +> of the following places: within a NOTICE text file distributed +> as part of the Derivative Works; within the Source form or +> documentation, if provided along with the Derivative Works; or, +> within a display generated by the Derivative Works, if and +> wherever such third-party notices normally appear. The contents +> of the NOTICE file are for informational purposes only and +> do not modify the License. You may add Your own attribution +> notices within Derivative Works that You distribute, alongside +> or as an addendum to the NOTICE text from the Work, provided +> that such additional attribution notices cannot be construed +> as modifying the License. +> +> You may add Your own copyright statement to Your modifications and +> may provide additional or different license terms and conditions +> for use, reproduction, or distribution of Your modifications, or +> for any such Derivative Works as a whole, provided Your use, +> reproduction, and distribution of the Work otherwise complies with +> the conditions stated in this License. +> +> 5. Submission of Contributions. Unless You explicitly state otherwise, +> any Contribution intentionally submitted for inclusion in the Work +> by You to the Licensor shall be under the terms and conditions of +> this License, without any additional terms or conditions. +> Notwithstanding the above, nothing herein shall supersede or modify +> the terms of any separate license agreement you may have executed +> with Licensor regarding such Contributions. +> 6. Trademarks. This License does not grant permission to use the trade +> names, trademarks, service marks, or product names of the Licensor, +> except as required for reasonable and customary use in describing the +> origin of the Work and reproducing the content of the NOTICE file. +> 7. Disclaimer of Warranty. Unless required by applicable law or +> agreed to in writing, Licensor provides the Work (and each +> Contributor provides its Contributions) on an "AS IS" BASIS, +> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +> implied, including, without limitation, any warranties or conditions +> of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A +> PARTICULAR PURPOSE. You are solely responsible for determining the +> appropriateness of using or redistributing the Work and assume any +> risks associated with Your exercise of permissions under this License. +> 8. Limitation of Liability. In no event and under no legal theory, +> whether in tort (including negligence), contract, or otherwise, +> unless required by applicable law (such as deliberate and grossly +> negligent acts) or agreed to in writing, shall any Contributor be +> liable to You for damages, including any direct, indirect, special, +> incidental, or consequential damages of any character arising as a +> result of this License or out of the use or inability to use the +> Work (including but not limited to damages for loss of goodwill, +> work stoppage, computer failure or malfunction, or any and all +> other commercial damages or losses), even if such Contributor +> has been advised of the possibility of such damages. +> 9. Accepting Warranty or Additional Liability. While redistributing +> the Work or Derivative Works thereof, You may choose to offer, +> and charge a fee for, acceptance of support, warranty, indemnity, +> or other liability obligations and/or rights consistent with this +> License. However, in accepting such obligations, You may act only +> on Your own behalf and on Your sole responsibility, not on behalf +> of any other Contributor, and only if You agree to indemnify, +> defend, and hold each Contributor harmless for any liability +> incurred by, or claims asserted against, such Contributor by reason +> of your accepting any such warranty or additional liability. +> +> END OF TERMS AND CONDITIONS +> +> APPENDIX: How to apply the Apache License to your work. +> +> To apply the Apache License to your work, attach the following +> boilerplate notice, with the fields enclosed by brackets "[]" +> replaced with your own identifying information. (Don't include +> the brackets!) The text should be enclosed in the appropriate +> comment syntax for the file format. We also recommend that a +> file or class name and description of purpose be included on the +> same "printed page" as the copyright notice for easier +> identification within third-party archives. +> +> Copyright 2017 Vercel, Inc. +> +> Licensed under the Apache License, Version 2.0 (the "License"); +> you may not use this file except in compliance with the License. +> You may obtain a copy of the License at +> +> http://www.apache.org/licenses/LICENSE-2.0 +> +> Unless required by applicable law or agreed to in writing, software +> distributed under the License is distributed on an "AS IS" BASIS, +> WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +> See the License for the specific language governing permissions and +> limitations under the License. + ### @vitest/expect Licensed under MIT license in the repository at git+https://github.com/vitest-dev/vitest.git. @@ -953,6 +1181,32 @@ Licensed under MIT license in the repository at git+https://github.com/Rich-Harr > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +### package-manager-detector + +Licensed under MIT license in the repository at git+https://github.com/antfu-collective/package-manager-detector.git. + +> MIT License +> +> Copyright (c) 2020-PRESENT Anthony Fu +> +> Permission is hereby granted, free of charge, to any person obtaining a copy +> of this software and associated documentation files (the "Software"), to deal +> in the Software without restriction, including without limitation the rights +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the Software is +> furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all +> copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +> SOFTWARE. + ### pathe Licensed under MIT license in the repository at unjs/pathe. @@ -1179,6 +1433,32 @@ Licensed under MIT license in the repository at https://github.com/rspack-contri > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE > SOFTWARE. +### sisteransi + +Licensed under MIT license in the repository at https://github.com/terkelg/sisteransi. + +> MIT License +> +> Copyright (c) 2018 Terkel Gjervig Nielsen +> +> Permission is hereby granted, free of charge, to any person obtaining a copy +> of this software and associated documentation files (the "Software"), to deal +> in the Software without restriction, including without limitation the rights +> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +> copies of the Software, and to permit persons to whom the Software is +> furnished to do so, subject to the following conditions: +> +> The above copyright notice and this permission notice shall be included in all +> copies or substantial portions of the Software. +> +> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +> SOFTWARE. + ### source-map Licensed under BSD-3-Clause license in the repository at http://github.com/mozilla/source-map.git. diff --git a/packages/core/package.json b/packages/core/package.json index 562243ed0..25bc13563 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -80,6 +80,8 @@ "@types/jsdom": "^21.1.7", "@types/picomatch": "^4.0.2", "@types/sinonjs__fake-timers": "^8.1.5", + "@clack/prompts": "^0.10.1", + "@vercel/detect-agent": "^1.0.0", "@types/source-map-support": "^0.5.10", "@vitest/expect": "^3.2.4", "@vitest/snapshot": "^3.2.4", @@ -91,6 +93,7 @@ "jest-diff": "^30.2.0", "jsdom": "^26.1.0", "memfs": "^4.51.1", + "package-manager-detector": "^1.6.0", "pathe": "^2.0.3", "picocolors": "^1.1.1", "picomatch": "^4.0.3", diff --git a/packages/core/rslib.config.ts b/packages/core/rslib.config.ts index 81350e2e2..64424769e 100644 --- a/packages/core/rslib.config.ts +++ b/packages/core/rslib.config.ts @@ -1,5 +1,6 @@ import { pluginNodePolyfill } from '@rsbuild/plugin-node-polyfill'; import { defineConfig, rspack } from '@rslib/core'; +import { peerDependencies } from '../browser/package.json'; import { licensePlugin } from './licensePlugin'; import { version } from './package.json'; @@ -167,6 +168,7 @@ export default defineConfig({ source: { define: { RSTEST_VERSION: JSON.stringify(version), + PLAYWRIGHT_VERSION: JSON.stringify(peerDependencies.playwright), }, }, tools: { diff --git a/packages/core/src/cli/commands.ts b/packages/core/src/cli/commands.ts index db2997292..5c012267e 100644 --- a/packages/core/src/cli/commands.ts +++ b/packages/core/src/cli/commands.ts @@ -235,5 +235,54 @@ export function setupCommands(): void { }, ); + // init command - initialize rstest configuration + cli + .command('init [project]', 'Initialize rstest configuration') + .option('--yes', 'Use default options (non-interactive)') + .action(async (project: string | undefined, options: { yes?: boolean }) => { + try { + let selectedProject = project; + + // If no project specified, show selection menu + if (!selectedProject) { + const { select, isCancel } = await import('@clack/prompts'); + const color = (await import('picocolors')).default; + + console.log(); + const selected = await select({ + message: 'What would you like to initialize?', + options: [ + { + value: 'browser', + label: 'browser', + hint: 'Browser mode for component testing', + }, + ], + }); + + if (isCancel(selected)) { + console.log(color.yellow('Operation cancelled.')); + process.exit(0); + } + + selectedProject = selected as string; + } + + if (selectedProject === 'browser') { + const { create } = await import('./init/browser'); + await create({ yes: options.yes }); + } else { + logger.error( + `Unknown project type: "${selectedProject}". Available: browser`, + ); + process.exit(1); + } + } catch (err) { + logger.error('Failed to initialize rstest.'); + logger.error(formatError(err)); + process.exit(1); + } + }); + cli.parse(); } diff --git a/packages/core/src/cli/init/browser/create.ts b/packages/core/src/cli/init/browser/create.ts new file mode 100644 index 000000000..5239395a2 --- /dev/null +++ b/packages/core/src/cli/init/browser/create.ts @@ -0,0 +1,362 @@ +import path from 'node:path'; +import * as p from '@clack/prompts'; +import { determineAgent } from '@vercel/detect-agent'; +import color from 'picocolors'; +import { detectProject } from './detect'; +import type { BrowserProvider, Framework } from './templates'; +import { + getConfigFileName, + getConfigTemplate, + getDependenciesWithVersions, + getInstallCommand, + getPlaywrightInstallCommand, + getReactComponentTemplate, + getReactTestTemplate, + getRunCommand, + getVanillaComponentTemplate, + getVanillaTestTemplate, +} from './templates'; +import { + ensureDir, + getUniqueBaseName, + updatePackageJsonDevDeps, + updatePackageJsonScripts, + writeFile, +} from './utils'; + +export interface CreateOptions { + /** Non-interactive mode, use default options */ + yes?: boolean; +} + +type ProjectInfo = Awaited>; + +/** Preview info for files to be created */ +interface FilePreview { + configFile: string; + componentFile: string; + testFile: string; + framework: Framework; +} + +/** + * Main init function for browser mode. + */ +export async function create(options: CreateOptions = {}): Promise { + const cwd = process.cwd(); + const { yes: nonInteractive } = options; + + // Detect project info + const projectInfo = await detectProject(cwd); + + // Check if running in AI agent environment + const { isAgent } = await determineAgent(); + + if (nonInteractive) { + // Non-interactive mode + await createNonInteractive(cwd, projectInfo); + } else { + // Interactive mode + await createInteractive(cwd, projectInfo, isAgent); + } +} + +/** + * Compute which files will be created (for preview). + */ +function computeFilePreview( + cwd: string, + projectInfo: ProjectInfo, +): FilePreview { + const { language, testDir, framework } = projectInfo; + const effectiveFramework: Framework = + framework === 'react' ? 'react' : 'vanilla'; + + const configFile = getConfigFileName(); + + // Determine file extensions based on framework and language + let componentExt: string; + let testExt: string; + + if (effectiveFramework === 'react') { + componentExt = language === 'ts' ? '.tsx' : '.jsx'; + testExt = language === 'ts' ? '.test.tsx' : '.test.jsx'; + } else { + componentExt = language === 'ts' ? '.ts' : '.js'; + testExt = language === 'ts' ? '.test.ts' : '.test.js'; + } + + const testDirPath = path.join(cwd, testDir); + const baseName = getUniqueBaseName(testDirPath, 'Counter', componentExt); + + return { + configFile, + componentFile: `${testDir}/${baseName}${componentExt}`, + testFile: `${testDir}/${baseName}${testExt}`, + framework: effectiveFramework, + }; +} + +/** + * Non-interactive creation (--yes mode). + */ +async function createNonInteractive( + cwd: string, + projectInfo: ProjectInfo, +): Promise { + const { agent, testDir, framework, reactVersion } = projectInfo; + const provider: BrowserProvider = 'playwright'; + + console.log(); + console.log(color.cyan('◆'), color.bold('rstest init browser --yes')); + console.log(); + + // Show detection results + console.log(' Detecting project...'); + if (framework === 'react' && reactVersion) { + console.log(color.green(' ✓'), `Found React ${reactVersion}`); + } else if (framework === 'react') { + console.log(color.green(' ✓'), 'Found React'); + } else { + console.log( + color.yellow(' ⚠'), + 'Framework not detected, generating vanilla DOM example', + ); + } + console.log(color.green(' ✓'), 'Using playwright as browser provider'); + console.log(color.green(' ✓'), `Test directory: ${testDir}/`); + console.log(); + + // Generate files + const createdFiles = await generateFiles(cwd, projectInfo, provider); + + // Show created files + console.log(' Created files:'); + for (const file of createdFiles) { + console.log(` - ${file}`); + } + console.log(' - Updated package.json'); + console.log(); + + // Show next steps + console.log(' Next steps:'); + console.log(` ${getInstallCommand(agent)}`); + console.log(` ${getPlaywrightInstallCommand(agent, provider)}`); + console.log(` ${getRunCommand(agent)}`); + console.log(); + + console.log(color.green('└'), 'Done!'); +} + +/** + * Interactive creation with prompts. + */ +async function createInteractive( + cwd: string, + projectInfo: ProjectInfo, + isAgent: boolean, +): Promise { + const { agent, language, testDir, framework, reactVersion } = projectInfo; + const effectiveFramework: Framework = + framework === 'react' ? 'react' : 'vanilla'; + + p.intro(color.bgCyan(color.black(' rstest init browser '))); + + // Step 1: Show detection results + const detectionLines: string[] = []; + if (framework === 'react' && reactVersion) { + detectionLines.push(`${color.green('✓')} Found React ${reactVersion}`); + } else if (framework === 'react') { + detectionLines.push(`${color.green('✓')} Found React`); + } else { + detectionLines.push( + `${color.yellow('⚠')} Framework not detected, will generate vanilla DOM example`, + ); + } + detectionLines.push( + `${color.green('✓')} Found ${language === 'ts' ? 'TypeScript' : 'JavaScript'}`, + ); + detectionLines.push(`${color.green('✓')} Test directory: ${testDir}/`); + + p.note(detectionLines.join('\n'), 'Detecting project...'); + + // Show agent hint if running in AI agent environment + if (isAgent) { + p.log.info( + `AI Agent detected. For non-interactive mode, run:\n ${color.cyan('npx rstest init browser --yes')}`, + ); + } + + // Step 2: Choose browser provider (only playwright supported for now) + const providerSelection = await p.select({ + message: 'Choose a browser provider (so far, only Playwright)', + options: [ + { + value: 'playwright', + label: 'Playwright', + hint: 'recommended', + }, + ], + }); + + if (p.isCancel(providerSelection)) { + p.cancel('Operation cancelled.'); + process.exit(0); + } + + const provider = providerSelection; + + // Step 3: Preview changes + const preview = computeFilePreview(cwd, projectInfo); + const deps = getDependenciesWithVersions( + effectiveFramework, + provider, + RSTEST_VERSION, + ); + const depsList = Object.entries(deps) + .map(([name, version]) => `${name}@${version}`) + .join(', '); + + const previewLines = [ + `${color.cyan('+')} Create ${preview.configFile}`, + `${color.cyan('+')} Create ${preview.componentFile}`, + `${color.cyan('+')} Create ${preview.testFile}`, + `${color.yellow('~')} Modify package.json`, + ` - Add "test:browser" script`, + ` - Add devDependencies: ${color.dim(depsList)}`, + ]; + p.note(previewLines.join('\n'), 'Changes to be made'); + + // Step 4: Confirm + const confirmed = await p.confirm({ + message: 'Proceed with these changes?', + initialValue: true, + }); + + if (p.isCancel(confirmed) || !confirmed) { + p.cancel('Operation cancelled.'); + process.exit(0); + } + + // Step 5: Generate files + const s = p.spinner(); + s.start('Creating files...'); + + const createdFiles = await generateFiles(cwd, projectInfo, provider); + + s.stop('Created files'); + + // Show created files + const fileLines = createdFiles.map((f) => `${color.green('✓')} Created ${f}`); + fileLines.push(`${color.green('✓')} Updated package.json`); + p.note(fileLines.join('\n'), 'Files'); + + // Step 6: Show next steps + const nextStepsLines = [ + `${color.bold('1.')} Install dependencies:`, + ` ${color.cyan(getInstallCommand(agent))}`, + '', + `${color.bold('2.')} Install Playwright browsers:`, + ` ${color.cyan(getPlaywrightInstallCommand(agent, provider))}`, + '', + `${color.bold('3.')} Run your tests:`, + ` ${color.cyan(getRunCommand(agent))}`, + ]; + + p.note(nextStepsLines.join('\n'), 'Next steps'); + + p.outro(color.green('Done! Happy testing with Rstest!')); +} + +/** + * Generate all required files. + * @returns List of created file paths (relative to cwd) + */ +async function generateFiles( + cwd: string, + projectInfo: ProjectInfo, + provider: BrowserProvider, +): Promise { + const { language, testDir, framework } = projectInfo; + const effectiveFramework: Framework = + framework === 'react' ? 'react' : 'vanilla'; + const createdFiles: string[] = []; + + // 1. Create config file + const configFileName = getConfigFileName(); + const configPath = path.join(cwd, configFileName); + writeFile(configPath, getConfigTemplate()); + createdFiles.push(configFileName); + + // 2. Ensure test directory exists + const testDirPath = path.join(cwd, testDir); + ensureDir(testDirPath); + + // 3. Create example files based on framework + let componentExt: string; + let testExt: string; + + if (effectiveFramework === 'react') { + componentExt = language === 'ts' ? '.tsx' : '.jsx'; + testExt = language === 'ts' ? '.test.tsx' : '.test.jsx'; + } else { + componentExt = language === 'ts' ? '.ts' : '.js'; + testExt = language === 'ts' ? '.test.ts' : '.test.js'; + } + + // Get unique base name to avoid conflicts + const baseName = getUniqueBaseName(testDirPath, 'Counter', componentExt); + + // Create component file + const componentFileName = `${baseName}${componentExt}`; + const componentPath = path.join(testDirPath, componentFileName); + + if (effectiveFramework === 'react') { + writeFile(componentPath, getReactComponentTemplate(language)); + } else { + writeFile(componentPath, getVanillaComponentTemplate(language)); + } + createdFiles.push(`${testDir}/${componentFileName}`); + + // Create test file + const testFileName = `${baseName}${testExt}`; + const testPath = path.join(testDirPath, testFileName); + + let testContent: string; + if (effectiveFramework === 'react') { + testContent = getReactTestTemplate(language); + // Update import path if using non-default name + if (baseName !== 'Counter') { + testContent = testContent.replace( + /from '\.\/Counter\.(tsx|jsx)'/, + `from './${baseName}.$1'`, + ); + } + } else { + testContent = getVanillaTestTemplate(language); + // Update import path if using non-default name + if (baseName !== 'Counter') { + testContent = testContent.replace( + /from '\.\/Counter\.(ts|js)'/, + `from './${baseName}.$1'`, + ); + } + } + writeFile(testPath, testContent); + createdFiles.push(`${testDir}/${testFileName}`); + + // 4. Update package.json scripts + updatePackageJsonScripts(cwd, { + 'test:browser': 'rstest --config=rstest.browser.config.ts', + }); + + // 5. Add devDependencies to package.json + const deps = getDependenciesWithVersions( + effectiveFramework, + provider, + RSTEST_VERSION, + ); + updatePackageJsonDevDeps(cwd, deps); + + return createdFiles; +} diff --git a/packages/core/src/cli/init/browser/detect.ts b/packages/core/src/cli/init/browser/detect.ts new file mode 100644 index 000000000..3efe1e80f --- /dev/null +++ b/packages/core/src/cli/init/browser/detect.ts @@ -0,0 +1,95 @@ +import fs from 'node:fs'; +import path from 'node:path'; +import type { Agent } from 'package-manager-detector'; +import { detect as detectPM } from 'package-manager-detector/detect'; +import { readPackageJson } from './utils'; + +export type { Agent }; + +export interface ProjectInfo { + /** Detected framework, null if not detected */ + framework: 'react' | null; + /** Detected language */ + language: 'ts' | 'js'; + /** Detected or default test directory (relative path) */ + testDir: string; + /** Detected package manager agent */ + agent: Agent; + /** React version if detected */ + reactVersion: string | null; +} + +/** + * Detect package manager using package-manager-detector. + */ +async function detectPackageManagerAgent(cwd: string): Promise { + const result = await detectPM({ cwd }); + return result?.agent ?? 'npm'; +} + +/** + * Detect test directory. + * Check in order: tests/ -> test/ -> __tests__/ -> src/__tests__/ + * Returns 'tests/' as default if none exists. + */ +function detectTestDir(cwd: string): string { + const candidates = ['tests', 'test', '__tests__', 'src/__tests__']; + + for (const dir of candidates) { + const fullPath = path.join(cwd, dir); + if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) { + return dir; + } + } + + return 'tests'; +} + +/** + * Detect React and its version from package.json. + */ +function detectReact(pkg: Record): { + detected: boolean; + version: string | null; +} { + const deps = (pkg.dependencies ?? {}) as Record; + const devDeps = (pkg.devDependencies ?? {}) as Record; + + const reactVersion = deps.react ?? devDeps.react ?? null; + + if (reactVersion) { + // Clean up version string (remove ^, ~, etc.) + const cleanVersion = reactVersion.replace(/^[\^~>=<]+/, ''); + return { detected: true, version: cleanVersion }; + } + + return { detected: false, version: null }; +} + +/** + * Detect TypeScript by checking tsconfig.json existence. + */ +function detectTypeScript(cwd: string): boolean { + return fs.existsSync(path.join(cwd, 'tsconfig.json')); +} + +/** + * Detect project information. + */ +export async function detectProject(cwd: string): Promise { + const pkg = readPackageJson(cwd); + const { detected: hasReact, version: reactVersion } = pkg + ? detectReact(pkg) + : { detected: false, version: null }; + const hasTypeScript = detectTypeScript(cwd); + const testDir = detectTestDir(cwd); + const agent = await detectPackageManagerAgent(cwd); + + return { + framework: hasReact ? 'react' : null, + language: hasTypeScript ? 'ts' : 'js', + testDir, + agent, + reactVersion, + }; +} diff --git a/packages/core/src/cli/init/browser/index.ts b/packages/core/src/cli/init/browser/index.ts new file mode 100644 index 000000000..d9292c9da --- /dev/null +++ b/packages/core/src/cli/init/browser/index.ts @@ -0,0 +1,2 @@ +export type { CreateOptions } from './create'; +export { create } from './create'; diff --git a/packages/core/src/cli/init/browser/templates.ts b/packages/core/src/cli/init/browser/templates.ts new file mode 100644 index 000000000..448f83812 --- /dev/null +++ b/packages/core/src/cli/init/browser/templates.ts @@ -0,0 +1,250 @@ +import type { Agent } from 'package-manager-detector'; +import { resolveCommand } from 'package-manager-detector/commands'; + +export type Framework = 'react' | 'vanilla'; +export type BrowserProvider = 'playwright'; + +/** + * Get rstest.config.ts template content. + */ +export function getConfigTemplate(): string { + return `import { defineConfig } from '@rstest/core'; + +export default defineConfig({ + browser: { + enabled: true, + }, +}); +`; +} + +/** + * Get React component template. + */ +export function getReactComponentTemplate(lang: 'ts' | 'js'): string { + if (lang === 'ts') { + return `import { useState } from 'react'; + +export default function Counter({ initial = 0 }: { initial?: number }) { + const [count, setCount] = useState(initial); + + return ( +
+

Count: {count}

+ + +
+ ); +} +`; + } + + return `import { useState } from 'react'; + +export default function Counter({ initial = 0 }) { + const [count, setCount] = useState(initial); + + return ( +
+

Count: {count}

+ + +
+ ); +} +`; +} + +/** + * Get React test file template. + */ +export function getReactTestTemplate(lang: 'ts' | 'js'): string { + const componentExt = lang === 'ts' ? 'tsx' : 'jsx'; + + return `import { expect, test } from '@rstest/core'; +import { render } from '@rstest/browser-react'; +import Counter from './Counter.${componentExt}'; + +test('increments count on button click', async () => { + const screen = await render(); + + await expect.element(screen.getByText('Count: 5')).toBeInTheDocument(); + + await screen.getByRole('button', { name: 'Increment' }).click(); + await expect.element(screen.getByText('Count: 6')).toBeInTheDocument(); +}); +`; +} + +/** + * Get vanilla DOM component template. + */ +export function getVanillaComponentTemplate(lang: 'ts' | 'js'): string { + if (lang === 'ts') { + return `export function createCounter(initial = 0): HTMLElement { + let count = initial; + + const container = document.createElement('div'); + const display = document.createElement('p'); + const incBtn = document.createElement('button'); + const decBtn = document.createElement('button'); + + display.textContent = \`Count: \${count}\`; + incBtn.textContent = 'Increment'; + decBtn.textContent = 'Decrement'; + + incBtn.addEventListener('click', () => { + count++; + display.textContent = \`Count: \${count}\`; + }); + + decBtn.addEventListener('click', () => { + count--; + display.textContent = \`Count: \${count}\`; + }); + + container.append(display, incBtn, decBtn); + return container; +} +`; + } + + return `export function createCounter(initial = 0) { + let count = initial; + + const container = document.createElement('div'); + const display = document.createElement('p'); + const incBtn = document.createElement('button'); + const decBtn = document.createElement('button'); + + display.textContent = \`Count: \${count}\`; + incBtn.textContent = 'Increment'; + decBtn.textContent = 'Decrement'; + + incBtn.addEventListener('click', () => { + count++; + display.textContent = \`Count: \${count}\`; + }); + + decBtn.addEventListener('click', () => { + count--; + display.textContent = \`Count: \${count}\`; + }); + + container.append(display, incBtn, decBtn); + return container; +} +`; +} + +/** + * Get vanilla DOM test file template. + */ +export function getVanillaTestTemplate(lang: 'ts' | 'js'): string { + const ext = lang === 'ts' ? 'ts' : 'js'; + + return `import { expect, test } from '@rstest/core'; +import { page } from '@rstest/browser'; +import { createCounter } from './Counter.${ext}'; + +test('increments count on button click', async () => { + document.body.appendChild(createCounter(5)); + + await expect.element(page.getByText('Count: 5')).toBeInTheDocument(); + + await page.getByRole('button', { name: 'Increment' }).click(); + await expect.element(page.getByText('Count: 6')).toBeInTheDocument(); +}); +`; +} + +/** + * Get the dependencies that need to be installed. + */ +export function getDependencies(framework: Framework): string[] { + const deps = ['@rstest/browser', 'playwright', '@testing-library/dom']; + if (framework === 'react') { + deps.splice(1, 0, '@rstest/browser-react'); + } + return deps; +} + +/** + * Get the dependencies with versions. + * @param rstestVersion The current rstest version to use for rstest packages + */ +export function getDependenciesWithVersions( + framework: Framework, + provider: BrowserProvider, + rstestVersion: string, +): Record { + const deps: Record = { + '@rstest/browser': `^${rstestVersion}`, + '@testing-library/dom': '^10.0.0', + }; + + // Currently we only support Playwright, keep this switch + // so it's easy to extend providers in the future. + if (provider === 'playwright') { + deps.playwright = PLAYWRIGHT_VERSION; + } + if (framework === 'react') { + deps['@rstest/browser-react'] = `^${rstestVersion}`; + } + return deps; +} + +/** + * Get install command for the package manager. + */ +export function getInstallCommand(agent: Agent): string { + const resolved = resolveCommand(agent, 'install', []); + if (!resolved) { + return 'npm install'; + } + return [resolved.command, ...resolved.args].join(' '); +} + +/** + * Get Playwright browsers install command. + */ +export function getPlaywrightInstallCommand( + agent: Agent, + _provider: BrowserProvider, +): string { + const resolved = resolveCommand(agent, 'execute', [ + 'playwright', + 'install', + '--with-deps', + ]); + if (!resolved) { + return 'npx playwright install --with-deps'; + } + return [resolved.command, ...resolved.args].join(' '); +} + +/** + * Get run command for the package manager. + */ +export function getRunCommand(agent: Agent): string { + const resolved = resolveCommand(agent, 'run', ['test:browser']); + if (!resolved) { + return 'npm run test:browser'; + } + return [resolved.command, ...resolved.args].join(' '); +} + +/** + * Get the config file name to create. + */ +export function getConfigFileName(): string { + return 'rstest.browser.config.ts'; +} diff --git a/packages/core/src/cli/init/browser/utils.ts b/packages/core/src/cli/init/browser/utils.ts new file mode 100644 index 000000000..12e430bae --- /dev/null +++ b/packages/core/src/cli/init/browser/utils.ts @@ -0,0 +1,113 @@ +import fs from 'node:fs'; +import path from 'node:path'; + +/** + * Get a unique file name by appending _1, _2, etc. if the file already exists. + * @param dir Directory path + * @param baseName Base file name without extension (e.g., 'HelloWorld') + * @param ext File extension including dot (e.g., '.tsx') + * @returns Unique base name (e.g., 'HelloWorld' or 'HelloWorld_1') + */ +export function getUniqueBaseName( + dir: string, + baseName: string, + ext: string, +): string { + const fullPath = path.join(dir, `${baseName}${ext}`); + if (!fs.existsSync(fullPath)) { + return baseName; + } + + let suffix = 1; + while (fs.existsSync(path.join(dir, `${baseName}_${suffix}${ext}`))) { + suffix++; + } + return `${baseName}_${suffix}`; +} + +/** + * Ensure a directory exists, creating it if necessary. + */ +export function ensureDir(dir: string): void { + if (!fs.existsSync(dir)) { + fs.mkdirSync(dir, { recursive: true }); + } +} + +/** + * Write content to a file. + */ +export function writeFile(filePath: string, content: string): void { + fs.writeFileSync(filePath, content, 'utf-8'); +} + +/** + * Read package.json from a directory. + */ +export function readPackageJson(cwd: string): Record | null { + const pkgPath = path.join(cwd, 'package.json'); + if (!fs.existsSync(pkgPath)) { + return null; + } + try { + const content = fs.readFileSync(pkgPath, 'utf-8'); + return JSON.parse(content); + } catch { + return null; + } +} + +/** + * Update package.json scripts. + */ +export function updatePackageJsonScripts( + cwd: string, + scripts: Record, +): void { + const pkgPath = path.join(cwd, 'package.json'); + + let pkg: Record; + if (fs.existsSync(pkgPath)) { + const content = fs.readFileSync(pkgPath, 'utf-8'); + pkg = JSON.parse(content); + } else { + pkg = {}; + } + + const existingScripts = (pkg.scripts ?? {}) as Record; + pkg.scripts = { ...existingScripts, ...scripts }; + + fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`, 'utf-8'); +} + +/** + * Update package.json devDependencies. + * Only adds dependencies that don't already exist. + */ +export function updatePackageJsonDevDeps( + cwd: string, + deps: Record, +): void { + const pkgPath = path.join(cwd, 'package.json'); + + let pkg: Record; + if (fs.existsSync(pkgPath)) { + const content = fs.readFileSync(pkgPath, 'utf-8'); + pkg = JSON.parse(content); + } else { + pkg = {}; + } + + const existingDevDeps = (pkg.devDependencies ?? {}) as Record; + + // Only add deps that don't already exist + for (const [name, version] of Object.entries(deps)) { + if (!existingDevDeps[name]) { + existingDevDeps[name] = version; + } + } + + pkg.devDependencies = existingDevDeps; + + fs.writeFileSync(pkgPath, `${JSON.stringify(pkg, null, 2)}\n`, 'utf-8'); +} diff --git a/packages/core/src/core/browserLoader.ts b/packages/core/src/core/browserLoader.ts index fa637a8fd..59b443570 100644 --- a/packages/core/src/core/browserLoader.ts +++ b/packages/core/src/core/browserLoader.ts @@ -3,8 +3,6 @@ import { pathToFileURL } from 'node:url'; import type { ListCommandResult } from '../types'; import { color, logger } from '../utils'; -declare const RSTEST_VERSION: string; - /** * Type definition for the @rstest/browser package exports. */ diff --git a/packages/core/src/env.d.ts b/packages/core/src/env.d.ts index 2bed2301a..c6ead8ed5 100644 --- a/packages/core/src/env.d.ts +++ b/packages/core/src/env.d.ts @@ -2,6 +2,7 @@ declare const RSTEST_VERSION: string; declare const RSTEST_SELF_CI: boolean; +declare const PLAYWRIGHT_VERSION: string; /** * Module declaration for @rstest/browser (optional peer dependency). diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ea0da25f3..055862246 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -58,6 +58,9 @@ importers: path-serializer: specifier: 0.5.1 version: 0.5.1 + playwright: + specifier: ^1.49.1 + version: 1.57.0 prettier: specifier: ^3.7.4 version: 3.7.4 @@ -704,6 +707,9 @@ importers: '@babel/code-frame': specifier: ^7.27.1 version: 7.27.1 + '@clack/prompts': + specifier: ^0.10.1 + version: 0.10.1 '@jridgewell/trace-mapping': specifier: 0.3.31 version: 0.3.31 @@ -749,6 +755,9 @@ importers: '@types/source-map-support': specifier: ^0.5.10 version: 0.5.10 + '@vercel/detect-agent': + specifier: ^1.0.0 + version: 1.0.0 '@vitest/expect': specifier: ^3.2.4 version: 3.2.4 @@ -779,6 +788,9 @@ importers: memfs: specifier: ^4.51.1 version: 4.51.1 + package-manager-detector: + specifier: ^1.6.0 + version: 1.6.0 pathe: specifier: ^2.0.3 version: 2.0.3 @@ -1508,6 +1520,12 @@ packages: '@changesets/write@0.4.0': resolution: {integrity: sha512-CdTLvIOPiCNuH71pyDu3rA+Q0n65cmAbXnwWH84rKGiFumFzkmHNT8KHTMEchcxN+Kl8I54xGUhJ7l3E7X396Q==} + '@clack/core@0.4.2': + resolution: {integrity: sha512-NYQfcEy8MWIxrT5Fj8nIVchfRFA26yYKJcvBS7WlUIlw2OmQOY9DhGGXMovyI5J5PpxrCPGkgUi207EBrjpBvg==} + + '@clack/prompts@0.10.1': + resolution: {integrity: sha512-Q0T02vx8ZM9XSv9/Yde0jTmmBQufZhPJfYAg2XrrrxWWaZgq1rr8nU8Hv710BQ1dhoP8rtY7YUdpGej2Qza/cw==} + '@csstools/color-helpers@5.0.2': resolution: {integrity: sha512-JqWH1vsgdGcw2RR6VliXXdA0/59LttzlU8UlRT/iUUsEeWfYq8I+K0yhihEUTTHLRm1EXvpsCx3083EU15ecsA==} engines: {node: '>=18'} @@ -3038,6 +3056,10 @@ packages: peerDependencies: react: '>=18.3.1' + '@vercel/detect-agent@1.0.0': + resolution: {integrity: sha512-AIPgNkmtFcDgPCl+xvTT1ga90OL7OTX2RKM4zu0PMpwBthPfN2DpdHy10n3bh8K+CA22GDU0/ncjzprZsrk0sw==} + engines: {node: '>=14'} + '@vercel/oidc@3.0.3': resolution: {integrity: sha512-yNEQvPcVrK9sIe637+I0jD6leluPxzwJKx/Haw6F4H77CdDsszUn5V3o96LPziXkSNE2B83+Z3mjqGKBK/R6Gg==} engines: {node: '>= 20'} @@ -5644,6 +5666,9 @@ packages: package-manager-detector@0.2.10: resolution: {integrity: sha512-1wlNZK7HW+UE3eGCcMv3hDaYokhspuIeH6enXSnCL1eEZSVDsy/dYwo/4CczhUsrKLA1SSXB+qce8Glw5DEVtw==} + package-manager-detector@1.6.0: + resolution: {integrity: sha512-61A5ThoTiDG/C8s8UMZwSorAGwMJ0ERVGj2OjoW5pAalsNOg15+iQiPzrLJ4jhZ1HJzmC2PIHT2oEiH3R5fzNA==} + pako@1.0.11: resolution: {integrity: sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==} @@ -6631,6 +6656,9 @@ packages: resolution: {integrity: sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ==} engines: {node: '>= 10'} + sisteransi@1.0.5: + resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} + slash@3.0.0: resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==} engines: {node: '>=8'} @@ -8120,6 +8148,17 @@ snapshots: human-id: 4.1.1 prettier: 2.8.8 + '@clack/core@0.4.2': + dependencies: + picocolors: 1.1.1 + sisteransi: 1.0.5 + + '@clack/prompts@0.10.1': + dependencies: + '@clack/core': 0.4.2 + picocolors: 1.1.1 + sisteransi: 1.0.5 + '@csstools/color-helpers@5.0.2': {} '@csstools/css-calc@2.1.4(@csstools/css-parser-algorithms@3.0.5(@csstools/css-tokenizer@3.0.4))(@csstools/css-tokenizer@3.0.4)': @@ -9887,6 +9926,8 @@ snapshots: react: 19.2.3 unhead: 2.0.19 + '@vercel/detect-agent@1.0.0': {} + '@vercel/oidc@3.0.3': {} '@vitest/expect@3.2.4': @@ -13097,6 +13138,8 @@ snapshots: dependencies: quansync: 0.2.4 + package-manager-detector@1.6.0: {} + pako@1.0.11: {} parent-module@1.0.1: @@ -14229,6 +14272,8 @@ snapshots: mrmime: 2.0.1 totalist: 3.0.1 + sisteransi@1.0.5: {} + slash@3.0.0: {} slash@5.1.0: {}