@archlast/cli 0.1.5 → 0.1.7

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 CHANGED
@@ -6,6 +6,7 @@ CLI tool for Archlast development, deployment, and Docker lifecycle management.
6
6
 
7
7
  - Node.js 18+
8
8
  - Docker Desktop or Docker Engine
9
+ - Bun 1.3+
9
10
 
10
11
  ## Installation
11
12
 
@@ -13,6 +14,16 @@ CLI tool for Archlast development, deployment, and Docker lifecycle management.
13
14
  npm install -g @archlast/cli
14
15
  ```
15
16
 
17
+ On Windows, ensure Bun is on your PATH (the installer adds it, but terminals need a restart):
18
+
19
+ ```powershell
20
+ [Environment]::SetEnvironmentVariable(
21
+ "Path",
22
+ "$env:Path;$env:USERPROFILE\\.bun\\bin",
23
+ "User"
24
+ )
25
+ ```
26
+
16
27
  ## Quick start
17
28
 
18
29
  ```bash
@@ -1 +1 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAMA,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAcjF;AAED,qBAAa,uBAAwB,SAAQ,KAAK;;CAUjD;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAY9E;AAED,wBAAgB,cAAc,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CA2C5D;AAED,wBAAgB,cAAc,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAK5E;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQ9C;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOjD"}
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAMA,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAcjF;AAED,qBAAa,uBAAwB,SAAQ,KAAK;;CAUjD;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAY9E;AAED,wBAAgB,cAAc,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAyD5D;AAED,wBAAgB,cAAc,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAK5E;AAED,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAQ9C;AAED,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAOjD"}
package/dist/cli.js CHANGED
@@ -316619,28 +316619,35 @@ function extractFromEnv(content, varName) {
316619
316619
  return null;
316620
316620
  }
