ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / extensions / aura-harness / harness / tools / frontend-init.mjs 98 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import fs from 'node:fs' ;
import path from 'node:path' ;
import { HARNESS_ROOT , parseArgs, readJson, walkFiles, appendEvent, fail } from './lib.mjs' ;
import { detectPackageManager, detectFrontend } from './gates.mjs' ;
const { flags } = parseArgs ( process. argv . slice ( 2 ) ) ;
const cwd = path. resolve ( flags. cwd && flags flags process
write flags
withUnit flags flags
pkgFile path cwd
pkg pkgFile
pkg
cwd flags
templates path
fs templates
pm cwd
pm
deps pkg pkg
scripts pkg
isNext deps
devCmd scripts isNext
prodReady scripts scripts
buildCmd prodReady
serveCmd prodReady devCmd
hasUnitRunner d deps scripts
plan
file templates
relPath path templates file
withUnit hasUnitRunner relPath
dest path cwd relPath
fs dest
plan relPath
plan relPath
write
content fs file devCmd buildCmd serveCmd
fs path dest
fs dest content
wantedScripts
scripts fs path cwd wantedScripts
withUnit hasUnitRunner
wantedScripts
wantedScripts
name cmd wantedScripts scripts name plan name cmd
wantedDeps
withUnit hasUnitRunner wantedDeps
deps fs path cwd wantedDeps
plan wantedDeps d deps
gitignoreFile path cwd
gitignore fs gitignoreFile fs gitignoreFile
plan gitignore l
write
plan
pkg scripts plan
fs pkgFile
plan fs gitignoreFile
cwd plan plan plan
add pm
exec pm
plan
plan
prodReady
write
.
cwd
!==
true
?
.
cwd
:
.
cwd
(
)
)
;
const
=
Boolean
(
.
write
)
;
const
=
.
unit
!==
'false'
&&
[
'no-unit'
]
!==
true
;
const
=
.
join
(
,
'package.json'
)
;
const
=
readJson
(
,
null
)
;
if
(
!
)
{
fail
(
` No package.json in ${ cwd} `
)
;
}
if
(
!
detectFrontend
(
)
&&
!
.
force
)
{
fail
(
'No frontend framework detected in package.json (use --force to scaffold anyway)'
)
;
}
const
=
.
join
(
HARNESS_ROOT
,
'templates'
,
'frontend'
)
;
if
(
!
.
existsSync
(
)
)
{
fail
(
` Templates missing at ${ templates} ; reinstall the harness `
)
;
}
const
=
detectPackageManager
(
)
??
'npm'
;
const
run
=
(
script
)
=>
(
===
'npm'
?
` npm run ${ script} `
:
` ${ pm} ${ script} `
)
;
const
=
{
...
.
dependencies
,
...
.
devDependencies
}
;
const
=
.
scripts
??
{
}
;
const
=
'next'
in
;
const
=
.
dev
?
run
(
'dev'
)
:
?
` ${ pm === 'npm' ? 'npx' : ` ${ pm} exec ` } next dev `
:
run
(
'start'
)
;
const
=
Boolean
(
.
build
&&
.
start
)
;
const
=
?
` ${ run ( 'build' ) } && `
:
''
;
const
=
?
run
(
'start'
)
:
;
const
=
[
'vitest'
,
'jest'
]
.
some
(
(
d
)
=>
in
)
||
Boolean
(
.
test
)
;
const
=
{
files
:
[
]
,
skipped
:
[
]
,
scripts
:
{
}
,
devDependencies
:
[
]
,
gitignore
:
[
]
}
;
for
(
const
of
walkFiles
(
,
{
skip
:
[
]
}
)
)
{
const
=
.
relative
(
,
)
;
if
(
!
||
)
{
if
(
/ ^ vitest\. /
.
test
(
)
)
{
continue
;
}
}
const
=
.
join
(
,
)
;
if
(
.
existsSync
(
)
)
{
.
skipped
.
push
(
)
;
continue
;
}
.
files
.
push
(
)
;
if
(
)
{
const
=
.
readFileSync
(
,
'utf8'
)
.
replaceAll
(
'__DEV_CMD__'
,
)
.
replaceAll
(
'__BUILD_CMD__'
,
)
.
replaceAll
(
'__SERVE_CMD__'
,
)
;
.
mkdirSync
(
.
dirname
(
)
,
{
recursive
:
true
}
)
;
.
writeFileSync
(
,
)
;
}
}
const
=
{
'test:e2e'
:
'playwright test --grep @e2e'
,
'test:a11y'
:
'playwright test --grep @a11y'
,
'test:visual'
:
'playwright test --grep @visual'
,
'test:visual:update'
:
'playwright test --grep @visual --update-snapshots'
,
'test:perf'
:
'lhci autorun'
,
'test:journeys'
:
'node ~/.agent-harness/tools/journeys.mjs --cwd .'
,
}
;
if
(
!
.
typecheck
&&
.
existsSync
(
.
join
(
,
'tsconfig.json'
)
)
)
{
.
typecheck
=
'tsc --noEmit'
;
}
if
(
&&
!
)
{
[
'test:unit'
]
=
'vitest run'
;
.
test
=
'vitest run'
;
}
for
(
const
[
,
]
of
Object
.
entries
(
)
)
{
if
(
!
[
]
)
{
.
scripts
[
]
=
;
}
}
const
=
[
'@playwright/test'
,
'@axe-core/playwright'
,
'@lhci/cli'
]
;
if
(
&&
!
)
{
.
push
(
'vitest'
,
'@vitejs/plugin-react'
,
'jsdom'
,
'@testing-library/react'
,
'@testing-library/jest-dom'
,
'@testing-library/user-event'
)
;
}
if
(
!
(
'typescript'
in
)
&&
.
existsSync
(
.
join
(
,
'tsconfig.json'
)
)
)
{
.
push
(
'typescript'
)
;
}
.
devDependencies
=
.
filter
(
(
d
)
=>
!
(
in
)
)
;
const
=
.
join
(
,
'.gitignore'
)
;
const
=
.
existsSync
(
)
?
.
readFileSync
(
,
'utf8'
)
.
split
(
'\n'
)
:
[
]
;
.
gitignore
=
[
'.agent-state/'
,
'.agent-worktrees/'
,
'.lighthouseci/'
,
'test-results/'
,
'playwright-report/'
]
.
filter
(
(
l
)
=>
!
.
includes
(
)
)
;
if
(
)
{
if
(
Object
.
keys
(
.
scripts
)
.
length
)
{
.
scripts
=
{
...
,
...
.
scripts
}
;
.
writeFileSync
(
,
` ${ JSON . stringify ( pkg, null , 2 ) } \n `
)
;
}
if
(
.
gitignore
.
length
)
{
.
appendFileSync
(
,
` ${ gitignore. length && gitignore. at ( - 1 ) !== '' ? '\n' : '' } ${ plan. gitignore . join ( '\n' ) } \n `
)
;
}
appendEvent
(
,
{
type
:
'frontend.init'
,
files
:
.
files
,
scripts
:
Object
.
keys
(
.
scripts
)
,
devDependencies
:
.
devDependencies
}
)
;
}
const
=
{
pnpm
:
'pnpm add -D'
,
yarn
:
'yarn add -D'
,
bun
:
'bun add -d'
,
npm
:
'npm i -D'
}
[
]
??
'npm i -D'
;
const
=
===
'npm'
?
'npx'
:
` ${ pm} exec `
;
console
.
log
(
` ${ write ? 'Applied' : '[dry-run] Would apply' } frontend quality contour in ${ cwd} (pm: ${ pm} )\n `
)
;
console
.
log
(
` files: ${ plan. files . join ( ', ' ) || '—' } `
)
;
if
(
.
skipped
.
length
)
{
console
.
log
(
` kept: ${ plan. skipped . join ( ', ' ) } (already exist) `
)
;
}
console
.
log
(
` scripts: ${ Object . keys ( plan. scripts ) . join ( ', ' ) || '—' } `
)
;
console
.
log
(
` ignore: ${ plan. gitignore . join ( ' ' ) || '—' } `
)
;
console
.
log
(
'\nNext steps (installs need human approval):'
)
;
if
(
.
devDependencies
.
length
)
{
console
.
log
(
` 1. ${ add} ${ plan. devDependencies . join ( ' ' ) } `
)
;
}
console
.
log
(
` 2. ${ exec} playwright install --with-deps chromium `
)
;
console
.
log
(
' 3. Add every route to e2e/routes.ts and ROUTES in lighthouserc.cjs; write at least one component test (*.test.tsx).'
)
;
if
(
!
)
{
console
.
log
(
' note: no build+start scripts, Lighthouse will measure the dev server (numbers are pessimistic).'
)
;
}
console
.
log
(
' Lighthouse needs Chrome: set CHROME_PATH if it is not in PATH.'
)
;
console
.
log
(
` 4. Baselines on the CI platform, with approval: ${ run ( 'test:visual:update' ) } `
)
;
console
.
log
(
' 5. node ~/.agent-harness/tools/gates.mjs'
)
;
if
(
!
)
{
console
.
log
(
'\nRe-run with --write to apply.'
)
;
}