Skip to content

Commit

Permalink
fix: convert underscore files to dotfiles (a la RN CLI) (#924)
Browse files Browse the repository at this point in the history
* Fix issue with vercel dependency and TS errors

* Convert underscore files to dotfiles (as in RN CLI)

* Update src/Examples.ts

Co-authored-by: Cedric van Putten <[email protected]>

---------

Co-authored-by: Cedric van Putten <[email protected]>
  • Loading branch information
douglowder and byCedric authored May 18, 2023
1 parent 847aa92 commit 11507c8
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@types/node": "^12.6.8",
"@types/prompts": "2.0.8",
"@types/tar": "4.0.3",
"@vercel/ncc": "^0.27.0",
"@vercel/ncc": "^0.36.1",
"babel-jest": "^26.0.1",
"chalk": "2.4.2",
"commander": "2.20.0",
Expand Down
1 change: 1 addition & 0 deletions src/Examples.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export async function resolveTemplateArgAsync(
// @ts-ignore
repoUrl = new URL(template);
} catch (error) {
// @ts-expect-error
if (error.code !== 'ERR_INVALID_URL') {
oraInstance.fail(error);
process.exit(1);
Expand Down
20 changes: 20 additions & 0 deletions src/createFileTransform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,23 @@ class Transformer extends Minipass {
}
}

// Files and directories that have `_` as their first character in React Native CLI templates
// These should be transformed to have `.` as the first character
const UNDERSCORED_DOTFILES = [
'buckconfig',
'eslintrc.js',
'flowconfig',
'gitattributes',
'gitignore',
'prettierrc.js',
'watchmanconfig',
'editorconfig',
'bundle',
'ruby-version',
'node-version',
'xcode.env',
];

export function createEntryResolver(name: string) {
return (entry: ReadEntry) => {
if (name) {
Expand All @@ -46,6 +63,9 @@ export function createEntryResolver(name: string) {
// See: https://github.com/npm/npm/issues/1862
entry.path = entry.path.replace(/gitignore$/, '.gitignore');
}
for (const fileName of UNDERSCORED_DOTFILES) {
entry.path = entry.path.replace(`_${fileName}`, `.${fileName}`);
}
};
}

Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1310,10 +1310,10 @@
semver "^6.3.0"
tsutils "^3.17.1"

"@vercel/ncc@^0.27.0":
version "0.27.0"
resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.27.0.tgz#c0cfeebb0bebb56052719efa4a0ecc090a932c76"
integrity sha512-DllIJQapnU2YwewIhh/4dYesmMQw3h2cFtabECc/zSJHqUbNa0eJuEkRa6DXbZvh1YPWBtYQoPV17NlDpBw1Vw==
"@vercel/ncc@^0.36.1":
version "0.36.1"
resolved "https://registry.yarnpkg.com/@vercel/ncc/-/ncc-0.36.1.tgz#d4c01fdbbe909d128d1bf11c7f8b5431654c5b95"
integrity sha512-S4cL7Taa9yb5qbv+6wLgiKVZ03Qfkc4jGRuiUQMQ8HGBD5pcNRnHeYM33zBvJE4/zJGjJJ8GScB+WmTsn9mORw==

abab@^2.0.3:
version "2.0.3"
Expand Down

0 comments on commit 11507c8

Please sign in to comment.