Skip to content

Commit

Permalink
chore: refactor in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrzn committed Jul 1, 2022
1 parent fe30a2f commit ddb2985
Show file tree
Hide file tree
Showing 22 changed files with 36 additions and 34 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@
"link:schema:compose": "cd packages/schema/compose && (yarn unlink || true) && yarn link && cd ../../../dependencies && yarn link @polywrap/schema-compose && cd ../",
"link:schema:bind": "cd packages/schema/bind && (yarn unlink || true) && yarn link && cd ../../../dependencies && yarn link @polywrap/schema-bind && cd ../",
"preinstall": "yarn dependencies:install",
"build": "yarn build:core && yarn dependencies:link && yarn build:interfaces && yarn build:plugins && yarn build:client && yarn build:test-env && yarn build:cli",
"build": "yarn build:manifests && yarn build:core && yarn dependencies:link && yarn build:interfaces && yarn build:plugins && yarn build:client && yarn build:test-env && yarn build:cli",
"build:core": "lerna run build --no-private --ignore @polywrap/*-plugin-js --ignore polywrap --ignore @polywrap/client-js --ignore @polywrap/react --ignore @polywrap/test-env-js",
"build:interfaces": "lerna run build --scope @polywrap/*-interface --concurrency 1",
"build:plugins": "lerna run build --scope @polywrap/*-plugin-js --concurrency 1",
"build:client": "lerna run build --scope @polywrap/client-js --scope @polywrap/react",
"build:test-env": "lerna run build --scope @polywrap/test-env-js",
"build:cli": "lerna run build --scope polywrap",
"build:manifests": "lerna run build --scope @polywrap/tracing-js && cd packages/manifest-schemas/polywrap && yarn build && cd ../wrap && yarn build",
"lint": "lerna run lint",
"lint:fix": "lerna run lint -- --fix",
"lint:ci": "yarn lint",
Expand Down
3 changes: 2 additions & 1 deletion packages/cli/src/commands/infra.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { intlMsg, Infra, loadInfraManifest, InfraManifest } from "../lib";
import { intlMsg, Infra, loadInfraManifest } from "../lib";
import { Command, Program } from "./types";

import { InfraManifest } from "@polywrap/polywrap-manifest-schemas"
import { print } from "gluegun";
import path from "path";
import { Argument } from "commander";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CompilerOverrides } from "../../../../Compiler";
import { intlMsg } from "../../../../intl";

import { PolywrapManifest } from "../../../../polywrap-manifests";
import { PolywrapManifest } from "@polywrap/polywrap-manifest-schemas";

