@meetploy/cli 1.10.0 → 1.11.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.
Files changed (2) hide show
  1. package/dist/index.js +97 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -60,6 +60,19 @@ var init_package_manager = __esm({
60
60
  "../tools/dist/package-manager.js"() {
61
61
  }
62
62
  });
63
+ function getCompatibilityFlags(config) {
64
+ if (!config.compatibility_flags || config.compatibility_flags.length === 0) {
65
+ return DEFAULT_COMPATIBILITY_FLAGS;
66
+ }
67
+ const allFlags = [
68
+ ...DEFAULT_COMPATIBILITY_FLAGS,
69
+ ...config.compatibility_flags
70
+ ];
71
+ return [...new Set(allFlags)];
72
+ }
73
+ function getCompatibilityDate(config) {
74
+ return config.compatibility_date || DEFAULT_COMPATIBILITY_DATE;
75
+ }
63
76
  function validateBindings(bindings, bindingType, configFile) {
64
77
  if (bindings === void 0) {
65
78
  return;
@@ -124,6 +137,24 @@ function validatePloyConfig(config, configFile = "ploy.yaml", options = {}) {
124
137
  if (config.monorepo !== void 0 && typeof config.monorepo !== "boolean") {
125
138
  throw new Error(`'monorepo' in ${configFile} must be a boolean`);
126
139
  }
140
+ if (config.compatibility_flags !== void 0) {
141
+ if (!Array.isArray(config.compatibility_flags)) {
142
+ throw new Error(`'compatibility_flags' in ${configFile} must be an array of strings`);
143
+ }
144
+ for (const flag of config.compatibility_flags) {
145
+ if (typeof flag !== "string") {
146
+ throw new Error(`'compatibility_flags' in ${configFile} must contain only strings`);
147
+ }
148
+ }
149
+ }
150
+ if (config.compatibility_date !== void 0) {
151
+ if (typeof config.compatibility_date !== "string") {
152
+ throw new Error(`'compatibility_date' in ${configFile} must be a string in YYYY-MM-DD format`);
153
+ }
154
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(config.compatibility_date)) {
155
+ throw new Error(`'compatibility_date' in ${configFile} must be in YYYY-MM-DD format (e.g., 2025-04-02)`);
156
+ }
157
+ }
127
158
  return validatedConfig;
128
159
  }
129
160
  async function readPloyConfig(projectDir, configPath) {
@@ -183,10 +214,12 @@ function getWorkerEntryPoint(projectDir, config) {
183
214
  }
184
215
  throw new Error("Could not find worker entry point. Specify 'main' in ploy.yaml");
185
216
  }
186
- var readFileAsync, BINDING_NAME_REGEX, RESOURCE_NAME_REGEX;
217
+ var readFileAsync, DEFAULT_COMPATIBILITY_FLAGS, DEFAULT_COMPATIBILITY_DATE, BINDING_NAME_REGEX, RESOURCE_NAME_REGEX;
187
218
  var init_ploy_config = __esm({
188
219
  "../tools/dist/ploy-config.js"() {
189
220
  readFileAsync = promisify(readFile$1);
221
+ DEFAULT_COMPATIBILITY_FLAGS = ["nodejs_compat_v2"];
222
+ DEFAULT_COMPATIBILITY_DATE = "2025-04-02";
190
223
  BINDING_NAME_REGEX = /^[A-Z][A-Z0-9_]*$/;
191
224
  RESOURCE_NAME_REGEX = /^[a-z][a-z0-9_]*$/;
192
225
  }
@@ -195,7 +228,11 @@ var init_ploy_config = __esm({
195
228
  // ../tools/dist/cli.js
196
229
  var cli_exports = {};
197
230
  __export(cli_exports, {
231
+ DEFAULT_COMPATIBILITY_DATE: () => DEFAULT_COMPATIBILITY_DATE,
232
+ DEFAULT_COMPATIBILITY_FLAGS: () => DEFAULT_COMPATIBILITY_FLAGS,
198
233
  getAddDevDependencyCommand: () => getAddDevDependencyCommand,
234
+ getCompatibilityDate: () => getCompatibilityDate,
235
+ getCompatibilityFlags: () => getCompatibilityFlags,
199
236
  getRunCommand: () => getRunCommand,
200
237
  getWorkerEntryPoint: () => getWorkerEntryPoint,
201
238
  hasBindings: () => hasBindings,
@@ -944,7 +981,11 @@ async function bundleWorker(options) {
944
981
  outfile: bundlePath,
945
982
  minify: false,
946
983
  sourcemap: false,
947
- external: ["cloudflare:*"],
984
+ external: [
985
+ "cloudflare:*",
986
+ "node:*",
987
+ ...NODE_BUILTINS
988
+ ],
948
989
  alias: {
949
990
  __ploy_user_worker__: entryPoint
950
991
  },
@@ -955,11 +996,55 @@ async function bundleWorker(options) {
955
996
  await build(buildOptions);
956
997
  return bundlePath;
957
998
  }
999
+ var NODE_BUILTINS;
958
1000
  var init_bundler = __esm({
959
1001
  "../emulator/dist/bundler/bundler.js"() {
960
1002
  init_db_runtime();
961
1003
  init_queue_runtime();
962
1004
  init_workflow_runtime();
1005
+ NODE_BUILTINS = [
1006
+ "assert",
1007
+ "async_hooks",
1008
+ "buffer",
1009
+ "child_process",
1010
+ "cluster",
1011
+ "console",
1012
+ "constants",
1013
+ "crypto",
1014
+ "dgram",
1015
+ "diagnostics_channel",
1016
+ "dns",
1017
+ "domain",
1018
+ "events",
1019
+ "fs",
1020
+ "http",
1021
+ "http2",
1022
+ "https",
1023
+ "inspector",
1024
+ "module",
1025
+ "net",
1026
+ "os",
1027
+ "path",
1028
+ "perf_hooks",
1029
+ "process",
1030
+ "punycode",
1031
+ "querystring",
1032
+ "readline",
1033
+ "repl",
1034
+ "stream",
1035
+ "string_decoder",
1036
+ "sys",
1037
+ "timers",
1038
+ "tls",
1039
+ "trace_events",
1040
+ "tty",
1041
+ "url",
1042
+ "util",
1043
+ "v8",
1044
+ "vm",
1045
+ "worker_threads",
1046
+ "zlib"
1047
+ ];
963
1048
  }
964
1049
  });
965
1050
  function createFileWatcher(srcDir, onRebuild) {
@@ -3937,17 +4022,23 @@ function readExistingWranglerConfig(cwd) {
3937
4022
  }
3938
4023
  return {};
3939
4024
  }
3940
- function runWranglerBuild(entrypoint) {
4025
+ function runWranglerBuild(entrypoint, ployConfig) {
3941
4026
  return new Promise((resolve, reject) => {
3942
4027
  const cwd = process.cwd();
3943
4028
  const packageManager = detectPackageManager();
3944
4029
  const existingConfig = readExistingWranglerConfig(cwd);
3945
4030
  const relativeEntrypoint = relative(cwd, entrypoint);
4031
+ const compatibilityFlags = getCompatibilityFlags(ployConfig);
4032
+ const compatibilityDate = getCompatibilityDate(ployConfig);
3946
4033
  const wranglerConfig = {
3947
4034
  ...existingConfig,
4035
+ // Wrangler requires a name, use placeholder since ploy build doesn't deploy
4036
+ name: existingConfig.name || "ploy-build",
3948
4037
  main: relativeEntrypoint,
3949
- // Ensure compatibility_date is set if not already
3950
- compatibility_date: existingConfig.compatibility_date || "2025-01-01"
4038
+ // Use compatibility date from config, or from existing wrangler config, or default
4039
+ compatibility_date: existingConfig.compatibility_date || compatibilityDate,
4040
+ // Use compatibility flags from config, or defaults if not set in existing config
4041
+ compatibility_flags: existingConfig.compatibility_flags || compatibilityFlags
3951
4042
  };
3952
4043
  const tempConfigPath = join(cwd, ".wrangler-ploy-build.json");
3953
4044
  writeFileSync(tempConfigPath, JSON.stringify(wranglerConfig, null, " "));
@@ -4000,7 +4091,7 @@ async function buildCommand(options = {}) {
4000
4091
  const entrypoint = getWorkerEntryPoint(cwd, config);
4001
4092
  console.log(`Using entrypoint: ${relative(cwd, entrypoint)}`);
4002
4093
  console.log("");
4003
- await runWranglerBuild(entrypoint);
4094
+ await runWranglerBuild(entrypoint, config);
4004
4095
  }
4005
4096
  function parseBuildArgs(args2) {
4006
4097
  const options = {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetploy/cli",
3
- "version": "1.10.0",
3
+ "version": "1.11.1",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",