@cosmwasm/ts-codegen 1.2.0 → 1.3.0

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.
@@ -1,32 +1,8 @@
1
1
  import { join, dirname, basename, extname } from "path";
2
- import { readFileSync, existsSync } from "fs";
3
2
  import { sync as mkdirp } from "mkdirp";
4
3
  import { writeContentToFile } from "../utils/files";
4
+ import { readAndParsePackageJson } from "../utils/package";
5
5
  import { contractContextBase, contractContextBaseShortHandCtor, contractsContextTSX, } from "../helpers";
6
- // need to search due to the dist/ folder and src/, etc.
7
- function findPackageJson(currentDir) {
8
- const filePath = join(currentDir, 'package.json');
9
- // Check if package.json exists in the current directory
10
- if (existsSync(filePath)) {
11
- return filePath;
12
- }
13
- // Get the parent directory
14
- const parentDir = dirname(currentDir);
15
- // If reached the root directory, package.json is not found
16
- if (parentDir === currentDir) {
17
- throw new Error('package.json not found in any parent directory');
18
- }
19
- // Recursively look in the parent directory
20
- return findPackageJson(parentDir);
21
- }
22
- function readAndParsePackageJson() {
23
- // Start searching from the current directory
24
- const pkgPath = findPackageJson(__dirname);
25
- // Read and parse the package.json
26
- const str = readFileSync(pkgPath, 'utf8');
27
- const pkg = JSON.parse(str);
28
- return pkg;
29
- }
30
6
  const pkg = readAndParsePackageJson();
31
7
  const version = process.env.NODE_ENV === "test" ? "latest" : pkg.version;
