Skip to content

Commit dcb5656

Browse files
chore: verdaccio setup (#35)
* chore: setup verdaccio tweaks chore: verdaccio setup chore: verdaccio setup chore: tweaks fix ci fix fix fix fix fix local e2e debug fix fix * fix typecheck * debug * fix * fix * disable tests * debug * publish template package * fix merging of NPM-based templates * cleanup * remove `publishConfig` * fix * move verdaccio config * remove sleep * fix * restore sleep * tweaks * more tweaks * code review changes * code review: limit create app steps * replaceAll * packageJson field removal * improve verdaccio startup script * chore tweaks * improve verdaccio init script * simplify verdaccio config * pnpm lock * swap execa for nano-spawn * handle also sigterm * backup file * more tweaks * run verdaccio in bg on ci * fix help * use npm publish instead of pnpm publish * fix issue with removed +x flag on gradlew * fix * fix pnpm install * improve ci stability * docs * fix typo * refactor: cleanup template handling in packages (#47) * move template dirs * fix output package structure * remove: *.md from nx/tsc assets (advised by jbroma) * remove dist/package.json after build * fix package.json resolution in cli --------- Co-authored-by: Michał Pierzchała <[email protected]>
1 parent bcc20b7 commit dcb5656

File tree

99 files changed

+865
-456
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+865
-456
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,22 @@ jobs:
3232
- uses: nrwl/nx-set-shas@v4
3333

3434
# Nx Affected runs only tasks affected by the changes in this PR/commit. Learn more: https://nx.dev/ci/features/affected
35-
- run: pnpm exec nx affected -t typecheck lint
36-
- run: pnpm exec nx affected -t test
37-
- run: pnpm exec nx affected -t build
38-
- run: pnpm exec nx affected -t e2e
35+
- name: Typecheck and lint
36+
run: pnpm exec nx affected -t typecheck lint
37+
38+
- name: Run tests
39+
run: pnpm exec nx affected -t test
40+
41+
- name: Build
42+
run: pnpm build
43+
44+
- name: Run end-to-end tests
45+
run: |
46+
# Run in background
47+
pnpm verdaccio:init &
48+
49+
npx [email protected] http://localhost:4873
50+
pnpm verdaccio:publish
51+
52+
NPM_CONFIG_REGISTRY=http://localhost:4873 pnpm exec nx affected -t e2e
53+

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
dist
55
tmp
66
/out-tsc
7+
*.orig
78

89
# dependencies
910
node_modules

.npmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
strict-peer-dependencies=false
1+
link-workspace-packages=true
22
auto-install-peers=true

.verdaccio/config.yml

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,19 @@
1-
# path to a directory with all packages
2-
storage: ../tmp/local-registry/storage
1+
storage: /tmp/verdaccio-storage
32

4-
# a list of other known repositories we can talk to
53
uplinks:
64
npmjs:
75
url: https://registry.npmjs.org/
8-
maxage: 60m
96

107
packages:
11-
'**':
12-
# give all users (including non-authenticated users) full access
13-
# because it is a local registry
8+
'@callstack/*':
149
access: $all
1510
publish: $all
16-
unpublish: $all
17-
18-
# if package is not available locally, proxy requests to npm registry
11+
'**':
12+
access: $all
1913
proxy: npmjs
2014

21-
# log settings
15+
# This options does not seem to react to changes when used with `runServer()` node API
16+
# Maybe upgrade to Verdaccio 6.x will help
17+
# See: https://github.com/verdaccio/verdaccio/issues/3728
2218
logs:
23-
type: stdout
24-
format: pretty
25-
level: warn
26-
27-
publish:
28-
allow_offline: true # set offline to true to allow publish offline
19+
- { type: stdout, format: pretty, level: info }

CONTRIBUTING.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,36 @@ pnpm rnef start
6767
pnpm rnef run:android
6868
```
6969

70+
### Testing Create RNEF App project
71+
72+
In order to test changes to `create-app` package, you need to run the following commands:
73+
74+
```sh
75+
# Ensure fresh build
76+
nx reset
77+
pnpm build
78+
79+
# Start local verdaccio registry (in one terminal), keep it open
80+
pnpm verdaccio:init
81+
82+
# Publish packages to verdaccio (in another terminal)
83+
pnpm verdaccio:publish
84+
85+
# Remove pnpm dlx cache, so that new version of package is used
86+
rm -rf ~/Library/Caches/pnpm/dlx/
87+
88+
# Run tests
89+
pnpm e2e
90+
91+
# Or Create RNEF app
92+
NPM_CONFIG_REGISTRY=http://localhost:4873 pnpm create @callstack/rnef-app --registry http://localhost:4873
93+
# Then use pnpm install with registry
94+
NPM_CONFIG_REGISTRY=http://localhost:4873 pnpm install
95+
96+
# Clean up
97+
pnpm verdaccio-reset
98+
```
99+
70100
## Typechecking, linting and testing
71101

72102
Currently we use TypeScript for typechecking, `eslint` with `prettier` for linting and formatting the code and `jest` for testing.

nx.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
"outputPath": "{projectRoot}/dist",
2020
"main": "{projectRoot}/src/index.ts",
2121
"tsConfig": "{projectRoot}/tsconfig.lib.json",
22-
"assets": ["packages/{projectRoot}/*.md"],
2322
"buildableProjectDepsInPackageJsonType": "dependencies",
2423
"generateExportsField": true,
2524
"compilerOptions": {

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,24 @@
55
"type": "module",
66
"scripts": {
77
"build": "nx run-many --target build",
8+
"postbuild": "nx run-many --target clean-dist",
89
"test": "nx run-many --target test",
910
"e2e": "nx run-many --target e2e",
1011
"lint": "nx run-many --target lint",
1112
"typecheck": "nx run-many --target typecheck",
1213
"watch": "nx watch --all -- nx run \\$NX_PROJECT_NAME:build",
13-
"link-packages": "node ./scripts/linkPackages.mjs"
14+
"link-packages": "node ./scripts/linkPackages.mjs",
15+
"verdaccio:init": "node ./scripts/verdaccio-init.mjs",
16+
"verdaccio:publish": "node ./scripts/verdaccio-publish.mjs",
17+
"verdaccio:reset": "./scripts/verdaccio-reset.sh"
1418
},
1519
"private": true,
1620
"dependencies": {
1721
"tslib": "^2.3.0",
1822
"vite-tsconfig-paths": "^5.0.1"
1923
},
2024
"devDependencies": {
25+
"@clack/prompts": "^0.8.2",
2126
"@eslint/js": "^9.8.0",
2227
"@nx/eslint": "19.8.0",
2328
"@nx/eslint-plugin": "19.8.0",
@@ -39,7 +44,7 @@
3944
"ts-node": "10.9.1",
4045
"typescript": "~5.5.2",
4146
"typescript-eslint": "^8.0.0",
42-
"verdaccio": "^5.0.4",
47+
"verdaccio": "^5.33.0",
4348
"vite": "^5.0.0",
4449
"vitest": "^2.1.2"
4550
},

packages/cli/package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@
99
"bin": {
1010
"rnef": "./dist/src/bin.js"
1111
},
12+
"scripts": {
13+
"clean-dist": "rm -f dist/package.json",
14+
"publish:verdaccio": "npm publish --registry http://localhost:4873 --userconfig ../../.npmrc"
15+
},
1216
"dependencies": {
13-
"@callstack/rnef-config": "workspace:*",
14-
"@callstack/rnef-tools": "workspace:*",
17+
"@callstack/rnef-config": "^0.0.1",
18+
"@callstack/rnef-tools": "^0.0.1",
1519
"@clack/prompts": "^0.8.1",
1620
"@react-native-community/cli-config": "^15.1.2",
1721
"commander": "^12.1.0",

packages/cli/project.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
"options": {
1212
"outputPath": "packages/cli/dist",
1313
"main": "packages/cli/src/index.ts",
14-
"tsConfig": "packages/cli/tsconfig.lib.json",
15-
"assets": ["packages/cli/*.md"]
14+
"tsConfig": "packages/cli/tsconfig.lib.json"
1615
}
1716
}
1817
}

packages/cli/src/lib/cli.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
import { dirname } from 'path';
2+
import { fileURLToPath } from 'url';
13
import { Command } from 'commander';
24
import { getConfig } from '@callstack/rnef-config';
35
import { createRequire } from 'module';
4-
import { logger } from '@callstack/rnef-tools';
6+
import { logger, resolveFilenameUp } from '@callstack/rnef-tools';
57
import { logConfig } from '../config.js';
68
import { nativeFingerprintCommand } from './commands/fingerprint.js';
79

810
const require = createRequire(import.meta.url);
9-
10-
const { version } = require('./../../package.json');
11+
const __dirname = dirname(fileURLToPath(import.meta.url));
12+
const { version } = require(resolveFilenameUp(__dirname, 'package.json'));
1113

1214
type CliOptions = {
1315
cwd?: string;

0 commit comments

Comments
 (0)