Skip to content
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(typeorm): make spec diff-versioned #1559

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

fedeci
Copy link
Contributor

@fedeci fedeci commented Oct 1, 2022

No description provided.

@withfig-bot
Copy link
Collaborator

Overview

src/typeorm/0.2.0.ts:

Info:

src/typeorm/index.ts:

Info:

src/typeorm/0.3.0.ts:

Info:

@withfig-bot
Copy link
Collaborator

Hello @fedeci,
thank you very much for creating a Pull Request!
Here is a small checklist to get this PR merged as quickly as possible:

  • Do all subcommands / options which take arguments include the args property (args: {})?
  • Are all options modular? E.g. -a -u -x instead of -aux
  • Have all other checks passed?

Please add a 👍 as a reaction to this comment to show that you read this.

@fedeci
Copy link
Contributor Author

fedeci commented Oct 1, 2022

This makes it really verbose by duplicating the spec, but at the same time we should start to expand and to try to make as many open source projects as possible to be directly integrated with autocomplete!

@fedeci
Copy link
Contributor Author

fedeci commented Oct 1, 2022

Closes #1158

@loosheng
Copy link
Contributor

loosheng commented Dec 17, 2022

This makes it really verbose by duplicating the spec

I agree with you, I thought of this when I added autocomplete to pnpm.

I have an idea, maybe we should add a dependsOnVersion for subcommand

interface Subcommand {
	dependsOnVersion: (string | (executeShellCommand) => boolean)[]
}

When it's a string, you can refer directly to the package.json version control, which is a very mature solution.

Version range Matching version
* You can use subcommand regardless of the version, and this will be the default
^2.1.0 2.1.0 <= v < 3 Versions available
~2.1.0 2.1.0 <= v < 2.2 Versions available
2.1.0 - 3.2.7 2.1.0 <= v <= 3.2.7 Versions available
<2.2.0 ...
<=2.0.0 ...
\>4.2.0 ...
\>=4.2.0 ...
=4.3.0 ...
^0.7 || ~2 ...

When it's a function, we need to take into account that some commands depend not only on their own version but also on the version of the external environment, e.g. pnpm v7 requires nodejs >= 14, at which point we can do some custom comparisons in the function and return whether the version is available in the current environment.

eg:

{
// pnpm v7 
// pnpm patch
const completionSpec: Fig.Spec = {
	name: "pnpm",
	description: "Fast, disk space efficient package manager",
	args: {
    	name: "Scripts",
    	filterStrategy: "fuzzy",
    	generators: npmScriptsGenerator,
    	isVariadic: true,
  	},
	dependsOnVersion: [async ( executeShellCommand ){
			const nodeVersion = await executeShellCommand('node -v');
			return compareVersions(nodeVersion,'>=14')
		}],	// Maybe there are multiple environmental dependencies?

	subcommand:[
	{
    	name: "patch",
    	description: `This command will cause a package to be extracted in a temporary directory intended to be editable at will`,
		dependsOnVersion: '\>=7.14.0',
    	args: {
      		name: "package",
    	},
    	options: [
      	{
        	name: "--edit-dir",
        	description: `The package that needs to be patched will be extracted to this directory`,
      },
    ],
  },

}
]
}
  

@fedeci
Copy link
Contributor Author

fedeci commented Dec 18, 2022

Hey @loosheng, we already have something like for subcommands this and it is called generateSpec. However since these solutions are really difficult to automate (they use functions to determine CLI tool version) we created diff-versioned specs like this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants