@dedot/codegen 0.0.1-alpha.4 → 0.0.1-alpha.6
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.
- package/cjs/generator/dirname.cjs +5 -0
- package/cjs/generator/dirname.mjs +10 -0
- package/cjs/generator/utils.js +4 -9
- package/cjs/packageInfo.js +1 -1
- package/generator/dirname.cjs +4 -0
- package/generator/dirname.d.cts +1 -0
- package/generator/dirname.d.mts +1 -0
- package/generator/dirname.mjs +6 -0
- package/generator/utils.d.ts +0 -1
- package/generator/utils.js +3 -7
- package/package.json +7 -7
- package/packageInfo.js +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.currentDirname = void 0;
|
|
4
|
+
const path_1 = require("path");
|
|
5
|
+
const url_1 = require("url");
|
|
6
|
+
const currentDirname = () => {
|
|
7
|
+
const __filename = (0, url_1.fileURLToPath)(import.meta.url);
|
|
8
|
+
return (0, path_1.dirname)(__filename);
|
|
9
|
+
};
|
|
10
|
+
exports.currentDirname = currentDirname;
|
package/cjs/generator/utils.js
CHANGED
|
@@ -26,12 +26,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.isReservedWord = exports.compileTemplate = exports.beautifySourceCode = exports.
|
|
29
|
+
exports.isReservedWord = exports.compileTemplate = exports.beautifySourceCode = exports.commentBlock = exports.TUPLE_TYPE_REGEX = exports.WRAPPER_TYPE_REGEX = void 0;
|
|
30
30
|
const fs = __importStar(require("fs"));
|
|
31
31
|
const handlebars_1 = __importDefault(require("handlebars"));
|
|
32
32
|
const path = __importStar(require("path"));
|
|
33
|
-
const process = __importStar(require("process"));
|
|
34
33
|
const prettier = __importStar(require("prettier"));
|
|
34
|
+
const dirname_1 = require("./dirname");
|
|
35
35
|
exports.WRAPPER_TYPE_REGEX = /^(\w+)<(.*)>$/;
|
|
36
36
|
exports.TUPLE_TYPE_REGEX = /^\[(.*)]$/;
|
|
37
37
|
const commentBlock = (...docs) => {
|
|
@@ -48,18 +48,13 @@ ${flatLines.map((line) => `* ${line.replaceAll(/\s+/g, ' ').trim()}`).join('\n')
|
|
|
48
48
|
}
|
|
49
49
|
};
|
|
50
50
|
exports.commentBlock = commentBlock;
|
|
51
|
-
const resolveFilePath = (relativePath) => {
|
|
52
|
-
relativePath = Array.isArray(relativePath) ? relativePath : [relativePath];
|
|
53
|
-
return path.resolve(process.cwd(), ...relativePath);
|
|
54
|
-
};
|
|
55
|
-
exports.resolveFilePath = resolveFilePath;
|
|
56
51
|
const beautifySourceCode = async (source) => {
|
|
57
|
-
const prettierOptions = await prettier.resolveConfig((0,
|
|
52
|
+
const prettierOptions = await prettier.resolveConfig(path.resolve((0, dirname_1.currentDirname)(), '../../../../.prettierrc.js'));
|
|
58
53
|
return prettier.format(source, { parser: 'babel-ts', ...prettierOptions });
|
|
59
54
|
};
|
|
60
55
|
exports.beautifySourceCode = beautifySourceCode;
|
|
61
56
|
const compileTemplate = (templateFileName) => {
|
|
62
|
-
const templateFilePath = (0,
|
|
57
|
+
const templateFilePath = path.resolve((0, dirname_1.currentDirname)(), `../templates/${templateFileName}`);
|
|
63
58
|
return handlebars_1.default.compile(fs.readFileSync(templateFilePath, 'utf8'));
|
|
64
59
|
};
|
|
65
60
|
exports.compileTemplate = compileTemplate;
|
package/cjs/packageInfo.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
exports.packageInfo = void 0;
|
|
5
|
-
exports.packageInfo = { name: '@dedot/codegen', version: '0.0.1-alpha.
|
|
5
|
+
exports.packageInfo = { name: '@dedot/codegen', version: '0.0.1-alpha.24' };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function currentDirname(): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export function currentDirname(): string;
|
package/generator/utils.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export declare const WRAPPER_TYPE_REGEX: RegExp;
|
|
2
2
|
export declare const TUPLE_TYPE_REGEX: RegExp;
|
|
3
3
|
export declare const commentBlock: (...docs: (string | string[])[]) => string;
|
|
4
|
-
export declare const resolveFilePath: (relativePath: string | string[]) => string;
|
|
5
4
|
export declare const beautifySourceCode: (source: string) => Promise<string>;
|
|
6
5
|
export declare const compileTemplate: (templateFileName: string) => HandlebarsTemplateDelegate<any>;
|
|
7
6
|
/**
|
package/generator/utils.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as fs from 'fs';
|
|
2
2
|
import handlebars from 'handlebars';
|
|
3
3
|
import * as path from 'path';
|
|
4
|
-
import * as process from 'process';
|
|
5
4
|
import * as prettier from 'prettier';
|
|
5
|
+
import { currentDirname } from './dirname';
|
|
6
6
|
export const WRAPPER_TYPE_REGEX = /^(\w+)<(.*)>$/;
|
|
7
7
|
export const TUPLE_TYPE_REGEX = /^\[(.*)]$/;
|
|
8
8
|
export const commentBlock = (...docs) => {
|
|
@@ -18,16 +18,12 @@ ${flatLines.map((line) => `* ${line.replaceAll(/\s+/g, ' ').trim()}`).join('\n')
|
|
|
18
18
|
`;
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
|
-
export const resolveFilePath = (relativePath) => {
|
|
22
|
-
relativePath = Array.isArray(relativePath) ? relativePath : [relativePath];
|
|
23
|
-
return path.resolve(process.cwd(), ...relativePath);
|
|
24
|
-
};
|
|
25
21
|
export const beautifySourceCode = async (source) => {
|
|
26
|
-
const prettierOptions = await prettier.resolveConfig(
|
|
22
|
+
const prettierOptions = await prettier.resolveConfig(path.resolve(currentDirname(), '../../../../.prettierrc.js'));
|
|
27
23
|
return prettier.format(source, { parser: 'babel-ts', ...prettierOptions });
|
|
28
24
|
};
|
|
29
25
|
export const compileTemplate = (templateFileName) => {
|
|
30
|
-
const templateFilePath =
|
|
26
|
+
const templateFilePath = path.resolve(currentDirname(), `../templates/${templateFileName}`);
|
|
31
27
|
return handlebars.compile(fs.readFileSync(templateFilePath, 'utf8'));
|
|
32
28
|
};
|
|
33
29
|
// TODO add more reserved words
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dedot/codegen",
|
|
3
|
-
"version": "0.0.1-alpha.
|
|
3
|
+
"version": "0.0.1-alpha.6+6fbf1fe",
|
|
4
4
|
"description": "Generate types",
|
|
5
5
|
"author": "Thang X. Vu <thang@coongcrafts.io>",
|
|
6
6
|
"homepage": "https://github.com/dedotdev/dedot/tree/main/packages/codegen",
|
|
@@ -16,12 +16,12 @@
|
|
|
16
16
|
"clean": "rm -rf ./dist && rm -rf ./tsconfig.tsbuildinfo ./tsconfig.build.tsbuildinfo"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@dedot/codecs": "0.0.1-alpha.
|
|
20
|
-
"@dedot/shape": "0.0.1-alpha.
|
|
21
|
-
"@dedot/specs": "0.0.1-alpha.
|
|
22
|
-
"@dedot/utils": "0.0.1-alpha.
|
|
19
|
+
"@dedot/codecs": "0.0.1-alpha.6+6fbf1fe",
|
|
20
|
+
"@dedot/shape": "0.0.1-alpha.6+6fbf1fe",
|
|
21
|
+
"@dedot/specs": "0.0.1-alpha.6+6fbf1fe",
|
|
22
|
+
"@dedot/utils": "0.0.1-alpha.6+6fbf1fe",
|
|
23
23
|
"@polkadot/util": "^12.6.2",
|
|
24
|
-
"dedot": "0.0.1-alpha.
|
|
24
|
+
"dedot": "0.0.1-alpha.6+6fbf1fe",
|
|
25
25
|
"handlebars": "^4.7.8",
|
|
26
26
|
"prettier": "^3.0.3"
|
|
27
27
|
},
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"directory": "dist"
|
|
31
31
|
},
|
|
32
32
|
"license": "Apache-2.0",
|
|
33
|
-
"gitHead": "
|
|
33
|
+
"gitHead": "6fbf1fe509c7c07569adc4c1cced998c809458e0",
|
|
34
34
|
"module": "./index.js",
|
|
35
35
|
"types": "./index.d.ts",
|
|
36
36
|
"exports": {
|
package/packageInfo.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// THIS FILE IS AUTO-GENERATED, DO NOT EDIT!
|
|
2
|
-
export const packageInfo = { name: '@dedot/codegen', version: '0.0.1-alpha.
|
|
2
|
+
export const packageInfo = { name: '@dedot/codegen', version: '0.0.1-alpha.24' };
|