@meetploy/cli 1.18.0 → 1.19.0
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.
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>Ploy Dev Dashboard</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/main-
|
|
7
|
+
<script type="module" crossorigin src="/assets/main-CZRtZPnP.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/main-5Kt9I_hM.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env -S node --disable-warning=ExperimentalWarning
|
|
2
2
|
import '@meetploy/emulator';
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env -S node --disable-warning=ExperimentalWarning
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
3
|
import { mkdir, writeFile, readFile, chmod, access } from 'fs/promises';
|
|
4
4
|
import { join, dirname, relative, basename } from 'path';
|
|
@@ -1462,7 +1462,12 @@ function generateWrapperCode(config, mockServiceUrl, envVars) {
|
|
|
1462
1462
|
injectedEnv.vars = {
|
|
1463
1463
|
${envVarsEntries}
|
|
1464
1464
|
};` : "";
|
|
1465
|
-
|
|
1465
|
+
const envInjectImport = envVarsEntries ? 'import "__ploy_env_inject__";' : "";
|
|
1466
|
+
const runtimeImports = imports.filter((i) => !i.includes("__ploy_user_worker__"));
|
|
1467
|
+
const userImport = 'import userWorker from "__ploy_user_worker__";';
|
|
1468
|
+
return `${runtimeImports.join("\n")}
|
|
1469
|
+
${envInjectImport}
|
|
1470
|
+
${userImport}
|
|
1466
1471
|
|
|
1467
1472
|
const ployBindings = {
|
|
1468
1473
|
${bindings.join("\n")}
|
|
@@ -1492,10 +1497,15 @@ export default {
|
|
|
1492
1497
|
};
|
|
1493
1498
|
`;
|
|
1494
1499
|
}
|
|
1495
|
-
function createRuntimePlugin(_config) {
|
|
1500
|
+
function createRuntimePlugin(_config, envVars) {
|
|
1496
1501
|
return {
|
|
1497
1502
|
name: "ploy-runtime",
|
|
1498
1503
|
setup(build2) {
|
|
1504
|
+
build2.onResolve({ filter: /^__ploy_env_inject__$/ }, () => ({
|
|
1505
|
+
path: "__ploy_env_inject__",
|
|
1506
|
+
namespace: "ploy-runtime",
|
|
1507
|
+
sideEffects: true
|
|
1508
|
+
}));
|
|
1499
1509
|
build2.onResolve({ filter: /^__ploy_db_runtime__$/ }, () => ({
|
|
1500
1510
|
path: "__ploy_db_runtime__",
|
|
1501
1511
|
namespace: "ploy-runtime"
|
|
@@ -1552,6 +1562,16 @@ function createRuntimePlugin(_config) {
|
|
|
1552
1562
|
contents: TIMER_RUNTIME_CODE,
|
|
1553
1563
|
loader: "ts"
|
|
1554
1564
|
}));
|
|
1565
|
+
build2.onLoad({ filter: /^__ploy_env_inject__$/, namespace: "ploy-runtime" }, () => {
|
|
1566
|
+
const entries = Object.entries(envVars ?? {});
|
|
1567
|
+
if (entries.length === 0) {
|
|
1568
|
+
return { contents: "", loader: "js" };
|
|
1569
|
+
}
|
|
1570
|
+
const code = `if (typeof process !== "undefined" && process.env) {
|
|
1571
|
+
${entries.map(([key, value]) => ` process.env[${JSON.stringify(key)}] = ${JSON.stringify(value)};`).join("\n")}
|
|
1572
|
+
}`;
|
|
1573
|
+
return { contents: code, loader: "js" };
|
|
1574
|
+
});
|
|
1555
1575
|
}
|
|
1556
1576
|
};
|
|
1557
1577
|
}
|
|
@@ -1578,7 +1598,7 @@ async function bundleWorker(options) {
|
|
|
1578
1598
|
alias: {
|
|
1579
1599
|
__ploy_user_worker__: entryPoint
|
|
1580
1600
|
},
|
|
1581
|
-
plugins: [createRuntimePlugin()],
|
|
1601
|
+
plugins: [createRuntimePlugin(config, envVars)],
|
|
1582
1602
|
absWorkingDir: projectDir,
|
|
1583
1603
|
logLevel: "warning"
|
|
1584
1604
|
};
|
|
@@ -6283,7 +6303,6 @@ async function updateTsConfigInclude(cwd, outputPath) {
|
|
|
6283
6303
|
}
|
|
6284
6304
|
}
|
|
6285
6305
|
function generateEnvType(config) {
|
|
6286
|
-
const imports = [];
|
|
6287
6306
|
const properties = [];
|
|
6288
6307
|
if (config.env && Object.keys(config.env).length > 0) {
|
|
6289
6308
|
const varProps = Object.keys(config.env).map((key) => ` ${key}: string;`).join("\n");
|
|
@@ -6296,61 +6315,47 @@ ${varProps}
|
|
|
6296
6315
|
properties.push(" AI_TOKEN: string;");
|
|
6297
6316
|
}
|
|
6298
6317
|
if (config.db) {
|
|
6299
|
-
imports.push("D1Database");
|
|
6300
6318
|
for (const bindingName of Object.keys(config.db)) {
|
|
6301
6319
|
properties.push(` ${bindingName}: D1Database;`);
|
|
6302
6320
|
}
|
|
6303
6321
|
}
|
|
6304
6322
|
if (config.queue) {
|
|
6305
|
-
imports.push("QueueBinding");
|
|
6306
6323
|
for (const bindingName of Object.keys(config.queue)) {
|
|
6307
6324
|
properties.push(` ${bindingName}: QueueBinding;`);
|
|
6308
6325
|
}
|
|
6309
6326
|
}
|
|
6310
6327
|
if (config.cache) {
|
|
6311
|
-
imports.push("CacheBinding");
|
|
6312
6328
|
for (const bindingName of Object.keys(config.cache)) {
|
|
6313
6329
|
properties.push(` ${bindingName}: CacheBinding;`);
|
|
6314
6330
|
}
|
|
6315
6331
|
}
|
|
6316
6332
|
if (config.state) {
|
|
6317
|
-
imports.push("StateBinding");
|
|
6318
6333
|
for (const bindingName of Object.keys(config.state)) {
|
|
6319
6334
|
properties.push(` ${bindingName}: StateBinding;`);
|
|
6320
6335
|
}
|
|
6321
6336
|
}
|
|
6322
6337
|
if (config.workflow) {
|
|
6323
|
-
imports.push("WorkflowBinding");
|
|
6324
6338
|
for (const bindingName of Object.keys(config.workflow)) {
|
|
6325
6339
|
properties.push(` ${bindingName}: WorkflowBinding;`);
|
|
6326
6340
|
}
|
|
6327
6341
|
}
|
|
6328
6342
|
if (config.fs) {
|
|
6329
|
-
const
|
|
6330
|
-
|
|
6331
|
-
imports.push("FileStorageBinding");
|
|
6332
|
-
for (const bindingName of fsKeys) {
|
|
6333
|
-
properties.push(` ${bindingName}: FileStorageBinding;`);
|
|
6334
|
-
}
|
|
6343
|
+
for (const bindingName of Object.keys(config.fs)) {
|
|
6344
|
+
properties.push(` ${bindingName}: FileStorageBinding;`);
|
|
6335
6345
|
}
|
|
6336
6346
|
}
|
|
6337
6347
|
if (config.timer) {
|
|
6338
|
-
const
|
|
6339
|
-
|
|
6340
|
-
imports.push("TimerBinding");
|
|
6341
|
-
for (const bindingName of timerKeys) {
|
|
6342
|
-
properties.push(` ${bindingName}: TimerBinding;`);
|
|
6343
|
-
}
|
|
6348
|
+
for (const bindingName of Object.keys(config.timer)) {
|
|
6349
|
+
properties.push(` ${bindingName}: TimerBinding;`);
|
|
6344
6350
|
}
|
|
6345
6351
|
}
|
|
6352
|
+
if (config.auth) {
|
|
6353
|
+
properties.push(` PLOY_AUTH: PloyAuth;`);
|
|
6354
|
+
}
|
|
6346
6355
|
const lines = [
|
|
6347
6356
|
"// This file is auto-generated by `ploy types`. Do not edit manually.",
|
|
6348
6357
|
""
|
|
6349
6358
|
];
|
|
6350
|
-
if (imports.length > 0) {
|
|
6351
|
-
lines.push(`import type { ${imports.join(", ")} } from "@meetploy/types";`);
|
|
6352
|
-
lines.push("");
|
|
6353
|
-
}
|
|
6354
6359
|
lines.push('declare module "@meetploy/nextjs" {');
|
|
6355
6360
|
lines.push(" interface PloyEnv {");
|
|
6356
6361
|
for (const prop of properties) {
|
|
@@ -6359,7 +6364,69 @@ ${varProps}
|
|
|
6359
6364
|
lines.push(" }");
|
|
6360
6365
|
lines.push("}");
|
|
6361
6366
|
lines.push("");
|
|
6367
|
+
const p = "@meetploy/types";
|
|
6362
6368
|
lines.push("declare global {");
|
|
6369
|
+
lines.push(
|
|
6370
|
+
` type PloyHandler<TEnv = unknown> = import("${p}").PloyHandler<TEnv>;`
|
|
6371
|
+
);
|
|
6372
|
+
lines.push(` type Ploy = PloyHandler<PloyEnv>;`);
|
|
6373
|
+
lines.push(` interface PloyRequest {`);
|
|
6374
|
+
lines.push(` readonly method: string;`);
|
|
6375
|
+
lines.push(` readonly url: string;`);
|
|
6376
|
+
lines.push(` readonly headers: Headers;`);
|
|
6377
|
+
lines.push(` readonly redirect: string;`);
|
|
6378
|
+
lines.push(` readonly signal: AbortSignal;`);
|
|
6379
|
+
lines.push(` readonly integrity: string;`);
|
|
6380
|
+
lines.push(` readonly keepalive: boolean;`);
|
|
6381
|
+
lines.push(` readonly body: ReadableStream | null;`);
|
|
6382
|
+
lines.push(` readonly bodyUsed: boolean;`);
|
|
6383
|
+
lines.push(` clone(): PloyRequest;`);
|
|
6384
|
+
lines.push(` arrayBuffer(): Promise<ArrayBuffer>;`);
|
|
6385
|
+
lines.push(` bytes(): Promise<Uint8Array>;`);
|
|
6386
|
+
lines.push(` text(): Promise<string>;`);
|
|
6387
|
+
lines.push(` json<T>(): Promise<T>;`);
|
|
6388
|
+
lines.push(` formData(): Promise<FormData>;`);
|
|
6389
|
+
lines.push(` blob(): Promise<Blob>;`);
|
|
6390
|
+
lines.push(` }`);
|
|
6391
|
+
lines.push("");
|
|
6392
|
+
lines.push(` interface PloyResponse {`);
|
|
6393
|
+
lines.push(` readonly status: number;`);
|
|
6394
|
+
lines.push(` readonly statusText: string;`);
|
|
6395
|
+
lines.push(` readonly headers: Headers;`);
|
|
6396
|
+
lines.push(` readonly ok: boolean;`);
|
|
6397
|
+
lines.push(` readonly redirected: boolean;`);
|
|
6398
|
+
lines.push(` readonly url: string;`);
|
|
6399
|
+
lines.push(` readonly body: ReadableStream | null;`);
|
|
6400
|
+
lines.push(` readonly bodyUsed: boolean;`);
|
|
6401
|
+
lines.push(` clone(): PloyResponse;`);
|
|
6402
|
+
lines.push(` arrayBuffer(): Promise<ArrayBuffer>;`);
|
|
6403
|
+
lines.push(` bytes(): Promise<Uint8Array>;`);
|
|
6404
|
+
lines.push(` text(): Promise<string>;`);
|
|
6405
|
+
lines.push(` json<T>(): Promise<T>;`);
|
|
6406
|
+
lines.push(` formData(): Promise<FormData>;`);
|
|
6407
|
+
lines.push(` blob(): Promise<Blob>;`);
|
|
6408
|
+
lines.push(` }`);
|
|
6409
|
+
lines.push("");
|
|
6410
|
+
lines.push(` // Binding types`);
|
|
6411
|
+
lines.push(` type D1Database = import("${p}").D1Database;`);
|
|
6412
|
+
lines.push(` type CacheBinding = import("${p}").CacheBinding;`);
|
|
6413
|
+
lines.push(` type QueueBinding = import("${p}").QueueBinding;`);
|
|
6414
|
+
lines.push(` type StateBinding = import("${p}").StateBinding;`);
|
|
6415
|
+
lines.push(` type WorkflowBinding = import("${p}").WorkflowBinding;`);
|
|
6416
|
+
lines.push(` type FileStorageBinding = import("${p}").FileStorageBinding;`);
|
|
6417
|
+
lines.push(` type TimerBinding = import("${p}").TimerBinding;`);
|
|
6418
|
+
lines.push(` type PloyAuth = import("${p}").PloyAuth;`);
|
|
6419
|
+
lines.push(` type PloyUser = import("${p}").PloyUser;`);
|
|
6420
|
+
lines.push("");
|
|
6421
|
+
lines.push(` // Handler and context types`);
|
|
6422
|
+
lines.push(
|
|
6423
|
+
` type WorkflowContext<TEnv = unknown, TInput = unknown> = import("${p}").WorkflowContext<TEnv, TInput>;`
|
|
6424
|
+
);
|
|
6425
|
+
lines.push(` type QueueMessageEvent = import("${p}").QueueMessageEvent;`);
|
|
6426
|
+
lines.push(` type ScheduledEvent = import("${p}").ScheduledEvent;`);
|
|
6427
|
+
lines.push(` type TimerEvent = import("${p}").TimerEvent;`);
|
|
6428
|
+
lines.push(` type ExecutionContext = import("${p}").ExecutionContext;`);
|
|
6429
|
+
lines.push("");
|
|
6363
6430
|
lines.push(" interface PloyEnv {");
|
|
6364
6431
|
for (const prop of properties) {
|
|
6365
6432
|
lines.push(` ${prop}`);
|
|
@@ -6384,7 +6451,7 @@ async function typesCommand(options = {}) {
|
|
|
6384
6451
|
console.error("Error: ploy.yaml not found in current directory");
|
|
6385
6452
|
process.exit(1);
|
|
6386
6453
|
}
|
|
6387
|
-
const hasBindings2 = config.env || config.ai || config.db || config.queue || config.cache || config.state || config.workflow || config.fs || config.timer || config.cron;
|
|
6454
|
+
const hasBindings2 = config.env || config.ai || config.db || config.queue || config.cache || config.state || config.workflow || config.fs || config.timer || config.cron || config.auth;
|
|
6388
6455
|
if (!hasBindings2) {
|
|
6389
6456
|
console.log("No bindings found in ploy.yaml. Generating empty Env.");
|
|
6390
6457
|
}
|
|
@@ -6536,30 +6603,30 @@ async function startNextJsDev(options) {
|
|
|
6536
6603
|
nextArgs.push("-H", options.host);
|
|
6537
6604
|
}
|
|
6538
6605
|
console.log(` Starting Next.js dev server...`);
|
|
6606
|
+
const suppressWarning = "--disable-warning=ExperimentalWarning";
|
|
6607
|
+
const nodeOptions = process.env.NODE_OPTIONS ? `${process.env.NODE_OPTIONS} ${suppressWarning}` : suppressWarning;
|
|
6608
|
+
const childEnv = {
|
|
6609
|
+
...process.env,
|
|
6610
|
+
NODE_OPTIONS: nodeOptions,
|
|
6611
|
+
// Set environment variable so initPloyForDev knows the mock server URL
|
|
6612
|
+
PLOY_MOCK_SERVER_URL: `http://localhost:${dashboard.port}`,
|
|
6613
|
+
// Set PORT so initPloyForDev can construct the correct handler URL
|
|
6614
|
+
PORT: String(nextPort)
|
|
6615
|
+
};
|
|
6539
6616
|
let nextProcess;
|
|
6540
6617
|
if (nextBin.includes("npx")) {
|
|
6541
6618
|
nextProcess = spawn("npx", ["next", ...nextArgs], {
|
|
6542
6619
|
cwd: projectDir,
|
|
6543
6620
|
stdio: "inherit",
|
|
6544
6621
|
shell: true,
|
|
6545
|
-
env:
|
|
6546
|
-
...process.env,
|
|
6547
|
-
// Set environment variable so initPloyForDev knows the mock server URL
|
|
6548
|
-
PLOY_MOCK_SERVER_URL: `http://localhost:${dashboard.port}`,
|
|
6549
|
-
// Set PORT so initPloyForDev can construct the correct handler URL
|
|
6550
|
-
PORT: String(nextPort)
|
|
6551
|
-
}
|
|
6622
|
+
env: childEnv
|
|
6552
6623
|
});
|
|
6553
6624
|
} else {
|
|
6554
6625
|
nextProcess = spawn(nextBin, nextArgs, {
|
|
6555
6626
|
cwd: projectDir,
|
|
6556
6627
|
stdio: "inherit",
|
|
6557
6628
|
shell: true,
|
|
6558
|
-
env:
|
|
6559
|
-
...process.env,
|
|
6560
|
-
PLOY_MOCK_SERVER_URL: `http://localhost:${dashboard.port}`,
|
|
6561
|
-
PORT: String(nextPort)
|
|
6562
|
-
}
|
|
6629
|
+
env: childEnv
|
|
6563
6630
|
});
|
|
6564
6631
|
}
|
|
6565
6632
|
const cleanup = async () => {
|