Skip to content

Commit ef04031

Browse files
authored
Add Prettier, format files (#185)
1 parent 6625428 commit ef04031

File tree

14 files changed

+79
-54
lines changed

14 files changed

+79
-54
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
✋ To keep the backlog clean and actionable, issues will be
22
🚫 closed if they do not follow one of the issue templates:
33
👉 https://github.com/react-native-community/template/issues/new/choose
4-

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
name: 🐛 Bug Report
22
description: Report a reproducible bug or regression in React Native Community Template.
3-
labels: ["Needs: Triage :mag:"]
3+
labels: ['Needs: Triage :mag:']
44
body:
55
- type: markdown
66
attributes:
7-
value: "## Reporting a bug to the React Native Community Template"
7+
value: '## Reporting a bug to the React Native Community Template'
88
- type: markdown
99
attributes:
1010
value: |
@@ -42,7 +42,7 @@ body:
4242
attributes:
4343
label: React Native Community Template Version
4444
description: The version of Template that this issue reproduces on. Bear in mind that only issues on the latest version of the Template will be supported.
45-
placeholder: "0.75.0"
45+
placeholder: '0.75.0'
4646
validations:
4747
required: true
4848
- type: dropdown
@@ -107,7 +107,7 @@ body:
107107
attributes:
108108
label: Reproducer
109109
description: A link to the public repository that reproduces this bug, using [this template](https://github.com/react-native-community/reproducer-react-native). Reproducers are **mandatory**.
110-
placeholder: "https://github.com/<myuser>/<myreproducer>"
110+
placeholder: 'https://github.com/<myuser>/<myreproducer>'
111111
validations:
112112
required: true
113113
- type: textarea

.github/workflows/release.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@ on:
44
workflow_dispatch:
55
inputs:
66
version:
7-
description: "The version of the react-native we the template to use in this release. For example 0.75.0-rc.0"
7+
description: 'The version of the react-native we the template to use in this release. For example 0.75.0-rc.0'
88
required: true
99
type: string
1010
is_latest_on_npm:
11-
description: "Whether we want to tag this template release as `latest` on NPM"
11+
description: 'Whether we want to tag this template release as `latest` on NPM'
1212
required: true
1313
type: boolean
1414
default: false
1515
dry_run:
16-
description: "Run without making persistent changes to git or npm"
16+
description: 'Run without making persistent changes to git or npm'
1717
type: boolean
1818
default: true
1919

.github/workflows/tests.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,3 @@ jobs:
1919
node-version: 18
2020
- name: Run unit tests
2121
run: npm install && npm test
22-
23-

.prettierignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
template/android/
2+
template/ios/

.prettierrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
arrowParens: 'avoid',
3+
singleQuote: true,
4+
trailingComma: 'all',
5+
};

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,23 @@ The template used by `npx @react-native-community/cli init` to bootstrap a React
44

55
[![Build Status][build-badge]][build] [![Version][version-badge]][package] [![MIT License][license-badge]][license] [![PRs Welcome][prs-welcome-badge]][prs-welcome]
66

7-
87
# Create Latest CLI Project
8+
99
Using this command create latest react-native project with this template
10+
1011
```
1112
npx @react-native-community/cli@latest init TestApp
1213
```
1314

1415
# Create Specific Version React-Native CLI Project
16+
1517
Add version flag and specify that existing version of react-native to create project.
1618
Note that this command will create a new project from the template using the specific version passed to the flag
1719

1820
npx @react-native-community/cli init TestApp --version <VERSION>
1921

2022
Replace `<VERSION>` with the version number you need. For example: 0.75.2.
2123

22-
2324
## Contents
2425

2526
- [About](#about)

jest.config.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
/** @type {import('jest').Config} */
22
const config = {
3-
coverageProvider: "v8",
4-
testMatch: [
5-
"**/__tests__/*.js",
6-
],
3+
coverageProvider: 'v8',
4+
testMatch: ['**/__tests__/*.js'],
75
};
86

97
module.exports = config;

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"access": "public"
88
},
99
"scripts": {
10+
"format": "prettier --write .",
1011
"test": "jest"
1112
},
1213
"type": "commonjs",
@@ -17,6 +18,7 @@
1718
"dependencies": {},
1819
"devDependencies": {
1920
"jest": "^29.7.0",
21+
"prettier": "^3.6.2",
2022
"semver": "^7.6.3"
2123
},
2224
"homepage": "https://github.com/react-native-community/template/tree/main",
Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,37 @@
1-
const {execSync, exec: _exec} = require('child_process');
1+
const { execSync, exec: _exec } = require('child_process');
22
const fs = require('fs');
3-
const {promisify} = require('util');
3+
const { promisify } = require('util');
44
const path = require('path');
55
const semver = require('semver');
66

77
function run(version) {
8-
return execSync(`./bumpedTemplateVersion.sh ${version}`, { cwd: 'scripts', stdio: ['ignore', 'pipe', 'ignore'] }).toString().trim();
8+
return execSync(`./bumpedTemplateVersion.sh ${version}`, {
9+
cwd: 'scripts',
10+
stdio: ['ignore', 'pipe', 'ignore'],
11+
})
12+
.toString()
13+
.trim();
914
}
1015

11-
const FIFO_PATH = '/tmp/_npm_fifo'
16+
const FIFO_PATH = '/tmp/_npm_fifo';
1217

1318
const exec = promisify(_exec);
1419
const writeFile = promisify(fs.writeFile);
1520

1621
async function runStubbedNpm(version, response) {
1722
cleanUpStubbedNpm();
1823
execSync(`mkfifo ${FIFO_PATH}`);
19-
return Promise.all(
20-
[
21-
writeFile(FIFO_PATH, JSON.stringify(response)),
22-
exec(`./bumpedTemplateVersion.sh ${version}`, {
23-
cwd: 'scripts',
24-
stdio: ['ignore', 'pipe', 'ignore'],
25-
env: {
26-
PATH: `${__dirname}/stub:${process.env.PATH}`,
27-
NPM_STUB_FIFO: FIFO_PATH,
28-
}
29-
}).then(raw => raw.stdout.toString().trim()),
30-
]
31-
).then(([, resp]) => resp);
24+
return Promise.all([
25+
writeFile(FIFO_PATH, JSON.stringify(response)),
26+
exec(`./bumpedTemplateVersion.sh ${version}`, {
27+
cwd: 'scripts',
28+
stdio: ['ignore', 'pipe', 'ignore'],
29+
env: {
30+
PATH: `${__dirname}/stub:${process.env.PATH}`,
31+
NPM_STUB_FIFO: FIFO_PATH,
32+
},
33+
}).then(raw => raw.stdout.toString().trim()),
34+
]).then(([, resp]) => resp);
3235
}
3336

3437
function cleanUpStubbedNpm() {
@@ -40,9 +43,10 @@ function cleanUpStubbedNpm() {
4043
}
4144

4245
describe('bumpTemplateVersion.sh', () => {
43-
4446
it('nightlies stay the same', () => {
45-
expect(run('0.75.0-nightly-20240606-4324f0874')).toEqual('0.75.0-nightly-20240606-4324f0874');
47+
expect(run('0.75.0-nightly-20240606-4324f0874')).toEqual(
48+
'0.75.0-nightly-20240606-4324f0874',
49+
);
4650
});
4751

4852
it('release candidates appended with a sha', () => {
@@ -56,24 +60,32 @@ describe('bumpTemplateVersion.sh', () => {
5660

5761
it('bumps the patch if a version of the template already exists', async () => {
5862
// This sucks I know:
59-
const {version} = await fetch('https://registry.npmjs.com/@react-native-community/template/latest').then(resp => resp.json());
60-
const {major, minor, patch} = semver.parse(version);
61-
expect(run(`${major}.${minor}.${patch}`)).toEqual(`${major}.${minor}.${patch+1}`);
63+
const { version } = await fetch(
64+
'https://registry.npmjs.com/@react-native-community/template/latest',
65+
).then(resp => resp.json());
66+
const { major, minor, patch } = semver.parse(version);
67+
expect(run(`${major}.${minor}.${patch}`)).toEqual(
68+
`${major}.${minor}.${patch + 1}`,
69+
);
6270
});
6371

6472
describe('handles different npm responses', () => {
6573
afterAll(cleanUpStubbedNpm);
6674
it('arrays of versions', async () => {
67-
expect(await runStubbedNpm('0.76.0', [
68-
{ version: '0.76.0' },
69-
{ version: '0.76.2' },
70-
// Expecting +1 on this:
71-
{ version: '0.76.3' },
72-
])).toEqual('0.76.4');
75+
expect(
76+
await runStubbedNpm('0.76.0', [
77+
{ version: '0.76.0' },
78+
{ version: '0.76.2' },
79+
// Expecting +1 on this:
80+
{ version: '0.76.3' },
81+
]),
82+
).toEqual('0.76.4');
7383
});
7484

7585
it('single version', async () => {
76-
expect(await runStubbedNpm('0.76.0', { version: '0.76.0' })).toEqual('0.76.1');
86+
expect(await runStubbedNpm('0.76.0', { version: '0.76.0' })).toEqual(
87+
'0.76.1',
88+
);
7789
});
7890
});
7991
});

0 commit comments

Comments
 (0)