@farm.js/cli 0.1.0-beta.57 → 0.1.0-beta.58
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 +28 -18
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -19
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -429,8 +429,9 @@ async function deployNetlify(root, outputDir, site) {
|
|
|
429
429
|
function formatCommand$1(executable, args) {
|
|
430
430
|
return [executable, ...args].map(formatCommandArgument).join(" ");
|
|
431
431
|
}
|
|
432
|
+
const SAFE_ARGUMENT = process.platform === "win32" ? /^[A-Za-z0-9_.\\/:=@+-]+$/ : /^[A-Za-z0-9_./:=@+-]+$/;
|
|
432
433
|
function formatCommandArgument(argument) {
|
|
433
|
-
if (
|
|
434
|
+
if (SAFE_ARGUMENT.test(argument)) return argument;
|
|
434
435
|
return `'${argument.replace(/'/g, `'"'"'`)}'`;
|
|
435
436
|
}
|
|
436
437
|
function getErrorMessage(error) {
|
|
@@ -1376,18 +1377,18 @@ function renderPrismaModel(model) {
|
|
|
1376
1377
|
const defaultAttribute = getPrismaDefaultAttribute(field);
|
|
1377
1378
|
if (defaultAttribute) attributes.push(defaultAttribute);
|
|
1378
1379
|
if (field.meta?.autoUpdate && field.type === "datetime") attributes.push("@updatedAt");
|
|
1379
|
-
if (field.name !== fieldKey) attributes.push(`@map("${
|
|
1380
|
+
if (field.name !== fieldKey) attributes.push(`@map("${escapeDoubleQuoted(field.name)}")`);
|
|
1380
1381
|
if (attributes.length) parts.push(attributes.join(" "));
|
|
1381
1382
|
lines.push(` ${parts.join(" ")}`);
|
|
1382
|
-
if (field.index) modelLevelConstraints.push(`@@index([${fieldKey}], map: "${
|
|
1383
|
+
if (field.index) modelLevelConstraints.push(`@@index([${fieldKey}], map: "${escapeDoubleQuoted(`${model.modelName}_${field.name}_idx`)}")`);
|
|
1383
1384
|
}
|
|
1384
1385
|
for (const constraint of model.model.constraints || []) {
|
|
1385
1386
|
const fields = constraint.fields.join(", ");
|
|
1386
1387
|
const attribute = constraint.type === "unique" ? "@@unique" : "@@index";
|
|
1387
|
-
const suffix = constraint.name ? `, map: "${
|
|
1388
|
+
const suffix = constraint.name ? `, map: "${escapeDoubleQuoted(constraint.name)}"` : "";
|
|
1388
1389
|
modelLevelConstraints.push(`${attribute}([${fields}]${suffix})`);
|
|
1389
1390
|
}
|
|
1390
|
-
lines.push(` @@map("${
|
|
1391
|
+
lines.push(` @@map("${escapeDoubleQuoted(model.modelName)}")`);
|
|
1391
1392
|
for (const constraint of modelLevelConstraints) lines.push(` ${constraint}`);
|
|
1392
1393
|
lines.push("}");
|
|
1393
1394
|
return lines.join("\n");
|
|
@@ -1405,7 +1406,7 @@ function getPrismaFieldType(field) {
|
|
|
1405
1406
|
function getPrismaDefaultAttribute(field) {
|
|
1406
1407
|
if (field.default === void 0) return null;
|
|
1407
1408
|
if (field.type === "datetime" && field.default === "now") return "@default(now())";
|
|
1408
|
-
if (typeof field.default === "string") return `@default("${
|
|
1409
|
+
if (typeof field.default === "string") return `@default("${escapeDoubleQuoted(field.default)}")`;
|
|
1409
1410
|
if (typeof field.default === "number" || typeof field.default === "boolean") return `@default(${String(field.default)})`;
|
|
1410
1411
|
return null;
|
|
1411
1412
|
}
|
|
@@ -1443,12 +1444,12 @@ function renderDrizzleModel(model, dialect, tableFactoryName) {
|
|
|
1443
1444
|
lines.push(` ${fieldKey}: ${renderDrizzleColumn(field, dialect)},`);
|
|
1444
1445
|
}
|
|
1445
1446
|
lines.push("}, (table) => ({");
|
|
1446
|
-
for (const [fieldKey, field] of Object.entries(model.model.fields)) if (field.index) lines.push(` ${fieldKey}Idx: index("${
|
|
1447
|
+
for (const [fieldKey, field] of Object.entries(model.model.fields)) if (field.index) lines.push(` ${fieldKey}Idx: index("${escapeDoubleQuoted(`${model.modelName}_${field.name}_idx`)}").on(table.${fieldKey}),`);
|
|
1447
1448
|
for (const constraint of model.model.constraints || []) {
|
|
1448
1449
|
const builder = constraint.type === "unique" ? "uniqueIndex" : "index";
|
|
1449
1450
|
const accessor = constraint.fields.map((fieldKey) => `table.${fieldKey}`).join(", ");
|
|
1450
1451
|
const name = constraint.name || `${model.modelName}_${constraint.fields.map((fieldKey) => model.model.fields[fieldKey]?.name || fieldKey).join("_")}_${constraint.type}`;
|
|
1451
|
-
lines.push(` ${toCamelCase(name)}: ${builder}("${
|
|
1452
|
+
lines.push(` ${toCamelCase(name)}: ${builder}("${escapeDoubleQuoted(name)}").on(${accessor}),`);
|
|
1452
1453
|
}
|
|
1453
1454
|
lines.push("}));");
|
|
1454
1455
|
return lines.join("\n");
|
|
@@ -1526,7 +1527,7 @@ function renderSqliteDrizzleColumn(field) {
|
|
|
1526
1527
|
function getDrizzleDefaultExpression(field, dialect) {
|
|
1527
1528
|
if (field.default === void 0) return "";
|
|
1528
1529
|
if (field.type === "datetime" && field.default === "now") return dialect === "sqlite" ? "" : ".defaultNow()";
|
|
1529
|
-
if (typeof field.default === "string") return `.default("${
|
|
1530
|
+
if (typeof field.default === "string") return `.default("${escapeDoubleQuoted(field.default)}")`;
|
|
1530
1531
|
if (typeof field.default === "number" || typeof field.default === "boolean") return `.default(${String(field.default)})`;
|
|
1531
1532
|
return "";
|
|
1532
1533
|
}
|
|
@@ -1617,7 +1618,7 @@ function getSqlColumnType(field, dialect) {
|
|
|
1617
1618
|
function getSqlDefaultExpression(field, dialect) {
|
|
1618
1619
|
if (field.default === void 0) return null;
|
|
1619
1620
|
if (field.type === "datetime" && field.default === "now") return "CURRENT_TIMESTAMP";
|
|
1620
|
-
if (typeof field.default === "string") return `'${
|
|
1621
|
+
if (typeof field.default === "string") return `'${escapeSqlString(field.default)}'`;
|
|
1621
1622
|
if (typeof field.default === "number") return String(field.default);
|
|
1622
1623
|
if (typeof field.default === "boolean") {
|
|
1623
1624
|
if (dialect === "sqlite") return field.default ? "1" : "0";
|
|
@@ -1634,20 +1635,20 @@ function generateMongoBootstrap(models) {
|
|
|
1634
1635
|
];
|
|
1635
1636
|
for (const model of models) {
|
|
1636
1637
|
lines.push(` // Integration "${model.integrationKey}" model "${model.modelKey}"`);
|
|
1637
|
-
lines.push(` const ${model.exportName} = db.collection("${
|
|
1638
|
+
lines.push(` const ${model.exportName} = db.collection("${escapeDoubleQuoted(model.modelName)}");`);
|
|
1638
1639
|
for (const [fieldKey, field] of Object.entries(model.model.fields)) {
|
|
1639
1640
|
if (field.unique) {
|
|
1640
1641
|
const options = ["unique: true"];
|
|
1641
1642
|
if (isNullableField(field)) options.push("sparse: true");
|
|
1642
|
-
options.push(`name: "${
|
|
1643
|
+
options.push(`name: "${escapeDoubleQuoted(`${model.modelName}_${field.name}_unique`)}"`);
|
|
1643
1644
|
lines.push(` await ${model.exportName}.createIndex({ ${JSON.stringify(field.name)}: 1 }, { ${options.join(", ")} });`);
|
|
1644
|
-
} else if (field.index) lines.push(` await ${model.exportName}.createIndex({ ${JSON.stringify(field.name)}: 1 }, { name: "${
|
|
1645
|
+
} else if (field.index) lines.push(` await ${model.exportName}.createIndex({ ${JSON.stringify(field.name)}: 1 }, { name: "${escapeDoubleQuoted(`${model.modelName}_${field.name}_idx`)}" });`);
|
|
1645
1646
|
if (field.reference) lines.push(` // ${fieldKey} references ${field.reference.model}.${field.reference.field}${field.reference.onDelete ? ` (onDelete: ${field.reference.onDelete})` : ""}`);
|
|
1646
1647
|
}
|
|
1647
1648
|
for (const constraint of model.model.constraints || []) {
|
|
1648
1649
|
const indexSpec = constraint.fields.map((fieldKey) => `${JSON.stringify(model.model.fields[fieldKey]?.name || fieldKey)}: 1`).join(", ");
|
|
1649
1650
|
const indexName = constraint.name || `${model.modelName}_${constraint.fields.map((fieldKey) => model.model.fields[fieldKey]?.name || fieldKey).join("_")}_${constraint.type}`;
|
|
1650
|
-
const options = constraint.type === "unique" ? `{ unique: true, name: "${
|
|
1651
|
+
const options = constraint.type === "unique" ? `{ unique: true, name: "${escapeDoubleQuoted(indexName)}" }` : `{ name: "${escapeDoubleQuoted(indexName)}" }`;
|
|
1651
1652
|
lines.push(` await ${model.exportName}.createIndex({ ${indexSpec} }, ${options});`);
|
|
1652
1653
|
}
|
|
1653
1654
|
lines.push("");
|
|
@@ -1679,8 +1680,11 @@ function toCamelCase(value) {
|
|
|
1679
1680
|
const pascal = toPascalCase(value);
|
|
1680
1681
|
return pascal ? pascal.charAt(0).toLowerCase() + pascal.slice(1) : pascal;
|
|
1681
1682
|
}
|
|
1682
|
-
function
|
|
1683
|
-
return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")
|
|
1683
|
+
function escapeDoubleQuoted(value) {
|
|
1684
|
+
return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
1685
|
+
}
|
|
1686
|
+
function escapeSqlString(value) {
|
|
1687
|
+
return value.replace(/'/g, "''");
|
|
1684
1688
|
}
|
|
1685
1689
|
function escapeRegExp$1(value) {
|
|
1686
1690
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
@@ -1790,6 +1794,10 @@ async function fetchLiveSnapshot(baseUrl, options) {
|
|
|
1790
1794
|
clearTimeout(timeout);
|
|
1791
1795
|
}
|
|
1792
1796
|
}
|
|
1797
|
+
/** Reported paths are shown to the user, so keep them POSIX on every platform. */
|
|
1798
|
+
function toPosix$1(value) {
|
|
1799
|
+
return value.split(path.sep).join("/");
|
|
1800
|
+
}
|
|
1793
1801
|
function createLiveReport(snapshot, baseUrl, now) {
|
|
1794
1802
|
const checks = [
|
|
1795
1803
|
{
|
|
@@ -1873,7 +1881,7 @@ async function createProjectReport(root, options) {
|
|
|
1873
1881
|
status: "pass",
|
|
1874
1882
|
code: "CONFIG_VALID",
|
|
1875
1883
|
title: "Farm config loads successfully",
|
|
1876
|
-
message: configFile ? path.relative(root, configFile) || path.basename(configFile) : "Resolved config"
|
|
1884
|
+
message: configFile ? toPosix$1(path.relative(root, configFile)) || path.basename(configFile) : "Resolved config"
|
|
1877
1885
|
});
|
|
1878
1886
|
}
|
|
1879
1887
|
} catch (error) {
|
|
@@ -1919,7 +1927,7 @@ function applySafeProjectFixes(root, config, checks) {
|
|
|
1919
1927
|
fixes.push({
|
|
1920
1928
|
code: "ROOT_LAYOUT_CREATED",
|
|
1921
1929
|
title: "Created the missing root layout",
|
|
1922
|
-
filePath: path.relative(root, layoutPath)
|
|
1930
|
+
filePath: toPosix$1(path.relative(root, layoutPath))
|
|
1923
1931
|
});
|
|
1924
1932
|
}
|
|
1925
1933
|
}
|
|
@@ -3352,6 +3360,6 @@ function formatError(error) {
|
|
|
3352
3360
|
return error instanceof Error ? error.message : String(error);
|
|
3353
3361
|
}
|
|
3354
3362
|
//#endregion
|
|
3355
|
-
export { FarmDeployError, FarmGeneratedArtifactsStaleError, FarmStartError, addFarmIntegration, buildFarm, createFarmDeployPlan, createFarmStartPlan, createFarmUpgradePlan, createFrameworkMigrationPlan, createGatewaySession, createPreviewGatewayPlan, createPreviewTunnelPlan, createServer, deployFarm, detectFarmPackageManager, explainFarmRoute, formatFarmCronJobs, formatFarmDeployPlan, formatFarmDoctorReport, formatFarmRouteExplanation, formatFarmUpgradePlan, forwardGatewayRequest, generateFarmArtifacts, getFarmTelemetryConfigFile, getFarmTelemetryStatus, inspectFrameworkMigrations, listFarmCronJobs, listFarmIntegrationProviders, loadFarmCronConfig, migrateFarm, migrateFarmAuth, parsePreviewPublicUrl, previewFarm, resolveCloudflareAgentDeployPlan, resolveFarmCreateAppTelemetryCommand, resolveFarmTelemetryCommand, resolvePreviewTarget, runFarmCronJob, runFarmDoctor, runNativePreviewTunnel, runPreviewGateway, setFarmTelemetryEnabled, showFarmTelemetryNotice, startDevServer, startFarm, startFarmCronScheduler, trackFarmCommand, trackFarmCreateAppCommand, trackFarmProjectCreated, upgradeFarm };
|
|
3363
|
+
export { FarmDeployError, FarmGeneratedArtifactsStaleError, FarmStartError, addFarmIntegration, buildFarm, createFarmDeployPlan, createFarmStartPlan, createFarmUpgradePlan, createFrameworkMigrationPlan, createGatewaySession, createPreviewGatewayPlan, createPreviewTunnelPlan, createServer, deployFarm, detectFarmPackageManager, escapeDoubleQuoted, escapeSqlString, explainFarmRoute, formatFarmCronJobs, formatFarmDeployPlan, formatFarmDoctorReport, formatFarmRouteExplanation, formatFarmUpgradePlan, forwardGatewayRequest, generateFarmArtifacts, getFarmTelemetryConfigFile, getFarmTelemetryStatus, inspectFrameworkMigrations, listFarmCronJobs, listFarmIntegrationProviders, loadFarmCronConfig, migrateFarm, migrateFarmAuth, parsePreviewPublicUrl, previewFarm, resolveCloudflareAgentDeployPlan, resolveFarmCreateAppTelemetryCommand, resolveFarmTelemetryCommand, resolvePreviewTarget, runFarmCronJob, runFarmDoctor, runNativePreviewTunnel, runPreviewGateway, setFarmTelemetryEnabled, showFarmTelemetryNotice, startDevServer, startFarm, startFarmCronScheduler, trackFarmCommand, trackFarmCreateAppCommand, trackFarmProjectCreated, upgradeFarm };
|
|
3356
3364
|
|
|
3357
3365
|
//# sourceMappingURL=index.mjs.map
|