Skip to content

Commit 2b74de8

Browse files
authored
Merge pull request #270 from ZephyrCloudIO/feat/metro-plugin-v2
feat(zephyr-metro-plugin): add Metro bundler plugin for React Native
2 parents 1ff7e16 + c5c8c42 commit 2b74de8

Some content is hidden

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

46 files changed

+4003
-78
lines changed

libs/with-zephyr/project.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"build": {
1010
"executor": "nx:run-commands",
1111
"outputs": ["{projectRoot}/dist"],
12+
"dependsOn": ["^build"],
1213
"options": {
1314
"command": "pnpm build",
1415
"cwd": "libs/with-zephyr"

libs/zephyr-agent/src/lib/deployment/aws-upload.strategy.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { ZeErrors, ZephyrError } from '../errors';
55
import { getApplicationConfiguration } from '../edge-requests/get-application-configuration';
66
import { makeRequest } from '../http/http-request';
77
import { zeUploadSnapshot } from '../edge-actions';
8-
import {type UploadAssetsOptions, uploadBuildStatsAndEnableEnvs } from './upload-base';
8+
import { type UploadAssetsOptions, uploadBuildStatsAndEnableEnvs } from './upload-base';
99
import { update_hash_list } from '../edge-hash-list/distributed-hash-control';
1010
import { white, whiteBright } from '../logging/picocolor';
1111
import type { UploadFileProps } from '../http/upload-file';
@@ -15,7 +15,7 @@ const AWS_MAX_BODY_SIZE = 20971520;
1515

1616
export async function awsUploadStrategy(
1717
zephyr_engine: ZephyrEngine,
18-
{ snapshot, getDashData, assets: { assetsMap, missingAssets } }: UploadOptions,
18+
{ snapshot, getDashData, assets: { assetsMap, missingAssets } }: UploadOptions
1919
): Promise<string> {
2020
const snapshotSize = Buffer.byteLength(JSON.stringify(snapshot), 'utf8');
2121
if (snapshotSize > AWS_MAX_BODY_SIZE) {
@@ -145,12 +145,13 @@ async function zeUploadAssets(
145145
return;
146146
}
147147

148-
const [ok, cause] = await makeRequest(result.url,
148+
const [ok, cause] = await makeRequest(
149+
result.url,
149150
{
150151
method: 'PUT',
151152
headers: {
152153
'Content-Type': result.contentType,
153-
}
154+
},
154155
},
155156
asset.buffer
156157
);
@@ -174,7 +175,7 @@ async function zeUploadAssets(
174175
async function getUploadUrl(
175176
{ hash, asset }: UploadFileProps,
176177
{ EDGE_URL, jwt }: ZeApplicationConfig
177-
): Promise<{url: string; contentType: string; message?: string;}> {
178+
): Promise<{ url: string; contentType: string; message?: string }> {
178179
const type = 'uploadUrl';
179180
const options: RequestInit = {
180181
method: 'POST',
@@ -186,7 +187,7 @@ async function zeUploadAssets(
186187
},
187188
};
188189

189-
const [ok, cause, data] = await makeRequest<{url: string; contentType: string;}>(
190+
const [ok, cause, data] = await makeRequest<{ url: string; contentType: string }>(
190191
{
191192
path: '/upload',
192193
base: EDGE_URL,

libs/zephyr-agent/src/lib/node-persist/storage-keys.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@ import * as os from 'node:os';
33
import * as path from 'node:path';
44

55
export const ZE_PATH = path.resolve(os.homedir(), '.zephyr');
6+
export const ZE_PERSIST_PATH = path.resolve(ZE_PATH, 'persist');
67
export const ZE_SESSION_LOCK = path.resolve(ZE_PATH, 'session');
78

89
try {
9-
// Ensures that the directory exists and lockfile is writable
10+
// Ensures that the directories exist and lockfile is writable
1011
fs.mkdirSync(ZE_PATH, { recursive: true });
12+
fs.mkdirSync(ZE_PERSIST_PATH, { recursive: true });
1113
} catch (error) {
1214
console.error(
1315
'error',
14-
`Could not create ~/.zephyr directory. Please check your permissions: ${error}`
16+
`Could not create ~/.zephyr directories. Please check your permissions: ${error}`
1517
);
1618
}
1719

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
import { init } from 'node-persist';
2-
import { ZE_PATH } from './storage-keys';
2+
import { ZE_PERSIST_PATH } from './storage-keys';
33

44
/** @internal */
55
export const storage = init({
6-
dir: ZE_PATH,
7-
// node-persist thinks every file in .zephyr folder is a JSON valid file,
8-
// since we use that folder for other purposes too, we need to set this to true
9-
forgiveParseErrors: true,
6+
dir: ZE_PERSIST_PATH,
107
});

libs/zephyr-agent/src/tests/ze-agent.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ runner('ZeAgent', () => {
5959
if (fs.existsSync(zephyrAppFolder)) {
6060
const files = fs.readdirSync(zephyrAppFolder);
6161
files.forEach((file) => {
62-
fs.rmSync(path.join(zephyrAppFolder, file));
62+
fs.rmSync(path.join(zephyrAppFolder, file), { recursive: true });
6363
});
6464
}
6565
await exec(`git config --add user.name "${gitUserName}"`);

libs/zephyr-agent/src/zephyr-engine/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ type ZephyrEngineBuilderTypes =
8080
| 'webpack'
8181
| 'rspack'
8282
| 'repack'
83+
| 'metro'
8384
| 'vite'
8485
| 'rollup'
8586
| 'parcel'

libs/zephyr-edge-contract/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@
1313
"url": "https://github.com/ZephyrCloudIO"
1414
},
1515
"type": "commonjs",
16+
"exports": {
17+
".": {
18+
"types": "./dist/index.d.ts",
19+
"import": "./dist/index.js",
20+
"require": "./dist/index.js",
21+
"default": "./dist/index.js"
22+
}
23+
},
1624
"main": "dist/index.js",
1725
"types": "dist/index.d.ts",
1826
"scripts": {

libs/zephyr-edge-contract/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ export type { ZeApplicationList } from './lib/ze-api/app-list';
2121
export type { ZeAppVersion, ZeAppVersionResponse } from './lib/ze-api/app-version';
2222
export type { ConvertedGraph } from './lib/ze-api/converted-graph';
2323
export type { LocalPackageJson } from './lib/ze-api/local-package-json';
24-
export type { ZephyrBuildStats, ZephyrDependency } from './lib/zephyr-build-stats';
24+
export type {
25+
ApplicationConsumes,
26+
ZephyrBuildStats,
27+
ZephyrDependency,
28+
} from './lib/zephyr-build-stats';
2529
export type {
2630
Asset,
2731
SnapshotUploadRes,
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"extends": ["../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx"],
7+
"parserOptions": {
8+
"project": ["libs/zephyr-metro-plugin/tsconfig.spec.json"]
9+
},
10+
"rules": {}
11+
},
12+
{
13+
"files": ["*.ts", "*.tsx"],
14+
"rules": {
15+
"@nx/enforce-module-boundaries": [
16+
"error",
17+
{
18+
"enforceBuildableLibDependency": false,
19+
"allow": ["^zephyr-agent$"],
20+
"depConstraints": [
21+
{
22+
"sourceTag": "*",
23+
"onlyDependOnLibsWithTags": ["*"]
24+
}
25+
]
26+
}
27+
]
28+
}
29+
},
30+
{
31+
"files": ["*.js", "*.jsx"],
32+
"rules": {}
33+
}
34+
]
35+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
src
2+
tsconfig.*
3+
jest.config.ts
4+
project.json
5+
.eslintrc.json

0 commit comments

Comments
 (0)