Skip to content

Commit 5c527bb

Browse files
committed
Reorganize monorepo scripts
1 parent ba07ebb commit 5c527bb

12 files changed

+68
-74
lines changed

package-lock.json

+15-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
"prettier": "prettier --write \"**/*.js\" \"**/*.ts\"",
1212
"prettier:report": "prettier --check \"**/*.js\"",
1313
"lint": "npm run lint:report -- --fix",
14-
"lint:report": "eslint",
14+
"lint:report": "eslint packages tools",
15+
"release": "tools/npm/release.js",
1516
"test:packages": "npm run test --workspaces --if-present",
1617
"test": "npm run build && npm run flow && npm run test:packages && npm run prettier:report && npm run lint:report"
1718
},
@@ -38,7 +39,7 @@
3839
"prettier": "^3.5.0",
3940
"prettier-plugin-hermes-parser": "^0.26.0",
4041
"rimraf": "^5.0.10",
41-
"typescript": "^5.3.3"
42+
"yargs": "17.7.2"
4243
},
4344
"prettier": {
4445
"singleQuote": true,

packages/cli/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"yargs": "^17.7.2"
2828
},
2929
"devDependencies": {
30-
"@stylexjs/scripts": "0.11.1"
30+
"scripts": "0.11.1"
3131
},
3232
"bin": {
3333
"stylex": "./lib/index.js"

packages/scripts/README.md

+2-36
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,3 @@
1-
# @stylexjs/scripts
1+
# scripts
22

3-
Private scripts used by the monorepo.
4-
5-
## How to create a release
6-
7-
The release script (run from the monorepo root) must be used to create and publish releases.
8-
9-
```shell
10-
npm run release
11-
# workspace
12-
-w @stylexjs/scripts --
13-
# package version (required)
14-
--pkg-version 0.10.2
15-
# creates git commit and tag
16-
--commit
17-
# publishes to npm using 2fa
18-
--publish --otp 123456
19-
```
20-
21-
You can perform a dry run by only specifying the new version for a release:
22-
23-
```shell
24-
npm run release -w @stylexjs/scripts -- --pkg-version 0.10.2
25-
```
26-
27-
To commit and tag the release:
28-
29-
```shell
30-
npm run release -w @stylexjs/scripts -- --pkg-version 0.10.2 --commit
31-
```
32-
33-
To publish the release:
34-
35-
```shell
36-
npm run release -w @stylexjs/scripts -- --pkg-version 0.10.2 --publish
37-
```
3+
Private CLI scripts that can be installed and used by packages within the monorepo as part of their dev and build processes.

packages/scripts/gen-types.js packages/scripts/flow-translator/generate-types.js

+4-8
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,15 @@
99
*/
1010

1111
const fsPromises = require('fs/promises');
12-
const monorepoPackage = require('../../package.json');
12+
const monorepoPackage = require('../../../package.json');
1313
const path = require('path');
1414
const translate = require('flow-api-translator');
15+
const utils = require('./flow-module-utils');
1516
const yargs = require('yargs/yargs');
1617

17-
const {
18-
findFlowModules,
19-
patchFlowModulePaths,
20-
} = require('./handle-flow-modules');
21-
2218
async function generateTypes(inputDir, outputDir, rootDir) {
2319
const rootPath = rootDir ?? path.resolve(inputDir, '../');
24-
const flowModules = await findFlowModules(inputDir, rootPath);
20+
const flowModules = await utils.findFlowModules(inputDir, rootPath);
2521

2622
await fsPromises.mkdir(outputDir, { recursive: true });
2723
let dirents = await fsPromises.readdir(inputDir, { withFileTypes: true });
@@ -85,7 +81,7 @@ async function generateTypes(inputDir, outputDir, rootDir) {
8581

8682
await fsPromises.writeFile(
8783
`${outputFullPath}.flow`,
88-
patchFlowModulePaths(
84+
utils.patchFlowModulePaths(
8985
outputFullPath,
9086
outputFlowContents,
9187
flowModules,

packages/scripts/rewrite-imports.js packages/scripts/flow-translator/rewrite-imports.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* This source code is licensed under the MIT license found in the
66
* LICENSE file in the root directory of this source tree.
77
*
8-
* @flow
8+
*
99
*/
1010

1111
const fs = require('fs').promises;

packages/scripts/package.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
{
22
"private": true,
3-
"name": "@stylexjs/scripts",
3+
"name": "scripts",
44
"version": "0.11.1",
55
"description": "Helper scripts for stylex monorepo.",
66
"license": "MIT",
77
"bin": {
8-
"gen-types": "./gen-types.js",
9-
"rewrite-imports": "./rewrite-imports.js"
10-
},
11-
"scripts": {
12-
"release": "./create-release.js"
8+
"gen-types": "./flow-translator/generate-types.js",
9+
"rewrite-imports": "./flow-translator/rewrite-imports.js"
1310
},
1411
"dependencies": {
1512
"flow-api-translator": "0.26.0",

packages/shared/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
"@babel/preset-flow": "^7.25.9",
2525
"@babel/preset-react": "^7.26.3",
2626
"@babel/preset-typescript": "^7.26.0",
27-
"@stylexjs/scripts": "0.11.1",
28-
"babel-plugin-syntax-hermes-parser": "^0.26.0"
27+
"babel-plugin-syntax-hermes-parser": "^0.26.0",
28+
"scripts": "0.11.1"
2929
},
3030
"jest": {
3131
"snapshotFormat": {

packages/stylex/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,10 @@
6363
"@rollup/plugin-json": "^6.1.0",
6464
"@rollup/plugin-node-resolve": "^15.3.0",
6565
"@rollup/plugin-replace": "^6.0.1",
66-
"@stylexjs/scripts": "0.11.1",
6766
"babel-plugin-syntax-hermes-parser": "^0.26.0",
6867
"cross-env": "^7.0.3",
69-
"rollup": "^4.24.0"
68+
"rollup": "^4.24.0",
69+
"scripts": "0.11.1"
7070
},
7171
"jest": {},
7272
"files": [

tools/README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Tools
2+
3+
Tools used to manage monorepo tasks like pre-commit hooks and npm releases.
4+
5+
## How to create a release
6+
7+
The release script (run from the monorepo root) must be used to create and publish releases.
8+
9+
```shell
10+
npm run release
11+
# package version (required)
12+
--pkg-version 0.10.2
13+
# creates git commit and tag
14+
--commit
15+
# publishes to npm using 2fa
16+
--publish --otp 123456
17+
```
18+
19+
You can perform a dry run by only specifying the new version for a release:
20+
21+
```shell
22+
npm run release -- --pkg-version 0.10.2
23+
```
24+
25+
To commit and tag the release:
26+
27+
```shell
28+
npm run release -- --pkg-version 0.10.2 --commit
29+
```
30+
31+
To publish the release:
32+
33+
```shell
34+
npm run release -- --pkg-version 0.10.2 --publish
35+
```
File renamed without changes.

0 commit comments

Comments
 (0)