Generated typescript files edit rights - javascript

I'm writting some typescript code and I would like that no other developpers can directly edit compiled files created with Typescript. Is there a way to automaticly make readonly generated files ? Or maybe to encrypt compiled files to force next devs to use typescript original files. I know if I write some comments like "Do not edit this file, use typescript version", they will not necessary be read...

Setting permission to prevent other developers from accessing the typescript files could be a tedious work. I suggest that you add comment on that typescript file that you want to protect from being modified so that other developers would be notified of your intention on that file.

Generally you separate your source files from your build files. Say for example you use Git you would only keep your source files in Git, not your build files. This way whenever another developer wants to work on your project they can only get the source files. They won't be able to change your build files because they do not have access to these.
Encrypting or making the files read only is not the way to go in this scenario. Educate your developers to not edit build files. And only share source files with your developers.

Related

Is there any way to export the current rendered angular page to static HTML along with all the JS functionalities?

I want to export the rendered HTML files with its resources to a zip file in order to share it via mail but i could not find any solution for this usecase. Could you please guide me how to proceed?
The web application is developed using Angular8.
Sure. I guess you had a code test or something: just build your project for development, compress the /dist folder and send it as a compressed file of your choice. Type and execute:
ng build
In the project main folder. Notice that --watch doesn’t help here, since you don’t need a CI/CD. Check the official documentation for more details.

Typescript: is it possible to generate a ts file from declaration file and .js file?

I know declaration files are meant for libraries and not for projects.
But lets assume i have an existing js project that I want to migrate to .ts and I want to start by creating d.ts files for each file in my source.
That way,
1- I don't enforce my team to use typescript while getting the benefits of typescript compiler features in my IDE. People can keep committing .js files. And use of typescript in the project is left to the developer. By creating d.ts files for each file they can get the benefits of type safety.
But it also hinders development in a sense that when a developer changes a js file, the d.ts file for that file also has to be changed. So as a shortcut i want to be able to generate a .ts file from existing d.ts and .js files and do the development there. It makes sense to create a d.ts file and .js file for committing to the remote source so that the source is left clean and approachable by people who are not used to typescript.
2- And can we generate d.ts files with dts-gen to have an head start, then add remaining types manually.
3- Also: compability with react.
4- And, what is the right way to generate dts files for a project that does not consist of a single file? What is the right way to do it in your experience?
So how possible is this pipeline? What are the chances of this working, and what are the barriers that are blocking us? What suggestions can I get for this?
Thanks in advance!
If you have a .d.ts file, you don't need to generate it - so instead of trying to get the compiler to generate the file, you can use a task runner to just copy the original .d.ts file to your desired location.
For example, have a Gulp task to copy the .d.ts from the source folder to your dist folder.

VS 2015- typescript does not generate javascript files

I just installed VS 2015 Community.
After building no js files are created inside the solution or the explorer.
TypeScript is part of Community. The produced .js files aren't part of the project, so you won't see them unless you turn on 'show all files' from the solution explorer. Here is the button you need to press:
Then the .js files will appear after you build:
If you're not seeing these, then check to make sure you're using this project template:
I want to thanks all who tryied to help But the solution in cordova typescript project - The compiled .ts files are inside the www\scripts\appBundle.js.
*you may need to use #Micheal Braude solution to see the appBundle.js file.
thanks agian.
I`m not sure that VS 2015 Enterprise works like Community version, but I tried to explain you, how to create Simple TypeScript project, and configure it for using step by step.
Steps
Create new HTML Application, developed for TypeScript.
When you have done it, you would get something like on image below:
It is a simple structure of application, here we have file app.ts, html view, and css style-sheet.
Configure compilation - What you should to know about this step:
ES target version
Compile single merged file or separate files.
Enter project configurations -->> Open TypeScripts Compilation tab -->>
Choose required ES version in ComboBox -->> Write path to compiled file and it name, if needed (located slightly below).
Add your first file to solution and write some code in it
Create your file.
4.1. If you prefer separate compilation then you should add dependency for your js file into html view. Usually, the *.js file compiled in the same location folder of *.ts file, that`s why targeting on you ts file when write dependency to js file
4.2. If you prefer merged compilation, first that you need - it is configure order of file, it is very simple challenge:
Add into the main file (in my case usually it is app.ts) and write in it list of your dependencies
///<reference path="path/to/file1.ts"/>
///<reference path="path/to/file2.ts"/>
Than, you should replace in html view this default script path:
with path to your final js file
Test your application:
try to add some code that would help you to be ensure that your code works perfectly
run you application and ensure that it works as you expected.
Good Luck! I hope that this post helps you in your beginnings!!
P.S. Here working project.

Rename js files in maven build process with sha1/md5

I need to versioning my javascript files and think the best way is to generate the sha1/md5 of each file and rename it with that result (and the reference to each js file too obviously) during the build process.
This way, when a file content changes, its name changes too and I have not to worry about versioning anymore.
I am trying to find some info about how to make this works with maven but I don't find anything related to.
Any help?

Keeping track of boilerplate webapp code

In a project we are working on we have a bunch of boilerplate code that gets copied to a number of projects. We are using GIT for version control.
Currently I am using a .bat file to copy boilerplate files, set the read-only attribute on each file and apply a comment header to .js, .html and .css files waring the user that this file was generated automatically and not bother editing it.
This is working ok but not foolproof. If the boilerplate code is refactored and items deleted client projects will still have the old file hanging around. Git does not remember windows attributes such as read-only.
Is there a better way of doing this to overcome these restrictions?
I'd recommend using a Git subdmodule for this. You can have a clone/checkout hook that will run your script to add file headers. It won't solve the read-only problem, but that can be circumvented anyway. You can then distribute any updates to your boilerplate by doing git submodule update.
The caveat with this method is that your boilerplate must reside in a single folder. You could copy it out with your script but this will cause more problems than it solves.

Categories