316621
316621
  function readAdminToken(archlastPath) {
316622
- const apiKey = process.env.ARCHLAST_API_KEY;
316623
- const validation = validateApiKey(apiKey || "");
316624
- if (!validation.valid) {
316622
+ const envApiKey = process.env.ARCHLAST_API_KEY;
316623
+ if (envApiKey) {
316624
+ const validation = validateApiKey(envApiKey);
316625
+ if (validation.valid) {
316626
+ return envApiKey;
316627
+ }
316625
316628
  throw new Error(validation.error || "Invalid API key");
316626
316629
  }
316627
- if (apiKey) {
316628
- return apiKey;
316629
- }
316630
316630
  const searchPaths = [];
316631
316631
  if (archlastPath) {
316632
316632
  searchPaths.push(path6.resolve(archlastPath, ".env.local"));
316633
316633
  searchPaths.push(path6.resolve(archlastPath, ".env"));
316634
+ searchPaths.push(path6.resolve(archlastPath, "apps", "archlast", ".env.local"));
316635
+ searchPaths.push(path6.resolve(archlastPath, "apps", "archlast", ".env"));
316634
316636
  } else {
316635
316637
  searchPaths.push(path6.resolve(process.cwd(), ".env.local"));
316636
316638
  searchPaths.push(path6.resolve(process.cwd(), ".env"));
316637
316639
  let currentDir = process.cwd();
316638
316640
  for (let i = 0;i < 5; i++) {
316639
- const repoArchlast = path6.join(currentDir, "apps", "archlast", ".env.local");
316641
+ const repoArchlastLocal = path6.join(currentDir, "apps", "archlast", ".env.local");
316642
+ const repoArchlast = path6.join(currentDir, "apps", "archlast", ".env");
316643
+ if (fs5.existsSync(repoArchlastLocal)) {
316644
+ searchPaths.push(repoArchlastLocal);
316645
+ }
316640
316646
  if (fs5.existsSync(repoArchlast)) {
316641
316647
  searchPaths.push(repoArchlast);
316642
- break;
316643
316648
  }
316649
+ if (searchPaths.length > 2)
316650
+ break;
316644
316651
  const parent = path6.dirname(currentDir);
316645
316652
  if (parent === currentDir)
316646
316653
  break;
@@ -316652,7 +316659,11 @@ function readAdminToken(archlastPath) {
316652
316659
  const content = fs5.readFileSync(filePath, "utf-8");
316653
316660
  const key = extractFromEnv(content, "ARCHLAST_API_KEY");
316654
316661
  if (key) {
316655
- return key;
316662
+ const validation = validateApiKey(key);
316663
+ if (validation.valid) {
316664
+ return key;
316665
+ }
316666
+ console.warn(`Warning: Invalid API key format in ${filePath}: ${validation.error}`);
316656
316667
  }
316657
316668
  }
316658
316669
  }
@@ -316737,9 +316748,9 @@ class CodeUploader {
316737
316748
  if (!response.ok) {
316738
316749
  if (response.status === 401) {
316739
316750
  const error = await response.text();
316740
- throw new Error(`Authentication failed: ${error || "Invalid admin token"}
316751
+ throw new Error(`Authentication failed: ${error || "Invalid API key"}
316741
316752
 
316742
- Please create a token in the dashboard (Settings → API Tokens) and update ARCHLAST_ADMIN_TOKEN in your .env file.`);
316753
+ Please create an API key in the admin dashboard (http://localhost:4001/dashboard/settings) and set ARCHLAST_API_KEY in your .env file.`);
316743
316754
  }
316744
316755
  const localFiles2 = await this.collectAllFiles();
316745
316756
  return {
@@ -316837,9 +316848,9 @@ Please create a token in the dashboard (Settings → API Tokens) and update ARCH
316837
316848
  if (response.status === 401) {
316838
316849
  return {
316839
316850
  success: false,
316840
- message: `Authentication failed: ${errorText || "Invalid admin token"}
316851
+ message: `Authentication failed: ${errorText || "Invalid API key"}
316841
316852
 
316842
- Please create a token in the dashboard (Settings → API Tokens) and update ARCHLAST_ADMIN_TOKEN in your .env file.`
316853
+ Please create an API key in the admin dashboard (http://localhost:4001/dashboard/settings) and set ARCHLAST_API_KEY in your .env file.`
316843
316854
  };
316844
316855
  }
316845
316856
  return { success: false, message: errorText };
@@ -322340,7 +322351,7 @@ async function configCommand(options) {
322340
322351
 
322341
322352
  // src/cli.ts
322342
322353
  var program2 = new Command;
322343
- program2.name("archlast").description("Archlast CLI for development and deployment").version("0.1.5");
322354
+ program2.name("archlast").description("Archlast CLI for development and deployment").version("0.1.7");
322344
322355
  program2.command("build").description("Generate types without deploying").option("--path <path>", "Path to archlast folder", ".").action(buildCommand);
322345
322356
  program2.command("dev").description("Start development mode with file watching").option("-p, --port <port>", "Server port", "3001").option("--path <path>", "Path to archlast folder", ".").option("--server <url>", "Server URL for code upload", "http://localhost:4000").option("--max-poll <number>", "Maximum server polling retries", "30").action(devCommand);
322346
322357
  program2.command("deploy").description("Deploy to production").option("--path <path>", "Path to archlast folder", ".").option("--server <url>", "Server URL for code upload", "http://localhost:4000").option("--max-poll <number>", "Maximum server polling retries", "30").action(deployCommand);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@archlast/cli",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Archlast CLI for development and deployment",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -9,6 +9,7 @@
9
9
  },
10
10
  "files": [
11
11
  "dist",
12
+ "scripts",
12
13
  "README.md",
13
14
  "LICENSE"
14
15
  ],
@@ -23,6 +24,7 @@
23
24
  "format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
24
25
  "format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,json,md}\"",
25
26
  "prepublishOnly": "bun run build",
27
+ "postinstall": "node scripts/postinstall.js",
26
28
  "clean": "rm -rf dist"
27
29
  },
28
30
  "keywords": [
@@ -0,0 +1,65 @@
1
+ const { spawnSync } = require("child_process");
2
+ const fs = require("fs");
3
+ const path = require("path");
4
+
5
+ function bunOnPath() {
6
+ try {
7
+ const result = spawnSync("bun", ["--version"], { stdio: "ignore" });
8
+ return result.status === 0;
9
+ } catch {
10
+ return false;
11
+ }
12
+ }
13
+
14
+ function getBunBin() {
15
+ const home = process.env.USERPROFILE || process.env.HOME;
16
+ if (!home) return null;
17
+ return path.join(home, ".bun", "bin");
18
+ }
19
+
20
+ function pathIncludes(pathValue, target) {
21
+ const normalizedTarget = target.trim().toLowerCase();
22
+ return pathValue
23
+ .split(";")
24
+ .map((entry) => entry.trim().toLowerCase())
25
+ .includes(normalizedTarget);
26
+ }
27
+
28
+ function ensureWindowsBunPath() {
29
+ if (process.platform !== "win32") return;
30
+
31
+ if (bunOnPath()) return;
32
+
33
+ const bunBin = getBunBin();
34
+ if (!bunBin || !fs.existsSync(bunBin)) {
35
+ console.log("[info] Bun not found. Install it from https://bun.sh/");
36
+ return;
37
+ }
38
+
39
+ const pathValue = process.env.Path || process.env.PATH || "";
40
+ if (pathIncludes(pathValue, bunBin)) return;
41
+
42
+ const command = `[Environment]::SetEnvironmentVariable('Path', "$env:Path;${bunBin}", 'User')`;
43
+ const result = spawnSync("powershell.exe", ["-NoProfile", "-Command", command], {
44
+ stdio: "ignore",
45
+ });
46
+
47
+ if (result.status === 0) {
48
+ console.log(`[ok] Added ${bunBin} to user PATH. Restart your terminal.`);
49
+ } else {
50
+ console.log("[warn] Could not update PATH automatically. Run:");
51
+ console.log(`[warn] ${command}`);
52
+ }
53
+ }
54
+
55
+ function run() {
56
+ ensureWindowsBunPath();
57
+ }
58
+
59
+ try {
60
+ run();
61
+ } catch {
62
+ // Never fail the install.
63
+ }
64
+
65
+ process.exit(0);