From 4586b03f4ab05aabb58792fc7ba7637059e89634 Mon Sep 17 00:00:00 2001 From: matthieu-crouzet Date: Thu, 19 Dec 2024 14:29:10 +0100 Subject: [PATCH] fix(#2628): generate eol LF config --- packages/@o3r/create/src/index.ts | 15 +++++++++++ .../workspace/schematics/index.it.spec.ts | 1 + .../schematics/ng-add/project-setup.ts | 14 ++++++++++ .../new-version/packaged-action/LICENSE.txt | 27 +++++++++++++++++++ 4 files changed, 57 insertions(+) diff --git a/packages/@o3r/create/src/index.ts b/packages/@o3r/create/src/index.ts index f0c014c4d2..39853043aa 100644 --- a/packages/@o3r/create/src/index.ts +++ b/packages/@o3r/create/src/index.ts @@ -265,6 +265,21 @@ const prepareWorkspace = (relativeDirectory = '.', projectPackageManager = 'npm' } } + writeFileSync( + resolve(cwd, '.gitattributes'), + [ + '* text eol=lf', + '', + '# Binary files', + '*.png binary', + '*.jpg binary', + '*.gif binary', + '*.jar binary', + '*.ico binary', + '' + ].join('\n') + ); + exitProcessIfErrorInSpawnSync(INSTALL_PROCESS_ERROR_CODE, spawnSync(runner, ['install'], spawnSyncOpts)); }; diff --git a/packages/@o3r/workspace/schematics/index.it.spec.ts b/packages/@o3r/workspace/schematics/index.it.spec.ts index bcc0750764..896c6fd7c0 100644 --- a/packages/@o3r/workspace/schematics/index.it.spec.ts +++ b/packages/@o3r/workspace/schematics/index.it.spec.ts @@ -133,5 +133,6 @@ describe('new otter workspace', () => { expect(rootPackageJson.workspaces).toContain('libs/*'); expect(rootPackageJson.workspaces).toContain('apps/*'); expect(existsSync(path.join(workspacePath, '.renovaterc.json'))).toBe(true); + expect(existsSync(path.join(workspacePath, '.editorconfig'))).toBe(true); }); }); diff --git a/packages/@o3r/workspace/schematics/ng-add/project-setup.ts b/packages/@o3r/workspace/schematics/ng-add/project-setup.ts index 5f5b90fc7d..5dc3a6301b 100644 --- a/packages/@o3r/workspace/schematics/ng-add/project-setup.ts +++ b/packages/@o3r/workspace/schematics/ng-add/project-setup.ts @@ -40,6 +40,19 @@ import type { NgAddSchematicsSchema, } from './schema'; +const updateEditorConfig: Rule = (tree) => { + const editorconfigPath = '.editorconfig'; + const editorconfig = tree.exists(editorconfigPath) ? tree.readText(editorconfigPath) : ''; + if (editorconfig.includes('end_of_line')) { + return tree; + } + const newEditorconfig = /\[[*]\]/.test(editorconfig) + ? editorconfig.replace(/(\[[*]\])/, '$1\nend_of_line = lf') + : editorconfig.concat('[*]\nend_of_line = lf'); + tree.overwrite(editorconfigPath, newEditorconfig); + return tree; +}; + /** * Enable all the otter features requested by the user * Install all the related dependencies and import the features inside the application @@ -89,6 +102,7 @@ export const prepareProject = (options: NgAddSchematicsSchema): Rule => { return () => chain([ generateRenovateConfig(__dirname), + updateEditorConfig, addVsCodeRecommendations(vsCodeExtensions), updateGitIgnore(workspaceConfig), filterPackageJsonScripts, diff --git a/tools/github-actions/new-version/packaged-action/LICENSE.txt b/tools/github-actions/new-version/packaged-action/LICENSE.txt index 7ee631dd7c..4ec329636a 100644 --- a/tools/github-actions/new-version/packaged-action/LICENSE.txt +++ b/tools/github-actions/new-version/packaged-action/LICENSE.txt @@ -94,6 +94,33 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @o3r/new-version +Copyright Amadeus SAS + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors +may be used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + @octokit/auth-token MIT