@cloudflare/autoconfig 0.2.6 → 0.2.7
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 +23 -30
- 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, getTodaysCompatDate, parseJSONC, isPackageInstalled, NubPackageManager, NpmPackageManager, BunPackageManager, YarnPackageManager, PnpmPackageManager, getWorkerName, parsePackageJSON, readFileSync as readFileSync$1, checkWorkerNameValidity } from '@cloudflare/workers-utils';
|
|
7
|
+
import { UserError, FatalError, getInstalledPackageVersion, getTodaysCompatDate, parseJSONC, isPackageInstalled, 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';
|
|
@@ -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");
|