-
Notifications
You must be signed in to change notification settings - Fork 40
Refactor the manifest commands, add gradle to maven conversion #323
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
+1,280
−403
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1106ad0
Add gradle, refactor other manifest commands
pvdz 8759db5
polish
pvdz 971f1f9
Add quick readme to manifest
pvdz 7722259
Put comment back in
pvdz 10d4a43
Slap a beta tag on it
pvdz f155664
Merge branch 'main' into maven
pvdz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| # Manifest | ||
|
|
||
| (At the time of writing...) | ||
|
|
||
| ## Dev | ||
|
|
||
| First build the bundle: | ||
|
|
||
| ``` | ||
| npm run build:dist | ||
| ``` | ||
|
|
||
| Then run it like these examples: | ||
|
|
||
| ``` | ||
| # Scala: | ||
| npm exec socket manifest scala -- --bin ~/apps/sbt/bin/sbt ~/socket/repos/scala/akka | ||
| # Gradle/Kotlin | ||
| npm exec socket manifest yolo -- --cwd ~/socket/repos/kotlin/kotlinx.coroutines | ||
| ``` | ||
|
|
||
| And upload with this: | ||
|
|
||
| ``` | ||
| npm exec socket scan create -- --repo=depscantmp --branch=mastertmp --tmp --cwd ~/socket/repos/scala/akka socketdev . | ||
| npm exec socket scan create -- --repo=depscantmp --branch=mastertmp --tmp --cwd ~/socket/repos/kotlin/kotlinx.coroutines . | ||
| ``` | ||
|
|
||
| (The `cwd` option for `create` is necessary because we can't go to the dir and run `npm exec`). | ||
|
|
||
| ## Prod | ||
|
|
||
| User flow look something like this: | ||
|
|
||
| ``` | ||
| socket manifest scala . | ||
| socket manifest kotlin . | ||
| socket manifest yolo | ||
|
|
||
| socket scan create --repo=depscantmp --branch=mastertmp --tmp socketdev . | ||
| ``` |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,116 @@ | ||
| import fs from 'node:fs' | ||
| import path from 'node:path' | ||
|
|
||
| import meow from 'meow' | ||
|
|
||
| import { cmdManifestGradle } from './cmd-gradle.ts' | ||
| import { cmdManifestScala } from './cmd-scala.ts' | ||
| import { commonFlags } from '../../flags.ts' | ||
| import { getFlagListOutput } from '../../utils/output-formatting.ts' | ||
|
|
||
| import type { CliCommandConfig } from '../../utils/meow-with-subcommands' | ||
|
|
||
| const config: CliCommandConfig = { | ||
| commandName: 'auto', | ||
| description: 'Auto-detect build and attempt to generate manifest file', | ||
| hidden: false, | ||
| flags: { | ||
| ...commonFlags, | ||
| cwd: { | ||
| type: 'string', | ||
| description: 'Set the cwd, defaults to process.cwd()' | ||
| }, | ||
| verbose: { | ||
| type: 'boolean', | ||
| default: false, | ||
| description: 'Enable debug output, may help when running into errors' | ||
| } | ||
| // TODO: support output flags | ||
| }, | ||
| help: (parentName, config) => ` | ||
| Usage | ||
| $ ${parentName} ${config.commandName} | ||
|
|
||
| Options | ||
| ${getFlagListOutput(config.flags, 6)} | ||
|
|
||
| Tries to figure out what language your current repo uses. If it finds a | ||
| supported case then it will try to generate the manifest file for that | ||
| language with the default or detected settings. | ||
| ` | ||
| } | ||
|
|
||
| export const cmdManifestAuto = { | ||
| description: config.description, | ||
| hidden: config.hidden, | ||
| run | ||
| } | ||
|
|
||
| async function run( | ||
| argv: readonly string[], | ||
| importMeta: ImportMeta, | ||
| { parentName }: { parentName: string } | ||
| ): Promise<void> { | ||
| const cli = meow(config.help(parentName, config), { | ||
| argv, | ||
| description: config.description, | ||
| importMeta, | ||
| flags: config.flags, | ||
| allowUnknownFlags: false | ||
| }) | ||
|
|
||
| const verbose = cli.flags['verbose'] ?? false | ||
| const cwd = String(cli.flags['cwd']) || false | ||
| if (verbose) { | ||
| console.group('- ', parentName, config.commandName, ':') | ||
| console.group('- flags:', cli.flags) | ||
| console.groupEnd() | ||
| console.log('- input:', cli.input) | ||
| console.log('- cwd:', cwd || process.cwd()) | ||
| console.groupEnd() | ||
| } | ||
|
|
||
| const subArgs = [] | ||
| if (verbose) subArgs.push('--verbose') | ||
|
|
||
| const dir = cwd || '.' | ||
|
|
||
| if (fs.existsSync(path.join(dir, 'build.sbt'))) { | ||
| console.log( | ||
| 'Detected a Scala sbt build, running default Scala generator...' | ||
| ) | ||
| if (cwd) subArgs.push('--cwd', cwd) | ||
| subArgs.push(dir) | ||
| await cmdManifestScala.run(subArgs, importMeta, { parentName }) | ||
| return | ||
| } | ||
|
|
||
| if (fs.existsSync(path.join(dir, 'gradlew'))) { | ||
| console.log('Detected a gradle build, running default gradle generator...') | ||
| if (cwd) subArgs.push(cwd) // This command takes the cwd as first arg | ||
| await cmdManifestGradle.run(subArgs, importMeta, { parentName }) | ||
| return | ||
| } | ||
|
|
||
| // Show new help screen and exit | ||
| meow( | ||
| ` | ||
| $ ${parentName} ${config.commandName} | ||
|
|
||
| Unfortunately this script did not discover a supported language in the | ||
| current folder. | ||
|
|
||
| - Make sure this script would work with your target build | ||
| - Make sure to run it from the correct folder | ||
| - Make sure the necessary build tools are available (\`PATH\`) | ||
|
|
||
| If that doesn't work, see \`${parentName} <lang> --help\` for config details for | ||
| your target language. | ||
| `, | ||
| { | ||
| argv: [], | ||
| description: config.description, | ||
| importMeta | ||
| } | ||
| ).showHelp() | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.