@meetploy/cli 1.9.0 → 1.10.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.
Files changed (2) hide show
  1. package/dist/index.js +44 -8
  2. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire } from 'module';
3
3
  import { mkdir, writeFile, readFile, chmod, access } from 'fs/promises';
4
- import { join, dirname } from 'path';
5
- import { existsSync, readFileSync, readFile as readFile$1, mkdirSync, writeFileSync } from 'fs';
4
+ import { join, dirname, relative } from 'path';
5
+ import { existsSync, readFileSync, writeFileSync, unlinkSync, readFile as readFile$1, mkdirSync } from 'fs';
6
6
  import { promisify } from 'util';
7
7
  import { parse } from 'yaml';
8
8
  import { build } from 'esbuild';
@@ -3923,31 +3923,64 @@ function detectPackageManager() {
3923
3923
  }
3924
3924
  return "npm";
3925
3925
  }
3926
- function runWranglerBuild() {
3926
+ function readExistingWranglerConfig(cwd) {
3927
+ const jsonPath = join(cwd, "wrangler.json");
3928
+ const jsoncPath = join(cwd, "wrangler.jsonc");
3929
+ if (existsSync(jsonPath)) {
3930
+ const content = readFileSync(jsonPath, "utf-8");
3931
+ return JSON.parse(content);
3932
+ }
3933
+ if (existsSync(jsoncPath)) {
3934
+ const content = readFileSync(jsoncPath, "utf-8");
3935
+ const stripped = content.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
3936
+ return JSON.parse(stripped);
3937
+ }
3938
+ return {};
3939
+ }
3940
+ function runWranglerBuild(entrypoint) {
3927
3941
  return new Promise((resolve, reject) => {
3942
+ const cwd = process.cwd();
3928
3943
  const packageManager = detectPackageManager();
3944
+ const existingConfig = readExistingWranglerConfig(cwd);
3945
+ const relativeEntrypoint = relative(cwd, entrypoint);
3946
+ const wranglerConfig = {
3947
+ ...existingConfig,
3948
+ main: relativeEntrypoint,
3949
+ // Ensure compatibility_date is set if not already
3950
+ compatibility_date: existingConfig.compatibility_date || "2025-01-01"
3951
+ };
3952
+ const tempConfigPath = join(cwd, ".wrangler-ploy-build.json");
3953
+ writeFileSync(tempConfigPath, JSON.stringify(wranglerConfig, null, " "));
3929
3954
  let command2;
3930
3955
  let args2;
3931
3956
  if (packageManager === "npm") {
3932
3957
  command2 = "npx";
3933
- args2 = ["wrangler", "build"];
3958
+ args2 = ["wrangler", "build", "--config", tempConfigPath];
3934
3959
  } else if (packageManager === "yarn") {
3935
3960
  command2 = "yarn";
3936
- args2 = ["wrangler", "build"];
3961
+ args2 = ["wrangler", "build", "--config", tempConfigPath];
3937
3962
  } else {
3938
3963
  command2 = "pnpm";
3939
- args2 = ["wrangler", "build"];
3964
+ args2 = ["wrangler", "build", "--config", tempConfigPath];
3940
3965
  }
3941
3966
  console.log(`Running: ${command2} ${args2.join(" ")}`);
3942
3967
  const child = spawn(command2, args2, {
3943
- cwd: process.cwd(),
3968
+ cwd,
3944
3969
  stdio: "inherit",
3945
3970
  shell: process.platform === "win32"
3946
3971
  });
3947
3972
  child.on("error", (error2) => {
3973
+ try {
3974
+ unlinkSync(tempConfigPath);
3975
+ } catch {
3976
+ }
3948
3977
  reject(new Error(`Failed to run wrangler build: ${error2.message}`));
3949
3978
  });
3950
3979
  child.on("close", (code) => {
3980
+ try {
3981
+ unlinkSync(tempConfigPath);
3982
+ } catch {
3983
+ }
3951
3984
  if (code === 0) {
3952
3985
  resolve();
3953
3986
  } else {
@@ -3964,7 +3997,10 @@ async function buildCommand(options = {}) {
3964
3997
  validatePloyConfig(config, configFile);
3965
3998
  console.log("Configuration valid.");
3966
3999
  console.log("");
3967
- await runWranglerBuild();
4000
+ const entrypoint = getWorkerEntryPoint(cwd, config);
4001
+ console.log(`Using entrypoint: ${relative(cwd, entrypoint)}`);
4002
+ console.log("");
4003
+ await runWranglerBuild(entrypoint);
3968
4004
  }
3969
4005
  function parseBuildArgs(args2) {
3970
4006
  const options = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetploy/cli",
3
- "version": "1.9.0",
3
+ "version": "1.10.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",
@@ -49,6 +49,7 @@
49
49
  "@meetploy/emulator": "*",
50
50
  "@meetploy/tools": "*",
51
51
  "@types/better-sqlite3": "^7.6.12",
52
+ "api": "*",
52
53
  "openapi-typescript": "7.8.0",
53
54
  "tsup": "^8.0.0"
54
55
  }