create-ponder 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,12 +21,15 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
21
21
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
22
22
  var create_ponder_exports = {};
23
23
  module.exports = __toCommonJS(create_ponder_exports);
24
- var import_commander = require("commander");
24
+ var import_cac = require("cac");
25
25
  var import_node_path = __toESM(require("node:path"));
26
- const program = new import_commander.Command();
27
- program.description("Create a Ponder project").option("--dir <string>", "Path to directory for generated Ponder project").option("--from-subgraph <string>", "Path to subgraph directory").option("--from-etherscan <string>", "Link to etherscan contract page").option("--etherscan-api-key <string>", "Etherscan API key");
28
- program.parse();
29
- const options = program.opts();
26
+ var import_package = __toESM(require("../../package.json"));
27
+ const cli = (0, import_cac.cac)(import_package.default.name).version(import_package.default.version).usage("[options]").help().option("--dir [path]", "Path to directory for generated project").option("--from-subgraph [path]", "Path to subgraph directory").option("--from-etherscan [url]", "Link to etherscan contract page").option("--etherscan-api-key [key]", "Etherscan API key");
28
+ const parsed = cli.parse(process.argv);
29
+ const options = parsed.options;
30
+ if (options.help) {
31
+ process.exit(0);
32
+ }
30
33
  if (options.fromSubgraph && options.fromEtherscan) {
31
34
  throw new Error(`Cannot specify more than one "--from" option:
32
35
  --from-subgraph
@@ -34,7 +37,7 @@ if (options.fromSubgraph && options.fromEtherscan) {
34
37
  `);
35
38
  }
