Frontmatter for inline scripts
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 30/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Tranquilla
- Stack tecnologico
- javascript, node.js, typescript
- Ambito
- cli, developer-experience
Direzione di ricerca
Non vengono indicati file di implementazione o test. Inizia confrontando il formato proposto con i riferimenti collegati a Node.js, Nix, Cargo e Python, quindi determina come il frontmatter debba interagire con le opzioni esplicite, package.json, node.config.json e argv; «done» richiede che sintassi e comportamento siano concordati prima di poter iniziare l'implementazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
What is the problem this feature will solve?
Taking inspiration from nix, cargo, and python I would like a way for stand-alone scripts to embed configuration normally passed via package.json, node.config.json, argv, or wrapper scripts.
https://github.com/nodejs/node/issues/59565 asks to support typescript-module in extensionless files but proposals for #!/usr/bin/env node --ext mts were rejected because many systems don't support multi-word shebangs.
I don't think this limitation is exclusive to that --ext use cases, there are other options including --permission that cannot be set in a self contained script, yes you can use .env, node.config.json, or package.json but that's no-longer self contained.
This would also be an interesting integration point for package managers that could read dependencies from the frontmatter and support npm x ./script to install the script's inline dependencies.
https://nixos.wiki/wiki/Nix-shell_shebang
https://rust-lang.github.io/rfcs/3424-cargo-script.html
https://packaging.python.org/en/latest/specifications/inline-script-metadata/
What is the feature you are proposing to solve the problem?
The rough outline is for node to parse a leading comment in the main entry point and read command line arguments,
node.config, and package.json fields. The comment would only be read in the main entry point and would sit after explicit options in priority.
#!/usr/bin/env node
// ```node.config.json
// {
// "nodeOptions": { "ext": "mts" },
// "permission": {},
// }
// ```
await main(process.argv.slice(2))
async function main(args: string[]) {
console.log(args)
}
What alternatives have you considered?
Today I'll create directories with package.jsonuse .mts file extensions, or use nasty tricks to combine shell and ts into a single script
#!/bin/sh
':' // ; exec node --ext mts
// script goes here
let n: number = 1;
- Lingua principale
- JavaScript
- Stelle
- 122k
- Fork
- 37.4k
- Merge medio
- 4g 3h
- PR unite (30g)
- 273
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di nodejs/node
-
doc
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
build
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
-
feature request
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
avniproject/avni-client#2135 ·
-
automated broken-link
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
-
agent/security hive/hosted-available-lke648397-260827-5n31 security
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
babalae/bettergi-scripts-list#3674 ·
-
A-Release-Notes C-Editing D-Modest S-Ready-For-Implementation
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
bevyengine/bevy-website#2595 ·