-
Notifications
You must be signed in to change notification settings - Fork 40
Add socket manifest <lang> including scala as first lang
#311
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
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
923645e
Add `socket sbom` command and `socket sbom scala`
pvdz 5f2fcfa
lint fix/prettier
pvdz 3356fbe
sbom -> manifest
pvdz 6a7a6c1
lint:fix
pvdz 1b1b4e8
Use common readFile/spawn deps
pvdz e89a921
lint
pvdz cabccdf
Merge branch 'main' into add-sbom
pvdz 875eb61
Add a `manifest auto` command which tries to zero config generate a m…
pvdz 3cd83e9
Back out change that landed in main already
pvdz 3a79c58
Merge branch 'main' into add-sbom
pvdz 59f5e43
Pass on flag options to meow proper, fixing boolean flags
pvdz 82ea91b
npm run check:lint -- --fix
pvdz 71a86f4
Merge branch 'main' into add-sbom
jdalton 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,78 @@ | ||
| import fs from 'node:fs' | ||
|
|
||
| import meow from 'meow' | ||
|
|
||
| import { scala } from './scala.ts' | ||
|
|
||
| import type { CliSubcommand } from '../../utils/meow-with-subcommands' | ||
|
|
||
| const description = 'Auto-detect build and attempt to generate manifest file' | ||
|
|
||
| const help = (name: string) => ` | ||
| Usage | ||
| $ ${name} | ||
|
|
||
| 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. | ||
|
|
||
| This command takes no arguments except --verbose. | ||
| ` | ||
|
|
||
| export const auto: CliSubcommand = { | ||
| description, | ||
| async run(argv, importMeta, { parentName }) { | ||
| // Allow `--verbose` to pass through | ||
| let verbose = false | ||
| const args = argv.filter(arg => { | ||
| if (arg === '--verbose') { | ||
| verbose = true | ||
| return false | ||
| } | ||
| return true | ||
| }) | ||
|
|
||
| const name = `${parentName} auto` | ||
| if (args.length) { | ||
| // note: meow will exit if it prints the --help screen | ||
| meow(help(name), { | ||
| argv: ['--help'], | ||
| description, | ||
| importMeta | ||
| }) | ||
| } | ||
|
|
||
| const subArgs = [] | ||
| if (verbose) subArgs.push('--verbose', '1') | ||
| const scalaDir = '.' | ||
| if (fs.existsSync(scalaDir)) { | ||
| console.log( | ||
| 'Detected a Scala sbt build, running default Scala generator...' | ||
| ) | ||
| subArgs.push(scalaDir) | ||
| await scala.run(subArgs, importMeta, { parentName }) | ||
| return | ||
| } | ||
|
|
||
| // Show new help screen and exit | ||
| meow( | ||
| ` | ||
| $ ${name} | ||
|
|
||
| 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 \`${name} <lang> --help\` for config details | ||
| `, | ||
| { | ||
| argv: ['--help'], | ||
| description, | ||
| importMeta | ||
| } | ||
| ) | ||
| } | ||
| } |
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,70 @@ | ||
| import meow from 'meow' | ||
|
|
||
| import { auto } from './auto.ts' | ||
| import { scala } from './scala' | ||
| import { meowWithSubcommands } from '../../utils/meow-with-subcommands' | ||
|
|
||
| import type { CliSubcommand } from '../../utils/meow-with-subcommands' | ||
|
|
||
| const description = 'Generate a dependency manifest for given file or dir' | ||
| const help = (name: string) => ` | ||
| Usage | ||
|
|
||
| $ ${name} <language> <target> | ||
|
|
||
| Generates a declarative dependency manifest (like a package.json for Node.JS | ||
| or requirements.txt for PyPi), but for certain supported ecosystems | ||
| where it's common to use a dynamic manifest, like Scala's sbt. | ||
|
|
||
| Only certain languages are supported and there may be language specific | ||
| configurations available. See \`manifest <language> --help\` for usage details | ||
| per language. | ||
|
|
||
| Currently supported language: scala | ||
|
|
||
| Examples | ||
|
|
||
| $ ${name} scala . | ||
|
|
||
| To have it auto-detect and attempt to run: | ||
|
|
||
| $ ${name} yolo | ||
| ` | ||
|
|
||
| export const manifest: CliSubcommand = { | ||
| description, | ||
| hidden: true, | ||
| async run(argv, importMeta, { parentName }) { | ||
| const name = `${parentName} manifest` | ||
|
|
||
| // Note: this won't catch `socket manifest -xyz --help` sort of cases which | ||
| // would fallback to the default meow help behavior. That's fine. | ||
| if (argv.length === 0 || argv[0] === '--help') { | ||
| meow(help(name), { | ||
| argv: ['--help'] as const, // meow will exit() when --help is passed | ||
| description, | ||
| importMeta | ||
| }) | ||
| } | ||
|
|
||
| await meowWithSubcommands( | ||
| { | ||
| scala, | ||
| auto | ||
| }, | ||
| { | ||
| argv, | ||
| aliases: { | ||
| yolo: { | ||
| description: auto.description, | ||
| hidden: true, | ||
| argv: ['auto'] | ||
| } | ||
| }, | ||
| description, | ||
| importMeta, | ||
| name | ||
| } | ||
| ) | ||
| } | ||
| } | ||
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.