Skip to content

Commit

Permalink
Merge pull request #1046 from polywrap/feat/remove-schema-file
Browse files Browse the repository at this point in the history
Feat: Post origin build artifact
  • Loading branch information
dOrgJelli authored Aug 18, 2022
2 parents 95e7c7c + aaefd3b commit 60c35e8
Show file tree
Hide file tree
Showing 483 changed files with 34,553 additions and 6,475 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ module.exports = {
root: true,
ignorePatterns: [
"**/wrap/**/*.*",
"**/wrap-man/**/*.*",
"**/infra-modules/**/*.*",
"**/build/**/*.*",
"**/build-man/**/*.*",
"**/__tests__/**/*.*",
"**/node_modules/**/*.*",
"**/coverage/**/*.*"
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
"clean": "npx rimraf ./**/node_modules ./**/yarn.lock ./**/build ./**/coverage ./**/.polywrap",
"dependencies:install": "cd dependencies && yarn",
"preinstall": "yarn dependencies:install",
"build": "yarn build:core && yarn build:interfaces && yarn build:plugins && yarn build:client && yarn build:test-env && yarn build:cli",
"build": "yarn build:core && yarn build:plugins && yarn build:client && yarn build:test-env && yarn build:cli && yarn build:plugins:patch",
"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 --ignore @polywrap/*-interface",
"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:plugins:patch": "cd packages/js/plugins/ethereum && yarn codegen:patch && cd ../http && yarn codegen:patch && lerna run codegen:patch --scope @polywrap/*-plugin-js --concurrency 1",
"link:interface:deps": "yarn link:manifests && yarn link:schema",
"link:manifests": "yarn link:manifests:polywrap && yarn link:manifests:wrap",
"link:manifests:polywrap": "cd packages/js/manifests/polywrap && (yarn unlink || true) && yarn link && cd ../../../../dependencies && yarn link @polywrap/polywrap-manifest-types-js && cd ../",
Expand Down
7 changes: 5 additions & 2 deletions packages/cli/lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@
"lib_compiler_compileWasmModulesError": "Failed to compile Wasm modules",
"lib_compiler_compileWasmModulesText": "Compile Wasm modules",
"lib_compiler_compileWasmModulesWarning": "Warnings while compiling Wasm modules",
"lib_compiler_failedSchemaReturn": "Schema composer failed to return a combined schema.",
"lib_compiler_failedAbiReturn": "Abi composer failed to return a combined abi.",
"lib_compiler_noModulesToBuild": "No modules to build declared.",
"lib_compiler_missingSchema": "Missing schema definition",
"lib_compiler_missingAbi": "Missing ABI definition",
"lib_compiler_missingModule": "Missing module definition",
"lib_compiler_noInterfaceModule": "Interfaces cannot have implementation file",
"lib_compiler_step": "Compiling WASM module",
Expand All @@ -239,6 +239,9 @@
"lib_compiler_outputMetadataError": "Failed to output metadata",
"lib_compiler_outputMetadataWarning": "Warnings writing metadata",
"lib_compiler_outputMetadataFileText": "Metadata written to {path}",
"lib_schemaComposer_abi_not_found": "ABI not found at {path}",
"lib_schemaComposer_unknown_abi": "Unknown ABI type at {path}. Supported types: {types}",
"lib_schemaComposer_invalid_yaml": "Invalid YAML at {path}",
"lib_generators_projectGenerator_fallback": "Falling back to the local Yarn cache.",
"lib_generators_projectGenerator_offline": "You appear to be offline.",
"lib_helpers_manifest_loadError": "Failed to load manifest from {path}",
Expand Down
7 changes: 5 additions & 2 deletions packages/cli/lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,9 +225,9 @@
"lib_compiler_compileWasmModulesError": "Failed to compile Wasm modules",
"lib_compiler_compileWasmModulesText": "Compile Wasm modules",
"lib_compiler_compileWasmModulesWarning": "Warnings while compiling Wasm modules",
"lib_compiler_failedSchemaReturn": "Schema composer failed to return a combined schema.",
"lib_compiler_failedAbiReturn": "Abi composer failed to return a combined abi.",
"lib_compiler_noModulesToBuild": "No modules to build declared.",
"lib_compiler_missingSchema": "Missing schema definition",
"lib_compiler_missingAbi": "Missing ABI definition",
"lib_compiler_missingModule": "Missing module definition",
"lib_compiler_noInterfaceModule": "Interfaces cannot have implementation file",
"lib_compiler_step": "Compiling WASM module",
Expand All @@ -239,6 +239,9 @@
"lib_compiler_outputMetadataError": "Failed to output metadata",
"lib_compiler_outputMetadataWarning": "Warnings writing metadata",
"lib_compiler_outputMetadataFileText": "Metadata written to {path}",
"lib_schemaComposer_abi_not_found": "ABI not found at {path}",
"lib_schemaComposer_unknown_abi": "Unknown ABI type at {path}. Supported types: {types}",
"lib_schemaComposer_invalid_yaml": "Invalid YAML at {path}",
"lib_generators_projectGenerator_fallback": "Falling back to the local Yarn cache.",
"lib_generators_projectGenerator_offline": "You appear to be offline.",
"lib_helpers_manifest_loadError": "Failed to load manifest from {path}",
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,16 @@
"polywrap": "bin/polywrap"
},
"scripts": {
"build": "rimraf ./build && tsc --project tsconfig.build.json && yarn build:build-images && yarn build:deploy-modules && yarn build:infra-modules && yarn build:docgen-templates",
"build": "yarn build:intl && yarn build:fast",
"build:fast": "rimraf ./build && tsc --project tsconfig.build.json && yarn build:build-images && yarn build:deploy-modules && yarn build:infra-modules && yarn build:docgen-templates",
"build:build-images": "copyfiles ./src/lib/defaults/build-images/**/**/* ./build/lib/defaults/build-images/ -u 4",
"build:deploy-modules": "copyfiles ./src/lib/defaults/deploy-modules/**/polywrap.deploy.ext.json ./build/lib/defaults/deploy-modules -u 4",
"build:infra-modules": "ts-node ./scripts/copyfiles ./src/lib/defaults/infra-modules ./build/lib/defaults/infra-modules",
"build:docgen-templates": "yarn build:docgen-templates:docusaurus && yarn build:docgen-templates:jsdoc && yarn build:docgen-templates:schema",
"build:docgen-templates:docusaurus": "ts-node ./scripts/copyfiles ./src/lib/docgen/docusaurus/templates ./build/lib/docgen/docusaurus/templates",
"build:docgen-templates:jsdoc": "ts-node ./scripts/copyfiles ./src/lib/docgen/jsdoc/templates ./build/lib/docgen/jsdoc/templates",
"build:docgen-templates:schema": "ts-node ./scripts/copyfiles ./src/lib/docgen/schema/templates ./build/lib/docgen/schema/templates",
"prebuild": "ts-node ./scripts/generateIntlTypes.ts",
"build:fast": "rimraf ./build && tsc --project tsconfig.build.json",
"build:intl": "ts-node ./scripts/generateIntlTypes.ts",
"lint": "eslint --color -c ../../.eslintrc.js .",
"test": "cross-env TEST=true jest --passWithNoTests --runInBand --verbose",
"test:ci": "cross-env TEST=true jest --passWithNoTests --runInBand --verbose",
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/__tests__/e2e/deploy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,13 @@ describe("e2e tests for deploy command", () => {
input: {
uri: "wrap://fs/./build"
},
result: "wrap://ipfs/QmPDJ9GMgqx1iScNpZh2MerK27YFNKayY5fBoGXfPWWEqm"
result: "wrap://ipfs/QmT5nBb8xwrfZnmFNRZexmrebzaaxW7CPfh1ZznQ6zsVaG"
},
{
id: "ipfs_deploy.from_deploy",
name: "from_deploy",
input: {
uri: "wrap://ipfs/QmPDJ9GMgqx1iScNpZh2MerK27YFNKayY5fBoGXfPWWEqm",
uri: "wrap://ipfs/QmT5nBb8xwrfZnmFNRZexmrebzaaxW7CPfh1ZznQ6zsVaG",
config: {
domainName: "test1.eth",
provider: "http://localhost:8545",
Expand All @@ -226,7 +226,7 @@ describe("e2e tests for deploy command", () => {
id: "ipfs_deploy.from_deploy2",
name: "from_deploy2",
input: {
uri: "wrap://ipfs/QmPDJ9GMgqx1iScNpZh2MerK27YFNKayY5fBoGXfPWWEqm",
uri: "wrap://ipfs/QmT5nBb8xwrfZnmFNRZexmrebzaaxW7CPfh1ZznQ6zsVaG",
config: {
domainName: "test2.eth",
provider: "http://localhost:8545",
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/__tests__/e2e/docgen.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Generate wrapper documentation
Arguments:
action
schema Generate GraphQL schema
schema Generate GraphQL schema
docusaurus Generate Docusaurus markdown
jsdoc Generate JSDoc markdown
(choices: "schema", "docusaurus", "jsdoc")
Expand Down
10 changes: 3 additions & 7 deletions packages/cli/src/commands/docgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ import {
PluginProject,
parseClientConfigOption,
defaultPluginManifest,
} from "../lib";
import { Command, Program } from "./types";
import {
parseDirOption,
parseDocgenManifestFileOption,
} from "../lib/option-parsers";
} from "../lib";
import { Command, Program } from "./types";
import { scriptPath as docusaurusScriptPath } from "../lib/docgen/docusaurus";
import { scriptPath as jsdocScriptPath } from "../lib/docgen/jsdoc";
import { scriptPath as schemaScriptPath } from "../lib/docgen/schema";
Expand Down Expand Up @@ -55,9 +53,7 @@ enum Actions {
}

const argumentsDescription = `
${chalk.bold(
Actions.SCHEMA
)} ${intlMsg.commands_docgen_options_schema()}
${chalk.bold(Actions.SCHEMA)} ${intlMsg.commands_docgen_options_schema()}
${chalk.bold(
Actions.DOCUSAURUS
)} ${intlMsg.commands_docgen_options_markdown({
Expand Down
34 changes: 12 additions & 22 deletions packages/cli/src/commands/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@ import {
PluginProject,
SchemaComposer,
defaultPluginManifest,
outputManifest,
intlMsg,
parseDirOption,
parsePluginManifestFileOption,
parseClientConfigOption,
generateWrapFile,
} from "../lib";

import { ComposerFilter } from "@polywrap/schema-compose";
import { writeFileSync } from "@polywrap/os-js";
import path from "path";
import fs from "fs";
import { PolywrapClient, PolywrapClientConfig } from "@polywrap/client-js";
import fs from "fs";

const defaultPublishDir = "./build";
const defaultCodegenDir = "./wrap";
Expand Down Expand Up @@ -87,39 +85,31 @@ async function run(options: PluginCommandOptions) {
});
await project.validate();
const manifest = await project.getManifest();

const schemaComposer = new SchemaComposer({
project,
client,
});

let result = false;

const codeGenerator = new CodeGenerator({
project,
schemaComposer,
codegenDirAbs: codegenDir,
});

result = await codeGenerator.generate();
const result = await codeGenerator.generate();
process.exitCode = result ? 0 : 1;

if (result) {
process.exitCode = 0;
} else {
process.exitCode = 1;
}

// Output the built schema & manifest
const schemas = await schemaComposer.getComposedSchemas(
ComposerFilter.Schema
);
const publishSchemaPath = path.join(publishDir, "schema.graphql");
const publishManifestPath = path.join(publishDir, "polywrap.plugin.json");
// Output the built manifest
const manifestPath = path.join(publishDir, "wrap.info");

if (!fs.existsSync(publishDir)) {
fs.mkdirSync(publishDir);
}

writeFileSync(publishSchemaPath, schemas.schema);
await outputManifest(manifest, publishManifestPath);
await generateWrapFile(
await schemaComposer.getComposedAbis(),
manifest.name,
"plugin",
manifestPath
);
}
14 changes: 3 additions & 11 deletions packages/cli/src/lib/CodeGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,8 @@ export class CodeGenerator {
);
}

// Get the fully composed schema
const composed = await schemaComposer.getComposedSchemas();

if (!composed) {
throw Error(intlMsg.lib_codeGenerator_noComposedSchema());
}

const abi = composed.abi;
this._schema = composed.schema;
// Get the fully composed abi
const abi = await schemaComposer.getComposedAbis();

if (!abi) {
throw Error(intlMsg.lib_codeGenerator_abiMissing());
Expand Down Expand Up @@ -119,7 +112,6 @@ export class CodeGenerator {
const binding = await generateBinding({
projectName: await project.getName(),
abi,
schema: this._schema || "",
outputDirAbs: codegenDirAbs,
bindLanguage,
config: this._config.mustacheView,
Expand All @@ -134,7 +126,7 @@ export class CodeGenerator {
);
} else {
const binding = await project.generateSchemaBindings(
composed,
abi,
path.relative(project.getManifestDir(), codegenDirAbs)
);

Expand Down
Loading

0 comments on commit 60c35e8

Please sign in to comment.