@archlast/cli 0.1.5 → 0.1.6
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 +11 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/cli.js +23 -14
- package/package.json +3 -1
- package/scripts/postinstall.js +65 -0
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
|
package/dist/auth.d.ts.map
CHANGED
|
@@ -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,
|
|
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,CAuD5D;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,14 +316619,14 @@ function extractFromEnv(content, varName) {
|
|
|
316619
316619
|
return null;
|
|
316620
316620
|
}
|
|
316621
316621
|
function readAdminToken(archlastPath) {
|
|
316622
|
-
const
|
|
316623
|
-
|
|
316624
|
-
|
|
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"));
|
|
@@ -316636,11 +316636,16 @@ function readAdminToken(archlastPath) {
|
|
|
316636
316636
|
searchPaths.push(path6.resolve(process.cwd(), ".env"));
|
|
316637
316637
|
let currentDir = process.cwd();
|
|
316638
316638
|
for (let i = 0;i < 5; i++) {
|
|
316639
|
-
const
|
|
316639
|
+
const repoArchlastLocal = path6.join(currentDir, "apps", "archlast", ".env.local");
|
|
316640
|
+
const repoArchlast = path6.join(currentDir, "apps", "archlast", ".env");
|
|
316641
|
+
if (fs5.existsSync(repoArchlastLocal)) {
|
|
316642
|
+
searchPaths.push(repoArchlastLocal);
|
|
316643
|
+
}
|
|
316640
316644
|
if (fs5.existsSync(repoArchlast)) {
|
|
316641
316645
|
searchPaths.push(repoArchlast);
|
|
316642
|
-
break;
|
|
316643
316646
|
}
|
|
316647
|
+
if (searchPaths.length > 2)
|
|
316648
|
+
break;
|
|
316644
316649
|
const parent = path6.dirname(currentDir);
|
|
316645
316650
|
if (parent === currentDir)
|
|
316646
316651
|
break;
|
|
@@ -316652,7 +316657,11 @@ function readAdminToken(archlastPath) {
|
|
|
316652
316657
|
const content = fs5.readFileSync(filePath, "utf-8");
|
|
316653
316658
|
const key = extractFromEnv(content, "ARCHLAST_API_KEY");
|
|
316654
316659
|
if (key) {
|
|
316655
|
-
|
|
316660
|
+
const validation = validateApiKey(key);
|
|
316661
|
+
if (validation.valid) {
|
|
316662
|
+
return key;
|
|
316663
|
+
}
|
|
316664
|
+
console.warn(`Warning: Invalid API key format in ${filePath}: ${validation.error}`);
|
|
316656
316665
|
}
|
|
316657
316666
|
}
|
|
316658
316667
|
}
|
|
@@ -316737,9 +316746,9 @@ class CodeUploader {
|
|
|
316737
316746
|
if (!response.ok) {
|
|
316738
316747
|
if (response.status === 401) {
|
|
316739
316748
|
const error = await response.text();
|
|
316740
|
-
throw new Error(`Authentication failed: ${error || "Invalid
|
|
316749
|
+
throw new Error(`Authentication failed: ${error || "Invalid API key"}
|
|
316741
316750
|
|
|
316742
|
-
Please create
|
|
316751
|
+
Please create an API key in the admin dashboard (http://localhost:4001/dashboard/settings) and set ARCHLAST_API_KEY in your .env file.`);
|
|
316743
316752
|
}
|
|
316744
316753
|
const localFiles2 = await this.collectAllFiles();
|
|
316745
316754
|
return {
|
|
@@ -316837,9 +316846,9 @@ Please create a token in the dashboard (Settings → API Tokens) and update ARCH
|
|
|
316837
316846
|
if (response.status === 401) {
|
|
316838
316847
|
return {
|
|
316839
316848
|
success: false,
|
|
316840
|
-
message: `Authentication failed: ${errorText || "Invalid
|
|
316849
|
+
message: `Authentication failed: ${errorText || "Invalid API key"}
|
|
316841
316850
|
|
|
316842
|
-
Please create
|
|
316851
|
+
Please create an API key in the admin dashboard (http://localhost:4001/dashboard/settings) and set ARCHLAST_API_KEY in your .env file.`
|
|
316843
316852
|
};
|
|
316844
316853
|
}
|
|
316845
316854
|
return { success: false, message: errorText };
|
|
@@ -322340,7 +322349,7 @@ async function configCommand(options) {
|
|
|
322340
322349
|
|
|
322341
322350
|
// src/cli.ts
|
|
322342
322351
|
var program2 = new Command;
|
|
322343
|
-
program2.name("archlast").description("Archlast CLI for development and deployment").version("0.1.
|
|
322352
|
+
program2.name("archlast").description("Archlast CLI for development and deployment").version("0.1.6");
|
|
322344
322353
|
program2.command("build").description("Generate types without deploying").option("--path <path>", "Path to archlast folder", ".").action(buildCommand);
|
|
322345
322354
|
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
322355
|
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.
|
|
3
|
+
"version": "0.1.6",
|
|
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);
|