diff --git a/.gitignore b/.gitignore index 6704566..adb2c19 100644 --- a/.gitignore +++ b/.gitignore @@ -80,7 +80,6 @@ typings/ # Nuxt.js build / generate output .nuxt -dist # Gatsby files .cache/ diff --git a/dist/src/index.d.ts b/dist/src/index.d.ts new file mode 100644 index 0000000..29d85df --- /dev/null +++ b/dist/src/index.d.ts @@ -0,0 +1,2 @@ +import "./type-extensions"; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/dist/src/index.d.ts.map b/dist/src/index.d.ts.map new file mode 100644 index 0000000..f0bd0cc --- /dev/null +++ b/dist/src/index.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAIA,OAAO,mBAAmB,CAAC"} \ No newline at end of file diff --git a/dist/src/index.js b/dist/src/index.js new file mode 100644 index 0000000..b71a18d --- /dev/null +++ b/dist/src/index.js @@ -0,0 +1,110 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +const config_1 = require("hardhat/config"); +const chokidar_1 = __importDefault(require("chokidar")); +require("./type-extensions"); +config_1.extendConfig((config, userConfig) => { + var _a; + let w = (_a = userConfig.watcher) !== null && _a !== void 0 ? _a : {}; + const normalizedWatcher = {}; + Object.entries(w).forEach(([name, task]) => { + var _a, _b, _c; + normalizedWatcher[name] = { + tasks: ((_a = task === null || task === void 0 ? void 0 : task.tasks) !== null && _a !== void 0 ? _a : []).map((t) => { + var _a; + if (typeof t === "string") { + return { + command: t, + params: {}, + }; + } + else { + return { + command: t.command, + params: (_a = t.params) !== null && _a !== void 0 ? _a : {}, + }; + } + }), + files: (_b = task.files) !== null && _b !== void 0 ? _b : [config.paths.sources], + verbose: (_c = task.verbose) !== null && _c !== void 0 ? _c : false, + }; + }); + config.watcher = normalizedWatcher; +}); +config_1.task("watch", "Start the file watcher") + .addPositionalParam("watcherTask", "watcher task to run (as defined in hardhat config)") + .setAction(async ({ watcherTask }, { run, tasks, config: { watcher, paths } }) => { + if (!(watcherTask in watcher)) { + console.log(`Watcher task "${watcherTask}" was not found in hardhat config.`); + process.exit(1); + } + const taskConfig = watcher[watcherTask]; + const logVerbose = (...messages) => { + if (taskConfig.verbose) + console.log(...messages); + }; + logVerbose("Starting file watcher", taskConfig.files); + const templateReplace = (value, pattern, replace) => { + if (Array.isArray(value)) { + return value.map(v => v.replace(pattern, replace)); + } + else if (typeof (value) == 'string') { + return value.replace(pattern, replace); + } + else { + return value; + } + }; + const paramsTemplateReplace = (params, pattern, replace) => { + const newParams = {}; + Object.keys(params).forEach(k => { + newParams[k] = templateReplace(params[k], pattern, replace); + }); + return newParams; + }; + // Validate tasks + taskConfig.tasks.forEach((task) => { + if (!(task.command in tasks)) { + console.log(`Watcher error: task "${task.command}" is not supported by hardhat runtime.`); + console.log(`Found tasks: ${JSON.stringify(Object.keys(tasks))}`); + process.exit(1); + } + }); + chokidar_1.default + .watch(taskConfig.files, { + ignoreInitial: true, + usePolling: true, + interval: 250, + }) + .on("change", async (path) => { + for (let i = 0; i < taskConfig.tasks.length; i++) { + const task = taskConfig.tasks[i]; + // Replace template pattern with the changed file + const newParams = paramsTemplateReplace(task.params, '{path}', path); + logVerbose(`Running task "${task.command}" with params ${JSON.stringify(newParams)}`); + try { + await run(task.command, newParams); + // This hack is required to allow running Mocha commands. Check out https://github.com/mochajs/mocha/issues/1938 for more details. + Object.keys(require.cache).forEach(function (key) { + if (key.startsWith(paths.tests)) { + delete require.cache[key]; + } + }); + } + catch (err) { + console.log(`Task "${task.command}" failed.`); + console.log(err); + } + } + }) + .on("error", (error) => { + console.log(`Watcher error: ${error}`); + process.exit(1); + }); + console.log("File watcher started."); + await new Promise((resolve) => setTimeout(resolve, 2000000000)); +}); +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/src/index.js.map b/dist/src/index.js.map new file mode 100644 index 0000000..1ba74b4 --- /d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IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,UAAU,GAAG;oBAC9C,IAAI,GAAG,CAAC,UAAU,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;wBAC/B,OAAO,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;qBAC3B;gBACH,CAAC,CAAC,CAAC;aACJ;YAAC,OAAO,GAAG,EAAE;gBACZ,OAAO,CAAC,GAAG,CAAC,SAAS,IAAI,CAAC,OAAO,WAAW,CAAC,CAAC;gBAC9C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;aAClB;SACF;IACH,CAAC,CAAC;SACD,EAAE,CAAC,OAAO,EAAE,CAAC,KAAY,EAAE,EAAE;QAC5B,OAAO,CAAC,GAAG,CAAC,kBAAkB,KAAK,EAAE,CAAC,CAAC;QACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEL,OAAO,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;IAErC,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AAClE,CAAC,CACF,CAAC"} \ No newline at end of file diff --git a/dist/src/type-extensions.d.ts b/dist/src/type-extensions.d.ts new file mode 100644 index 0000000..d85b69e --- /dev/null +++ b/dist/src/type-extensions.d.ts @@ -0,0 +1,32 @@ +import "hardhat/types/config"; +import "hardhat/types/runtime"; +declare module "hardhat/types/config" { + type HardhatTask = string | ExpandedHardhatTask; + type ExpandedHardhatTask = { + command: string; + params?: { + [key: string]: any; + }; + }; + type WatcherTask = { + tasks?: HardhatTask[]; + files?: string[]; + verbose?: boolean; + }; + interface HardhatUserConfig { + watcher?: { + [key: string]: WatcherTask; + }; + } + type WatcherConfig = { + [key: string]: { + tasks: Required[]; + files: string[]; + verbose: boolean; + }; + }; + interface HardhatConfig { + watcher: WatcherConfig; + } +} +//# sourceMappingURL=type-extensions.d.ts.map \ No newline at end of file diff --git a/dist/src/type-extensions.d.ts.map b/dist/src/type-extensions.d.ts.map new file mode 100644 index 0000000..1e5abf0 --- /dev/null +++ b/dist/src/type-extensions.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"type-extensions.d.ts","sourceRoot":"","sources":["../../src/type-extensions.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,uBAAuB,CAAC;AAE/B,OAAO,QAAQ,sBAAsB,CAAC;IACpC,KAAY,WAAW,GAAG,MAAM,GAAG,mBAAmB,CAAC;IAEvD,KAAY,mBAAmB,GAAG;QAChC,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE;YACP,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;SACpB,CAAC;KACH,CAAC;IAEF,KAAY,WAAW,GAAG;QACxB,KAAK,CAAC,EAAE,WAAW,EAAE,CAAC;QACtB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB,CAAC;IAGF,UAAiB,iBAAiB;QAChC,OAAO,CAAC,EAAE;YAAE,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAAA;SAAE,CAAC;KAC1C;IAED,KAAY,aAAa,GAAG;QAC1B,CAAC,GAAG,EAAE,MAAM,GAAG;YACb,KAAK,EAAE,QAAQ,CAAC,mBAAmB,CAAC,EAAE,CAAC;YACvC,KAAK,EAAE,MAAM,EAAE,CAAC;YAChB,OAAO,EAAE,OAAO,CAAC;SAClB,CAAC;KACH,CAAC;IAGF,UAAiB,aAAa;QAC5B,OAAO,EAAE,aAAa,CAAC;KACxB;CACF"} \ No newline at end of file diff --git a/dist/src/type-extensions.js b/dist/src/type-extensions.js new file mode 100644 index 0000000..8f9d70f --- /dev/null +++ b/dist/src/type-extensions.js @@ -0,0 +1,5 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +require("hardhat/types/config"); +require("hardhat/types/runtime"); +//# sourceMappingURL=type-extensions.js.map \ No newline at end of file diff --git a/dist/src/type-extensions.js.map b/dist/src/type-extensions.js.map new file mode 100644 index 0000000..ad58e0a --- /dev/null +++ b/dist/src/type-extensions.js.map @@ -0,0 +1 @@ +{"version":3,"file":"type-extensions.js","sourceRoot":"","sources":["../../src/type-extensions.ts"],"names":[],"mappings":";;AAAA,gCAA8B;AAC9B,iCAA+B"} \ No newline at end of file diff --git a/dist/test/fixture-projects/hardhat-project/hardhat.config.d.ts b/dist/test/fixture-projects/hardhat-project/hardhat.config.d.ts new file mode 100644 index 0000000..1f51f3e --- /dev/null +++ b/dist/test/fixture-projects/hardhat-project/hardhat.config.d.ts @@ -0,0 +1,5 @@ +import { HardhatUserConfig } from "hardhat/types"; +import "../../../src/index"; +declare const config: HardhatUserConfig; +export default config; +//# sourceMappingURL=hardhat.config.d.ts.map \ No newline at end of file diff --git a/dist/test/fixture-projects/hardhat-project/hardhat.config.d.ts.map b/dist/test/fixture-projects/hardhat-project/hardhat.config.d.ts.map new file mode 100644 index 0000000..42cae4b --- /dev/null +++ b/dist/test/fixture-projects/hardhat-project/hardhat.config.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"hardhat.config.d.ts","sourceRoot":"","sources":["../../../../test/fixture-projects/hardhat-project/hardhat.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAElD,OAAO,oBAAoB,CAAC;AAE5B,QAAA,MAAM,MAAM,EAAE,iBAUb,CAAC;AAEF,eAAe,MAAM,CAAC"} \ No newline at end of file diff --git a/dist/test/fixture-projects/hardhat-project/hardhat.config.js b/dist/test/fixture-projects/hardhat-project/hardhat.config.js new file mode 100644 index 0000000..1eb70ee --- /dev/null +++ b/dist/test/fixture-projects/hardhat-project/hardhat.config.js @@ -0,0 +1,16 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +require("../../../src/index"); +const config = { + solidity: "0.7.3", + defaultNetwork: "hardhat", + watcher: { + compilation: { + tasks: ["clean", { command: "compile", params: { quiet: true } }], + files: ["./contracts"], + verbose: true, + }, + }, +}; +exports.default = config; +//# sourceMappingURL=hardhat.config.js.map \ No newline at end of file diff --git a/dist/test/fixture-projects/hardhat-project/hardhat.config.js.map b/dist/test/fixture-projects/hardhat-project/hardhat.config.js.map new file mode 100644 index 0000000..c1ddd94 --- /dev/null +++ b/dist/test/fixture-projects/hardhat-project/hardhat.config.js.map @@ -0,0 +1 @@ +{"version":3,"file":"hardhat.config.js","sourceRoot":"","sources":["../../../../test/fixture-projects/hardhat-project/hardhat.config.ts"],"names":[],"mappings":";;AAEA,8BAA4B;AAE5B,MAAM,MAAM,GAAsB;IAChC,QAAQ,EAAE,OAAO;IACjB,cAAc,EAAE,SAAS;IACzB,OAAO,EAAE;QACP,WAAW,EAAE;YACX,KAAK,EAAE,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC;YACjE,KAAK,EAAE,CAAC,aAAa,CAAC;YACtB,OAAO,EAAE,IAAI;SACd;KACF;CACF,CAAC;AAEF,kBAAe,MAAM,CAAC"} \ No newline at end of file diff --git a/dist/test/helpers.d.ts b/dist/test/helpers.d.ts new file mode 100644 index 0000000..fda9064 --- /dev/null +++ b/dist/test/helpers.d.ts @@ -0,0 +1,11 @@ +import { HardhatRuntimeEnvironment } from "hardhat/types"; +declare module "mocha" { + interface Context { + hre: HardhatRuntimeEnvironment; + } +} +export declare function useEnvironment(fixtureProjectName: string): void; +export declare function sleep(ms: number): Promise; +export declare const readArtifactDir: (hre: HardhatRuntimeEnvironment) => string[]; +export declare const simulateFileChange: (dummyFile: string, fileToOverwrite?: string) => void; +//# sourceMappingURL=helpers.d.ts.map \ No newline at end of file diff --git a/dist/test/helpers.d.ts.map b/dist/test/helpers.d.ts.map new file mode 100644 index 0000000..904e019 --- /dev/null +++ b/dist/test/helpers.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../test/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,eAAe,CAAC;AAI1D,OAAO,QAAQ,OAAO,CAAC;IACrB,UAAU,OAAO;QACf,GAAG,EAAE,yBAAyB,CAAC;KAChC;CACF;AAED,wBAAgB,cAAc,CAAC,kBAAkB,EAAE,MAAM,QAUxD;AAED,wBAAgB,KAAK,CAAC,EAAE,EAAE,MAAM,oBAE/B;AAED,eAAO,MAAM,eAAe,QAAS,yBAAyB,KAAG,MAAM,EAGpE,CAAC;AAEJ,eAAO,MAAM,kBAAkB,cAClB,MAAM,mCAShB,CAAC"} \ No newline at end of file diff --git a/dist/test/helpers.js b/dist/test/helpers.js new file mode 100644 index 0000000..b14ab4d --- /dev/null +++ b/dist/test/helpers.js @@ -0,0 +1,26 @@ +"use strict"; +var __importDefault = (this && this.__importDefault) || function (mod) { + return (mod && mod.__esModule) ? mod : { "default": mod }; +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.simulateFileChange = exports.readArtifactDir = exports.sleep = exports.useEnvironment = void 0; +const plugins_testing_1 = require("hardhat/plugins-testing"); +const path_1 = __importDefault(require("path")); +const fs_1 = __importDefault(require("fs")); +function useEnvironment(fixtureProjectName) { + beforeEach("Loading hardhat environment", function () { + process.chdir(path_1.default.join(__dirname, "fixture-projects", fixtureProjectName)); + this.hre = require("hardhat"); + }); + afterEach("Resetting hardhat", function () { + plugins_testing_1.resetHardhatContext(); + }); +} +exports.useEnvironment = useEnvironment; +function sleep(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} +exports.sleep = sleep; +exports.readArtifactDir = (hre) => fs_1.default.readdirSync(path_1.default.join(hre.config.paths.artifacts, "contracts/Contract.sol")); +exports.simulateFileChange = (dummyFile, fileToOverwrite = "contracts/Contract.sol") => fs_1.default.copyFileSync(path_1.default.join(__dirname, `./dummyFiles/${dummyFile}`), path_1.default.join(__dirname, `./fixture-projects/hardhat-project/${fileToOverwrite}`)); +//# sourceMappingURL=helpers.js.map \ No newline at end of file diff --git a/dist/test/helpers.js.map b/dist/test/helpers.js.map new file mode 100644 index 0000000..b265012 --- /dev/null +++ b/dist/test/helpers.js.map @@ -0,0 +1 @@ +{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../test/helpers.ts"],"names":[],"mappings":";;;;;;AAAA,6DAA8D;AAE9D,gDAAwB;AACxB,4CAAoB;AAQpB,SAAgB,cAAc,CAAC,kBAA0B;IACvD,UAAU,CAAC,6BAA6B,EAAE;QACxC,OAAO,CAAC,KAAK,CAAC,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,kBAAkB,EAAE,kBAAkB,CAAC,CAAC,CAAC;QAE5E,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,mBAAmB,EAAE;QAC7B,qCAAmB,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC;AAVD,wCAUC;AAED,SAAgB,KAAK,CAAC,EAAU;IAC9B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC;AAFD,sBAEC;AAEY,QAAA,eAAe,GAAG,CAAC,GAA8B,EAAY,EAAE,CAC1E,YAAE,CAAC,WAAW,CACZ,cAAI,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,wBAAwB,CAAC,CAChE,CAAC;AAES,QAAA,kBAAkB,GAAG,CAChC,SAAiB,EACjB,eAAe,GAAG,wBAAwB,EAC1C,EAAE,CACF,YAAE,CAAC,YAAY,CACb,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,gBAAgB,SAAS,EAAE,CAAC,EACjD,cAAI,CAAC,IAAI,CACP,SAAS,EACT,sCAAsC,eAAe,EAAE,CACxD,CACF,CAAC"} \ No newline at end of file diff --git a/dist/test/project.test.d.ts b/dist/test/project.test.d.ts new file mode 100644 index 0000000..6fe7527 --- /dev/null +++ b/dist/test/project.test.d.ts @@ -0,0 +1,2 @@ +export {}; +//# sourceMappingURL=project.test.d.ts.map \ No newline at end of file diff --git a/dist/test/project.test.d.ts.map b/dist/test/project.test.d.ts.map new file mode 100644 index 0000000..483991c --- /dev/null +++ b/dist/test/project.test.d.ts.map @@ -0,0 +1 @@ +{"version":3,"file":"project.test.d.ts","sourceRoot":"","sources":["../../test/project.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/test/project.test.js b/dist/test/project.test.js new file mode 100644 index 0000000..2bba50b --- /dev/null +++ b/dist/test/project.test.js @@ -0,0 +1,33 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +// tslint:disable-next-line no-implicit-dependencies +const chai_1 = require("chai"); +const helpers_1 = require("./helpers"); +describe("Watcher tests", function () { + this.timeout(15000); + helpers_1.useEnvironment("hardhat-project"); + beforeEach(async function () { + await this.hre.run("clean"); + }); + it("Watch contracts and clean + compile on change", async function () { + try { + helpers_1.simulateFileChange("Contract.sol"); + this.hre.run("watch", { watcherTask: "compilation" }); + await helpers_1.sleep(1000); + console.log("=========== Simulating file change ============="); + helpers_1.simulateFileChange("Contract2.sol"); + await helpers_1.sleep(2000); + const dir = helpers_1.readArtifactDir(this.hre); + chai_1.expect(dir).to.contain("TestContract2.json"); + console.log("=========== Simulating file change ============="); + helpers_1.simulateFileChange("Contract3.sol"); + await helpers_1.sleep(2000); + const dir2 = helpers_1.readArtifactDir(this.hre); + chai_1.expect(dir2).to.contain("TestContract3.json"); + } + catch (error) { + chai_1.assert.fail(error.message); + } + }); +}); +//# sourceMappingURL=project.test.js.map \ No newline at end of file diff --git a/dist/test/project.test.js.map b/dist/test/project.test.js.map new file mode 100644 index 0000000..a3def35 --- /dev/null +++ b/dist/test/project.test.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