Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions libs/with-zephyr/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"build": {
"executor": "nx:run-commands",
"outputs": ["{projectRoot}/dist"],
"dependsOn": ["^build"],
"options": {
"command": "pnpm build",
"cwd": "libs/with-zephyr"
Expand Down
13 changes: 7 additions & 6 deletions libs/zephyr-agent/src/lib/deployment/aws-upload.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ZeErrors, ZephyrError } from '../errors';
import { getApplicationConfiguration } from '../edge-requests/get-application-configuration';
import { makeRequest } from '../http/http-request';
import { zeUploadSnapshot } from '../edge-actions';
import {type UploadAssetsOptions, uploadBuildStatsAndEnableEnvs } from './upload-base';
import { type UploadAssetsOptions, uploadBuildStatsAndEnableEnvs } from './upload-base';
import { update_hash_list } from '../edge-hash-list/distributed-hash-control';
import { white, whiteBright } from '../logging/picocolor';
import type { UploadFileProps } from '../http/upload-file';
Expand All @@ -15,7 +15,7 @@ const AWS_MAX_BODY_SIZE = 20971520;

export async function awsUploadStrategy(
zephyr_engine: ZephyrEngine,
{ snapshot, getDashData, assets: { assetsMap, missingAssets } }: UploadOptions,
{ snapshot, getDashData, assets: { assetsMap, missingAssets } }: UploadOptions
): Promise<string> {
const snapshotSize = Buffer.byteLength(JSON.stringify(snapshot), 'utf8');
if (snapshotSize > AWS_MAX_BODY_SIZE) {
Expand Down Expand Up @@ -145,12 +145,13 @@ async function zeUploadAssets(
return;
}

const [ok, cause] = await makeRequest(result.url,
const [ok, cause] = await makeRequest(
result.url,
{
method: 'PUT',
headers: {
'Content-Type': result.contentType,
}
},
},
asset.buffer
);
Expand All @@ -174,7 +175,7 @@ async function zeUploadAssets(
async function getUploadUrl(
{ hash, asset }: UploadFileProps,
{ EDGE_URL, jwt }: ZeApplicationConfig
): Promise<{url: string; contentType: string; message?: string;}> {
): Promise<{ url: string; contentType: string; message?: string }> {
const type = 'uploadUrl';
const options: RequestInit = {
method: 'POST',
Expand All @@ -186,7 +187,7 @@ async function zeUploadAssets(
},
};

const [ok, cause, data] = await makeRequest<{url: string; contentType: string;}>(
const [ok, cause, data] = await makeRequest<{ url: string; contentType: string }>(
{
path: '/upload',
base: EDGE_URL,
Expand Down
6 changes: 4 additions & 2 deletions libs/zephyr-agent/src/lib/node-persist/storage-keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@ import * as os from 'node:os';
import * as path from 'node:path';

export const ZE_PATH = path.resolve(os.homedir(), '.zephyr');
export const ZE_PERSIST_PATH = path.resolve(ZE_PATH, 'persist');
export const ZE_SESSION_LOCK = path.resolve(ZE_PATH, 'session');

try {
// Ensures that the directory exists and lockfile is writable
// Ensures that the directories exist and lockfile is writable
fs.mkdirSync(ZE_PATH, { recursive: true });
fs.mkdirSync(ZE_PERSIST_PATH, { recursive: true });
} catch (error) {
console.error(
'error',
`Could not create ~/.zephyr directory. Please check your permissions: ${error}`
`Could not create ~/.zephyr directories. Please check your permissions: ${error}`
);
}

Expand Down
7 changes: 2 additions & 5 deletions libs/zephyr-agent/src/lib/node-persist/storage.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { init } from 'node-persist';
import { ZE_PATH } from './storage-keys';
import { ZE_PERSIST_PATH } from './storage-keys';

/** @internal */
export const storage = init({
dir: ZE_PATH,
// node-persist thinks every file in .zephyr folder is a JSON valid file,
// since we use that folder for other purposes too, we need to set this to true
forgiveParseErrors: true,
dir: ZE_PERSIST_PATH,
});
2 changes: 1 addition & 1 deletion libs/zephyr-agent/src/tests/ze-agent.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ runner('ZeAgent', () => {
if (fs.existsSync(zephyrAppFolder)) {
const files = fs.readdirSync(zephyrAppFolder);
files.forEach((file) => {
fs.rmSync(path.join(zephyrAppFolder, file));
fs.rmSync(path.join(zephyrAppFolder, file), { recursive: true });
});
}
await exec(`git config --add user.name "${gitUserName}"`);
Expand Down
1 change: 1 addition & 0 deletions libs/zephyr-agent/src/zephyr-engine/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ type ZephyrEngineBuilderTypes =
| 'webpack'
| 'rspack'
| 'repack'
| 'metro'
| 'vite'
| 'rollup'
| 'parcel'
Expand Down
8 changes: 8 additions & 0 deletions libs/zephyr-edge-contract/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
"url": "https://github.com/ZephyrCloudIO"
},
"type": "commonjs",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.js",
"default": "./dist/index.js"
}
},
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
Expand Down
6 changes: 5 additions & 1 deletion libs/zephyr-edge-contract/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ export type { ZeApplicationList } from './lib/ze-api/app-list';
export type { ZeAppVersion, ZeAppVersionResponse } from './lib/ze-api/app-version';
export type { ConvertedGraph } from './lib/ze-api/converted-graph';
export type { LocalPackageJson } from './lib/ze-api/local-package-json';
export type { ZephyrBuildStats, ZephyrDependency } from './lib/zephyr-build-stats';
export type {
ApplicationConsumes,
ZephyrBuildStats,
ZephyrDependency,
} from './lib/zephyr-build-stats';
export type {
Asset,
SnapshotUploadRes,
Expand Down
35 changes: 35 additions & 0 deletions libs/zephyr-metro-plugin/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx"],
"parserOptions": {
"project": ["libs/zephyr-metro-plugin/tsconfig.spec.json"]
},
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {
"@nx/enforce-module-boundaries": [
"error",
{
"enforceBuildableLibDependency": false,
"allow": ["^zephyr-agent$"],
"depConstraints": [
{
"sourceTag": "*",
"onlyDependOnLibsWithTags": ["*"]
}
]
}
]
}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
5 changes: 5 additions & 0 deletions libs/zephyr-metro-plugin/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
src
tsconfig.*
jest.config.ts
project.json
.eslintrc.json
39 changes: 39 additions & 0 deletions libs/zephyr-metro-plugin/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/

TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION

1. Definitions.

"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.

...

END OF TERMS AND CONDITIONS

APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same line as the copyright notice for each file. The "copyright"
word should be left as is (without quotes).

Copyright [2023] [Zephyr Cloud]

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Loading
Loading