mirror of
https://github.com/embarklabs/embark.git
synced 2025-01-20 10:40:27 +00:00
refactor(@embark/embark-typings) move typings to its own module
fix typings
WIP: refactor
WIP: just needed an annotation 🎉 thanks @emizzle!
WIP: don't pack a tarball since it's a private package
WIP: no need to list as a devDep
This commit is contained in:
parent
8091c4e6d0
commit
fbc8ab0fea
4
packages/embark-typings/.npmrc
Normal file
4
packages/embark-typings/.npmrc
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
engine-strict = true
|
||||||
|
package-lock = false
|
||||||
|
save-exact = true
|
||||||
|
scripts-prepend-node-path = true
|
10
packages/embark-typings/index.d.ts
vendored
Normal file
10
packages/embark-typings/index.d.ts
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import "./src/remix-debug-debugtest";
|
||||||
|
import "./src/solidity-parser-antlr";
|
||||||
|
|
||||||
|
export * from "./src/callbacks";
|
||||||
|
export * from "./src/contract";
|
||||||
|
export * from "./src/embark";
|
||||||
|
export * from "./src/embarkConfig";
|
||||||
|
export * from "./src/logger";
|
||||||
|
export * from "./src/maybe";
|
||||||
|
export * from "./src/plugins";
|
43
packages/embark-typings/package.json
Normal file
43
packages/embark-typings/package.json
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
{
|
||||||
|
"name": "@types/embark",
|
||||||
|
"private": true,
|
||||||
|
"version": "4.0.0-beta.0",
|
||||||
|
"author": "Iuri Matias <iuri.matias@gmail.com>",
|
||||||
|
"contributors": [],
|
||||||
|
"description": "TypeScript definitions for embark",
|
||||||
|
"homepage": "https://embark.status.im/",
|
||||||
|
"keywords": [
|
||||||
|
"blockchain",
|
||||||
|
"dapps",
|
||||||
|
"ethereum",
|
||||||
|
"ipfs",
|
||||||
|
"serverless",
|
||||||
|
"solc",
|
||||||
|
"solidity"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": "github:embark-framework/embark",
|
||||||
|
"main": "",
|
||||||
|
"types": "index",
|
||||||
|
"scripts": {
|
||||||
|
"ci": "npm run qa",
|
||||||
|
"lint": "tslint -c tslint.json index.d.ts \"src/**/*.ts\"",
|
||||||
|
"qa": "npm-run-all lint typecheck",
|
||||||
|
"reset": "npx rimraf node_modules",
|
||||||
|
"start": "npm run watch",
|
||||||
|
"typecheck": "tsc",
|
||||||
|
"watch": "npm run typecheck -- --preserveWatchOutput --watch"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/web3": "1.0.12",
|
||||||
|
"npm-run-all": "4.1.5",
|
||||||
|
"rimraf": "2.6.3",
|
||||||
|
"tslint": "5.11.0",
|
||||||
|
"typescript": "3.3.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.12.0",
|
||||||
|
"npm": ">=6.4.1",
|
||||||
|
"yarn": ">=1.12.3"
|
||||||
|
}
|
||||||
|
}
|
@ -8,15 +8,6 @@ export interface Events {
|
|||||||
setCommandHandler(name: string, callback: (options: any, cb: () => void) => void): void;
|
setCommandHandler(name: string, callback: (options: any, cb: () => void) => void): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Plugins {
|
|
||||||
getPluginsProperty(pluginType: string, property: string, sub_property?: string): any[];
|
|
||||||
plugins: Plugin[];
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Plugin {
|
|
||||||
name: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Embark {
|
export interface Embark {
|
||||||
events: Events;
|
events: Events;
|
||||||
registerAPICall: any;
|
registerAPICall: any;
|
@ -5,7 +5,12 @@ export interface Plugin {
|
|||||||
export interface Plugins {
|
export interface Plugins {
|
||||||
getPluginsFor(name: string): [Plugin];
|
getPluginsFor(name: string): [Plugin];
|
||||||
loadInternalPlugin(name: string, options: any): void;
|
loadInternalPlugin(name: string, options: any): void;
|
||||||
getPluginsProperty(prop: string, name: string): any[];
|
getPluginsProperty(pluginType: string, property: string, sub_property?: string): any[];
|
||||||
|
plugins: Plugin[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Plugin {
|
||||||
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CompilerPluginObject {
|
export interface CompilerPluginObject {
|
7
packages/embark-typings/tsconfig.json
Normal file
7
packages/embark-typings/tsconfig.json
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tsconfig.json",
|
||||||
|
"files": [
|
||||||
|
"index.d.ts"
|
||||||
|
],
|
||||||
|
"include": ["src/**/*"]
|
||||||
|
}
|
3
packages/embark-typings/tslint.json
Normal file
3
packages/embark-typings/tslint.json
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../tslint.json"
|
||||||
|
}
|
@ -196,7 +196,7 @@
|
|||||||
"rimraf": "2.6.3",
|
"rimraf": "2.6.3",
|
||||||
"sinon": "4.5.0",
|
"sinon": "4.5.0",
|
||||||
"tslint": "5.11.0",
|
"tslint": "5.11.0",
|
||||||
"typescript": "3.1.3"
|
"typescript": "3.3.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8.12.0",
|
"node": ">=8.12.0",
|
||||||
|
@ -3,7 +3,7 @@ import * as i18n from "i18n";
|
|||||||
import * as osLocale from "os-locale";
|
import * as osLocale from "os-locale";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
|
||||||
import { Maybe } from "../../../typings/maybe";
|
import { Maybe } from "embark";
|
||||||
|
|
||||||
enum LocalType {
|
enum LocalType {
|
||||||
Specified = "specified",
|
Specified = "specified",
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { each } from "async";
|
import { each } from "async";
|
||||||
|
import { Callback, Logger } from "embark";
|
||||||
import { NodeVM, NodeVMOptions } from "vm2";
|
import { NodeVM, NodeVMOptions } from "vm2";
|
||||||
import { Callback } from "../../../../typings/callbacks";
|
|
||||||
import { Logger } from "../../../../typings/logger";
|
|
||||||
|
|
||||||
const fs = require("../../fs");
|
const fs = require("../../fs");
|
||||||
const { recursiveMerge, isEs6Module } = require("../../../utils/utils");
|
const { recursiveMerge, isEs6Module } = require("../../../utils/utils");
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import {Embark} from "../../../typings/embark";
|
import {Embark} from "embark";
|
||||||
|
import {__} from "i18n";
|
||||||
import {dockerHostSwap} from "../../utils/host.js";
|
import {dockerHostSwap} from "../../utils/host.js";
|
||||||
import {findNextPort} from "../../utils/network";
|
import {findNextPort} from "../../utils/network";
|
||||||
import Server from "./server";
|
import Server from "./server";
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
import bodyParser from "body-parser";
|
import bodyParser from "body-parser";
|
||||||
import cors from "cors";
|
import cors from "cors";
|
||||||
|
import { Embark, Plugins } from "embark";
|
||||||
import express, { NextFunction, Request, Response } from "express";
|
import express, { NextFunction, Request, Response } from "express";
|
||||||
import proxy from "express-http-proxy";
|
import proxy from "express-http-proxy";
|
||||||
import expressWs from "express-ws";
|
import expressWs from "express-ws";
|
||||||
import findUp from "find-up";
|
import findUp from "find-up";
|
||||||
import helmet from "helmet";
|
import helmet from "helmet";
|
||||||
import * as http from "http";
|
import * as http from "http";
|
||||||
|
import {__} from "i18n";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import * as ws from "ws";
|
import * as ws from "ws";
|
||||||
import { Embark, Plugins } from "../../../typings/embark";
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import { embarkPath } from "../../core/fs";
|
import { embarkPath } from "../../core/fs";
|
||||||
|
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
import {Callback} from "../../../typings/callbacks";
|
import {Callback, CompilerPluginObject, Embark, Plugins} from "embark";
|
||||||
|
import {__} from "i18n";
|
||||||
|
|
||||||
const async = require("../../utils/async_extend.js");
|
const async = require("../../utils/async_extend.js");
|
||||||
import { Embark } from "../../../typings/embark";
|
|
||||||
import { CompilerPluginObject, Plugins } from "../../../typings/plugins";
|
|
||||||
|
|
||||||
class Compiler {
|
class Compiler {
|
||||||
private logger: any;
|
private logger: any;
|
||||||
|
@ -5,8 +5,9 @@ const utils = require("../../utils/utils");
|
|||||||
const EmbarkJS = require("embarkjs");
|
const EmbarkJS = require("embarkjs");
|
||||||
const IpfsApi = require("ipfs-api");
|
const IpfsApi = require("ipfs-api");
|
||||||
const stringify = require("json-stringify-safe");
|
const stringify = require("json-stringify-safe");
|
||||||
|
import { Embark, Events } from "embark";
|
||||||
|
import {__} from "i18n";
|
||||||
import Web3 from "web3";
|
import Web3 from "web3";
|
||||||
import { Embark, Events } from "../../../typings/embark";
|
|
||||||
import Suggestions from "./suggestions";
|
import Suggestions from "./suggestions";
|
||||||
|
|
||||||
type MatchFunction = (cmd: string) => boolean;
|
type MatchFunction = (cmd: string) => boolean;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
const fuzzySearch = require("../../utils/utils").fuzzySearch;
|
const fuzzySearch = require("../../utils/utils").fuzzySearch;
|
||||||
|
|
||||||
import { Embark, Events } from "../../../typings/embark";
|
import { Embark, Events } from "embark";
|
||||||
|
|
||||||
interface ContractsManager {
|
interface ContractsManager {
|
||||||
[key: string]: any;
|
[key: string]: any;
|
||||||
|
@ -2,8 +2,7 @@ import * as globule from "globule";
|
|||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import Web3Contract from "web3/eth/contract";
|
import Web3Contract from "web3/eth/contract";
|
||||||
|
|
||||||
import { Contract } from "../../../typings/contract";
|
import { Contract, Embark } from "embark";
|
||||||
import { Embark } from "../../../typings/embark";
|
|
||||||
import { removePureView } from "../../utils/solidity/code";
|
import { removePureView } from "../../utils/solidity/code";
|
||||||
import { ContractEnhanced } from "./contractEnhanced";
|
import { ContractEnhanced } from "./contractEnhanced";
|
||||||
import { coverageContractsPath } from "./path";
|
import { coverageContractsPath } from "./path";
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
import {__} from "i18n";
|
||||||
import DebuggerManager from "./debugger_manager";
|
import DebuggerManager from "./debugger_manager";
|
||||||
|
|
||||||
const NO_DEBUG_SESSION = __("No debug session active. Activate one with `debug`");
|
const NO_DEBUG_SESSION = __("No debug session active. Activate one with `debug`");
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import Ajv from "ajv";
|
import Ajv from "ajv";
|
||||||
|
import { Logger } from "embark";
|
||||||
import { Logger } from "../../../typings/logger";
|
import {__} from "i18n";
|
||||||
|
|
||||||
export enum Framework {
|
export enum Framework {
|
||||||
React = "react",
|
React = "react",
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
|
import { Embark } from "embark";
|
||||||
import Handlebars from "handlebars";
|
import Handlebars from "handlebars";
|
||||||
|
import {__} from "i18n";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
|
|
||||||
import { Embark } from "../../../../../typings/embark";
|
|
||||||
import { Builder } from "../../builder";
|
import { Builder } from "../../builder";
|
||||||
import { CommandOptions } from "../../commandOptions";
|
import { CommandOptions } from "../../commandOptions";
|
||||||
import { SmartContractsRecipe } from "../../smartContractsRecipe";
|
import { SmartContractsRecipe } from "../../smartContractsRecipe";
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
|
import { Contract, Embark } from "embark";
|
||||||
import Handlebars from "handlebars";
|
import Handlebars from "handlebars";
|
||||||
|
import {__} from "i18n";
|
||||||
import * as path from "path";
|
import * as path from "path";
|
||||||
import { ABIDefinition } from "web3/eth/abi";
|
import { ABIDefinition } from "web3/eth/abi";
|
||||||
|
|
||||||
import { Contract } from "../../../../../typings/contract";
|
|
||||||
import { Embark } from "../../../../../typings/embark";
|
|
||||||
import { Builder } from "../../builder";
|
import { Builder } from "../../builder";
|
||||||
import { CommandOptions } from "../../commandOptions";
|
import { CommandOptions } from "../../commandOptions";
|
||||||
import { SmartContractsRecipe } from "../../smartContractsRecipe";
|
import { SmartContractsRecipe } from "../../smartContractsRecipe";
|
||||||
@ -31,16 +30,19 @@ export class ReactBuilder implements Builder {
|
|||||||
public async build() {
|
public async build() {
|
||||||
await this.installDependencies();
|
await this.installDependencies();
|
||||||
|
|
||||||
return [].concat.apply([], Object.keys(this.description.data).map((contractName) => {
|
const arr: string[] = [];
|
||||||
const [indexCode, dappCode] = this.generateCodes(contractName);
|
return arr.concat(
|
||||||
if (indexCode && dappCode) {
|
...Object.keys(this.description.data).map((contractName) => {
|
||||||
const files = this.saveFiles(contractName, indexCode, dappCode);
|
const [indexCode, dappCode] = this.generateCodes(contractName);
|
||||||
this.updateEmbarkJson(contractName, files);
|
if (indexCode && dappCode) {
|
||||||
return files;
|
const files = this.saveFiles(contractName, indexCode, dappCode);
|
||||||
} else {
|
this.updateEmbarkJson(contractName, files);
|
||||||
return [];
|
return files;
|
||||||
}
|
} else {
|
||||||
}));
|
return [];
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateEmbarkJson(contractName: string, files: string[]) {
|
private updateEmbarkJson(contractName: string, files: string[]) {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import { Contract } from "../../../typings/contract";
|
import { Contract, Embark } from "embark";
|
||||||
import { Embark } from "../../../typings/embark";
|
|
||||||
import { CommandOptions, ContractLanguage, Framework } from "./commandOptions";
|
import { CommandOptions, ContractLanguage, Framework } from "./commandOptions";
|
||||||
import { SolidityBuilder } from "./contractLanguage/solidityBuilder";
|
import { SolidityBuilder } from "./contractLanguage/solidityBuilder";
|
||||||
import { ReactBuilder } from "./framework/reactBuilder";
|
import { ReactBuilder } from "./framework/reactBuilder";
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import Ajv from "ajv";
|
import Ajv from "ajv";
|
||||||
|
import { Logger } from "embark";
|
||||||
import { Logger } from "../../../typings/logger";
|
import {__} from "i18n";
|
||||||
import { schema } from "./schema";
|
import { schema } from "./schema";
|
||||||
|
|
||||||
const fs = require("../../core/fs");
|
const fs = require("../../core/fs");
|
||||||
|
@ -2,7 +2,7 @@ import { red } from "colors";
|
|||||||
import { performance, PerformanceObserver } from "perf_hooks";
|
import { performance, PerformanceObserver } from "perf_hooks";
|
||||||
import prettyMs from "pretty-ms";
|
import prettyMs from "pretty-ms";
|
||||||
|
|
||||||
import { Logger } from "../../../src/typings/logger";
|
import { Logger } from "embark";
|
||||||
|
|
||||||
const utils = require("./utils.js");
|
const utils = require("./utils.js");
|
||||||
const ora = require("ora");
|
const ora = require("ora");
|
||||||
@ -21,7 +21,7 @@ export default class LongRunningProcessTimer {
|
|||||||
private endMark: string;
|
private endMark: string;
|
||||||
private downloadComplete: string;
|
private downloadComplete: string;
|
||||||
private spinner!: any;
|
private spinner!: any;
|
||||||
private intOngoingDownload!: number;
|
private intOngoingDownload!: NodeJS.Timeout;
|
||||||
|
|
||||||
// backing variables
|
// backing variables
|
||||||
private _observer!: PerformanceObserver;
|
private _observer!: PerformanceObserver;
|
||||||
@ -116,7 +116,7 @@ export default class LongRunningProcessTimer {
|
|||||||
() => {
|
() => {
|
||||||
performance.mark(this.ongoingMark);
|
performance.mark(this.ongoingMark);
|
||||||
performance.measure(this.downloadOngoing, this.startMark, this.ongoingMark);
|
performance.measure(this.downloadOngoing, this.startMark, this.ongoingMark);
|
||||||
}, this.options.interval);
|
}, this.options.interval || 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public end() {
|
public end() {
|
||||||
|
1
packages/embark/src/typings/i18n/index.d.ts
vendored
1
packages/embark/src/typings/i18n/index.d.ts
vendored
@ -1 +0,0 @@
|
|||||||
declare function __(...values: string[]): string;
|
|
@ -1,20 +1,7 @@
|
|||||||
{
|
{
|
||||||
|
"extends": "../../tsconfig.json",
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"module": "commonjs",
|
|
||||||
"target": "es5",
|
|
||||||
"lib": ["es2017", "dom"],
|
|
||||||
"moduleResolution": "node",
|
|
||||||
"noEmit": true,
|
|
||||||
"strict": true,
|
|
||||||
"isolatedModules": true,
|
|
||||||
"esModuleInterop": true,
|
|
||||||
"typeRoots": ["node_modules/@types"],
|
|
||||||
"rootDir": ".",
|
|
||||||
"baseUrl": ".",
|
|
||||||
"paths": {
|
|
||||||
"*": ["./typings/*"]
|
|
||||||
},
|
|
||||||
"noImplicitThis": false
|
"noImplicitThis": false
|
||||||
},
|
},
|
||||||
"include": ["./src/**/*"]
|
"include": ["src/**/*"]
|
||||||
}
|
}
|
@ -1,17 +1,3 @@
|
|||||||
{
|
{
|
||||||
"defaultSeverity": "error",
|
"extends": "../../tslint.json"
|
||||||
"extends": [
|
|
||||||
"tslint:recommended"
|
|
||||||
],
|
|
||||||
"jsRules": {},
|
|
||||||
"rules": {
|
|
||||||
"max-line-length": [true, 200],
|
|
||||||
"interface-name": [true, "never-prefix"],
|
|
||||||
"member-ordering": [false],
|
|
||||||
"no-var-requires": false,
|
|
||||||
"no-empty": false,
|
|
||||||
"no-console": false,
|
|
||||||
"variable-name": ["allow-leading-underscore"]
|
|
||||||
},
|
|
||||||
"rulesDirectory": []
|
|
||||||
}
|
}
|
||||||
|
11
tsconfig.json
Normal file
11
tsconfig.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"isolatedModules": true,
|
||||||
|
"lib": ["ES2017"],
|
||||||
|
"module": "CommonJS",
|
||||||
|
"noEmit": true,
|
||||||
|
"strict": true,
|
||||||
|
"target": "ES2017"
|
||||||
|
}
|
||||||
|
}
|
17
tslint.json
Normal file
17
tslint.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"defaultSeverity": "error",
|
||||||
|
"extends": [
|
||||||
|
"tslint:recommended"
|
||||||
|
],
|
||||||
|
"jsRules": {},
|
||||||
|
"rules": {
|
||||||
|
"interface-name": [true, "never-prefix"],
|
||||||
|
"max-line-length": [true, 200],
|
||||||
|
"member-ordering": [false],
|
||||||
|
"no-empty": false,
|
||||||
|
"no-console": false,
|
||||||
|
"no-var-requires": false,
|
||||||
|
"variable-name": ["allow-leading-underscore"]
|
||||||
|
},
|
||||||
|
"rulesDirectory": []
|
||||||
|
}
|
@ -20819,10 +20819,10 @@ typedarray@^0.0.6:
|
|||||||
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
|
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
|
||||||
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
|
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
|
||||||
|
|
||||||
typescript@3.1.3:
|
typescript@3.3.1:
|
||||||
version "3.1.3"
|
version "3.3.1"
|
||||||
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.1.3.tgz#01b70247a6d3c2467f70c45795ef5ea18ce191d5"
|
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.3.1.tgz#6de14e1db4b8a006ac535e482c8ba018c55f750b"
|
||||||
integrity sha512-+81MUSyX+BaSo+u2RbozuQk/UWx6hfG0a5gHu4ANEM4sU96XbuIyAB+rWBW1u70c6a5QuZfuYICn3s2UjuHUpA==
|
integrity sha512-cTmIDFW7O0IHbn1DPYjkiebHxwtCMU+eTy30ZtJNBPF9j2O1ITu5XH2YnBeVRKWHqF+3JQwWJv0Q0aUgX8W7IA==
|
||||||
|
|
||||||
typewise-core@^1.2, typewise-core@^1.2.0:
|
typewise-core@^1.2, typewise-core@^1.2.0:
|
||||||
version "1.2.0"
|
version "1.2.0"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user