-
Notifications
You must be signed in to change notification settings - Fork 233
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
feat(cli): Add shortest init
command
#297
feat(cli): Add shortest init
command
#297
Conversation
… the lib in a fresh repo
@khalatevarun is attempting to deploy a commit to the Antiwork Team on Vercel. A member of the Team first needs to authorize it. |
Should update the README too |
…b to detect package manager
shortest init
command to setup library in a fresh repo with config filesshortest init
command
nit: I think the purpose of the util folder is to store files that are frequently reused throughout the project. since most of the functions are not reused, they don't belong there. while I would suggest inlining them |
shortest init
commandshortest init
command
the changes seem to be working fine when the package is built locally and used in another project |
open to any additional reviews - @gladyshcodes @rmarescu |
I've started reviewing, will wrap up tomorrow! |
thank you for the review and code changes, learning alot in the process @rmarescu |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested on a empty folder, and on a fresh Next.js install, seems to be working fine. Thanks for the contribution @khalatevarun!
@@ -24,18 +24,20 @@ If helpful, [here's a short video](https://github.com/anti-work/shortest/issues/ | |||
|
|||
### Installation | |||
|
|||
```bash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Manual instructions can be removed. The description below outlines the steps, in case someone would like to do it manually.
@@ -111,6 +111,11 @@ function isValidArg(arg: string): boolean { | |||
async function main() { | |||
const args = process.argv.slice(2); | |||
|
|||
if (args[0] === "init") { | |||
await require("../commands/init").default(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extracted all the logic to its own module.
import { addToGitignore } from "../../utils/add-to-gitignore"; | ||
|
||
export default async function main() { | ||
console.log(pc.blue("Setting up Shortest...")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blue
doesn't look great on a dark terminal. We should consider improving the contrast at some point.
packageJson?.devDependencies?.["@antiwork/shortest"] | ||
) { | ||
console.log(pc.green("✔ Package already installed")); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Important to exit early if the package is already installed, otherwise there would be some considerable effort to ensure the install doesn't overwrite any existing data.
const configPath = join(process.cwd(), CONFIG_FILENAME); | ||
const exampleConfigPath = join( | ||
fileURLToPath(new URL("../../src", import.meta.url)), | ||
`${CONFIG_FILENAME}.example`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplified the logic to use an example file.
console.log(pc.green(`✔ ${CONFIG_FILENAME} created`)); | ||
|
||
const envResult = await addToEnv(process.cwd(), { | ||
ANTHROPIC_API_KEY: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think it's worth adding Mailosaur at this time, although other ENVs can be easily added in the future.
} | ||
|
||
const resultGitignore = await addToGitignore(process.cwd(), [ | ||
".env*.local", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not worth the effort trying to group with other env*
-like values already present (e.g. .env
from a fresh Next.js install).
Resolves #294