nuxt-spec 0.4.0-alpha.2 → 0.4.0-alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +13 -13
  3. package/app/app.vue +10 -10
  4. package/app/components/NuxtSpecApiTestComponent.vue +24 -24
  5. package/app/components/NuxtSpecTestComponent.vue +9 -9
  6. package/app/components/index.d.ts +7 -7
  7. package/app/components/index.ts +2 -2
  8. package/app/utils/vitest-utils.ts +5 -5
  9. package/config/index.d.ts +36 -36
  10. package/config/index.mjs +147 -147
  11. package/config/report/report-entry.html +6 -6
  12. package/config/report/report-head.html +34 -34
  13. package/config/report/report-screenshot.html +8 -8
  14. package/config/report/report-tail.html +4 -4
  15. package/config/templates/.github/workflows/ci-test-update.yml.template +105 -105
  16. package/config/templates/.github/workflows/ci-test-verify.yml.template +68 -68
  17. package/config/templates/.gitlab/ci/ci-test-update.yml.template +69 -69
  18. package/config/templates/.gitlab/ci/ci-test-verify.yml.template +41 -41
  19. package/config/templates/.gitlab-ci.yml.template +6 -6
  20. package/config/templates/pnpm-workspace.yaml.template +19 -19
  21. package/config/templates/vitest.config.ts.template +5 -5
  22. package/config/utils/merge.mjs +43 -43
  23. package/config/utils/options.d.mts +59 -59
  24. package/config/utils/options.mjs +116 -116
  25. package/config/utils/reporter.mjs +409 -409
  26. package/config/utils/warnings.mjs +38 -38
  27. package/modules/spec-options.ts +23 -23
  28. package/nuxt.config.ts +20 -20
  29. package/package.json +17 -23
  30. package/utils/e2e.ts +131 -131
  31. package/utils/helpers/check-params.ts +44 -44
  32. package/utils/helpers/location-hint.ts +30 -30
  33. package/utils/helpers/screenshot-utils.ts +27 -27
  34. package/utils/index.ts +12 -12
  35. package/utils/playwright.ts +28 -28
  36. package/utils/screenshot.ts +201 -201
  37. package/bin/_internal/prepublish-check.js +0 -16
  38. package/bin/cli.js +0 -53
  39. package/bin/commands/ci.js +0 -124
  40. package/bin/commands/setup.js +0 -367
  41. package/bin/commands/update.js +0 -126
  42. package/bin/helpers/commands.js +0 -82
  43. package/bin/helpers/constants.js +0 -8
  44. package/bin/helpers/git.js +0 -73
