Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Origin 0.12.1 | /workflows/release-pr #1916

Merged
merged 28 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5b302c1
added "embed" option to codegen
krisbitney Sep 7, 2023
fef8d91
added check for app project
krisbitney Sep 7, 2023
ae74ad3
changed WasmEmbed types
krisbitney Sep 8, 2023
2e77d93
made sure bindConfig is passed to bindgen in AppProject and PluginPro…
krisbitney Sep 11, 2023
2298155
reverted accidental commit of change in app-rs bindgen uri
krisbitney Sep 11, 2023
81c89dd
removed bindConfig passthrough for PluginProject
krisbitney Sep 14, 2023
45d5af9
updated manifests and added defaults for manifest module and schema l…
krisbitney Sep 19, 2023
edf9873
updated plugin manifest kotlin module default
krisbitney Sep 20, 2023
ea223c1
updated plugin manifest kotlin module default
krisbitney Sep 20, 2023
e062f41
chore: Update CODEOWNERS
dOrgJelli Sep 20, 2023
fd6a1de
added tests and fixed some bugs in manifest defaults
krisbitney Sep 22, 2023
70a3f52
tests passing for manifest source defaults
krisbitney Sep 22, 2023
c30a76f
updated polywrap-wasm-rs version in rust template
krisbitney Sep 22, 2023
4dd0fc4
using default ipfs providers from the default config
nerfZael Sep 29, 2023
1c39df4
Merge pull request #1910 from polywrap/update-codeowners
dOrgJelli Sep 29, 2023
c111edf
formatting the ipfs resolver uri
nerfZael Sep 29, 2023
fc2667a
fixed not adding array properly
nerfZael Sep 30, 2023
c0dca15
Merge pull request #1913 from polywrap/nerfzael-use-default-ipfs-prov…
dOrgJelli Oct 2, 2023
a409897
Update package.json
dOrgJelli Oct 2, 2023
0926a92
Update index.ts
dOrgJelli Oct 2, 2023
98bc2dc
Merge pull request #1911 from polywrap/kris/manifest-defaults
dOrgJelli Oct 2, 2023
587b147
Merge pull request #1893 from polywrap/kris/polywrap-embed
dOrgJelli Oct 2, 2023
774b0b7
chore: update WRAP_TEST_HARNESS
dOrgJelli Oct 2, 2023
ba86766
fix: update app-rust template to latest bindgen
dOrgJelli Oct 2, 2023
f7dcc4b
fix: update app-rust template
dOrgJelli Oct 2, 2023
1f51248
Merge pull request #1914 from polywrap/fix-ci-oct-3
dOrgJelli Oct 2, 2023
62023f2
chore: update CHANGELOG & VERSION
dOrgJelli Oct 2, 2023
ecbfdfd
Merge pull request #1915 from polywrap/origin-dev
dOrgJelli Oct 2, 2023
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
63 changes: 1 addition & 62 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,62 +1 @@
# Default
* @dOrgJelli @namesty

# Wasm Runtime
packages/wasm/as @dOrgJelli @krisbitney @namesty @Niraj-Kamdar
packages/wasm/rs @namesty @dOrgJelli

# Wrapper Test-Cases
packages/test-cases/cases/wrappers/wasm-as @cbrzn @namesty @nerfZael @krisbitney @Niraj-Kamdar
packages/test-cases/cases/wrappers/wasm-rs @cbrzn @namesty @nerfZael @krisbitney @Niraj-Kamdar

# Schema
packages/schema/parse @dOrgJelli @namesty @nerfZael @Niraj-Kamdar
packages/schema/compose @dOrgJelli @namesty @nerfZael @Niraj-Kamdar
packages/schema/bind @dOrgJelli @krisbitney @nerfZael @Niraj-Kamdar @cbrzn

