Skip to content

Commit 11507c8

Browse files
douglowderbyCedric
andauthored
fix: convert underscore files to dotfiles (a la RN CLI) (#924)
* 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]>
1 parent 847aa92 commit 11507c8

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"@types/node": "^12.6.8",
5858
"@types/prompts": "2.0.8",
5959
"@types/tar": "4.0.3",
60-
"@vercel/ncc": "^0.27.0",
60+
"@vercel/ncc": "^0.36.1",
6161
"babel-jest": "^26.0.1",
6262
"chalk": "2.4.2",
6363
"commander": "2.20.0",

src/Examples.ts

+1
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ export async function resolveTemplateArgAsync(
151151
// @ts-ignore
152152
repoUrl = new URL(template);
153153
} catch (error) {
154+
// @ts-expect-error
154155
if (error.code !== 'ERR_INVALID_URL') {
155156
oraInstance.fail(error);
156157
process.exit(1);

src/createFileTransform.ts

+20
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,23 @@ class Transformer extends Minipass {
3030
}
3131
}
3232

33+
// Files and directories that have `_` as their first character in React Native CLI templates
34+
// These should be transformed to have `.` as the first character
35+
const UNDERSCORED_DOTFILES = [
36+
'buckconfig',
37+
'eslintrc.js',
38+
'flowconfig',
39+
'gitattributes',
40+
'gitignore',
41+
'prettierrc.js',
42+
'watchmanconfig',
43+
'editorconfig',
44+
'bundle',
45+
'ruby-version',
46+
'node-version',
47+
'xcode.env',
48+
];
49+
3350
export function createEntryResolver(name: string) {
3451
return (entry: ReadEntry) => {
3552
if (name) {
@@ -46,6 +63,9 @@ export function createEntryResolver(name: string) {
4663
// See: https://github.com/npm/npm/issues/1862
4764
entry.path = entry.path.replace(/gitignore$/, '.gitignore');
4865
}
66+
for (const fileName of UNDERSCORED_DOTFILES) {
67+
entry.path = entry.path.replace(`_${fileName}`, `.${fileName}`);
68+
}
4969
};
5070
}
5171

yarn.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -1310,10 +1310,10 @@
13101310
semver "^6.3.0"
13111311
tsutils "^3.17.1"
13121312

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

13181318
abab@^2.0.3:
13191319
version "2.0.3"

0 commit comments

Comments
 (0)