-
Notifications
You must be signed in to change notification settings - Fork 662
feat(cli): lingo.dev init cursor Command for .cursorrules Setup (#1101) #1409
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 13 commits
c77b54f
85a1a0e
d59ed3d
2239479
85b681b
6746cec
89ddbff
6df021e
890c58f
8d30df1
55a079a
e864fbf
d657c6d
44f9963
a80466e
5a530f3
4fe3d16
f361eb9
ebe9d6e
13d14a9
00714d9
8e567eb
a068b0e
cdcaa90
6273c63
bd3f99b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| "lingo.dev": minor | ||
| --- | ||
|
|
||
| feat: add init cursor command for .cursorrules setup |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Test template for Cursor AI rules. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,6 +19,7 @@ import { ensurePatterns } from "../utils/ensure-patterns"; | |
| import updateGitignore from "../utils/update-gitignore"; | ||
| import initCICD from "../utils/init-ci-cd"; | ||
| import open from "open"; | ||
| import cursorInitCmd from "./init/cursor"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be imported in the
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hii @The-Best-Codes
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh gosh you might be right on that lol. Let me make sure when I get a chance
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @SK8-infi I was wrong about this! So you might do something like this:
...at least, that's what I would do. You can ask a maintainer too if you want more clarification!
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems to be a systematic approach to me too(beneficial for other agent sub commands). But would require directory changes... Maybe I should ask maintainers' views |
||
|
|
||
| const openUrl = (path: string) => { | ||
| const settings = getSettings(undefined); | ||
|
|
@@ -116,7 +117,6 @@ export default new InteractiveCommand() | |
| throw new Error(`Invalid path: ${p}`); | ||
| } | ||
| } | ||
|
|
||
| return values; | ||
| }) | ||
| .prompt(undefined) // make non-interactive | ||
|
|
@@ -258,4 +258,5 @@ export default new InteractiveCommand() | |
| if (!isInteractive) { | ||
| Ora().info("Please see https://lingo.dev/cli"); | ||
| } | ||
| }); | ||
| }) | ||
| .addCommand(cursorInitCmd); // Add cursor subcommand | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| import { InteractiveCommand, InteractiveOption } from "interactive-commander"; | ||
| import Ora from "ora"; | ||
| import fs from "fs"; | ||
| import path from "path"; | ||
| import { confirm } from "@inquirer/prompts"; | ||
|
|
||
| const AGENTS_MD = path.resolve(process.cwd(), "packages/cli/agents.md"); | ||
| const CURSORRULES = path.resolve(process.cwd(), ".cursorrules"); | ||
|
|
||
| export default new InteractiveCommand() | ||
| .command("cursor") | ||
| .description( | ||
| "Initialize .cursorrules with i18n-specific instructions for Cursor AI.", | ||
| ) | ||
| .addOption( | ||
| new InteractiveOption( | ||
| "-f, --force", | ||
| "Overwrite .cursorrules without prompt.", | ||
| ).default(false), | ||
| ) | ||
| .action(async (options) => { | ||
| const spinner = Ora(); | ||
| // Read agents.md | ||
| let template: string; | ||
| try { | ||
| template = fs.readFileSync(AGENTS_MD, "utf-8"); | ||
| } catch (err) { | ||
| spinner.fail(`Template not found: ${AGENTS_MD}`); | ||
SK8-infi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| return process.exit(1); | ||
| } | ||
| // Check for existing .cursorrules | ||
| const exists = fs.existsSync(CURSORRULES); | ||
| let shouldWrite = true; | ||
SK8-infi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if (exists && !options.force) { | ||
| shouldWrite = await confirm({ | ||
| message: ".cursorrules already exists. Overwrite?", | ||
| }); | ||
| if (!shouldWrite) { | ||
| spinner.info("Skipped: .cursorrules left unchanged."); | ||
| return; | ||
| } | ||
| } | ||
| try { | ||
| fs.writeFileSync(CURSORRULES, template); | ||
| spinner.succeed("✓ Created .cursorrules"); | ||
SK8-infi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| spinner.info( | ||
| ".cursorrules has been created with i18n-specific instructions for Cursor AI.", | ||
| ); | ||
| if (!fs.existsSync(CURSORRULES)) { | ||
| spinner.fail(".cursorrules not found after write"); | ||
| } | ||
SK8-infi marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } catch (err) { | ||
| spinner.fail(`Failed to write .cursorrules: ${err}`); | ||
| process.exit(1); | ||
| } | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.