@base44-preview/cli 0.0.1-pr.5.e49d892 → 0.0.1-pr.7.36e5bda
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 +18 -14
- package/dist/cli/commands/auth/login.d.ts.map +1 -1
- package/dist/cli/commands/auth/login.js +28 -58
- package/dist/cli/commands/auth/login.js.map +1 -1
- package/dist/cli/commands/auth/logout.d.ts.map +1 -1
- package/dist/cli/commands/auth/logout.js +2 -12
- package/dist/cli/commands/auth/logout.js.map +1 -1
- package/dist/cli/commands/auth/whoami.d.ts.map +1 -1
- package/dist/cli/commands/auth/whoami.js +2 -12
- package/dist/cli/commands/auth/whoami.js.map +1 -1
- package/dist/cli/commands/project/show-project.d.ts +3 -0
- package/dist/cli/commands/project/show-project.d.ts.map +1 -0
- package/dist/cli/commands/project/show-project.js +20 -0
- package/dist/cli/commands/project/show-project.js.map +1 -0
- package/dist/cli/index.js +3 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/utils/index.d.ts +1 -0
- package/dist/cli/utils/index.d.ts.map +1 -1
- package/dist/cli/utils/index.js +1 -0
- package/dist/cli/utils/index.js.map +1 -1
- package/dist/cli/utils/packageVersion.js +3 -3
- package/dist/cli/utils/packageVersion.js.map +1 -1
- package/dist/cli/utils/runCommand.d.ts.map +1 -1
- package/dist/cli/utils/runCommand.js +11 -1
- package/dist/cli/utils/runCommand.js.map +1 -1
- package/dist/cli/utils/runTask.d.ts +14 -0
- package/dist/cli/utils/runTask.d.ts.map +1 -0
- package/dist/cli/utils/runTask.js +24 -0
- package/dist/cli/utils/runTask.js.map +1 -0
- package/dist/core/api/auth/client.d.ts +1 -1
- package/dist/core/api/auth/client.d.ts.map +1 -1
- package/dist/core/api/auth/client.js +4 -4
- package/dist/core/api/auth/client.js.map +1 -1
- package/dist/core/config/auth.d.ts +1 -1
- package/dist/core/config/auth.d.ts.map +1 -1
- package/dist/core/config/auth.js +1 -1
- package/dist/core/config/auth.js.map +1 -1
- package/dist/core/config/constants.d.ts +3 -0
- package/dist/core/config/constants.d.ts.map +1 -1
- package/dist/core/config/constants.js +5 -2
- package/dist/core/config/constants.js.map +1 -1
- package/dist/core/config/entities.d.ts +3 -0
- package/dist/core/config/entities.d.ts.map +1 -0
- package/dist/core/config/entities.js +37 -0
- package/dist/core/config/entities.js.map +1 -0
- package/dist/core/config/functions.d.ts +4 -0
- package/dist/core/config/functions.d.ts.map +1 -0
- package/dist/core/config/functions.js +38 -0
- package/dist/core/config/functions.js.map +1 -0
- package/dist/core/config/index.d.ts +3 -0
- package/dist/core/config/index.d.ts.map +1 -1
- package/dist/core/config/index.js +3 -0
- package/dist/core/config/index.js.map +1 -1
- package/dist/core/config/project.d.ts +15 -0
- package/dist/core/config/project.d.ts.map +1 -0
- package/dist/core/config/project.js +64 -0
- package/dist/core/config/project.js.map +1 -0
- package/dist/core/schemas/entity.d.ts +16 -0
- package/dist/core/schemas/entity.d.ts.map +1 -0
- package/dist/core/schemas/entity.js +10 -0
- package/dist/core/schemas/entity.js.map +1 -0
- package/dist/core/schemas/function.d.ts +53 -0
- package/dist/core/schemas/function.d.ts.map +1 -0
- package/dist/core/schemas/function.js +19 -0
- package/dist/core/schemas/function.js.map +1 -0
- package/dist/core/schemas/index.d.ts +3 -0
- package/dist/core/schemas/index.d.ts.map +1 -1
- package/dist/core/schemas/index.js +3 -0
- package/dist/core/schemas/index.js.map +1 -1
- package/dist/core/schemas/project.d.ts +14 -0
- package/dist/core/schemas/project.d.ts.map +1 -0
- package/dist/core/schemas/project.js +9 -0
- package/dist/core/schemas/project.js.map +1 -0
- package/dist/core/utils/fs.d.ts +1 -1
- package/dist/core/utils/fs.d.ts.map +1 -1
- package/dist/core/utils/fs.js +21 -11
- package/dist/core/utils/fs.js.map +1 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -11,32 +11,42 @@ npm install
|
|
|
11
11
|
# Build the project
|
|
12
12
|
npm run build
|
|
13
13
|
|
|
14
|
-
# Run the CLI
|
|
14
|
+
# Run the CLI
|
|
15
15
|
npm start # Using node directly
|
|
16
|
-
npm run base44 # Using npm (runs node_modules/.bin/base44)
|
|
17
16
|
./dist/cli/index.js # Run executable directly
|
|
18
17
|
```
|
|
19
18
|
|
|
20
19
|
## Development
|
|
21
20
|
|
|
22
21
|
```bash
|
|
23
|
-
# Run in development mode
|
|
22
|
+
# Run in development mode
|
|
24
23
|
npm run dev
|
|
25
24
|
|
|
26
25
|
# Build the project
|
|
27
26
|
npm run build
|
|
28
27
|
|
|
28
|
+
# Run the built CLI
|
|
29
|
+
npm run start
|
|
30
|
+
|
|
29
31
|
# Clean build artifacts
|
|
30
32
|
npm run clean
|
|
33
|
+
|
|
34
|
+
# Lint the code
|
|
35
|
+
npm run lint
|
|
31
36
|
```
|
|
32
37
|
|
|
33
38
|
## Commands
|
|
34
39
|
|
|
35
40
|
### Authentication
|
|
36
|
-
|
|
41
|
+
|
|
42
|
+
- `base44 login` - Authenticate with Base44 using device code flow
|
|
37
43
|
- `base44 whoami` - Display current authenticated user
|
|
38
44
|
- `base44 logout` - Logout from current device
|
|
39
45
|
|
|
46
|
+
### Project
|
|
47
|
+
|
|
48
|
+
- `base44 show-project` - Display project configuration, entities, and functions
|
|
49
|
+
|
|
40
50
|
## Project Structure
|
|
41
51
|
|
|
42
52
|
```
|
|
@@ -45,28 +55,22 @@ cli/
|
|
|
45
55
|
│ ├── core/ # Core module (shared code)
|
|
46
56
|
│ │ ├── api/ # API client code
|
|
47
57
|
│ │ ├── config/ # Configuration management
|
|
58
|
+
│ │ ├── errors/ # Custom error classes
|
|
48
59
|
│ │ ├── schemas/ # Zod schemas
|
|
49
60
|
│ │ ├── utils/ # Utility functions
|
|
50
61
|
│ │ └── index.ts # Core module exports
|
|
51
62
|
│ └── cli/ # CLI module (main CLI)
|
|
52
63
|
│ ├── commands/ # Command implementations
|
|
53
|
-
│ │
|
|
64
|
+
│ │ ├── auth/ # Authentication commands
|
|
65
|
+
│ │ └── project/ # Project commands
|
|
54
66
|
│ ├── utils/ # CLI-specific utilities
|
|
55
|
-
│ └── index.ts # Main CLI entry point
|
|
67
|
+
│ └── index.ts # Main CLI entry point
|
|
56
68
|
├── dist/ # Build output (compiled JavaScript)
|
|
57
69
|
├── package.json # Package configuration
|
|
58
70
|
├── tsconfig.json # TypeScript configuration
|
|
59
71
|
└── README.md
|
|
60
72
|
```
|
|
61
73
|
|
|
62
|
-
## Technologies
|
|
63
|
-
|
|
64
|
-
- **TypeScript** - Primary language
|
|
65
|
-
- **Commander.js** - CLI framework
|
|
66
|
-
- **@clack/prompts** - Interactive user prompts
|
|
67
|
-
- **Zod** - Schema validation
|
|
68
|
-
|
|
69
74
|
## License
|
|
70
75
|
|
|
71
76
|
ISC
|
|
72
|
-
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/auth/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/auth/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6FpC,eAAO,MAAM,YAAY,SAIrB,CAAC"}
|
|
@@ -1,87 +1,57 @@
|
|
|
1
1
|
import { Command } from "commander";
|
|
2
|
-
import { log
|
|
2
|
+
import { log } from "@clack/prompts";
|
|
3
3
|
import pWaitFor from "p-wait-for";
|
|
4
4
|
import { writeAuth } from "../../../core/config/auth.js";
|
|
5
|
-
import { generateDeviceCode, getTokenFromDeviceCode
|
|
6
|
-
import { runCommand } from "../../utils/index.js";
|
|
5
|
+
import { generateDeviceCode, getTokenFromDeviceCode } from "../../../core/api/auth/index.js";
|
|
6
|
+
import { runCommand, runTask } from "../../utils/index.js";
|
|
7
7
|
async function generateAndDisplayDeviceCode() {
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
catch (error) {
|
|
18
|
-
s.stop("Failed to generate device code");
|
|
19
|
-
if (error instanceof AuthValidationError) {
|
|
20
|
-
const issues = error.issues.map((i) => i.message).join(", ");
|
|
21
|
-
throw new Error(`Invalid response from server: ${issues}`);
|
|
22
|
-
}
|
|
23
|
-
if (error instanceof AuthApiError) {
|
|
24
|
-
throw new Error(`Failed to generate device code: ${error.message}`);
|
|
25
|
-
}
|
|
26
|
-
throw new Error(`Unexpected error: ${error instanceof Error ? error.message : String(error)}`);
|
|
27
|
-
}
|
|
8
|
+
const deviceCodeResponse = await runTask("Generating device code...", async () => {
|
|
9
|
+
return await generateDeviceCode();
|
|
10
|
+
}, {
|
|
11
|
+
successMessage: "Device code generated",
|
|
12
|
+
errorMessage: "Failed to generate device code",
|
|
13
|
+
});
|
|
14
|
+
log.info(`Please visit: ${deviceCodeResponse.verificationUrl}\n` +
|
|
15
|
+
`Enter your device code: ${deviceCodeResponse.userCode}`);
|
|
16
|
+
return deviceCodeResponse;
|
|
28
17
|
}
|
|
29
18
|
async function waitForAuthentication(deviceCode, expiresIn) {
|
|
30
|
-
|
|
31
|
-
s.start("Waiting for you to complete authentication...");
|
|
32
|
-
let tokenResponse = null;
|
|
19
|
+
let tokenResponse;
|
|
33
20
|
try {
|
|
34
|
-
await
|
|
35
|
-
|
|
21
|
+
await runTask("Waiting for you to complete authentication...", async () => {
|
|
22
|
+
await pWaitFor(async () => {
|
|
36
23
|
const result = await getTokenFromDeviceCode(deviceCode);
|
|
37
24
|
if (result !== null) {
|
|
38
25
|
tokenResponse = result;
|
|
39
26
|
return true;
|
|
40
27
|
}
|
|
41
28
|
return false;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
throw new Error(`Invalid response from server: ${issues}`);
|
|
47
|
-
}
|
|
48
|
-
if (error instanceof AuthApiError) {
|
|
49
|
-
throw new Error(`API error: ${error.message}`);
|
|
50
|
-
}
|
|
51
|
-
throw error;
|
|
52
|
-
}
|
|
29
|
+
}, {
|
|
30
|
+
interval: 2000,
|
|
31
|
+
timeout: expiresIn * 1000,
|
|
32
|
+
});
|
|
53
33
|
}, {
|
|
54
|
-
|
|
55
|
-
|
|
34
|
+
successMessage: "Authentication completed!",
|
|
35
|
+
errorMessage: "Authentication failed",
|
|
56
36
|
});
|
|
57
37
|
}
|
|
58
38
|
catch (error) {
|
|
59
|
-
s.stop("Authentication failed");
|
|
60
39
|
if (error instanceof Error && error.message.includes("timed out")) {
|
|
61
40
|
throw new Error("Authentication timed out. Please try again.");
|
|
62
41
|
}
|
|
63
|
-
|
|
64
|
-
throw error;
|
|
65
|
-
}
|
|
66
|
-
throw new Error("Unexpected error during authentication");
|
|
42
|
+
throw error;
|
|
67
43
|
}
|
|
68
|
-
|
|
69
|
-
if (!tokenResponse) {
|
|
44
|
+
if (tokenResponse === undefined) {
|
|
70
45
|
throw new Error("Failed to retrieve authentication token.");
|
|
71
46
|
}
|
|
72
47
|
return tokenResponse;
|
|
73
48
|
}
|
|
74
49
|
async function saveAuthData(token) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
catch (error) {
|
|
83
|
-
throw new Error(`Failed to save authentication data: ${error instanceof Error ? error.message : String(error)}`);
|
|
84
|
-
}
|
|
50
|
+
await writeAuth({
|
|
51
|
+
token: token.token,
|
|
52
|
+
email: token.email,
|
|
53
|
+
name: token.name,
|
|
54
|
+
});
|
|
85
55
|
}
|
|
86
56
|
async function login() {
|
|
87
57
|
const deviceCodeResponse = await generateAndDisplayDeviceCode();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../../../src/cli/commands/auth/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MA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AAC,CAAC;AAC1B,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,eAAO,MAAM,aAAa,SAItB,CAAC"}
|
|
@@ -3,18 +3,8 @@ import { log } from "@clack/prompts";
|
|
|
3
3
|
import { deleteAuth } from "../../../core/config/auth.js";
|
|
4
4
|
import { runCommand } from "../../utils/index.js";
|
|
5
5
|
async function logout() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
log.info("Logged out successfully");
|
|
9
|
-
}
|
|
10
|
-
catch (error) {
|
|
11
|
-
if (error instanceof Error) {
|
|
12
|
-
log.error(error.message);
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
log.error("Failed to logout");
|
|
16
|
-
}
|
|
17
|
-
}
|
|
6
|
+
await deleteAuth();
|
|
7
|
+
log.info("Logged out successfully");
|
|
18
8
|
}
|
|
19
9
|
export const logoutCommand = new Command("logout")
|
|
20
10
|
.description("Logout from current device")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../../src/cli/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,KAAK,UAAU,MAAM;IACnB,
|
|
1
|
+
{"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../../src/cli/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,KAAK,UAAU,MAAM;IACnB,MAAM,UAAU,EAAE,CAAC;IACnB,GAAG,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;AACtC,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,4BAA4B,CAAC;KACzC,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whoami.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/auth/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"whoami.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/auth/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAUpC,eAAO,MAAM,aAAa,SAItB,CAAC"}
|
|
@@ -3,18 +3,8 @@ import { log } from "@clack/prompts";
|
|
|
3
3
|
import { readAuth } from "../../../core/config/auth.js";
|
|
4
4
|
import { runCommand } from "../../utils/index.js";
|
|
5
5
|
async function whoami() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
log.info(`Logged in as: ${auth.name} (${auth.email})`);
|
|
9
|
-
}
|
|
10
|
-
catch (error) {
|
|
11
|
-
if (error instanceof Error) {
|
|
12
|
-
log.error(error.message);
|
|
13
|
-
}
|
|
14
|
-
else {
|
|
15
|
-
log.error("Failed to read authentication data");
|
|
16
|
-
}
|
|
17
|
-
}
|
|
6
|
+
const auth = await readAuth();
|
|
7
|
+
log.info(`Logged in as: ${auth.name} (${auth.email})`);
|
|
18
8
|
}
|
|
19
9
|
export const whoamiCommand = new Command("whoami")
|
|
20
10
|
.description("Display current authenticated user")
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../../../src/cli/commands/auth/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,KAAK,UAAU,MAAM;IACnB,
|
|
1
|
+
{"version":3,"file":"whoami.js","sourceRoot":"","sources":["../../../../src/cli/commands/auth/whoami.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD,KAAK,UAAU,MAAM;IACnB,MAAM,IAAI,GAAG,MAAM,QAAQ,EAAE,CAAC;IAC9B,GAAG,CAAC,IAAI,CAAC,iBAAiB,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC;KAC/C,WAAW,CAAC,oCAAoC,CAAC;KACjD,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,UAAU,CAAC,MAAM,CAAC,CAAC;AAC3B,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show-project.d.ts","sourceRoot":"","sources":["../../../../src/cli/commands/project/show-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqBpC,eAAO,MAAM,kBAAkB,SAI3B,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Command } from "commander";
|
|
2
|
+
import { log } from "@clack/prompts";
|
|
3
|
+
import { readProjectConfig } from "../../../core/config/project.js";
|
|
4
|
+
import { runCommand, runTask } from "../../utils/index.js";
|
|
5
|
+
async function showProject() {
|
|
6
|
+
const projectData = await runTask("Reading project configuration", async () => {
|
|
7
|
+
return await readProjectConfig();
|
|
8
|
+
}, {
|
|
9
|
+
successMessage: "Project configuration loaded",
|
|
10
|
+
errorMessage: "Failed to load project configuration",
|
|
11
|
+
});
|
|
12
|
+
const jsonOutput = JSON.stringify(projectData, null, 2);
|
|
13
|
+
log.info(jsonOutput);
|
|
14
|
+
}
|
|
15
|
+
export const showProjectCommand = new Command("show-project")
|
|
16
|
+
.description("Display project configuration, entities, and functions")
|
|
17
|
+
.action(async () => {
|
|
18
|
+
await runCommand(showProject);
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=show-project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"show-project.js","sourceRoot":"","sources":["../../../../src/cli/commands/project/show-project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAC;AACpE,OAAO,EAAE,UAAU,EAAG,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE5D,KAAK,UAAU,WAAW;IACxB,MAAM,WAAW,GAAG,MAAM,OAAO,CAC/B,+BAA+B,EAC/B,KAAK,IAAI,EAAE;QACT,OAAO,MAAM,iBAAiB,EAAE,CAAC;IACnC,CAAC,EACD;QACE,cAAc,EAAE,8BAA8B;QAC9C,YAAY,EAAE,sCAAsC;KACrD,CACF,CAAC;IAEF,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACxD,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,IAAI,OAAO,CAAC,cAAc,CAAC;KAC1D,WAAW,CAAC,wDAAwD,CAAC;KACrE,MAAM,CAAC,KAAK,IAAI,EAAE;IACjB,MAAM,UAAU,CAAC,WAAW,CAAC,CAAC;AAChC,CAAC,CAAC,CAAC"}
|
package/dist/cli/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import { getPackageVersion } from './utils/index.js';
|
|
|
4
4
|
import { loginCommand } from './commands/auth/login.js';
|
|
5
5
|
import { whoamiCommand } from './commands/auth/whoami.js';
|
|
6
6
|
import { logoutCommand } from './commands/auth/logout.js';
|
|
7
|
+
import { showProjectCommand } from './commands/project/show-project.js';
|
|
7
8
|
const program = new Command();
|
|
8
9
|
program
|
|
9
10
|
.name('base44')
|
|
@@ -13,6 +14,8 @@ program
|
|
|
13
14
|
program.addCommand(loginCommand);
|
|
14
15
|
program.addCommand(whoamiCommand);
|
|
15
16
|
program.addCommand(logoutCommand);
|
|
17
|
+
// Register project commands
|
|
18
|
+
program.addCommand(showProjectCommand);
|
|
16
19
|
// Parse command line arguments
|
|
17
20
|
program.parse();
|
|
18
21
|
//# sourceMappingURL=index.js.map
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAExE,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,QAAQ,CAAC;KACd,WAAW,CAAC,iEAAiE,CAAC;KAC9E,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAAC;AAEhC,mCAAmC;AACnC,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;AACjC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAClC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAElC,4BAA4B;AAC5B,OAAO,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;AAEvC,+BAA+B;AAC/B,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
|
package/dist/cli/utils/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { readFileSync } from "fs";
|
|
2
|
-
import { fileURLToPath } from "url";
|
|
3
|
-
import { dirname, join } from "path";
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
import { fileURLToPath } from "node:url";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
4
|
export function getPackageVersion() {
|
|
5
5
|
const __filename = fileURLToPath(import.meta.url);
|
|
6
6
|
const __dirname = dirname(__filename);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../../../src/cli/utils/packageVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"packageVersion.js","sourceRoot":"","sources":["../../../src/cli/utils/packageVersion.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,UAAU,iBAAiB;IAC/B,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAEtC,+CAA+C;IAC/C,MAAM,eAAe,GAAG,IAAI,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,cAAc,CAAC,CAAC;IAC1E,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,eAAe,EAAE,OAAO,CAAC,CAAC,CAAC;IACvE,OAAO,WAAW,CAAC,OAAO,CAAC;AAC7B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runCommand.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/runCommand.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"runCommand.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/runCommand.ts"],"names":[],"mappings":"AAMA;;;;;GAKG;AACH,wBAAsB,UAAU,CAC9B,SAAS,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAC7B,OAAO,CAAC,IAAI,CAAC,CAgBf"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { intro, log } from "@clack/prompts";
|
|
2
2
|
import chalk from "chalk";
|
|
3
|
+
import { AuthApiError, AuthValidationError } from "../../core/errors/index.js";
|
|
3
4
|
const base44Color = chalk.bgHex("#E86B3C");
|
|
4
5
|
/**
|
|
5
6
|
* Wraps a command function with the Base44 intro banner.
|
|
@@ -13,7 +14,16 @@ export async function runCommand(commandFn) {
|
|
|
13
14
|
await commandFn();
|
|
14
15
|
}
|
|
15
16
|
catch (e) {
|
|
16
|
-
|
|
17
|
+
if (e instanceof AuthValidationError) {
|
|
18
|
+
const issues = e.issues.map((i) => i.message).join(", ");
|
|
19
|
+
log.error(`Invalid response from server: ${issues}`);
|
|
20
|
+
}
|
|
21
|
+
else if (e instanceof AuthApiError || e instanceof Error) {
|
|
22
|
+
log.error(e.message);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
log.error(String(e));
|
|
26
|
+
}
|
|
17
27
|
process.exit(1);
|
|
18
28
|
}
|
|
19
29
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runCommand.js","sourceRoot":"","sources":["../../../src/cli/utils/runCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"runCommand.js","sourceRoot":"","sources":["../../../src/cli/utils/runCommand.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE1E,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,SAA8B;IAE9B,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,CAAC;IAEhC,IAAI,CAAC;QACH,MAAM,SAAS,EAAE,CAAC;IACpB,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,YAAY,mBAAmB,EAAE,CAAC;YACrC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACzD,GAAG,CAAC,KAAK,CAAC,iCAAiC,MAAM,EAAE,CAAC,CAAC;QACvD,CAAC;aAAM,IAAI,CAAC,YAAY,YAAY,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;YAC3D,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Wraps an async operation with automatic spinner management.
|
|
3
|
+
* The spinner is automatically started, and stopped on both success and error.
|
|
4
|
+
*
|
|
5
|
+
* @param startMessage - Message to show when spinner starts
|
|
6
|
+
* @param operation - The async operation to execute
|
|
7
|
+
* @param options - Optional configuration
|
|
8
|
+
* @returns The result of the operation
|
|
9
|
+
*/
|
|
10
|
+
export declare function runTask<T>(startMessage: string, operation: () => Promise<T>, options?: {
|
|
11
|
+
successMessage?: string;
|
|
12
|
+
errorMessage?: string;
|
|
13
|
+
}): Promise<T>;
|
|
14
|
+
//# sourceMappingURL=runTask.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runTask.d.ts","sourceRoot":"","sources":["../../../src/cli/utils/runTask.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,wBAAsB,OAAO,CAAC,CAAC,EAC7B,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAC3B,OAAO,CAAC,EAAE;IACR,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GACA,OAAO,CAAC,CAAC,CAAC,CAYZ"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { spinner } from "@clack/prompts";
|
|
2
|
+
/**
|
|
3
|
+
* Wraps an async operation with automatic spinner management.
|
|
4
|
+
* The spinner is automatically started, and stopped on both success and error.
|
|
5
|
+
*
|
|
6
|
+
* @param startMessage - Message to show when spinner starts
|
|
7
|
+
* @param operation - The async operation to execute
|
|
8
|
+
* @param options - Optional configuration
|
|
9
|
+
* @returns The result of the operation
|
|
10
|
+
*/
|
|
11
|
+
export async function runTask(startMessage, operation, options) {
|
|
12
|
+
const s = spinner();
|
|
13
|
+
s.start(startMessage);
|
|
14
|
+
try {
|
|
15
|
+
const result = await operation();
|
|
16
|
+
s.stop(options?.successMessage || startMessage);
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
s.stop(options?.errorMessage || "Failed");
|
|
21
|
+
throw error;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=runTask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runTask.js","sourceRoot":"","sources":["../../../src/cli/utils/runTask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAEzC;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,YAAoB,EACpB,SAA2B,EAC3B,OAGC;IAED,MAAM,CAAC,GAAG,OAAO,EAAE,CAAC;IACpB,CAAC,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;IAEtB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;QACjC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,IAAI,YAAY,CAAC,CAAC;QAChD,OAAO,MAAM,CAAC;IAChB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,YAAY,IAAI,QAAQ,CAAC,CAAC;QAC1C,MAAM,KAAK,CAAC;IACd,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { DeviceCodeResponse, TokenResponse } from "./schema.js";
|
|
2
2
|
export declare function generateDeviceCode(): Promise<DeviceCodeResponse>;
|
|
3
3
|
export declare function getTokenFromDeviceCode(deviceCode: string): Promise<TokenResponse | null>;
|
|
4
4
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/core/api/auth/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../../src/core/api/auth/client.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAC,kBAAkB,EAAE,aAAa,EAAC,MAAM,aAAa,CAAC;AAWnE,wBAAsB,kBAAkB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAuCtE;AAED,wBAAsB,sBAAsB,CAC1C,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC,CA4C/B"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DeviceCodeResponseSchema, TokenResponseSchema, } from "./schema.js";
|
|
2
1
|
import { AuthApiError, AuthValidationError } from "../../errors/index.js";
|
|
2
|
+
import { DeviceCodeResponseSchema, TokenResponseSchema } from "./schema.js";
|
|
3
3
|
async function delay(ms) {
|
|
4
4
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
5
5
|
}
|
|
@@ -46,9 +46,9 @@ export async function getTokenFromDeviceCode(deviceCode) {
|
|
|
46
46
|
return null;
|
|
47
47
|
}
|
|
48
48
|
const mockResponse = {
|
|
49
|
-
token:
|
|
50
|
-
email: "
|
|
51
|
-
name: "
|
|
49
|
+
token: `mock-token-${Date.now()}`,
|
|
50
|
+
email: "shahart@base44.com",
|
|
51
|
+
name: "Shahar Talmi",
|
|
52
52
|
};
|
|
53
53
|
const result = TokenResponseSchema.safeParse(mockResponse);
|
|
54
54
|
if (!result.success) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/core/api/auth/client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../../src/core/api/auth/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,mB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AAC,CAAC;QACxC,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,mBAAmB,IAAI,KAAK,YAAY,YAAY,EAAE,CAAC;YAC1E,MAAM,KAAK,CAAC;QACd,CAAC;QACD,MAAM,IAAI,YAAY,CACpB,2CAA2C,EAC3C,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAC1D,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AuthData } from "../schemas/auth.js";
|
|
2
2
|
export declare function readAuth(): Promise<AuthData>;
|
|
3
3
|
export declare function writeAuth(authData: AuthData): Promise<void>;
|
|
4
4
|
export declare function deleteAuth(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/core/config/auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/core/config/auth.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,QAAQ,EAAC,MAAM,oBAAoB,CAAC;AAIjD,wBAAsB,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,CA2BlD;AAED,wBAAsB,SAAS,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAoBjE;AAED,wBAAsB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAUhD"}
|
package/dist/core/config/auth.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AuthDataSchema } from "../schemas/auth.js";
|
|
2
2
|
import { AUTH_FILE_PATH } from "./constants.js";
|
|
3
|
-
import { readJsonFile, writeJsonFile, deleteFile
|
|
3
|
+
import { readJsonFile, writeJsonFile, deleteFile } from "../utils/fs.js";
|
|
4
4
|
export async function readAuth() {
|
|
5
5
|
try {
|
|
6
6
|
const parsed = await readJsonFile(AUTH_FILE_PATH);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/core/config/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/core/config/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAG,MAAM,oBAAoB,CAAC;AAErD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEzE,MAAM,CAAC,KAAK,UAAU,QAAQ;IAC5B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,cAAc,CAAC,CAAC;QAClD,MAAM,MAAM,GAAG,cAAc,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAEhD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CACb,gCAAgC,MAAM,CAAC,KAAK,CAAC,MAAM;iBAChD,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;iBACrB,IAAI,CAAC,IAAI,CAAC,EAAE,CAChB,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;YACvE,MAAM,KAAK,CAAC;QACd,CAAC;QACD,IAAI,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;YAC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;
|
|
3
3
|
export declare const AUTH_FILE_PATH: string;
|
|
4
|
+
export declare const PROJECT_SUBDIR = ".base44";
|
|
5
|
+
export declare const PROJECT_CONFIG_FILE = "config.jsonc";
|
|
6
|
+
export declare const FUNCTION_CONFIG_FILE = "function.jsonc";
|
|
4
7
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/core/config/constants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,QAA6B,CAAC;AACrD,eAAO,MAAM,QAAQ,QAA2B,CAAC;AACjD,eAAO,MAAM,cAAc,QAA8B,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/core/config/constants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,QAA6B,CAAC;AACrD,eAAO,MAAM,QAAQ,QAA2B,CAAC;AACjD,eAAO,MAAM,cAAc,QAA8B,CAAC;AAE1D,eAAO,MAAM,cAAc,YAAY,CAAC;AACxC,eAAO,MAAM,mBAAmB,iBAAiB,CAAC;AAClD,eAAO,MAAM,oBAAoB,mBAAmB,CAAC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { join } from 'path';
|
|
2
|
-
import { homedir } from 'os';
|
|
1
|
+
import { join } from 'node:path';
|
|
2
|
+
import { homedir } from 'node:os';
|
|
3
3
|
export const BASE44_DIR = join(homedir(), '.base44');
|
|
4
4
|
export const AUTH_DIR = join(BASE44_DIR, 'auth');
|
|
5
5
|
export const AUTH_FILE_PATH = join(AUTH_DIR, 'auth.json');
|
|
6
|
+
export const PROJECT_SUBDIR = '.base44';
|
|
7
|
+
export const PROJECT_CONFIG_FILE = 'config.jsonc';
|
|
8
|
+
export const FUNCTION_CONFIG_FILE = 'function.jsonc';
|
|
6
9
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/core/config/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/core/config/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,MAAM,CAAC,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAC;AACrD,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AACjD,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;AAE1D,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC;AACxC,MAAM,CAAC,MAAM,mBAAmB,GAAG,cAAc,CAAC;AAClD,MAAM,CAAC,MAAM,oBAAoB,GAAG,gBAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../../src/core/config/entities.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AA8BjD,wBAAsB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAkB5E"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { globby } from "globby";
|
|
2
|
+
import { EntitySchema } from "../schemas/entity.js";
|
|
3
|
+
import { readJsonFile, pathExists } from "../utils/fs.js";
|
|
4
|
+
async function readEntityFile(entityPath) {
|
|
5
|
+
if (!(await pathExists(entityPath))) {
|
|
6
|
+
throw new Error(`Entity file not found: ${entityPath}`);
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
const parsed = await readJsonFile(entityPath);
|
|
10
|
+
const result = EntitySchema.safeParse(parsed);
|
|
11
|
+
if (!result.success) {
|
|
12
|
+
throw new Error(`Invalid entity configuration in ${entityPath}: ${result.error.issues
|
|
13
|
+
.map((e) => e.message)
|
|
14
|
+
.join(", ")}`);
|
|
15
|
+
}
|
|
16
|
+
return result.data;
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
throw new Error(`Failed to read entity file ${entityPath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
export async function readAllEntities(entitiesDir) {
|
|
23
|
+
if (!(await pathExists(entitiesDir))) {
|
|
24
|
+
throw new Error(`Entities directory not found: ${entitiesDir}`);
|
|
25
|
+
}
|
|
26
|
+
const files = await globby("*.{json,jsonc}", {
|
|
27
|
+
cwd: entitiesDir,
|
|
28
|
+
absolute: true,
|
|
29
|
+
});
|
|
30
|
+
const entities = [];
|
|
31
|
+
for (const filePath of files) {
|
|
32
|
+
const entity = await readEntityFile(filePath);
|
|
33
|
+
entities.push(entity);
|
|
34
|
+
}
|
|
35
|
+
return entities;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=entities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.js","sourceRoot":"","sources":["../../../src/core/config/entities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,YAAY,EAAG,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE1D,KAAK,UAAU,cAAc,CAAC,UAAkB;IAC9C,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,0BAA0B,UAAU,EAAE,CAAC,CAAC;IAC1D,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,YAAY,C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
|
|
2
|
+
export declare function readFunctionConfig(configPath: string): Promise<FunctionConfig>;
|
|
3
|
+
export declare function readAllFunctions(functionsDir: string): Promise<FunctionConfig[]>;
|
|
4
|
+
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../src/core/config/functions.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAI3D,wBAAsB,kBAAkB,CACtC,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,cAAc,CAAC,CAyBzB;AAED,wBAAsB,gBAAgB,CACpC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,cAAc,EAAE,CAAC,CAkB3B"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { globby } from "globby";
|
|
2
|
+
import { FunctionConfigSchema } from "../schemas/function.js";
|
|
3
|
+
import { FUNCTION_CONFIG_FILE } from "./constants.js";
|
|
4
|
+
import { readJsonFile, pathExists } from "../utils/fs.js";
|
|
5
|
+
export async function readFunctionConfig(configPath) {
|
|
6
|
+
if (!(await pathExists(configPath))) {
|
|
7
|
+
throw new Error(`Function configuration file not found: ${configPath}`);
|
|
8
|
+
}
|
|
9
|
+
try {
|
|
10
|
+
const parsed = await readJsonFile(configPath);
|
|
11
|
+
const result = FunctionConfigSchema.safeParse(parsed);
|
|
12
|
+
if (!result.success) {
|
|
13
|
+
throw new Error(`Invalid function configuration in ${configPath}: ${result.error.issues
|
|
14
|
+
.map((e) => e.message)
|
|
15
|
+
.join(", ")}`);
|
|
16
|
+
}
|
|
17
|
+
return result.data;
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
throw new Error(`Failed to read function configuration ${configPath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export async function readAllFunctions(functionsDir) {
|
|
24
|
+
if (!(await pathExists(functionsDir))) {
|
|
25
|
+
throw new Error(`Functions directory not found: ${functionsDir}`);
|
|
26
|
+
}
|
|
27
|
+
const configFiles = await globby(`*/${FUNCTION_CONFIG_FILE}`, {
|
|
28
|
+
cwd: functionsDir,
|
|
29
|
+
absolute: true,
|
|
30
|
+
});
|
|
31
|
+
const functionConfigs = [];
|
|
32
|
+
for (const configPath of configFiles) {
|
|
33
|
+
const config = await readFunctionConfig(configPath);
|
|
34
|
+
functionConfigs.push(config);
|
|
35
|
+
}
|
|
36
|
+
return functionConfigs;
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=functions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.js","sourceRoot":"","sources":["../../../src/core/config/functions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EACL,oBAAoB,EAErB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE1D,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,UAAkB;IAElB,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,0CAA0C,UAAU,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,UAAU,CAAC,CAAC;QAC9C,MAAM,MAAM,GAAG,oBAAoB,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;QAEtD,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CACb,qCAAqC,UAAU,KAAK,MAAM,CAAC,KAAK,CAAC,MAAM;iBACpE,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;iBACrB,IAAI,CAAC,IAAI,CAAC,EAAE,CAChB,CAAC;QACJ,CAAC;QAED,OAAO,MAAM,CAAC,IAAI,CAAC;IACrB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CACb,yCAAyC,UAAU,KACjD,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAC3C,EAAE,CACH,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,YAAoB;IAEpB,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,YAAY,CAAC,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,kCAAkC,YAAY,EAAE,CAAC,CAAC;IACpE,CAAC;IAED,MAAM,WAAW,GAAG,MAAM,MAAM,CAAC,KAAK,oBAAoB,EAAE,EAAE;QAC5D,GAAG,EAAE,YAAY;QACjB,QAAQ,EAAE,IAAI;KACf,CAAC,CAAC;IAEH,MAAM,eAAe,GAAqB,EAAE,CAAC;IAE7C,KAAK,MAAM,UAAU,IAAI,WAAW,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC,UAAU,CAAC,CAAC;QACpD,eAAe,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,eAAe,CAAC;AACzB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/config/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ProjectWithPaths } from "../schemas/project.js";
|
|
2
|
+
import type { Entity } from "../schemas/entity.js";
|
|
3
|
+
import type { FunctionConfig } from "../schemas/function.js";
|
|
4
|
+
export interface ProjectRoot {
|
|
5
|
+
root: string;
|
|
6
|
+
configPath: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ProjectData {
|
|
9
|
+
project: ProjectWithPaths;
|
|
10
|
+
entities: Entity[];
|
|
11
|
+
functions: FunctionConfig[];
|
|
12
|
+
}
|
|
13
|
+
export declare function findProjectRoot(startPath?: string): Promise<ProjectRoot | null>;
|
|
14
|
+
export declare function readProjectConfig(projectRoot?: string): Promise<ProjectData>;
|
|
15
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/core/config/project.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,wBAAwB,CAAC;AAM3D,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,cAAc,EAAE,CAAC;CAC7B;AAkBD,wBAAsB,eAAe,CACnC,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAY7B;AAED,wBAAsB,iBAAiB,CACrC,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,WAAW,CAAC,CAyCtB"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { join, dirname } from "node:path";
|
|
2
|
+
import { ProjectConfigSchema } from "../schemas/project.js";
|
|
3
|
+
import { PROJECT_CONFIG_FILE, PROJECT_SUBDIR } from "./constants.js";
|
|
4
|
+
import { readJsonFile, pathExists } from "../utils/fs.js";
|
|
5
|
+
import { readAllEntities } from "./entities.js";
|
|
6
|
+
import { readAllFunctions } from "./functions.js";
|
|
7
|
+
// Checks for config file in a directory, prioritizing .base44/ subdirectory.
|
|
8
|
+
async function findConfigInDir(dir) {
|
|
9
|
+
const subdirPath = join(dir, PROJECT_SUBDIR, PROJECT_CONFIG_FILE);
|
|
10
|
+
if (await pathExists(subdirPath)) {
|
|
11
|
+
return subdirPath;
|
|
12
|
+
}
|
|
13
|
+
const rootPath = join(dir, PROJECT_CONFIG_FILE);
|
|
14
|
+
if (await pathExists(rootPath)) {
|
|
15
|
+
return rootPath;
|
|
16
|
+
}
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
// Walks up the directory tree to locate a Base44 project config file.
|
|
20
|
+
export async function findProjectRoot(startPath) {
|
|
21
|
+
let current = startPath || process.cwd();
|
|
22
|
+
while (current !== dirname(current)) {
|
|
23
|
+
const configPath = await findConfigInDir(current);
|
|
24
|
+
if (configPath) {
|
|
25
|
+
return { root: current, configPath };
|
|
26
|
+
}
|
|
27
|
+
current = dirname(current);
|
|
28
|
+
}
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
export async function readProjectConfig(projectRoot) {
|
|
32
|
+
let found;
|
|
33
|
+
if (projectRoot) {
|
|
34
|
+
const configPath = await findConfigInDir(projectRoot);
|
|
35
|
+
found = configPath ? { root: projectRoot, configPath } : null;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
found = await findProjectRoot();
|
|
39
|
+
}
|
|
40
|
+
if (!found) {
|
|
41
|
+
throw new Error(`Project root not found. Please ensure ${PROJECT_CONFIG_FILE} exists in the project directory or .base44/ subdirectory.`);
|
|
42
|
+
}
|
|
43
|
+
const { root, configPath } = found;
|
|
44
|
+
const parsed = await readJsonFile(configPath);
|
|
45
|
+
const result = ProjectConfigSchema.safeParse(parsed);
|
|
46
|
+
if (!result.success) {
|
|
47
|
+
const errors = result.error.issues.map((e) => e.message).join(", ");
|
|
48
|
+
throw new Error(`Invalid project configuration: ${errors}`);
|
|
49
|
+
}
|
|
50
|
+
const project = result.data;
|
|
51
|
+
const configDir = dirname(configPath);
|
|
52
|
+
const entitiesPath = join(configDir, project.entitySrc);
|
|
53
|
+
const functionsPath = join(configDir, project.functionSrc);
|
|
54
|
+
const [entities, functions] = await Promise.all([
|
|
55
|
+
(await pathExists(entitiesPath)) ? readAllEntities(entitiesPath) : [],
|
|
56
|
+
(await pathExists(functionsPath)) ? readAllFunctions(functionsPath) : [],
|
|
57
|
+
]);
|
|
58
|
+
return {
|
|
59
|
+
project: { ...project, root, configPath },
|
|
60
|
+
entities,
|
|
61
|
+
functions,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../../src/core/config/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CA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,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE;QACrE,CAAC,MAAM,UAAU,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,EAAE;KACzE,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,EAAE,EAAE,GAAG,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE;QACzC,QAAQ;QACR,SAAS;KACV,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
declare const FieldSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
type: z.ZodString;
|
|
5
|
+
}, z.core.$loose>;
|
|
6
|
+
export declare const EntitySchema: z.ZodObject<{
|
|
7
|
+
name: z.ZodString;
|
|
8
|
+
fields: z.ZodArray<z.ZodObject<{
|
|
9
|
+
name: z.ZodString;
|
|
10
|
+
type: z.ZodString;
|
|
11
|
+
}, z.core.$loose>>;
|
|
12
|
+
}, z.core.$loose>;
|
|
13
|
+
export type Entity = z.infer<typeof EntitySchema>;
|
|
14
|
+
export type EntityField = z.infer<typeof FieldSchema>;
|
|
15
|
+
export {};
|
|
16
|
+
//# sourceMappingURL=entity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity.d.ts","sourceRoot":"","sources":["../../../src/core/schemas/entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,WAAW;;;iBAGf,CAAA;AAEF,eAAO,MAAM,YAAY;;;;;;iBAGvB,CAAA;AAEF,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAClD,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
const FieldSchema = z.looseObject({
|
|
3
|
+
name: z.string().min(1, 'Field name cannot be empty'),
|
|
4
|
+
type: z.string().min(1, 'Field type cannot be empty'),
|
|
5
|
+
});
|
|
6
|
+
export const EntitySchema = z.looseObject({
|
|
7
|
+
name: z.string().min(1, 'Entity name cannot be empty'),
|
|
8
|
+
fields: z.array(FieldSchema).min(0),
|
|
9
|
+
});
|
|
10
|
+
//# sourceMappingURL=entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity.js","sourceRoot":"","sources":["../../../src/core/schemas/entity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC;IAChC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,4BAA4B,CAAC;IACrD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,4BAA4B,CAAC;CACtD,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,CAAC,WAAW,CAAC;IACxC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,6BAA6B,CAAC;IACtD,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CACpC,CAAC,CAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const HttpTriggerSchema: z.ZodObject<{
|
|
3
|
+
type: z.ZodLiteral<"http">;
|
|
4
|
+
route: z.ZodString;
|
|
5
|
+
method: z.ZodEnum<{
|
|
6
|
+
GET: "GET";
|
|
7
|
+
POST: "POST";
|
|
8
|
+
PUT: "PUT";
|
|
9
|
+
PATCH: "PATCH";
|
|
10
|
+
DELETE: "DELETE";
|
|
11
|
+
}>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
declare const ScheduleTriggerSchema: z.ZodObject<{
|
|
14
|
+
type: z.ZodLiteral<"schedule">;
|
|
15
|
+
crontab: z.ZodString;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
declare const TriggerSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
18
|
+
type: z.ZodLiteral<"http">;
|
|
19
|
+
route: z.ZodString;
|
|
20
|
+
method: z.ZodEnum<{
|
|
21
|
+
GET: "GET";
|
|
22
|
+
POST: "POST";
|
|
23
|
+
PUT: "PUT";
|
|
24
|
+
PATCH: "PATCH";
|
|
25
|
+
DELETE: "DELETE";
|
|
26
|
+
}>;
|
|
27
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
28
|
+
type: z.ZodLiteral<"schedule">;
|
|
29
|
+
crontab: z.ZodString;
|
|
30
|
+
}, z.core.$strip>], "type">;
|
|
31
|
+
export declare const FunctionConfigSchema: z.ZodObject<{
|
|
32
|
+
name: z.ZodString;
|
|
33
|
+
triggers: z.ZodOptional<z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
34
|
+
type: z.ZodLiteral<"http">;
|
|
35
|
+
route: z.ZodString;
|
|
36
|
+
method: z.ZodEnum<{
|
|
37
|
+
GET: "GET";
|
|
38
|
+
POST: "POST";
|
|
39
|
+
PUT: "PUT";
|
|
40
|
+
PATCH: "PATCH";
|
|
41
|
+
DELETE: "DELETE";
|
|
42
|
+
}>;
|
|
43
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
44
|
+
type: z.ZodLiteral<"schedule">;
|
|
45
|
+
crontab: z.ZodString;
|
|
46
|
+
}, z.core.$strip>], "type">>>;
|
|
47
|
+
}, z.core.$loose>;
|
|
48
|
+
export type HttpTrigger = z.infer<typeof HttpTriggerSchema>;
|
|
49
|
+
export type ScheduleTrigger = z.infer<typeof ScheduleTriggerSchema>;
|
|
50
|
+
export type Trigger = z.infer<typeof TriggerSchema>;
|
|
51
|
+
export type FunctionConfig = z.infer<typeof FunctionConfigSchema>;
|
|
52
|
+
export {};
|
|
53
|
+
//# sourceMappingURL=function.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../../src/core/schemas/function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,QAAA,MAAM,iBAAiB;;;;;;;;;;iBAIrB,CAAC;AAEH,QAAA,MAAM,qBAAqB;;;iBAGzB,CAAC;AAEH,QAAA,MAAM,aAAa;;;;;;;;;;;;;2BAGjB,CAAC;AAEH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;iBAG/B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AACpE,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC;AACpD,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const HttpTriggerSchema = z.object({
|
|
3
|
+
type: z.literal("http"),
|
|
4
|
+
route: z.string().min(1, "Route cannot be empty"),
|
|
5
|
+
method: z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]),
|
|
6
|
+
});
|
|
7
|
+
const ScheduleTriggerSchema = z.object({
|
|
8
|
+
type: z.literal("schedule"),
|
|
9
|
+
crontab: z.string().min(1, "Crontab expression cannot be empty"),
|
|
10
|
+
});
|
|
11
|
+
const TriggerSchema = z.discriminatedUnion("type", [
|
|
12
|
+
HttpTriggerSchema,
|
|
13
|
+
ScheduleTriggerSchema,
|
|
14
|
+
]);
|
|
15
|
+
export const FunctionConfigSchema = z.looseObject({
|
|
16
|
+
name: z.string().min(1, "Function name cannot be empty"),
|
|
17
|
+
triggers: z.array(TriggerSchema).optional(),
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../../src/core/schemas/function.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC;IACvB,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,uBAAuB,CAAC;IACjD,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;CAC1D,CAAC,CAAC;AAEH,MAAM,qBAAqB,GAAG,CAAC,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,UAAU,CAAC;IAC3B,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,oCAAoC,CAAC;CACjE,CAAC,CAAC;AAEH,MAAM,aAAa,GAAG,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE;IACjD,iBAAiB;IACjB,qBAAqB;CACtB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAAC;IAChD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,+BAA+B,CAAC;IACxD,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,QAAQ,EAAE;CAC5C,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/schemas/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export declare const ProjectConfigSchema: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
name: z.ZodString;
|
|
5
|
+
createdAt: z.ZodString;
|
|
6
|
+
entitySrc: z.ZodDefault<z.ZodString>;
|
|
7
|
+
functionSrc: z.ZodDefault<z.ZodString>;
|
|
8
|
+
}, z.core.$loose>;
|
|
9
|
+
export type ProjectConfig = z.infer<typeof ProjectConfigSchema>;
|
|
10
|
+
export interface ProjectWithPaths extends ProjectConfig {
|
|
11
|
+
root: string;
|
|
12
|
+
configPath: string;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=project.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.d.ts","sourceRoot":"","sources":["../../../src/core/schemas/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,mBAAmB;;;;;;iBAM9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACrD,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;CACpB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const ProjectConfigSchema = z.looseObject({
|
|
3
|
+
id: z.string().min(1, "Project ID cannot be empty"),
|
|
4
|
+
name: z.string().min(1, "Project name cannot be empty"),
|
|
5
|
+
createdAt: z.string(),
|
|
6
|
+
entitySrc: z.string().default("./entities"),
|
|
7
|
+
functionSrc: z.string().default("./functions"),
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../../src/core/schemas/project.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,WAAW,CAAC;IAC/C,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,4BAA4B,CAAC;IACnD,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,8BAA8B,CAAC;IACvD,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC;IAC3C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,aAAa,CAAC;CAC/C,CAAC,CAAC"}
|
package/dist/core/utils/fs.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function pathExists(path: string): Promise<boolean>;
|
|
2
2
|
export declare function readJsonFile(filePath: string): Promise<unknown>;
|
|
3
3
|
export declare function writeJsonFile(filePath: string, data: unknown): Promise<void>;
|
|
4
4
|
export declare function deleteFile(filePath: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/core/utils/fs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/core/utils/fs.ts"],"names":[],"mappings":"AAKA,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,oBAItC;AAED,wBAAsB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CA4BrE;AAED,wBAAsB,aAAa,CACjC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,OAAO,GACZ,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAchE"}
|
package/dist/core/utils/fs.js
CHANGED
|
@@ -1,20 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export function
|
|
5
|
-
return
|
|
1
|
+
import { readFile, writeFile, mkdir, unlink, access } from "node:fs/promises";
|
|
2
|
+
import { dirname } from "node:path";
|
|
3
|
+
import { parse, printParseErrorCode } from "jsonc-parser";
|
|
4
|
+
export function pathExists(path) {
|
|
5
|
+
return access(path)
|
|
6
|
+
.then(() => true)
|
|
7
|
+
.catch(() => false);
|
|
6
8
|
}
|
|
7
9
|
export async function readJsonFile(filePath) {
|
|
8
|
-
if (!
|
|
10
|
+
if (!(await pathExists(filePath))) {
|
|
9
11
|
throw new Error(`File not found: ${filePath}`);
|
|
10
12
|
}
|
|
11
13
|
try {
|
|
12
14
|
const fileContent = await readFile(filePath, "utf-8");
|
|
13
|
-
|
|
15
|
+
const errors = [];
|
|
16
|
+
const result = parse(fileContent, errors, { allowTrailingComma: true });
|
|
17
|
+
if (errors.length > 0) {
|
|
18
|
+
const errorMessages = errors
|
|
19
|
+
.map((e) => `${printParseErrorCode(e.error)} at offset ${e.offset}`)
|
|
20
|
+
.join(", ");
|
|
21
|
+
throw new Error(`File contains invalid JSONC: ${filePath} (${errorMessages})`);
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
14
24
|
}
|
|
15
25
|
catch (error) {
|
|
16
|
-
if (error instanceof
|
|
17
|
-
throw
|
|
26
|
+
if (error instanceof Error && error.message.includes("invalid JSONC")) {
|
|
27
|
+
throw error;
|
|
18
28
|
}
|
|
19
29
|
throw new Error(`Failed to read file ${filePath}: ${error instanceof Error ? error.message : "Unknown error"}`);
|
|
20
30
|
}
|
|
@@ -22,7 +32,7 @@ export async function readJsonFile(filePath) {
|
|
|
22
32
|
export async function writeJsonFile(filePath, data) {
|
|
23
33
|
try {
|
|
24
34
|
const dir = dirname(filePath);
|
|
25
|
-
if (!
|
|
35
|
+
if (!(await pathExists(dir))) {
|
|
26
36
|
await mkdir(dir, { recursive: true });
|
|
27
37
|
}
|
|
28
38
|
const jsonContent = JSON.stringify(data, null, 2);
|
|
@@ -33,7 +43,7 @@ export async function writeJsonFile(filePath, data) {
|
|
|
33
43
|
}
|
|
34
44
|
}
|
|
35
45
|
export async function deleteFile(filePath) {
|
|
36
|
-
if (!
|
|
46
|
+
if (!(await pathExists(filePath))) {
|
|
37
47
|
return;
|
|
38
48
|
}
|
|
39
49
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../src/core/utils/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../../src/core/utils/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE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C,OAAO,CAAC,CAAC,CAAC,eAC3C,EAAE,CACH,CAAC;IACJ,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@base44-preview/cli",
|
|
3
|
-
"version": "0.0.1-pr.
|
|
3
|
+
"version": "0.0.1-pr.7.36e5bda",
|
|
4
4
|
"description": "Base44 CLI - Unified interface for managing Base44 applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/cli/index.js",
|
|
@@ -37,6 +37,8 @@
|
|
|
37
37
|
"@clack/prompts": "^0.11.0",
|
|
38
38
|
"chalk": "^5.6.2",
|
|
39
39
|
"commander": "^12.1.0",
|
|
40
|
+
"globby": "^16.1.0",
|
|
41
|
+
"jsonc-parser": "^3.3.1",
|
|
40
42
|
"p-wait-for": "^6.0.0",
|
|
41
43
|
"zod": "^4.3.5"
|
|
42
44
|
},
|
|
@@ -46,9 +48,11 @@
|
|
|
46
48
|
"@typescript-eslint/parser": "^8.51.0",
|
|
47
49
|
"eslint": "^9.39.2",
|
|
48
50
|
"eslint-plugin-import": "^2.32.0",
|
|
51
|
+
"eslint-plugin-unicorn": "^62.0.0",
|
|
49
52
|
"tsc-alias": "^1.8.16",
|
|
50
53
|
"tsx": "^4.19.2",
|
|
51
|
-
"typescript": "^5.7.2"
|
|
54
|
+
"typescript": "^5.7.2",
|
|
55
|
+
"typescript-eslint": "^8.52.0"
|
|
52
56
|
},
|
|
53
57
|
"engines": {
|
|
54
58
|
"node": ">=20.0.0"
|