@meetploy/cli 1.10.0 → 1.11.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.
- package/dist/index.js +46 -5
- 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,
|
|
@@ -3937,17 +3974,21 @@ function readExistingWranglerConfig(cwd) {
|
|
|
3937
3974
|
}
|
|
3938
3975
|
return {};
|
|
3939
3976
|
}
|
|
3940
|
-
function runWranglerBuild(entrypoint) {
|
|
3977
|
+
function runWranglerBuild(entrypoint, ployConfig) {
|
|
3941
3978
|
return new Promise((resolve, reject) => {
|
|
3942
3979
|
const cwd = process.cwd();
|
|
3943
3980
|
const packageManager = detectPackageManager();
|
|
3944
3981
|
const existingConfig = readExistingWranglerConfig(cwd);
|
|
3945
3982
|
const relativeEntrypoint = relative(cwd, entrypoint);
|
|
3983
|
+
const compatibilityFlags = getCompatibilityFlags(ployConfig);
|
|
3984
|
+
const compatibilityDate = getCompatibilityDate(ployConfig);
|
|
3946
3985
|
const wranglerConfig = {
|
|
3947
3986
|
...existingConfig,
|
|
3948
3987
|
main: relativeEntrypoint,
|
|
3949
|
-
//
|
|
3950
|
-
compatibility_date: existingConfig.compatibility_date ||
|
|
3988
|
+
// Use compatibility date from config, or from existing wrangler config, or default
|
|
3989
|
+
compatibility_date: existingConfig.compatibility_date || compatibilityDate,
|
|
3990
|
+
// Use compatibility flags from config, or defaults if not set in existing config
|
|
3991
|
+
compatibility_flags: existingConfig.compatibility_flags || compatibilityFlags
|
|
3951
3992
|
};
|
|
3952
3993
|
const tempConfigPath = join(cwd, ".wrangler-ploy-build.json");
|
|
3953
3994
|
writeFileSync(tempConfigPath, JSON.stringify(wranglerConfig, null, " "));
|
|
@@ -4000,7 +4041,7 @@ async function buildCommand(options = {}) {
|
|
|
4000
4041
|
const entrypoint = getWorkerEntryPoint(cwd, config);
|
|
4001
4042
|
console.log(`Using entrypoint: ${relative(cwd, entrypoint)}`);
|
|
4002
4043
|
console.log("");
|
|
4003
|
-
await runWranglerBuild(entrypoint);
|
|
4044
|
+
await runWranglerBuild(entrypoint, config);
|
|
4004
4045
|
}
|
|
4005
4046
|
function parseBuildArgs(args2) {
|
|
4006
4047
|
const options = {};
|