@oaysus/cli 0.1.0 → 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/README.md +87 -95
- package/dist/lib/shared/auth.d.ts.map +1 -1
- package/dist/lib/shared/auth.js +57 -10
- package/dist/lib/shared/auth.js.map +1 -1
- package/dist/lib/shared/config.d.ts +6 -8
- package/dist/lib/shared/config.d.ts.map +1 -1
- package/dist/lib/shared/config.js +74 -10
- package/dist/lib/shared/config.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,47 +1,58 @@
|
|
|
1
1
|
# @oaysus/cli
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/@oaysus/cli)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
**Build components in React, Vue, or Svelte. Push with one command. Let your team create pages visually.**
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
Stop building every landing page from scratch. Oaysus lets developers create reusable components that marketing teams can assemble into pages without writing code or waiting for deployments.
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
npm install -g @oaysus/cli
|
|
11
|
-
```
|
|
10
|
+
## What is Oaysus?
|
|
12
11
|
|
|
13
|
-
|
|
12
|
+
[Oaysus](https://oaysus.com) is a visual page builder for developer-built components. You write components in your favorite framework, define what's editable via a simple schema, and push them to Oaysus. Your marketing team then uses a drag-and-drop editor to create pages instantly.
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
**The workflow:**
|
|
15
|
+
```
|
|
16
|
+
Developer builds component → Pushes to Oaysus → Marketing creates pages visually
|
|
18
17
|
```
|
|
19
18
|
|
|
20
|
-
|
|
19
|
+
No more "can you update the hero text?" tickets. No more waiting for deploys to change copy. Your team ships faster, and you get back to building features.
|
|
20
|
+
|
|
21
|
+
## Installation
|
|
21
22
|
|
|
22
23
|
```bash
|
|
23
|
-
oaysus
|
|
24
|
+
npm install -g @oaysus/cli
|
|
24
25
|
```
|
|
25
26
|
|
|
27
|
+
Requires Node.js 20 or higher.
|
|
28
|
+
|
|
26
29
|
## Quick Start
|
|
27
30
|
|
|
28
31
|
```bash
|
|
29
|
-
# Authenticate with Oaysus
|
|
32
|
+
# 1. Authenticate with your Oaysus account
|
|
30
33
|
oaysus login
|
|
31
34
|
|
|
32
|
-
# Create a new theme pack project
|
|
33
|
-
oaysus init my-
|
|
34
|
-
|
|
35
|
-
# Navigate to project
|
|
36
|
-
cd my-theme
|
|
35
|
+
# 2. Create a new theme pack project
|
|
36
|
+
oaysus init my-components
|
|
37
37
|
|
|
38
|
-
#
|
|
39
|
-
|
|
38
|
+
# 3. Navigate to the project
|
|
39
|
+
cd my-components
|
|
40
40
|
|
|
41
|
-
#
|
|
41
|
+
# 4. Push your components to Oaysus
|
|
42
42
|
oaysus push
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
+
That's it. Your components are now available in the visual page builder.
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
✓ Validated 1 component
|
|
49
|
+
✓ Built and bundled (2.1 KB)
|
|
50
|
+
✓ Uploaded to Oaysus
|
|
51
|
+
✓ Published!
|
|
52
|
+
|
|
53
|
+
Install in dashboard: Content → Theme Packs
|
|
54
|
+
```
|
|
55
|
+
|
|
45
56
|
## Commands
|
|
46
57
|
|
|
47
58
|
| Command | Description |
|
|
@@ -57,109 +68,90 @@ oaysus push
|
|
|
57
68
|
|
|
58
69
|
## Framework Support
|
|
59
70
|
|
|
60
|
-
|
|
71
|
+
Build with the tools you already know:
|
|
61
72
|
|
|
62
|
-
- **React**
|
|
63
|
-
- **Vue**
|
|
64
|
-
- **Svelte**
|
|
73
|
+
- **React** — JSX/TSX components with full hooks support
|
|
74
|
+
- **Vue** — Single File Components (.vue)
|
|
75
|
+
- **Svelte** — Native Svelte components (.svelte)
|
|
65
76
|
|
|
66
77
|
Framework is automatically detected from your `package.json` dependencies.
|
|
67
78
|
|
|
68
|
-
##
|
|
69
|
-
|
|
70
|
-
### Single Component
|
|
71
|
-
|
|
72
|
-
```
|
|
73
|
-
my-component/
|
|
74
|
-
├── package.json
|
|
75
|
-
├── index.tsx # Main component file
|
|
76
|
-
└── schema.json # Component props schema
|
|
77
|
-
```
|
|
79
|
+
## How Components Work
|
|
78
80
|
|
|
79
|
-
|
|
81
|
+
Each component has two files: the code and a schema that defines what's editable.
|
|
80
82
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
│ ├── index.tsx
|
|
90
|
-
│ └── schema.json
|
|
91
|
-
└── Header/
|
|
92
|
-
├── index.tsx
|
|
93
|
-
└── schema.json
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
## Configuration
|
|
97
|
-
|
|
98
|
-
### package.json
|
|
99
|
-
|
|
100
|
-
```json
|
|
101
|
-
{
|
|
102
|
-
"name": "my-theme",
|
|
103
|
-
"version": "1.0.0",
|
|
104
|
-
"dependencies": {
|
|
105
|
-
"react": "^18.0.0"
|
|
106
|
-
},
|
|
107
|
-
"oaysus": {
|
|
108
|
-
"theme": {
|
|
109
|
-
"name": "my-theme",
|
|
110
|
-
"displayName": "My Theme",
|
|
111
|
-
"category": "ui",
|
|
112
|
-
"tags": ["react", "components"]
|
|
113
|
-
}
|
|
114
|
-
}
|
|
83
|
+
**Component (React example):**
|
|
84
|
+
```tsx
|
|
85
|
+
export default function AnnouncementBar({ message, backgroundColor }) {
|
|
86
|
+
return (
|
|
87
|
+
<div style={{ backgroundColor }} className="py-3 px-4 text-center text-white">
|
|
88
|
+
{message}
|
|
89
|
+
</div>
|
|
90
|
+
);
|
|
115
91
|
}
|
|
116
92
|
```
|
|
117
93
|
|
|
118
|
-
|
|
119
|
-
|
|
94
|
+
**Schema:**
|
|
120
95
|
```json
|
|
121
96
|
{
|
|
122
|
-
"
|
|
123
|
-
"displayName": "My Component",
|
|
124
|
-
"description": "A reusable UI component",
|
|
97
|
+
"displayName": "Announcement Bar",
|
|
125
98
|
"props": {
|
|
126
|
-
"
|
|
99
|
+
"message": {
|
|
127
100
|
"type": "string",
|
|
128
|
-
"default": "
|
|
129
|
-
"description": "The title text"
|
|
101
|
+
"default": "Free shipping on orders over $50"
|
|
130
102
|
},
|
|
131
|
-
"
|
|
132
|
-
"type": "
|
|
133
|
-
"default": "
|
|
134
|
-
"description": "Button variant"
|
|
103
|
+
"backgroundColor": {
|
|
104
|
+
"type": "color",
|
|
105
|
+
"default": "#2563eb"
|
|
135
106
|
}
|
|
136
107
|
}
|
|
137
108
|
}
|
|
138
109
|
```
|
|
139
110
|
|
|
140
|
-
|
|
111
|
+
Marketing edits `message` and `backgroundColor` in the visual editor. You never touch the code again.
|
|
141
112
|
|
|
142
|
-
|
|
143
|
-
- Oaysus account
|
|
113
|
+
## Project Structure
|
|
144
114
|
|
|
145
|
-
|
|
115
|
+
```
|
|
116
|
+
my-components/
|
|
117
|
+
├── package.json
|
|
118
|
+
└── components/
|
|
119
|
+
├── AnnouncementBar/
|
|
120
|
+
│ ├── index.tsx
|
|
121
|
+
│ └── schema.json
|
|
122
|
+
├── Hero/
|
|
123
|
+
│ ├── index.tsx
|
|
124
|
+
│ └── schema.json
|
|
125
|
+
└── FeatureGrid/
|
|
126
|
+
├── index.tsx
|
|
127
|
+
└── schema.json
|
|
128
|
+
```
|
|
146
129
|
|
|
147
|
-
|
|
130
|
+
## Documentation
|
|
148
131
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
132
|
+
- **[Quick Start Guide](https://oaysus.com/docs/quickstart)** — Build your first component in 5 minutes
|
|
133
|
+
- **[CLI Reference](https://oaysus.com/docs/cli)** — Complete command documentation
|
|
134
|
+
- **[Component Guide](https://oaysus.com/docs/components)** — Props, schemas, and best practices
|
|
135
|
+
- **[Theme Packs](https://oaysus.com/docs/theme-packs)** — Organize and distribute component collections
|
|
153
136
|
|
|
154
|
-
|
|
137
|
+
## Why Oaysus?
|
|
155
138
|
|
|
156
|
-
|
|
139
|
+
| Traditional Approach | With Oaysus |
|
|
140
|
+
|---------------------|-------------|
|
|
141
|
+
| Marketing files a ticket for every page change | Marketing creates pages themselves |
|
|
142
|
+
| Developers build one-off landing pages | Developers build reusable components |
|
|
143
|
+
| Every text change requires a deploy | Changes publish instantly |
|
|
144
|
+
| Locked into proprietary CMS themes | Standard React/Vue/Svelte you own |
|
|
145
|
+
|
|
146
|
+
## Get Started
|
|
157
147
|
|
|
158
|
-
|
|
148
|
+
1. **[Create an account](https://oaysus.com/pricing)** — Free tier available
|
|
149
|
+
2. **Install the CLI** — `npm install -g @oaysus/cli`
|
|
150
|
+
3. **Follow the quick start** — [oaysus.com/docs/quickstart](https://oaysus.com/docs/quickstart)
|
|
159
151
|
|
|
160
152
|
## Contributing
|
|
161
153
|
|
|
162
|
-
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup
|
|
154
|
+
We welcome contributions! See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup.
|
|
163
155
|
|
|
164
156
|
## License
|
|
165
157
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/lib/shared/auth.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/lib/shared/auth.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAyDlG;;GAEG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BvF;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,MAAM,CAKzC;AAED;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAmCpE;AAED;;GAEG;AACH,wBAAsB,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BxF;AAED;;;GAGG;AACH,wBAAsB,WAAW,CAC/B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAC7C,OAAO,CAAC,WAAW,GAAG,oBAAoB,CAAC,CA+E7C;AAED;;GAEG;AACH,wBAAsB,eAAe,CAAC,WAAW,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAY7E;AAED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,CAOnE;AAED;;GAEG;AACH,wBAAsB,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC,CAMtD;AAED;;GAEG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CAYxD;AAED;;GAEG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,CAgBxD"}
|
package/dist/lib/shared/auth.js
CHANGED
|
@@ -3,7 +3,46 @@ import fs from 'fs/promises';
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import os from 'os';
|
|
5
5
|
import crypto from 'crypto';
|
|
6
|
-
import { SSO_BASE_URL, ADMIN_URL, CREDENTIALS_PATH, debug as log, debugError as logError } from './config.js';
|
|
6
|
+
import { SSO_BASE_URL, ADMIN_URL, CREDENTIALS_PATH, IS_LOCAL_DEV, debug as log, debugError as logError } from './config.js';
|
|
7
|
+
/**
|
|
8
|
+
* Format a friendly error message for API errors
|
|
9
|
+
*/
|
|
10
|
+
function formatApiError(error, context) {
|
|
11
|
+
if (axios.isAxiosError(error)) {
|
|
12
|
+
const status = error.response?.status;
|
|
13
|
+
const data = error.response?.data;
|
|
14
|
+
// Connection refused - server not running
|
|
15
|
+
if (error.code === 'ECONNREFUSED') {
|
|
16
|
+
const serverUrl = IS_LOCAL_DEV ? 'localhost:3003' : 'auth.oaysus.com';
|
|
17
|
+
return new Error(`Cannot connect to ${serverUrl}. ${IS_LOCAL_DEV ? 'Is your local FastAPI server running?' : 'Please check your internet connection.'}`);
|
|
18
|
+
}
|
|
19
|
+
// 500 errors - server-side issue
|
|
20
|
+
if (status === 500) {
|
|
21
|
+
const detail = data?.detail?.error || data?.error || data?.message;
|
|
22
|
+
return new Error(`Server error during ${context}. ${detail ? `Details: ${detail}` : 'Please try again or contact support.'}`);
|
|
23
|
+
}
|
|
24
|
+
// 401/403 - auth issues
|
|
25
|
+
if (status === 401 || status === 403) {
|
|
26
|
+
return new Error(data?.message || data?.error || 'Authentication failed. Please try again.');
|
|
27
|
+
}
|
|
28
|
+
// 404 - endpoint not found
|
|
29
|
+
if (status === 404) {
|
|
30
|
+
return new Error(IS_LOCAL_DEV
|
|
31
|
+
? `API endpoint not found. Make sure your local server is running the latest code.`
|
|
32
|
+
: `Service temporarily unavailable. Please try again later.`);
|
|
33
|
+
}
|
|
34
|
+
// Other errors with messages
|
|
35
|
+
const message = data?.message || data?.error || data?.detail?.error;
|
|
36
|
+
if (message) {
|
|
37
|
+
return new Error(message);
|
|
38
|
+
}
|
|
39
|
+
return new Error(`Request failed with status ${status || 'unknown'}`);
|
|
40
|
+
}
|
|
41
|
+
if (error instanceof Error) {
|
|
42
|
+
return error;
|
|
43
|
+
}
|
|
44
|
+
return new Error('An unexpected error occurred');
|
|
45
|
+
}
|
|
7
46
|
/**
|
|
8
47
|
* Request magic link for email authentication with device code
|
|
9
48
|
*/
|
|
@@ -27,13 +66,12 @@ export async function requestMagicLink(email, deviceCode) {
|
|
|
27
66
|
throw new Error(response.data.message || 'Failed to send magic link');
|
|
28
67
|
}
|
|
29
68
|
catch (error) {
|
|
69
|
+
logError('[ERROR] Magic link request failed');
|
|
30
70
|
if (axios.isAxiosError(error)) {
|
|
31
|
-
logError('[ERROR] Magic link request failed');
|
|
32
71
|
logError('[ERROR] Status:', error.response?.status);
|
|
33
72
|
logError('[ERROR] Response:', error.response?.data);
|
|
34
|
-
throw new Error(error.response?.data?.message || 'Failed to send magic link');
|
|
35
73
|
}
|
|
36
|
-
throw error;
|
|
74
|
+
throw formatApiError(error, 'magic link request');
|
|
37
75
|
}
|
|
38
76
|
}
|
|
39
77
|
/**
|
|
@@ -77,14 +115,13 @@ export async function initializeDevice() {
|
|
|
77
115
|
return response.data;
|
|
78
116
|
}
|
|
79
117
|
catch (error) {
|
|
118
|
+
logError('[ERROR] Device init failed');
|
|
119
|
+
logError('[ERROR] URL:', url);
|
|
80
120
|
if (axios.isAxiosError(error)) {
|
|
81
|
-
logError('[ERROR] Request failed');
|
|
82
|
-
logError('[ERROR] URL:', url);
|
|
83
121
|
logError('[ERROR] Status:', error.response?.status);
|
|
84
122
|
logError('[ERROR] Response:', error.response?.data);
|
|
85
|
-
logError('[ERROR] Message:', error.message);
|
|
86
123
|
}
|
|
87
|
-
throw error;
|
|
124
|
+
throw formatApiError(error, 'device initialization');
|
|
88
125
|
}
|
|
89
126
|
}
|
|
90
127
|
/**
|
|
@@ -131,6 +168,8 @@ export async function pollForAuth(deviceCode, options) {
|
|
|
131
168
|
try {
|
|
132
169
|
const response = await axios.get(`${SSO_BASE_URL}/sso/cli/device/status`, { params: { deviceCode } });
|
|
133
170
|
const data = response.data;
|
|
171
|
+
log('[DEBUG] Poll response status:', data.status);
|
|
172
|
+
log('[DEBUG] Poll response data:', JSON.stringify(data, null, 2));
|
|
134
173
|
// Device approved but needs website selection
|
|
135
174
|
if (data.status === 'approved' && data.needsWebsiteSelection && data.websites) {
|
|
136
175
|
log('[DEBUG] Device approved - needs website selection');
|
|
@@ -163,8 +202,16 @@ export async function pollForAuth(deviceCode, options) {
|
|
|
163
202
|
await new Promise(resolve => setTimeout(resolve, options.interval));
|
|
164
203
|
}
|
|
165
204
|
catch (error) {
|
|
166
|
-
if (axios.isAxiosError(error)
|
|
167
|
-
|
|
205
|
+
if (axios.isAxiosError(error)) {
|
|
206
|
+
logError('[ERROR] Poll request failed');
|
|
207
|
+
logError('[ERROR] Status:', error.response?.status);
|
|
208
|
+
logError('[ERROR] Response:', error.response?.data);
|
|
209
|
+
if (error.response?.status === 404) {
|
|
210
|
+
throw new Error('Authorization request not found or expired');
|
|
211
|
+
}
|
|
212
|
+
if (error.response?.status === 500) {
|
|
213
|
+
logError('[ERROR] Server error - check FastAPI logs');
|
|
214
|
+
}
|
|
168
215
|
}
|
|
169
216
|
if (error instanceof Error && error.message.includes('denied')) {
|
|
170
217
|
throw error;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/shared/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,KAAK,IAAI,GAAG,EAAE,UAAU,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/shared/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,MAAM,aAAa,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,gBAAgB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C,gBAAgB,CAAC,CAAC;IACpC,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,+BAA+B;IACjC,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe;IACnC,MAAM,WAAW,GAAG,MAAM,eAAe,EAAE,CAAC;IAE5C,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,yBAAyB;IACzB,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAClD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IAEvB,OAAO,SAAS,GAAG,GAAG,CAAC;AACzB,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW;IAC/B,MAAM,WAAW,GAAG,MAAM,eAAe,EAAE,CAAC;IAE5C,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;IAC1D,CAAC;IAED,eAAe;IACf,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAClD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC;IAEvB,IAAI,SAAS,IAAI,GAAG,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Centralized Configuration Module
|
|
3
3
|
*
|
|
4
|
-
* Production defaults are baked in for end users
|
|
5
|
-
*
|
|
4
|
+
* Production defaults are baked in for end users.
|
|
5
|
+
* Local development: Create .env.local in the CLI directory to override.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* - NPM global install: npm install -g @oaysus/cli
|
|
9
|
-
* - Homebrew: brew install oaysus
|
|
10
|
-
* - Local development: bun run dev
|
|
7
|
+
* Install: npm install -g @oaysus/cli
|
|
11
8
|
*/
|
|
12
9
|
/**
|
|
13
10
|
* Environment configuration
|
|
14
|
-
*
|
|
11
|
+
* Priority: .env.local > environment variables > production defaults
|
|
15
12
|
*/
|
|
16
13
|
export declare const config: {
|
|
17
14
|
readonly SSO_BASE_URL: string;
|
|
@@ -22,8 +19,9 @@ export declare const config: {
|
|
|
22
19
|
readonly DEBUG: boolean;
|
|
23
20
|
readonly CREDENTIALS_PATH: string;
|
|
24
21
|
readonly CONFIG_DIR: string;
|
|
22
|
+
readonly IS_LOCAL_DEV: boolean;
|
|
25
23
|
};
|
|
26
|
-
export declare const SSO_BASE_URL: string, ADMIN_URL: string, R2_PUBLIC_URL: string, API_STAGE: string, DEVELOPER: string | undefined, DEBUG: boolean, CREDENTIALS_PATH: string, CONFIG_DIR: string;
|
|
24
|
+
export declare const SSO_BASE_URL: string, ADMIN_URL: string, R2_PUBLIC_URL: string, API_STAGE: string, DEVELOPER: string | undefined, DEBUG: boolean, CREDENTIALS_PATH: string, CONFIG_DIR: string, IS_LOCAL_DEV: boolean;
|
|
27
25
|
/**
|
|
28
26
|
* Get current deployment environment
|
|
29
27
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/lib/shared/config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/lib/shared/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAkFH;;;GAGG;AACH,eAAO,MAAM,MAAM;;;;;;;;;;CA2BT,CAAC;AAGX,eAAO,MACL,YAAY,UACZ,SAAS,UACT,aAAa,UACb,SAAS,UACT,SAAS,sBACT,KAAK,WACL,gBAAgB,UAChB,UAAU,UACV,YAAY,SACJ,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,KAAK,GAAG,MAAM,CAAC;AAEnD,wBAAgB,cAAc,IAAI,WAAW,CAS5C;AAED;;GAEG;AACH,wBAAgB,KAAK,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAI9C;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAInD"}
|
|
@@ -1,23 +1,85 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Centralized Configuration Module
|
|
3
3
|
*
|
|
4
|
-
* Production defaults are baked in for end users
|
|
5
|
-
*
|
|
4
|
+
* Production defaults are baked in for end users.
|
|
5
|
+
* Local development: Create .env.local in the CLI directory to override.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
* - NPM global install: npm install -g @oaysus/cli
|
|
9
|
-
* - Homebrew: brew install oaysus
|
|
10
|
-
* - Local development: bun run dev
|
|
7
|
+
* Install: npm install -g @oaysus/cli
|
|
11
8
|
*/
|
|
12
9
|
import os from 'os';
|
|
13
10
|
import path from 'path';
|
|
11
|
+
import fs from 'fs';
|
|
12
|
+
import dotenv from 'dotenv';
|
|
13
|
+
import { fileURLToPath } from 'url';
|
|
14
14
|
// Production URLs (baked in for security)
|
|
15
15
|
const PROD_SSO_URL = 'https://auth.oaysus.com';
|
|
16
16
|
const PROD_ADMIN_URL = 'https://admin.oaysus.com';
|
|
17
17
|
const PROD_R2_URL = 'https://pub-71eb20e9b97849f18a95eaa92feb648a.r2.dev';
|
|
18
|
+
/**
|
|
19
|
+
* Get current file's directory (works in both ESM and CJS)
|
|
20
|
+
*/
|
|
21
|
+
function getCurrentDir() {
|
|
22
|
+
// ESM: use import.meta.url
|
|
23
|
+
// @ts-ignore - import.meta exists in ESM
|
|
24
|
+
if (typeof import.meta !== 'undefined' && import.meta.url) {
|
|
25
|
+
// @ts-ignore
|
|
26
|
+
return path.dirname(fileURLToPath(import.meta.url));
|
|
27
|
+
}
|
|
28
|
+
// CJS fallback
|
|
29
|
+
if (typeof __dirname !== 'undefined') {
|
|
30
|
+
return __dirname;
|
|
31
|
+
}
|
|
32
|
+
return process.cwd();
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Find the CLI root directory (where package.json is)
|
|
36
|
+
*/
|
|
37
|
+
function findCliRoot() {
|
|
38
|
+
let dir = getCurrentDir();
|
|
39
|
+
// Walk up until we find package.json or hit root
|
|
40
|
+
for (let i = 0; i < 10; i++) {
|
|
41
|
+
const pkgPath = path.join(dir, 'package.json');
|
|
42
|
+
if (fs.existsSync(pkgPath)) {
|
|
43
|
+
try {
|
|
44
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));
|
|
45
|
+
if (pkg.name === '@oaysus/cli' || pkg.name === 'oaysus-cli') {
|
|
46
|
+
return dir;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
// Continue searching
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
const parent = path.dirname(dir);
|
|
54
|
+
if (parent === dir)
|
|
55
|
+
break;
|
|
56
|
+
dir = parent;
|
|
57
|
+
}
|
|
58
|
+
return process.cwd();
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Load .env.local if it exists
|
|
62
|
+
* Returns true if .env.local was found and loaded
|
|
63
|
+
* Skipped during test runs to ensure predictable test behavior
|
|
64
|
+
*/
|
|
65
|
+
function loadEnvLocal() {
|
|
66
|
+
// Skip loading .env.local during tests
|
|
67
|
+
if (process.env.NODE_ENV === 'test' || process.env.JEST_WORKER_ID !== undefined) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
const cliRoot = findCliRoot();
|
|
71
|
+
const envLocalPath = path.join(cliRoot, '.env.local');
|
|
72
|
+
if (fs.existsSync(envLocalPath)) {
|
|
73
|
+
dotenv.config({ path: envLocalPath });
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
// Load .env.local if present (this sets process.env values)
|
|
79
|
+
const _hasEnvLocal = loadEnvLocal();
|
|
18
80
|
/**
|
|
19
81
|
* Environment configuration
|
|
20
|
-
*
|
|
82
|
+
* Priority: .env.local > environment variables > production defaults
|
|
21
83
|
*/
|
|
22
84
|
export const config = {
|
|
23
85
|
// Authentication server URL
|
|
@@ -27,18 +89,20 @@ export const config = {
|
|
|
27
89
|
// R2 CDN URL for component hosting
|
|
28
90
|
R2_PUBLIC_URL: process.env.NEXT_PUBLIC_R2_PUBLIC_URL || PROD_R2_URL,
|
|
29
91
|
// Deployment environment: 'prod' | 'dev' | 'local'
|
|
30
|
-
API_STAGE: process.env.NEXT_PUBLIC_API_STAGE ||
|
|
92
|
+
API_STAGE: process.env.NEXT_PUBLIC_API_STAGE || 'prod',
|
|
31
93
|
// Developer namespace for local testing (contributors only)
|
|
32
94
|
DEVELOPER: process.env.DEVELOPER,
|
|
33
95
|
// Debug mode (console logging, off by default)
|
|
34
96
|
DEBUG: process.env.DEBUG === 'true',
|
|
35
|
-
// Credentials storage path
|
|
97
|
+
// Credentials storage path
|
|
36
98
|
CREDENTIALS_PATH: path.join(os.homedir(), '.oaysus', 'credentials.json'),
|
|
37
99
|
// Config directory
|
|
38
100
|
CONFIG_DIR: path.join(os.homedir(), '.oaysus'),
|
|
101
|
+
// Flag indicating if .env.local was loaded
|
|
102
|
+
IS_LOCAL_DEV: _hasEnvLocal,
|
|
39
103
|
};
|
|
40
104
|
// Export individual values for convenience
|
|
41
|
-
export const { SSO_BASE_URL, ADMIN_URL, R2_PUBLIC_URL, API_STAGE, DEVELOPER, DEBUG, CREDENTIALS_PATH, CONFIG_DIR, } = config;
|
|
105
|
+
export const { SSO_BASE_URL, ADMIN_URL, R2_PUBLIC_URL, API_STAGE, DEVELOPER, DEBUG, CREDENTIALS_PATH, CONFIG_DIR, IS_LOCAL_DEV, } = config;
|
|
42
106
|
export function getEnvironment() {
|
|
43
107
|
const stage = config.API_STAGE;
|
|
44
108
|
if (stage === 'local')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/lib/shared/config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/lib/shared/config.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,MAAM,MAAM,QAAQ,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAC;AAEpC,0CAA0C;AAC1C,MAAM,YAAY,GAAG,yBAAyB,CAAC;AAC/C,MAAM,cAAc,GAAG,0BAA0B,CAAC;AAClD,MAAM,WAAW,GAAG,qDAAqD,CAAC;AAE1E;;GAEG;AACH,SAAS,aAAa;IACpB,2BAA2B;IAC3B,yCAAyC;IACzC,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,WAAW,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;QAC1D,aAAa;QACb,OAAO,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IACtD,CAAC;IACD,eAAe;IACf,IAAI,OAAO,SAAS,KAAK,WAAW,EAAE,CAAC;QACrC,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,OAAO,CAAC,GAAG,EAAE,CAAC;AACvB,CAAC;AAED;;GAEG;AACH,SAAS,WAAW;IAClB,IAAI,GAAG,GAAG,aAAa,EAAE,CAAC;IAE1B,iDAAiD;IACjD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;QAC/C,IAAI,EAAE,CAAC,UAAU,CAAC,OAAO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