angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Allow schematics to create file with permissions

Open bgotink opened this issue 7 years ago • 7 comments

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:

{
  "//": "...",
  "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

bgotink avatar Aug 05 '18 22:08 bgotink

Does this solution works in Windows??

sdharagit avatar Dec 08 '20 16:12 sdharagit

Thanks to https://github.com/nrwl/nx/issues/5680 it is working with Nx :heart_eyes:

hadrien-toma avatar Aug 02 '21 12:08 hadrien-toma

I'm the author of that PR on https://github.com/nrwl/nx/issues/5680 😇.

I will submit a similar PR for the CLI, hoping it gets accepted as well. ^^

Cheers

tinesoft avatar Aug 02 '21 14:08 tinesoft

Arf it seems it finally doesn't work with the current latest version @tinesoft :cry: https://github.com/nrwl/nx/issues/6590

hadrien-toma avatar Aug 03 '21 13:08 hadrien-toma

It now working again as expected thanks to https://github.com/nrwl/nx/pull/6592 :heart_eyes: :rocket:

hadrien-toma avatar Aug 04 '21 06:08 hadrien-toma

Just a heads up that we kicked off a community voting process for your feature request. There are 20 days until the voting process ends.

Find more details about Angular's feature request process in our documentation.

angular-robot[bot] avatar Feb 01 '22 18:02 angular-robot[bot]

Thank you for submitting your feature request! Looks like during the polling process it didn't collect a sufficient number of votes to move to the next stage.

We want to keep Angular rich and ergonomic and at the same time be mindful about its scope and learning journey. If you think your request could live outside Angular's scope, we'd encourage you to collaborate with the community on publishing it as an open source package.

You can find more details about the feature request process in our documentation.

angular-robot[bot] avatar Feb 21 '22 13:02 angular-robot[bot]