@townco/cli 0.1.35 ā 0.1.36
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/commands/upgrade.d.ts +1 -0
- package/dist/commands/upgrade.js +60 -0
- package/dist/index.js +6 -0
- package/package.json +6 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function upgradeCommand(): Promise<void>;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { rm } from "node:fs/promises";
|
|
3
|
+
import { join, dirname } from "node:path";
|
|
4
|
+
import { execSync } from "node:child_process";
|
|
5
|
+
/**
|
|
6
|
+
* Find the nearest directory with package.json by walking up from current directory
|
|
7
|
+
*/
|
|
8
|
+
function findPackageRoot() {
|
|
9
|
+
let currentDir = process.cwd();
|
|
10
|
+
while (true) {
|
|
11
|
+
const packageJsonPath = join(currentDir, "package.json");
|
|
12
|
+
if (existsSync(packageJsonPath)) {
|
|
13
|
+
return currentDir;
|
|
14
|
+
}
|
|
15
|
+
const parentDir = dirname(currentDir);
|
|
16
|
+
if (parentDir === currentDir) {
|
|
17
|
+
// Reached filesystem root
|
|
18
|
+
console.error("ā Error: No package.json found in current directory or any parent directory.");
|
|
19
|
+
process.exit(1);
|
|
20
|
+
}
|
|
21
|
+
currentDir = parentDir;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export async function upgradeCommand() {
|
|
25
|
+
console.log("š Upgrading dependencies...\n");
|
|
26
|
+
const packageRoot = findPackageRoot();
|
|
27
|
+
const nodeModulesPath = join(packageRoot, "node_modules");
|
|
28
|
+
const bunLockPath = join(packageRoot, "bun.lock");
|
|
29
|
+
// Delete node_modules
|
|
30
|
+
if (existsSync(nodeModulesPath)) {
|
|
31
|
+
console.log("šļø Deleting node_modules...");
|
|
32
|
+
await rm(nodeModulesPath, { recursive: true, force: true });
|
|
33
|
+
console.log("ā node_modules deleted\n");
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
console.log("āļø node_modules not found, skipping...\n");
|
|
37
|
+
}
|
|
38
|
+
// Delete bun.lockb
|
|
39
|
+
if (existsSync(bunLockPath)) {
|
|
40
|
+
console.log("šļø Deleting bun.lock...");
|
|
41
|
+
await rm(bunLockPath, { force: true });
|
|
42
|
+
console.log("ā bun.lock deleted\n");
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
console.log("āļø bun.lock not found, skipping...\n");
|
|
46
|
+
}
|
|
47
|
+
// Run bun install
|
|
48
|
+
console.log("š¦ Running bun install...\n");
|
|
49
|
+
try {
|
|
50
|
+
execSync("bun install", {
|
|
51
|
+
cwd: packageRoot,
|
|
52
|
+
stdio: "inherit",
|
|
53
|
+
});
|
|
54
|
+
console.log("\nā
Dependencies upgraded successfully!");
|
|
55
|
+
}
|
|
56
|
+
catch (error) {
|
|
57
|
+
console.error("\nā Error running bun install:", error);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,7 @@ import { configureCommand } from "./commands/configure.js";
|
|
|
13
13
|
import { createCommand } from "./commands/create.js";
|
|
14
14
|
import { createProjectCommand } from "./commands/create-project.js";
|
|
15
15
|
import { runCommand } from "./commands/run.js";
|
|
16
|
+
import { upgradeCommand } from "./commands/upgrade.js";
|
|
16
17
|
/**
|
|
17
18
|
* Securely prompt for a secret value without echoing to the terminal
|
|
18
19
|
*/
|
|
@@ -29,6 +30,8 @@ async function promptSecret(secretName) {
|
|
|
29
30
|
}
|
|
30
31
|
const parser = or(command("deploy", constant("deploy"), { brief: message `Deploy a Town.` }), command("configure", constant("configure"), {
|
|
31
32
|
brief: message `Configure environment variables.`,
|
|
33
|
+
}), command("upgrade", constant("upgrade"), {
|
|
34
|
+
brief: message `Upgrade dependencies by cleaning and reinstalling.`,
|
|
32
35
|
}), command("create", object({
|
|
33
36
|
command: constant("create"),
|
|
34
37
|
name: optional(option("-n", "--name", string())),
|
|
@@ -74,6 +77,9 @@ async function main(parser, meta) {
|
|
|
74
77
|
.with("deploy", async () => { })
|
|
75
78
|
.with("configure", async () => {
|
|
76
79
|
await configureCommand();
|
|
80
|
+
})
|
|
81
|
+
.with("upgrade", async () => {
|
|
82
|
+
await upgradeCommand();
|
|
77
83
|
})
|
|
78
84
|
.with({ command: "create" }, async ({ name, model, tools, systemPrompt, init, claude }) => {
|
|
79
85
|
// Handle --claude flag (initialize .claude in existing project)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@townco/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.36",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"town": "./dist/index.js"
|
|
@@ -15,17 +15,17 @@
|
|
|
15
15
|
"build": "tsc"
|
|
16
16
|
},
|
|
17
17
|
"devDependencies": {
|
|
18
|
-
"@townco/tsconfig": "0.1.
|
|
18
|
+
"@townco/tsconfig": "0.1.28",
|
|
19
19
|
"@types/bun": "^1.3.1",
|
|
20
20
|
"@types/react": "^19.2.2"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@optique/core": "^0.6.2",
|
|
24
24
|
"@optique/run": "^0.6.2",
|
|
25
|
-
"@townco/agent": "0.1.
|
|
26
|
-
"@townco/core": "0.0.
|
|
27
|
-
"@townco/secret": "0.1.
|
|
28
|
-
"@townco/ui": "0.1.
|
|
25
|
+
"@townco/agent": "0.1.36",
|
|
26
|
+
"@townco/core": "0.0.9",
|
|
27
|
+
"@townco/secret": "0.1.31",
|
|
28
|
+
"@townco/ui": "0.1.31",
|
|
29
29
|
"@types/inquirer": "^9.0.9",
|
|
30
30
|
"ink": "^6.4.0",
|
|
31
31
|
"ink-text-input": "^6.0.0",
|