Commit Graph

6 Commits

Author SHA1 Message Date
Fabien "egg" O'Carroll
104f84f252 Added eslint rule for file naming convention
As discussed with the product team we want to enforce kebab-case file names for
all files, with the exception of files which export a single class, in which
case they should be PascalCase and reflect the class which they export.

This will help find classes faster, and should push better naming for them too.

Some files and packages have been excluded from this linting, specifically when
a library or framework depends on the naming of a file for the functionality
e.g. Ember, knex-migrator, adapter-manager
2023-05-09 12:34:34 -04:00
Simon Backx
e1bee3c647
Implemented admin auth origin check (#15135)
refs https://github.com/TryGhost/Team/issues/1694

- Added replacements option to `@tryghost/minifier` + updated documentation and name of 'options' param which was a bit confusing. 
- At compile time, we'll replace `'{{SITE_ORIGIN}}'` with the actual and JS encoded origin string.
- Block requests to the auth frame with the wrong origin, but log a warning for now to make debugging easier.
- Limit who can read the response messages by origin
2022-08-03 15:59:08 +02:00
Hannah Wolfe
0ffeee6712 🐛 Ensured directory exists before attempting write
- Currently, nothing happens if the file doesn't exist, the error is swallowed
- This module should ensure the directory exists at the point of write, else Ghost has to do too much
- TODO: improve the testing and error handling here as well
2021-11-19 12:50:54 +00:00
Hannah Wolfe
2a5d7f225c Reworked minifier to have 100% coverage
- As a library, minifier should be subject to 100% coverage
- minor change to the code combining globbing and file reading into a single function for error handling any case where the files can't be found or read
   - we could do more fine grained errors here, but that seems unnecessary given that the usecase is internal, not for user files at the moment
- added error case tests to capture all the uncovered lines
2021-11-03 14:25:02 +00:00
Hannah Wolfe
19383f27f7 Switched uglify for terser + bugfixes
- Uglify was really slow and clunky, so replaced with terser which is fast and simple
- Ensured test cleanup works properly so we can be sure about the state of files during tests
- Changed the output from being the absolute path to just the "dest" value, as that is much more useful as absolute paths include local machine path names
- Fixed async/await issue that got the whole thing working 100%
2021-11-03 14:19:17 +00:00
Hannah Wolfe
03b1e9c3bd Minifier initial version
- wired up a basic minification package
- accepts config for css or js files and can concat and minify them into a single file for each type
- this will be used for generating merged css and js files for various cards, controlled by theme config
2021-11-03 14:16:49 +00:00