@@ -1,82 +0,0 @@
1
- import { getPackageManager } from 'elrh-cosca'
2
-
3
- export const SUPPORTED_PACKAGE_MANAGERS = ['npm', 'pnpm', 'yarn', 'bun', 'deno']
4
-
5
- // get the package manager name for usage in commands
6
- // explicit override takes precedence over auto-detection
7
- export function resolvePackageManager(override) {
8
- if (override) {
9
- if (!SUPPORTED_PACKAGE_MANAGERS.includes(override)) {
10
- throw new Error(`Unsupported package manager '${override}'. Use one of: ${SUPPORTED_PACKAGE_MANAGERS.join(', ')}`)
11
- }
12
- return override
13
- }
14
- return getPackageManager()
15
- }
16
-
17
- // use nuxt-spec CLI tool
18
- export function getCmd(packageManager) {
19
- const command = 'nuxt-spec'
20
- switch (packageManager) {
21
- case 'pnpm':
22
- return `pnpx ${command}`
23
- case 'yarn':
24
- return `yarn dlx ${command}`
25
- case 'bun':
26
- return `bunx ${command}`
27
- case 'deno':
28
- return `deno run -A npm:${command}`
29
- default:
30
- return `npx ${command}`
31
- }
32
- }
33
-
34
- // update nuxt-spec
35
- export function getUpdateCmd(packageManager, target) {
36
- switch (packageManager) {
37
- case 'pnpm':
38
- return `pnpm update ${target}`
39
- case 'yarn':
40
- return `yarn up ${target}`
41
- case 'bun':
42
- return `bun update ${target}`
43
- case 'deno':
44
- return `deno add npm:${target}`
45
- default:
46
- return `npm install ${target}`
47
- }
48
- }
49
-
50
- // generate Nuxt types and auto-imports
51
- export function getPrepareCmd(packageManager) {
52
- const command = 'nuxt prepare'
53
- switch (packageManager) {
54
- case 'pnpm':
55
- return `pnpm exec ${command}`
56
- case 'yarn':
57
- return `yarn ${command}`
58
- case 'bun':
59
- return `bunx ${command}`
60
- case 'deno':
61
- return `deno run -A npm:${command}`
62
- default:
63
- return `npx ${command}`
64
- }
65
- }
66
-
67
- // install/update playwright
68
- export function getPlaywrightInstallCmd(packageManager) {
69
- const command = 'playwright install'
70
- switch (packageManager) {
71
- case 'pnpm':
72
- return `pnpm exec ${command}`
73
- case 'yarn':
74
- return `yarn ${command}`
75
- case 'bun':
76
- return `bunx ${command}`
77
- case 'deno':
78
- return `deno run -A npm:${command}`
79
- default:
80
- return `npx ${command}`
81
- }
82
- }
@@ -1,8 +0,0 @@
1
- // current elrh-cosca version for usage in CLI scripts
2
- export const COSCA_VERSION = '0.4.0-alpha.2'
3
-
4
- // URL to current tag in GitHub repository to fetch template files in CLI scripts
5
- export const COSCA_URL = `https://raw.githubusercontent.com/AloisSeckar/nuxt-spec/refs/tags/v${COSCA_VERSION}`
6
-
7
- // current Playwright version for usage in CLI scripts
8
- export const PLAYWRIGHT_VERSION = '1.64.0'
@@ -1,73 +0,0 @@
1
- import { execFileSync } from 'node:child_process'
2
-
3
- export const FALLBACK_DEFAULT_BRANCH = 'main'
4
-
5
- // run a read-only git command, returning trimmed stdout or `undefined` on failure
6
- function git(...args) {
7
- try {
8
- return execFileSync('git', args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim() || undefined
9
- } catch {
10
- return undefined
11
- }
12
- }
13
-
14
- function hasRef(ref) {
15
- try {
16
- execFileSync('git', ['show-ref', '--verify', '--quiet', ref], { stdio: 'ignore' })
17
- return true
18
- } catch {
19
- return false
20
- }
21
- }
22
-
23
- export function isGitRepo() {
24
- return git('rev-parse', '--is-inside-work-tree') === 'true'
25
- }
26
-
27
- /**
28
- * Resolve the default branch of the Git repository in the current working directory.
29
- *
30
- * Tries (in order):
31
- * 1) HEAD of `origin` remote (or the first available remote) - set when cloned or via `git remote set-head <remote> --auto`
32
- * 2) existing local or remote-tracking `main` or `master` branch
33
- * 3) the only local branch, or current branch if there are no commits yet
34
- * 4) `init.defaultBranch` from Git config
35
- *
36
- * @returns {{ branch: string, source: string }} resolved branch name and description of where it came from
37
- */
38
- export function resolveDefaultBranch() {
39
- if (isGitRepo()) {
40
- const remotes = git('remote')?.split(/\r?\n/) ?? []
41
- const remote = remotes.includes('origin') ? 'origin' : remotes[0]
42
- if (remote) {
43
- const remoteHead = git('symbolic-ref', '--quiet', '--short', `refs/remotes/${remote}/HEAD`)
44
- if (remoteHead?.startsWith(`${remote}/`)) {
45
- return { branch: remoteHead.slice(remote.length + 1), source: `HEAD of '${remote}' remote` }
46
- }
47
- }
48
-
49
- for (const candidate of ['main', 'master']) {
50
- if (hasRef(`refs/heads/${candidate}`) || (remote && hasRef(`refs/remotes/${remote}/${candidate}`))) {
51
- return { branch: candidate, source: 'existing branch' }
52
- }
53
- }
54
-
55
- const localBranches = git('for-each-ref', '--format=%(refname:short)', 'refs/heads')?.split(/\r?\n/) ?? []
56
- if (localBranches.length === 1) {
57
- return { branch: localBranches[0], source: 'the only local branch' }
58
- }
59
- if (localBranches.length === 0) {
60
- const unbornHead = git('symbolic-ref', '--quiet', '--short', 'HEAD')
61
- if (unbornHead) {
62
- return { branch: unbornHead, source: 'current branch of repository without commits' }
63
- }
64
- }
65
- }
66
-
67
- const configured = git('config', '--get', 'init.defaultBranch')
68
- if (configured) {
69
- return { branch: configured, source: 'Git config \'init.defaultBranch\'' }
70
- }
71
-
72
- return { branch: FALLBACK_DEFAULT_BRANCH, source: 'fallback value' }
73
- }