@arcote.tech/arc-cli 0.1.1 → 0.1.2

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 CHANGED
@@ -174469,6 +174469,7 @@ import { dirname as dirname2 } from "path";
174469
174469
  // src/utils/build.ts
174470
174470
  var ts = __toESM(require_typescript(), 1);
174471
174471
  import { spawn } from "child_process";
174472
+ import { readFileSync as readFileSync2 } from "fs";
174472
174473
  import { dirname, join as join2 } from "path";
174473
174474
 
174474
174475
  // src/utils/config.ts
@@ -179837,6 +179838,16 @@ function normalizeClientName(client) {
179837
179838
  }
179838
179839
 
179839
179840
  // src/utils/build.ts
179841
+ function getPeerDependencies(configDir) {
179842
+ try {
179843
+ const packageJsonPath = join2(configDir, "package.json");
179844
+ const packageJson = JSON.parse(readFileSync2(packageJsonPath, "utf-8"));
179845
+ return Object.keys(packageJson.peerDependencies || {});
179846
+ } catch (error) {
179847
+ console.warn("Could not read package.json or peerDependencies:", error);
179848
+ return [];
179849
+ }
179850
+ }
179840
179851
  async function buildClient(configPath, config, client, watch = false) {
179841
179852
  const configDir = dirname(configPath);
179842
179853
  const { file, outDir } = config;
@@ -179849,9 +179860,12 @@ async function buildClient(configPath, config, client, watch = false) {
179849
179860
  defineValues[`ONLY_${normalizedC}`] = c === client ? "true" : "false";
179850
179861
  }
179851
179862
  const defineArgs = Object.entries(defineValues).map(([key, value]) => `--define="${key}=${value}"`).join(" ");
179863
+ const peerDeps = getPeerDependencies(configDir);
179864
+ const externalArgs = peerDeps.length > 0 ? peerDeps.map((dep) => `--external=${dep}`).join(" ") + " " : "";
179865
+ const buildTarget = client === "browser" ? "browser" : "bun";
179852
179866
  const filePath = join2(configDir, file);
179853
- const outFilePath = join2(configDir, outDir, client.toLowerCase(), "index.js");
179854
- const command = `bun build ${filePath} --outfile=${outFilePath} ${defineArgs}${watch ? " --watch" : ""}`;
179867
+ const outDirPath = join2(configDir, outDir, client.toLowerCase());
179868
+ const command = `bun build ${filePath} --target=${buildTarget} --outdir=${outDirPath} ${defineArgs} ${externalArgs}${watch ? " --watch" : ""}`;
179855
179869
  console.log(`Building ${client} client...`);
179856
179870
  console.log(command);
179857
179871
  return new Promise((resolve, reject) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcote.tech/arc-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "CLI tool for Arc framework",
5
5
  "module": "index.ts",
6
6
  "main": "dist/index.js",
@@ -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 outFilePath = join(configDir, outDir, client.toLowerCase(), "index.js");
65
+ const outDirPath = join(configDir, outDir, client.toLowerCase());
41
66
 
42
- const command = `bun build ${filePath} --outfile=${outFilePath} ${defineArgs}${watch ? " --watch" : ""}`;
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);