Skip to content

Commit

Permalink
fix: typos and toml safe update
Browse files Browse the repository at this point in the history
  • Loading branch information
charlypoly committed Sep 15, 2023
1 parent 3d78bb1 commit 10d5c2a
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 13 deletions.
1 change: 0 additions & 1 deletion packages/defer-rw-setup/src/cron/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const description = "Add a Defer CRON";

export const builder = (yargs: Yargs.Argv<BaseOptions>) => {
return yargs
.commandDir("cron")
.option("force", {
alias: "f",
default: false,
Expand Down
3 changes: 2 additions & 1 deletion packages/defer-rw-setup/src/cron/tasks.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import path from "path";
import { Listr } from "listr2";
import fs from "fs-extra";
import { getPaths, writeFile } from "@redwoodjs/cli-helpers";
import humanize from "humanize-string";
import pkg from "@redwoodjs/cli-helpers";
const { getPaths, writeFile } = pkg;

import type { FunctionOptions } from "./command";

Expand Down
1 change: 0 additions & 1 deletion packages/defer-rw-setup/src/function/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export const description = "Add a Defer background function";

export const builder = (yargs: Yargs.Argv<BaseOptions>) => {
return yargs
.commandDir("function")
.option("force", {
alias: "f",
default: false,
Expand Down
3 changes: 2 additions & 1 deletion packages/defer-rw-setup/src/function/tasks.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import path from "path";
import { Listr } from "listr2";
import fs from "fs-extra";
import { getPaths, writeFile } from "@redwoodjs/cli-helpers";
import humanize from "humanize-string";
import pkg from "@redwoodjs/cli-helpers";
const { getPaths, writeFile } = pkg;

import type { FunctionOptions } from "./command";

Expand Down
65 changes: 56 additions & 9 deletions packages/defer-rw-setup/src/plugin/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,66 @@ export const configureDeferClient = ({
);
};

const tomlString = `
[experimental.cli]
autoInstall = false
[[experimental.cli.plugins]]
package = "@defer/redwood"`;

export const updateTomlConfig = () => {
const redwoodTomlPath = getConfigPath();
const configContent = fs.readFileSync(redwoodTomlPath, "utf-8");

if (!configContent.includes("@defer/redwood")) {
writeFile(redwoodTomlPath, configContent.concat(tomlString), {
existingFiles: "OVERWRITE",
});
if (configContent.includes(" [experimental.cli]")) {
if (configContent.includes(" [[experimental.cli.plugins]]")) {
writeFile(
redwoodTomlPath,
configContent.concat(`
[[experimental.cli.plugins]]
package = "@defer/redwood"
[[experimental.cli.plugins]]`),
{
existingFiles: "OVERWRITE",
}
);
} else {
if (
configContent.match(`[experimental.cli]
autoInstall = true`)
) {
writeFile(
redwoodTomlPath,
configContent.concat(`
[experimental.cli]
autoInstall = true
[[experimental.cli.plugins]]
package = "@defer/redwood"`),
{
existingFiles: "OVERWRITE",
}
);
} else {
writeFile(
redwoodTomlPath,
configContent.concat(`
[experimental.cli]
autoInstall = false
[[experimental.cli.plugins]]
package = "@defer/redwood"`),
{
existingFiles: "OVERWRITE",
}
);
}
}
} else {
writeFile(
redwoodTomlPath,
configContent.concat(`
[experimental.cli]
autoInstall = false
[[experimental.cli.plugins]]
package = "@defer/redwood"`),
{
existingFiles: "OVERWRITE",
}
);
}
}
};

0 comments on commit 10d5c2a

Please sign in to comment.