@cedarjs/cli 2.2.1-next.0 → 2.2.1-rc.23
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/cfw.js +2 -2
- package/dist/commands/buildHandler.js +1 -1
- package/dist/commands/consoleHandler.js +1 -1
- package/dist/commands/deploy/baremetal/baremetalHandler.js +2 -2
- package/dist/commands/deploy/flightcontrolHandler.js +7 -7
- package/dist/commands/deploy/packing/nft.js +12 -7
- package/dist/commands/deploy/renderHandler.js +4 -4
- package/dist/commands/deploy/serverlessHandler.js +2 -2
- package/dist/commands/dev.js +2 -1
- package/dist/commands/devHandler.js +28 -19
- package/dist/commands/experimental/setupOpentelemetryHandler.js +2 -2
- package/dist/commands/experimental/setupReactCompilerHandler.js +6 -3
- package/dist/commands/experimental/setupRscHandler.js +2 -2
- package/dist/commands/experimental/setupStreamingSsrHandler.js +3 -3
- package/dist/commands/experimental/util.js +2 -2
- package/dist/commands/generate/dataMigration/dataMigration.js +2 -2
- package/dist/commands/generate/dbAuth/dbAuthHandler.js +2 -2
- package/dist/commands/generate/scaffold/scaffoldHandler.js +1 -1
- package/dist/commands/prerenderHandler.js +1 -1
- package/dist/commands/prismaHandler.js +1 -1
- package/dist/commands/serve.js +1 -1
- package/dist/commands/setup/auth/auth.js +4 -4
- package/dist/commands/setup/cache/cacheHandler.js +1 -1
- package/dist/commands/setup/deploy/helpers/index.js +1 -1
- package/dist/commands/setup/deploy/providers/coherenceHandler.js +1 -1
- package/dist/commands/setup/deploy/providers/flightcontrolHandler.js +1 -1
- package/dist/commands/setup/deploy/providers/renderHandler.js +1 -1
- package/dist/commands/setup/deploy/providers/serverlessHandler.js +3 -4
- package/dist/commands/setup/deploy/templates/serverless/api.js +1 -1
- package/dist/commands/setup/docker/dockerHandler.js +12 -6
- package/dist/commands/setup/generator/generator.js +1 -1
- package/dist/commands/setup/generator/generatorHandler.js +2 -2
- package/dist/commands/setup/i18n/i18nHandler.js +1 -1
- package/dist/commands/setup/mailer/mailer.js +1 -1
- package/dist/commands/setup/mailer/mailerHandler.js +6 -4
- package/dist/commands/setup/middleware/ogImage/ogImageHandler.js +4 -2
- package/dist/commands/setup/monitoring/sentry/sentryHandler.js +1 -1
- package/dist/commands/setup/realtime/realtimeHandler.js +1 -1
- package/dist/commands/setup/server-file/serverFileHandler.js +1 -1
- package/dist/commands/setup/ui/libraries/mantineHandler.js +12 -11
- package/dist/commands/setup/uploads/uploadsHandler.js +1 -1
- package/dist/commands/setup/vite/viteHandler.js +1 -1
- package/dist/commands/studioHandler.js +3 -3
- package/dist/commands/testHandler.js +1 -1
- package/dist/commands/upgrade.js +51 -35
- package/dist/index.js +1 -1
- package/dist/lib/background.js +2 -2
- package/dist/lib/configureStorybook.js +1 -1
- package/dist/lib/extendFile.js +1 -1
- package/dist/lib/generatePrismaClient.js +1 -1
- package/dist/lib/index.js +1 -1
- package/dist/lib/locking.js +7 -3
- package/dist/lib/packages.js +3 -3
- package/dist/lib/plugin.js +1 -1
- package/dist/lib/ports.js +1 -1
- package/dist/lib/project.js +1 -1
- package/dist/lib/rollback.js +1 -1
- package/dist/lib/test.js +1 -1
- package/dist/lib/updateCheck.js +16 -8
- package/dist/telemetry/exporter.js +2 -2
- package/dist/telemetry/resource.js +3 -2
- package/dist/telemetry/send.js +7 -4
- package/dist/testLib/cells.js +1 -1
- package/dist/testLib/getRootPackageJSON.js +1 -1
- package/package.json +14 -15
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
1
2
|
import path from "node:path";
|
|
2
|
-
import fs from "fs-extra";
|
|
3
3
|
import { Listr } from "listr2";
|
|
4
4
|
import { format } from "prettier";
|
|
5
5
|
import { addWebPackages, getPrettierOptions } from "@cedarjs/cli-helpers";
|
|
@@ -7,7 +7,9 @@ import { getConfig, getPaths } from "@cedarjs/project-config";
|
|
|
7
7
|
import { runTransform } from "../../../../lib/runTransform.js";
|
|
8
8
|
async function handler({ force }) {
|
|
9
9
|
const rwPaths = getPaths();
|
|
10
|
-
const rootPkgJson =
|
|
10
|
+
const rootPkgJson = JSON.parse(
|
|
11
|
+
fs.readFileSync(path.join(rwPaths.base, "package.json"), "utf8")
|
|
12
|
+
);
|
|
11
13
|
const currentProjectVersion = rootPkgJson.devDependencies["@cedarjs/core"];
|
|
12
14
|
const notes = [""];
|
|
13
15
|
const tasks = new Listr(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
2
3
|
import execa from "execa";
|
|
3
|
-
import fse from "fs-extra";
|
|
4
4
|
import { Listr } from "listr2";
|
|
5
5
|
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
6
6
|
import c from "../../../../lib/colors.js";
|
|
@@ -38,8 +38,8 @@ async function handler({ force, install, packages }) {
|
|
|
38
38
|
install,
|
|
39
39
|
packages
|
|
40
40
|
});
|
|
41
|
-
const
|
|
42
|
-
const configFilePath = path.join(
|
|
41
|
+
const cedarPaths = getPaths();
|
|
42
|
+
const configFilePath = path.join(cedarPaths.web.config, "mantine.config.js");
|
|
43
43
|
const installPackages = (packages.includes(ALL_KEYWORD) ? ALL_MANTINE_PACKAGES : packages).map((pack) => `@mantine/${pack}`).concat("postcss", "postcss-preset-mantine", "postcss-simple-vars");
|
|
44
44
|
const tasks = new Listr(
|
|
45
45
|
[
|
|
@@ -69,8 +69,8 @@ async function handler({ force, install, packages }) {
|
|
|
69
69
|
},
|
|
70
70
|
{
|
|
71
71
|
title: "Setting up Mantine...",
|
|
72
|
-
skip: () => fileIncludes(
|
|
73
|
-
task: () => extendJSXFile(
|
|
72
|
+
skip: () => fileIncludes(cedarPaths.web.app, "MantineProvider"),
|
|
73
|
+
task: () => extendJSXFile(cedarPaths.web.app, {
|
|
74
74
|
insertComponent: {
|
|
75
75
|
name: "MantineProvider",
|
|
76
76
|
props: { theme: "theme" },
|
|
@@ -86,20 +86,21 @@ async function handler({ force, install, packages }) {
|
|
|
86
86
|
{
|
|
87
87
|
title: "Configuring PostCSS...",
|
|
88
88
|
task: () => {
|
|
89
|
-
const postCSSConfigPath =
|
|
90
|
-
if (!force &&
|
|
89
|
+
const postCSSConfigPath = cedarPaths.web.postcss;
|
|
90
|
+
if (!force && fs.existsSync(postCSSConfigPath)) {
|
|
91
91
|
throw new Error(
|
|
92
92
|
"PostCSS config already exists.\nUse --force to override existing config."
|
|
93
93
|
);
|
|
94
94
|
} else {
|
|
95
|
-
const postCSSConfig =
|
|
95
|
+
const postCSSConfig = fs.readFileSync(
|
|
96
96
|
path.join(
|
|
97
97
|
import.meta.dirname,
|
|
98
98
|
"../templates/mantine-postcss.config.cjs.template"
|
|
99
99
|
),
|
|
100
100
|
"utf-8"
|
|
101
101
|
);
|
|
102
|
-
|
|
102
|
+
fs.mkdirSync(path.dirname(postCSSConfigPath), { recursive: true });
|
|
103
|
+
return fs.writeFileSync(postCSSConfigPath, postCSSConfig);
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
106
|
},
|
|
@@ -113,7 +114,7 @@ async function handler({ force, install, packages }) {
|
|
|
113
114
|
},
|
|
114
115
|
{
|
|
115
116
|
title: "Configure Storybook...",
|
|
116
|
-
skip: () => fileIncludes(
|
|
117
|
+
skip: () => fileIncludes(cedarPaths.web.storybookPreviewConfig, "withMantine"),
|
|
117
118
|
task: async () => await extendStorybookConfiguration(
|
|
118
119
|
path.join(
|
|
119
120
|
import.meta.dirname,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
1
2
|
import path from "node:path";
|
|
2
|
-
import fs from "fs-extra";
|
|
3
3
|
import semver from "semver";
|
|
4
4
|
import { getPaths } from "@cedarjs/project-config";
|
|
5
5
|
import { isModuleInstalled, installModule } from "../lib/packages.js";
|
|
@@ -50,8 +50,8 @@ function assertRedwoodVersion(minVersions) {
|
|
|
50
50
|
process.exit(1);
|
|
51
51
|
}
|
|
52
52
|
function getProjectRedwoodVersion() {
|
|
53
|
-
const { devDependencies } =
|
|
54
|
-
path.join(getPaths().base, "package.json")
|
|
53
|
+
const { devDependencies } = JSON.parse(
|
|
54
|
+
fs.readFileSync(path.join(getPaths().base, "package.json"), "utf-8")
|
|
55
55
|
);
|
|
56
56
|
return devDependencies["@cedarjs/core"];
|
|
57
57
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
1
2
|
import path from "path";
|
|
2
3
|
import execa from "execa";
|
|
3
|
-
import fs from "fs-extra";
|
|
4
4
|
import { recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
|
5
5
|
import { ensurePosixPath } from "@cedarjs/project-config";
|
|
6
6
|
import { errorTelemetry, timedTelemetry } from "@cedarjs/telemetry";
|
package/dist/commands/upgrade.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
1
2
|
import { builtinModules } from "node:module";
|
|
2
3
|
import os from "node:os";
|
|
3
4
|
import path from "node:path";
|
|
4
5
|
import { ListrEnquirerPromptAdapter } from "@listr2/prompt-adapter-enquirer";
|
|
5
6
|
import execa from "execa";
|
|
6
|
-
import fs from "fs-extra";
|
|
7
7
|
import latestVersion from "latest-version";
|
|
8
8
|
import { Listr } from "listr2";
|
|
9
9
|
import semver from "semver";
|
|
@@ -238,18 +238,16 @@ const handler = async ({ dryRun, tag, verbose, dedupe, yes, force }) => {
|
|
|
238
238
|
await tasks.run();
|
|
239
239
|
if (preUpgradeError) {
|
|
240
240
|
console.error("");
|
|
241
|
-
console.error(`
|
|
242
|
-
|
|
243
|
-
console.error(" " + preUpgradeError.replace(/\n/g, "\n "));
|
|
241
|
+
console.error(` \u{1F6A8} ${c.error("Pre-upgrade Error:")}`);
|
|
242
|
+
console.error(" " + preUpgradeError.replace(/\n/g, "\n "));
|
|
244
243
|
if (!force) {
|
|
245
244
|
process.exit(1);
|
|
246
245
|
}
|
|
247
246
|
}
|
|
248
247
|
if (preUpgradeMessage) {
|
|
249
248
|
console.log("");
|
|
250
|
-
console.log(`
|
|
251
|
-
|
|
252
|
-
console.log(" " + preUpgradeMessage.replace(/\n/g, "\n "));
|
|
249
|
+
console.log(` \u{1F4E3} ${c.info("Pre-upgrade Message:")}`);
|
|
250
|
+
console.log(" " + preUpgradeMessage.replace(/\n/g, "\n "));
|
|
253
251
|
}
|
|
254
252
|
};
|
|
255
253
|
async function yarnInstall({ verbose }) {
|
|
@@ -274,7 +272,7 @@ async function removeCliCache(ctx, { dryRun, verbose }) {
|
|
|
274
272
|
console.log("Removing CLI cache at: ", cliCacheDir);
|
|
275
273
|
}
|
|
276
274
|
if (!dryRun) {
|
|
277
|
-
fs.
|
|
275
|
+
fs.rmSync(cliCacheDir, { recursive: true, force: true });
|
|
278
276
|
}
|
|
279
277
|
}
|
|
280
278
|
async function setLatestVersionToContext(ctx, tag) {
|
|
@@ -379,17 +377,18 @@ async function updatePackageVersionsFromTemplate(ctx, { dryRun, verbose }) {
|
|
|
379
377
|
const pkgJsonPath = path.join(basePath, "package.json");
|
|
380
378
|
return {
|
|
381
379
|
title: `Updating ${pkgJsonPath}`,
|
|
382
|
-
task: async () => {
|
|
380
|
+
task: async (_ctx, task) => {
|
|
383
381
|
const res = await fetch(url);
|
|
384
382
|
const text = await res.text();
|
|
385
383
|
const templatePackageJson = JSON.parse(text);
|
|
386
384
|
const localPackageJsonText = fs.readFileSync(pkgJsonPath, "utf-8");
|
|
387
385
|
const localPackageJson = JSON.parse(localPackageJsonText);
|
|
386
|
+
const messages = [];
|
|
388
387
|
Object.entries(templatePackageJson.dependencies || {}).forEach(
|
|
389
388
|
([depName, depVersion]) => {
|
|
390
389
|
if (!depName.startsWith("@cedarjs/")) {
|
|
391
390
|
if (verbose || dryRun) {
|
|
392
|
-
|
|
391
|
+
messages.push(
|
|
393
392
|
` - ${depName}: ${localPackageJson.dependencies[depName]} => ${depVersion}`
|
|
394
393
|
);
|
|
395
394
|
}
|
|
@@ -401,7 +400,7 @@ async function updatePackageVersionsFromTemplate(ctx, { dryRun, verbose }) {
|
|
|
401
400
|
([depName, depVersion]) => {
|
|
402
401
|
if (!depName.startsWith("@cedarjs/")) {
|
|
403
402
|
if (verbose || dryRun) {
|
|
404
|
-
|
|
403
|
+
messages.push(
|
|
405
404
|
` - ${depName}: ${localPackageJson.devDependencies[depName]} => ${depVersion}`
|
|
406
405
|
);
|
|
407
406
|
}
|
|
@@ -409,6 +408,9 @@ async function updatePackageVersionsFromTemplate(ctx, { dryRun, verbose }) {
|
|
|
409
408
|
}
|
|
410
409
|
}
|
|
411
410
|
);
|
|
411
|
+
if (messages.length > 0) {
|
|
412
|
+
task.title = task.title + "\n" + messages.join("\n");
|
|
413
|
+
}
|
|
412
414
|
if (!dryRun) {
|
|
413
415
|
fs.writeFileSync(
|
|
414
416
|
pkgJsonPath,
|
|
@@ -466,7 +468,7 @@ async function downloadYarnPatches(ctx, { dryRun, verbose }) {
|
|
|
466
468
|
console.log("Writing patch", patchPath);
|
|
467
469
|
}
|
|
468
470
|
if (!dryRun) {
|
|
469
|
-
await fs.writeFile(patchPath, patchMeta.content, "base64");
|
|
471
|
+
await fs.promises.writeFile(patchPath, patchMeta.content, "base64");
|
|
470
472
|
}
|
|
471
473
|
}
|
|
472
474
|
};
|
|
@@ -529,7 +531,7 @@ async function runPreUpgradeScripts(ctx, task, { verbose, force }) {
|
|
|
529
531
|
return;
|
|
530
532
|
}
|
|
531
533
|
const checkLevels = [];
|
|
532
|
-
if (parsed) {
|
|
534
|
+
if (parsed && !parsed.prerelease.length) {
|
|
533
535
|
checkLevels.push({
|
|
534
536
|
id: "exact",
|
|
535
537
|
candidates: [`${version}.ts`, `${version}/index.ts`]
|
|
@@ -545,10 +547,13 @@ async function runPreUpgradeScripts(ctx, task, { verbose, force }) {
|
|
|
545
547
|
id: "minor",
|
|
546
548
|
candidates: [`${parsed.major}.x.ts`, `${parsed.major}.x/index.ts`]
|
|
547
549
|
});
|
|
548
|
-
} else {
|
|
550
|
+
} else if (parsed && parsed.prerelease.length > 0) {
|
|
549
551
|
checkLevels.push({
|
|
550
552
|
id: "tag",
|
|
551
|
-
candidates: [
|
|
553
|
+
candidates: [
|
|
554
|
+
`${parsed.prerelease[0]}.ts`,
|
|
555
|
+
`${parsed.prerelease[0]}/index.ts`
|
|
556
|
+
]
|
|
552
557
|
});
|
|
553
558
|
}
|
|
554
559
|
const scriptsToRun = [];
|
|
@@ -570,8 +575,11 @@ async function runPreUpgradeScripts(ctx, task, { verbose, force }) {
|
|
|
570
575
|
ctx.preUpgradeError = "";
|
|
571
576
|
for (const scriptName of scriptsToRun) {
|
|
572
577
|
task.output = `Found upgrade check script: ${scriptName}. Downloading...`;
|
|
573
|
-
const tempDir = await fs.mkdtemp(
|
|
574
|
-
|
|
578
|
+
const tempDir = await fs.promises.mkdtemp(
|
|
579
|
+
// realpath: https://github.com/e18e/ecosystem-issues/issues/168
|
|
580
|
+
path.join(fs.realpathSync(os.tmpdir()), "cedar-upgrade-")
|
|
581
|
+
);
|
|
582
|
+
const scriptPath = path.join(tempDir, "script.mts");
|
|
575
583
|
const isDirectoryScript = scriptName.includes("/");
|
|
576
584
|
if (isDirectoryScript) {
|
|
577
585
|
const dirName = scriptName.split("/")[0];
|
|
@@ -597,9 +605,9 @@ async function runPreUpgradeScripts(ctx, task, { verbose, force }) {
|
|
|
597
605
|
}
|
|
598
606
|
const fileContent = await fileRes.text();
|
|
599
607
|
const filePath = path.join(tempDir, file.name);
|
|
600
|
-
await fs.writeFile(filePath, fileContent);
|
|
608
|
+
await fs.promises.writeFile(filePath, fileContent);
|
|
601
609
|
if (file.name === "index.ts") {
|
|
602
|
-
await fs.rename(filePath, scriptPath);
|
|
610
|
+
await fs.promises.rename(filePath, scriptPath);
|
|
603
611
|
}
|
|
604
612
|
}
|
|
605
613
|
}
|
|
@@ -619,7 +627,7 @@ async function runPreUpgradeScripts(ctx, task, { verbose, force }) {
|
|
|
619
627
|
throw new Error(`Failed to download script: ${res.statusText}`);
|
|
620
628
|
}
|
|
621
629
|
const scriptContent2 = await res.text();
|
|
622
|
-
await fs.writeFile(scriptPath, scriptContent2);
|
|
630
|
+
await fs.promises.writeFile(scriptPath, scriptContent2);
|
|
623
631
|
} catch (e) {
|
|
624
632
|
if (verbose) {
|
|
625
633
|
console.error(e);
|
|
@@ -627,49 +635,57 @@ async function runPreUpgradeScripts(ctx, task, { verbose, force }) {
|
|
|
627
635
|
throw new Error(`Failed to download upgrade script from ${scriptUrl}`);
|
|
628
636
|
}
|
|
629
637
|
}
|
|
630
|
-
const scriptContent = await fs.readFile(scriptPath, "utf8");
|
|
638
|
+
const scriptContent = await fs.promises.readFile(scriptPath, "utf8");
|
|
631
639
|
const deps = extractDependencies(scriptContent);
|
|
632
640
|
if (deps.length > 0) {
|
|
633
641
|
const depList = deps.join(", ");
|
|
634
642
|
task.output = `Installing dependencies for ${scriptName}: ${depList}...`;
|
|
635
|
-
await fs.
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
643
|
+
await fs.promises.writeFile(
|
|
644
|
+
path.join(tempDir, "package.json"),
|
|
645
|
+
JSON.stringify({
|
|
646
|
+
name: "pre-upgrade-script",
|
|
647
|
+
version: "0.0.0",
|
|
648
|
+
dependencies: {}
|
|
649
|
+
})
|
|
650
|
+
);
|
|
651
|
+
await execa("npm", ["install", ...deps], { cwd: tempDir });
|
|
641
652
|
}
|
|
642
653
|
task.output = `Running pre-upgrade script: ${scriptName}...`;
|
|
643
654
|
let shouldCleanup = true;
|
|
644
655
|
try {
|
|
645
656
|
const { stdout } = await execa(
|
|
646
657
|
"node",
|
|
647
|
-
["script.
|
|
658
|
+
["script.mts", "--verbose", verbose, "--force", force],
|
|
648
659
|
{ cwd: tempDir }
|
|
649
660
|
);
|
|
650
661
|
if (stdout) {
|
|
651
662
|
if (ctx.preUpgradeMessage) {
|
|
652
|
-
ctx.preUpgradeMessage += "\n
|
|
663
|
+
ctx.preUpgradeMessage += "\n";
|
|
653
664
|
}
|
|
654
665
|
ctx.preUpgradeMessage += `
|
|
655
666
|
${stdout}`;
|
|
656
667
|
}
|
|
657
668
|
} catch (e) {
|
|
658
669
|
const errorOutput = e.stdout || e.stderr || e.message || "";
|
|
659
|
-
const
|
|
660
|
-
${
|
|
670
|
+
const verboseErrorMessage = verbose ? `Pre-upgrade check ${scriptName} failed with exit code ${e.exitCode}:
|
|
671
|
+
${e.stderr ? e.stderr + "\n" : ""}` : "";
|
|
661
672
|
if (ctx.preUpgradeError) {
|
|
662
|
-
ctx.preUpgradeError += "\n
|
|
673
|
+
ctx.preUpgradeError += "\n";
|
|
663
674
|
}
|
|
664
|
-
|
|
675
|
+
if (verbose) {
|
|
676
|
+
ctx.preUpgradeError += `
|
|
677
|
+
${verboseErrorMessage}`;
|
|
678
|
+
}
|
|
679
|
+
ctx.preUpgradeError += `
|
|
680
|
+
${errorOutput}`;
|
|
665
681
|
if (!force) {
|
|
666
|
-
await fs.
|
|
682
|
+
await fs.promises.rm(tempDir, { recursive: true });
|
|
667
683
|
shouldCleanup = false;
|
|
668
684
|
return;
|
|
669
685
|
}
|
|
670
686
|
} finally {
|
|
671
687
|
if (shouldCleanup) {
|
|
672
|
-
await fs.
|
|
688
|
+
await fs.promises.rm(tempDir, { recursive: true });
|
|
673
689
|
}
|
|
674
690
|
}
|
|
675
691
|
}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import fs from "node:fs";
|
|
2
3
|
import path from "path";
|
|
3
4
|
import { trace, SpanStatusCode } from "@opentelemetry/api";
|
|
4
|
-
import fs from "fs-extra";
|
|
5
5
|
import { hideBin, Parser } from "yargs/helpers";
|
|
6
6
|
import yargs from "yargs/yargs";
|
|
7
7
|
import { loadEnvFiles, recordTelemetryAttributes } from "@cedarjs/cli-helpers";
|
package/dist/lib/background.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { spawn } from "child_process";
|
|
2
|
+
import fs from "node:fs";
|
|
2
3
|
import os from "os";
|
|
3
4
|
import path from "path";
|
|
4
|
-
import fs from "fs-extra";
|
|
5
5
|
import { getPaths } from "@cedarjs/project-config";
|
|
6
6
|
function spawnBackgroundProcess(name, cmd, args) {
|
|
7
7
|
const logDirectory = path.join(getPaths().generated.base, "logs");
|
|
8
|
-
fs.
|
|
8
|
+
fs.mkdirSync(logDirectory, { recursive: true });
|
|
9
9
|
const safeName = name.replace(/[^a-z0-9]/gi, "_").toLowerCase();
|
|
10
10
|
const logHeader = [
|
|
11
11
|
`Starting log:`,
|
package/dist/lib/extendFile.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
1
2
|
import { createRequire } from "node:module";
|
|
2
3
|
import path from "node:path";
|
|
3
|
-
import fs from "fs-extra";
|
|
4
4
|
import { runCommandTask, getPaths } from "../lib/index.js";
|
|
5
5
|
const generatePrismaCommand = async () => {
|
|
6
6
|
const createdRequire = createRequire(import.meta.url);
|
package/dist/lib/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import https from "https";
|
|
2
|
+
import fs from "node:fs";
|
|
2
3
|
import path from "path";
|
|
3
4
|
import * as babel from "@babel/core";
|
|
4
5
|
import boxen from "boxen";
|
|
@@ -6,7 +7,6 @@ import camelcase from "camelcase";
|
|
|
6
7
|
import { paramCase } from "change-case";
|
|
7
8
|
import decamelize from "decamelize";
|
|
8
9
|
import execa from "execa";
|
|
9
|
-
import fs from "fs-extra";
|
|
10
10
|
import { Listr } from "listr2";
|
|
11
11
|
import lodash from "lodash";
|
|
12
12
|
import pascalcase from "pascalcase";
|
package/dist/lib/locking.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
1
2
|
import path from "path";
|
|
2
|
-
import fs from "fs-extra";
|
|
3
3
|
import { getPaths } from "./index.js";
|
|
4
4
|
function ensureLockDirectoryExists() {
|
|
5
5
|
const locksPath = path.join(getPaths().generated.base, "locks");
|
|
@@ -17,13 +17,17 @@ function setLock(identifier) {
|
|
|
17
17
|
""
|
|
18
18
|
);
|
|
19
19
|
}
|
|
20
|
+
function isErrorWithCode(error, code) {
|
|
21
|
+
return !!error && typeof error === "object" && "code" in error && error.code === code;
|
|
22
|
+
}
|
|
20
23
|
function unsetLock(identifier) {
|
|
21
24
|
try {
|
|
22
25
|
fs.rmSync(path.join(getPaths().generated.base, "locks", identifier));
|
|
23
26
|
} catch (error) {
|
|
24
|
-
if (error
|
|
25
|
-
|
|
27
|
+
if (isErrorWithCode(error, "ENOENT")) {
|
|
28
|
+
return;
|
|
26
29
|
}
|
|
30
|
+
throw error;
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
33
|
function isLockSet(identifier) {
|
package/dist/lib/packages.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
1
2
|
import { createRequire } from "node:module";
|
|
2
3
|
import path from "node:path";
|
|
3
4
|
import execa from "execa";
|
|
4
|
-
import fs from "fs-extra";
|
|
5
5
|
import { getPaths } from "./index.js";
|
|
6
6
|
async function installModule(name, version = void 0) {
|
|
7
7
|
if (isModuleInstalled(name)) {
|
|
@@ -55,8 +55,8 @@ async function installRedwoodModule(module) {
|
|
|
55
55
|
return false;
|
|
56
56
|
}
|
|
57
57
|
function isModuleInstalled(module) {
|
|
58
|
-
const { dependencies, devDependencies } =
|
|
59
|
-
path.join(getPaths().base, "package.json")
|
|
58
|
+
const { dependencies, devDependencies } = JSON.parse(
|
|
59
|
+
fs.readFileSync(path.join(getPaths().base, "package.json"), "utf-8")
|
|
60
60
|
);
|
|
61
61
|
const deps = {
|
|
62
62
|
...dependencies,
|
package/dist/lib/plugin.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
1
2
|
import path from "path";
|
|
2
3
|
import ansis from "ansis";
|
|
3
4
|
import enquirer from "enquirer";
|
|
4
|
-
import fs from "fs-extra";
|
|
5
5
|
import { getCompatibilityData } from "@cedarjs/cli-helpers";
|
|
6
6
|
import { installModule, isModuleInstalled } from "./packages.js";
|
|
7
7
|
import { getPaths } from "./index.js";
|
package/dist/lib/ports.js
CHANGED
package/dist/lib/project.js
CHANGED
package/dist/lib/rollback.js
CHANGED
package/dist/lib/test.js
CHANGED
package/dist/lib/updateCheck.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
1
2
|
import path from "path";
|
|
2
3
|
import ansis from "ansis";
|
|
3
4
|
import boxen from "boxen";
|
|
4
|
-
import fs from "fs-extra";
|
|
5
5
|
import latestVersion from "latest-version";
|
|
6
6
|
import semver from "semver";
|
|
7
7
|
import { getConfig } from "@cedarjs/project-config";
|
|
@@ -26,7 +26,7 @@ async function check() {
|
|
|
26
26
|
try {
|
|
27
27
|
console.time("Update Check");
|
|
28
28
|
const packageJson = JSON.parse(
|
|
29
|
-
fs.readFileSync(path.join(getPaths().base, "package.json"))
|
|
29
|
+
fs.readFileSync(path.join(getPaths().base, "package.json"), "utf-8")
|
|
30
30
|
);
|
|
31
31
|
let localVersion = packageJson.devDependencies["@cedarjs/core"];
|
|
32
32
|
while (!/\d/.test(localVersion.charAt(0))) {
|
|
@@ -116,20 +116,26 @@ function getUpdateMessage() {
|
|
|
116
116
|
borderStyle: "round"
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
+
function isErrorWithCode(error, code) {
|
|
120
|
+
return !!error && error instanceof Object && "code" in error && error.code === code;
|
|
121
|
+
}
|
|
119
122
|
function readUpdateDataFile() {
|
|
120
123
|
try {
|
|
121
124
|
if (!fs.existsSync(getPersistenceDirectory())) {
|
|
122
125
|
fs.mkdirSync(getPersistenceDirectory(), { recursive: true });
|
|
123
126
|
}
|
|
124
127
|
const persistedData = JSON.parse(
|
|
125
|
-
fs.readFileSync(
|
|
128
|
+
fs.readFileSync(
|
|
129
|
+
path.join(getPersistenceDirectory(), "data.json"),
|
|
130
|
+
"utf-8"
|
|
131
|
+
)
|
|
126
132
|
);
|
|
127
133
|
persistedData.remoteVersions = new Map(
|
|
128
134
|
Object.entries(persistedData.remoteVersions)
|
|
129
135
|
);
|
|
130
136
|
return persistedData;
|
|
131
137
|
} catch (error) {
|
|
132
|
-
if (error
|
|
138
|
+
if (isErrorWithCode(error, "ENOENT")) {
|
|
133
139
|
return {
|
|
134
140
|
localVersion: "0.0.0",
|
|
135
141
|
remoteVersions: /* @__PURE__ */ new Map(),
|
|
@@ -149,15 +155,17 @@ function updateUpdateDataFile({
|
|
|
149
155
|
const existingData = readUpdateDataFile();
|
|
150
156
|
const updatedData = {
|
|
151
157
|
localVersion: localVersion ?? existingData.localVersion,
|
|
152
|
-
remoteVersions:
|
|
153
|
-
remoteVersions ?? existingData.remoteVersions
|
|
154
|
-
),
|
|
158
|
+
remoteVersions: remoteVersions ?? existingData.remoteVersions,
|
|
155
159
|
checkedAt: checkedAt ?? existingData.checkedAt,
|
|
156
160
|
shownAt: shownAt ?? existingData.shownAt
|
|
157
161
|
};
|
|
162
|
+
const dataToWrite = {
|
|
163
|
+
...updatedData,
|
|
164
|
+
remoteVersions: Object.fromEntries(updatedData.remoteVersions)
|
|
165
|
+
};
|
|
158
166
|
fs.writeFileSync(
|
|
159
167
|
path.join(getPersistenceDirectory(), "data.json"),
|
|
160
|
-
JSON.stringify(
|
|
168
|
+
JSON.stringify(dataToWrite, null, 2)
|
|
161
169
|
);
|
|
162
170
|
}
|
|
163
171
|
function extractTagFromVersion(version) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
1
2
|
import path from "path";
|
|
2
|
-
import fs from "fs-extra";
|
|
3
3
|
import { getPaths } from "@cedarjs/project-config";
|
|
4
4
|
class CustomFileExporter {
|
|
5
5
|
/**
|
|
@@ -24,7 +24,7 @@ class CustomFileExporter {
|
|
|
24
24
|
"telemetry",
|
|
25
25
|
this.#storageFileName
|
|
26
26
|
);
|
|
27
|
-
fs.
|
|
27
|
+
fs.mkdirSync(path.dirname(this.#storageFilePath), { recursive: true });
|
|
28
28
|
fs.writeFileSync(this.#storageFilePath, "[");
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
1
2
|
import path from "path";
|
|
2
3
|
import { SemanticResourceAttributes } from "@opentelemetry/semantic-conventions";
|
|
3
4
|
import ci from "ci-info";
|
|
4
5
|
import envinfo from "envinfo";
|
|
5
|
-
import fs from "fs-extra";
|
|
6
6
|
import system from "systeminformation";
|
|
7
7
|
import { v4 as uuidv4, validate as validateUUID } from "uuid";
|
|
8
8
|
import { getPaths, getRawConfig } from "@cedarjs/project-config";
|
|
@@ -17,7 +17,8 @@ async function getResources() {
|
|
|
17
17
|
try {
|
|
18
18
|
const telemetryFile = path.join(getPaths().generated.base, "telemetry.txt");
|
|
19
19
|
if (!fs.existsSync(telemetryFile)) {
|
|
20
|
-
fs.
|
|
20
|
+
fs.mkdirSync(path.dirname(telemetryFile), { recursive: true });
|
|
21
|
+
fs.writeFileSync(telemetryFile, "");
|
|
21
22
|
}
|
|
22
23
|
if (fs.statSync(telemetryFile).mtimeMs < Date.now() - 864e5) {
|
|
23
24
|
fs.writeFileSync(telemetryFile, UID);
|