export function getCompilerOverrides(): CompilerOverrides {
return {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/helpers/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { withSpinner } from "./";
import { displayPath, intlMsg } from "../";

import { normalizePath } from "@polywrap/os-js";
import { MetaManifest } from "../polywrap-manifests";
import { MetaManifest } from "@polywrap/polywrap-manifest-schemas";
import { Ora } from "ora";
import fs from "fs";
import path from "path";
Expand Down
1 change: 0 additions & 1 deletion packages/cli/src/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export * from "./helpers";
export * from "./infra";
export * from "./intl";
export * from "./option-parsers";
export * from "./polywrap-manifests";
export * from "./project";
export * from "./system";
export * from "./test-env";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/infra/Infra.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
CacheDirectory,
} from "../";

import { InfraManifest } from "../polywrap-manifests";
import { InfraManifest } from "@polywrap/polywrap-manifest-schemas";
import path from "path";
import fs, { lstatSync, readdirSync } from "fs";
import YAML from "js-yaml";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/project/AppProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import {
loadAppManifest,
appManifestLanguageToBindLanguage,
} from "./manifests";
import { AppManifest } from "../polywrap-manifests";

import { AppManifest } from "@polywrap/polywrap-manifest-schemas";
import { Client } from "@polywrap/core-js";
import { ComposerOutput } from "@polywrap/schema-compose";
import { bindSchema, BindOutput } from "@polywrap/schema-bind";
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/project/PluginProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import {
isPluginManifestLanguage,
pluginManifestLanguageToBindLanguage,
} from "./manifests";
import { PluginManifest } from "../polywrap-manifests";
import { resetDir } from "../system";

import { PluginManifest } from "@polywrap/polywrap-manifest-schemas";
import { bindSchema, BindOutput, BindOptions } from "@polywrap/schema-bind";
import { ComposerOutput } from "@polywrap/schema-compose";
import { Abi } from "@polywrap/schema-parse";
Expand Down
10 changes: 5 additions & 5 deletions packages/cli/src/lib/project/PolywrapProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ import {
polywrapManifestLanguageToBindLanguage,
} from "./manifests";
import { Deployer } from "../deploy";
import { generateDockerImageName, resetDir } from "../system";
import { createUUID } from "../helpers";
import { intlMsg } from "../intl";

import {
BuildManifest,
PolywrapManifest,
MetaManifest,
DeployManifest,
} from "../polywrap-manifests";
import { generateDockerImageName, resetDir } from "../system";
import { createUUID } from "../helpers";
import { intlMsg } from "../intl";

} from "@polywrap/polywrap-manifest-schemas";
import { normalizePath } from "@polywrap/os-js";
import { bindSchema, BindOutput, BindOptions } from "@polywrap/schema-bind";
import { ComposerOutput } from "@polywrap/schema-compose";
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/lib/project/manifests/app/load.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { displayPath, withSpinner, intlMsg } from "../../../";

import {
AppManifest,
deserializeAppManifest,
} from "../../../polywrap-manifests";

} from "@polywrap/polywrap-manifest-schemas";
import fs from "fs";

export const defaultAppManifest = ["polywrap.app.yaml", "polywrap.app.yml"];
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/lib/project/manifests/plugin/load.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { displayPath, withSpinner, intlMsg } from "../../../";

import {
PluginManifest,
deserializePluginManifest,
} from "../../../polywrap-manifests";

} from "@polywrap/polywrap-manifest-schemas";
import fs from "fs";

export const defaultPluginManifest = [
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/lib/project/manifests/polywrap/load.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
deserializeDeployManifest,
InfraManifest,
deserializeInfraManifest,
} from "../../../polywrap-manifests";
} from "@polywrap/polywrap-manifest-schemas";

import { Schema as JsonSchema } from "jsonschema";
import path from "path";
Expand Down
2 changes: 1 addition & 1 deletion packages/js/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"build"
],
"scripts": {
"build": "rimraf ./build tsc --project tsconfig.build.json",
"build": "rimraf ./build && tsc --project tsconfig.build.json",
"lint": "eslint --color -c ../../../.eslintrc.js src/",
"test": "jest --passWithNoTests --runInBand --verbose",
"test:ci": "jest --passWithNoTests --runInBand --verbose",
Expand Down
1 change: 0 additions & 1 deletion packages/js/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export * from "./types";
export * from "./algorithms";
export * from "./interfaces";
export * from "./wrap-manifests";
export * from "./msgpack";
export * from "./uri-resolution/core";
export * from "./uri-resolution/resolvers";
Expand Down
3 changes: 2 additions & 1 deletion packages/js/core/src/types/Client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
} from "./";
import { UriResolver } from "../uri-resolution/core";
import { UriResolverHandler } from "./UriResolver";
import { WrapManifest } from "../wrap-manifests";

import { WrapManifest } from "@polywrap/wrap-manifest-schemas";

export interface ClientConfig<TUri extends Uri | string = string> {
redirects: UriRedirect<TUri>[];
Expand Down
2 changes: 1 addition & 1 deletion packages/js/core/src/types/Wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
Invoker,
InvocableResult,
} from ".";
import { WrapManifest } from "../wrap-manifests";
import { WrapManifest } from "@polywrap/polywrap-manifest-schemas";

