-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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(yarn): add options #1612
feat(yarn): add options #1612
Conversation
Overviewsrc/yarn.ts:Info:Script: function (out) {
if (out.trim() == "") {
return [];
}
try {
const startIndex = out.indexOf("{");
const endIndex = out.indexOf("}");
let output = out.substring(startIndex, endIndex + 1);
// TODO: fix hacky code
// reason: JSON parse was not working without double quotes
output = output
.replace(/\'/gi, '"')
.replace("lastUpdateCheck", '"lastUpdateCheck"')
.replace("registry", '"lastUpdateCheck"');
const configObject = JSON.parse(output);
if (configObject) {
return Object.keys(configObject).map((key) => ({ name: key }));
}
} catch (e) {}
return [];
} Script: function (out, context = []) {
if (out.trim() === "") {
return [];
}
try {
const packageContent = JSON.parse(out);
const dependencies = packageContent["dependencies"] ?? {};
const devDependencies = packageContent["devDependencies"];
const optionalDependencies = packageContent["optionalDependencies"] ?? {};
Object.assign(dependencies, devDependencies, optionalDependencies);
return Object.keys(dependencies)
.filter((pkgName) => {
const isListed = context.some((current) => current === pkgName);
return !isListed;
})
.map((pkgName) => ({
name: pkgName,
icon: "📦",
description: dependencies[pkgName]
? "dependency"
: optionalDependencies[pkgName]
? "optionalDependency"
: "devDependency",
}));
} catch (e) {
console.error(e);
return [];
}
} Script: function (context) {
if (context[context.length - 1] === "") return "";
const searchTerm = "create-" + context[context.length - 1];
return `curl -s -H "Accept: application/json" "https://api.npms.io/v2/search?q=${searchTerm}&size=20"`;
} Script: function (out) {
try {
return JSON.parse(out).results.map(
(item) =>
({
name: item.package.name.substring(7),
description: item.package.description,
} as Fig.Suggestion)
) as Fig.Suggestion[];
} catch (e) {
return [];
}
} Script: function (out: string) {
if (out.trim() == "") {
return [];
}
try {
const packageContent = JSON.parse(out);
const scripts = packageContent["scripts"];
if (scripts) {
return Object.keys(scripts).map((script) => ({
name: script,
}));
}
} catch (e) {}
return [];
} URLs:
|
Hello @vatana7,
Please add a 👍 as a reaction to this comment to show that you read this. |
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.
Thanks for the PR! I left a few things to get fixed before merging this in.
Thanks! Can you label this as hacktoberfest PR please 🤟🏻 |
@vatana7 PRs are automatically counted for hacktoberfest because the repo itself has the label 🙂 |
Co-authored-by: Federico Ciardi <fed.ciardi@gmail.com>
Co-authored-by: Federico Ciardi <fed.ciardi@gmail.com>
Co-authored-by: Federico Ciardi <fed.ciardi@gmail.com>
Co-authored-by: Federico Ciardi <fed.ciardi@gmail.com>
Co-authored-by: Federico Ciardi <fed.ciardi@gmail.com>
Co-authored-by: Federico Ciardi <fed.ciardi@gmail.com>
@separaterecords Everything should be able to merge now. Thanks for the suggestion! |
Just one thing to fix up first! Either prettier or eslint is unhappy. Easy fix: |
What version of node does this project use? |
That's not strictly relevant. I believe node@16 is good. |
Any version of node should be fine for this. Personally I just use the latest (node@18) and only change per project if required |
I have run both command and made changes. Can you take a look at it again? |
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.
Thanks!
args: { | ||
name: "<scope:team> <user>", | ||
}, |
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.
args: { | |
name: "<scope:team> <user>", | |
}, | |
args: [ | |
{ | |
name: "<scope:team>", | |
}, | |
{ | |
name: "<user>", | |
}, | |
], |
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Adding more specs to yarn
Important
This is a code solution submitted for Closes #1611