@meetploy/cli 1.17.2 → 1.18.1
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.d.ts +1 -1
- package/dist/index.js +36 -16
- package/package.json +1 -1
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
|
};
|
|
@@ -6536,30 +6556,30 @@ async function startNextJsDev(options) {
|
|
|
6536
6556
|
nextArgs.push("-H", options.host);
|
|
6537
6557
|
}
|
|
6538
6558
|
console.log(` Starting Next.js dev server...`);
|
|
6559
|
+
const suppressWarning = "--disable-warning=ExperimentalWarning";
|
|
6560
|
+
const nodeOptions = process.env.NODE_OPTIONS ? `${process.env.NODE_OPTIONS} ${suppressWarning}` : suppressWarning;
|
|
6561
|
+
const childEnv = {
|
|
6562
|
+
...process.env,
|
|
6563
|
+
NODE_OPTIONS: nodeOptions,
|
|
6564
|
+
// Set environment variable so initPloyForDev knows the mock server URL
|
|
6565
|
+
PLOY_MOCK_SERVER_URL: `http://localhost:${dashboard.port}`,
|
|
6566
|
+
// Set PORT so initPloyForDev can construct the correct handler URL
|
|
6567
|
+
PORT: String(nextPort)
|
|
6568
|
+
};
|
|
6539
6569
|
let nextProcess;
|
|
6540
6570
|
if (nextBin.includes("npx")) {
|
|
6541
6571
|
nextProcess = spawn("npx", ["next", ...nextArgs], {
|
|
6542
6572
|
cwd: projectDir,
|
|
6543
6573
|
stdio: "inherit",
|
|
6544
6574
|
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
|
-
}
|
|
6575
|
+
env: childEnv
|
|
6552
6576
|
});
|
|
6553
6577
|
} else {
|
|
6554
6578
|
nextProcess = spawn(nextBin, nextArgs, {
|
|
6555
6579
|
cwd: projectDir,
|
|
6556
6580
|
stdio: "inherit",
|
|
6557
6581
|
shell: true,
|
|
6558
|
-
env:
|
|
6559
|
-
...process.env,
|
|
6560
|
-
PLOY_MOCK_SERVER_URL: `http://localhost:${dashboard.port}`,
|
|
6561
|
-
PORT: String(nextPort)
|
|
6562
|
-
}
|
|
6582
|
+
env: childEnv
|
|
6563
6583
|
});
|
|
6564
6584
|
}
|
|
6565
6585
|
const cleanup = async () => {
|