Conversation
1. Gists are created perfectly 2. But when we access it in ast-explorer we are getting error like Failed to parse revision
|
@rwjblue Please let me know your comments whether we are going in the right direction. |
1. Move api keys to .env file using dotenv 2. Added test cases for new with import url
commands/global/new.js
Outdated
| require('dotenv').config(); | ||
| const Octokit = require('@octokit/rest'); | ||
| const octokit = new Octokit({ auth: process.env.CODEMOD_CLI_API_KEY }); | ||
| let codemodDir = `${process.cwd()}/${projectName}/transforms/${codemodName}`; |
There was a problem hiding this comment.
Do we need this? Can we download the actual file directly (without needing an API key)?
I'm thinking like, from:
https://gist.githubusercontent.com/astexplorer/6f3bf899542dbe21e0474a2a74b2ffc9/raw/c23b658b268c2e5b644fed7f1a360433748e7f71/transform.js
There was a problem hiding this comment.
I think yes, but in case of export we need an api to create gists, so I thought we can use this. What do you think?
commands/global/new.js
Outdated
| fs.outputFileSync( | ||
| `${codemodDir}/README.md`, | ||
| stripIndent` | ||
| # ${codemodName}\n | ||
|
|
||
| ## Usage | ||
|
|
||
| \`\`\` | ||
| npx ${projectName} ${codemodName} path/of/files/ or/some**/*glob.js | ||
|
|
||
| # or | ||
|
|
||
| yarn global add ${projectName} | ||
| ${projectName} ${codemodName} path/of/files/ or/some**/*glob.js | ||
| \`\`\` | ||
|
|
||
| ## Input / Output | ||
|
|
||
| <!--FIXTURES_TOC_START--> | ||
| <!--FIXTURES_TOC_END--> | ||
|
|
||
| <!--FIXTURES_CONTENT_START--> | ||
| <!--FIXTURES_CONTENT_END--> | ||
| `, | ||
| 'utf8' | ||
| ); |
There was a problem hiding this comment.
Can you abstract this so we don't slowly diverge the README.md contents?
There was a problem hiding this comment.
Sure, working on it.
commands/local/export.js
Outdated
| let { codemodName } = options; | ||
|
|
||
| const Octokit = require('@octokit/rest'); | ||
| const octokit = new Octokit({ auth: 'acabfddbefb244cb3e674fa84046a907c78f2294' }); |
There was a problem hiding this comment.
🤔 - Seems odd to hard code this here? Is this a mistake?
There was a problem hiding this comment.
Yep, my bad, will remove that.
commands/local/export.js
Outdated
| // https://api.github.com/gists/de5cff0a12c2aaf129f94b775306af6f | ||
| console.log(data); |
There was a problem hiding this comment.
Just notating for removal in the future
commands/local/export.js
Outdated
| .create({ | ||
| files, | ||
| }) | ||
| .then(({ data }) => { |
There was a problem hiding this comment.
I think we can use async/await here instead of manual chaining.
commands/local/import.js
Outdated
| fs.outputFileSync( | ||
| `${codemodDir}/README.md`, | ||
| stripIndent` | ||
| # ${codemodName}\n | ||
|
|
||
| ## Usage | ||
|
|
||
| \`\`\` | ||
| npx ${projectName} ${codemodName} path/of/files/ or/some**/*glob.js | ||
|
|
||
| # or | ||
|
|
||
| yarn global add ${projectName} | ||
| ${projectName} ${codemodName} path/of/files/ or/some**/*glob.js | ||
| \`\`\` | ||
|
|
||
| ## Input / Output | ||
|
|
||
| <!--FIXTURES_TOC_START--> | ||
| <!--FIXTURES_TOC_END--> | ||
|
|
||
| <!--FIXTURES_CONTENT_START--> | ||
| <!--FIXTURES_CONTENT_END--> | ||
| `, | ||
| 'utf8' | ||
| ); |
There was a problem hiding this comment.
Lets use a shared function to generate these README.md's, I don't want them to slowly get out of sync due to the duplication.
package-lock.json
Outdated
| @@ -0,0 +1,11641 @@ | |||
| { | |||
There was a problem hiding this comment.
I think we are using a yarn.lock, can you delete this?
There was a problem hiding this comment.
OK, I got used to npm so much , I forgot to remove, will do it right away.
1. Added new lib for readme-support 2. Project readme abstracted to readme-support 3. Codemod readme abstracted to readme-support 4. Removed console.logs and api keys
1. Removed package-lock 2. Update yarn.lock
|
@rwjblue Do you mind if I create a separate PR for export, after figuring out the issues with ast-explorer? |
1. Add new with import command example in Readme 2. Clean up some comments and console.logs 3. Added error handling to new and import commands
1. Made changes for downloading transform with node's built-in request object in new and import commands 2. Remove octokit from package.json and yarn.lock 3. Removed export command
No problem, that seems fine to me. |
|
I'm going to try to get CI passing again this week. |
#12