32
8
  const header = `/**
@@ -1,4 +1,5 @@
1
- import pkg from '../../package.json';
1
+ import { readAndParsePackageJson } from "./package";
2
+ const pkg = readAndParsePackageJson();
2
3
  const version = process.env.NODE_ENV === 'test' ? 'latest' : pkg.version;
3
4
  export const header = `/**
4
5
  * This file was automatically generated by ${pkg.name}@${version}.
@@ -0,0 +1,26 @@
1
+ import { join, dirname } from "path";
2
+ import { readFileSync, existsSync } from "fs";
3
+ // need to search due to the dist/ folder and src/, etc.
4
+ function findPackageJson(currentDir) {
5
+ const filePath = join(currentDir, 'package.json');
6
+ // Check if package.json exists in the current directory
7
+ if (existsSync(filePath)) {
8
+ return filePath;
9
+ }
10
+ // Get the parent directory
11
+ const parentDir = dirname(currentDir);
12
+ // If reached the root directory, package.json is not found
13
+ if (parentDir === currentDir) {
14
+ throw new Error('package.json not found in any parent directory');
15
+ }
16
+ // Recursively look in the parent directory
17
+ return findPackageJson(parentDir);
18
+ }
19
+ export function readAndParsePackageJson() {
20
+ // Start searching from the current directory
21
+ const pkgPath = findPackageJson(__dirname);
22
+ // Read and parse the package.json
23
+ const str = readFileSync(pkgPath, 'utf8');
24
+ const pkg = JSON.parse(str);
25
+ return pkg;
26
+ }
@@ -2,35 +2,11 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createHelpers = void 0;
4
4
  const path_1 = require("path");
5
- const fs_1 = require("fs");
6
5
  const mkdirp_1 = require("mkdirp");
7
6
  const files_1 = require("../utils/files");
7
+ const package_1 = require("../utils/package");
8
8
  const helpers_1 = require("../helpers");
9
- // need to search due to the dist/ folder and src/, etc.
10
- function findPackageJson(currentDir) {
11
- const filePath = (0, path_1.join)(currentDir, 'package.json');
12
- // Check if package.json exists in the current directory
13
- if ((0, fs_1.existsSync)(filePath)) {
14
- return filePath;
15
- }
16
- // Get the parent directory
17
- const parentDir = (0, path_1.dirname)(currentDir);
18
- // If reached the root directory, package.json is not found
19
- if (parentDir === currentDir) {
20
- throw new Error('package.json not found in any parent directory');
21
- }
22
- // Recursively look in the parent directory
23
- return findPackageJson(parentDir);
24
- }
25
- function readAndParsePackageJson() {
26
- // Start searching from the current directory
27
- const pkgPath = findPackageJson(__dirname);
28
- // Read and parse the package.json
29
- const str = (0, fs_1.readFileSync)(pkgPath, 'utf8');
30
- const pkg = JSON.parse(str);
31
- return pkg;
32
- }
33
- const pkg = readAndParsePackageJson();
9
+ const pkg = (0, package_1.readAndParsePackageJson)();
34
10
  const version = process.env.NODE_ENV === "test" ? "latest" : pkg.version;
35
11
  const header = `/**
36
12
  * This file and any referenced files were automatically generated by ${pkg.name}@${version}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmwasm/ts-codegen",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "@cosmwasm/ts-codegen converts your CosmWasm smart contracts into dev-friendly TypeScript classes so you can focus on shipping code.",
5
5
  "author": "Dan Lynch <pyramation@gmail.com>",
6
6
  "homepage": "https://github.com/cosmwasm/ts-codegen",
@@ -63,5 +63,5 @@
63
63
  "smart contracts",
64
64
  "codegen"
65
65
  ],
66
- "gitHead": "e105783253da5352163be0bb2fc4ac65b027fa94"
66
+ "gitHead": "f7230f9ef06a3fe5a7e3f64302abc1f726c7bf33"
67
67
  }
package/utils/header.js CHANGED
@@ -1,14 +1,12 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.header = void 0;
7
- const package_json_1 = __importDefault(require("../../package.json"));
8
- const version = process.env.NODE_ENV === 'test' ? 'latest' : package_json_1.default.version;
4
+ const package_1 = require("./package");
5
+ const pkg = (0, package_1.readAndParsePackageJson)();
6
+ const version = process.env.NODE_ENV === 'test' ? 'latest' : pkg.version;
9
7
  exports.header = `/**
10
- * This file was automatically generated by ${package_json_1.default.name}@${version}.
8
+ * This file was automatically generated by ${pkg.name}@${version}.
11
9
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
12
- * and run the ${package_json_1.default.name} generate command to regenerate this file.
10
+ * and run the ${pkg.name} generate command to regenerate this file.
13
11
  */
14
12
  \n`;
@@ -0,0 +1 @@
1
+ export declare function readAndParsePackageJson(): any;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.readAndParsePackageJson = void 0;
4
+ const path_1 = require("path");
5
+ const fs_1 = require("fs");
6
+ // need to search due to the dist/ folder and src/, etc.
7
+ function findPackageJson(currentDir) {
8
+ const filePath = (0, path_1.join)(currentDir, 'package.json');
9
+ // Check if package.json exists in the current directory
10
+ if ((0, fs_1.existsSync)(filePath)) {
11
+ return filePath;
12
+ }
13
+ // Get the parent directory
14
+ const parentDir = (0, path_1.dirname)(currentDir);
15
+ // If reached the root directory, package.json is not found
16
+ if (parentDir === currentDir) {
17
+ throw new Error('package.json not found in any parent directory');
18
+ }
19
+ // Recursively look in the parent directory
20
+ return findPackageJson(parentDir);
21
+ }
22
+ function readAndParsePackageJson() {
23
+ // Start searching from the current directory
24
+ const pkgPath = findPackageJson(__dirname);
25
+ // Read and parse the package.json
26
+ const str = (0, fs_1.readFileSync)(pkgPath, 'utf8');
27
+ const pkg = JSON.parse(str);
28
+ return pkg;
29
+ }
30
+ exports.readAndParsePackageJson = readAndParsePackageJson;