@arcote.tech/arc-cli 0.1.1 → 0.1.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.
- package/dist/index.js +35 -1455
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/utils/build.ts +27 -2
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { dev } from "./commands/dev";
|
|
|
8
8
|
const program = new Command();
|
|
9
9
|
|
|
10
10
|
// Setup program information
|
|
11
|
-
program.name("arc").description("CLI tool for Arc framework").version("0.0.
|
|
11
|
+
program.name("arc").description("CLI tool for Arc framework").version("0.0.2");
|
|
12
12
|
|
|
13
13
|
// Register commands
|
|
14
14
|
program
|
package/src/utils/build.ts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
1
|
import { spawn } from "child_process";
|
|
2
|
+
import { readFileSync } from "fs";
|
|
2
3
|
import { dirname, join } from "path";
|
|
3
4
|
import * as ts from "typescript";
|
|
4
5
|
import type { ArcConfig } from "./config";
|
|
5
6
|
import { generateClientTypes } from "./config";
|
|
6
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Read package.json and extract peer dependencies
|
|
10
|
+
*/
|
|
11
|
+
function getPeerDependencies(configDir: string): string[] {
|
|
12
|
+
try {
|
|
13
|
+
const packageJsonPath = join(configDir, "package.json");
|
|
14
|
+
const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf-8"));
|
|
15
|
+
return Object.keys(packageJson.peerDependencies || {});
|
|
16
|
+
} catch (error) {
|
|
17
|
+
console.warn("Could not read package.json or peerDependencies:", error);
|
|
18
|
+
return [];
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
7
22
|
/**
|
|
8
23
|
* Build a package using Bun for a specific client
|
|
9
24
|
*/
|
|
@@ -35,11 +50,21 @@ export async function buildClient(
|
|
|
35
50
|
.map(([key, value]) => `--define="${key}=${value}"`)
|
|
36
51
|
.join(" ");
|
|
37
52
|
|
|
53
|
+
// Get peer dependencies and use them as external dependencies
|
|
54
|
+
const peerDeps = getPeerDependencies(configDir);
|
|
55
|
+
const externalArgs =
|
|
56
|
+
peerDeps.length > 0
|
|
57
|
+
? peerDeps.map((dep) => `--external=${dep}`).join(" ") + " "
|
|
58
|
+
: "";
|
|
59
|
+
|
|
60
|
+
// Client-specific build target
|
|
61
|
+
const buildTarget = client === "browser" ? "browser" : "bun";
|
|
62
|
+
|
|
38
63
|
// Construct the bun build command
|
|
39
64
|
const filePath = join(configDir, file);
|
|
40
|
-
const
|
|
65
|
+
const outDirPath = join(configDir, outDir, client.toLowerCase());
|
|
41
66
|
|
|
42
|
-
const command = `bun build ${filePath} --
|
|
67
|
+
const command = `bun build ${filePath} --target=${buildTarget} --outdir=${outDirPath} ${defineArgs} ${externalArgs}${watch ? " --watch" : ""}`;
|
|
43
68
|
|
|
44
69
|
console.log(`Building ${client} client...`);
|
|
45
70
|
console.log(command);
|