/**
* The Wrapper definition, which can be used to spawn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
deserializeWrapManifest,
} from "@polywrap/wrap-manifest-schemas";
import { Tracer } from "@polywrap/tracing-js";
import { msgpackDecode } from "../../../msgpack";

export class UriResolverWrapper implements UriResolver {
constructor(
Expand Down Expand Up @@ -52,6 +53,7 @@ export class UriResolverWrapper implements UriResolver {
// meaning the URI resolver can also be used as an Wrapper resolver
const manifest = deserializeWrapManifest(
result.manifest,
msgpackDecode,
this.deserializeOptions
);

Expand Down
2 changes: 1 addition & 1 deletion packages/js/core/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
"exclude": [
"./src/**/__tests__"
]
}
}
8 changes: 6 additions & 2 deletions packages/js/validation/src/types/WasmPackageValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import {
WRAP_WASM,
} from "..";

import { deserializeWrapManifest, WrapManifest } from "@polywrap/core-js";
import { msgpackDecode } from "@polywrap/core-js";
import {
WrapManifest,
deserializeWrapManifest,
} from "@polywrap/wrap-manifest-schemas";
import { renderSchema } from "@polywrap/schema-compose";
import * as path from "path";

Expand Down Expand Up @@ -134,7 +138,7 @@ export class WasmPackageValidator {
const info = await reader.readFile(name);
return {
valid: true,
manifest: deserializeWrapManifest(info),
manifest: deserializeWrapManifest(info, msgpackDecode),
};
} catch (e) {
if (e.message.includes('instance requires property "abi"')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ import {
import { DeserializeManifestOptions } from "../";

import { compare } from "semver";
import { msgpackDecode } from "@polywrap/core-js";
import { Tracer } from "@polywrap/tracing-js";

export const deserializeWrapManifest = Tracer.traceFunc(
"core: deserializeWrapManifest",
(manifest: Uint8Array, options?: DeserializeManifestOptions): WrapManifest => {
(manifest: Uint8Array, decoder: (m: Uint8Array) => unknown, options?: DeserializeManifestOptions): WrapManifest => {
let anyWrapManifest: AnyWrapManifest | undefined;
try {
anyWrapManifest = msgpackDecode(manifest) as AnyWrapManifest;
anyWrapManifest = decoder(manifest) as AnyWrapManifest;
} catch (e) {
throw Error(`Unable to parse WrapManifest: ${`[${new Uint8Array(manifest).toString()}]`}`);
}
Expand Down
3 changes: 0 additions & 3 deletions packages/manifest-schemas/wrap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
"lint": "eslint --color -c ../../.eslintrc.js .",
"build": "ts-node generator.ts && tsc"
},
"dependencies": {
"@polywrap/core-js": "0.0.1-prealpha.91"
},
"devDependencies": {
"ts-node": "8.10.2"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ import {
import { DeserializeManifestOptions } from "../";

import { compare } from "semver";
import { msgpackDecode } from "@polywrap/core-js";
import { Tracer } from "@polywrap/tracing-js";

export const deserializeWrapManifest = Tracer.traceFunc(
"core: deserializeWrapManifest",
(manifest: Uint8Array, options?: DeserializeManifestOptions): WrapManifest => {
(manifest: Uint8Array, decoder: (m: Uint8Array) => unknown, options?: DeserializeManifestOptions): WrapManifest => {
let anyWrapManifest: AnyWrapManifest | undefined;
try {
anyWrapManifest = msgpackDecode(manifest) as AnyWrapManifest;
anyWrapManifest = decoder(manifest) as AnyWrapManifest;
} catch (e) {
throw Error(`Unable to parse WrapManifest: ${`[${new Uint8Array(manifest).toString()}]`}`);
}
Expand Down

0 comments on commit ddb2985

Please sign in to comment.