# Schema Test-Cases
packages/test-cases/cases/parse @dOrgJelli @namesty @nerfZael @Niraj-Kamdar
packages/test-cases/cases/compose @dOrgJelli @namesty @nerfZael @Niraj-Kamdar
packages/test-cases/cases/bind @dOrgJelli @krisbitney @nerfZael @Niraj-Kamdar @cbrzn

# Project Manifests
packages/manifests/ @dOrgJelli @namesty @cbrzn @Niraj-Kamdar

# CLI
packages/js/cli @dOrgJelli @krisbitney @namesty @nerfZael @Niraj-Kamdar

# CLI Test-Cases
packages/test-cases/cases/cli @dOrgJelli @krisbitney @namesty @nerfZael @Niraj-Kamdar

# Interfaces
packages/interfaces @dOrgJelli @krisbitney @cbrzn

# JS Client
packages/js @dOrgJelli @nerfZael
packages/js/asyncify @namesty @dOrgJelli
packages/js/client @dOrgJelli @krisbitney @namesty @nerfZael
packages/js/client-config-builder @pileks @nerfZael
packages/js/core @dOrgJelli @krisbitney @namesty @nerfZael
packages/js/manifests @dOrgJelli @namesty @nerfZael @pileks @Niraj-Kamdar
packages/js/msgpack @dOrgJelli @Niraj-Kamdar
packages/js/os @dOrgJelli
packages/js/plugin @nerfZael @dOrgJelli
packages/js/react @dOrgJelli @nerfZael
packages/js/result @nerfZael
packages/js/test-env @dOrgJelli @krisbitney @cbrzn @namesty
packages/js/tracing @dOrgJelli @Niraj-Kamdar @fetsorn
packages/js/uri-resolver-extensions @nerfZael
packages/js/uri-resolvers @nerfZael
packages/js/validation @nerfZael @cbrzn
packages/js/wasm @nerfZael @dOrgJelli

