Skip to content

Commit 23199ac

Browse files
authored
chore: don't publish internal scripts (#954)
1 parent b0d5197 commit 23199ac

File tree

10 files changed

+46
-31
lines changed

10 files changed

+46
-31
lines changed

.github/actions/cocoapods/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ runs:
1414
id: cache-key-generator
1515
run: |
1616
if [[ -f ${{ inputs.working-directory }}/${{ inputs.project-directory }}/Podfile.lock ]]; then
17-
echo "::set-output name=cache-key::$(node scripts/shasum.js ${{ inputs.working-directory }}/${{ inputs.project-directory }}/Podfile.lock)"
17+
echo "::set-output name=cache-key::$(node scripts/shasum.mjs ${{ inputs.working-directory }}/${{ inputs.project-directory }}/Podfile.lock)"
1818
else
1919
echo '::set-output name=cache-key::false'
2020
fi

.github/actions/init-test-app/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ runs:
99
steps:
1010
- name: Generate cache key
1111
id: cache-key-generator
12-
run: echo "::set-output name=cache-key::$(node scripts/shasum.js yarn.lock)"
12+
run: echo "::set-output name=cache-key::$(node scripts/shasum.mjs yarn.lock)"
1313
shell: bash
1414
- name: Cache /.yarn/cache
1515
uses: actions/cache@v3

.github/actions/setup-toolchain/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ runs:
3434
id: cache-key-generator
3535
run: |
3636
if [[ -f example/${{ inputs.platform }}/Podfile.lock ]]; then
37-
echo "::set-output name=cache-key::$(node scripts/shasum.js example/${{ inputs.platform }}/Podfile.lock)"
37+
echo "::set-output name=cache-key::$(node scripts/shasum.mjs example/${{ inputs.platform }}/Podfile.lock)"
3838
else
3939
echo '::set-output name=cache-key::false'
4040
fi

.github/actions/yarn/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ runs:
99
steps:
1010
- name: Generate cache key
1111
id: cache-key-generator
12-
run: echo "::set-output name=cache-key::$(node scripts/shasum.js yarn.lock)"
12+
run: echo "::set-output name=cache-key::$(node scripts/shasum.mjs yarn.lock)"
1313
shell: bash
1414
- name: Cache /.yarn/cache
1515
uses: actions/cache@v3

.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ jobs:
9090
# Ignore errors until we can create a GitHub PAT from a system
9191
# account.
9292
if [[ ${{ matrix.platform }} == macos ]]; then
93-
scripts/prettier-diff.js $(git ls-files '*.js' '*.yml' 'test/**/*.json') || true
93+
scripts/prettier-diff.mjs $(git ls-files '*.js' '*.yml' 'test/**/*.json') || true
9494
echo "::add-matcher::.github/eslint-stylish.json"
9595
npm run lint:js
9696
echo "::remove-matcher owner=eslint-stylish::"

CONTRIBUTING.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,20 @@ For more information see the
1717
contact [[email protected]](mailto:[email protected]) with any
1818
additional questions or comments.
1919

20-
## Commit messages
20+
## Commit Messages
2121

2222
This repository adheres to the
2323
[conventional commit format](https://conventionalcommits.org) via
2424
[commitlint](https://github.com/conventional-changelog/commitlint/#what-is-commitlint).
2525
Commit messages must match the pattern:
2626

2727
```sh
28-
type(scope?): subject #scope is optional; multiple scopes are supported (current delimiter options: "/", "\" and ",")
28+
type(scope?): subject
2929
```
3030

31+
Scope is optional. You can also specify multiple scopes using `/` or `,` as
32+
delimiters.
33+
3134
Following this is necessary to pass CI.
3235

3336
## Additional Dependencies
@@ -158,7 +161,18 @@ If you choose to use Visual Studio, remember to first set the target platform to
158161
> re-run `install-windows-test-app` to make sure that the changes are included
159162
> in the Visual Studio project.
160163
161-
### Testing Other React Native Versions
164+
## Adding New Files
165+
166+
When adding new files, please make sure they are published (or not if it's for
167+
internal use only). To get a list of files that get published, you can run:
168+
169+
```sh
170+
npm pack --dry-run --verbose
171+
```
172+
173+
If your files are missing, you can modify the `files` section in `package.json`.
174+
175+
## Testing Specific React Native Versions
162176

163177
`react-native-test-app` supports multiple versions of React Native. Use
164178
`set-react-version` to set the version, e.g. to use 0.68:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"/ios",
3636
"/macos",
3737
"/schema.json",
38-
"/scripts",
38+
"/scripts/*.js",
3939
"/windows/*.{js,props,sln}",
4040
"/windows/ReactTestApp"
4141
],

scripts/prettier-diff.js

Lines changed: 0 additions & 18 deletions
This file was deleted.

scripts/prettier-diff.mjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env node
2+
// @ts-check
3+
4+
import { spawnSync } from "node:child_process";
5+
import { readFileSync } from "node:fs";
6+
import { format } from "prettier";
7+
import suggest from "suggestion-bot";
8+
9+
const diff = process.argv.slice(2).reduce((diff, filepath) => {
10+
const source = readFileSync(filepath, { encoding: "utf-8" });
11+
const { stdout } = spawnSync("diff", ["--unified", filepath, "-"], {
12+
input: format(source, { filepath }),
13+
encoding: "utf-8",
14+
});
15+
return diff + stdout;
16+
}, "");
17+
18+
suggest(diff);

scripts/shasum.js renamed to scripts/shasum.mjs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
#!/usr/bin/env node
22
// @ts-check
33

4+
import { createHash } from "node:crypto";
5+
import { readFileSync } from "node:fs";
6+
47
/**
58
* @param {string} filename
69
* @param {string=} algorithm
710
* @returns {string}
811
*/
912
function hashFile(filename, algorithm = "sha256") {
10-
const data = require("fs")
11-
.readFileSync(filename, { encoding: "utf-8" })
12-
.replace(/\r/g, "");
13-
return require("crypto").createHash(algorithm).update(data).digest("hex");
13+
const data = readFileSync(filename, { encoding: "utf-8" }).replace(/\r/g, "");
14+
return createHash(algorithm).update(data).digest("hex");
1415
}
1516

1617
const { [2]: filename } = process.argv;

0 commit comments

Comments
 (0)