angular / angular/angular-cli

Allow schematics to create file with permissions

Ouverte
#11,781 7 commentaires 6 réactions 0 personnes assignées Voir sur GitHub
area: @angular-devkit/schematics feature feature: insufficient votes
Langage dominant
TypeScript
Étoiles
27k
Forks
11.8k
Merge moyen
14 h 23 min
PR mergées (30 j)
162

Description

### Bug Report or Feature Request (mark with an `x`)
```
- [ ] bug report -> please search issues before submitting
- [x] feature request
```

### Versions

any

### Desired functionality

I'm writing schematics to help colleagues scaffold applications and libraries following our internal guidelines. One part of our set-up is the use of a file called `Taskfile` to contain scripts instead of cramming complicated one-liners in yarn run-scripts. This file should be executable, but a schematic cannot create executable files. The result is a broken package because `./Taskfile: Permission denied`.

I've got a simple workaround:

The schematic in question is based on `@schematics/angular:library`. It runs the `NodePackageInstallTask` at the end. This allows me to create a selfdestructing `preinstall` script in the newly scaffolded `package.json`:

```json
{
"//": "...",
"scripts": {
"preinstall": "chmod +x Taskfile && ex +g/preinstall/d -cwq package.json",
"prepublish": "./Taskfile build",
"test": "./Taskfile test"
}
}
```

This works, but it feels like a hack to me. It would be cleaner if either

- file permissions were respected, as the source file for the scaffold has correct permissions; or
- the schematic could modify permissions

Guide de contribution

Ouvrir le guide de contribution

Piste de recherche

Commencez par le point d’entrée @schematics/angular:library et suivez la manière dont il crée des fichiers avant l’exécution de NodePackageInstallTask. Utilisez la Taskfile exécutable et le contournement généré pour package.json comme cas de reproduction. Le travail est terminé lorsqu’un schematic peut créer ou modifier un fichier avec des permissions d’exécution sans dépendre du script de preinstall qui s’autodétruit.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Évaluation

Stack technique
angular, typescript
Domaine
cli
Type d'issue
Fonctionnalité
Difficulté
4/5
Temps estimé
3-5 jours
Activité
À l'abandon
Clarté
Plutôt claire
Accessibilité débutants
35/100

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.