@nuasite/cli 0.39.2 → 0.41.0
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.
- package/README.md +8 -30
- package/dist/index.js +963 -569
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -6
- package/src/index.ts +1 -53
- package/src/tsconfig.json +1 -1
- package/dist/types/build.d.ts +0 -3
- package/dist/types/build.d.ts.map +0 -1
- package/src/build.ts +0 -30
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuasite/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -19,14 +19,11 @@
|
|
|
19
19
|
"nua": "src/index.ts"
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
|
-
"build": "bun build --target=bun --outdir=dist --external lightningcss
|
|
22
|
+
"build": "bun build --target=bun --outdir=dist --external lightningcss src/index.ts",
|
|
23
23
|
"prepack": "bun run ../../scripts/workspace-deps/resolve-deps.ts"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@nuasite/
|
|
27
|
-
"@nuasite/cms": "0.39.2",
|
|
28
|
-
"astro": "6.1.4",
|
|
29
|
-
"stacktracey": "2.2.0"
|
|
26
|
+
"@nuasite/cms": "0.41.0"
|
|
30
27
|
},
|
|
31
28
|
"devDependencies": {
|
|
32
29
|
"@types/bun": "1.3.11"
|
package/src/index.ts
CHANGED
|
@@ -1,21 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import { agentsSummary } from '@nuasite/agent-summary'
|
|
3
|
-
import { type AstroInlineConfig, build as astroBuild, dev, preview } from 'astro'
|
|
4
2
|
import { spawn } from 'node:child_process'
|
|
5
|
-
import { readFileSync } from 'node:fs'
|
|
6
|
-
import { findAstroConfig } from './utils'
|
|
7
3
|
|
|
8
4
|
const [, , command, ...args] = process.argv
|
|
9
5
|
|
|
10
|
-
function hasNuaIntegration(configPath: string): boolean {
|
|
11
|
-
try {
|
|
12
|
-
const content = readFileSync(configPath, 'utf-8')
|
|
13
|
-
return content.includes('@nuasite/agent-summary') || content.includes('agentsSummary')
|
|
14
|
-
} catch {
|
|
15
|
-
return false
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
6
|
function proxyToAstroCLI(command: string, args: string[]) {
|
|
20
7
|
const astro = spawn('npx', ['astro', command, ...args], {
|
|
21
8
|
stdio: 'inherit',
|
|
@@ -45,49 +32,10 @@ function printUsage() {
|
|
|
45
32
|
console.log('\nAll Astro CLI options are supported.\n')
|
|
46
33
|
}
|
|
47
34
|
|
|
48
|
-
|
|
49
|
-
const canProxyDirectly = configPath && hasNuaIntegration(configPath)
|
|
50
|
-
|
|
51
|
-
if (canProxyDirectly && command && ['build', 'dev', 'preview'].includes(command)) {
|
|
35
|
+
if (command && ['build', 'dev', 'preview'].includes(command)) {
|
|
52
36
|
proxyToAstroCLI(command, args)
|
|
53
37
|
} else {
|
|
54
38
|
switch (command) {
|
|
55
|
-
case 'build':
|
|
56
|
-
astroBuild({
|
|
57
|
-
root: process.cwd(),
|
|
58
|
-
integrations: [agentsSummary()],
|
|
59
|
-
}).catch((error) => {
|
|
60
|
-
console.error('Error:', error)
|
|
61
|
-
process.exit(1)
|
|
62
|
-
})
|
|
63
|
-
break
|
|
64
|
-
case 'dev':
|
|
65
|
-
case 'preview': {
|
|
66
|
-
const server: { port?: number; host?: string } = {}
|
|
67
|
-
|
|
68
|
-
for (let i = 0; i < args.length; i++) {
|
|
69
|
-
if (args[i] === '--port' && args[i + 1]) {
|
|
70
|
-
server.port = parseInt(args[i + 1]!, 10)
|
|
71
|
-
i++
|
|
72
|
-
} else if (args[i] === '--host' && args[i + 1]) {
|
|
73
|
-
server.host = args[i + 1]
|
|
74
|
-
i++
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const options: AstroInlineConfig = {
|
|
79
|
-
root: process.cwd(),
|
|
80
|
-
integrations: [agentsSummary()],
|
|
81
|
-
server,
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const runner = command === 'dev' ? dev : preview
|
|
85
|
-
runner(options).catch((error) => {
|
|
86
|
-
console.error('Error:', error)
|
|
87
|
-
process.exit(1)
|
|
88
|
-
})
|
|
89
|
-
break
|
|
90
|
-
}
|
|
91
39
|
case 'init': {
|
|
92
40
|
const { init } = await import('./init')
|
|
93
41
|
await init({
|
package/src/tsconfig.json
CHANGED
package/dist/types/build.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/build.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAuB,MAAM,OAAO,CAAA;AAGnE,wBAAsB,KAAK,CAAC,YAAY,EAAE,iBAAiB,iBA0B1D"}
|
package/src/build.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { type AstroInlineConfig, build as astroBuild } from 'astro'
|
|
2
|
-
import Stacktracey from 'stacktracey'
|
|
3
|
-
|
|
4
|
-
export async function build(inlineConfig: AstroInlineConfig) {
|
|
5
|
-
try {
|
|
6
|
-
await astroBuild(inlineConfig)
|
|
7
|
-
} catch (error) {
|
|
8
|
-
if (error instanceof Error) {
|
|
9
|
-
const stack = new Stacktracey(error.stack).withSources()
|
|
10
|
-
console.error('\nBuild failed:', error.message)
|
|
11
|
-
for (const frame of stack.items) {
|
|
12
|
-
if (frame.native || frame.fileShort.includes('node_modules') || frame.line === undefined) {
|
|
13
|
-
console.error(`at ${frame.calleeShort} (${frame.fileShort}:${frame.line}:${frame.column})`)
|
|
14
|
-
continue
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const contextLines = frame.sourceFile?.lines.slice(frame.line - 3, frame.line + 2) || []
|
|
18
|
-
const context = contextLines.map((line, index) => {
|
|
19
|
-
const lineNumber = frame.line! - 2 + index
|
|
20
|
-
const isCurrentPrefix = lineNumber === frame.line ? '>' : ' '
|
|
21
|
-
return `${isCurrentPrefix} ${lineNumber}: ${line}`
|
|
22
|
-
}).join('\n')
|
|
23
|
-
console.error(`at ${frame.calleeShort} (${frame.fileShort}:${frame.line}:${frame.column})\n${context}`)
|
|
24
|
-
}
|
|
25
|
-
} else {
|
|
26
|
-
console.error('Build failed:', error)
|
|
27
|
-
}
|
|
28
|
-
process.exit(1)
|
|
29
|
-
}
|
|
30
|
-
}
|