Skip to content

Commit

Permalink
fix(#2628): generate eol LF config (#2635)
Browse files Browse the repository at this point in the history
## Proposed change

Generate eol LF config

## Related issues

<!--
Please make sure to follow the [contribution
guidelines](https://github.com/amadeus-digital/Otter/blob/main/CONTRIBUTING.md)
-->

<!-- * 🐛 Fix #issue -->
* 🐛 Fix resolves #2628
<!-- * 🚀 Feature #issue -->
<!-- * 🚀 Feature resolves #issue -->
<!-- * :octocat: Pull Request #issue -->
  • Loading branch information
matthieu-crouzet authored Jan 10, 2025
2 parents a083fe5 + 4586b03 commit 897af75
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/@o3r/create/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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));
};

Expand Down
1 change: 1 addition & 0 deletions packages/@o3r/workspace/schematics/index.it.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
14 changes: 14 additions & 0 deletions packages/@o3r/workspace/schematics/ng-add/project-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -89,6 +102,7 @@ export const prepareProject = (options: NgAddSchematicsSchema): Rule => {

return () => chain([
generateRenovateConfig(__dirname),
updateEditorConfig,
addVsCodeRecommendations(vsCodeExtensions),
updateGitIgnore(workspaceConfig),
filterPackageJsonScripts,
Expand Down
27 changes: 27 additions & 0 deletions tools/github-actions/new-version/packaged-action/LICENSE.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 897af75

Please sign in to comment.