# JS Plugins
packages/js/plugins/ethereum @dOrgJelli @krisbitney @namesty
packages/js/plugins/file-system @krisbitney @dOrgJelli @Niraj-Kamdar @cbrzn
packages/js/plugins/http @dOrgJelli @ramilexe @cbrzn @namesty @krisbitney
packages/js/plugins/ipfs @dOrgJelli @krisbitney @nerfZael
packages/js/plugins/ws @dOrgJelli @nerfZael @fetsorn
packages/js/plugins/uri-resolvers/ens-resolver @nerfZael @pileks @krisbitney @cbrzn @dOrgJelli
packages/js/plugins/uri-resolvers/file-system-resolver @pileks @dOrgJelli @nerfZael @cbrzn @krisbitney
packages/js/plugins/uri-resolvers/http-resolver @namesty @krisbitney @nerfZael
packages/js/plugins/uri-resolvers/ipfs-resolver @pileks @nerfZael @dOrgJelli @cbrzn
* @dOrgJelli @namesty @pileks
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
# Polywrap Origin (0.12.1)
## Features
**`polywrap` CLI:**
* [PR-1911](https://github.com/polywrap/cli/pull/1911) **Polywrap Manifest - Default Source Paths**
* `polywrap.yaml` manifests can now omit the `source:` section and use the defaults defined by the CLI babsed on the manifest's `project.type` property.
* [PR-1893](https://github.com/polywrap/cli/pull/1893) **Add `embed` option to `polywrap codegen`**
* Adds the `--embed` option to `polywrap codegen` which embeds wrap modules into applications (requires wrap-abi-bindgen support).

## Bugs
**`polywrap` CLI:**
* [PR-1913](https://github.com/polywrap/cli/pull/1913) **Use Sys Bundle IPFS Providers in CLI**

# Polywrap Origin (0.12.0)
## Breaking Changes
**`@polywrap/schema-bind`:**
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.12.0
0.12.1
2 changes: 1 addition & 1 deletion WRAP_TEST_HARNESS
Original file line number Diff line number Diff line change
@@ -1 +1 @@
kris/test-wrap-rust-2
master
6 changes: 4 additions & 2 deletions packages/cli/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@
"commands_codegen_description": "Generate Code For Polywrap Projects",
"commands_codegen_error_domain": "domain",
"commands_codegen_error_optionMissingArgument": "{option} option missing {argument} argument",
"commands_codegen_error_embedAppOnly": "The --embed option is currently only available for app projects",
"commands_codegen_options_codegen": "Output directory for the generated code (default: {default})",
"commands_codegen_options_e": "ENS address to lookup external schemas (default: 0x0000...2e1e)",
"commands_codegen_options_e_address": "address",
"commands_codegen_options_e": "Locally embed Wasm wraps",
"commands_codegen_options_h": "Show usage information",
"commands_codegen_options_s": "Path to a custom generation script (JavaScript | TypeScript)",
"commands_codegen_options_i": "IPFS node to load external schemas (default: ipfs.io & localhost)",
Expand Down Expand Up @@ -272,6 +272,8 @@
"lib_project_app_uri_support": "The app command supports only filesystem URIs for plugins. Examples:",
"lib_project_imported_plugin_manifest_not_found": "No manifest found for imported plugin namespace `{namespace}` at path `{path}`",
"lib_project_invalid_uri": "Invalid URI Received:",
"lib_project_no_default_schema": "Couldn't find schema in default paths. Please specify the schema location in the project manifest.",
"lib_project_no_default_module": "Couldn't find module entry point in default paths. Please specify the module entry point in the project manifest.",
"lib_typescript_notInstalled": "Your project uses typescript, but it's not installed",
"lib_typescript_tsNodeNotInstalled": "Your project uses typescript, but ts-node is not installed",
"lib_watcher_alreadyWatching": "Watcher session is already in progress. Directory: {dir}",
Expand Down
6 changes: 4 additions & 2 deletions packages/cli/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@
"commands_codegen_description": "Generate Code For Polywrap Projects",
"commands_codegen_error_domain": "domain",
"commands_codegen_error_optionMissingArgument": "{option} option missing {argument} argument",
"commands_codegen_error_embedAppOnly": "The --embed option is currently only available for app projects",
"commands_codegen_options_codegen": "Output directory for the generated code (default: {default})",
"commands_codegen_options_e": "ENS address to lookup external schemas (default: 0x0000...2e1e)",
"commands_codegen_options_e_address": "address",
"commands_codegen_options_e": "Locally embed Wasm wraps",
"commands_codegen_options_h": "Show usage information",
"commands_codegen_options_s": "Path to a custom generation script (JavaScript | TypeScript)",
"commands_codegen_options_i": "IPFS node to load external schemas (default: ipfs.io & localhost)",
Expand Down Expand Up @@ -272,6 +272,8 @@
"lib_project_app_uri_support": "The app command supports only filesystem URIs for plugins. Examples:",
"lib_project_imported_plugin_manifest_not_found": "No manifest found for imported plugin namespace `{namespace}` at path `{path}`",
"lib_project_invalid_uri": "Invalid URI Received:",
"lib_project_no_default_schema": "Couldn't find schema in default paths. Please specify the schema location in the project manifest.",
"lib_project_no_default_module": "Couldn't find module entry point in default paths. Please specify the module entry point in the project manifest.",
"lib_typescript_notInstalled": "Your project uses typescript, but it's not installed",
"lib_typescript_tsNodeNotInstalled": "Your project uses typescript, but ts-node is not installed",
"lib_watcher_alreadyWatching": "Watcher session is already in progress. Directory: {dir}",
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/__tests__/e2e/p2/codegen.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Options:
-b, --bindgen <URI> Uri for custom bindgen wrap (must
implement wrap-abi-bindgen interface; see
https://github.com/polywrap/wrap-abi-bindgen)
-e, --embed Locally embed Wasm wraps
-s, --script <path> Path to a custom generation script
(JavaScript | TypeScript)
-c, --client-config <config-path> Add custom configuration to the
Expand Down
9 changes: 5 additions & 4 deletions packages/cli/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,15 +132,15 @@ export const build: Command = {
async function validateManifestModules(polywrapManifest: PolywrapManifest) {
if (
polywrapManifest.project.type !== "interface" &&
!polywrapManifest.source.module
!polywrapManifest.source?.module
) {
const missingModuleMessage = intlMsg.lib_compiler_missingModule();
throw Error(missingModuleMessage);
}

if (
polywrapManifest.project.type === "interface" &&
polywrapManifest.source.module
polywrapManifest.source?.module
) {
const noInterfaceModule = intlMsg.lib_compiler_noInterfaceModule();
throw Error(noInterfaceModule);
Expand Down Expand Up @@ -242,11 +242,12 @@ async function run(options: Required<BuildCommandOptions>) {
project,
client,
});
const abi = await schemaComposer.getComposedAbis();

if (canRunCodegen && !noCodegen) {
const codeGenerator = new CodeGenerator({
project,
schemaComposer,
abi,
codegenDirAbs: codegenDir || undefined,
bindgenUri,
});
Expand All @@ -261,7 +262,7 @@ async function run(options: Required<BuildCommandOptions>) {
const compiler = new Compiler({
project: project as PolywrapProject,
outputDir,
schemaComposer,
abi,
buildStrategy,
});

Expand Down
23 changes: 21 additions & 2 deletions packages/cli/src/commands/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
defaultPolywrapManifestFiles,
parseLogFileOption,
parseWrapperEnvsOption,
WasmEmbed,
getWasmEmbeds,
} from "../lib";
import { ScriptCodegenerator } from "../lib/codegen/ScriptCodeGenerator";
import { DEFAULT_CODEGEN_DIR } from "../lib/defaults";
Expand All @@ -29,6 +31,7 @@ export interface CodegenCommandOptions extends BaseCommandOptions {
manifestFile: string;
codegenDir: string | false;
bindgen: string | false;
embed: boolean | false;
script: string | false;
clientConfig: string | false;
wrapperEnvs: string | false;
Expand All @@ -54,6 +57,7 @@ export const codegen: Command = {
})}`
)
.option(`-b, --bindgen <URI>`, `${intlMsg.commands_codegen_options_b()}`)
.option(`-e, --embed`, `${intlMsg.commands_codegen_options_e()}`)
.option(
`-s, --script <${pathStr}>`,
`${intlMsg.commands_codegen_options_s()}`
Expand Down Expand Up @@ -81,6 +85,7 @@ export const codegen: Command = {
),
codegenDir: parseDirOptionNoDefault(options.codegenDir),
bindgen: options.bindgen || false,
embed: options.embed || false,
script: parseCodegenScriptOption(options.script),
clientConfig: options.clientConfig || false,
wrapperEnvs: options.wrapperEnvs || false,
Expand All @@ -100,6 +105,7 @@ async function run(options: Required<CodegenCommandOptions>) {
wrapperEnvs,
codegenDir,
bindgen,
embed,
script,
verbose,
quiet,
Expand Down Expand Up @@ -133,21 +139,34 @@ async function run(options: Required<CodegenCommandOptions>) {
project,
client,
});
const abi = await schemaComposer.getComposedAbis();

const projectLang = await project.getManifestLanguage();
if (embed && !projectLang.startsWith("app")) {
logger.error(intlMsg.commands_codegen_error_embedAppOnly());
process.exit(1);
}

const embeds: WasmEmbed[] | undefined =
embed && abi.importedModuleTypes
? await getWasmEmbeds(abi.importedModuleTypes, client, logger)
: undefined;

const codeGenerator = script
? new ScriptCodegenerator({
codegenDirAbs: codegenDir || undefined,
script,
schemaComposer,
abi,
project,
omitHeader: false,
mustacheView: undefined,
})
: new CodeGenerator({
codegenDirAbs: codegenDir || undefined,
schemaComposer,
abi,
project,
bindgenUri,
embeds,
});

const execute = async (): Promise<boolean> => {
Expand Down
7 changes: 3 additions & 4 deletions packages/cli/src/lib/Compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
PolywrapProject,
PluginProject,
resetDir,
SchemaComposer,
logActivity,
loadDocsManifest,
} from "./";
Expand All @@ -21,12 +20,13 @@ import fs from "fs";
import fse from "fs-extra";
import path from "path";
import { DocsManifest } from "@polywrap/polywrap-manifest-types-js";
import { Abi } from "@polywrap/schema-parse";

export interface CompilerConfig {
outputDir: string;
project: PolywrapProject | PluginProject;
buildStrategy?: BuildStrategy;
schemaComposer: SchemaComposer;
abi: Abi;
}

export class Compiler {
Expand Down Expand Up @@ -111,13 +111,12 @@ export class Compiler {
}

private async _outputWrapManifest(): Promise<unknown> {
const { outputDir, project, schemaComposer } = this._config;
const { outputDir, project, abi } = this._config;
const manifestPath = `${outputDir}/wrap.info`;
const run = async () => {
const manifest = await project.getManifest();

const type = manifest.project.type.split("/")[0];
const abi = await schemaComposer.getComposedAbis();
await generateWrapFile(
abi,
manifest.project.name,
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/lib/SchemaComposer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class SchemaComposer {
private _abiResolver(
schemaFile: SchemaFile,
importFrom: string,
import_abis?: PolywrapManifest["source"]["import_abis"]
import_abis?: NonNullable<PolywrapManifest["source"]>["import_abis"]
): Promise<WrapAbi | SchemaFile> {
if (Uri.isValidUri(importFrom)) {
return this._resolveUri(importFrom, import_abis);
Expand All @@ -97,7 +97,7 @@ export class SchemaComposer {

private async _resolveUri(
uri: string,
import_abis?: PolywrapManifest["source"]["import_abis"]
import_abis?: NonNullable<PolywrapManifest["source"]>["import_abis"]
): Promise<WrapAbi> {
// Check to see if we have any import redirects that match
if (import_abis) {
Expand Down Expand Up @@ -155,7 +155,7 @@ export class SchemaComposer {

private async _loadGraphqlAbi(
path: string,
import_abis: PolywrapManifest["source"]["import_abis"]
import_abis: NonNullable<PolywrapManifest["source"]>["import_abis"]
): Promise<WrapAbi> {
const schema = fs.readFileSync(path, "utf-8");

Expand Down
18 changes: 13 additions & 5 deletions packages/cli/src/lib/codegen/CodeGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,21 @@ import {
Project,
} from "../project";
import { resetDir } from "../system";
import { SchemaComposer } from "../SchemaComposer";
import { CodegenOverrides, tryGetCodegenOverrides } from "./CodegenOverrides";
import { WasmEmbed } from "./WasmEmbed";

import path from "path";
import { BindLanguage } from "@polywrap/schema-bind";
import { writeDirectorySync } from "@polywrap/os-js";
import { Uri } from "@polywrap/core-js";
import { Abi } from "@polywrap/schema-parse";

export interface CodeGeneratorConfig {
project: Project<AnyProjectManifest>;
schemaComposer: SchemaComposer;
abi: Abi;
codegenDirAbs?: string;
bindgenUri?: Uri;
embeds?: WasmEmbed[];
}

export class CodeGenerator {
Expand Down Expand Up @@ -88,13 +90,19 @@ export class CodeGenerator {
)
: undefined;

const bindConfig = overrides
let bindConfig = overrides
? await overrides.getSchemaBindConfig(this._config.project)
: {};

const abi = await this._config.schemaComposer.getComposedAbis();
if (this._config.embeds) {
bindConfig = {
...bindConfig,
embeds: this._config.embeds,
};
}

const binding = await this._config.project.generateSchemaBindings(
abi,
this._config.abi,
codegenDir,
this._config.bindgenUri?.toString(),
bindConfig
Expand Down
Loading
Loading