playcademy 0.13.14 → 0.13.15
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 +73 -81
- package/dist/utils.js +18 -21
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -5442,76 +5442,8 @@ import { bold as bold3, cyan as cyan2 } from "colorette";
|
|
|
5442
5442
|
init_constants2();
|
|
5443
5443
|
init_core();
|
|
5444
5444
|
init_loader2();
|
|
5445
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync3, writeFileSync as
|
|
5446
|
-
import { join as
|
|
5447
|
-
|
|
5448
|
-
// src/lib/init/types.ts
|
|
5449
|
-
init_file_loader();
|
|
5450
|
-
init_package_manager();
|
|
5451
|
-
init_constants2();
|
|
5452
|
-
init_loader();
|
|
5453
|
-
init_core();
|
|
5454
|
-
init_loader2();
|
|
5455
|
-
import { execSync as execSync3 } from "child_process";
|
|
5456
|
-
import { writeFileSync as writeFileSync3 } from "fs";
|
|
5457
|
-
import { dirname as dirname4, join as join9 } from "path";
|
|
5458
|
-
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
5459
|
-
var playcademyEnvTemplate = loadTemplateString("playcademy-env.d.ts");
|
|
5460
|
-
async function ensurePlaycademyTypes(configPath) {
|
|
5461
|
-
try {
|
|
5462
|
-
const workspace = getWorkspace();
|
|
5463
|
-
console.log({ configPath, workspace });
|
|
5464
|
-
const config = await loadConfig(configPath);
|
|
5465
|
-
const hasDB = hasDatabaseSetup();
|
|
5466
|
-
const hasKV = hasKVSetup(config);
|
|
5467
|
-
const hasBucket = hasBucketSetup(config);
|
|
5468
|
-
if (!hasDB && !hasKV && !hasBucket) {
|
|
5469
|
-
return;
|
|
5470
|
-
}
|
|
5471
|
-
const playcademyDir = join9(workspace, CLI_DIRECTORIES.WORKSPACE);
|
|
5472
|
-
const playcademyPkgPath = join9(playcademyDir, "package.json");
|
|
5473
|
-
const __dirname2 = dirname4(fileURLToPath2(import.meta.url));
|
|
5474
|
-
const cliPkg = await loadPackageJson({ cwd: __dirname2, searchUp: true, required: true });
|
|
5475
|
-
const workersTypesVersion = cliPkg?.devDependencies?.["@cloudflare/workers-types"] || "latest";
|
|
5476
|
-
const honoVersion = cliPkg?.dependencies?.hono || "latest";
|
|
5477
|
-
const playcademyPkg = {
|
|
5478
|
-
private: true,
|
|
5479
|
-
dependencies: {
|
|
5480
|
-
hono: honoVersion
|
|
5481
|
-
},
|
|
5482
|
-
devDependencies: {
|
|
5483
|
-
"@cloudflare/workers-types": workersTypesVersion
|
|
5484
|
-
}
|
|
5485
|
-
};
|
|
5486
|
-
writeFileSync3(playcademyPkgPath, JSON.stringify(playcademyPkg, null, 4) + "\n");
|
|
5487
|
-
const pm = detectPackageManager(workspace);
|
|
5488
|
-
const installCmd = getInstallCommand(pm);
|
|
5489
|
-
execSync3(installCmd, {
|
|
5490
|
-
cwd: playcademyDir,
|
|
5491
|
-
stdio: ["ignore", "ignore", "ignore"]
|
|
5492
|
-
});
|
|
5493
|
-
const bindings = [];
|
|
5494
|
-
if (hasKV) {
|
|
5495
|
-
bindings.push(" KV: KVNamespace");
|
|
5496
|
-
}
|
|
5497
|
-
if (hasDB) {
|
|
5498
|
-
bindings.push(" DB: D1Database");
|
|
5499
|
-
}
|
|
5500
|
-
if (hasBucket) {
|
|
5501
|
-
bindings.push(" BUCKET: R2Bucket");
|
|
5502
|
-
}
|
|
5503
|
-
const bindingsStr = bindings.length > 0 ? "\n" + bindings.join("\n") : "";
|
|
5504
|
-
const envContent = playcademyEnvTemplate.replace("{{BINDINGS}}", bindingsStr);
|
|
5505
|
-
const envPath = join9(workspace, "playcademy-env.d.ts");
|
|
5506
|
-
writeFileSync3(envPath, envContent);
|
|
5507
|
-
} catch (error) {
|
|
5508
|
-
logger.warn(
|
|
5509
|
-
`Failed to generate TypeScript types: ${error instanceof Error ? error.message : String(error)}`
|
|
5510
|
-
);
|
|
5511
|
-
}
|
|
5512
|
-
}
|
|
5513
|
-
|
|
5514
|
-
// src/lib/init/scaffold.ts
|
|
5445
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync3, writeFileSync as writeFileSync3 } from "fs";
|
|
5446
|
+
import { join as join9, resolve as resolve6 } from "path";
|
|
5515
5447
|
var sampleCustomRouteTemplate = loadTemplateString("api/sample-custom.ts");
|
|
5516
5448
|
var sampleDatabaseRouteTemplate = loadTemplateString("api/sample-database.ts");
|
|
5517
5449
|
var sampleKvRouteTemplate = loadTemplateString("api/sample-kv.ts");
|
|
@@ -5519,7 +5451,7 @@ var sampleBucketRouteTemplate = loadTemplateString("api/sample-bucket.ts");
|
|
|
5519
5451
|
var playcademyGitignoreTemplate = loadTemplateString("playcademy-gitignore");
|
|
5520
5452
|
async function scaffoldApiDirectory(apiDirectory, sampleRoutes) {
|
|
5521
5453
|
const apiPath = resolve6(getWorkspace(), apiDirectory);
|
|
5522
|
-
const samplePath =
|
|
5454
|
+
const samplePath = join9(apiPath, "sample");
|
|
5523
5455
|
if (!existsSync8(apiPath)) {
|
|
5524
5456
|
mkdirSync3(apiPath, { recursive: true });
|
|
5525
5457
|
}
|
|
@@ -5527,7 +5459,7 @@ async function scaffoldApiDirectory(apiDirectory, sampleRoutes) {
|
|
|
5527
5459
|
mkdirSync3(samplePath, { recursive: true });
|
|
5528
5460
|
}
|
|
5529
5461
|
for (const route of sampleRoutes) {
|
|
5530
|
-
|
|
5462
|
+
writeFileSync3(join9(samplePath, route.filename), route.template, "utf-8");
|
|
5531
5463
|
}
|
|
5532
5464
|
}
|
|
5533
5465
|
function validateApiDirectoryDoesNotExist(value) {
|
|
@@ -5539,12 +5471,12 @@ function validateApiDirectoryDoesNotExist(value) {
|
|
|
5539
5471
|
}
|
|
5540
5472
|
function ensurePlaycademyGitignore() {
|
|
5541
5473
|
const workspace = getWorkspace();
|
|
5542
|
-
const playcademyDir =
|
|
5474
|
+
const playcademyDir = join9(workspace, CLI_DIRECTORIES.WORKSPACE);
|
|
5543
5475
|
if (!existsSync8(playcademyDir)) {
|
|
5544
5476
|
mkdirSync3(playcademyDir, { recursive: true });
|
|
5545
5477
|
}
|
|
5546
|
-
const gitignorePath =
|
|
5547
|
-
|
|
5478
|
+
const gitignorePath = join9(playcademyDir, ".gitignore");
|
|
5479
|
+
writeFileSync3(gitignorePath, playcademyGitignoreTemplate);
|
|
5548
5480
|
}
|
|
5549
5481
|
async function scaffoldIntegrations(gameName, options) {
|
|
5550
5482
|
const { customRoutes, database, kv, bucket } = options;
|
|
@@ -5566,12 +5498,7 @@ async function scaffoldIntegrations(gameName, options) {
|
|
|
5566
5498
|
await scaffoldApiDirectory(customRoutes.directory, sampleRoutes);
|
|
5567
5499
|
}
|
|
5568
5500
|
if (database) {
|
|
5569
|
-
|
|
5570
|
-
await ensurePlaycademyTypes();
|
|
5571
|
-
return depsAdded;
|
|
5572
|
-
}
|
|
5573
|
-
if (kv || bucket) {
|
|
5574
|
-
await ensurePlaycademyTypes();
|
|
5501
|
+
return await scaffoldDatabaseSetup({ gameName });
|
|
5575
5502
|
}
|
|
5576
5503
|
return false;
|
|
5577
5504
|
}
|
|
@@ -5796,6 +5723,71 @@ function displaySuccessMessage(context2) {
|
|
|
5796
5723
|
logger.newLine();
|
|
5797
5724
|
}
|
|
5798
5725
|
|
|
5726
|
+
// src/lib/init/types.ts
|
|
5727
|
+
init_file_loader();
|
|
5728
|
+
init_package_manager();
|
|
5729
|
+
init_constants2();
|
|
5730
|
+
init_loader();
|
|
5731
|
+
init_core();
|
|
5732
|
+
init_loader2();
|
|
5733
|
+
import { execSync as execSync3 } from "child_process";
|
|
5734
|
+
import { writeFileSync as writeFileSync4 } from "fs";
|
|
5735
|
+
import { dirname as dirname4, join as join10 } from "path";
|
|
5736
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
5737
|
+
var playcademyEnvTemplate = loadTemplateString("playcademy-env.d.ts");
|
|
5738
|
+
async function ensurePlaycademyTypes(configPath) {
|
|
5739
|
+
try {
|
|
5740
|
+
const workspace = getWorkspace();
|
|
5741
|
+
const config = await loadConfig(configPath);
|
|
5742
|
+
const hasDB = hasDatabaseSetup();
|
|
5743
|
+
const hasKV = hasKVSetup(config);
|
|
5744
|
+
const hasBucket = hasBucketSetup(config);
|
|
5745
|
+
if (!hasDB && !hasKV && !hasBucket) {
|
|
5746
|
+
return;
|
|
5747
|
+
}
|
|
5748
|
+
const playcademyDir = join10(workspace, CLI_DIRECTORIES.WORKSPACE);
|
|
5749
|
+
const playcademyPkgPath = join10(playcademyDir, "package.json");
|
|
5750
|
+
const __dirname2 = dirname4(fileURLToPath2(import.meta.url));
|
|
5751
|
+
const cliPkg = await loadPackageJson({ cwd: __dirname2, searchUp: true, required: true });
|
|
5752
|
+
const workersTypesVersion = cliPkg?.devDependencies?.["@cloudflare/workers-types"] || "latest";
|
|
5753
|
+
const honoVersion = cliPkg?.dependencies?.hono || "latest";
|
|
5754
|
+
const playcademyPkg = {
|
|
5755
|
+
private: true,
|
|
5756
|
+
dependencies: {
|
|
5757
|
+
hono: honoVersion
|
|
5758
|
+
},
|
|
5759
|
+
devDependencies: {
|
|
5760
|
+
"@cloudflare/workers-types": workersTypesVersion
|
|
5761
|
+
}
|
|
5762
|
+
};
|
|
5763
|
+
writeFileSync4(playcademyPkgPath, JSON.stringify(playcademyPkg, null, 4) + "\n");
|
|
5764
|
+
const pm = detectPackageManager(workspace);
|
|
5765
|
+
const installCmd = getInstallCommand(pm);
|
|
5766
|
+
execSync3(installCmd, {
|
|
5767
|
+
cwd: playcademyDir,
|
|
5768
|
+
stdio: ["ignore", "ignore", "ignore"]
|
|
5769
|
+
});
|
|
5770
|
+
const bindings = [];
|
|
5771
|
+
if (hasKV) {
|
|
5772
|
+
bindings.push(" KV: KVNamespace");
|
|
5773
|
+
}
|
|
5774
|
+
if (hasDB) {
|
|
5775
|
+
bindings.push(" DB: D1Database");
|
|
5776
|
+
}
|
|
5777
|
+
if (hasBucket) {
|
|
5778
|
+
bindings.push(" BUCKET: R2Bucket");
|
|
5779
|
+
}
|
|
5780
|
+
const bindingsStr = bindings.length > 0 ? "\n" + bindings.join("\n") : "";
|
|
5781
|
+
const envContent = playcademyEnvTemplate.replace("{{BINDINGS}}", bindingsStr);
|
|
5782
|
+
const envPath = join10(workspace, "playcademy-env.d.ts");
|
|
5783
|
+
writeFileSync4(envPath, envContent);
|
|
5784
|
+
} catch (error) {
|
|
5785
|
+
logger.warn(
|
|
5786
|
+
`Failed to generate TypeScript types: ${error instanceof Error ? error.message : String(error)}`
|
|
5787
|
+
);
|
|
5788
|
+
}
|
|
5789
|
+
}
|
|
5790
|
+
|
|
5799
5791
|
// src/lib/init/gitignore.ts
|
|
5800
5792
|
init_core();
|
|
5801
5793
|
init_loader2();
|
package/dist/utils.js
CHANGED
|
@@ -1522,29 +1522,36 @@ function hasDatabaseSetup() {
|
|
|
1522
1522
|
return existsSync6(drizzleConfigPath) || existsSync6(drizzleConfigJsPath);
|
|
1523
1523
|
}
|
|
1524
1524
|
|
|
1525
|
-
// src/lib/init/
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1525
|
+
// src/lib/init/scaffold.ts
|
|
1526
|
+
var sampleCustomRouteTemplate = loadTemplateString("api/sample-custom.ts");
|
|
1527
|
+
var sampleDatabaseRouteTemplate = loadTemplateString("api/sample-database.ts");
|
|
1528
|
+
var sampleKvRouteTemplate = loadTemplateString("api/sample-kv.ts");
|
|
1529
|
+
var sampleBucketRouteTemplate = loadTemplateString("api/sample-bucket.ts");
|
|
1530
|
+
var playcademyGitignoreTemplate = loadTemplateString("playcademy-gitignore");
|
|
1531
1531
|
|
|
1532
|
-
// src/lib/init/
|
|
1533
|
-
|
|
1534
|
-
return !!config.integrations?.bucket;
|
|
1535
|
-
}
|
|
1532
|
+
// src/lib/init/display.ts
|
|
1533
|
+
import { blueBright } from "colorette";
|
|
1536
1534
|
|
|
1537
1535
|
// src/lib/init/kv.ts
|
|
1538
1536
|
function hasKVSetup(config) {
|
|
1539
1537
|
return !!config.integrations?.kv;
|
|
1540
1538
|
}
|
|
1541
1539
|
|
|
1540
|
+
// src/lib/init/bucket.ts
|
|
1541
|
+
function hasBucketSetup(config) {
|
|
1542
|
+
return !!config.integrations?.bucket;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1542
1545
|
// src/lib/init/types.ts
|
|
1546
|
+
init_file_loader();
|
|
1547
|
+
import { execSync as execSync2 } from "child_process";
|
|
1548
|
+
import { writeFileSync as writeFileSync3 } from "fs";
|
|
1549
|
+
import { dirname as dirname4, join as join8 } from "path";
|
|
1550
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
1543
1551
|
var playcademyEnvTemplate = loadTemplateString("playcademy-env.d.ts");
|
|
1544
1552
|
async function ensurePlaycademyTypes(configPath) {
|
|
1545
1553
|
try {
|
|
1546
1554
|
const workspace = getWorkspace();
|
|
1547
|
-
console.log({ configPath, workspace });
|
|
1548
1555
|
const config = await loadConfig(configPath);
|
|
1549
1556
|
const hasDB = hasDatabaseSetup();
|
|
1550
1557
|
const hasKV = hasKVSetup(config);
|
|
@@ -1595,16 +1602,6 @@ async function ensurePlaycademyTypes(configPath) {
|
|
|
1595
1602
|
}
|
|
1596
1603
|
}
|
|
1597
1604
|
|
|
1598
|
-
// src/lib/init/scaffold.ts
|
|
1599
|
-
var sampleCustomRouteTemplate = loadTemplateString("api/sample-custom.ts");
|
|
1600
|
-
var sampleDatabaseRouteTemplate = loadTemplateString("api/sample-database.ts");
|
|
1601
|
-
var sampleKvRouteTemplate = loadTemplateString("api/sample-kv.ts");
|
|
1602
|
-
var sampleBucketRouteTemplate = loadTemplateString("api/sample-bucket.ts");
|
|
1603
|
-
var playcademyGitignoreTemplate = loadTemplateString("playcademy-gitignore");
|
|
1604
|
-
|
|
1605
|
-
// src/lib/init/display.ts
|
|
1606
|
-
import { blueBright } from "colorette";
|
|
1607
|
-
|
|
1608
1605
|
// src/lib/init/gitignore.ts
|
|
1609
1606
|
var rootGitignoreTemplate = loadTemplateString("gitignore");
|
|
1610
1607
|
|