@myvillage/cli 1.0.0 → 1.0.3
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 +0 -27
- package/package.json +1 -1
- package/src/utils/config.js +9 -3
package/README.md
CHANGED
|
@@ -6,37 +6,10 @@ A command-line interface for MyVillage Project student developers to create, man
|
|
|
6
6
|
|
|
7
7
|
Requires Node.js 18 or higher.
|
|
8
8
|
|
|
9
|
-
### From npm (once published)
|
|
10
|
-
|
|
11
9
|
```bash
|
|
12
10
|
npm install -g @myvillage/cli
|
|
13
11
|
```
|
|
14
12
|
|
|
15
|
-
> **Note:** The package is not yet published to npm. Use the development install below.
|
|
16
|
-
|
|
17
|
-
### Development install (from source)
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
# Clone the repository
|
|
21
|
-
git clone https://github.com/MyVillage-Project-Technologies/MyVillageOS-CLI.git
|
|
22
|
-
cd MyVillageOS-CLI
|
|
23
|
-
|
|
24
|
-
# Install dependencies
|
|
25
|
-
npm install
|
|
26
|
-
|
|
27
|
-
# Link the CLI globally so "myvillage" command works anywhere
|
|
28
|
-
npm link
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
After linking, the `myvillage` command is available system-wide. To unlink later, run `npm unlink -g @myvillage/cli`.
|
|
32
|
-
|
|
33
|
-
You can also run commands directly without linking:
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
node bin/myvillage.js --help
|
|
37
|
-
node bin/myvillage.js create-game
|
|
38
|
-
```
|
|
39
|
-
|
|
40
13
|
## Quick Start
|
|
41
14
|
|
|
42
15
|
```bash
|
package/package.json
CHANGED
package/src/utils/config.js
CHANGED
|
@@ -8,7 +8,7 @@ const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
|
|
|
8
8
|
const DEFAULT_CONFIG = {
|
|
9
9
|
apiBaseUrl: 'https://portal.myvillageproject.ai/api/v1',
|
|
10
10
|
oauthBaseUrl: 'https://portal.myvillageproject.ai/api/oauth',
|
|
11
|
-
clientId: '
|
|
11
|
+
clientId: 'mvos_aG_c729fuQxvvqYHOnkgTQ',
|
|
12
12
|
callbackPort: 3737,
|
|
13
13
|
};
|
|
14
14
|
|
|
@@ -21,14 +21,20 @@ function ensureConfigDir() {
|
|
|
21
21
|
export function getConfig() {
|
|
22
22
|
ensureConfigDir();
|
|
23
23
|
|
|
24
|
+
// Only persist user-overridable settings (not clientId/oauthBaseUrl which are app constants)
|
|
24
25
|
if (!existsSync(CONFIG_FILE)) {
|
|
25
|
-
|
|
26
|
+
const { clientId, oauthBaseUrl, ...persistable } = DEFAULT_CONFIG;
|
|
27
|
+
writeFileSync(CONFIG_FILE, JSON.stringify(persistable, null, 2));
|
|
26
28
|
return { ...DEFAULT_CONFIG };
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
try {
|
|
30
32
|
const data = readFileSync(CONFIG_FILE, 'utf-8');
|
|
31
|
-
|
|
33
|
+
const fileConfig = JSON.parse(data);
|
|
34
|
+
// Remove stale clientId/oauthBaseUrl from file config — code defaults always win
|
|
35
|
+
delete fileConfig.clientId;
|
|
36
|
+
delete fileConfig.oauthBaseUrl;
|
|
37
|
+
return { ...DEFAULT_CONFIG, ...fileConfig };
|
|
32
38
|
} catch {
|
|
33
39
|
return { ...DEFAULT_CONFIG };
|
|
34
40
|
}
|