@agentuity/cli 0.0.43 → 0.0.45
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/AGENTS.md +1 -1
- package/README.md +1 -1
- package/dist/api.d.ts +3 -3
- package/dist/api.d.ts.map +1 -1
- package/dist/auth.d.ts +10 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/banner.d.ts.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cmd/auth/api.d.ts +4 -4
- package/dist/cmd/auth/api.d.ts.map +1 -1
- package/dist/cmd/auth/index.d.ts.map +1 -1
- package/dist/cmd/auth/login.d.ts.map +1 -1
- package/dist/cmd/auth/signup.d.ts.map +1 -1
- package/dist/cmd/auth/ssh/add.d.ts +2 -0
- package/dist/cmd/auth/ssh/add.d.ts.map +1 -0
- package/dist/cmd/auth/ssh/api.d.ts +16 -0
- package/dist/cmd/auth/ssh/api.d.ts.map +1 -0
- package/dist/cmd/auth/ssh/delete.d.ts +2 -0
- package/dist/cmd/auth/ssh/delete.d.ts.map +1 -0
- package/dist/cmd/auth/ssh/index.d.ts +3 -0
- package/dist/cmd/auth/ssh/index.d.ts.map +1 -0
- package/dist/cmd/auth/ssh/list.d.ts +2 -0
- package/dist/cmd/auth/ssh/list.d.ts.map +1 -0
- package/dist/cmd/auth/whoami.d.ts.map +1 -1
- package/dist/cmd/bundle/ast.d.ts +14 -3
- package/dist/cmd/bundle/ast.d.ts.map +1 -1
- package/dist/cmd/bundle/ast.test.d.ts +2 -0
- package/dist/cmd/bundle/ast.test.d.ts.map +1 -0
- package/dist/cmd/bundle/bundler.d.ts +6 -1
- package/dist/cmd/bundle/bundler.d.ts.map +1 -1
- package/dist/cmd/bundle/file.d.ts.map +1 -1
- package/dist/cmd/bundle/fix-duplicate-exports.d.ts +2 -0
- package/dist/cmd/bundle/fix-duplicate-exports.d.ts.map +1 -0
- package/dist/cmd/bundle/fix-duplicate-exports.test.d.ts +2 -0
- package/dist/cmd/bundle/fix-duplicate-exports.test.d.ts.map +1 -0
- package/dist/cmd/bundle/plugin.d.ts +2 -0
- package/dist/cmd/bundle/plugin.d.ts.map +1 -1
- package/dist/cmd/cloud/deploy.d.ts.map +1 -1
- package/dist/cmd/cloud/domain.d.ts +17 -0
- package/dist/cmd/cloud/domain.d.ts.map +1 -0
- package/dist/cmd/cloud/index.d.ts.map +1 -1
- package/dist/cmd/cloud/resource/add.d.ts +2 -0
- package/dist/cmd/cloud/resource/add.d.ts.map +1 -0
- package/dist/cmd/cloud/resource/delete.d.ts +2 -0
- package/dist/cmd/cloud/resource/delete.d.ts.map +1 -0
- package/dist/cmd/cloud/resource/index.d.ts +3 -0
- package/dist/cmd/cloud/resource/index.d.ts.map +1 -0
- package/dist/cmd/cloud/resource/list.d.ts +2 -0
- package/dist/cmd/cloud/resource/list.d.ts.map +1 -0
- package/dist/cmd/cloud/scp/download.d.ts +2 -0
- package/dist/cmd/cloud/scp/download.d.ts.map +1 -0
- package/dist/cmd/cloud/scp/index.d.ts +3 -0
- package/dist/cmd/cloud/scp/index.d.ts.map +1 -0
- package/dist/cmd/cloud/scp/upload.d.ts +2 -0
- package/dist/cmd/cloud/scp/upload.d.ts.map +1 -0
- package/dist/cmd/cloud/ssh.d.ts +2 -0
- package/dist/cmd/cloud/ssh.d.ts.map +1 -0
- package/dist/cmd/dev/api.d.ts +18 -0
- package/dist/cmd/dev/api.d.ts.map +1 -0
- package/dist/cmd/dev/download.d.ts +11 -0
- package/dist/cmd/dev/download.d.ts.map +1 -0
- package/dist/cmd/dev/index.d.ts.map +1 -1
- package/dist/cmd/dev/templates.d.ts +3 -0
- package/dist/cmd/dev/templates.d.ts.map +1 -0
- package/dist/cmd/env/delete.d.ts.map +1 -1
- package/dist/cmd/env/get.d.ts.map +1 -1
- package/dist/cmd/env/import.d.ts.map +1 -1
- package/dist/cmd/env/list.d.ts.map +1 -1
- package/dist/cmd/env/pull.d.ts.map +1 -1
- package/dist/cmd/env/push.d.ts.map +1 -1
- package/dist/cmd/env/set.d.ts.map +1 -1
- package/dist/cmd/profile/show.d.ts.map +1 -1
- package/dist/cmd/project/create.d.ts.map +1 -1
- package/dist/cmd/project/delete.d.ts.map +1 -1
- package/dist/cmd/project/list.d.ts.map +1 -1
- package/dist/cmd/project/show.d.ts.map +1 -1
- package/dist/cmd/project/template-flow.d.ts +4 -0
- package/dist/cmd/project/template-flow.d.ts.map +1 -1
- package/dist/cmd/secret/delete.d.ts.map +1 -1
- package/dist/cmd/secret/get.d.ts.map +1 -1
- package/dist/cmd/secret/import.d.ts.map +1 -1
- package/dist/cmd/secret/list.d.ts.map +1 -1
- package/dist/cmd/secret/pull.d.ts.map +1 -1
- package/dist/cmd/secret/push.d.ts.map +1 -1
- package/dist/cmd/secret/set.d.ts.map +1 -1
- package/dist/config.d.ts +9 -3
- package/dist/config.d.ts.map +1 -1
- package/dist/crypto/box.d.ts +65 -0
- package/dist/crypto/box.d.ts.map +1 -0
- package/dist/crypto/box.test.d.ts +2 -0
- package/dist/crypto/box.test.d.ts.map +1 -0
- package/dist/download.d.ts.map +1 -1
- package/dist/steps.d.ts +4 -1
- package/dist/steps.d.ts.map +1 -1
- package/dist/terminal.d.ts.map +1 -1
- package/dist/tui.d.ts +31 -1
- package/dist/tui.d.ts.map +1 -1
- package/dist/types.d.ts +249 -126
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/detectSubagent.d.ts +15 -0
- package/dist/utils/detectSubagent.d.ts.map +1 -0
- package/dist/utils/zip.d.ts +7 -0
- package/dist/utils/zip.d.ts.map +1 -0
- package/package.json +11 -3
- package/src/api-errors.md +2 -2
- package/src/api.ts +12 -7
- package/src/auth.ts +116 -7
- package/src/banner.ts +13 -6
- package/src/cli.ts +695 -63
- package/src/cmd/auth/api.ts +10 -16
- package/src/cmd/auth/index.ts +2 -1
- package/src/cmd/auth/login.ts +24 -8
- package/src/cmd/auth/signup.ts +15 -11
- package/src/cmd/auth/ssh/add.ts +263 -0
- package/src/cmd/auth/ssh/api.ts +94 -0
- package/src/cmd/auth/ssh/delete.ts +102 -0
- package/src/cmd/auth/ssh/index.ts +10 -0
- package/src/cmd/auth/ssh/list.ts +74 -0
- package/src/cmd/auth/whoami.ts +13 -13
- package/src/cmd/bundle/ast.test.ts +565 -0
- package/src/cmd/bundle/ast.ts +457 -44
- package/src/cmd/bundle/bundler.ts +255 -57
- package/src/cmd/bundle/file.ts +6 -12
- package/src/cmd/bundle/fix-duplicate-exports.test.ts +387 -0
- package/src/cmd/bundle/fix-duplicate-exports.ts +204 -0
- package/src/cmd/bundle/index.ts +9 -9
- package/src/cmd/bundle/patch/aisdk.ts +1 -1
- package/src/cmd/bundle/plugin.ts +373 -53
- package/src/cmd/cloud/deploy.ts +300 -93
- package/src/cmd/cloud/domain.ts +92 -0
- package/src/cmd/cloud/index.ts +4 -1
- package/src/cmd/cloud/resource/add.ts +56 -0
- package/src/cmd/cloud/resource/delete.ts +120 -0
- package/src/cmd/cloud/resource/index.ts +11 -0
- package/src/cmd/cloud/resource/list.ts +69 -0
- package/src/cmd/cloud/scp/download.ts +59 -0
- package/src/cmd/cloud/scp/index.ts +9 -0
- package/src/cmd/cloud/scp/upload.ts +62 -0
- package/src/cmd/cloud/ssh.ts +68 -0
- package/src/cmd/dev/api.ts +46 -0
- package/src/cmd/dev/download.ts +111 -0
- package/src/cmd/dev/index.ts +360 -34
- package/src/cmd/dev/templates.ts +84 -0
- package/src/cmd/env/delete.ts +5 -20
- package/src/cmd/env/get.ts +5 -18
- package/src/cmd/env/import.ts +5 -20
- package/src/cmd/env/list.ts +5 -18
- package/src/cmd/env/pull.ts +10 -23
- package/src/cmd/env/push.ts +5 -23
- package/src/cmd/env/set.ts +5 -20
- package/src/cmd/index.ts +2 -2
- package/src/cmd/profile/show.ts +15 -6
- package/src/cmd/project/create.ts +7 -2
- package/src/cmd/project/delete.ts +75 -18
- package/src/cmd/project/download.ts +2 -2
- package/src/cmd/project/list.ts +8 -8
- package/src/cmd/project/show.ts +3 -7
- package/src/cmd/project/template-flow.ts +170 -72
- package/src/cmd/secret/delete.ts +5 -20
- package/src/cmd/secret/get.ts +5 -18
- package/src/cmd/secret/import.ts +5 -20
- package/src/cmd/secret/list.ts +5 -18
- package/src/cmd/secret/pull.ts +10 -23
- package/src/cmd/secret/push.ts +5 -23
- package/src/cmd/secret/set.ts +5 -20
- package/src/config.ts +224 -24
- package/src/crypto/box.test.ts +431 -0
- package/src/crypto/box.ts +477 -0
- package/src/download.ts +1 -0
- package/src/env-util.test.ts +1 -1
- package/src/steps.ts +65 -6
- package/src/terminal.ts +24 -23
- package/src/tui.ts +192 -61
- package/src/types.ts +291 -201
- package/src/utils/detectSubagent.ts +31 -0
- package/src/utils/zip.ts +38 -0
- package/dist/cmd/example/create-user.d.ts +0 -2
- package/dist/cmd/example/create-user.d.ts.map +0 -1
- package/dist/cmd/example/create.d.ts +0 -2
- package/dist/cmd/example/create.d.ts.map +0 -1
- package/dist/cmd/example/deploy.d.ts +0 -2
- package/dist/cmd/example/deploy.d.ts.map +0 -1
- package/dist/cmd/example/index.d.ts +0 -2
- package/dist/cmd/example/index.d.ts.map +0 -1
- package/dist/cmd/example/list.d.ts +0 -2
- package/dist/cmd/example/list.d.ts.map +0 -1
- package/dist/cmd/example/optional-auth.d.ts +0 -3
- package/dist/cmd/example/optional-auth.d.ts.map +0 -1
- package/dist/cmd/example/run-command.d.ts +0 -2
- package/dist/cmd/example/run-command.d.ts.map +0 -1
- package/dist/cmd/example/sound.d.ts +0 -3
- package/dist/cmd/example/sound.d.ts.map +0 -1
- package/dist/cmd/example/spinner.d.ts +0 -2
- package/dist/cmd/example/spinner.d.ts.map +0 -1
- package/dist/cmd/example/steps.d.ts +0 -2
- package/dist/cmd/example/steps.d.ts.map +0 -1
- package/dist/cmd/example/version.d.ts +0 -2
- package/dist/cmd/example/version.d.ts.map +0 -1
- package/src/cmd/example/create-user.ts +0 -38
- package/src/cmd/example/create.ts +0 -31
- package/src/cmd/example/deploy.ts +0 -36
- package/src/cmd/example/index.ts +0 -29
- package/src/cmd/example/list.ts +0 -32
- package/src/cmd/example/optional-auth.ts +0 -38
- package/src/cmd/example/run-command.ts +0 -45
- package/src/cmd/example/sound.ts +0 -14
- package/src/cmd/example/spinner.ts +0 -44
- package/src/cmd/example/steps.ts +0 -66
- package/src/cmd/example/version.ts +0 -13
|
@@ -1,16 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { $ } from 'bun';
|
|
2
|
+
import { join, relative, resolve, dirname } from 'node:path';
|
|
3
|
+
import { cpSync, existsSync, mkdirSync, rmSync } from 'node:fs';
|
|
4
|
+
import gitParseUrl from 'git-url-parse';
|
|
5
|
+
import AgentuityBundler, { getBuildMetadata } from './plugin';
|
|
4
6
|
import { getFilesRecursively } from './file';
|
|
5
7
|
import { getVersion } from '../../version';
|
|
8
|
+
import type { Project } from '../../types';
|
|
9
|
+
import { fixDuplicateExportsInDirectory } from './fix-duplicate-exports';
|
|
6
10
|
|
|
7
11
|
export interface BundleOptions {
|
|
8
12
|
rootDir: string;
|
|
9
13
|
dev?: boolean;
|
|
10
14
|
env?: Map<string, string>;
|
|
15
|
+
orgId?: string;
|
|
16
|
+
projectId?: string;
|
|
17
|
+
deploymentId?: string;
|
|
18
|
+
project?: Project;
|
|
11
19
|
}
|
|
12
20
|
|
|
13
|
-
export async function bundle({
|
|
21
|
+
export async function bundle({
|
|
22
|
+
orgId,
|
|
23
|
+
projectId,
|
|
24
|
+
deploymentId,
|
|
25
|
+
dev = false,
|
|
26
|
+
rootDir,
|
|
27
|
+
project,
|
|
28
|
+
}: BundleOptions) {
|
|
14
29
|
const appFile = join(rootDir, 'app.ts');
|
|
15
30
|
if (!existsSync(appFile)) {
|
|
16
31
|
throw new Error(`App file not found at expected location: ${appFile}`);
|
|
@@ -37,21 +52,33 @@ export async function bundle({ dev = false, rootDir }: BundleOptions) {
|
|
|
37
52
|
}
|
|
38
53
|
appEntrypoints.push(appFile);
|
|
39
54
|
|
|
40
|
-
const webDir = join(srcDir, 'web');
|
|
41
|
-
|
|
42
55
|
if (existsSync(outDir)) {
|
|
43
56
|
rmSync(outDir, { recursive: true, force: true });
|
|
44
57
|
}
|
|
58
|
+
// Ensure output directory and subdirectories exist before building
|
|
59
|
+
mkdirSync(outDir, { recursive: true });
|
|
60
|
+
mkdirSync(join(outDir, 'chunk'), { recursive: true });
|
|
61
|
+
mkdirSync(join(outDir, 'asset'), { recursive: true });
|
|
45
62
|
|
|
46
|
-
const pkgFile = Bun.file('
|
|
63
|
+
const pkgFile = Bun.file(join(rootDir, 'package.json'));
|
|
47
64
|
const pkgContents = JSON.parse(await pkgFile.text());
|
|
48
65
|
const isProd = !dev;
|
|
49
66
|
|
|
50
|
-
const define = {
|
|
67
|
+
const define: Record<string, string> = {
|
|
51
68
|
'process.env.AGENTUITY_CLOUD_SDK_VERSION': JSON.stringify(getVersion() ?? '1.0.0'),
|
|
52
69
|
'process.env.NODE_ENV': JSON.stringify(isProd ? 'production' : 'development'),
|
|
53
70
|
};
|
|
54
71
|
|
|
72
|
+
if (orgId) {
|
|
73
|
+
define['process.env.AGENTUITY_CLOUD_ORG_ID'] = JSON.stringify(orgId);
|
|
74
|
+
}
|
|
75
|
+
if (projectId) {
|
|
76
|
+
define['process.env.AGENTUITY_CLOUD_PROJECT_ID'] = JSON.stringify(projectId);
|
|
77
|
+
}
|
|
78
|
+
if (deploymentId) {
|
|
79
|
+
define['process.env.AGENTUITY_CLOUD_DEPLOYMENT_ID'] = JSON.stringify(deploymentId);
|
|
80
|
+
}
|
|
81
|
+
|
|
55
82
|
await (async () => {
|
|
56
83
|
const config: Bun.BuildConfig = {
|
|
57
84
|
entrypoints: appEntrypoints,
|
|
@@ -64,78 +91,249 @@ export async function bundle({ dev = false, rootDir }: BundleOptions) {
|
|
|
64
91
|
target: 'bun',
|
|
65
92
|
format: 'esm',
|
|
66
93
|
banner: `// Generated file. DO NOT EDIT`,
|
|
67
|
-
minify
|
|
94
|
+
// Disable minify for server bundle (keep code readable for debugging)
|
|
95
|
+
// Enable splitting to reduce bundle size by extracting common code
|
|
96
|
+
minify: false,
|
|
68
97
|
drop: isProd ? ['debugger'] : undefined,
|
|
98
|
+
splitting: true,
|
|
69
99
|
conditions: [isProd ? 'production' : 'development', 'bun'],
|
|
100
|
+
naming: {
|
|
101
|
+
entry: '[dir]/[name].[ext]',
|
|
102
|
+
chunk: 'chunk/[name]-[hash].[ext]',
|
|
103
|
+
asset: 'asset/[name]-[hash].[ext]',
|
|
104
|
+
},
|
|
70
105
|
};
|
|
71
106
|
try {
|
|
72
107
|
await Bun.build(config);
|
|
108
|
+
// Fix duplicate exports caused by Bun splitting bug
|
|
109
|
+
// See: https://github.com/oven-sh/bun/issues/5344
|
|
110
|
+
await fixDuplicateExportsInDirectory(outDir, false);
|
|
73
111
|
} catch (ex) {
|
|
74
112
|
console.error(ex);
|
|
75
113
|
process.exit(1);
|
|
76
114
|
}
|
|
77
115
|
})();
|
|
78
116
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
117
|
+
const buildmetadata = getBuildMetadata();
|
|
118
|
+
buildmetadata.assets = [];
|
|
119
|
+
buildmetadata.project = {
|
|
120
|
+
id: projectId ?? '',
|
|
121
|
+
name: pkgContents.name,
|
|
122
|
+
version: pkgContents.version,
|
|
123
|
+
orgId: orgId ?? '',
|
|
124
|
+
};
|
|
125
|
+
buildmetadata.deployment = {
|
|
126
|
+
...(project?.deployment ?? {}),
|
|
127
|
+
build: {
|
|
128
|
+
bun: Bun.version,
|
|
129
|
+
agentuity: '',
|
|
130
|
+
arch: process.arch,
|
|
131
|
+
platform: process.platform,
|
|
132
|
+
},
|
|
133
|
+
date: new Date().toUTCString(),
|
|
134
|
+
id: deploymentId ?? '',
|
|
135
|
+
};
|
|
136
|
+
if (!dev) {
|
|
137
|
+
// try local first
|
|
138
|
+
const agNMPackage = join(rootDir, 'node_modules', '@agentuity', 'cli', 'package.json');
|
|
139
|
+
if (existsSync(agNMPackage)) {
|
|
140
|
+
try {
|
|
141
|
+
const npmpkg = await Bun.file(agNMPackage).json();
|
|
142
|
+
if (npmpkg.version) {
|
|
143
|
+
buildmetadata.deployment.build.agentuity = npmpkg.version;
|
|
90
144
|
}
|
|
145
|
+
} catch {
|
|
146
|
+
// Ignore malformed package.json
|
|
147
|
+
}
|
|
148
|
+
} else {
|
|
149
|
+
try {
|
|
150
|
+
// now try the global
|
|
151
|
+
const r = $`bunx @agentuity/cli version`.quiet().nothrow();
|
|
152
|
+
if (r) {
|
|
153
|
+
const version = await r.text();
|
|
154
|
+
if (version) {
|
|
155
|
+
buildmetadata.deployment.build.agentuity = version.trim();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
} catch {
|
|
159
|
+
// ignore error from bunx
|
|
91
160
|
}
|
|
92
|
-
const parent = resolve(currentDir, '..');
|
|
93
|
-
if (parent === currentDir) break; // reached filesystem root
|
|
94
|
-
currentDir = parent;
|
|
95
161
|
}
|
|
162
|
+
}
|
|
96
163
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
)
|
|
164
|
+
// web folder is optional
|
|
165
|
+
const webDir = join(srcDir, 'web');
|
|
166
|
+
if (existsSync(webDir)) {
|
|
167
|
+
await (async () => {
|
|
168
|
+
// Find workspace root for monorepo support
|
|
169
|
+
let workspaceRoot = rootDir;
|
|
170
|
+
let currentDir = rootDir;
|
|
171
|
+
while (true) {
|
|
172
|
+
const pkgPath = join(currentDir, 'package.json');
|
|
173
|
+
if (existsSync(pkgPath)) {
|
|
174
|
+
const pkg = JSON.parse(await Bun.file(pkgPath).text());
|
|
175
|
+
if (pkg.workspaces) {
|
|
176
|
+
workspaceRoot = currentDir;
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const parent = resolve(currentDir, '..');
|
|
181
|
+
if (parent === currentDir) break; // reached filesystem root
|
|
182
|
+
currentDir = parent;
|
|
183
|
+
}
|
|
101
184
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
185
|
+
// Make webEntrypoints - just the HTML files themselves
|
|
186
|
+
const webEntrypoints = [...new Bun.Glob('**.html').scanSync(webDir)].map((htmlFile) =>
|
|
187
|
+
resolve(webDir, htmlFile)
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
if (webEntrypoints.length) {
|
|
191
|
+
const config: Bun.BuildConfig = {
|
|
192
|
+
entrypoints: webEntrypoints,
|
|
193
|
+
root: webDir,
|
|
194
|
+
outdir: join(outDir, 'web'),
|
|
195
|
+
define,
|
|
196
|
+
sourcemap: dev ? 'inline' : 'linked',
|
|
197
|
+
env: 'AGENTUITY_PUBLIC_*',
|
|
198
|
+
plugins: [AgentuityBundler],
|
|
199
|
+
target: 'browser',
|
|
200
|
+
format: 'esm',
|
|
201
|
+
banner: `// Generated file. DO NOT EDIT`,
|
|
202
|
+
minify: true,
|
|
203
|
+
drop: isProd ? ['debugger'] : undefined,
|
|
204
|
+
splitting: true,
|
|
205
|
+
packages: 'bundle',
|
|
206
|
+
external: workspaceRoot !== rootDir ? [] : undefined,
|
|
207
|
+
publicPath:
|
|
208
|
+
isProd && deploymentId
|
|
209
|
+
? `https://static.agentuity.com/${deploymentId}/`
|
|
210
|
+
: undefined,
|
|
211
|
+
naming: {
|
|
212
|
+
entry: '[dir]/[name].[ext]',
|
|
213
|
+
chunk: 'web/chunk/[name]-[hash].[ext]',
|
|
214
|
+
asset: 'web/asset/[name]-[hash].[ext]',
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
try {
|
|
218
|
+
const result = await Bun.build(config);
|
|
219
|
+
if (result.success) {
|
|
220
|
+
// Fix duplicate exports caused by Bun splitting bug
|
|
221
|
+
// See: https://github.com/oven-sh/bun/issues/5344
|
|
222
|
+
await fixDuplicateExportsInDirectory(join(outDir, 'web'), false);
|
|
223
|
+
|
|
224
|
+
if (!dev && buildmetadata?.assets) {
|
|
225
|
+
const assets = buildmetadata.assets;
|
|
226
|
+
result.outputs
|
|
227
|
+
// Filter for deployable assets: sourcemaps (hash '00000000') and content-addressed files
|
|
228
|
+
.filter((x) => x.hash === '00000000' || (x.hash && x.path.includes(x.hash)))
|
|
229
|
+
.forEach((artifact) => {
|
|
230
|
+
const r = relative(join(outDir, 'web'), artifact.path);
|
|
231
|
+
assets.push({
|
|
232
|
+
filename: r,
|
|
233
|
+
kind: artifact.kind,
|
|
234
|
+
contentType: artifact.type,
|
|
235
|
+
size: artifact.size,
|
|
236
|
+
});
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
} else {
|
|
240
|
+
console.error(result.logs.join('\n'));
|
|
241
|
+
process.exit(1);
|
|
242
|
+
}
|
|
243
|
+
} catch (ex) {
|
|
244
|
+
console.error(ex);
|
|
245
|
+
process.exit(1);
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
})();
|
|
249
|
+
|
|
250
|
+
if (!dev && buildmetadata) {
|
|
251
|
+
const webPublicDir = join(webDir, 'public');
|
|
252
|
+
if (existsSync(webPublicDir)) {
|
|
253
|
+
const assets = buildmetadata.assets;
|
|
254
|
+
const webOutPublicDir = join(outDir, 'web', 'public');
|
|
255
|
+
cpSync(webPublicDir, webOutPublicDir, { recursive: true });
|
|
256
|
+
[...new Bun.Glob('**.*').scanSync(webOutPublicDir)].forEach((f) => {
|
|
257
|
+
const bf = Bun.file(join(webOutPublicDir, f));
|
|
258
|
+
assets.push({
|
|
259
|
+
filename: join('public', f),
|
|
260
|
+
kind: 'static',
|
|
261
|
+
contentType: bf.type,
|
|
262
|
+
size: bf.size,
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (!dev && Bun.which('git') && buildmetadata?.deployment) {
|
|
270
|
+
buildmetadata.deployment.git = {
|
|
271
|
+
commit: process.env.GIT_SHA || process.env.GITHUB_SHA,
|
|
272
|
+
branch: process.env.GITHUB_REF ? process.env.GITHUB_REF.replace('refs/heads/', '') : '',
|
|
273
|
+
repo: process.env.GITHUB_REPOSITORY
|
|
274
|
+
? gitParseUrl(process.env.GITHUB_REPOSITORY).toString('https')
|
|
275
|
+
: '',
|
|
122
276
|
};
|
|
277
|
+
// pull out the git information if we have it
|
|
123
278
|
try {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
279
|
+
let gitDir = join(rootDir, '.git');
|
|
280
|
+
let parentDir = dirname(dirname(gitDir));
|
|
281
|
+
while (!existsSync(gitDir) && parentDir !== dirname(parentDir) && gitDir !== '/') {
|
|
282
|
+
gitDir = join(parentDir, '.git');
|
|
283
|
+
parentDir = dirname(parentDir);
|
|
284
|
+
}
|
|
285
|
+
if (existsSync(gitDir)) {
|
|
286
|
+
const tag = $`git tag -l --points-at HEAD`.nothrow().quiet();
|
|
287
|
+
if (tag) {
|
|
288
|
+
const tags = await tag.text();
|
|
289
|
+
buildmetadata.deployment.git.tags = tags
|
|
290
|
+
.trim()
|
|
291
|
+
.split(/\n/)
|
|
292
|
+
.map((s) => s.trim())
|
|
293
|
+
.filter(Boolean);
|
|
294
|
+
}
|
|
295
|
+
const branch = $`git branch --show-current`.nothrow().quiet();
|
|
296
|
+
if (branch) {
|
|
297
|
+
const _branch = await branch.text();
|
|
298
|
+
if (_branch) {
|
|
299
|
+
buildmetadata.deployment.git.branch = _branch.trim();
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
const commit = $`git rev-parse HEAD`.nothrow().quiet();
|
|
303
|
+
if (commit) {
|
|
304
|
+
const sha = await commit.text();
|
|
305
|
+
if (sha) {
|
|
306
|
+
buildmetadata.deployment.git.commit = sha.trim();
|
|
307
|
+
const msg = $`git log --pretty=format:%s -n1 ${buildmetadata.deployment.git.commit}`;
|
|
308
|
+
if (msg) {
|
|
309
|
+
const _msg = await msg.text();
|
|
310
|
+
if (_msg) {
|
|
311
|
+
buildmetadata.deployment.git.message = _msg.trim();
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
const origin = $`git config --get remote.origin.url`.nothrow().quiet();
|
|
315
|
+
if (origin) {
|
|
316
|
+
const _origin = await origin.text();
|
|
317
|
+
if (_origin) {
|
|
318
|
+
const _url = gitParseUrl(_origin.trim());
|
|
319
|
+
buildmetadata.deployment.git.repo = _url.toString('https');
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
} catch {
|
|
326
|
+
// ignore errors
|
|
128
327
|
}
|
|
129
|
-
})();
|
|
130
|
-
|
|
131
|
-
const webPublicDir = join(webDir, 'public');
|
|
132
|
-
if (existsSync(webPublicDir)) {
|
|
133
|
-
const webOutPublicDir = join(outDir, 'web', 'public');
|
|
134
|
-
cpSync(webPublicDir, webOutPublicDir, { recursive: true });
|
|
135
328
|
}
|
|
136
329
|
|
|
137
330
|
await Bun.write(
|
|
138
331
|
`${outDir}/package.json`,
|
|
139
332
|
JSON.stringify({ name: pkgContents.name, version: pkgContents.version }, null, 2)
|
|
140
333
|
);
|
|
334
|
+
|
|
335
|
+
await Bun.write(
|
|
336
|
+
`${outDir}/agentuity.metadata.json`,
|
|
337
|
+
dev ? JSON.stringify(buildmetadata, null, 2) : JSON.stringify(buildmetadata)
|
|
338
|
+
);
|
|
141
339
|
}
|
package/src/cmd/bundle/file.ts
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
1
|
import { resolve } from 'node:path';
|
|
3
|
-
import { promisify } from 'node:util';
|
|
4
|
-
|
|
5
|
-
const readdir = promisify(fs.readdir);
|
|
6
2
|
|
|
7
3
|
export async function getFilesRecursively(dir: string): Promise<string[]> {
|
|
8
|
-
const
|
|
9
|
-
const files =
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
);
|
|
15
|
-
return files.flat();
|
|
4
|
+
const glob = new Bun.Glob('**/*');
|
|
5
|
+
const files: string[] = [];
|
|
6
|
+
for await (const file of glob.scan({ cwd: dir, onlyFiles: true, absolute: false })) {
|
|
7
|
+
files.push(resolve(dir, file));
|
|
8
|
+
}
|
|
9
|
+
return files;
|
|
16
10
|
}
|