36
39
  const validatedOptions = {
37
- ponderRootDir: import_node_path.default.resolve(options.dir ? options.dir : "ponder"),
40
+ ponderRootDir: import_node_path.default.resolve(".", options.dir ? options.dir : "ponder"),
38
41
  fromSubgraph: options.fromSubgraph,
39
42
  fromEtherscan: options.fromEtherscan,
40
43
  etherscanApiKey: options.etherscanApiKey
package/dist/index.js CHANGED
@@ -36,16 +36,16 @@ __export(src_exports, {
36
36
  run: () => run,
37
37
  });
38
38
  module.exports = __toCommonJS(src_exports);
39
- var import_chalk = __toESM(require("chalk"));
40
39
  var import_ethers = require("ethers");
41
40
  var import_node_child_process = require("node:child_process");
42
41
  var import_node_fs = require("node:fs");
43
42
  var import_node_path = __toESM(require("node:path"));
43
+ var import_picocolors = __toESM(require("picocolors"));
44
44
  var import_prettier = __toESM(require("prettier"));
45
- var import_fromBasic = require("./fromBasic");
46
- var import_fromEtherscan = require("./fromEtherscan");
47
- var import_fromSubgraph = require("./fromSubgraph");
48
45
  var import_detectPackageManager = require("./helpers/detectPackageManager");
46
+ var import_basic = require("./templates/basic");
47
+ var import_etherscan = require("./templates/etherscan");
48
+ var import_subgraph = require("./templates/subgraph");
49
49
  const run = async (options) => {
50
50
  const { ponderRootDir } = options;
51
51
  (0, import_node_fs.mkdirSync)(
@@ -59,18 +59,18 @@ const run = async (options) => {
59
59
  let ponderConfig;
60
60
  if (options.fromSubgraph) {
61
61
  console.log(
62
- import_chalk.default.bold.cyanBright("[create-ponder] ") +
62
+ import_picocolors.default.cyan("[create-ponder] ") +
63
63
  `Bootstrapping from subgraph`
64
64
  );
65
- ponderConfig = (0, import_fromSubgraph.fromSubgraph)(options);
65
+ ponderConfig = (0, import_subgraph.fromSubgraph)(options);
66
66
  } else if (options.fromEtherscan) {
67
67
  console.log(
68
- import_chalk.default.bold.cyanBright("[create-ponder] ") +
68
+ import_picocolors.default.cyan("[create-ponder] ") +
69
69
  `Bootstrapping from Etherscan`
70
70
  );
71
- ponderConfig = await (0, import_fromEtherscan.fromEtherscan)(options);
71
+ ponderConfig = await (0, import_etherscan.fromEtherscan)(options);
72
72
  } else {
73
- ponderConfig = (0, import_fromBasic.fromBasic)(options);
73
+ ponderConfig = (0, import_basic.fromBasic)(options);
74
74
  }
75
75
  ponderConfig.sources.forEach((source) => {
76
76
  const abi = (0, import_node_fs.readFileSync)(
@@ -132,7 +132,7 @@ const run = async (options) => {
132
132
  const finalPonderConfig = `const { graphqlPlugin } = require("@ponder/graphql");
133
133
 
134
134
  /**
135
- * @type {import('@ponder/ponder').PonderConfig}
135
+ * @type {import('@ponder/core').PonderConfig}
136
136
  */
137
137
  const ponderConfig = {
138
138
  plugins: [graphqlPlugin()],
@@ -171,14 +171,14 @@ module.exports = ponderConfig;`;
171
171
  "codegen": "ponder codegen"
172
172
  },
173
173
  "dependencies": {
174
- "@ponder/ponder": "latest",
174
+ "@ponder/core": "latest",
175
175
  "@ponder/graphql": "latest"
176
176
  },
177
177
  "devDependencies": {
178
178
  "ethers": "^5.6.9"
179
179
  },
180
180
  "engines": {
181
- "node": "16",
181
+ "node": ">=16.0.0 <19.0.0"
182
182
  }
183
183
  }
184
184
  `;
@@ -244,7 +244,7 @@ databases:
244
244
  import_prettier.default.format(renderYaml, { parser: "yaml" })
245
245
  );
246
246
  console.log(
247
- import_chalk.default.bold.cyanBright("[create-ponder] ") +
247
+ import_picocolors.default.cyan("[create-ponder] ") +
248
248
  `Installing using ${packageManager}`
249
249
  );
250
250
  (0, import_node_child_process.execSync)(`${packageManager} install`, {
@@ -252,8 +252,7 @@ databases:
252
252
  stdio: "inherit",
253
253
  });
254
254
  console.log(
255
- import_chalk.default.bold.cyanBright("[create-ponder] ") +
256
- `Generating types`
255
+ import_picocolors.default.cyan("[create-ponder] ") + `Generating types`
257
256
  );
258
257
  (0, import_node_child_process.execSync)(
259
258
  `${packageManager} run --silent codegen`,
@@ -263,9 +262,9 @@ databases:
263
262
  }
264
263
  );
265
264
  console.log(
266
- import_chalk.default.bold.cyanBright("[create-ponder] ") +
267
- import_chalk.default.bold.greenBright("Done! ") +
268
- `To get started: ${import_chalk.default.bold.yellowBright(
265
+ import_picocolors.default.cyan("[create-ponder] ") +
266
+ import_picocolors.default.green("Done! ") +
267
+ `To get started: ${import_picocolors.default.yellow(
269
268
  `cd ${import_node_path.default.relative(
270
269
  ".",
271
270
  ponderRootDir
@@ -31,11 +31,11 @@ var __toESM = (mod, isNodeMode, target) => (
31
31
  );
32
32
  var __toCommonJS = (mod) =>
33
33
  __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
- var fromBasic_exports = {};
35
- __export(fromBasic_exports, {
34
+ var basic_exports = {};
35
+ __export(basic_exports, {
36
36
  fromBasic: () => fromBasic,
37
37
  });
38
- module.exports = __toCommonJS(fromBasic_exports);
38
+ module.exports = __toCommonJS(basic_exports);
39
39
  var import_node_fs = require("node:fs");
40
40
  var import_node_path = __toESM(require("node:path"));
41
41
  var import_prettier = __toESM(require("prettier"));
@@ -31,16 +31,16 @@ var __toESM = (mod, isNodeMode, target) => (
31
31
  );
32
32
  var __toCommonJS = (mod) =>
33
33
  __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
- var fromEtherscan_exports = {};
35
- __export(fromEtherscan_exports, {
34
+ var etherscan_exports = {};
35
+ __export(etherscan_exports, {
36
36
  fromEtherscan: () => fromEtherscan,
37
37
  });
38
- module.exports = __toCommonJS(fromEtherscan_exports);
38
+ module.exports = __toCommonJS(etherscan_exports);
39
39
  var import_node_fs = require("node:fs");
40
40
  var import_node_path = __toESM(require("node:path"));
41
41
  var import_node_fetch = __toESM(require("node-fetch"));
42
42
  var import_prettier = __toESM(require("prettier"));
43
- var import_getEtherscanChainId = require("./helpers/getEtherscanChainId");
43
+ var import_getEtherscanChainId = require("../helpers/getEtherscanChainId");
44
44
  const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
45
45
  const fromEtherscan = async (options) => {
46
46
  const { ponderRootDir } = options;
@@ -31,16 +31,16 @@ var __toESM = (mod, isNodeMode, target) => (
31
31
  );
32
32
  var __toCommonJS = (mod) =>
33
33
  __copyProps(__defProp({}, "__esModule", { value: true }), mod);
34
- var fromSubgraph_exports = {};
35
- __export(fromSubgraph_exports, {
34
+ var subgraph_exports = {};
35
+ __export(subgraph_exports, {
36
36
  fromSubgraph: () => fromSubgraph,
37
37
  });
38
- module.exports = __toCommonJS(fromSubgraph_exports);
38
+ module.exports = __toCommonJS(subgraph_exports);
39
39
  var import_node_fs = require("node:fs");
40
40
  var import_node_path = __toESM(require("node:path"));
41
41
  var import_yaml = require("yaml");
42
- var import_getGraphProtocolChainId = require("./helpers/getGraphProtocolChainId");
43
- var import_validateGraphProtocolSource = require("./helpers/validateGraphProtocolSource");
42
+ var import_getGraphProtocolChainId = require("../helpers/getGraphProtocolChainId");
43
+ var import_validateGraphProtocolSource = require("../helpers/validateGraphProtocolSource");
44
44
  const fromSubgraph = (options) => {
45
45
  if (!options.fromSubgraph) {
46
46
  throw new Error(`Internal error: fromSubgraph undefined`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-ponder",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Tool to bootstrap a Ponder project",
5
5
  "license": "MIT",
6
6
  "author": "olias.eth",
@@ -24,11 +24,11 @@
24
24
  "dependencies": {
25
25
  "@ethersproject/abi": "^5.6.4",
26
26
  "@ethersproject/providers": "^5.6.8",
27
- "chalk": "4",
28
- "commander": "^9.4.0",
27
+ "cac": "^6.7.14",
29
28
  "ethers": "^5.6.9",
30
29
  "execa": "5",
31
30
  "node-fetch": "^2.6.7",
31
+ "picocolors": "^1.0.0",
32
32
  "prettier": "^2.6.2",
33
33
  "yaml": "^2.1.1"
34
34
  },
@@ -1,54 +0,0 @@
1
- "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if ((from && typeof from === "object") || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, {
15
- get: () => from[key],
16
- enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable,
17
- });
18
- }
19
- return to;
20
- };
21
- var __toCommonJS = (mod) =>
22
- __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
- var getPackageManager_exports = {};
24
- __export(getPackageManager_exports, {
25
- getPackageManager: () => getPackageManager,
26
- });
27
- module.exports = __toCommonJS(getPackageManager_exports);
28
- var import_child_process = require("child_process");
29
- function getPackageManager() {
30
- try {
31
- const userAgent = process.env.npm_config_user_agent;
32
- if (userAgent) {
33
- if (userAgent.startsWith("yarn")) {
34
- return "yarn";
35
- } else if (userAgent.startsWith("pnpm")) {
36
- return "pnpm";
37
- }
38
- }
39
- try {
40
- (0, import_child_process.execSync)("yarn --version", { stdio: "ignore" });
41
- return "yarn";
42
- } catch {
43
- (0, import_child_process.execSync)("pnpm --version", { stdio: "ignore" });
44
- return "pnpm";
45
- }
46
- } catch {
47
- return "npm";
48
- }
49
- }
50
- // Annotate the CommonJS export names for ESM import in node:
51
- 0 &&
52
- (module.exports = {
53
- getPackageManager,
54
- });