@cloudflare/autoconfig 0.2.6 → 0.2.8
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 +26 -33
- package/dist/metafile-esm.json +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { existsSync, writeFileSync, mkdirSync, readFileSync, promises as promise
|
|
|
4
4
|
import { readFile, writeFile, readdir, stat } from 'node:fs/promises';
|
|
5
5
|
import path8, { join, resolve, relative as relative$1 } from 'node:path';
|
|
6
6
|
import { blue, brandColor, dim } from '@cloudflare/cli-shared-helpers/colors';
|
|
7
|
-
import { UserError, FatalError, getInstalledPackageVersion,
|
|
7
|
+
import { UserError, FatalError, getInstalledPackageVersion, parseJSONC, isPackageInstalled, DEFAULT_COMPAT_DATE, NubPackageManager, NpmPackageManager, BunPackageManager, YarnPackageManager, PnpmPackageManager, getWorkerName, parsePackageJSON, readFileSync as readFileSync$1, checkWorkerNameValidity, isNodejsCompatDefaultOn } from '@cloudflare/workers-utils';
|
|
8
8
|
export { getInstalledPackageVersion } from '@cloudflare/workers-utils';
|
|
9
9
|
import { updateStatus, endSection } from '@cloudflare/cli-shared-helpers';
|
|
10
10
|
import { spinner } from '@cloudflare/cli-shared-helpers/interactive';
|
|
@@ -43764,7 +43764,7 @@ async function updateViteConfig(projectPath) {
|
|
|
43764
43764
|
} else {
|
|
43765
43765
|
throw new Error("Could not find Vite config file to modify");
|
|
43766
43766
|
}
|
|
43767
|
-
const compatDate =
|
|
43767
|
+
const compatDate = DEFAULT_COMPAT_DATE;
|
|
43768
43768
|
updateStatus(`Updating configuration in ${blue(viteConfigPath)}`);
|
|
43769
43769
|
transformFile(viteConfigPath, {
|
|
43770
43770
|
visitCallExpression: /* @__PURE__ */ __name(function(n) {
|
|
@@ -44990,7 +44990,7 @@ function updateViteConfigFile(projectPath) {
|
|
|
44990
44990
|
__name(updateViteConfigFile, "updateViteConfigFile");
|
|
44991
44991
|
function updateAppConfigFile(projectPath) {
|
|
44992
44992
|
const filePath = `app.config.${usesTypescript(projectPath) ? "ts" : "js"}`;
|
|
44993
|
-
const compatDate =
|
|
44993
|
+
const compatDate = DEFAULT_COMPAT_DATE;
|
|
44994
44994
|
updateStatus(`Updating configuration in ${blue(filePath)}`);
|
|
44995
44995
|
transformFile(filePath, {
|
|
44996
44996
|
visitCallExpression: /* @__PURE__ */ __name(function(n) {
|
|
@@ -52442,7 +52442,7 @@ async function runAutoConfig(autoConfigDetails, autoConfigOptions) {
|
|
|
52442
52442
|
autoConfigDetails.outputDir,
|
|
52443
52443
|
"The Output Directory is unexpectedly missing"
|
|
52444
52444
|
);
|
|
52445
|
-
const compatibilityDate =
|
|
52445
|
+
const compatibilityDate = DEFAULT_COMPAT_DATE;
|
|
52446
52446
|
const wranglerConfig = {
|
|
52447
52447
|
$schema: "node_modules/wrangler/config-schema.json",
|
|
52448
52448
|
name: autoConfigDetails.workerName,
|
|
@@ -52475,7 +52475,7 @@ async function runAutoConfig(autoConfigDetails, autoConfigOptions) {
|
|
|
52475
52475
|
const { npx } = packageManager;
|
|
52476
52476
|
const autoConfigSummary = await buildOperationsSummary(
|
|
52477
52477
|
{ ...autoConfigDetails, outputDir: autoConfigDetails.outputDir },
|
|
52478
|
-
dryRunConfigurationResults.wranglerConfig === null ? null :
|
|
52478
|
+
dryRunConfigurationResults.wranglerConfig === null ? null : ensureNodejsCompatIsEnabled({
|
|
52479
52479
|
...wranglerConfig,
|
|
52480
52480
|
...dryRunConfigurationResults.wranglerConfig
|
|
52481
52481
|
}),
|
|
@@ -52539,13 +52539,10 @@ ${JSON.stringify(autoConfigDetails, null, 2)}...`
|
|
|
52539
52539
|
);
|
|
52540
52540
|
}
|
|
52541
52541
|
if (configurationResults.wranglerConfig !== null) {
|
|
52542
|
-
await saveWranglerJsonc(
|
|
52543
|
-
|
|
52544
|
-
|
|
52545
|
-
|
|
52546
|
-
...configurationResults.wranglerConfig
|
|
52547
|
-
})
|
|
52548
|
-
);
|
|
52542
|
+
await saveWranglerJsonc(autoConfigDetails.projectPath, {
|
|
52543
|
+
...wranglerConfig,
|
|
52544
|
+
...configurationResults.wranglerConfig
|
|
52545
|
+
});
|
|
52549
52546
|
}
|
|
52550
52547
|
maybeAppendWranglerToGitIgnore(autoConfigDetails.projectPath);
|
|
52551
52548
|
if (autoConfigDetails.outputDir === autoConfigDetails.projectPath) {
|
|
@@ -52564,21 +52561,20 @@ ${JSON.stringify(autoConfigDetails, null, 2)}...`
|
|
|
52564
52561
|
return autoConfigSummary;
|
|
52565
52562
|
}
|
|
52566
52563
|
__name(runAutoConfig, "runAutoConfig");
|
|
52567
|
-
function
|
|
52568
|
-
|
|
52569
|
-
|
|
52564
|
+
function ensureNodejsCompatIsEnabled(wranglerConfig) {
|
|
52565
|
+
const flags = (wranglerConfig.compatibility_flags ?? []).filter(
|
|
52566
|
+
(flag) => !flag.startsWith("nodejs_")
|
|
52567
|
+
);
|
|
52568
|
+
if (!isNodejsCompatDefaultOn(wranglerConfig.compatibility_date)) {
|
|
52569
|
+
flags.push("nodejs_compat");
|
|
52570
52570
|
}
|
|
52571
|
-
|
|
52572
|
-
...wranglerConfig
|
|
52573
|
-
|
|
52574
|
-
|
|
52575
|
-
|
|
52576
|
-
) ?? [],
|
|
52577
|
-
"nodejs_compat"
|
|
52578
|
-
]
|
|
52579
|
-
};
|
|
52571
|
+
if (flags.length === 0) {
|
|
52572
|
+
const { compatibility_flags: _removed, ...rest } = wranglerConfig;
|
|
52573
|
+
return rest;
|
|
52574
|
+
}
|
|
52575
|
+
return { ...wranglerConfig, compatibility_flags: flags };
|
|
52580
52576
|
}
|
|
52581
|
-
__name(
|
|
52577
|
+
__name(ensureNodejsCompatIsEnabled, "ensureNodejsCompatIsEnabled");
|
|
52582
52578
|
async function saveWranglerJsonc(projectPath, wranglerConfig) {
|
|
52583
52579
|
let existingWranglerConfig = {};
|
|
52584
52580
|
const wranglerConfigPath = getDirWranglerJsonConfigPath(projectPath);
|
|
@@ -52589,16 +52585,13 @@ async function saveWranglerJsonc(projectPath, wranglerConfig) {
|
|
|
52589
52585
|
wranglerConfigPath
|
|
52590
52586
|
);
|
|
52591
52587
|
}
|
|
52588
|
+
const mergedWranglerConfig = ensureNodejsCompatIsEnabled({
|
|
52589
|
+
...existingWranglerConfig,
|
|
52590
|
+
...wranglerConfig
|
|
52591
|
+
});
|
|
52592
52592
|
await writeFile(
|
|
52593
52593
|
resolve(projectPath, "wrangler.jsonc"),
|
|
52594
|
-
JSON.stringify(
|
|
52595
|
-
{
|
|
52596
|
-
...existingWranglerConfig,
|
|
52597
|
-
...wranglerConfig
|
|
52598
|
-
},
|
|
52599
|
-
null,
|
|
52600
|
-
2
|
|
52601
|
-
) + "\n"
|
|
52594
|
+
JSON.stringify(mergedWranglerConfig, null, 2) + "\n"
|
|
52602
52595
|
);
|
|
52603
52596
|
}
|
|
52604
52597
|
__name(saveWranglerJsonc, "saveWranglerJsonc");
|