@babylonjsmarket/cli 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +290 -324
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -176,13 +176,8 @@ var AuthManager = class {
|
|
|
176
176
|
};
|
|
177
177
|
|
|
178
178
|
// src/commands/login-simple.ts
|
|
179
|
-
import { createServer } from "https";
|
|
180
179
|
import { createServer as createHttpServer } from "http";
|
|
181
180
|
import { URL } from "url";
|
|
182
|
-
import { execSync } from "child_process";
|
|
183
|
-
import fs from "fs";
|
|
184
|
-
import path from "path";
|
|
185
|
-
import os from "os";
|
|
186
181
|
var loginCommand = new Command("login").description("Authenticate with BabylonJS Market").option("--no-browser", "Don't open browser automatically").action(async (options) => {
|
|
187
182
|
const authManager = new AuthManager();
|
|
188
183
|
if (authManager.isAuthenticated()) {
|
|
@@ -195,39 +190,10 @@ var loginCommand = new Command("login").description("Authenticate with BabylonJS
|
|
|
195
190
|
try {
|
|
196
191
|
const port = 8765;
|
|
197
192
|
let token = null;
|
|
198
|
-
const
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
fs.mkdirSync(certDir, { recursive: true });
|
|
203
|
-
}
|
|
204
|
-
if (!fs.existsSync(keyPath) || !fs.existsSync(certPath)) {
|
|
205
|
-
console.log(chalk.gray("Generating self-signed certificate for HTTPS..."));
|
|
206
|
-
try {
|
|
207
|
-
execSync(
|
|
208
|
-
`openssl req -x509 -newkey rsa:2048 -nodes -sha256 -days 365 -keyout "${keyPath}" -out "${certPath}" -subj "/C=US/ST=State/L=City/O=BJS-CLI/CN=localhost"`,
|
|
209
|
-
{ stdio: "pipe" }
|
|
210
|
-
);
|
|
211
|
-
} catch (error) {
|
|
212
|
-
console.log(chalk.yellow("Could not generate HTTPS certificate, falling back to HTTP"));
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
let server;
|
|
216
|
-
let protocol = "https";
|
|
217
|
-
if (fs.existsSync(keyPath) && fs.existsSync(certPath)) {
|
|
218
|
-
const serverOptions = {
|
|
219
|
-
key: fs.readFileSync(keyPath),
|
|
220
|
-
cert: fs.readFileSync(certPath)
|
|
221
|
-
};
|
|
222
|
-
server = createServer(serverOptions, (req, res) => {
|
|
223
|
-
handleRequest(req, res);
|
|
224
|
-
});
|
|
225
|
-
} else {
|
|
226
|
-
protocol = "http";
|
|
227
|
-
server = createHttpServer((req, res) => {
|
|
228
|
-
handleRequest(req, res);
|
|
229
|
-
});
|
|
230
|
-
}
|
|
193
|
+
const protocol = "http";
|
|
194
|
+
const server = createHttpServer((req, res) => {
|
|
195
|
+
handleRequest(req, res);
|
|
196
|
+
});
|
|
231
197
|
const handleRequest = (req, res) => {
|
|
232
198
|
const url = new URL(req.url, `${protocol}://localhost:${port}`);
|
|
233
199
|
token = url.searchParams.get("token");
|
|
@@ -463,7 +429,7 @@ import ora2 from "ora";
|
|
|
463
429
|
import { createWriteStream, existsSync as existsSync2, mkdirSync as mkdirSync2 } from "fs";
|
|
464
430
|
import { pipeline } from "stream/promises";
|
|
465
431
|
import fetch3 from "node-fetch";
|
|
466
|
-
import
|
|
432
|
+
import path from "path";
|
|
467
433
|
var downloadCommand = new Command4("download").description("Download assets from BabylonJS Market").argument("<asset-key>", "Asset key to download").option("-o, --output <path>", "Output directory (default: current directory)").action(async (assetKey, options) => {
|
|
468
434
|
const authManager = new AuthManager();
|
|
469
435
|
const theme = applyTheme();
|
|
@@ -511,7 +477,7 @@ var downloadCommand = new Command4("download").description("Download assets from
|
|
|
511
477
|
if (!existsSync2(outputDir)) {
|
|
512
478
|
mkdirSync2(outputDir, { recursive: true });
|
|
513
479
|
}
|
|
514
|
-
const outputPath =
|
|
480
|
+
const outputPath = path.join(outputDir, fileName);
|
|
515
481
|
const contentLength = fileResponse.headers.get("content-length");
|
|
516
482
|
const total = contentLength ? parseInt(contentLength, 10) : 0;
|
|
517
483
|
let loaded = 0;
|
|
@@ -1721,7 +1687,7 @@ var MarkdownTerminalRenderer = class {
|
|
|
1721
1687
|
|
|
1722
1688
|
// src/utils/course-detail-viewer.ts
|
|
1723
1689
|
import { EventEmitter as EventEmitter2 } from "events";
|
|
1724
|
-
import { execSync
|
|
1690
|
+
import { execSync } from "child_process";
|
|
1725
1691
|
import open2 from "open";
|
|
1726
1692
|
|
|
1727
1693
|
// src/utils/course-detail/layout.ts
|
|
@@ -2906,13 +2872,13 @@ var CourseDetailViewer = class extends EventEmitter2 {
|
|
|
2906
2872
|
command = "clip";
|
|
2907
2873
|
} else {
|
|
2908
2874
|
try {
|
|
2909
|
-
|
|
2875
|
+
execSync("which xclip", { stdio: "ignore" });
|
|
2910
2876
|
command = "xclip -selection clipboard";
|
|
2911
2877
|
} catch {
|
|
2912
2878
|
command = "xsel --clipboard --input";
|
|
2913
2879
|
}
|
|
2914
2880
|
}
|
|
2915
|
-
|
|
2881
|
+
execSync(command, { input: block.code });
|
|
2916
2882
|
const nowMs = Date.now();
|
|
2917
2883
|
this.vs = {
|
|
2918
2884
|
...this.vs,
|
|
@@ -3028,14 +2994,14 @@ var CourseDetailViewer = class extends EventEmitter2 {
|
|
|
3028
2994
|
};
|
|
3029
2995
|
|
|
3030
2996
|
// src/commands/bbs.ts
|
|
3031
|
-
import
|
|
3032
|
-
import
|
|
2997
|
+
import fs4 from "fs";
|
|
2998
|
+
import path4 from "path";
|
|
3033
2999
|
import { homedir as homedir2 } from "os";
|
|
3034
3000
|
import process2 from "process";
|
|
3035
3001
|
|
|
3036
3002
|
// src/utils/asset-downloader.ts
|
|
3037
3003
|
import fetch5 from "node-fetch";
|
|
3038
|
-
import
|
|
3004
|
+
import fs from "fs";
|
|
3039
3005
|
import { pipeline as pipeline2 } from "stream/promises";
|
|
3040
3006
|
var AssetDownloader = class {
|
|
3041
3007
|
authManager;
|
|
@@ -3088,7 +3054,7 @@ var AssetDownloader = class {
|
|
|
3088
3054
|
const contentLength = fileResponse.headers.get("content-length");
|
|
3089
3055
|
const total = parseInt(contentLength || "0", 10);
|
|
3090
3056
|
let loaded = 0;
|
|
3091
|
-
const writer =
|
|
3057
|
+
const writer = fs.createWriteStream(outputPath);
|
|
3092
3058
|
fileResponse.body.on("data", (chunk) => {
|
|
3093
3059
|
loaded += chunk.length;
|
|
3094
3060
|
writer.write(chunk);
|
|
@@ -3102,7 +3068,7 @@ var AssetDownloader = class {
|
|
|
3102
3068
|
});
|
|
3103
3069
|
await pipeline2(fileResponse.body, writer);
|
|
3104
3070
|
} else {
|
|
3105
|
-
const fileStream =
|
|
3071
|
+
const fileStream = fs.createWriteStream(outputPath);
|
|
3106
3072
|
await pipeline2(fileResponse.body, fileStream);
|
|
3107
3073
|
}
|
|
3108
3074
|
return true;
|
|
@@ -3130,15 +3096,15 @@ var AssetDownloader = class {
|
|
|
3130
3096
|
};
|
|
3131
3097
|
|
|
3132
3098
|
// src/utils/project-scanner.ts
|
|
3133
|
-
import
|
|
3134
|
-
import
|
|
3099
|
+
import fs2 from "fs";
|
|
3100
|
+
import path2 from "path";
|
|
3135
3101
|
async function scanForProjects(baseDir, maxDepth = 2) {
|
|
3136
3102
|
const projects = [];
|
|
3137
3103
|
let projectId = 1;
|
|
3138
3104
|
async function scanDirectory(dir, depth) {
|
|
3139
3105
|
if (depth > maxDepth) return;
|
|
3140
3106
|
try {
|
|
3141
|
-
const entries = await
|
|
3107
|
+
const entries = await fs2.promises.readdir(dir, { withFileTypes: true });
|
|
3142
3108
|
for (const entry of entries) {
|
|
3143
3109
|
if (entry.name === "node_modules" || entry.name === ".git" || entry.name === "dist" || entry.name === ".next") {
|
|
3144
3110
|
continue;
|
|
@@ -3146,7 +3112,7 @@ async function scanForProjects(baseDir, maxDepth = 2) {
|
|
|
3146
3112
|
if (entry.isSymbolicLink()) {
|
|
3147
3113
|
continue;
|
|
3148
3114
|
}
|
|
3149
|
-
const fullPath =
|
|
3115
|
+
const fullPath = path2.join(dir, entry.name);
|
|
3150
3116
|
if (entry.isDirectory()) {
|
|
3151
3117
|
const isProject = await isProjectDirectory(fullPath);
|
|
3152
3118
|
if (isProject) {
|
|
@@ -3165,10 +3131,10 @@ async function scanForProjects(baseDir, maxDepth = 2) {
|
|
|
3165
3131
|
}
|
|
3166
3132
|
async function isProjectDirectory(dir) {
|
|
3167
3133
|
try {
|
|
3168
|
-
const entries = await
|
|
3134
|
+
const entries = await fs2.promises.readdir(dir);
|
|
3169
3135
|
if (entries.includes("package.json")) {
|
|
3170
|
-
const packageJsonPath =
|
|
3171
|
-
const packageJson = JSON.parse(await
|
|
3136
|
+
const packageJsonPath = path2.join(dir, "package.json");
|
|
3137
|
+
const packageJson = JSON.parse(await fs2.promises.readFile(packageJsonPath, "utf-8"));
|
|
3172
3138
|
const allDeps = {
|
|
3173
3139
|
...packageJson.dependencies || {},
|
|
3174
3140
|
...packageJson.devDependencies || {}
|
|
@@ -3191,10 +3157,10 @@ async function isProjectDirectory(dir) {
|
|
|
3191
3157
|
async function detectGenre(dir) {
|
|
3192
3158
|
const configFiles = ["arcade.json", ".arcade", ".arcade.json"];
|
|
3193
3159
|
for (const configFile of configFiles) {
|
|
3194
|
-
const configPath =
|
|
3195
|
-
if (
|
|
3160
|
+
const configPath = path2.join(dir, configFile);
|
|
3161
|
+
if (fs2.existsSync(configPath)) {
|
|
3196
3162
|
try {
|
|
3197
|
-
const config = JSON.parse(await
|
|
3163
|
+
const config = JSON.parse(await fs2.promises.readFile(configPath, "utf-8"));
|
|
3198
3164
|
if (config.genre || config.template) {
|
|
3199
3165
|
return config.genre || config.template;
|
|
3200
3166
|
}
|
|
@@ -3202,20 +3168,20 @@ async function detectGenre(dir) {
|
|
|
3202
3168
|
}
|
|
3203
3169
|
}
|
|
3204
3170
|
}
|
|
3205
|
-
const packageJsonPath =
|
|
3206
|
-
if (
|
|
3171
|
+
const packageJsonPath = path2.join(dir, "package.json");
|
|
3172
|
+
if (fs2.existsSync(packageJsonPath)) {
|
|
3207
3173
|
try {
|
|
3208
|
-
const pkg = JSON.parse(await
|
|
3174
|
+
const pkg = JSON.parse(await fs2.promises.readFile(packageJsonPath, "utf-8"));
|
|
3209
3175
|
if (pkg.arcade?.genre) return pkg.arcade.genre;
|
|
3210
3176
|
if (pkg.arcade?.template) return pkg.arcade.template;
|
|
3211
3177
|
if (pkg.gameType) return pkg.gameType;
|
|
3212
3178
|
} catch {
|
|
3213
3179
|
}
|
|
3214
3180
|
}
|
|
3215
|
-
const componentsDir =
|
|
3216
|
-
if (
|
|
3181
|
+
const componentsDir = path2.join(dir, "src", "Components");
|
|
3182
|
+
if (fs2.existsSync(componentsDir)) {
|
|
3217
3183
|
try {
|
|
3218
|
-
const components = await
|
|
3184
|
+
const components = await fs2.promises.readdir(componentsDir);
|
|
3219
3185
|
const componentNames = components.map((c) => c.toLowerCase());
|
|
3220
3186
|
if (componentNames.some((c) => c.includes("fps") || c.includes("firstperson"))) {
|
|
3221
3187
|
return "FPS";
|
|
@@ -3235,10 +3201,10 @@ async function detectGenre(dir) {
|
|
|
3235
3201
|
} catch {
|
|
3236
3202
|
}
|
|
3237
3203
|
}
|
|
3238
|
-
const dataDir =
|
|
3239
|
-
if (
|
|
3204
|
+
const dataDir = path2.join(dir, "data");
|
|
3205
|
+
if (fs2.existsSync(dataDir)) {
|
|
3240
3206
|
try {
|
|
3241
|
-
const dataDirs = await
|
|
3207
|
+
const dataDirs = await fs2.promises.readdir(dataDir);
|
|
3242
3208
|
for (const d of dataDirs) {
|
|
3243
3209
|
const lowerName = d.toLowerCase();
|
|
3244
3210
|
if (lowerName === "thirdperson") return "ThirdPerson";
|
|
@@ -3253,12 +3219,12 @@ async function detectGenre(dir) {
|
|
|
3253
3219
|
}
|
|
3254
3220
|
async function scanComponents(dir) {
|
|
3255
3221
|
const components = [];
|
|
3256
|
-
const componentsDir =
|
|
3257
|
-
if (!
|
|
3222
|
+
const componentsDir = path2.join(dir, "src", "Components");
|
|
3223
|
+
if (!fs2.existsSync(componentsDir)) {
|
|
3258
3224
|
return components;
|
|
3259
3225
|
}
|
|
3260
3226
|
try {
|
|
3261
|
-
const files = await
|
|
3227
|
+
const files = await fs2.promises.readdir(componentsDir);
|
|
3262
3228
|
for (const file of files) {
|
|
3263
3229
|
if (file.endsWith(".ts") || file.endsWith(".js")) {
|
|
3264
3230
|
const componentName = file.replace(/\.(ts|js)$/, "");
|
|
@@ -3272,14 +3238,14 @@ async function scanComponents(dir) {
|
|
|
3272
3238
|
return components.sort();
|
|
3273
3239
|
}
|
|
3274
3240
|
async function analyzeProject(dir, id) {
|
|
3275
|
-
const name =
|
|
3241
|
+
const name = path2.basename(dir);
|
|
3276
3242
|
let hasPackageJson = false;
|
|
3277
3243
|
let engine = "Unknown";
|
|
3278
3244
|
try {
|
|
3279
|
-
const packageJsonPath =
|
|
3280
|
-
if (
|
|
3245
|
+
const packageJsonPath = path2.join(dir, "package.json");
|
|
3246
|
+
if (fs2.existsSync(packageJsonPath)) {
|
|
3281
3247
|
hasPackageJson = true;
|
|
3282
|
-
const packageJson = JSON.parse(await
|
|
3248
|
+
const packageJson = JSON.parse(await fs2.promises.readFile(packageJsonPath, "utf-8"));
|
|
3283
3249
|
const allDeps = {
|
|
3284
3250
|
...packageJson.dependencies || {},
|
|
3285
3251
|
...packageJson.devDependencies || {}
|
|
@@ -3307,15 +3273,15 @@ async function analyzeProject(dir, id) {
|
|
|
3307
3273
|
}
|
|
3308
3274
|
|
|
3309
3275
|
// src/utils/component-catalog.ts
|
|
3310
|
-
import
|
|
3311
|
-
import
|
|
3276
|
+
import fs3 from "fs";
|
|
3277
|
+
import path3 from "path";
|
|
3312
3278
|
function getLibraryPath() {
|
|
3313
3279
|
const auth = new AuthManager();
|
|
3314
3280
|
return auth.getLibraryPath();
|
|
3315
3281
|
}
|
|
3316
3282
|
function isLibraryInitialized() {
|
|
3317
3283
|
const libraryPath = getLibraryPath();
|
|
3318
|
-
return
|
|
3284
|
+
return fs3.existsSync(path3.join(libraryPath, "Components"));
|
|
3319
3285
|
}
|
|
3320
3286
|
async function initializeLibrary(libraryPath) {
|
|
3321
3287
|
const targetPath = libraryPath || getLibraryPath();
|
|
@@ -3329,13 +3295,13 @@ async function initializeLibrary(libraryPath) {
|
|
|
3329
3295
|
];
|
|
3330
3296
|
try {
|
|
3331
3297
|
for (const dir of dirs) {
|
|
3332
|
-
const fullPath =
|
|
3333
|
-
if (!
|
|
3334
|
-
|
|
3298
|
+
const fullPath = path3.join(targetPath, dir);
|
|
3299
|
+
if (!fs3.existsSync(fullPath)) {
|
|
3300
|
+
fs3.mkdirSync(fullPath, { recursive: true });
|
|
3335
3301
|
}
|
|
3336
3302
|
}
|
|
3337
|
-
const readmePath =
|
|
3338
|
-
if (!
|
|
3303
|
+
const readmePath = path3.join(targetPath, "README.md");
|
|
3304
|
+
if (!fs3.existsSync(readmePath)) {
|
|
3339
3305
|
const readme = `# BJS Library
|
|
3340
3306
|
|
|
3341
3307
|
Your personal library of BabylonJS components, systems, and game mode presets.
|
|
@@ -3362,7 +3328,7 @@ Your personal library of BabylonJS components, systems, and game mode presets.
|
|
|
3362
3328
|
|
|
3363
3329
|
Content from babylonjsmarket.com will be downloaded here automatically.
|
|
3364
3330
|
`;
|
|
3365
|
-
|
|
3331
|
+
fs3.writeFileSync(readmePath, readme);
|
|
3366
3332
|
}
|
|
3367
3333
|
return { success: true, message: `Library initialized at ${targetPath}` };
|
|
3368
3334
|
} catch (error) {
|
|
@@ -3371,12 +3337,12 @@ Content from babylonjsmarket.com will be downloaded here automatically.
|
|
|
3371
3337
|
}
|
|
3372
3338
|
function getGameModeSchema(modeName) {
|
|
3373
3339
|
const libraryPath = getLibraryPath();
|
|
3374
|
-
const schemaPath =
|
|
3375
|
-
if (!
|
|
3340
|
+
const schemaPath = path3.join(libraryPath, "GameModes", modeName, "gamemode.json");
|
|
3341
|
+
if (!fs3.existsSync(schemaPath)) {
|
|
3376
3342
|
return null;
|
|
3377
3343
|
}
|
|
3378
3344
|
try {
|
|
3379
|
-
const content =
|
|
3345
|
+
const content = fs3.readFileSync(schemaPath, "utf-8");
|
|
3380
3346
|
return JSON.parse(content);
|
|
3381
3347
|
} catch {
|
|
3382
3348
|
return null;
|
|
@@ -3443,45 +3409,45 @@ var COMPONENT_CATALOG = [
|
|
|
3443
3409
|
];
|
|
3444
3410
|
async function installComponent(componentName, targetProjectPath) {
|
|
3445
3411
|
const libraryPath = getLibraryPath();
|
|
3446
|
-
const componentDir =
|
|
3447
|
-
const componentFile =
|
|
3412
|
+
const componentDir = path3.join(libraryPath, "Components", componentName);
|
|
3413
|
+
const componentFile = path3.join(componentDir, `${componentName}.ts`);
|
|
3448
3414
|
const files = [];
|
|
3449
|
-
if (!
|
|
3450
|
-
const legacyPath =
|
|
3451
|
-
if (
|
|
3452
|
-
const targetComponentDir2 =
|
|
3453
|
-
if (!
|
|
3454
|
-
|
|
3455
|
-
}
|
|
3456
|
-
const targetComponentPath2 =
|
|
3457
|
-
if (
|
|
3415
|
+
if (!fs3.existsSync(componentFile)) {
|
|
3416
|
+
const legacyPath = path3.join(libraryPath, "Components", `${componentName}.ts`);
|
|
3417
|
+
if (fs3.existsSync(legacyPath)) {
|
|
3418
|
+
const targetComponentDir2 = path3.join(targetProjectPath, "src", "Components");
|
|
3419
|
+
if (!fs3.existsSync(targetComponentDir2)) {
|
|
3420
|
+
fs3.mkdirSync(targetComponentDir2, { recursive: true });
|
|
3421
|
+
}
|
|
3422
|
+
const targetComponentPath2 = path3.join(targetComponentDir2, `${componentName}.ts`);
|
|
3423
|
+
if (fs3.existsSync(targetComponentPath2)) {
|
|
3458
3424
|
return { success: false, message: `${componentName}.ts already exists`, files };
|
|
3459
3425
|
}
|
|
3460
|
-
|
|
3426
|
+
fs3.copyFileSync(legacyPath, targetComponentPath2);
|
|
3461
3427
|
files.push(`src/Components/${componentName}.ts`);
|
|
3462
3428
|
return { success: true, message: `Installed ${componentName} (${files.length} files)`, files };
|
|
3463
3429
|
}
|
|
3464
3430
|
return { success: false, message: `Component ${componentName} not found in Library`, files };
|
|
3465
3431
|
}
|
|
3466
|
-
const targetComponentDir =
|
|
3467
|
-
if (!
|
|
3468
|
-
|
|
3432
|
+
const targetComponentDir = path3.join(targetProjectPath, "src", "Components");
|
|
3433
|
+
if (!fs3.existsSync(targetComponentDir)) {
|
|
3434
|
+
fs3.mkdirSync(targetComponentDir, { recursive: true });
|
|
3469
3435
|
}
|
|
3470
|
-
const targetComponentPath =
|
|
3471
|
-
if (
|
|
3436
|
+
const targetComponentPath = path3.join(targetComponentDir, `${componentName}.ts`);
|
|
3437
|
+
if (fs3.existsSync(targetComponentPath)) {
|
|
3472
3438
|
return { success: false, message: `${componentName}.ts already exists`, files };
|
|
3473
3439
|
}
|
|
3474
|
-
|
|
3440
|
+
fs3.copyFileSync(componentFile, targetComponentPath);
|
|
3475
3441
|
files.push(`src/Components/${componentName}.ts`);
|
|
3476
|
-
const testPath =
|
|
3477
|
-
if (
|
|
3478
|
-
const targetTestDir =
|
|
3479
|
-
if (!
|
|
3480
|
-
|
|
3481
|
-
}
|
|
3482
|
-
const targetTestPath =
|
|
3483
|
-
if (!
|
|
3484
|
-
|
|
3442
|
+
const testPath = path3.join(componentDir, `${componentName}.test.ts`);
|
|
3443
|
+
if (fs3.existsSync(testPath)) {
|
|
3444
|
+
const targetTestDir = path3.join(targetProjectPath, "tests", "Components");
|
|
3445
|
+
if (!fs3.existsSync(targetTestDir)) {
|
|
3446
|
+
fs3.mkdirSync(targetTestDir, { recursive: true });
|
|
3447
|
+
}
|
|
3448
|
+
const targetTestPath = path3.join(targetTestDir, `${componentName}.test.ts`);
|
|
3449
|
+
if (!fs3.existsSync(targetTestPath)) {
|
|
3450
|
+
fs3.copyFileSync(testPath, targetTestPath);
|
|
3485
3451
|
files.push(`tests/Components/${componentName}.test.ts`);
|
|
3486
3452
|
}
|
|
3487
3453
|
}
|
|
@@ -3493,26 +3459,26 @@ async function installComponent(componentName, targetProjectPath) {
|
|
|
3493
3459
|
}
|
|
3494
3460
|
function getAvailableComponents(targetProjectPath) {
|
|
3495
3461
|
const libraryPath = getLibraryPath();
|
|
3496
|
-
const libraryComponentsDir =
|
|
3497
|
-
const targetComponentDir =
|
|
3462
|
+
const libraryComponentsDir = path3.join(libraryPath, "Components");
|
|
3463
|
+
const targetComponentDir = path3.join(targetProjectPath, "src", "Components");
|
|
3498
3464
|
const installedComponents = /* @__PURE__ */ new Set();
|
|
3499
3465
|
const availableComponents = [];
|
|
3500
|
-
if (
|
|
3501
|
-
const files =
|
|
3466
|
+
if (fs3.existsSync(targetComponentDir)) {
|
|
3467
|
+
const files = fs3.readdirSync(targetComponentDir);
|
|
3502
3468
|
for (const file of files) {
|
|
3503
3469
|
if (file.endsWith(".ts")) {
|
|
3504
3470
|
installedComponents.add(file.replace(".ts", ""));
|
|
3505
3471
|
}
|
|
3506
3472
|
}
|
|
3507
3473
|
}
|
|
3508
|
-
if (
|
|
3509
|
-
const entries =
|
|
3474
|
+
if (fs3.existsSync(libraryComponentsDir)) {
|
|
3475
|
+
const entries = fs3.readdirSync(libraryComponentsDir, { withFileTypes: true });
|
|
3510
3476
|
for (const entry of entries) {
|
|
3511
3477
|
let name;
|
|
3512
3478
|
if (entry.isDirectory()) {
|
|
3513
3479
|
name = entry.name;
|
|
3514
|
-
const mainFile =
|
|
3515
|
-
if (!
|
|
3480
|
+
const mainFile = path3.join(libraryComponentsDir, name, `${name}.ts`);
|
|
3481
|
+
if (!fs3.existsSync(mainFile)) {
|
|
3516
3482
|
continue;
|
|
3517
3483
|
}
|
|
3518
3484
|
} else if (entry.isFile() && entry.name.endsWith(".ts")) {
|
|
@@ -3535,13 +3501,13 @@ function getAvailableComponents(targetProjectPath) {
|
|
|
3535
3501
|
}
|
|
3536
3502
|
function getGameModeCatalog() {
|
|
3537
3503
|
const libraryPath = getLibraryPath();
|
|
3538
|
-
const gameModesDir =
|
|
3504
|
+
const gameModesDir = path3.join(libraryPath, "GameModes");
|
|
3539
3505
|
const modes = [];
|
|
3540
|
-
if (!
|
|
3506
|
+
if (!fs3.existsSync(gameModesDir)) {
|
|
3541
3507
|
return modes;
|
|
3542
3508
|
}
|
|
3543
3509
|
try {
|
|
3544
|
-
const dirs =
|
|
3510
|
+
const dirs = fs3.readdirSync(gameModesDir, { withFileTypes: true });
|
|
3545
3511
|
for (const dir of dirs) {
|
|
3546
3512
|
if (!dir.isDirectory()) continue;
|
|
3547
3513
|
const schema = getGameModeSchema(dir.name);
|
|
@@ -3554,13 +3520,13 @@ function getGameModeCatalog() {
|
|
|
3554
3520
|
hasShared: schema.includeShared || false
|
|
3555
3521
|
});
|
|
3556
3522
|
} else {
|
|
3557
|
-
const modePath =
|
|
3523
|
+
const modePath = path3.join(gameModesDir, dir.name);
|
|
3558
3524
|
modes.push({
|
|
3559
3525
|
name: dir.name,
|
|
3560
3526
|
description: `${dir.name} game mode`,
|
|
3561
|
-
hasScenes:
|
|
3562
|
-
hasScreens:
|
|
3563
|
-
hasShared:
|
|
3527
|
+
hasScenes: fs3.existsSync(path3.join(modePath, "Scenes")),
|
|
3528
|
+
hasScreens: fs3.existsSync(path3.join(modePath, "Screens")),
|
|
3529
|
+
hasShared: fs3.existsSync(path3.join(modePath, "Data"))
|
|
3564
3530
|
});
|
|
3565
3531
|
}
|
|
3566
3532
|
}
|
|
@@ -3569,12 +3535,12 @@ function getGameModeCatalog() {
|
|
|
3569
3535
|
return modes;
|
|
3570
3536
|
}
|
|
3571
3537
|
function getAvailableGameModes(targetProjectPath) {
|
|
3572
|
-
const targetDataDir =
|
|
3538
|
+
const targetDataDir = path3.join(targetProjectPath, "data");
|
|
3573
3539
|
const installedModes = /* @__PURE__ */ new Set();
|
|
3574
|
-
if (
|
|
3575
|
-
const dirs =
|
|
3540
|
+
if (fs3.existsSync(targetDataDir)) {
|
|
3541
|
+
const dirs = fs3.readdirSync(targetDataDir);
|
|
3576
3542
|
for (const dir of dirs) {
|
|
3577
|
-
const stat =
|
|
3543
|
+
const stat = fs3.statSync(path3.join(targetDataDir, dir));
|
|
3578
3544
|
if (stat.isDirectory()) {
|
|
3579
3545
|
installedModes.add(dir);
|
|
3580
3546
|
}
|
|
@@ -3583,12 +3549,12 @@ function getAvailableGameModes(targetProjectPath) {
|
|
|
3583
3549
|
return getGameModeCatalog().filter((m) => !installedModes.has(m.name));
|
|
3584
3550
|
}
|
|
3585
3551
|
function getInstalledGameModes(targetProjectPath) {
|
|
3586
|
-
const targetDataDir =
|
|
3552
|
+
const targetDataDir = path3.join(targetProjectPath, "data");
|
|
3587
3553
|
const modes = [];
|
|
3588
|
-
if (
|
|
3589
|
-
const dirs =
|
|
3554
|
+
if (fs3.existsSync(targetDataDir)) {
|
|
3555
|
+
const dirs = fs3.readdirSync(targetDataDir);
|
|
3590
3556
|
for (const dir of dirs) {
|
|
3591
|
-
const stat =
|
|
3557
|
+
const stat = fs3.statSync(path3.join(targetDataDir, dir));
|
|
3592
3558
|
if (stat.isDirectory() && dir !== "Shared") {
|
|
3593
3559
|
modes.push(dir);
|
|
3594
3560
|
}
|
|
@@ -3597,29 +3563,29 @@ function getInstalledGameModes(targetProjectPath) {
|
|
|
3597
3563
|
return modes;
|
|
3598
3564
|
}
|
|
3599
3565
|
function copyDir(src, dest, files, baseRelPath) {
|
|
3600
|
-
|
|
3601
|
-
const entries =
|
|
3566
|
+
fs3.mkdirSync(dest, { recursive: true });
|
|
3567
|
+
const entries = fs3.readdirSync(src, { withFileTypes: true });
|
|
3602
3568
|
for (const entry of entries) {
|
|
3603
|
-
const srcPath =
|
|
3604
|
-
const destPath =
|
|
3605
|
-
const relPath =
|
|
3569
|
+
const srcPath = path3.join(src, entry.name);
|
|
3570
|
+
const destPath = path3.join(dest, entry.name);
|
|
3571
|
+
const relPath = path3.join(baseRelPath, entry.name);
|
|
3606
3572
|
if (entry.isDirectory()) {
|
|
3607
3573
|
copyDir(srcPath, destPath, files, relPath);
|
|
3608
3574
|
} else if (entry.name !== "gamemode.json") {
|
|
3609
|
-
|
|
3575
|
+
fs3.copyFileSync(srcPath, destPath);
|
|
3610
3576
|
files.push(relPath);
|
|
3611
3577
|
}
|
|
3612
3578
|
}
|
|
3613
3579
|
}
|
|
3614
3580
|
async function installGameMode(modeName, targetProjectPath) {
|
|
3615
3581
|
const libraryPath = getLibraryPath();
|
|
3616
|
-
const gameModeDir =
|
|
3582
|
+
const gameModeDir = path3.join(libraryPath, "GameModes", modeName);
|
|
3617
3583
|
const files = [];
|
|
3618
|
-
if (!
|
|
3584
|
+
if (!fs3.existsSync(gameModeDir)) {
|
|
3619
3585
|
return { success: false, message: `Game mode ${modeName} not found in Library`, files };
|
|
3620
3586
|
}
|
|
3621
|
-
const targetDataDir =
|
|
3622
|
-
if (
|
|
3587
|
+
const targetDataDir = path3.join(targetProjectPath, "data", modeName);
|
|
3588
|
+
if (fs3.existsSync(targetDataDir)) {
|
|
3623
3589
|
return { success: false, message: `${modeName} already exists`, files };
|
|
3624
3590
|
}
|
|
3625
3591
|
const schema = getGameModeSchema(modeName);
|
|
@@ -3633,34 +3599,34 @@ async function installGameMode(modeName, targetProjectPath) {
|
|
|
3633
3599
|
}
|
|
3634
3600
|
if (schema.systems) {
|
|
3635
3601
|
for (const sysName of schema.systems) {
|
|
3636
|
-
const sysPath =
|
|
3637
|
-
if (
|
|
3638
|
-
const targetSysDir =
|
|
3639
|
-
if (!
|
|
3640
|
-
|
|
3602
|
+
const sysPath = path3.join(libraryPath, "Systems", `${sysName}.ts`);
|
|
3603
|
+
if (fs3.existsSync(sysPath)) {
|
|
3604
|
+
const targetSysDir = path3.join(targetProjectPath, "src", "Systems");
|
|
3605
|
+
if (!fs3.existsSync(targetSysDir)) {
|
|
3606
|
+
fs3.mkdirSync(targetSysDir, { recursive: true });
|
|
3641
3607
|
}
|
|
3642
|
-
const targetSysPath =
|
|
3643
|
-
if (!
|
|
3644
|
-
|
|
3608
|
+
const targetSysPath = path3.join(targetSysDir, `${sysName}.ts`);
|
|
3609
|
+
if (!fs3.existsSync(targetSysPath)) {
|
|
3610
|
+
fs3.copyFileSync(sysPath, targetSysPath);
|
|
3645
3611
|
files.push(`src/Systems/${sysName}.ts`);
|
|
3646
3612
|
}
|
|
3647
3613
|
}
|
|
3648
3614
|
}
|
|
3649
3615
|
}
|
|
3650
|
-
|
|
3651
|
-
const modeDataDir =
|
|
3652
|
-
if (
|
|
3653
|
-
const targetSharedDir =
|
|
3616
|
+
fs3.mkdirSync(targetDataDir, { recursive: true });
|
|
3617
|
+
const modeDataDir = path3.join(gameModeDir, "Data");
|
|
3618
|
+
if (fs3.existsSync(modeDataDir)) {
|
|
3619
|
+
const targetSharedDir = path3.join(targetDataDir, "Shared");
|
|
3654
3620
|
copyDir(modeDataDir, targetSharedDir, files, `data/${modeName}/Shared`);
|
|
3655
3621
|
}
|
|
3656
|
-
const modeScenesDir =
|
|
3657
|
-
if (
|
|
3658
|
-
const targetScenesDir =
|
|
3622
|
+
const modeScenesDir = path3.join(gameModeDir, "Scenes");
|
|
3623
|
+
if (fs3.existsSync(modeScenesDir)) {
|
|
3624
|
+
const targetScenesDir = path3.join(targetDataDir, "Scenes");
|
|
3659
3625
|
copyDir(modeScenesDir, targetScenesDir, files, `data/${modeName}/Scenes`);
|
|
3660
3626
|
}
|
|
3661
|
-
const modeScreensDir =
|
|
3662
|
-
if (
|
|
3663
|
-
const targetScreensDir =
|
|
3627
|
+
const modeScreensDir = path3.join(gameModeDir, "Screens");
|
|
3628
|
+
if (fs3.existsSync(modeScreensDir)) {
|
|
3629
|
+
const targetScreensDir = path3.join(targetDataDir, "Screens");
|
|
3664
3630
|
copyDir(modeScreensDir, targetScreensDir, files, `data/${modeName}/Screens`);
|
|
3665
3631
|
}
|
|
3666
3632
|
} else {
|
|
@@ -3677,18 +3643,18 @@ async function installGameMode(modeName, targetProjectPath) {
|
|
|
3677
3643
|
}
|
|
3678
3644
|
function getProjectScenes(targetProjectPath) {
|
|
3679
3645
|
const scenes = [];
|
|
3680
|
-
const dataDir =
|
|
3681
|
-
if (!
|
|
3682
|
-
const modes =
|
|
3646
|
+
const dataDir = path3.join(targetProjectPath, "data");
|
|
3647
|
+
if (!fs3.existsSync(dataDir)) return scenes;
|
|
3648
|
+
const modes = fs3.readdirSync(dataDir);
|
|
3683
3649
|
for (const mode of modes) {
|
|
3684
|
-
const scenesDir =
|
|
3685
|
-
if (
|
|
3686
|
-
const sceneFiles =
|
|
3650
|
+
const scenesDir = path3.join(dataDir, mode, "Scenes");
|
|
3651
|
+
if (fs3.existsSync(scenesDir)) {
|
|
3652
|
+
const sceneFiles = fs3.readdirSync(scenesDir);
|
|
3687
3653
|
for (const file of sceneFiles) {
|
|
3688
3654
|
if (file.endsWith(".ts")) {
|
|
3689
3655
|
scenes.push({
|
|
3690
3656
|
name: file.replace(".ts", ""),
|
|
3691
|
-
path:
|
|
3657
|
+
path: path3.join(scenesDir, file),
|
|
3692
3658
|
gameMode: mode
|
|
3693
3659
|
});
|
|
3694
3660
|
}
|
|
@@ -3698,12 +3664,12 @@ function getProjectScenes(targetProjectPath) {
|
|
|
3698
3664
|
return scenes;
|
|
3699
3665
|
}
|
|
3700
3666
|
async function createScene(targetProjectPath, gameMode, sceneName) {
|
|
3701
|
-
const scenesDir =
|
|
3702
|
-
if (!
|
|
3703
|
-
|
|
3667
|
+
const scenesDir = path3.join(targetProjectPath, "data", gameMode, "Scenes");
|
|
3668
|
+
if (!fs3.existsSync(scenesDir)) {
|
|
3669
|
+
fs3.mkdirSync(scenesDir, { recursive: true });
|
|
3704
3670
|
}
|
|
3705
|
-
const scenePath =
|
|
3706
|
-
if (
|
|
3671
|
+
const scenePath = path3.join(scenesDir, `${sceneName}.ts`);
|
|
3672
|
+
if (fs3.existsSync(scenePath)) {
|
|
3707
3673
|
return { success: false, message: `Scene ${sceneName} already exists`, path: "" };
|
|
3708
3674
|
}
|
|
3709
3675
|
const template = `import Basics from "../../Shared/Basics";
|
|
@@ -3733,7 +3699,7 @@ export default {
|
|
|
3733
3699
|
};
|
|
3734
3700
|
`;
|
|
3735
3701
|
try {
|
|
3736
|
-
|
|
3702
|
+
fs3.writeFileSync(scenePath, template);
|
|
3737
3703
|
return {
|
|
3738
3704
|
success: true,
|
|
3739
3705
|
message: `Created scene ${sceneName}`,
|
|
@@ -3754,46 +3720,46 @@ async function migrateFromArcadeRef() {
|
|
|
3754
3720
|
}
|
|
3755
3721
|
}
|
|
3756
3722
|
try {
|
|
3757
|
-
const srcComponents =
|
|
3758
|
-
if (
|
|
3759
|
-
const targetComponents =
|
|
3760
|
-
const componentFiles2 =
|
|
3723
|
+
const srcComponents = path3.join(ARCADE_REF_PATH, "src", "Components");
|
|
3724
|
+
if (fs3.existsSync(srcComponents)) {
|
|
3725
|
+
const targetComponents = path3.join(libraryPath, "Components");
|
|
3726
|
+
const componentFiles2 = fs3.readdirSync(srcComponents);
|
|
3761
3727
|
for (const file of componentFiles2) {
|
|
3762
3728
|
if (file.endsWith(".ts")) {
|
|
3763
|
-
const srcPath =
|
|
3764
|
-
const destPath =
|
|
3765
|
-
if (!
|
|
3766
|
-
|
|
3729
|
+
const srcPath = path3.join(srcComponents, file);
|
|
3730
|
+
const destPath = path3.join(targetComponents, file);
|
|
3731
|
+
if (!fs3.existsSync(destPath)) {
|
|
3732
|
+
fs3.copyFileSync(srcPath, destPath);
|
|
3767
3733
|
files.push(`Components/${file}`);
|
|
3768
3734
|
}
|
|
3769
3735
|
}
|
|
3770
3736
|
}
|
|
3771
3737
|
}
|
|
3772
|
-
const srcTests =
|
|
3773
|
-
if (
|
|
3774
|
-
const targetTests =
|
|
3775
|
-
const testFiles =
|
|
3738
|
+
const srcTests = path3.join(ARCADE_REF_PATH, "tests", "Components");
|
|
3739
|
+
if (fs3.existsSync(srcTests)) {
|
|
3740
|
+
const targetTests = path3.join(libraryPath, "Tests");
|
|
3741
|
+
const testFiles = fs3.readdirSync(srcTests);
|
|
3776
3742
|
for (const file of testFiles) {
|
|
3777
3743
|
if (file.endsWith(".test.ts")) {
|
|
3778
|
-
const srcPath =
|
|
3779
|
-
const destPath =
|
|
3780
|
-
if (!
|
|
3781
|
-
|
|
3744
|
+
const srcPath = path3.join(srcTests, file);
|
|
3745
|
+
const destPath = path3.join(targetTests, file);
|
|
3746
|
+
if (!fs3.existsSync(destPath)) {
|
|
3747
|
+
fs3.copyFileSync(srcPath, destPath);
|
|
3782
3748
|
files.push(`Tests/${file}`);
|
|
3783
3749
|
}
|
|
3784
3750
|
}
|
|
3785
3751
|
}
|
|
3786
3752
|
}
|
|
3787
|
-
const srcData =
|
|
3788
|
-
if (
|
|
3789
|
-
const targetData =
|
|
3790
|
-
const dataFiles =
|
|
3753
|
+
const srcData = path3.join(ARCADE_REF_PATH, "data", "Shared");
|
|
3754
|
+
if (fs3.existsSync(srcData)) {
|
|
3755
|
+
const targetData = path3.join(libraryPath, "Data");
|
|
3756
|
+
const dataFiles = fs3.readdirSync(srcData);
|
|
3791
3757
|
for (const file of dataFiles) {
|
|
3792
3758
|
if (file.endsWith(".ts")) {
|
|
3793
|
-
const srcPath =
|
|
3794
|
-
const destPath =
|
|
3795
|
-
if (!
|
|
3796
|
-
|
|
3759
|
+
const srcPath = path3.join(srcData, file);
|
|
3760
|
+
const destPath = path3.join(targetData, file);
|
|
3761
|
+
if (!fs3.existsSync(destPath)) {
|
|
3762
|
+
fs3.copyFileSync(srcPath, destPath);
|
|
3797
3763
|
files.push(`Data/${file}`);
|
|
3798
3764
|
}
|
|
3799
3765
|
}
|
|
@@ -3801,24 +3767,24 @@ async function migrateFromArcadeRef() {
|
|
|
3801
3767
|
}
|
|
3802
3768
|
const gameModes = ["ThirdPerson", "Arcade"];
|
|
3803
3769
|
for (const mode of gameModes) {
|
|
3804
|
-
const srcMode =
|
|
3805
|
-
if (
|
|
3806
|
-
const targetMode =
|
|
3807
|
-
if (!
|
|
3808
|
-
|
|
3770
|
+
const srcMode = path3.join(ARCADE_REF_PATH, "data", mode);
|
|
3771
|
+
if (fs3.existsSync(srcMode)) {
|
|
3772
|
+
const targetMode = path3.join(libraryPath, "GameModes", mode);
|
|
3773
|
+
if (!fs3.existsSync(targetMode)) {
|
|
3774
|
+
fs3.mkdirSync(targetMode, { recursive: true });
|
|
3809
3775
|
const subdirs = ["Scenes", "Screens", "Shared"];
|
|
3810
3776
|
for (const subdir of subdirs) {
|
|
3811
|
-
const srcSubdir =
|
|
3812
|
-
if (
|
|
3813
|
-
const targetSubdir = subdir === "Shared" ?
|
|
3814
|
-
|
|
3815
|
-
const subFiles =
|
|
3777
|
+
const srcSubdir = path3.join(srcMode, subdir);
|
|
3778
|
+
if (fs3.existsSync(srcSubdir)) {
|
|
3779
|
+
const targetSubdir = subdir === "Shared" ? path3.join(targetMode, "Data") : path3.join(targetMode, subdir);
|
|
3780
|
+
fs3.mkdirSync(targetSubdir, { recursive: true });
|
|
3781
|
+
const subFiles = fs3.readdirSync(srcSubdir);
|
|
3816
3782
|
for (const file of subFiles) {
|
|
3817
|
-
const srcPath =
|
|
3818
|
-
const destPath =
|
|
3819
|
-
const stat =
|
|
3783
|
+
const srcPath = path3.join(srcSubdir, file);
|
|
3784
|
+
const destPath = path3.join(targetSubdir, file);
|
|
3785
|
+
const stat = fs3.statSync(srcPath);
|
|
3820
3786
|
if (stat.isFile()) {
|
|
3821
|
-
|
|
3787
|
+
fs3.copyFileSync(srcPath, destPath);
|
|
3822
3788
|
files.push(`GameModes/${mode}/${subdir === "Shared" ? "Data" : subdir}/${file}`);
|
|
3823
3789
|
}
|
|
3824
3790
|
}
|
|
@@ -3830,11 +3796,11 @@ async function migrateFromArcadeRef() {
|
|
|
3830
3796
|
components: mode === "ThirdPerson" ? ["Movement", "FollowCamera", "PlayerInput", "Animation", "Physics", "KeyboardTiming"] : ["Movement", "SimpleCamera", "PlayerInput", "SimplePhysics"],
|
|
3831
3797
|
data: ["Light", "Basics"],
|
|
3832
3798
|
includeShared: true,
|
|
3833
|
-
scenes:
|
|
3834
|
-
screens:
|
|
3799
|
+
scenes: fs3.existsSync(path3.join(srcMode, "Scenes")) ? fs3.readdirSync(path3.join(srcMode, "Scenes")).filter((f) => f.endsWith(".ts")) : [],
|
|
3800
|
+
screens: fs3.existsSync(path3.join(srcMode, "Screens")) ? fs3.readdirSync(path3.join(srcMode, "Screens")).filter((f) => f.endsWith(".ts")) : []
|
|
3835
3801
|
};
|
|
3836
|
-
|
|
3837
|
-
|
|
3802
|
+
fs3.writeFileSync(
|
|
3803
|
+
path3.join(targetMode, "gamemode.json"),
|
|
3838
3804
|
JSON.stringify(schema, null, 2)
|
|
3839
3805
|
);
|
|
3840
3806
|
files.push(`GameModes/${mode}/gamemode.json`);
|
|
@@ -3984,12 +3950,12 @@ async function syncLibrary(onProgress) {
|
|
|
3984
3950
|
componentSuccess = false;
|
|
3985
3951
|
continue;
|
|
3986
3952
|
}
|
|
3987
|
-
const fullPath =
|
|
3988
|
-
const dir =
|
|
3989
|
-
if (!
|
|
3990
|
-
|
|
3953
|
+
const fullPath = path3.join(libraryPath, filePath);
|
|
3954
|
+
const dir = path3.dirname(fullPath);
|
|
3955
|
+
if (!fs3.existsSync(dir)) {
|
|
3956
|
+
fs3.mkdirSync(dir, { recursive: true });
|
|
3991
3957
|
}
|
|
3992
|
-
|
|
3958
|
+
fs3.writeFileSync(fullPath, result.content);
|
|
3993
3959
|
}
|
|
3994
3960
|
if (componentSuccess) {
|
|
3995
3961
|
auth.updateLibraryFile(component.path, component.version);
|
|
@@ -5262,7 +5228,7 @@ var bbsCommand = new Command5("bbs").description("BabylonJS Market BBS - Browse
|
|
|
5262
5228
|
fatalError(reason instanceof Error ? reason : new Error(String(reason)), "Unhandled Promise Rejection");
|
|
5263
5229
|
});
|
|
5264
5230
|
const authManager = new AuthManager();
|
|
5265
|
-
const downloadDirectory = options.saveTo ?
|
|
5231
|
+
const downloadDirectory = options.saveTo ? path4.resolve(options.saveTo) : process2.cwd();
|
|
5266
5232
|
const savedPrefs = authManager.getPreferences();
|
|
5267
5233
|
if (savedPrefs && savedPrefs.theme && THEMES.includes(savedPrefs.theme)) {
|
|
5268
5234
|
options.theme = savedPrefs.theme;
|
|
@@ -5409,7 +5375,7 @@ var bbsCommand = new Command5("bbs").description("BabylonJS Market BBS - Browse
|
|
|
5409
5375
|
}
|
|
5410
5376
|
const user = authManager.getUser();
|
|
5411
5377
|
try {
|
|
5412
|
-
|
|
5378
|
+
fs4.appendFileSync("/tmp/bbs-debug.log", `${(/* @__PURE__ */ new Date()).toISOString()} BBS starting - animations: ${options.animations}
|
|
5413
5379
|
`);
|
|
5414
5380
|
if (options.animations) {
|
|
5415
5381
|
await bbs.showLoadingAnimation("Dialing BabylonJS Market BBS...", 1500);
|
|
@@ -5420,12 +5386,12 @@ var bbsCommand = new Command5("bbs").description("BabylonJS Market BBS - Browse
|
|
|
5420
5386
|
backBuffer.draw({ dst: screenBuffer });
|
|
5421
5387
|
screenBuffer.draw({ delta: true });
|
|
5422
5388
|
}
|
|
5423
|
-
|
|
5389
|
+
fs4.appendFileSync("/tmp/bbs-debug.log", `${(/* @__PURE__ */ new Date()).toISOString()} Fetching courses from ${API_URL}
|
|
5424
5390
|
`);
|
|
5425
5391
|
let allCoursesResponse;
|
|
5426
5392
|
try {
|
|
5427
5393
|
allCoursesResponse = await authManager.makeAuthenticatedRequest(`${API_URL}/api/auth/courses/all`);
|
|
5428
|
-
|
|
5394
|
+
fs4.appendFileSync("/tmp/bbs-debug.log", `${(/* @__PURE__ */ new Date()).toISOString()} Courses fetched OK
|
|
5429
5395
|
`);
|
|
5430
5396
|
} catch (fetchError) {
|
|
5431
5397
|
throw new Error(`Network error: ${fetchError.message}`);
|
|
@@ -5448,7 +5414,7 @@ var bbsCommand = new Command5("bbs").description("BabylonJS Market BBS - Browse
|
|
|
5448
5414
|
}
|
|
5449
5415
|
let scannedProjects = [];
|
|
5450
5416
|
const configuredProjectsDir = authManager.getProjectsDirectory();
|
|
5451
|
-
if (configuredProjectsDir &&
|
|
5417
|
+
if (configuredProjectsDir && fs4.existsSync(configuredProjectsDir)) {
|
|
5452
5418
|
try {
|
|
5453
5419
|
const scanPromise = scanForProjects(configuredProjectsDir, 2);
|
|
5454
5420
|
const timeoutPromise = new Promise(
|
|
@@ -5490,7 +5456,7 @@ var bbsCommand = new Command5("bbs").description("BabylonJS Market BBS - Browse
|
|
|
5490
5456
|
term[color](msg);
|
|
5491
5457
|
};
|
|
5492
5458
|
const debugLog = (msg) => {
|
|
5493
|
-
|
|
5459
|
+
fs4.appendFileSync("/tmp/bbs-debug.log", `${(/* @__PURE__ */ new Date()).toISOString()} ${msg}
|
|
5494
5460
|
`);
|
|
5495
5461
|
};
|
|
5496
5462
|
const buildRenderContext = () => {
|
|
@@ -5619,10 +5585,10 @@ var bbsCommand = new Command5("bbs").description("BabylonJS Market BBS - Browse
|
|
|
5619
5585
|
assetKey = toy.assetKey || toy.name.toLowerCase().replace(/\s+/g, "-");
|
|
5620
5586
|
fileName = assetKey + ".glb";
|
|
5621
5587
|
}
|
|
5622
|
-
const outputPath =
|
|
5588
|
+
const outputPath = path4.join(downloadDirectory, fileName);
|
|
5623
5589
|
try {
|
|
5624
|
-
if (!
|
|
5625
|
-
|
|
5590
|
+
if (!fs4.existsSync(downloadDirectory)) {
|
|
5591
|
+
fs4.mkdirSync(downloadDirectory, { recursive: true });
|
|
5626
5592
|
}
|
|
5627
5593
|
showStatus(`Downloading ${name}...`, "yellow");
|
|
5628
5594
|
const success = await assetDownloader.downloadAsset(
|
|
@@ -5650,19 +5616,19 @@ var bbsCommand = new Command5("bbs").description("BabylonJS Market BBS - Browse
|
|
|
5650
5616
|
if (!input || input.trim() === "") {
|
|
5651
5617
|
return homedir2() + "/";
|
|
5652
5618
|
}
|
|
5653
|
-
const dir =
|
|
5654
|
-
const base =
|
|
5655
|
-
if (dir &&
|
|
5656
|
-
const entries =
|
|
5619
|
+
const dir = path4.dirname(input);
|
|
5620
|
+
const base = path4.basename(input);
|
|
5621
|
+
if (dir && fs4.existsSync(dir)) {
|
|
5622
|
+
const entries = fs4.readdirSync(dir);
|
|
5657
5623
|
const matches = entries.filter((e) => e.toLowerCase().startsWith(base.toLowerCase())).filter((e) => {
|
|
5658
5624
|
try {
|
|
5659
|
-
return
|
|
5625
|
+
return fs4.statSync(path4.join(dir, e)).isDirectory();
|
|
5660
5626
|
} catch {
|
|
5661
5627
|
return false;
|
|
5662
5628
|
}
|
|
5663
5629
|
});
|
|
5664
5630
|
if (matches.length === 1) {
|
|
5665
|
-
return
|
|
5631
|
+
return path4.join(dir, matches[0]) + "/";
|
|
5666
5632
|
} else if (matches.length > 1) {
|
|
5667
5633
|
const commonPrefix = matches.reduce((prefix, match) => {
|
|
5668
5634
|
let i = 0;
|
|
@@ -5672,7 +5638,7 @@ var bbsCommand = new Command5("bbs").description("BabylonJS Market BBS - Browse
|
|
|
5672
5638
|
return match.slice(0, i);
|
|
5673
5639
|
});
|
|
5674
5640
|
if (commonPrefix.length > base.length) {
|
|
5675
|
-
return
|
|
5641
|
+
return path4.join(dir, commonPrefix);
|
|
5676
5642
|
}
|
|
5677
5643
|
}
|
|
5678
5644
|
} else if (input.startsWith("~")) {
|
|
@@ -5686,8 +5652,8 @@ var bbsCommand = new Command5("bbs").description("BabylonJS Market BBS - Browse
|
|
|
5686
5652
|
switch (effect.type) {
|
|
5687
5653
|
case "CommitProjectsDir": {
|
|
5688
5654
|
if (state.projectsDirInput.trim()) {
|
|
5689
|
-
const resolvedPath =
|
|
5690
|
-
if (
|
|
5655
|
+
const resolvedPath = path4.resolve(state.projectsDirInput.trim());
|
|
5656
|
+
if (fs4.existsSync(resolvedPath)) {
|
|
5691
5657
|
authManager.setProjectsDirectory(resolvedPath);
|
|
5692
5658
|
dispatch({ type: "SetProjectsDirResult", success: "\u2713 Saved! Scanning..." });
|
|
5693
5659
|
await render();
|
|
@@ -5714,9 +5680,9 @@ var bbsCommand = new Command5("bbs").description("BabylonJS Market BBS - Browse
|
|
|
5714
5680
|
break;
|
|
5715
5681
|
case "CommitLibraryPath": {
|
|
5716
5682
|
if (state.libraryPathInput.trim()) {
|
|
5717
|
-
const resolvedPath =
|
|
5683
|
+
const resolvedPath = path4.resolve(state.libraryPathInput.trim());
|
|
5718
5684
|
authManager.setLibraryPath(resolvedPath);
|
|
5719
|
-
if (!
|
|
5685
|
+
if (!fs4.existsSync(path4.join(resolvedPath, "Components"))) {
|
|
5720
5686
|
const result = await initializeLibrary(resolvedPath);
|
|
5721
5687
|
state = { ...state, libraryPathSuccess: result.success ? "\u2713 Library initialized!" : result.message };
|
|
5722
5688
|
} else {
|
|
@@ -5983,7 +5949,7 @@ var bbsCommand = new Command5("bbs").description("BabylonJS Market BBS - Browse
|
|
|
5983
5949
|
const project = state.projects[state.projectsSelectedIndex];
|
|
5984
5950
|
if (project) {
|
|
5985
5951
|
const editor = process2.env.EDITOR || "code";
|
|
5986
|
-
const editorName =
|
|
5952
|
+
const editorName = path4.basename(editor);
|
|
5987
5953
|
showStatus(`Opening ${project.name} in ${editorName}...`, "yellow");
|
|
5988
5954
|
const { spawn } = await import("child_process");
|
|
5989
5955
|
const editorProcess = spawn(editor, [project.path], { detached: true, stdio: "ignore" });
|
|
@@ -6239,8 +6205,8 @@ function getVersion() {
|
|
|
6239
6205
|
}
|
|
6240
6206
|
|
|
6241
6207
|
// src/lib/inject/engine.ts
|
|
6242
|
-
import
|
|
6243
|
-
import
|
|
6208
|
+
import fs6 from "fs";
|
|
6209
|
+
import path6 from "path";
|
|
6244
6210
|
import mri from "mri";
|
|
6245
6211
|
import colors2 from "picocolors";
|
|
6246
6212
|
|
|
@@ -6297,28 +6263,28 @@ function detectLayer(filePath, source, subjectLayer) {
|
|
|
6297
6263
|
}
|
|
6298
6264
|
|
|
6299
6265
|
// src/lib/inject/monorepo-root.ts
|
|
6300
|
-
import
|
|
6301
|
-
import
|
|
6266
|
+
import fs5 from "fs";
|
|
6267
|
+
import path5 from "path";
|
|
6302
6268
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
6303
6269
|
function findMonorepoRoot() {
|
|
6304
|
-
const here =
|
|
6270
|
+
const here = path5.dirname(fileURLToPath2(import.meta.url));
|
|
6305
6271
|
let dir = here;
|
|
6306
6272
|
while (true) {
|
|
6307
|
-
const pkgPath =
|
|
6308
|
-
if (
|
|
6273
|
+
const pkgPath = path5.join(dir, "package.json");
|
|
6274
|
+
if (fs5.existsSync(pkgPath)) {
|
|
6309
6275
|
try {
|
|
6310
|
-
const pkg = JSON.parse(
|
|
6276
|
+
const pkg = JSON.parse(fs5.readFileSync(pkgPath, "utf8"));
|
|
6311
6277
|
if (pkg.name === "babylonjs-market-monorepo") {
|
|
6312
6278
|
return {
|
|
6313
6279
|
root: dir,
|
|
6314
|
-
arcadeProRoot:
|
|
6315
|
-
vizProRoot:
|
|
6280
|
+
arcadeProRoot: path5.join(dir, "packages", "arcade-pro"),
|
|
6281
|
+
vizProRoot: path5.join(dir, "packages", "viz-pro")
|
|
6316
6282
|
};
|
|
6317
6283
|
}
|
|
6318
6284
|
} catch {
|
|
6319
6285
|
}
|
|
6320
6286
|
}
|
|
6321
|
-
const parent =
|
|
6287
|
+
const parent = path5.dirname(dir);
|
|
6322
6288
|
if (parent === dir) {
|
|
6323
6289
|
throw new Error(
|
|
6324
6290
|
`Could not locate umbrella repo (no ancestor package.json with name "babylonjs-market-monorepo" above ${here}).`
|
|
@@ -6333,46 +6299,46 @@ var { cyan: cyan2, green, yellow, dim, bold: bold2 } = colors2;
|
|
|
6333
6299
|
function componentFiles(dir) {
|
|
6334
6300
|
const out = [];
|
|
6335
6301
|
const walk = (d) => {
|
|
6336
|
-
for (const e of
|
|
6337
|
-
const p =
|
|
6302
|
+
for (const e of fs6.readdirSync(d, { withFileTypes: true })) {
|
|
6303
|
+
const p = path6.join(d, e.name);
|
|
6338
6304
|
if (e.isDirectory()) walk(p);
|
|
6339
6305
|
else if (/\.(ts|tsx)$/.test(e.name)) out.push(p);
|
|
6340
6306
|
}
|
|
6341
6307
|
};
|
|
6342
|
-
if (
|
|
6308
|
+
if (fs6.existsSync(dir)) walk(dir);
|
|
6343
6309
|
return out;
|
|
6344
6310
|
}
|
|
6345
6311
|
function allComponentFiles(dir) {
|
|
6346
6312
|
const out = [];
|
|
6347
6313
|
const walk = (d) => {
|
|
6348
|
-
for (const e of
|
|
6349
|
-
const p =
|
|
6314
|
+
for (const e of fs6.readdirSync(d, { withFileTypes: true })) {
|
|
6315
|
+
const p = path6.join(d, e.name);
|
|
6350
6316
|
if (e.isDirectory()) walk(p);
|
|
6351
6317
|
else out.push(p);
|
|
6352
6318
|
}
|
|
6353
6319
|
};
|
|
6354
|
-
if (
|
|
6320
|
+
if (fs6.existsSync(dir)) walk(dir);
|
|
6355
6321
|
return out;
|
|
6356
6322
|
}
|
|
6357
6323
|
function projectComponentNames(projectDir) {
|
|
6358
|
-
const dir =
|
|
6359
|
-
if (!
|
|
6360
|
-
return
|
|
6324
|
+
const dir = path6.join(projectDir, "src", "components");
|
|
6325
|
+
if (!fs6.existsSync(dir)) return [];
|
|
6326
|
+
return fs6.readdirSync(dir, { withFileTypes: true }).filter((e) => e.isDirectory() && e.name !== "_shared").map((e) => e.name);
|
|
6361
6327
|
}
|
|
6362
6328
|
function directDeps(name, componentsDir, allNames) {
|
|
6363
6329
|
const deps = /* @__PURE__ */ new Set();
|
|
6364
|
-
const metaPath =
|
|
6365
|
-
if (
|
|
6330
|
+
const metaPath = path6.join(componentsDir, name, "meta.json");
|
|
6331
|
+
if (fs6.existsSync(metaPath)) {
|
|
6366
6332
|
try {
|
|
6367
|
-
const meta = JSON.parse(
|
|
6333
|
+
const meta = JSON.parse(fs6.readFileSync(metaPath, "utf8"));
|
|
6368
6334
|
for (const d of meta.dependencies ?? []) if (allNames.has(d)) deps.add(d);
|
|
6369
6335
|
} catch {
|
|
6370
6336
|
}
|
|
6371
6337
|
}
|
|
6372
6338
|
const relRe = /['"]\.\.\/([A-Z][A-Za-z0-9_]*)\//g;
|
|
6373
6339
|
const aliasRe = /['"]~\/components\/([A-Z][A-Za-z0-9_]*)\//g;
|
|
6374
|
-
for (const file of componentFiles(
|
|
6375
|
-
const src =
|
|
6340
|
+
for (const file of componentFiles(path6.join(componentsDir, name))) {
|
|
6341
|
+
const src = fs6.readFileSync(file, "utf8");
|
|
6376
6342
|
let m;
|
|
6377
6343
|
while (m = relRe.exec(src)) if (allNames.has(m[1])) deps.add(m[1]);
|
|
6378
6344
|
while (m = aliasRe.exec(src)) if (allNames.has(m[1])) deps.add(m[1]);
|
|
@@ -6442,15 +6408,15 @@ function planArcadeProRegistry(existingRegistry, names, registryRelPath = "src/r
|
|
|
6442
6408
|
return { lines, added, warnings, markerFound: true };
|
|
6443
6409
|
}
|
|
6444
6410
|
function patchArcadeProRegistry(arcadeProRoot, names, dryRun) {
|
|
6445
|
-
const registryPath =
|
|
6446
|
-
const existing =
|
|
6411
|
+
const registryPath = path6.join(arcadeProRoot, "src", "registry.ts");
|
|
6412
|
+
const existing = fs6.existsSync(registryPath) ? fs6.readFileSync(registryPath, "utf8") : void 0;
|
|
6447
6413
|
const plan = planArcadeProRegistry(existing, names);
|
|
6448
6414
|
if (plan.warnings.length) return plan.warnings;
|
|
6449
6415
|
if (plan.added.length && !dryRun) {
|
|
6450
6416
|
const marker = /ARCADE_PRO_COMPONENT_REGISTRY:\s*Record<string,\s*LazyComponentResolver>\s*=\s*\{/;
|
|
6451
6417
|
const next = existing.replace(marker, (m) => `${m}
|
|
6452
6418
|
${plan.lines.join("\n")}`);
|
|
6453
|
-
|
|
6419
|
+
fs6.writeFileSync(registryPath, next);
|
|
6454
6420
|
}
|
|
6455
6421
|
return plan.added.map((n) => ` patched registry: ${n}`);
|
|
6456
6422
|
}
|
|
@@ -6468,21 +6434,21 @@ function planVizProBarrel(existingBarrel, layer, fileName) {
|
|
|
6468
6434
|
return { line: `export * from './${fileName}';`, warnings: [] };
|
|
6469
6435
|
}
|
|
6470
6436
|
function patchVizProBarrel(vizProRoot, layer, fileName, dryRun) {
|
|
6471
|
-
const barrelPath =
|
|
6472
|
-
const existing =
|
|
6437
|
+
const barrelPath = path6.join(vizProRoot, "src", layer, "index.ts");
|
|
6438
|
+
const existing = fs6.existsSync(barrelPath) ? fs6.readFileSync(barrelPath, "utf8") : void 0;
|
|
6473
6439
|
const plan = planVizProBarrel(existing, layer, fileName);
|
|
6474
6440
|
if (plan.warnings.length) return plan.warnings;
|
|
6475
6441
|
if (plan.line === null) return [];
|
|
6476
6442
|
if (!dryRun) {
|
|
6477
6443
|
const next = existing.endsWith("\n") ? existing + plan.line + "\n" : existing + "\n" + plan.line + "\n";
|
|
6478
|
-
|
|
6444
|
+
fs6.writeFileSync(barrelPath, next);
|
|
6479
6445
|
}
|
|
6480
6446
|
return [` patched ${layer}/index.ts: ${fileName}`];
|
|
6481
6447
|
}
|
|
6482
6448
|
function stripProjectRegistry(projectDir, names, dryRun) {
|
|
6483
|
-
const registryPath =
|
|
6484
|
-
if (!
|
|
6485
|
-
let text =
|
|
6449
|
+
const registryPath = path6.join(projectDir, "src", "registry.ts");
|
|
6450
|
+
if (!fs6.existsSync(registryPath)) return [];
|
|
6451
|
+
let text = fs6.readFileSync(registryPath, "utf8");
|
|
6486
6452
|
const removed = [];
|
|
6487
6453
|
for (const name of names) {
|
|
6488
6454
|
const re = new RegExp(
|
|
@@ -6494,7 +6460,7 @@ function stripProjectRegistry(projectDir, names, dryRun) {
|
|
|
6494
6460
|
removed.push(name);
|
|
6495
6461
|
}
|
|
6496
6462
|
}
|
|
6497
|
-
if (removed.length && !dryRun)
|
|
6463
|
+
if (removed.length && !dryRun) fs6.writeFileSync(registryPath, text);
|
|
6498
6464
|
return removed;
|
|
6499
6465
|
}
|
|
6500
6466
|
async function inject(args, opts = {}) {
|
|
@@ -6566,12 +6532,12 @@ async function inject(args, opts = {}) {
|
|
|
6566
6532
|
return;
|
|
6567
6533
|
}
|
|
6568
6534
|
}
|
|
6569
|
-
const componentsDir =
|
|
6535
|
+
const componentsDir = path6.join(projectDir, "src", "components");
|
|
6570
6536
|
const allProjectNames = projectComponentNames(projectDir);
|
|
6571
6537
|
const seeds = [];
|
|
6572
6538
|
for (const name of names) {
|
|
6573
|
-
const sourceDir = sourceOverride ?
|
|
6574
|
-
if (!
|
|
6539
|
+
const sourceDir = sourceOverride ? path6.resolve(cwd, sourceOverride) : path6.join(componentsDir, name);
|
|
6540
|
+
if (!fs6.existsSync(sourceDir)) {
|
|
6575
6541
|
console.error(
|
|
6576
6542
|
yellow(
|
|
6577
6543
|
`Could not find source for "${name}". Looked at ${sourceDir}. Use --source <path> to point at the seed explicitly.`
|
|
@@ -6586,9 +6552,9 @@ async function inject(args, opts = {}) {
|
|
|
6586
6552
|
const closure = sourceOverride ? seedNames : resolveClosure(seedNames, componentsDir, allProjectNames);
|
|
6587
6553
|
const closureFiles = [];
|
|
6588
6554
|
for (const name of closure) {
|
|
6589
|
-
const dir = sourceOverride && seedNames.has(name) ? seeds.find((s) => s.name === name).sourceDir :
|
|
6555
|
+
const dir = sourceOverride && seedNames.has(name) ? seeds.find((s) => s.name === name).sourceDir : path6.join(componentsDir, name);
|
|
6590
6556
|
for (const f of componentFiles(dir)) {
|
|
6591
|
-
closureFiles.push({ path: f, source:
|
|
6557
|
+
closureFiles.push({ path: f, source: fs6.readFileSync(f, "utf8") });
|
|
6592
6558
|
}
|
|
6593
6559
|
}
|
|
6594
6560
|
const target = explicitTarget ?? detectTarget(closureFiles);
|
|
@@ -6597,7 +6563,7 @@ async function inject(args, opts = {}) {
|
|
|
6597
6563
|
const dir = seed.sourceDir;
|
|
6598
6564
|
const files = componentFiles(dir).map((f) => ({
|
|
6599
6565
|
path: f,
|
|
6600
|
-
source:
|
|
6566
|
+
source: fs6.readFileSync(f, "utf8")
|
|
6601
6567
|
}));
|
|
6602
6568
|
const perSeed = detectTarget(files);
|
|
6603
6569
|
if (perSeed !== target) {
|
|
@@ -6615,14 +6581,14 @@ async function inject(args, opts = {}) {
|
|
|
6615
6581
|
if (mode === "apply") {
|
|
6616
6582
|
try {
|
|
6617
6583
|
if (target === "arcade") {
|
|
6618
|
-
if (!
|
|
6584
|
+
if (!fs6.existsSync(packageRoot)) {
|
|
6619
6585
|
throw new Error(
|
|
6620
6586
|
`packages/arcade is not checked out at ${packageRoot}. Run \`git submodule update --init packages/arcade\` and retry.`
|
|
6621
6587
|
);
|
|
6622
6588
|
}
|
|
6623
6589
|
chosenRoot = packageRoot;
|
|
6624
6590
|
} else {
|
|
6625
|
-
if (!
|
|
6591
|
+
if (!fs6.existsSync(vizProRoot)) {
|
|
6626
6592
|
throw new Error(
|
|
6627
6593
|
`packages/viz-pro is not checked out at ${vizProRoot}. Run \`git submodule update --init packages/viz-pro\` and retry.`
|
|
6628
6594
|
);
|
|
@@ -6680,9 +6646,9 @@ async function inject(args, opts = {}) {
|
|
|
6680
6646
|
);
|
|
6681
6647
|
}
|
|
6682
6648
|
for (const seed of seeds) {
|
|
6683
|
-
if (
|
|
6684
|
-
if (!dryRun)
|
|
6685
|
-
console.log(dim(` - ${
|
|
6649
|
+
if (fs6.existsSync(seed.sourceDir)) {
|
|
6650
|
+
if (!dryRun) fs6.rmSync(seed.sourceDir, { recursive: true, force: true });
|
|
6651
|
+
console.log(dim(` - ${path6.relative(projectDir, seed.sourceDir)}/ (project copy removed)`));
|
|
6686
6652
|
}
|
|
6687
6653
|
}
|
|
6688
6654
|
const removed = stripProjectRegistry(
|
|
@@ -6702,31 +6668,31 @@ Done. Components landed in packages/${target}/.
|
|
|
6702
6668
|
}
|
|
6703
6669
|
async function injectArcadePro(args) {
|
|
6704
6670
|
const { seeds, closure, componentsDir, sourceOverride, arcadeProRoot, dryRun, force } = args;
|
|
6705
|
-
const destComponents =
|
|
6706
|
-
if (!dryRun)
|
|
6671
|
+
const destComponents = path6.join(arcadeProRoot, "src", "Components");
|
|
6672
|
+
if (!dryRun) fs6.mkdirSync(destComponents, { recursive: true });
|
|
6707
6673
|
const sourceOf = (name) => {
|
|
6708
6674
|
const seed = seeds.find((s) => s.name === name);
|
|
6709
|
-
return seed && sourceOverride ? seed.sourceDir :
|
|
6675
|
+
return seed && sourceOverride ? seed.sourceDir : path6.join(componentsDir, name);
|
|
6710
6676
|
};
|
|
6711
6677
|
for (const name of [...closure].sort()) {
|
|
6712
6678
|
const src = sourceOf(name);
|
|
6713
|
-
const dest =
|
|
6714
|
-
if (
|
|
6679
|
+
const dest = path6.join(destComponents, name);
|
|
6680
|
+
if (fs6.existsSync(dest) && !force) {
|
|
6715
6681
|
console.log(
|
|
6716
6682
|
yellow(` ! packages/arcade/src/Components/${name}/ already exists \u2014 pass --force to overwrite.`)
|
|
6717
6683
|
);
|
|
6718
6684
|
continue;
|
|
6719
6685
|
}
|
|
6720
6686
|
if (!dryRun) {
|
|
6721
|
-
if (
|
|
6722
|
-
|
|
6687
|
+
if (fs6.existsSync(dest)) fs6.rmSync(dest, { recursive: true, force: true });
|
|
6688
|
+
fs6.cpSync(src, dest, { recursive: true });
|
|
6723
6689
|
}
|
|
6724
6690
|
console.log(green(` + packages/arcade/src/Components/${name}/`));
|
|
6725
6691
|
}
|
|
6726
6692
|
if (!dryRun) {
|
|
6727
6693
|
for (const name of closure) {
|
|
6728
|
-
const dest =
|
|
6729
|
-
if (!
|
|
6694
|
+
const dest = path6.join(destComponents, name);
|
|
6695
|
+
if (!fs6.existsSync(dest)) continue;
|
|
6730
6696
|
rewriteTree(dest, (text) => rewriteArcadeImports(text, closure));
|
|
6731
6697
|
}
|
|
6732
6698
|
}
|
|
@@ -6742,21 +6708,21 @@ function collectArcadePro(args) {
|
|
|
6742
6708
|
const { seeds, closure, componentsDir, sourceOverride } = args;
|
|
6743
6709
|
const sourceOf = (name) => {
|
|
6744
6710
|
const seed = seeds.find((s) => s.name === name);
|
|
6745
|
-
return seed && sourceOverride ? seed.sourceDir :
|
|
6711
|
+
return seed && sourceOverride ? seed.sourceDir : path6.join(componentsDir, name);
|
|
6746
6712
|
};
|
|
6747
6713
|
const files = [];
|
|
6748
6714
|
const warnings = [];
|
|
6749
6715
|
for (const name of [...closure].sort()) {
|
|
6750
6716
|
const src = sourceOf(name);
|
|
6751
|
-
if (!
|
|
6717
|
+
if (!fs6.existsSync(src)) {
|
|
6752
6718
|
warnings.push(` ! source for ${name} missing at ${src}`);
|
|
6753
6719
|
continue;
|
|
6754
6720
|
}
|
|
6755
6721
|
for (const abs of allComponentFiles(src)) {
|
|
6756
|
-
const rel =
|
|
6757
|
-
const baseRel =
|
|
6722
|
+
const rel = path6.relative(src, abs);
|
|
6723
|
+
const baseRel = path6.posix.join("src", "Components", name, rel.split(path6.sep).join("/"));
|
|
6758
6724
|
const isText = /\.(ts|tsx)$/i.test(abs);
|
|
6759
|
-
const raw =
|
|
6725
|
+
const raw = fs6.readFileSync(abs, "utf8");
|
|
6760
6726
|
const contents = isText ? rewriteArcadeImports(raw, closure) : raw;
|
|
6761
6727
|
files.push({ path: baseRel, contents });
|
|
6762
6728
|
}
|
|
@@ -6775,15 +6741,15 @@ function classifyVizFiles(args) {
|
|
|
6775
6741
|
const { seeds, closure, componentsDir, sourceOverride, layerOverride } = args;
|
|
6776
6742
|
const sourceOf = (name) => {
|
|
6777
6743
|
const seed = seeds.find((s) => s.name === name);
|
|
6778
|
-
return seed && sourceOverride ? seed.sourceDir :
|
|
6744
|
+
return seed && sourceOverride ? seed.sourceDir : path6.join(componentsDir, name);
|
|
6779
6745
|
};
|
|
6780
6746
|
const files = [];
|
|
6781
6747
|
for (const name of closure) {
|
|
6782
6748
|
const dir = sourceOf(name);
|
|
6783
6749
|
for (const abs of componentFiles(dir)) {
|
|
6784
|
-
const base =
|
|
6750
|
+
const base = path6.basename(abs);
|
|
6785
6751
|
if (/\.test\.tsx?$/.test(base)) continue;
|
|
6786
|
-
const source =
|
|
6752
|
+
const source = fs6.readFileSync(abs, "utf8");
|
|
6787
6753
|
const layer = layerOverride ?? detectLayer(abs, source);
|
|
6788
6754
|
files.push({ src: abs, base, owner: name, source, layer, destBase: base });
|
|
6789
6755
|
}
|
|
@@ -6791,9 +6757,9 @@ function classifyVizFiles(args) {
|
|
|
6791
6757
|
for (const name of closure) {
|
|
6792
6758
|
const dir = sourceOf(name);
|
|
6793
6759
|
for (const abs of componentFiles(dir)) {
|
|
6794
|
-
const base =
|
|
6760
|
+
const base = path6.basename(abs);
|
|
6795
6761
|
if (!/\.test\.tsx?$/.test(base)) continue;
|
|
6796
|
-
const source =
|
|
6762
|
+
const source = fs6.readFileSync(abs, "utf8");
|
|
6797
6763
|
const subjectBase = base.replace(/\.test(\.tsx?)$/, "$1");
|
|
6798
6764
|
const subjectAlt = base.replace(/\.test\.tsx?$/, ".tsx");
|
|
6799
6765
|
const subject = files.find((f) => f.owner === name && (f.base === subjectBase || f.base === subjectAlt));
|
|
@@ -6813,8 +6779,8 @@ async function injectVizPro(args) {
|
|
|
6813
6779
|
const { files, primaryLayer } = classifyVizFiles(args);
|
|
6814
6780
|
const layerOf = (name) => primaryLayer.get(name);
|
|
6815
6781
|
for (const f of files) {
|
|
6816
|
-
const dest =
|
|
6817
|
-
if (
|
|
6782
|
+
const dest = path6.join(vizProRoot, "src", f.layer, f.destBase);
|
|
6783
|
+
if (fs6.existsSync(dest) && !force) {
|
|
6818
6784
|
console.log(
|
|
6819
6785
|
yellow(
|
|
6820
6786
|
` ! packages/viz-pro/src/${f.layer}/${f.destBase} already exists \u2014 pass --force to overwrite.`
|
|
@@ -6823,13 +6789,13 @@ async function injectVizPro(args) {
|
|
|
6823
6789
|
}
|
|
6824
6790
|
}
|
|
6825
6791
|
for (const f of files) {
|
|
6826
|
-
const destDir =
|
|
6827
|
-
const dest =
|
|
6828
|
-
if (
|
|
6792
|
+
const destDir = path6.join(vizProRoot, "src", f.layer);
|
|
6793
|
+
const dest = path6.join(destDir, f.destBase);
|
|
6794
|
+
if (fs6.existsSync(dest) && !force) continue;
|
|
6829
6795
|
if (!dryRun) {
|
|
6830
|
-
|
|
6796
|
+
fs6.mkdirSync(destDir, { recursive: true });
|
|
6831
6797
|
const rewritten = rewriteVizImports(f.source, closure, layerOf, f.layer);
|
|
6832
|
-
|
|
6798
|
+
fs6.writeFileSync(dest, rewritten);
|
|
6833
6799
|
}
|
|
6834
6800
|
console.log(green(` + packages/viz-pro/src/${f.layer}/${f.destBase}`));
|
|
6835
6801
|
}
|
|
@@ -6857,7 +6823,7 @@ function collectVizPro(args) {
|
|
|
6857
6823
|
const files = [];
|
|
6858
6824
|
const warnings = [];
|
|
6859
6825
|
for (const f of classified) {
|
|
6860
|
-
const rel =
|
|
6826
|
+
const rel = path6.posix.join("src", f.layer, f.destBase);
|
|
6861
6827
|
const contents = rewriteVizImports(f.source, closure, layerOf, f.layer);
|
|
6862
6828
|
files.push({ path: rel, contents });
|
|
6863
6829
|
}
|
|
@@ -6878,13 +6844,13 @@ function collectVizPro(args) {
|
|
|
6878
6844
|
return { files, patches, warnings };
|
|
6879
6845
|
}
|
|
6880
6846
|
function rewriteTree(dir, rewrite) {
|
|
6881
|
-
for (const e of
|
|
6882
|
-
const p =
|
|
6847
|
+
for (const e of fs6.readdirSync(dir, { withFileTypes: true })) {
|
|
6848
|
+
const p = path6.join(dir, e.name);
|
|
6883
6849
|
if (e.isDirectory()) rewriteTree(p, rewrite);
|
|
6884
6850
|
else if (/\.(ts|tsx)$/.test(e.name)) {
|
|
6885
|
-
const before =
|
|
6851
|
+
const before = fs6.readFileSync(p, "utf8");
|
|
6886
6852
|
const after = rewrite(before);
|
|
6887
|
-
if (after !== before)
|
|
6853
|
+
if (after !== before) fs6.writeFileSync(p, after);
|
|
6888
6854
|
}
|
|
6889
6855
|
}
|
|
6890
6856
|
}
|
|
@@ -7000,8 +6966,8 @@ function readSeedMeta(projectDir, seedName) {
|
|
|
7000
6966
|
// src/commands/submissions.ts
|
|
7001
6967
|
import { Command as Command7 } from "commander";
|
|
7002
6968
|
import { createInterface } from "readline";
|
|
7003
|
-
async function apiCall(auth, method,
|
|
7004
|
-
return auth.makeAuthenticatedRequest(`${API_URL}${
|
|
6969
|
+
async function apiCall(auth, method, path7) {
|
|
6970
|
+
return auth.makeAuthenticatedRequest(`${API_URL}${path7}`, { method });
|
|
7005
6971
|
}
|
|
7006
6972
|
function formatDate(s) {
|
|
7007
6973
|
if (!s) return "";
|